akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cassert>
#include<random>
#include<fstream>
#include<chrono>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define pii          pair<int,int>
#define vi           vector<int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define VR46         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);ifstream fin("ip.txt");ofstream fout("op.txt");
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;

const int N = 3e3 + 5;
int n, m, dp[N][N];
string s, t;

int REC(int p, int q)
{
    if( p>=n || q>=m )
        return 0;
    if( dp[p][q]!=-1 )
        return dp[p][q];
    int ans = 0;
    ans = max( ans, REC( p+1, q ) );
    ans = max( ans, REC( p, q+1 ) );
    ans = max( ans, REC( p+1, q+1 ) + ( s[p]==t[q] ) );
    dp[p][q] = ans;
    return ans;
}

string ans = "";
void retrace(int p, int q)
{
    if( p>=n || q>=m )
        return;
    if( dp[p][q] == dp[p+1][q] )
        retrace( p+1, q );
    else if( dp[p][q] == dp[p][q+1] )
        retrace( p, q+1 );
    else
    {
        if( s[p]==t[q] )
            ans += s[p];
        retrace( p+1, q+1 );
    }
}

signed main()
{
    
    {
        cin >> s >> t;
        n = s.length();
        m = t.length();
        mem( dp, -1 );
        REC( 0, 0 );
        retrace( 0, 0 );
        cout << ans << endl;
    }
}


Measured memory_bytes: 71168
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int H, W;
vector< string > maze;
vector< vector<bool> > done;
vector< vs32 > dis;

