akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0;i<3;i++){
        if(s.at(i)==t.at(i)) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define ll long long int
#define eb emplace_back
#define F first
#define S second

int main(){_
	double a,b,c;
	while(cin>>a>>b>>c)
	{
		cout<<int(c*ceil(a/b))<<"\n";
	}

	return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll a,b;cin>>a>>b;
    ll ans=max(a+b,max(a-b,a*b));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  string S;
  string SS="CODEFESTIVAL2016";
  cin>>S;
  int cnt=0;
  FOR(i,0,16){
    if(S[i]!=SS[i]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys,itertools
def input():
    return sys.stdin.readline()[:-1]

X,Y = map(int,input().split(' '))
cnt = 0
if X==3:
    cnt += 100000
elif X==2:
    cnt += 200000
elif X==1:
    cnt += 300000

if Y==3:
    cnt += 100000
elif Y==2:
    cnt += 200000
elif Y==1:
    if X==1:
        cnt += 400000
    cnt += 300000
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

int main() {
    int  yymm;
    cin >> yymm;
    int y = yymm/100;
    int m = yymm%100;
    bool ym = false;
    bool my = false;

    if (1 <= m && m <= 12) {
        ym = true;
    }
    if (1 <= y && y <= 12) {
        my = true;
    }
    if (ym && my) {
        cout << "AMBIGUOUS" << endl;
    } else if (ym) {
        cout << "YYMM" << endl;
    } else if (my) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long mod=1e9+7;
std::map<long long,long long>dp;
long long solve(long long x){
	return (dp[x])?dp[x]:dp[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
int main(){
	long long n;
	dp[0]=1,dp[1]=2;
	scanf("%lld",&n);
	printf("%lld\n",solve(n));
	return 0;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ');
  const a = Number(s[0]);
  const b = Number(s[1]);
  const c = Number(s[2]);
  const d = Number(s[3]);

  const left  = a + b;
  const right = c + d;

  let ans = '';
  if (left > right)   ans = 'Left';
  if (left < right)   ans = 'Right';
  if (left === right) ans = 'Balanced';

  console.log(ans);
}

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


Measured memory_bytes: 21956
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

int main() {
     int a,A,b,B;
     cin>>a>>A>>b>>B;
     cout<<b-(B-A)<<' '<<B+(b-a)<<' '<<a-(B-A)<<' '<<A+(b-a)<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(R: int, G: int, B: int, N: int):
    
    res = 0
    for r in range(N+1): 
        if r*R > N:
            break
        for g in range(N+1): 
            rgcnt = r*R + g*G 
            if rgcnt > N:
                break
            if (N-rgcnt) % B == 0:
                res += 1

    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
//using namespace std;
//#define SZ(a) ((int)(a).size())
//#define PB push_back
//#define MP make_pair
//const int maxn = 200009;
//const int MOD = 1e9 + 7;
//vector<int> V[maxn];
//int64_t SUM[maxn << 2], LZ[maxn << 2];
//void upd(int rt, int l, int r, int ll, int rr, int v) {
  //if (ll <= l && rr >= r) {
    //LZ[rt] += v;
    //SUM[rt] += (r - l + 1) * v;
    //return;
  //}
  //int mid = (l + r) >> 1;
  //if (LZ[rt]) {
    //LZ[rt << 1 | 1] += LZ[rt];
    //LZ[rt << 1] += LZ[rt];
    //SUM[rt << 1] += (mid - l + 1) * LZ[rt];
    //SUM[rt << 1 | 1] += (r - mid) * LZ[rt];
    //LZ[rt] = 0;
  //}
  //if (ll <= mid) upd(rt << 1, l, mid, ll, rr, v);
  //if (rr > mid) upd(rt << 1 | 1, mid + 1, r, ll, rr, v);
  //SUM[rt] = SUM[rt << 1 | 1] + SUM[rt << 1];
//}
//int64_t query(int rt, int l, int r, int ll, int rr) {
  //if (ll <= l && rr >= r) {
    //return SUM[rt];
  //}
  //int mid = (l + r) >> 1;
  //if (LZ[rt]) {
    //LZ[rt << 1 | 1] += LZ[rt];
    //LZ[rt << 1] += LZ[rt];
    //SUM[rt << 1] += (mid - l + 1) * LZ[rt];
    //SUM[rt << 1 | 1] += (r - mid) * LZ[rt];
    //LZ[rt] = 0;
  //}
  //int64_t res = 0;
  //if (ll <= mid) res += query(rt << 1, l, mid, ll, rr);
  //if (rr > mid) res += query(rt << 1 | 1, mid + 1, r, ll, rr);
  //return res;
//}
//int main() {
//#ifdef LOCAL
  //freopen("a.in", "r", stdin);
//#endif
  //ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  //int n;
  //cin >> n;
  //for (int i = 1; i < n; ++i) {
    //int u, v;
    //cin >> u >> v;
    //V[u].PB(v);
    //V[v].PB(u);
  //}
  //for (int i = 1; i <= n; ++i) {
    //int q = 1;
    //for (int v : V[i])
      //if (v <= i) q--;
    //upd(1, 1, n, i, n, q);
  //}
  //int64_t ans = 0;
  //for (int i = 1; i <= n; ++i) {
    //ans += query(1, 1, n, i, n);
    //for (int v : V[i])
      //if (v > i) {
        //upd(1, 1, n, v, n, 1);
      //}
    //upd(1, 1, n, i, n, -1);
  //}
  //cout << ans << "\n";

  //return 0;
//}
////2020.07.05 23:20:13

#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int64_t N;
  cin>>N;
  int64_t res=N*(N+1)*(N+2)/6;
  for(int i=1;i<N;++i){
    int64_t u,v;cin>>u>>v;
    if(u>v)swap(u,v);
    res-=u*(N-v+1);
  }
  cout<<res<<"\n";
  
  return 0;
}
//2020.07.06 19:37:43


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	ll even=0,odd=0;
	rep(i,N){
		ll x; cin>>x;
		if(x%2==0) even++;
		else odd++;
	}
	even+=odd/2;
	odd%=2;
	if(odd==1) cout<<"NO";
	else cout<<"YES";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
int n, k, a[maxn], res;
vector<int> edge[maxn];
int dfs(int now, int lst = -1) {
	int mx = 0;
	for (int u : edge[now]) 
		mx = max(mx, dfs(u, now));
	if (abs(lst) != 1 && mx == k-1) ++res, mx = -k;//, DE(now, '\n');
	return mx+1;
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 1;i <= n;++i)
		cin >> a[i];
	if (k == 1) {
		cout << n - count(a+1, a+1+n, 1) << '\n';
		return 0;
	}
	if (a[1] != 1) a[1] = 1, ++res;
	for (int i = 2;i <= n;++i)
		edge[ a[i] ].pb(i);
	dfs(1);
	cout << res << '\n';
}


Measured memory_bytes: 18872
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<string>
using namespace std;
int main(){
//	freopen("1.in","r",stdin);	//freopen("AT2084 CF.out","w",stdout);
	string s;
    cin>>s;
    string::size_type pos=s.find_first_of("C");
    if(pos==string::npos)	printf("No");
    else{
    	if(s.find("F",pos+1)==string::npos)	printf("No");
    	else printf("Yes");
    }
//    fclose(stdin);	//fclose(stdout);
    return 0;
}

Measured memory_bytes: 256
// problem C
// from https://atcoder.jp/contests/abc172/tasks/abc172_c
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 200*1000 + 10;
int a[MAXN], b[MAXN];
long sa[MAXN], sb[MAXN];

int main () {
    ios::sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m >> k;
    fill(sa, sa+n, 0L);
    fill(sb, sb+m, 0L);

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sa[i] = sa[i-1] + a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        sb[i] = sb[i-1] + b[i];
    }
    
    int max_books = 0;

    int last_optimal_y = 0;
    for (int x = n; x >= 0; x--) {
        for (int y = last_optimal_y ; y <= m ; y++) {
		if (sa[x] + sb[y] <= k) {
	  		max_books = max(max_books, x+y);
			last_optimal_y = y;
        	} else {
			break;
		}
        }
    }
    cout << max_books << endl;
    return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    vector<int> data(200001,0);
    bool flag = false;
    rep(i,m){
        cin >> a[i] >> b[i];
        if(a[i] == 1) data[b[i]]++;
    }
    rep(i,m){
        if(b[i] == n && data[a[i]] > 0) flag = true;
    }
    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

H, W = map(int, input().split())

S = []
ans_S = []

for i in range(H):
    tmp_s = list(str(input()))
    S.append(tmp_s)
    ans_S.append(tmp_s)

for y in range(H):
    for x in range(W):
        tmp_ans_S = 0
        if S[y][x] == '#':
            tmp_ans_S = '#'
        else:
            # 1 左
            if x > 0:
                if S[y][x - 1] == '#':
                    tmp_ans_S += 1 
            # 2 左上
            if x > 0 and y > 0:
                if S[y - 1][x - 1] == '#':
                    tmp_ans_S += 1
            # 3 上
            if y > 0:
                if S[y - 1][x] == '#':
                    tmp_ans_S += 1
            # 4 右上
            if x < (W - 1) and y > 0:
                if S[y - 1][x + 1] == '#':
                    tmp_ans_S += 1
            # 5 右
            if x < (W - 1):
                if S[y][x + 1] == '#':
                    tmp_ans_S += 1
            # 6 右下
            if x < (W - 1) and y < (H - 1):
                if S[y + 1][x + 1] == '#':
                    tmp_ans_S += 1
            # 7 下
            if y < (H - 1):
                if S[y + 1][x] == '#':
                    tmp_ans_S += 1
            # 8 左下
            if x > 0 and y < (H - 1):
                if S[y + 1][x - 1] == '#':
                    tmp_ans_S += 1
        # ヒトマスごとに集計した分の挿入
        ans_S[y][x] = tmp_ans_S

for ans in ans_S:
    print(*ans, sep='')

Measured memory_bytes: 9292
#include<bits/stdc++.h>
#define M 1000000007
#define N 505
#define ll long long
#define ri register int
using namespace std;

inline int read()
{
	int f=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}

int n,c,l,a[505],b[505];
ll f[505][505],sum[505][505];

inline ll power(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%M;
		b>>=1;
		a=a*a%M;
	}
	return ans%M;
}

int main()
{
	n=read(),c=read();
	for(ri i=1;i<=n;i++)
		a[i]=read();
	for(ri i=1;i<=n;i++)
		b[i]=read();
	for(ri i=1;i<=n;i++)
		sum[i][0]=b[i]-a[i]+1;
	f[0][0]=1;
	for(ri i=1;i<=n;i++)
	for(ri j=1;j<=c;j++)
	for(ri k=a[i];k<=b[i];k++)
		sum[i][j]=(sum[i][j]+power(k,j))%M;
	for(ri i=1;i<=n;i++)
		f[i][0]=(f[i-1][0]*sum[i][0])%M;
	for(ri i=1;i<=n;i++)
	for(ri j=1;j<=c;j++)
	for(ri k=0;k<=j;k++)
		f[i][j]=(f[i][j]+f[i-1][j-k]*sum[i][k])%M;
	cout<<f[n][c];
	return 0;
}

Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(a >= c && b >= d)
    cout << c+(b-d) << " " << d-(a-c) << " " << a+(b-d) << " " << b-(a-c) << endl;
  else if (a >= c && b < d)
    cout << c-(d-b) << " " << d-(a-c) << " " << a-(d-b) << " " << b-(a-c) << endl;
  else if (a < c && b >= d)
    cout << c+(b-d) << " " << d+(c-a) << " " << a+(b-d) << " " << b+(c-a) << endl;
  else
    cout << c-(d-b) << " " << d+(c-a) << " " << a-(d-b) << " " << b+(c-a) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll n,k,ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>k;
	while(n){
		n/=k;
		ans++;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VSUM(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define LTS(n) to_string(n)
#define STL(str) stoll(str);

using namespace std;

VS split_to_VS(const string &s, char cut){
	VS elements;
	stringstream ss(s);
	string item;
	while (getline(ss, item, cut)) if (!item.empty()) elements.push_back(item);
	return elements;
}

VL split_to_VL(const string &s, char cut){
	VL elements;
	stringstream ss(s);
	string item;
	ll temp;
	while (getline(ss, item, cut)) if (!item.empty()){
		temp = STL(item);
		elements.push_back(temp);
	}
	return elements;
}

ll sum(ll index,string s){
	//cout << s <<" "<<index<< endl;
	if (index == s.size() - 1){
		//cout << "↑return" << endl;
		VL vec = split_to_VL(s, '+');
		return VSUM(vec);
	}
	VL vec1 = split_to_VL(s,'+');
	string temp=s;
	temp.insert(index + 1, "+");
	VL vec2 = split_to_VL(temp, '+');
	return sum(index + 1, s) + sum(index + 2, temp);
}

int main() {
	string s;
	cin >> s;
	cout << sum(0, s) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <utility>
#include <map>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define mp make_pair
#define INF 2000000000;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;

#define MAX_N 2000

vector<int> G[MAX_N];

int N, K;
int A[MAX_N], B[MAX_N];
int dist[MAX_N];

void dfs(int pos, int parent, int depth) {
	dist[pos] = min(dist[pos], depth);
	REP(i, G[pos].size()) {
		if (G[pos][i] != parent) {
			dfs(G[pos][i], pos, depth + 1);
		}
	}
}

int calc(int s1, int s2) {
	REP(i, N) {
		dist[i] = INF;
	}
	dfs(s1, -1, 0);
	dfs(s2, -1, 0);
	int ans = 0;
	REP(i, N) {
		if (dist[i] > K / 2)ans++;
	}
	return ans;
}

int main() {
	cin >> N >> K;
	REP(i, N - 1) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}
	int ans = INF;
	if (K % 2 == 0) {
		REP(i, N) {
			ans = min(ans, calc(i, i));
		}
	}
	else {
		REP(i, N - 1) {
			ans = min(ans, calc(A[i], B[i]));
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INF (1e9)

using namespace std;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;

    int n = 0, z = 0;
    unsigned long m = INF, S = 0;
    for (int i = 0; i < N; i++) {
        S += abs(A[i]);
        if(A[i] < 0) n++;
        if(A[i] == 0) z = 1;
        if(m > abs(A[i])) m = abs(A[i]);
    }

    if(z || n % 2 == 0){
        printf("%lu\n", S);
    }else{
        printf("%lu\n", S - 2*m);
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

const ll MAX = 1e6 + 1000;
const ll MOD = 1e9 + 7;
vector<ll> fac(MAX);
vector<ll> finv(MAX);
vector<ll> inv(MAX);

void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(ll 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;
  }
}

ll nCr(ll n, ll r){
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K; cin >> N >> K;
  vector<ll> A(N, 0);
  REP(i, N){
    cin >> A[i];
  }
  COMinit();
  sort(A.begin(), A.end());
  ll ans = 0;
  REP(i, N-K+1){
    ans += nCr(N-1-i, K-1)*A[N-1-i]%MOD;
    ans = (ans - nCr(N-1-i, K-1)*A[i])%MOD < 0 ? MOD + (ans - nCr(N-1-i, K-1)*A[i])%MOD : (ans - nCr(N-1-i, K-1)*A[i])%MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 24576
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


string s;
int K;
set<string> sset;


signed main(){
    cin >> s;
    cin >> K;

   rep(i, 0, SIZE(s)){
        string prev;
        rep(j, 0, SIZE(s) <= 5 ? SIZE(s)-i : 5){
            if(i+j >= SIZE(s)) break;
            prev += s[i+j];
            sset.insert(prev);
        }
   }

    int cnt = 1;
    for(string ans : sset){
        if(cnt == K) cout << ans << endl;
        cnt++;
    }

    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a>=b&&b>=c)cout<<a-c;
  else if(a>=c&&c>=b)cout<<a-b;
  else if(b>=c&&c>=a)cout<<b-a;
  else if(b>=a&&a>=c)cout<<b-c;
  else if(c>=a&&a>=b)cout<<c-b;
  else cout<<c-a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define PI 3.141592653589793238
double cal_cos(double n)
{
    double accuracy = 0.000000000000001;
    double x1, denominator, cosx, cosval;

    // Converting degrees to radian
    n = n * (PI / 180.0);

    x1 = 1;

    // Maps the sum along the series
    cosx = x1;

    // Holds the actual value of sin(n)
    cosval = cos(n);
    int i = 1;
    do {
        denominator = 2 * i * (2 * i - 1);
        x1 = -x1 * n * n / denominator;
        cosx = cosx + x1;
        i = i + 1;
    } while (accuracy <= fabs(cosval - cosx));

    return cosx;
}
double third_side(int a, int b, double angle)
{
    double yes = cal_cos(angle);
    return sqrt((a * a) + (b * b) - 2 * a * b * yes);
}
// Driver program to check the above function
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double angle = abs((0.5 * ((60 * h) + m)) - (6 * m));

    if(angle > 180){
        angle = 360 - angle;
    }
    cout << fixed;
    cout << setprecision(13) << double(third_side(a, b, angle));

    return 0;
}




Measured memory_bytes: 4132
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  a3 PIC 9(08).
       01  r pic 9(08).
       01  g pic 9(08).
       01  r2 pic 9(08).
       01 disp pic Z(20)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2.
        divide a2 by a1 giving g remainder r
         IF r > 0 THEN
          compute a3 = a2 - a1
          MOVE FUNCTION TRIM(a3) to disp
          DISPLAY disp
         ELSE
          compute a3 = a2 + a1
          MOVE FUNCTION TRIM(a3) to disp
          DISPLAY disp
         END-IF


       STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll wt[100002],val[100002];
ll dp[101][100001];
ll knapsack(ll W,ll n)
{
    if(W<=0 || n<0)
        return 0;
    ll ans=0;
    if(dp[n][W]!=-1)
        return dp[n][W];

    ll ans1=knapsack(W,n-1);
    ll ans2=knapsack(W-wt[n],n-1)+val[n];
    if(wt[n]>W)
        ans=dp[n][W]=ans1;
    else
        ans=dp[n][W]= max(ans1,ans2);

    return ans;

}
int main()
{
    ll i,j,k,l,m,n,W;
    cin>>n>>W;
    memset(dp,-1,sizeof dp);

    for(i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    cout<<knapsack(W,n-1);


}


Measured memory_bytes: 80128
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
  int n;
  int a[101];
  int max = 0;
  int min = 1000;

  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    if(max < a[i]){
      max = a[i];
    }
    if(min > a[i]){
      min = a[i];
    }
  }

  printf("%d\n", max - min);

  return 0;
}


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

typedef long long ll;
// #define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;

vector<int> graph[100005];

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);




	int n,m;
	cin>>n>>m;
	int arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];

	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		bool flag = true;
		for(auto v:graph[i]){
			if (arr[v] >= arr[i]){
				flag = false;
				break;
			}
		}
		if (flag){
			// cout<<i<<"\n";
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
int main()
{
	string a,b;
	cin>>a>>b;
	cout<<b<<a<<endl; 
	return 0;
}


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


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

int mat[12][12];
bool visited[12];
int cost[12];
int aux[12];
int n, m, x;
int mini = 1200005;

void full(int pos, int sum, int arr[]) {
  visited[pos] = true;
  for (int i = 0; i < m; i++) {
    arr[i] += mat[pos][i];
  }
  sum += cost[pos];
  bool complete = true;
  for (int i = 0; i < m; i++) {
    if (arr[i] < x) {
      complete = false;
      break;
    }
  }
  if (complete) {
    if (mini > sum) {
      mini = sum;
    }
    visited[pos] = false;
    for (int i = 0; i < m; i++) {
      arr[i] -= mat[pos][i];
    }
    sum -= cost[pos];
    return;
  }
  for (int i = pos + 1; i < n; i++) {
    if (!visited[i]) {
      full (i, sum, arr);
    }
  }
  visited[pos] = false;
  for (int i = 0; i < m; i++) {
    arr[i] -= mat[pos][i];
  }
  sum -= cost[pos];
}

int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> x;
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m + 1; j++) {
      if (j == 0) {
        cin >> cost[i];
      }else {
        cin >> mat[i][j - 1];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    full(i, 0, aux);
  }
  if (mini == 1200005)
    cout << "-1\n";
  else
    cout << mini << '\n';
  return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

inline int dis(int a,int b) { return min(b-a,24-b+a); }
int main()
{
	int n=gi(),i,s[13]={},f,ans=0,mi,one=0,two=0;
	for (i=0;i<n;i++) s[gi()]++;
	for (i=0;i<=12;i++)
		if (s[i]>=3) return puts("0"),0;
		else if (s[i]==1) one|=1<<i;
		else if (s[i]==2) two|=1<<i;
	for (f=0;f<1<<13;f++) {
		VI y;
		for (i=0;i<=12;i++)
			if (one>>i&1)
				y.pb(f>>i&1?i:24-i);
			else if (two>>i&1)
				y.pb(i),y.pb(24-i);
		sort(y.begin(),y.end());
		mi=min(dis(0,y.back()),dis(0,y.front()));
		for (i=1;i<y.size();i++) upmin(mi,dis(y[i-1],y[i]));
		upmax(ans,mi);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

long long F[22][1 << 19];

int K[22][1 << 19], n, m, k, S[22][22];

int main()
{
	memset(S, -1, sizeof S), scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= k; i++) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z), S[--x][--y] = z;
	}
	for(int i = 0; i < (1 << n - 1); i++)
		for(int lst = -1, j = n - 2; j >= 0; j--) {
			if((i >> j) & 1) lst = j;
			K[j][i] = i + (1 << j) - (lst != -1 ? 1 << lst : 0);
		}
	F[0][0] = 1;
	for(int O = 0; O < m; O++, memcpy(F[0], F[n - 1], sizeof F[0])) {
		for(int T = 0; T < n - 1; T++) {
			memset(F[T + 1], 0, sizeof F[T + 1]);
			for(int i = 0; i < (1 << n - 1); i++) {
				if(S[O][T] != 1 && !((i >> T) & 1)) F[T + 1][i] += F[T][i];
				if(S[O][T] != 0) F[T + 1][K[T][i]] += F[T][i];
			}
		}
		for(int i = 0; i < (1 << n - 1); i++) F[n - 1][i] %= P;
	}
	long long ans = 0;
	for(int i = 0; i < (1 << n - 1); i++) ans = (ans + F[n - 1][i]) % P;
	return printf("%lld\n", ans), 0;
}

Measured memory_bytes: 125184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main()
{
  ll H;
  cin >> H;

  ll ans = 0;
  ll i = 0;
  while (H > 0) {
    H /= 2;
    ans += pow(2, i);
    i++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int H,W;
  char a[1000][1000];
  cin>>H>>W;
  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      cin>>a[i][j];
    }
  }
  ll cnt[1000][1000]={0};
  cnt[0][0]=1;
  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      if (i==0&&j==0) continue;
      if (j==0){
        if (a[i-1][j] != '#'){
          cnt[i][j] = cnt[i-1][j];
        }
      }else if(i==0){
        if (a[i][j-1] != '#'){
          cnt[i][j] = cnt[i][j-1];
        }
      }else{
        if (a[i-1][j] != '#'){
          cnt[i][j] = cnt[i-1][j];
        }
        if (a[i][j-1] != '#'){
          cnt[i][j] += cnt[i][j-1];
        }
      }
      cnt[i][j]%=mod;
    }
  }
  cout << cnt[H-1][W-1] << endl;
  for (int i(0);i<H;i++){
    for (int j(0);j<W;j++){
      //cout << cnt[i][j] << " ";
    }
    //cout << endl;
  }
  return 0;
}



Measured memory_bytes: 9088
#include <stdio.h>

char g[110][110];
int n, m, bad_row[110], bad_col[110];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", g[i] + 1);
  }
  for (int i = 1; i <= n; ++i) {
    int bad = 1;
    for (int j = 1; j <= m; ++j) {
      if (g[i][j] == '#') {
        bad = 0;
        break;
      }
    }
    bad_row[i] = bad;
  }
  for (int j = 1; j <= m; ++j) {
    int bad = 1;
    for (int i = 1; i <= n; ++i) {
      if (g[i][j] == '#') {
        bad = 0;
        break;
      }
    }
    bad_col[j] = bad;
  }
  for (int i = 1; i <= n; ++i) {
    if (bad_row[i]) continue;
    for (int j = 1; j <= m; ++j) {
      if (bad_col[j]) continue;
      putchar(g[i][j]);
    }
    puts("");
  }
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K;
ll MOD = 1000000007;
int ans = 0;
int keta = 1;

//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<ll, ll> firstElof, pair<ll, ll> secondElof)
{
	return firstElof.second > secondElof.second;
}
//////////////
void dfs(ll I, int depth,int three,int five,int seven) {
	if (depth == keta) {
		if (I <= N && three != 0 && five != 0 && seven != 0) {
			ans++;
		}
	}
	else {
		if (three != 0 && five != 0 && seven != 0) {
			ans++;
		}
		dfs(I + 3 * pow(10, depth), depth + 1, three + 1, five, seven);
		dfs(I + 5 * pow(10, depth), depth + 1, three, five + 1, seven);
		dfs(I + 7 * pow(10, depth), depth + 1, three, five, seven + 1);
	}
}

int main()
{
	cin >> N;
	ll I = N;
	while (I / 10 > 0) {
		keta++;
		I /= 10;
	}
	dfs(3, 1, 1, 0, 0);
	dfs(5, 1, 0, 1, 0);
	dfs(7, 1, 0, 0, 1);
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


void DFS(int init,vector<vector<int> >& E, vector<int> & Node)
{
  int N = E.size();
  vector<int> visited (N,0);
  stack<int> st;
  Node[init] = 0;
  visited[init] = 1;
  st.push(init);
  while(st.empty() != 1)
  {
    int NODE = st.top();
    st.pop();
    if(E[NODE].size() == 1) Node[NODE] = 0;
    for (int i = 0; i < E[NODE].size(); i++)
    {
      int to = E[NODE][i];
      if(visited[to]==0)
      {
        st.push(to);
        Node[to] = Node[NODE] + 1;
        visited[to] = 1;
      }
    }
  }
}

void solve(void)
{ 

  int N,u,v;
  cin>>N>>u>>v;
  u--;
  v--;
  vector<int> V_u(N,0);
  vector<int> V_v(N,0);

  vector<vector<int> > E (N);
  for (int i = 0; i < N-1; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;
    B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }

  DFS(u,E,V_u);
  DFS(v,E,V_v);

  int MAX = 0;
  int MAX_PRE = 0;
  int index = -1;
  int PQ;
  for (int i = 0; i < N; i++)
  {
    if(V_v[i] - V_u[i] >= 0) PQ = V_v[i];
    MAX = max(MAX,PQ);
    if(MAX != MAX_PRE)
    {
      MAX_PRE = MAX;
      index = i;
    }
  }


  // for (int i = 0; i < N; i++)
  // {
  //   cout<<V_v[i]<<endl;
  // }

  // cout<<index<<endl;
  if(index == -1)cout<<0<<endl;
  else
  cout<<V_v[index]<<endl;
  
  
  
  return;  
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 8704
#include <stdio.h>

int main(void)
{
	int i, j, n, S[10000], q, T[10000], a, b;
	int count = 0;
	
	scanf("%d",&n);
	
	for(i = 0; i < n; i++){
		scanf(" %d",&S[i]);
	}
	scanf("%d",&q);
	
	for(j = 0; j < q; j++){
		scanf(" %d",&T[j]);
	}
	
	for(a = 0; a < q; a++){
		b = 0;
			while (T[a] != S[b]){
				b++;
				if(b == n)  break;
			}
		if(b != n)  count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

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

int main(){
  int n, q, b, e, com;
  cin >> n;
  vector<int> a(n);;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> com >> b >> e;
    if(com == 0){
      cout << *min_element(a.begin() + b, a.begin() + e) << endl;
    }else{
      cout << *max_element(a.begin() + b, a.begin() + e)  << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
//using p=pair<int,int>;
typedef long long ll;
//#define rep(i,N) for(int i=0;i<N;i++)
 int main ( ) {

    int n , m;
    cin >> n >> m;
    vector<bool> vis(n+1,false) ;
    bool ans = false ;

  for ( int i = 0 ; i < m; i++)
  {
  int a , b ;
  cin >> a >> b ;

  if( 1 <= a && a < b && b <= n ) {
    if ( a == 1 ){
        if(vis[b] ) ans = true ;

      vis[ b ] = true ;
    }
    else if ( b == n ){

      if (vis[a]) ans = true ;

      vis[a] = true ; }

  }

  }




if (!ans)
cout<<"IMPOSSIBLE" ;
else
cout<< "POSSIBLE" <<endl ;

return 0;
}



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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

void solve(int t) {
    int n;
    cin >> n;
}

int main(int argc, char *argv[])
{
    string s, t;
    cin >> s;
    cin >> t;

    int count = 0;

    for (int i = 0; i<s.size(); i++) {
        if (s[i] != t[i])
            count++;
    }

    cout << count<<endl;

    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p/2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1; // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= i + 1;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

 vector<pair<ll, ll>> prime_factorize(ll n) {
   vector<pair<ll, ll>> res;

   for (ll i = 2; i * i <= n; i++) {
     if (n % i == 0) {
       ll num = 0;
       while (n % i == 0) {
         num++;
         n /= i;
       }
       res.push_back(make_pair(i, num));
     }
   }

   if (n != 1) {
     res.push_back(make_pair(n, 1));
   }

   return res;
 }

 ll MOD = 1000000007;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> primeFactors = prime_factorize(M);

  ll ans = 1;
  for (auto e : primeFactors) {
    ll base = e.first;
    ll exponent = e.second;

    ans *= modCombination(exponent + N - 1, N - 1, MOD);
    ans %= MOD;
  }

  cout << ans % MOD << endl;

  return 0;
}

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

const int N = 1e5 + 9;

template <class T>
struct BIT { //1-indexed
    int n; vector<T> t;
    BIT(int _n) {
        n = _n; t.assign(n,0);
    }
    T query(int i) {
        T ans = 0;
        for (; i >= 1; i -= (i & -i)) ans += t[i];
        return ans;
    }
    void upd(int i, T val) {
        if (i <= 0) return;
        for (; i < n; i += (i & -i)) t[i] += val;
    }
    void upd(int l, int r, T val) {
        upd(l, val);
        upd(r + 1, -val);
    }
    T query(int l, int r) {
        return query(r) - query(l - 1);
    }
};
vector<int> line[N];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		int l, r; cin >> l >> r;
		line[r - l + 1].push_back(l);
	}
	BIT<int> t(N);
	int dead = n;
	for (int d = 1; d <= m; d++) {
		int ans = dead;
		for (int i = d; i <= m; i += d) ans += t.query(i);
		cout << ans << '\n';
		for (auto l: line[d]) {
			int r = l + d - 1;
			t.upd(l, r, 1);
			dead--;
		}
	}
    return 0;
}

Measured memory_bytes: 9248
/*
    Only way to go is UP 
    H1s3nb3rg's Here !!
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h> 
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pi;
typedef uint64_t i64;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vector<ll>> v2ll;
const int MOD = 1e9+7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAIN int main(){FAST_IO;ll tc;cin>>tc;while(tc--){solver();}ret0;}
#define MAIN1 int main(){FAST_IO;solver();ret0;}
#define rep(i,b,e) for(__typeof(e)i=(b)-((b)>(e));i!=(e)-((b)>(e));i+=1-2*((b)>(e)))
#define repa(i,x)  for(auto i:x)
#define vin(x) for(auto &i:x){cin>>i;}
#define vin1(x) for(ll i=1;i<x.size();i++){cin>>x[i];}
#define dbg(x) for(auto i:x){cout<<i<<" ";}cout<<ENDL;
#define dbg2(x) for(auto &i:x){for(auto j:i){cout<<j<<" ";}cout<<endl;}
#define dbgp(x) for(auto i:x){cout<<i.ff<<" "<<i.ss<<endl;}
#define ENDL "\n"
#define VALL(a) a.begin(),a.end()
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define MP(a,b) make_pair(a,b)
#define ff first
#define ss second
#define ret0 return 0;
#define ret return;
#define pb(x) push_back(x)
/*----------------------------*/


void solver(){
    ll n;
    cin>>n;
    vll el(n,0);
    vin(el);
    vll presum(n,0);
    *(presum.end()-1)=*(el.end()-1);
    for(ll i=n-2;i>=0;i--) presum[i]=(presum[i+1]+el[i])%MOD;
    ll ans=0;
    for(ll i=0;i<n-1;i++)  ans= (ans + (el[i]*presum[i+1])%MOD)%MOD;
    cout<<ans<<ENDL;


}

MAIN1


Measured memory_bytes: 6376
a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))
c = [list(map(int, input().split())) for l in range(m)]
l = [min(a1) + min(b1)]
for i in c:
    l.append(a1[i[0] - 1] + b1[i[1] - 1] - i[2])
print(min(l))

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

int main()
{
    int n, a, b;
    
    cin >> n;
    
    a = n % 10;
    b = n / 100;
    
    if(a == b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define clr(v,val) memset(v,val,sizeof v)
void file(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);  
#endif
}
void fast(){
	std::ios_base::sync_with_stdio(0); cin.tie(NULL);
}
const int N = 510 + 20;
/***You***Can***Do***It***/
int main()
{
	
	fast();
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2==0){
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	set<int> st;
	for (int d=1; d*d<=m; d++)
		if(m%d==0)
			st.insert(d), st.insert(m/d);
	int ret=0;
	for (auto d : st)
		if(m/d>=n)
			ret=max(ret,d);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


int N,M;
string S;
signed main(){
  cin>>N;
  M=100;
  int count=0;
  while(true){
    if(M>=N)break;
    M+=M*0.01;
    count++;
  }
  print(count);

}


Measured memory_bytes: 3656
from collections import deque
N,M=map(int,input().strip().split())
l=[]
dp=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().strip().split())
    l.append((a,b))
    dp[a-1].append(b)
    dp[b-1].append(a)

d=deque([1])
visited=[0 for _ in range(N)]
visited[0]=1
cnt=1
while d:
    tmp=d.popleft()
    for e in dp[tmp-1]:
        if visited[e-1]==0:
            visited[e-1]=tmp
            cnt+=1
            d.append(e)
            
if cnt!=len(visited):
    print("No")
else:
    print("Yes")
    for n in range(1,N):
        print(visited[n])

Measured memory_bytes: 48412
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int R = Integer.parseInt(sc.next());
		int G = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int N = Integer.parseInt(sc.next());
		int ans = 0;
		for(int r=0;r*R<=N;r++){
			for(int g=0;r*R+g*G<=N;g++){
				int sum = r*R+g*G;
				if((N-sum)%B==0)ans++;
			}
		}

		System.out.println(ans);
		
		
		sc.close();
	}
	
}


Measured memory_bytes: 23764
#include<stdio.h>

#define MAX_S 10000
#define MAX_T 500


int linearSearch(){
  int i,j,count,k,l;
  int s[MAX_S],t[MAX_T];

  count = 0;
  
  scanf("%d",&k);
  for(i = 0; i < k; i++)
    scanf("%d",&s[i]);
  
  scanf("%d",&l);
  for(i = 0; i < l; i++)
    scanf("%d",&t[i]);

    for(i = 0; i < l; i++)
      for(j = 0; j < k; j++)
	if(t[i] == s[j]){
	  count++;
	  break;
	}
    
  return count;
}

int main(){
  
  printf("%d\n",linearSearch());
  
  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<string>

using namespace std;

typedef long long int ll;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> c(26);
    for(int i = 0; i < n; i++){
        c[s[i] - 'a']++;
    }
    ll ans = 1;
    for(int i = 0; i < 26; i++){
        ans *= (c[i] + 1);
        ans %= MOD;
    }
    ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    char ch;
    cin>>a>>ch>>b;
    switch(ch)
    {
   case '+':
       cout<<a+b;
       break;
   case'-':
   cout<<a-b;
   break;






    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,k; cin>>a>>b>>k;
    int tmp=__gcd(a,b);
    vector<int> ans;
    for(int i=1; i*i<=tmp; i++){
        if(tmp%i==0){
            ans.emplace_back(i);
            if(i*i!=tmp){
                ans.emplace_back(tmp/i);
            }
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout<<ans[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 3616