akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define CO const
#define IN inline
typedef long long LL;

template<class T> T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int mod=998244353;
IN int add(int a,int b){
	return (a+=b)>=mod?a-mod:a;
}
IN int mul(int a,int b){
	return (LL)a*b%mod;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}

CO int N=4000+10;
int fac[N],ifac[N],pw2[N];

IN int binom(int n,int m){
	if(n<m or m<0) return 0;
	return mul(fac[n],mul(ifac[m],ifac[n-m]));
}
IN int candy(int n,int m){
	return binom(n+m-1,m-1);
}

int main(){
	int k=read<int>(),n=read<int>();
	fac[0]=1,pw2[0]=1;
	for(int i=1;i<=n+k;++i) fac[i]=mul(fac[i-1],i),pw2[i]=mul(pw2[i-1],2);
	ifac[n+k]=fpow(fac[n+k],mod-2);
	for(int i=n+k-1;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	for(int i=2;i<=2*k;++i){
		int f=0,g=0;
		for(int j=1;j<=k;++j){
			int l=i-j;
			if(l<1 or l>k) ++f;
			else if(j<l) ++f,++g;
		}
		int ans=0;
		for(int j=0;j<=g;++j){
			int sum=candy(n-j,f-g+j);
			if(i%2==0) sum=add(sum,candy(n-j-1,f-g+j));
			sum=mul(sum,mul(pw2[j],binom(g,j)));
			ans=add(ans,sum);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int n;
vector<P> G[1000005];
vector<int> ans;

void cal(int from, ll cur, ll dist) {
  if (dist % 2 == 1) {
    ans[cur] = 1;
  }
  for (P p : G[cur]) {
    if (p.first == from) continue;
    cal(cur, p.first, dist + p.second);
  }
}

int main() {
  cin >> n;
  ans.resize(n);
  rep(i, n - 1) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }

  cal(-1, 0, 0);

  rep(i, n) { cout << ans[i] << endl; }
}

Measured memory_bytes: 33676
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a = [[0] * 3 for _ in range(3)]
    b = [[0] * 3 for _ in range(3)]

    for i in range(3):
        a[i] = list(map(int,ipti().split()))

    n = int(input())

    for i in range(n):
        temp = int(input())
        for j in range(3):
            for k in range(3):
                if a[j][k] == temp:
                    b[j][k] = 1

    flag = False

    for i in range(3):
        for j in range(3):
            if b[i][j] != 1:
                break
        else:
            flag = True

    for i in range(3):
        for j in range(3):
            if b[j][i] != 1:
                break
        else:
            flag = True

    if b[1][1] == 1:
        if b[0][0] == 1:
            if b[2][2] ==1:
                flag = True
        if b[2][0] == 1:
            if b[0][2] ==1:
                flag = True

    if flag:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(void){
    int n,m; cin>>n>>m;
    if(n==1) {cout<<m<<endl; return 0;}
    int x = m/n;
    for(int i=x;i>0;i--){
       if(m%i==0) {cout<<i<<endl; return 0;}
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	int n;
	cin >> n;

	vector<double> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

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

	double res = (a.at(0) + a.at(1)) / 2.0;
	for (int i = 2; i < n; i++)
	{
		res = (res + a.at(i)) / 2.0;
	}
	cout << fixed << setprecision(8) << res << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
UV = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for _ in range(N)]
for u,v in UV:
    u,v = u-1,v-1
    if u>v: u,v = v,u
    es[v].append(u)

ans = 0
s = 0
for i in range(N):
    s += (i+1)
    ans += s
    t = 0
    for j in es[i]:
        t += (j+1)
    ans -= t*(N-i)

print(ans)

Measured memory_bytes: 62652
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

#define MAX 1e9 + 7

int dp[100000] = {};
int h[100000] = {};
int n;
int dfs(int k){
  if(k < n-2) dp[k+2] = min(dp[k+2], abs(h[k] - h[k+2]) + dp[k]);
  if(k < n-1) dp[k+1] = min(dp[k+1], abs(h[k] - h[k+1]) + dp[k]);
  if(k < n-1) dfs(k+1);
  return 0;
}

int main(){
  cin >> n;
  for(int i = 0; i < n ; i++){
    cin >> h[i];
  }
  for(int i = 0; i < n ; i++){
    dp[i] = MAX;
  }
  dp[0] = 0;
  dfs(0);
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 2688
#include<stdio.h>
#include<math.h>
int main(){
    int N;
    scanf("%d",&N);
    int ans[100000];
    int x,y,z,i;
    /*for(i=1;i<=N;i++){
        int count = 0;
        for(x=1;x<=sqrt(i);x++){
            for(y=1;y<=sqrt(i);y++){
                for(z=1;z<=sqrt(i);z++){
                    if((x*x+y*y+z*z+x*y+y*z+z*x) == i){
                        count++;
                    }
                }
            }
        }
        printf("%d\n",count);
    }*/
    for(i=1;i<=N;i++){
        ans[i] = 0;
    }
    for(x=1;x<=sqrt(N);x++){
        for(y=1;y<=sqrt(N);y++){
            for(z=1;z<=sqrt(N);z++){
                i = x*x+y*y+z*z+x*y+y*z+z*x;
                ans[i] = ans[i]+1;
            }
        }
    }
    for(i=1;i<=N;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 2376
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
int main(void){
    // Your code here!
    double a,b;
    double k;
    cin >> k;
    cin >> a >> b;

    double x = ceil(a / k) * k;
    if(a <= x && x <= b){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
const double PI = acos(-1.0);

int N;
int p[100010];
int diff[100010];

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

    int ans = 0;
    bool isSuccessive = false;

    cin >> N;
    FOR(i, 1, N+1){
        cin >> p[i];
        if(i - p[i] == 0){
            if(isSuccessive){
                isSuccessive = false;
                continue;
            }else{
                ans++;
                isSuccessive = true;
            }
        }else{
            isSuccessive = false;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3912
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int count(int N)
{
        int cnt = 0;
        while (N % 2 == 0)
        {
                cnt++;
                N /= 2;
        }
        return cnt;
}

int main()
{
        int N;
        cin >> N;
        vector<int> A(N + 1);
        rep(i, N) cin >> A[i];
        int ans = 100000;
        rep(i, N) ans = min(ans, count(A[i]));

        cout << ans << endl;

        return 0;
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N, v[1000005];

LL compute(int x)
{
    LL ans = 0;
    for(int i = 1; i <= N; i++)
        ans += abs(v[i] - (x + i));
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++) scanf("%d", &v[i]);

    int p = -(1e6);
    int u = 1e9;
    LL ans = 1LL << 60;
    while(p < u)
    {
        int mij = p + (u - p) / 2;

        LL ans1 = compute(mij);
        LL ans2 = compute(mij + 1);
        if(ans1 < ans2)
            u = mij;
        else
            p = mij + 1;
    }

    ans = compute(p);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
typedef long long ll;
 
const ll maxn = 1e5 + 1e2;
int dist[maxn];
int par[maxn];
int imp[maxn];
std::vector<int> adj[maxn];

int main(){
	std::ios::sync_with_stdio(false);
	
	ll n;
	std::cin >> n;
	
	for(int i = 0; i < n - 1; i++){
		int f, s;
		std::cin >> f >> s;
		f--, s--;
		
		adj[f].push_back(s);	
		adj[s].push_back(f);	
	}
	
	std::fill(dist, dist + maxn, -1);
	
	std::queue<int> q;
	q.push(0);
	dist[0] = 0;
	
	while(!q.empty()){
		int fr = q.front();
		q.pop();
		
		for(int i = 0; i < adj[fr].size(); i++){
			int next = adj[fr][i];
			
			if(dist[next] == -1){
				dist[next] = dist[fr] + 1;
				par[next] = fr;
				q.push(next);
			}
		}
	}
	
	int pos = n - 1;
	
	while(pos != 0){
		imp[pos] = true;
		pos = par[pos];
	}
	
	std::vector<int> white;
	
	for(int i = 0; i < n; i++){
		if(imp[i] and dist[i] <= dist[n - 1] / 2){
			white.push_back(i);
		}
	}
	
	int sum = 0;
	
	while(!white.empty()){
		int fr = white[white.size() - 1];
		white.pop_back();
		sum++;
		
		for(int i = 0; i < adj[fr].size(); i++){
			int next = adj[fr][i];
			
			if(!imp[next]){
				imp[next] = true;
				white.push_back(next);
			}
		}
	}
	
	if(sum > n - sum){
		std::cout << "Fennec";
	} else {
		std::cout << "Snuke";
	}
}

Measured memory_bytes: 7296
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* 
   If you know what you’re worth, 
   then go out and get what you’re worth
   But you gotta be willing to take the hits, 
   and not pointing fingers saying you ain’t 
   where you wanna be because of him, or her, or anybody. 
   Cowards do that and that ain’t you. You’re better than that! 
*/

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1e5+5;
map<int,int> dp;
    
int solve(int n){

    if(dp.count(n))
        return dp[n];

    int ans = 1 + solve(n/2) + solve(n/2);
    dp[n] = ans;

    return ans;
}

int32_t main(){
    FAST;

    dp[0] = 0;
    dp[1] = 1;
   int n;   cin >> n;
   cout << solve(n) << endl;

    
    return 0;
}




Measured memory_bytes: 256
A = [[i for i in map(int,input().split())] for j in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(n):
  for x in range(3):
    for y in range(3):
      if A[x][y] == b[i]:
        A[x][y] = -1
        
flag = 0
for i in range(3):
  if A[i][0]==-1 and A[i][1]==-1 and A[i][2]==-1:
    flag = 1
  if A[0][i]==-1 and A[1][i]==-1 and A[2][i]==-1:
    flag = 1
    
if A[0][0]==-1 and A[1][1]==-1 and A[2][2]==-1:
  flag = 1
if A[2][0]==-1 and A[1][1]==-1 and A[0][2]==-1:
  flag = 1
  
if flag==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
N = int(input())
# 初回は単純に人数として加算
T, A = map(int, input().split())

for _ in range(N - 1):
    t_i, a_i = map(int, input().split())

    # 比率を考えると総人数は T, A = n*t_i, n*a_i の形になる
    # 必ず現在のT, A以上となるnの値を考える
    n = max(-(-T // t_i), -(-A // a_i))

    # 更新
    T, A = n * t_i, n * a_i

print(T + A)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int n;
	int d[100] = {};
	int input;
	int counter = 0;
	scanf("%d", &n);
	int i;
	for ( i = 0; i < n; i++)
	{
		scanf("%d", &input);
		if (d[input - 1] != 1)
		{
			counter++;
			d[input - 1] = 1;
		}
	}
	printf("%d", counter);
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#define size 500010
#define debug(x) cerr<<#x<<"="<<x
#define gc getchar()
#define db double
#define ll long long
#define rep(i,s,n) for (register int i=s;i<=n;i++)
#define drep(i,n,s) for (register int i=n;i>=s;i--)
#define il inline
using namespace std;

il ll r()
{
	char c; ll x,f=1;
	for (c=gc;!isdigit(c);c=gc) if (c=='-') f=-1; x=c-'0';
	for (c=gc;isdigit(c);c=gc) x=(x<<1)+(x<<3)+c-'0';
	return f*x;
}

ll n,k,ans=0;

int main()
{
	n=r(); k=r(); if (!k) {cout<<1ll*n*n<<endl; return 0;}
	rep(i,k+1,n)
	 	ans+=(n/i)*(i-k) +max(n%i-(k-1),1ll*0);	
	cout<<ans<<endl;
	return 0;
}


















Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
bool good(string& s){
	stack<char> st;
	for(auto u : s){
		if(u=='(')st.push(u);
		else{
			if(!st.empty() and st.top()=='(')st.pop();
			else
				return false;
		}
	}
	return st.empty();
}
void solve(){
	ll n;
	cin>>n;
	vector<string> v(n);
	vector<pair<pair<ll,ll>,string> > pos, neg;
	rep(i,0,n){
		string tmp="";
		cin>>v[i];
		for(auto u : v[i]){
			if(u=='(')tmp.pb(u);
			else{
				if(sz(tmp)>0 and tmp.back()=='(')tmp.pop_back();
				else
					tmp.pb(u);
			}
		}
		if(sz(tmp)==0)continue;
		ll a=0, b=0, cur=sz(tmp)-1;
		while(a<sz(tmp) and tmp[a]==')')a++;
		while(cur>=0 and tmp[cur]=='(')cur--,b++;
		if(b-a>=0)pos.pb({{a,b},tmp});
		else
			neg.pb({{-b,a,},tmp});
	}
	sort(all(pos));
	sort(all(neg));
	string res="";
	for(auto u : pos)res+=u.se;
	for(auto u : neg)res+=u.se;
	good(res)?cout<<"Yes\n":cout<<"No\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 84316
/*---> 16 January 2020 <--- > 13:25:06 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
int fact[2*N],factInv[2*N],inv[2*N];
int ncr(int n,int r){
	if(n<r)
		return 0;
	if(r==1)
		return n;
	if(n==r || r==0)
		return 1;
	return ((fact[n]*factInv[n-r])%mod*factInv[r])%mod;
}
int32_t main(){__
	int n,k;
	cin>>n>>k;
	fact[0]=fact[1]=inv[0]=inv[1]=factInv[1]=factInv[0]=1;
	for(int i=2;i<=2*n;i++){
		fact[i]=(i*fact[i-1])%mod;
		inv[i]=mod-((mod/i)*inv[mod%i])%mod;
		factInv[i]=(inv[i]*factInv[i-1])%mod;
	}
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(all(a));
	int add=0,sub=0;
	for(int i=0;i<n;i++){
		if(n-i<k)
			break;
		sub+=(a[i]*ncr(n-i-1,k-1))%mod;
		sub%=mod;
	}
	reverse(all(a));
	for(int i=0;i<n;i++){
		if(n-i<k)
			break;
		add+=(a[i]*ncr(n-i-1,k-1))%mod;
		add%=mod;
	}
	// debug()<< imie(add) imie(sub) imie(ncr(4,2)) imie(fact[5]);
	int ans=(add-sub)%mod;
	if(ans<0)
		ans+=mod;
	cout<<ans<<"\n";
return 0;
}


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

using namespace std;

char arr[26];

int main() {
    string w;
    cin >> w;

    for (char c : w) arr[c - 97]++;
    for (int i = 0; i < 26; i++) {
        if (arr[i] % 2 != 0) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 3580
#include <iostream>

int main() {
	int a,b,c;
	int num=0;
	std::cin >> a >> b >> c;
	while(a<=b){
		if(c%a==0){
			num=num+1;
		}
		a=a+1;
	}
	std::cout << num << std::endl;
	return 0;
}

//if(c%a==0){ num++;}

Measured memory_bytes: 3100
import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven
  }
}

object Main extends App {
  import Helpers._

  val Array(n, k) = readIntLine
  val x = Array.fill(n)(0)

  for (_ <- Range(0, k)) {
    val d = readInt
    val as = readIntLine
    as.foreach(a => {
      x(a - 1) = 1
    })
  }

  println(x.count(_ == 0))
}



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

const int INF = (1 << 30) - 1;

int main()
{
	int N, T;
	int t;
	int pos = -INF;
	int sum = 0;

	cin >> N >> T;
	for ( int i = 0; i < N; i++ ) {
		cin >> t;
		sum += T - max(0, pos - t);
		pos = t + T;
	}

	cout << sum << endl;

	return ( 0 );
}


Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline())
a = []
for _ in xrange(n):
 a.append(int(stdin.readline()))
a.sort()
ans = sum(a)
if ans%10==0:
 ff = 0
 for i in a:
  if i%10:
   ff = 1; break
 if ff:
  ans-=i
 else:
  ans = 0
print ans

Measured memory_bytes: 2568
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <numeric>
#define pb push_back
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int INF =  2147483647;
const ll INFLL = 9223372036854775807;



int main() {
  int n, t, pre = 0;
  scanf("%d%d", &n, &t);
  int ans = t;
  for (size_t i = 0; i < n; i++) {
    int diff, ti;
    scanf("%d", &ti);
    diff = ti - pre;
    pre = ti;
    if (diff > t) {
      ans += t;
    } else {
      ans += diff;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
 
using namespace std;
typedef long long ll;

int main()
{
	ll N, A, B;
	scanf("%lld %lld %lld", &N, &A, &B);
	
	ll C = A+B;
	if(C >= N){
		printf("%lld\n", A < N ? A : N);
	}else{
		ll ans = (N / C) * A + ((N % C) < A ? N % C : A);
		printf("%lld\n", ans);
	}
	
	return 0;
}

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (a >= b) {
        cout << "delicious" << endl;
    } else if (b - a <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}


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

int main() {
    int a, b;
    while (1) {
        cin >> a >> b;
        if (a == 0 && b == 0) { break; }
        if (a < b) {
            cout << a << " " << b << endl;
        } else {
            cout << b << " " << a << endl;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m;
graph g;
graph r;
ll s,t;
ll vis[e5];
ll level[e5];
ll idx;
ll ans = 0;
vl anss;


ll dfs(ll x,ll c){
  vis[x]++;
  if(x == t) return c;
  for(auto y : g[x]){
    if(vis[y.first] == 1) continue;
    if(y.second == 0) continue;
    ll z = dfs(y.first, min(c,y.second));
    if(z > 0){
      g[x][y.first] -= z;
      r[y.first][x] += z;
      return z;
    }
  }
  for(auto y : r[x]){
    if(vis[y.first] == 1) continue;
    if(y.second == 0) continue;
    ll z = dfs(y.first, min(c,y.second));
    if(z > 0){
      r[x][y.first] -= z;
      g[y.first][x] += z;
      return z;
    }
  }
  return 0;
}

ll gcd(ll a,ll b){
  while(a > 0){
    b = b%a;
    swap(a,b);
  }
  return b;
}

int main(){
  while(true){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    vl b(n+1);
    vl c(m+1);
    for(ll i = 1;i <= n;i++) cin >> b[i];
    for(ll j = 1;j <= m;j++) cin >> c[j];
    g = graph();
    r = graph();
    s = 0;
    t = n+m+1;
    ans = 0;
    for(ll i = 1;i <= n;i++){
      for(ll j = 1;j <= m;j++){
        if(gcd(b[i],c[j]) > 1){
          g[i][n+j] = 1;
          r[n+j][i] = 0;
        }
      }
    }

    for(ll i = 1;i <= n;i++){
      g[s][i] = 1;
      r[i][s] = 0;
    }
    for(ll j = 1;j <= m;j++){
      g[n+j][t] = 1;
      r[t][n+j] = 0;
    }
    idx = t;
    for(;;){
      fill(vis,vis+(idx+1),0ll);
      ll z = dfs(s, INF);
      // cerr << z << endl;
      if(z <= 0) break;
      ans += z;
    }
    cout << ans << endl;
    // anss.push_back(ans);
  }
  //
  // for(ll x : anss){
  //   cout << ans << endl;
  // }
}



Measured memory_bytes: 12928
import math
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,P = map(int,input().split())
A = list(map(int,input().split()))
A_O = [e for e in A if e % 2 == 1]
A_E = [e for e in A if e % 2 == 0]
ans = 0
if P == 0:
    for k in range(math.floor(len(A_O)/2) + 1):
        for l in range(len(A_E) + 1):
            ans += c(len(A_O),2*k) * c(len(A_E),l)
elif P == 1:
    for k in range(math.floor((len(A_O) - 1) /2) + 1):
        for l in range(len(A_E) + 1):
            ans += c(len(A_O),2*k + 1) * c(len(A_E),l)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int main() {
    int x;
    scanf("%d", &x);
    printf("%d", x^1);
}


// author: rdd6584


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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int i = 0, Oflag = 0, Xflag = 0, OX = 0;
    while (i < N-1){
        if (S[i] == 'O'){
            Oflag = 1;
            Xflag = 0;
            if (S[i+1] == 'O'){
                i++;
            } else {
                OX++;
                i += 2;
            }
        } else {
            Xflag = 1;
            Oflag = 0;
            if (S[i+1] == 'O'){
                OX++;
                i += 2;
            } else {
                i++;
            }
        }
    }
    cout << OX << endl;
}


Measured memory_bytes: 3324
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    string S; cin>>S;
    int N=SZ(S);
    rep(i,N/2){
        if(S[i]!=S[N-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,N/2){
        if(S[i]!=S[N/2-1-i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = list(input())

r = N-1
w = 0

op = 0
while w < r : 
    while w < N and arr[w] != 'W' :
        w += 1
    while r >= 0 and arr[r] != 'R' :
        r -= 1

    if w < N and r >= 0 and w < r :
        op += 1
        arr[r], arr[w] = arr[w], arr[r]
        r -= 1
        w += 1  

print(op)



Measured memory_bytes: 10700
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		while(true){
			int n=stdIn.nextInt();
			int x=stdIn.nextInt();
			int ans=0;
			if(n==0&&x==0)
				System.exit(0);
			for(int i=1;i<=n;i++){
				for(int j=i+1;j<=n;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x)
							ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 26460
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  string S, T;
  cin >> S >> T;
  ll ssz = S.size(), tsz = T.size();
  ll ans = oo;
  for(ll i=0; i <= ssz - tsz; i++){
    ll tmp = 0;
    for(ll j=0; j < tsz; j++){
      if (S[i+j] != T[j])
        tmp++;
    }
    chmin(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

//#define INF 100000000
//#define MOD (int) (1e9+7)
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();

    for(int i = 1; i <= k; i++){
        cout << COM(k-1, k-i) * COM(n-k+1, n-k-(i-1)) % MOD << endl;
    }
}

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

int main() {
    int n,k;
    cin >> n >> k;
    int arr[k];
    for(int i=0;i<k;i++){
        cin >> arr[i];
    }
    int s = sizeof(arr)/sizeof(arr[0]);
    sort(arr, arr+k);
    int h = k, d = -arr[k-1]+n+arr[0];
    for(int i=0;i<k-1;i++){
        if(arr[i+1]-arr[i]>d){
            h=i;
            d=arr[i+1]-arr[i];
        }
    }
    cout << n-d << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };

int main() {
	ll n, m;
	cin >> n>>m;
	ll mi = 1e11;
	FOR(i, 1, m) {
		ll a = i*n;
		ll b = (n/2)*(m-i);
		ll c = ((n+1) / 2)*(m-i);
		ll ma = max(abs(a - b), abs(a - c));
		ma = max(ma, abs(b - c));
		mi = min(mi, ma);
		b = n*((m - i) / 2);
		c = n*((m - i + 1) / 2);
		ll ma2 = max(abs(a - b), abs(a - c));
		ma2 = max(ma2, abs(b - c));
		mi = min(mi, ma2);
	}
	FOR(i, 1, n) {
		ll a = i*m;
		ll b = (m / 2)*(n - i);
		ll c = ((m + 1) / 2)*(n - i);
		ll ma = max(abs(a - b), abs(a - c));
		ma = max(ma, abs(b - c));
		mi = min(mi, ma);
		b = m*((n - i) / 2);
		c = m*((n - i + 1) / 2);
		ll ma2 = max(abs(a - b), abs(a - c));
		ma2 = max(ma2, abs(b - c));
		mi = min(mi, ma2);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <queue>


int main(void)
{
    int N,x,flag,count;
    std::queue<std::pair<int,int>> Q;
    std::pair<int,int> p;
    scanf("%d",&N);
    x=0;
    flag=0;
    p.first=x;
    p.second=flag;
    count=0;
    Q.push(p);
    while(!Q.empty())
    {
        p=Q.front();
        Q.pop();
        x=p.first;
        flag=p.second;

        if(flag==7)
            count++;
        if(((long long)x)*10+3<=N)
        {
            p.first=x*10+3;
            p.second=flag|01;
            Q.push(p);
        }
        if(((long long)x)*10+5<=N)
        {
            p.first=x*10+5;
            p.second=flag|02;
            Q.push(p);
        }
        if(((long long)x)*10+7<=N)
        {
            p.first=x*10+7;
            p.second=flag|04;
            Q.push(p);
        }

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



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int bySearch(int nm, vector<int> t) {

	int mid, st, ed, ans;
	st = 0;
	ed = t.size();

	while (true)
	{
		mid = min((ed - st) / 2 + st, (int)t.size() - 1);
		if (nm == t[mid]) {
			ans = mid;
			break;
		}
		else if (nm > t[mid]) {
			st = mid + 1;
		}
		else
		{
			ed = mid;
		}
		if (ed <= st) {
			ans = -1;
			break;
		}
	}

	return ans;
}

int main() {

	int sn, tn, ttl;
	sn = tn = ttl = 0;

	cin >> sn;
	vector<int> s(sn);
	for (int i = 0;i < sn;i++) {
		cin >> s[i];
	}

	cin >> tn;
	vector<int> t(sn);
	for (int i = 0;i < tn;i++) {
		cin >> t[i];
	}

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

	for (int k = 0; k < tn;k++) {
		int tp = bySearch(t[k], s);
		if (tp > -1) ttl++;
	}

	cout << ttl << endl;

	return 0;
}



Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
int n,m,r;
int x[10];
int e[300][300];
int dp[8][1<<8];
int dfs(int v,int b){
  if(b==(1<<r)-1) return 0;
  if(~dp[v][b]) return dp[v][b];
  int res=1<<28;
  for(int i=0;i<r;i++){
    if((b>>i)&1) continue;
    int A=x[v],B=x[i];
    int c=e[A][B];
    res=min(res,dfs(i,b+(1<<i))+c);
  }
  return dp[v][b]=res;
}
signed main(){
  cin>>n>>m>>r;
  for(int i=0;i<r;i++) cin>>x[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j) e[i][j]=0;
      else e[i][j]=1<<28;
    }
  }
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    e[a][b]=e[b][a]=c;
  }
  for(int i=0;i<r;i++) x[i]--;
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
  
  memset(dp,-1,sizeof(dp));
  int a=INT_MAX;
  for(int i=0;i<r;i++)
    a=min(a,dfs(i,1<<i));
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 512
//A
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int K, A, B;
	scanf("%d%d%d", &K, &A, &B);
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			printf("OK\n");
			return 0;
		}
	}
	printf("NG\n");
}

Measured memory_bytes: 3760
N = int(input())
a = [int(x) for x in input().split()]

new_a = [0 for x in range(N)]

sw = False 
cnt = 0

for i in range(N) :
    new_a[cnt] = a[N - i - 1]
    if sw == False :
        cnt = N - cnt - 1
        sw = True
    else :
        cnt = -(cnt - N + 1) + 1
        sw = False
    
print(" ".join(map(str,new_a)))

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

int main(void){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    
    
    vector<ll> v(n+1,0);
    v[0] = a[0];
    for(int i = 1;i < n;i++)v[i] = v[i-1] + a[i];
    
    ll mod = 1e9+7,ans = 0;
    for(int i = 0;i < n;i++){
        ll num = v[n-1] - v[i];
        //cout << num * a[i] << endl;
        num %= mod;
        ans += ((num * a[i] + mod) % mod);
        ans %= mod;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 5628
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Rishabhdeep Singh
 */

// doot diddly donger cuckerino Hahahahahah
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

// @formatter:off
#define PB              push_back
#define EB              emplace_back
#define F               first
#define S               second
#define all(x)          begin(x), end(x)
#define rall(x)         rbegin(x), rend(x)
#define sz(x)           (long long) (x).size()
#define IOS             ios::sync_with_stdio(false);cin.tie(NULL); cout << fixed << setprecision(12);
#define IN_REP          int tt; cin >> tt; while(tt--)
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos(-1);

template<typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> void mini(T& x, T y) { x = min(x, y); }
template<typename T> void maxi(T& x, T y) { x = max(x, y); }
template<typename T, typename U> string to_string(pair<T, U> p) { return to_string(p.F) + " " + to_string(p.S); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class CSnack {
  public:

    void solveOne(istream& cin, ostream& cout) {
        ll a, b;
        cin >> a >> b;
        cout << (a * b / gcd(a, b) ) << endl;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int tc = 1;
//        cin >> tc;
        for(int test_case = 1; test_case <= tc; ++test_case){
            solveOne(cin, cout);
        }
    }
};

int main() {
    IOS;
	CSnack solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (PrintWriter out = new PrintWriter(System.out); Scanner sc = new Scanner(System.in);) {
			Task task = new Task();
			task.solve(sc, out);
			out.flush();

		} catch (Exception e) {

		}

	}

	static class Task {
		public void solve(Scanner sc, PrintWriter out) {
			int n = nint(sc);

			if (n <= 3) {
				out.print("No");
				return;
			}

			List<Integer> list4 = new ArrayList<>();
			for (int i = 4; i <= 100; i += 4) {
				list4.add(i);
			}
			List<Integer> list7 = new ArrayList<>();
			for (int i = 7; i <= 100; i += 7) {
				list7.add(i);
			}

			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < list4.size(); i++) {
				for (int j = 0; j < list7.size(); j++) {
					int ii = list4.get(i);
					int jj = list7.get(j);
					list.add(ii + jj);
				}
			}
			

			if (n % 4 == 0 || n % 7 == 0 || list.contains(Integer.valueOf(n))) {
				out.print("Yes");
				return;
			}
			out.print("No");
		}
	}

	// method
	static int nint(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static long nlong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static double ndouble(Scanner sc) {
		return Double.parseDouble(sc.next());
	}

	static float nfloat(Scanner sc) {
		return Float.parseFloat(sc.next());
	}

	static String nstr(Scanner sc) {
		return String.valueOf(sc.next());
	}

	static long[] longLine(Scanner sc, int size) {
		long[] lLine = new long[size];
		for (int i = 0; i < size; i++) {
			lLine[i] = nlong(sc);
		}
		return lLine;
	}

	static int[] intLine(Scanner sc, int size) {
		int[] iLine = new int[size];
		for (int i = 0; i < size; i++) {
			iLine[i] = nint(sc);
		}
		return iLine;
	}

	static String[] strLine(Scanner sc, int size) {
		String[] strLine = new String[size];
		for (int i = 0; i < size; i++) {
			strLine[i] = nstr(sc);
		}
		return strLine;
	}

	static long maxFromList(List<Long> longList) {
		return longList.stream().max(Comparator.naturalOrder()).get();
	}

	static long minFromList(List<Long> longList) {
		return longList.stream().min(Comparator.naturalOrder()).get();
	}

	public static int sumDigits(int n) {
		int sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	public static long sumDigits(long n) {
		long sum = 0;
		while (n != 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}

	static List<Integer> getIntegerList(Scanner sc, int size) {
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nint(sc));
		}
		return list;
	}

	static List<Long> getLongList(Scanner sc, int size) {
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < size; i++) {
			list.add(nlong(sc));
		}
		return list;
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll W, a, b;
  cin >> W >> a >> b;

  if(a + W < b) cout << b - (a + W) << endl;
  else if(b + W < a) cout << a - (b + W) << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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;}

int main () {
  int x, y, z;
  int K;
  cin >> x >> y >> z;
  cin >> K;
  vll a(x), b(y), c(z);

  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];

  RSORT(a);
  RSORT(b);
  RSORT(c);

  vll abc;
  rep(i,x) {
    rep(j,y) {
      //if ((i+1)*(j+1)>K) break;
      rep(k,z) {
        if ((i+1)*(j+1)*(k+1)>K) break;
        abc.pb(a[i]+b[j]+c[k]);
      }
    }
  }
  RSORT(abc);

  rep(i,K) {
    printf("%lld\n", abc[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1404
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
  
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(primeNumbers[input[i] - 0]);
  }
 
   
}
 
function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int8Array(max + 1);
 
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
     
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
 
  var primeNums = new Int32Array(max + 1);
  var sum = 0;
  for(var i = 1; i <= max; i++){
    sum = primeNums[i] += sum + (1 - primeNumbers[i]);
  }
   
  return primeNums;
}

Measured memory_bytes: 13580