void bfs(int sy, int sx)
{
    queue<pair<int, int>> q;
    if (maze[sy][sx] == '.')
    {
        q.push(make_pair(sx, sy));
    }
    dis[sy][sx] = 0;
    done[sy][sx] = true;

    while (!q.empty())
    {
        auto p = q.front(); q.pop();
        int x = p.first, y = p.second;
        if (x > 0 && !done[y][x - 1] && maze[y][x - 1] == '.')
        {
            dis[y][x - 1] = dis[y][x] + 1;
            done[y][x - 1] = true;
            q.push(make_pair(x - 1, y));
        }
        if (x < W - 1 && !done[y][x + 1] && maze[y][x + 1] == '.')
        {
            dis[y][x + 1] = dis[y][x] + 1;
            done[y][x + 1] = true;
            q.push(make_pair(x + 1, y));
        }
        if (y > 0 && !done[y - 1][x] && maze[y - 1][x] == '.')
        {
            dis[y - 1][x] = dis[y][x] + 1;
            done[y - 1][x] = true;
            q.push(make_pair(x, y - 1));
        }
        if (y < H - 1 && !done[y + 1][x] && maze[y + 1][x] == '.')
        {
            dis[y + 1][x] = dis[y][x] + 1;
            done[y + 1][x] = true;
            q.push(make_pair(x, y + 1));
        }
    }
}

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

    cin >> H >> W;
    maze.resize(H);
    done.resize(H, vector<bool>(W, false));
    dis.resize(H, vs32(W));
    rep (i, H) cin >> maze[i];

    int ans = 0;
    rep (i, H)
    {
        rep (j, W)
        {
            rep (y, H)
            {
                rep (x, W)
                {
                    done[y][x] = false;
                    dis[y][x] = 1e9;
                }
            }
            bfs(i, j);
            rep (k, H)
            {
                rep (l, W)
                {
                    if (dis[k][l] == 1e9) continue;
                    ans = MAX(ans, dis[k][l]);
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int a,b,c;
  cin>>a>>b>>c;
  rep(i,10){
    c=c*a-b;
    cout<<c<<endl;
  }
}


Measured memory_bytes: 256
s = input()
def shrink(char, s):
    i = 0
    while len(set(s)) != 1:
        i += 1
        s = ''.join([s[i] if s[i+1] != char else s[i+1] for i in range(len(s)-1)])
    return i
print(min([shrink(c, s) for c in set(s)]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Hn=0,Hn1=0;
  bool check=true;
  cin >> N;
  for(int i=0;i<N;i++){
      cin >> Hn1;
      if(Hn1==Hn)
      Hn=Hn1;
      else if(Hn1>Hn)
      Hn=Hn1-1;
      else{
          check=false;
          break;
      }

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

}
 

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

using namespace std;

#define MAX 100010

class Union_Find{
public:
  int par[MAX],rank[MAX],size[MAX],gnum;
  Union_Find(int N){
    gnum = N;
    for(int i = 0 ; i < N ; i++){
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

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

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y){ return; }
    if(rank[x] < rank[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      size[x] += size[y];
      if(rank[x] == rank[y]){
        rank[x]++;
      }
    }
    gnum--;
  }

  bool same(int x,int y){
    return find(x) == find(y);
  }

  int getSize(int x){
    return size[find(x)];
  }

  int groups(){
    return gnum;
  }
};

int main(){
  int N,M,Q,a,b;
  cin >> N >> M;
  Union_Find uf(N);
  for(int i = 0 ; i < M ; i++){
    cin >> a >> b;
    uf.unite(a,b);
  }
  cin >> Q;
  while(Q--){
    cin >> a >> b;
    cout << (uf.same(a,b) ? "yes" : "no") << endl;
  }
  return 0;
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int n , a[ N ] , b[ N ];

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        cin >> n;
        LL ans = 0;
        for( int i = 1; i <= n + 1; i++ ) cin >> a[i];
        for( int i = 1; i <= n; i++ ) cin >> b[i];
        for( int i = 1; i <= n; i++ ) {
                ans += min( a[i] , b[i] );
                b[i] -= min( a[i] , b[i] );
                ans += min( a[i+1] , b[i] );
                a[i+1] -= min( a[i+1] , b[i] );
        }
        cout << ans << endl;
        return 0;
}









Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    string s = "";
    getline(cin, s);

    int n = s.size();
    for (int i = 0; i < n - 4; ++i)
    {
        string t = s.substr(i, 5);
        if (t == "apple")
            s.replace(s.begin() + i, s.begin() + i + 5, "peach");
        if (t == "peach")
            s.replace(s.begin() + i, s.begin() + i + 5, "apple");
    }
    cout << s << endl;
    return 0;
}


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

typedef long long ll;

int main()
{
    ll i,j;
    ll a,b,k;
    cin >> a >> b >> k;
    if(k <= a){
        cout << a-k << endl;
        cout << b << endl;
    }else if(k <= a+b){
        cout << 0 << endl;
        cout << b-(k-a) << endl;
    }else{
        cout << 0 << endl;
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	if(std::abs(a - b) < std::abs(a - c)) printf("A\n");
	else printf("B\n");
	return 0;
}


Measured memory_bytes: 256
from math import ceil
n=int(input())
a=[int(i) for i in input().split()]
s=sum(a)
th=ceil(s/2)
l=0
r=0
k=0
for i in range(n):
    k+=a[i]
    if k >= th:
        l=k-(s-k)
        break

k=0
for i in range(n-1, -1, -1):
    k+=a[i]
    if k >= th:
        r=k-(s-k)
        break

print(min(l,r))

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

string parse(const string &A, const string &B, int la, int ra, int lb, int rb){
  if(abs(ra-la) < 5 || abs(rb-lb) < 5) return "";
  int t = 0, ra_ = -1, rb_ = -1;
  for(int i = la; i < ra; ++i){
    if(A[i] == '(') ++t;
    if(A[i] == ')') --t;
    if(!t){
      ra_ = i;
      break;
    }
  }
  t = 0;
  for(int i = lb; i < rb; ++i){
    if(B[i] == '(') ++t;
    if(B[i] == ')') --t;
    if(!t){
      rb_ = i;
      break;
    }
  }

  int va = -1, vb = -1, la_ = ra_+1, lb_ = rb_+1;
  if(A.at(la_) == '['){
    ++la_;
    va = 0;
    while(A.at(la_) >= '0' && A.at(la_) <= '9'){
      va *= 10;
      va += A.at(la_) - '0';
      ++la_;
    }
    ++la_;
  }
  if(B.at(lb_) == '['){
    ++lb_;
    vb = 0;
    while(B.at(lb_) >= '0' && B.at(lb_) <= '9'){
      vb *= 10;
      vb += B.at(lb_) - '0';
      ++lb_;
    }
    ++lb_;
  }
  string ret = "(" + parse(A,B,la+1,ra_-1,lb+1,rb_-1) + ")";
  if(va >= 0 && vb >= 0) ret += "[" + to_string(va+vb) + "]";
  ret += "(" + parse(A,B,la_+1,ra-1,lb_+1,rb-1) + ")";
  return ret;
}

int main(){
  string A, B;
  cin >> A >> B;
  cout << parse(A,B,0,A.length(),0,B.length()) << endl;
  return 0;
}



Measured memory_bytes: 3304
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int x;
    cin>>x;
    
    if(x>=2000){
        cout<<1<<endl;
        return 0;
    }
    int i=100,j=5;
    vi allowed;
    for(int k=i;k<=i+j;){
        allowed.pb(k);
        if(k==i+j){
            i += 100;
            j += 5;
            k = i;
        }
        else    k++;
        if(k==2000) break;
    }
    //for(int i=0;i<allowed.size();i++)
    //    cout<<allowed[i]<<" ";
    //cout<<endl;
    if(binary_search(all(allowed), x))  cout<<1<<endl;
    else                                cout<<0<<endl;
    return 0;
}



Measured memory_bytes: 3636
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353

n = 6000

fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod


def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod

def h(n, r):
    return comb(n + r - 1, r - 1)

k, n = LI()
for i in range(2, 2 * k + 1):
    ret = 0
    m = min(i // 2, (k - (i + 1) // 2 + 1))
    if i % 2:
        for j in range(m + 1):
            ret += comb(m, j) * pow(2, j, mod) * h(n - j, k - m * 2 + j)
    else:
        for j in range(m + 1):
            if j:
                ret += comb(m - 1, j - 1) * pow(2, j - 1, mod) * h(n - j, k - m * 2 + j)
                ret += comb(m - 1, j) * pow(2, j, mod) * h(n - j, k - m * 2 + 1 + j)
            else:
                ret += comb(m, j) * pow(2, j, mod) * h(n - j, k - m * 2 + 1 + j)
    print(ret % mod)



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin>>n;
    bool ans=false;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if(n==i*j)
            {
                ans=true;
                break;
            }
        }
        if(ans) break;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,m;
int main(){
	cin>>n>>m;
	int x,bwl=0;
	for(int i=1;i<=m;++i){
		scanf("%d",&x);
		bwl+=x;
	}
	cout<<(bwl<=n ? n-bwl : -1)<<endl;
	return 0;
}




Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    static int open[] = new int[10];
    static int ans = Integer.MIN_VALUE;
    static int n;
    static int f[][];
    static Scanner sc;

    static int p[][];
    static boolean first = true;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        n = sc.nextInt();
        f = new int[n][10];
        /*
         * for (int i = 0; i < n; i++) { f[i] = new int[10]; }
         */
        // 店番号 曜日 時間
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                f[i][j] = sc.nextInt();
            }
        }
        p = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                p[i][j] = sc.nextInt();
            }
        }
        // 入力終了
        DFS(0);
        System.out.println(ans);
    }

    public static void DFS(int pos) {
        if (pos >= 10) {
            return;
        }
        open[pos] = 0;

        func();

        DFS(pos + 1);
        open[pos] = 1;
        func();
        DFS(pos + 1);

    }

    // ansの書き換え
    public static void func() {
        int opencnt = 0;
        for (int i = 0; i < 10; i++) {
            if (open[i] == 0) {
                opencnt++;
            }
        }
        if (opencnt == 10) {
            return;
        }
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < 10; j++) {
                if (open[j] == 0) {
                    continue;
                } else {
                    if (f[i][j] == 1) {
                        cnt++;
                    }
                }
            }
            tmp += p[i][cnt];
        }
        ans = Math.max(ans, tmp);
    }
}


Measured memory_bytes: 27472
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N+2);
    A[0] = 0;
    A[N+1] = 0;
    int sum = 0;
    for(int i=1; i<=N; i++){
        cin >> A[i];
        sum += abs(A[i] - A[i-1]);
    }
    sum += abs(A[N]);

    for(int i=1; i<=N; i++)
        cout << sum - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]) << endl;

    return 0;
}


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

typedef pair<int, int> PR;

int main()
{
	PR tm;
	
	

	int fln=0;

	int cnt=0;

	bool onefl[500 + 10] = { 0 };
	bool fl[500 + 10] = { 0 };

	int n, m;

	int i;

	while (cin >> n >> m, n != 0 && m != 0)
	{
		vector < PR > flend;

		for (i = 0; i < m; i++)
		{
			cin >> tm.first >> tm.second;

			if (min(tm.first, tm.second) == 1)
			{
				onefl[max(tm.first, tm.second)] = true;
				fl[max(tm.first, tm.second)] = true;
			}
			else
			{
				flend.push_back(tm);
				fln++;
			}
		}

		for (i = 0; i < fln; i++)
		{
			if (onefl[flend[i].first])
			{
				fl[flend[i].second] = true;
			}
			else if (onefl[flend[i].second])
			{
				fl[flend[i].first] = true;
			}
		}

		for (i = 2; i <= 500; i++)
		{
			if (fl[i])
			{
				cnt++;
			}
		}

		cout << cnt << endl;

		memset(onefl, 0, sizeof(onefl));
		memset(fl, 0, sizeof(fl));
		cnt = 0;
		fln = 0;
	}

	return 0;
}

Measured memory_bytes: 3204
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include <cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#pragma comment(linker, "/STACK:880999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<pll, ll> ppll;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll settled = 400007;

int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	//freopen("qual.in", "r", stdin);
	//freopen("qual.out", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vector<ll> a(n, 0), b(n, 0);
	forn(i, 0, n)
		cin >> a[i];
	forn(i, 0, n)
		cin >> b[i];
	vector<ll> store;
	ll need = 0;
	ll co = 0;
	forn(i, 0, n)
	{
		if (a[i] > b[i])
			store.push_back(-(a[i] - b[i]));
		if (b[i] > a[i])
		{
			need += b[i] - a[i];
			co++;
		}
	}
	sort(store.begin(), store.end());
	forn(i, 1, store.size())
		store[i] += store[i - 1];
	if (need == 0)
	{
		cout << 0;
		exit(0);
	}
	if (store.size() == 0 || need > -store.back())
	{
		cout << -1;
		exit(0);
	}
	ll point = 0;
	while (store[point] + need > 0)
		point++;
	cout << co + point + 1;

	return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  string s; cin >>s;
  int n = s.size();
  ll res = 0;

  for (int bit=0; bit<(1<<n-1); bit++){
    int digit = 0;
    for (int i=0; i<n; i++){
      if (i != 0) if (bit & (1<<(i-1))) digit = 0;
      ll buf = (int)(s.at(n-1-i) - '0') * powerM(10LL, (ll)digit);
      res += buf;
      digit++;
    }
  }
  cout <<res <<endl;
}

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

int main() {
  ll A, B = 0;
  string S;
  cin >> A >> S;

  B += (int)(S[0] - '0') * 100 + (int)(S[2] - '0') * 10 + (int)(S[3] - '0');
  ll ans = A * B;
  ans /= 100;

  cout << ans << endl;
}

Measured memory_bytes: 3568
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c] <- getIntList
  print $ maximum [(b + c - a), 0]


Measured memory_bytes: 3688
S = input()
T = input()

SS = [s for s in S]
SS_set = list(set(SS))
CS = []
for c in SS_set:
  C_idx_in_S = [i for i, x in enumerate(SS) if x==c]
  if len(C_idx_in_S) > 1:
    CS.append(C_idx_in_S)

TT = [t for t in T]
TT_set = list(set(TT))
CT = []
for c in TT_set:
  C_idx_in_T = [i for i, x in enumerate(TT) if x==c]
  if len(C_idx_in_T) > 1:
    CT.append(C_idx_in_T)

if len(CS) == len(CT):
  for i in CS:
    if i in CT:
      continue
    else:
      print("No")
      break
  else:
    print("Yes")
else:
  print("No")

Measured memory_bytes: 22744
#include <bits/stdc++.h>
using namespace std;
typedef long long				ll;
typedef pair<int,int >			pii;
#define V						vector
#define SYNC					ios_base::sync_with_stdio(0);cin.tie(0);
#define rep(i,b)				for(int i=0;i<b;i++)
#define repn(i,n)				for(int i=1;i<=n;i++)
#define ALL(x)					(x).begin(),(x).end()
#define fi						first
#define se						second
#define pb						push_back
#define dzx						cerr<<"here";
const ll MOD=1e9+7,INF=9e18;
const int inf=2e9;
/* Equinox */
int a[100001];
int32_t main(){SYNC
	int n,k;
	int m=0;
	cin>>n>>k;
	int g=0;
	rep(i,n){
		cin>>a[i];
		m=max(a[i],m);
		g=__gcd(g,a[i]);
	}
	if(k%g==0 && m>=k){
		cout<<"POSSIBLE";
	}
	else
		cout<<"IMPOSSIBLE";
	return 0;
}

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

int main() {
  string Ans;
  int A; cin >>A;
  int B; cin >>B;
  Ans=(A*B)%2==0 ? "Even" : "Odd";
  cout << Ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

int main(){
	map<int,int> mp;
	int a;
	while(cin>>a){
		mp[a]++;
	}
	int ans=0;
	for(int i=0;i<101;i++){
		int b=mp[i];
		ans=max(ans,b);
	}
	
	for(int i=0;i<101;i++){
		if(mp[i]==ans)cout<<i<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 1000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e5+10;
const double eps=1e-6;



int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif

	double N,h,n,w;
	int temp;
	cin>>N;
	for(double i=1;i<=3500;i++){
		for(double j=1;j<=3500;j++){
			double t=(N*i*j)/(4*j*i-N*i-N*j);
			if(t<=0)
				continue;	
			temp=t;
			if(temp==t){
				printf("%.0lf %.0lf %.0lf",t,i,j);
				return 0;
			}
		}
	}

    return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

int main()
{
    _fastio
    ll n,tk=1000,st=0;
    cin>>n;
    ll ar[100];
    for1(i,n)
    {
        cin>>ar[i];
    }
    
        for1(i,n-1)
        {
            if(ar[i]>ar[i+1] && st!=0)
            {
                tk=tk+(st*ar[i]);
                st=0;
            }
            else if(ar[i]<ar[i+1] && tk>=ar[i])
            {
                ll nw=tk/ar[i];
                st+=nw;
                tk=tk-(nw*ar[i]);
            }
        }
        if(st!=0)
            tk=tk+(st*ar[n]);
        cout<<tk<<en;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main() {
	char str[19];
	scanf("%[^\n]", &str);
	for ( int a = 0; a < 19; a++){
		if(str[a] == ','){
			printf(" ");
		}
		else{
			printf("%c", str[a]);
		}
	}
	return 0;
}


Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    int ans = 1;
    // 0-no 1-up 2-down
    int nud = 0;
    int cnt = 0;
    cin >> cnt;
    REP(i,N-1) {
        int a;
        cin >> a;

        if (nud == 0) {
            if (cnt < a) nud = 1;
            else if (cnt > a) nud = 2;
        }
        
        if (nud == 1) {
            if (cnt > a) {
                ans++;
                nud = 0;
            }
        }
        if (nud == 2) {
            if (cnt < a) {
                ans++;
                nud = 0;
            }
        }
        cnt = a;
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace atcoder;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> x(n), y(n);
    
    for (int i = 0; i < n; ++i) {
        int y0;
        std::cin >> x[i] >> y0;
        --x[i];
        --y0;
        y[x[i]] = y0;
    }
    
    std::vector<int> ans(n);
    
    for (int i = 0, j; i < n; i = j) {
        int mn = y[i];
        j = i + 1;
        while (j < n - mn) {
            mn = std::min(mn, y[j]);
            ++j;
        }
        for (int k = i; k < j; ++k)
            ans[k] = j - i;
    }
    
    for (int i = 0; i < n; ++i)
        std::cout << ans[x[i]] << "\n";
    
    return 0;
}

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

int main() {
   int N;int Sum=0;int m=0;
   cin>>N;
   int H=N;
   for(int i=0;i<8;i++){
       Sum+=N%10;
       N=N/10;
  }if(H%Sum==0){
       cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
 }
}

Measured memory_bytes: 256
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh.sort(key=lambda x: x[2], reverse=True)

x1, y1, h1 = xyh[0]
for X, Y in product(range(101), range(101)):
    H = h1 + abs(x1-X) + abs(y1-Y)
    if all([max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]]):
        print(X, Y, H)
        break

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
int a,i;
double b=0,c,d;
scanf("%d\n",&a);
d=a;
for(i=0;i<a;i++){
scanf("%lf\n",&c);
b=b+c/d;
}
a=b;
printf("%d\n",a);
return 0;
}



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

int func(string s, string t) {
  int ans = 0;
  for (char c = 'a'; c <= 'z'; c++) {
    bool founds = false, foundt = false;
    for (int i = 0; i < s.length(); i++) {
      if (s.at(i) == c) {
        founds = true;
      }
    }
    for (int i = 0; i < t.length(); i++) {
      if (t.at(i) == c) {
        foundt = true;
      }
    }
    if (founds && foundt) ans++;
  }
  return ans;
}

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int tmp = func(S.substr(0, i), S.substr(i));
    ans = max(ans, tmp);
  }

  cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
//const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

int main() {
	ll H, W, A, B;

	cin >> H >> W >> A >> B;


	ll k = -1, s = -1;
	rep(i, H+1) {
		rep(j, W+1) {

			if ((W - j) * B + j * (H - B) == (H - i) * A + (W - A) * i) {

				k = i, s = j;
				break;
			}

		}
	}


	if (s == -1) {
		cout << "No" << endl;
		return 0;
	}

	rep(i, H) {
		rep(j, W) {

			if (i < B && j < W - A)
				cout << 1;
			else if (i >= B && j >= W - A)
				cout << 1;
			else
				cout << 0;

		}

		
		cout << '\n';
	}



	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int k, s;
    cin >> k >> s;
    int cnt=0;
      for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
          int z = s-(i+j);
          //cout << 'z' << i << j << z << endl;
          if(k<z) continue;
          if(z<0) break;
          cnt+=1;
        }
      }
      cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    stack<int> st;
    int i, s;
    int cnt = 0;
    while (cin >> n >> x && (n > 0 || x > 0)) {
        st = stack<int>();
        i = 1; s = 0;
        cnt = 0;
        if (x == 0) {
            cout << 0 << "\n";
            continue;
        }
        while (i<=n) {
            if (st.size()<3 && s+i <= x) {
                st.push(i);
                s += i;
                if (st.size()==3 && s==x)
                    cnt++;
            }
            if (s >= x) {
                i = st.top()+1; s -= st.top(); st.pop();
            }
            else {
                i++;
            }
            while (i > n && st.size() > 0) {
                i = st.top()+1; s -= st.top(); st.pop();
            }
        }
        cout << cnt << "\n";
    }
}

Measured memory_bytes: 3128
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int [] arr = new int [11000];
		long sum = 0;
		for(int i = 0;i<num;i++){
			arr[i] = sc.nextInt();
			sum = (long)arr[i]+sum;
		}
		int buffer;
		for(int i = 0; i<num-1;i++){
			if(arr[i]>arr[i+1]){
				buffer = arr[i];
				arr[i] = arr[i+1];
				arr[i+1] = buffer;
			}
		}
		int max = arr[num-1];

		for(int i=num-1;i>0;i--){
			if(arr[i]<arr[i-1]){
				buffer = arr[i];
				arr[i] = arr[i-1];
				arr[i-1] = buffer;
				
			}
		}
		int min = arr[0];
	    System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 42124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
int ans;

int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		int h;
		cin >> h;
		if(h >= K) ans++;
	}
	cout << ans  << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=1e7+5,mod=998244353;
int n,a,b,fact[N<<1],inv[N<<1],ans;
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline int sub(CI x,CI y)
{
	int t=x-y; return t<0?t+mod:t;
}
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
	for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
inline void init(CI n)
{
	RI i; for (fact[0]=i=1;i<=n;++i) fact[i]=1LL*fact[i-1]*i%mod;
	for (inv[n]=quick_pow(fact[n]),i=n-1;~i;--i) inv[i]=1LL*inv[i+1]*(i+1)%mod;
}
inline int C(CI n,CI m)
{
	if (n<m) return 0; return 1LL*fact[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	RI i; scanf("%d%d%d",&n,&a,&b); if (!b) return puts("1"),0;
	for (init(n<<1),i=0;i<=n-b&&i<=a;++i)
	{
		int ret=sub(C(b-1+i,b-1),C(b-1+i,b));
		if (i==n-b) inc(ans,i==a?ret:0); else inc(ans,1LL*ret*C(n-b-i-1+a-i,a-i)%mod);
	}
	return printf("%d",ans),0;
}

Measured memory_bytes: 156416
function Main(input) {
	input = input.split("");
	for(var i=0;i<input.length;i++){
      //console.log(input,i)
		if(input[i]=="B"){
			input.splice(i,1);
			i--;
			if(input[i]>=0){
				input.splice(i,1);
				i--;
			}
		}
	}
console.log(input.join(""))
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

int pow2(int x, int n) {
  if (n == 0) return 1;
  if (n & 1) return x * pow(x, n - 1);
  int h = pow(x, n / 2);
  return h * h;
}

int c(int n) {return pow2(2, max(0, n - 1));}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  long long res = 0;
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      res += stoll(s.substr(l, r - l + 1)) * c(l) * c(n - 1 - r);
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define mp make_pair
#define fi first
#define se second
typedef pair<int, int> pii;
const int MAXN = 500;
int N, M;
int add(int x, int y) {return (x + y) % M;}
int mul(int x, int y) {return 1LL*x*y % M;}
int sub(int x, int y) {return add(x, M-y);}
int f[MAXN + 5][MAXN + 5]; pii a[MAXN + 5];
int solve(int t) {
	int cnt1 = 0, cnt2 = 0;
	f[0][0] = 1;
	for(int i=0;i<2*N;i++) {
		if( a[i].se == 0 ) {
			for(int j=0;j<=cnt2;j++)
				f[i+1][j] = mul(f[i][j], a[i].fi - (cnt1 + j) + 1);
			cnt1++;
		}
		else {
			f[i+1][0] = 0;
			for(int j=0;j<=cnt2;j++)
				f[i+1][j+1] = mul(f[i][j], a[i].fi - (cnt1 + j) + 1);
			for(int j=0;j<=cnt2;j++)
				f[i+1][j] = add(f[i+1][j], mul(f[i][j], a[i].se - (N + cnt2 - j + t) + 1));
			cnt2++;
		}
	}
	return f[2*N][t];
}
int main() {
	scanf("%d%d", &N, &M);
	for(int i=0;i<N;i++) {
		a[i].fi = 0, a[i].se = 2*N - 1;
		while( a[i].fi*a[i].fi + i*i < N*N ) a[i].fi++; a[i].fi--; 
		while( a[i].se*a[i].se + i*i > 4*N*N ) a[i].se--;
	}
	for(int i=N;i<2*N;i++) {
		a[i].fi = 2*N - 1, a[i].se = 0;
		while( a[i].fi*a[i].fi + i*i > 4*N*N ) a[i].fi--;
	}
	sort(a, a + 2*N);
	int ans = 0;
	for(int i=N;i>=0;i--)
		ans = sub(solve(i), ans);
	printf("%d\n", ans);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
const int MAX = 510000;
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() {
    COMinit();
    ll N,M;
    cin >>N>>M;
    ll ans=1;
    const auto &res = prime_factorize(M);
    for (auto p : res) {
        ans = (ans*COM(N+p.second-1,p.second))%mod;
    }

    
    cout << ans << endl;


    return 0;
    

}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    for(i = 0;i < n;++i){
        cin >> b.at(i);
    }
    ll tmp = 0;
    for(i = 0;i < n;++i){
        if(a.at(i) == b.at(i)) continue;
        else if(a.at(i) > b.at(i)){
            tmp += 2*(a.at(i) - b.at(i));
        }else{
            tmp -= (b.at(i) - a.at(i))/2*2;
        }
    }
    if(tmp <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3740
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    x = []
    for i in a:
        if i % 2 == 0:
            if not(i % 3 == 0 or i % 5 == 0):
                print("DENIED")
                return
    print("APPROVED")
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
# innefficient but lowest to AC sol.
n, k = map(int, input().split())
houses = [int(x) for x in input().split()]
houses.sort()

diffList = []

for index, pos in enumerate(houses):
    diffList.append( (pos - houses[index-1]) % n)

m = max(diffList)

print(n - max(diffList))

Measured memory_bytes: 26436
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(30);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);



    int n, d;
    cin >> d >> n;
    cout << (n == 100 ? "101" : to_string(n)) << string(2 * d, '0');


}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main (){
	char d[14], e[14], f[14];
	scanf ("%s %s %s", &d, &e, &f);
		if ( d[strlen(d) - 1] == e[0] && e[strlen(e) - 1] == f[0]){
			puts ("YES\n");
		}else {
			puts ("NO\n");
		}
	return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>

int main(){
    int n,i,M[45];
    
    scanf("%d",&n);
    
    M[0]=M[1]=1;
    for(i=2;i<=n;i++){
        M[i]=M[i-2]+M[i-1];
    }
    printf("%d\n",M[n]);
    return 0;
}



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

int main(void){
  int N,n;
  cin>>N;
  int a[N+5];
  for(int i=0;i<=N;i++){
    a[i]=1;
  }
  for(int i=1;i<=N;i++){
    n=i;
    for(int j=2;j<=N;j++){
      while(n%j==0){
        if(n%j==0){
          a[j]+=1;
          n=n/j;
        }
      }
    }        
  }
  long long int ans=1;
  for(int i=1;i<=N;i++){
    ans*=a[i];
    ans=ans%1000000007;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  string s;
  cin>>s;
  ll sum=0;
  rep(i,len(s)){
    if(s[i]=='B') sum++;
  }
  ll ans=0;
  rep(i,len(s)){
    if(s[i]=='B'){
      ans+=len(s)-sum-i;
      sum--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int t[200000] = {};
int main() {
	in(ll, N);
	loop(i, N) {
		in(ll, a);
		++t[a];
		++t[a + 1];
		++t[a + 2];
	}
	out(*max_element(t, t + 100005));
	return 0;
}


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

int main() {
  int n; cin>>n;
  vector<int> l(n);
  rep(i, 0, n) cin>>l[i];
  
  sort(l.begin(), l.end(), greater<ll>());
  ll sum=0;
  rep(i, 0, n-2) {
    rep(j, i+1, n-1) {
      if (l[i]>=l[j]+l[j+1]) break;
      rep(k, j+1, n) {
        if (l[i]<l[j]+l[k]) sum++;
        else break;
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


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

int main(){
  int N,h,tmp,ans;
  cin >>N;
  tmp = 0;
  ans = 0;
  
  for(int i=0;i<N;i++){
    cin >>h;
    if(tmp < h) ans += h - tmp;
    tmp = h;
  }
  
  cout << ans << endl;
}

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

int main() {

  long long int y[2], m[2], d[2], ans[2] = {};

  long long int p[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

  for ( long long int i = 0; i < 2; i++ ) {

    cin >> y[i] >> m[i] >> d[i];
    if ( i == 0 && d[i] == 13 ) d[i]--;

    ans[i] += ( ( y[i] - 1 ) / 400 ) * 688;

    long long int cnt = 1;

    for ( long long int fy = 1 + ( y[i] - 1 ) / 400 * 400; fy <= y[i]; fy++ ) {
      for ( long long int fm = 1; ( fy < y[i] || fm <= m[i] ); fm++ ) {
	if ( fm > 12 ) break;
	if ( fy == y[i] && fm == m[i] && d[i] < 13 ) break;
	if ( cnt == 0 ) ans[i]++;
	cnt = ( cnt + p[ fm-1 ] ) % 7;
	if ( fm == 2 ) {
	  long long int k = 0;
	  if ( ( fy % 4 ) == 0 ) k = 1;
	  if ( ( fy % 100 ) == 0 ) k = 0;
	  if ( ( fy % 400 ) == 0 ) k = 1;
	  cnt = ( cnt + k ) % 7;
	}
      }
    }

  }

  cout << ans[1] - ans[0] << endl;

  return 0;

}


Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int s,w;
    cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe");

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    vector<double> A(N);
    REP(i,0,N){
        cin >> A[i];
    }

    double mother=0,child=1.0,tmp=1.0;
    REP(i,0,N){
        child*=A[i];
        tmp=1.0;
        REP(j,0,N){
            if(i==j)continue;
            tmp*=A[j];
        }
        mother+=tmp;
    }
    printf("%f\n",child/mother);
}

Measured memory_bytes: 256