akhauriyash/Code-Regression huggingface dataset:
/**
*    Username : adhoc_king
*    Name : adhoc_king
*    Institute : IIT Bombay
*/

#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
// #include <map>
// #include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>

using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()

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

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
    vi p, rank, setSize;                       // remember: vi is vector<int>
    int numSets;
public:
    UnionFind(int N) {
        setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    void unionSet(int i, int j) { 
        if (!isSameSet(i, j)) { numSets--; 
        int x = findSet(i), y = findSet(j);
        // rank is used to keep the tree short
        if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
        else                   { p[x] = y; setSize[y] += setSize[x];
                                 if (rank[x] == rank[y]) rank[y]++; } } }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string str;
    cin>>str;
    vi vec;
    for0(i,str.size()) if(str[i] == 'W') vec.push_back(i);
    int sum = 0;
    for0(i,vec.size()) sum += (vec[i] - i);
    cout<<sum;

    return 0;
}

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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
/*
think fast
think simple
*/
void mysol()
{
	int n, k;
	cin >> n;
	int arr[n];
	int ans = 0;
	for (int &a : arr)
		cin >> a, ans ^= a;

	for (int a : arr)
	{
		cout << (a ^ ans) << ' ' ;
	}

	// sort(arr, arr + n);
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
    string S, T;
    int cnt = 0;
    cin >> S >> T;
    int l = S.length();
    rep(i, l)
    {
        if (S[i] != T[i])
        {
            cnt = cnt + 1;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3852
<>;
for(`factor`){
	$x=$y=1;
	s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$y*=$&<1e5&&$&**(-$a%3)/ge;
	++$h{$x};
	$t{$x}=$y
}
$%=!!$h{1};
$h{1}=0;
for(keys%h){
	$%+=$h{$h{$_}>$h{$t{$_}}?$_:$t{$_}};
	$h{$_}=$h{$t{$_}}=0
}
print$%


Measured memory_bytes: 46680
import sys
import re

N = sys.stdin.readline() 
A = (sys.stdin.readline()).split()
B = (sys.stdin.readline()).split()
C = (sys.stdin.readline()).split()

j=0
result = 0

for i in A:
  i = int(i)
  result += int(B[i-1])
  
  if j != 0 and j+1 is i:
    result += int(C[j-1])
  j = i
  

print (result)

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

int main(){	
	ll a;
	double b;
	cin >> a >> b;
	b = b*100+0.5;
	ll s;
	ll c;
	c = floor(b);
	s = c%100;
	c /=100;
	ll ans;
	ans = a * c + a * s/100;
	cout << ans << endl;
	return 0;


}




Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin >> n >> x;
	int m[n];
	for(int i=0;i<n;i++)
	{
		cin >> m[i];
		x -= m[i];
	}
	sort(m,m+n);
	cout << n+x/m[0];
	return 0;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    ll n;
    cin>>n;
    string ans="";
    while(n!=0){
        if(n%2 != 0){//奇数のとき
            n--;
            ans="1"+ans;
        }else{
            ans="0"+ans;
        }
        n/=-2;
    }
    if(ans==""){
        ans="0";
    }
    cout<<ans<<endl;
    return 0;
}


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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int ans[26];
string s;

main() {
    cin >> s;
    repv(i,s) ans[(int)(s[i]-'a')]=1;
    rep(i,26) if (!ans[i]) {
        ct((char)(i+'a'))
        return 0;
   }
   ct("None")
}

Measured memory_bytes: 512
mod=10**9+7
N,K=map(int,input().split())

def P(x, y):
    r = 1
    for i in range(y):
        r = (r * (x - i)) % mod
    return r
G = [[] for _ in range(N+1)]
g=[0]*(N+1)
for v in range(N-1):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)
    g[a] += 1
    g[b] += 1
r = 1
for v in range(N-1):
    r=(P(K-2,g[v+1]-1)*r)%mod
#print((K*P(K-1,g[-1])*r)%mod)

s,V=G[1],{1}
r=P(K-1,len(s))
while len(s)!=0:
    v = s.pop()
    if v in V:continue
    V.add(v)
    s += G[v]
    r=(P(K-2,len(G[v])-1)*r)%mod
print((K*r)%mod)


Measured memory_bytes: 74912
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k, l;
  
  ll H, W, N;
  cin >> H >> W >> N;
  ll sx, sy;
  cin >> sx >> sy; sx--; sy--;
  string s, t;
  cin >> s >> t;
  
  ll tx, ty;
  
  //上を目指す
  tx=sx;
  for(i=0; i<N; i++) {
    if(s[i]=='U') tx--;
    if(tx<0) { pt("NO"); return 0;}
    if(t[i]=='D' && tx<H-1) tx++;
  }
  
  //下を目指す
  tx=sx;
  for(i=0; i<N; i++) {
    if(s[i]=='D') tx++;
    if(tx>=H) { pt("NO"); return 0;}
    if(t[i]=='U' && tx>0) tx--;
  }
  
  //左を目指す
  ty=sy;
  for(i=0; i<N; i++) {
    if(s[i]=='L') ty--;
    if(ty<0) { pt("NO"); return 0;}
    if(t[i]=='R' && ty<W-1) ty++;
  }
  
  //右を目指す
  ty=sy;
  for(i=0; i<N; i++) {
    if(s[i]=='R') ty++;
    if(ty>=W) { pt("NO"); return 0;}
    if(t[i]=='L' && ty>0) ty--;
  }
  
  pt("YES");
}




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

int main(int argc, char **argv)
{
    int H, W;
    std::cin >> H >> W;

    std::vector<std::vector<char>> M(H+2, std::vector<char>(W+2, '.'));
    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            std::cin >> M.at(i).at(j);
        }
    }

    for(int i = 1; i < H+1; i++){
        for(int j = 1; j < W+1; j++){
            bool flag = false;
            if(M.at(i).at(j) == '#'){
                flag |= (M.at(i).at(j-1) == '#');
                flag |= (M.at(i).at(j+1) == '#');
                flag |= (M.at(i-1).at(j) == '#');
                flag |= (M.at(i+1).at(j) == '#');
                if(flag == false){
                    std::cout << "No" << std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
    
}


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

using namespace std;

typedef long long ll;

int gcd3(int, int, int);

int main()
{
    int k;
    ll sum = 0;
    cin >> k;

    for (int a=1; a<=k; a++) {
        for (int b=1; b<= k; b++) {
            for (int c=1; c<=k; c++) {
                sum += gcd3(a,b,c);
            }
        }
    }

    cout << sum;


    return 0;
}

int gcd3(int a, int b, int c)
{
    return __gcd(__gcd(a,b), c);
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int D[100][100][100];
int main() {
	int i, j, k;
	for (i = 0; i <= 90; i++)for (j = 0; j <= 99; j++)for (k = 0; k <= 90; k++) {
		D[i][j][k] = 1e9;
		if (i == j&&j == k)D[i][j][k] = 0;
	}
	for (i = 80; i >= 0; i--)for (j = 80; j >= 0; j--)for (k = 80; k >= 0; k--) {
		if (i >= 2)D[i - 2][j][k] = min(D[i - 2][j][k], D[i][j][k] + 1);
		if (j >= 2)D[i][j - 2][k] = min(D[i][j - 2][k], D[i][j][k] + 1);
		if (k >= 2)D[i][j][k - 2] = min(D[i][j][k - 2], D[i][j][k] + 1);
		if (i && j)D[i - 1][j - 1][k] = min(D[i - 1][j - 1][k], D[i][j][k] + 1);
		if (i && k)D[i - 1][j][k - 1] = min(D[i - 1][j][k- 1], D[i][j][k] + 1);
		if (k && j)D[i][j - 1][k- 1] = min(D[i][j - 1][k - 1], D[i][j][k] + 1);
	}
	scanf("%d%d%d", &i, &j, &k);
	printf("%d\n", D[i][j][k]);
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
   
int main(){
  int n,t;cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  long long int d2=0,d3=0;
  int d1=0,d9=0;
    
  for(int i=0;i<n;i++) cin>>x.at(i);
  for(int i=0;i<n;i++) cin>>y.at(i);
    
  for(int i=0;i<n;i++){
    t=abs(x.at(i)-y.at(i));
    d1+=t;
  }
    
  for(int i=0;i<n;i++){
    t=abs(x.at(i)-y.at(i));
    d2+=t*t;
  }
           
  for(int i=0;i<n;i++){
    t=abs(x.at(i)-y.at(i));
    d3+=t*t*t;
  }
   for(int i=0;i<n;i++){
     	t=abs(x.at(i)-y.at(i));
        d9=max(d9,t);
   }
                 
               printf("%lf\n",(double)d1);
               printf("%lf\n",sqrt(d2));
               printf("%lf\n",pow(d3,1.0/3.0));
               printf("%lf\n",(double)d9);
}


Measured memory_bytes: 3356
#include<iostream>
using namespace std;
bool c;
int n;
int main(){
    cin>>n;
    for(int a=1;a<10;a++)
    for(int b=1;b<10;b++)
    if(n==a*b){
        c=1;
        break;
    }
    if(c)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
//Used code from antontrygubO_o because I don't know how to use modulo division with inverses, I have to learn it ASAP
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

#define vi vector<int>


#define ll long long
#define ld long double
#define mp make_pair
#define what_is(x) cerr << #x << " is " << x << endl;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

int p = 1e9+7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}


vector<int> Z(vector<int> s)
{
    int n = s.size();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R-L] == s[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R-L] == s[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
    return z;
}

mt19937 rnd(time(0));

const int N = 2e6;

vector<int> facs(N);
vector<int> invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}


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

    init();
  int xx, yy;
    cin >> xx >> yy;
    int p = 0, q = 0;
    int x = 0, y = 0, flag = 0;
    while(x+2 <= xx && y+1 <= yy){
        ++p;
        x += 2, y += 1;
        int rem_x = xx - x;
        int rem_y = yy - y;
        if(rem_y%2 == 0) {
            rem_x -= rem_y/2;
            q = rem_y/2;
            if(rem_x == 0) {
                flag = 1;
                break;
            }
        }
    }
    if(flag) {
      if(xx == 2*yy)
        	cout << 1 << "\n";
      else
      		cout<<mul(facs[p+q], mul(invfacs[p], invfacs[q]));
    }
    else {
      if(2*xx == yy) 
      		cout << 1 << "\n";
      else
      		cout << 0 << "\n";
    }
 }




Measured memory_bytes: 15872
package main

import "fmt"

func main() {
	// Code for A - Fairness
	var A, B, C, K int
	fmt.Scan(&A, &B, &C, &K)

	if K%2 == 0 {
		fmt.Println(A - B)
	} else {
		fmt.Println(B - A)
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
#define mp make_pair
#define mod 1000000007
#define INF 1e9+5
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(int i=a;i<(int)b;i++)
#define ff first
#define ss second
#define int long long
ll min(ll a, ll b) {return a>b?b:a;}
ll max(ll a, ll b) {return a>b?a:b;}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int a=gcd(i,j);
                int b=gcd(a,k);
                ans+=b;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    bool flag = false;

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                flag = true;
                break; 
            }
        if (flag) break;
        }
    if (flag) break;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100000;
const int yzd = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }
 
int n, m, s, t, u, v, c;
struct tt {int to, next, cost; }edge[(N<<2)+5];
int path[N+5], top;
int ans1[N+5], ans2[N+5], vis[N+5], in[N+5];
LL dist1[N+5], dist2[N+5];
queue<int>Q;
vector<int>to[N+5];
 
void add(int u, int v, int c) {
    edge[++top].to = v, edge[top].cost = c, edge[top].next = path[u], path[u] = top;
}
void SPFA(int s, LL *dist) {
    dist[s] = 0; Q.push(s); vis[s] = 1;
    while (!Q.empty()) {
    int u = Q.front(); Q.pop(); vis[u] = 0;
    for (int i = path[u]; i; i = edge[i].next)
        if (dist[edge[i].to] > dist[u]+edge[i].cost) {
        dist[edge[i].to] = dist[u]+edge[i].cost;
        if (!vis[edge[i].to]) {
            vis[edge[i].to] = 1; Q.push(edge[i].to);
        }
        }
    }
}
void topsort(int s, LL *dist, int *ans) {
    for (int u = 1; u <= n; u++) {
    to[u].clear();
    for (int i = path[u]; i; i = edge[i].next)
        if (dist[edge[i].to] == dist[u]+edge[i].cost) to[u].push_back(edge[i].to), ++in[edge[i].to];
    }
    ans[s] = 1; Q.push(s);
    while (!Q.empty()) {
    int u = Q.front(), size = to[u].size(); Q.pop();
    for (int i = 0; i < size; i++) {
        if (--in[to[u][i]] == 0) Q.push(to[u][i]); (ans[to[u][i]] += ans[u]) %= yzd;
    }
    }
}
void work() {
    read(n), read(m), read(s), read(t);
    for (int i = 1; i <= m; i++) {
    read(u), read(v), read(c); add(u, v, c); add(v, u, c);
    }
    memset(dist1, 127/3, sizeof(dist1));
    SPFA(s, dist1); topsort(s, dist1, ans1);
    memset(dist2, 127/3, sizeof(dist2));
    SPFA(t, dist2); topsort(t, dist2, ans2);
    int ans = 1ll*ans1[t]*ans1[t]%yzd;
    for (int u = 1; u <= n; u++) {
    if (dist1[u] == dist2[u] && dist2[u]*2 == dist1[t]) (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[u]%yzd*ans2[u]%yzd) %= yzd;
    for (int i = path[u]; i; i = edge[i].next)
        if (dist1[u]+edge[i].cost+dist2[edge[i].to] == dist1[t] && dist1[u]*2 < dist1[t] && dist2[edge[i].to]*2 < dist1[t])
        (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[edge[i].to]%yzd*ans2[edge[i].to]%yzd) %= yzd;
    }
    writeln((ans+yzd)%yzd);
}
int main() {
    work();
    return 0;
}

Measured memory_bytes: 14208
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int x;
	rep(i, n) {
		cin >> x;
		a[i] -= x;
	}
	sort(a.begin(), a.end(), check);
	int ans = 0;
	rep(i, n) {
		if (a[i] > 0) {
			ans += a[i];
		}
		else {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
name_list =[0,0,0,0,0]
alp =  ["M","A","R","C","H"]
for i in range(n):
  s = input()
  if s[0] in alp:
    name_list[alp.index(s[0])] += 1
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += name_list[i] * name_list[j] * name_list[k]

print(ans)


Measured memory_bytes: 9060
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	int N,K;cin>>N>>K;
	int x[N];rep(t ,N)cin>>x[t];
	int sum = 0;
	for(int j = 0; j < N; j++){
		if(K - x[j] >= x[j])sum += x[j] * 2;
		else sum += (K - x[j]) * 2;
	}
	cout<<sum;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let calc m a r c h =
        m * a * r         +
        m * a *     c     +
        m * a *         h +
        m *     r * c     + 
        m *     r *     h +
        m *         c * h +
            a * r * c     +
            a * r *     h +
            a *     c * h +
                r * c * h
    in
    let rec loop i m a r c h =
        if i = n then calc m a r c h else
        let s = Scanf.scanf " %s" (fun s -> s) in
        match s.[0] with
        | 'M' -> loop (i + 1) (m + 1) a r c h
        | 'A' -> loop (i + 1) m (a + 1) r c h
        | 'R' -> loop (i + 1) m a (r + 1) c h
        | 'C' -> loop (i + 1) m a r (c + 1) h
        | 'H' -> loop (i + 1) m a r c (h + 1)
        | _   -> loop (i + 1) m a r c h
    in
    loop 0 0 0 0 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 2688
//https://atcoder.jp/contests/agc018/tasks/agc018_a
//A - Getting Difference
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
ll lcm(ll num1,ll num2){
    return num1 / __gcd(num1,num2) * num2;
}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-4.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,K; cin>>N>>K;
    vector<ll> an(N);
    bool ans=false;
    for(auto&& a:an){
        cin>>a;
        if (K<=a) ans=true;
    }
    assert(an.size()>=1);
    ll gcdv=an[0];
    FOR(i,1,N){
        gcdv=__gcd(gcdv,an[i]);
    }
    ans &= (K%gcdv==0);
#if 0
    sort(an.begin(),an.end());

    vector<ll> candidate;
    for(const auto& a:an){
        auto df=a-K;
        if(df>=0) candidate.push_back(df);
    }

    bool ans=false;
    for(ll i=0;i<an.size();++i){
        for(ll j=i+1;j<an.size();++j){
            auto val = abs(an[i]-an[j]);
            if (val==0) continue;
            for(auto& cv:candidate){
                if(cv%val==0){
                    ans=true;
                    break;
                }
            }
        }
    }
#endif
    cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a1 = Integer.parseInt(stdIn.next());
    int a2 = Integer.parseInt(stdIn.next());
    int a3 = Integer.parseInt(stdIn.next());

    if (a1 + a2 + a3 >= 22) {
      System.out.println("bust");
    } else {
      System.out.println("win");
    }
  }
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    LL n;
    while (cin >> n) {
        LL ans = 0;
        if (n == 2)
            ans = 1;
        else
            ans = (n-1)*n/2 - 1 + n%2 + (n%2 == 0);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct page{
	string name,button[100];
	int b,x1[100],x2[100],y1[100],y2[100];
};

page pages[100];
int buf[1000];

int main() {
	int n;
	while(n=in()){
		int w,h;
		cin>>w>>h;
		int i,j;
		for(i=0;i<n;i++){
			cin>>pages[i].name>>pages[i].b;
			for(j=0;j<pages[i].b;j++){
				cin>>pages[i].x1[j];
				cin>>pages[i].y1[j];
				cin>>pages[i].x2[j];
				cin>>pages[i].y2[j];
				cin>>pages[i].button[j];
			}
		}
		buf[0]=0;
		int now=0;
		int size=1;
		int m=in();
		i=0;
		string ope;
		int x,y;
		for(j=0;j<m;j++){
			cin>>ope;
			if(ope=="click"){
				cin>>x>>y;
				int k;
				for(k=0;k<pages[i].b;k++){
					if(pages[i].x1[k]<=x&&x<=pages[i].x2[k]&&pages[i].y1[k]<=y&&y<=pages[i].y2[k]){
						string next=pages[i].button[k];
						int p;
						for(p=0;p<n;p++){
							if(pages[p].name==next)i=p;
						}
						now++;
						buf[now]=i;
						size=now;
						break;
					}
				}
			}else if(ope=="back"){
				if(now>0)now--;
				i=buf[now];
			}else if(ope=="forward"){
				if(now<size)now++;
				i=buf[now];
			}else if(ope=="show"){
				cout<<pages[i].name<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-6;
const ll MOD = 1000000007;
const ll INF = 1e15;

int main() {
	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ll ans = INF;
	for (ll i = 0;i <= max(X, Y);i++) {
		ans = min(ans, i * 2 * C + max(0LL, (X - i) * A) + max(0LL, (Y - i) * B));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 888
h, w = map(int, input().split())

s = [input() for _ in range(h)]

ans = 'Yes'

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#' and s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
            ans = 'No'

print(ans)


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	cout << s[0];
	cout << s.size()-2;
	cout << s[s.size()-1] << "\n";

	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
i = 0
ans = 0
chg = 1
mul = 0
while chg == 1:
    chg = 0
    for i in range(n):
        if b[i]-b[i-1]-b[(i+1)%n] >= a[i]:
            mul = (b[i]-a[i])//(b[i-1]+b[(i+1)%n])
            b[i] -= (b[i-1]+b[(i+1)%n])*mul
            ans += mul
            chg = 1
print(ans if a==b else -1)

Measured memory_bytes: 118904
MOD = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

f = [1]
for i in range(10**5+7):
    f.append(f[-1]*(i+1)%MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

ans = 0
for i in range(N-K+1):
    ans += (A[i] - A[-1-i]) * nCr(N-1-i, K-1)
    ans %= MOD
print(ans)


Measured memory_bytes: 14416
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

alias E = Tuple!(int, "node", int, "w");

void calc(int n, int[][] a) {
    E[][] adj;
    foreach (_; 0..n) adj ~= [[]];
    foreach (e; a) {
        int u = e[0], v = e[1], w = e[2];
        adj[u] ~= E(v, w);
        adj[v] ~= E(u, w);
    }

    auto ans = new int[n];
    void dfs(int node, int prev, int color) {
        ans[node] = color;
        foreach (e; adj[node]) {
            if (e.node == prev) continue; // 逆戻り
            if (e.w % 2 == 0) dfs(e.node, node, color);
            else dfs(e.node, node, color ^ 1);
        }
    }
    dfs(0, -1, 0);

    foreach (c; ans) writeln(c);
}

void main() {
    int n = readint;
    int[][] a;
    for (int i = 0; i < n - 1; i++) {
        auto x = readints;
        a ~= [x[0]-1, x[1]-1, x[2]];
    }
    calc(n, a);
}


Measured memory_bytes: 17148
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <stdio.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  for(int i=0; i<n; i++) std::cin >> a[i];
  std::sort(a.begin(), a.end());
  int c = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n-i-1; ++j) {
      for (int k = 0; k < n-i-j-2; ++k) {
        if (a[i+j+1] < a[i] + a[i+j+k+2] && a[i+j+k+2] < a[i+j+1] + a[i]) {
          c += 1;
        }
      }
    }
  }
  printf("%d", c);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<bitset>
using namespace std;

bitset<2002005> bi;
int n;

int main()
{
	scanf("%d",&n);
	bi[0]=1;int s=0;
	for (int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		s+=x;bi|=bi<<x;
	}
	for (int i=s/2+(s&1);;i++)
		if (bi[i]) {printf("%d",i);return 0;}
	return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n, d;
   cin>>n>>d;
   int cnt=0;
   rep(i, n){
      int x, y;
      cin>>x>>y;
      if((ll)x*x+(ll)y*y<=(ll)d*d) cnt++;
   }
   cout<<cnt<<endl;
   return 0;
}


Measured memory_bytes: 3628
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 110;
const int Mod = 1e9+7;

int n,m;
int a[maxn];
int f[maxn][maxn][maxn];

void add(int &x,int y){ x+=y; if(x>=Mod)x-=Mod; }

int main()
{
	scanf("%d",&n); m=2*n-1;
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	
	f[1][1][1]=1;
	for(int k=1;k<n;k++)
	{
		for(int i=1;i<=m;i++) for(int j=1;j<=i;j++) if(f[k][i][j])
		{
			int tmp=f[k][i][j];
			int now=j,al=i;
			if(a[n-k]!=a[n-k+1]) al++,now++;
			if(a[n+k]!=a[n+k-1]) al++;
			
			add(f[k+1][al][now],tmp);
			for(int l=1;l<now;l++) add(f[k+1][al-(now-l-1)][l],tmp);
			for(int l=now+1;l<=al;l++) add(f[k+1][al-(l-now-1)][now+1],tmp);
		}
	}
	int re=0;
	for(int i=1;i<=m;i++) for(int j=1;j<=i;j++) add(re,f[n][i][j]);
	printf("%d\n",re);
	
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<P> g[100005];
vector<int> res(100005);
vector<bool> vi(100005);

void dfs(int s, int col = 0) {
	res[s] = col;
	vi[s] = true;
	for (auto& c : g[s]) {
		if (vi[c.first]) continue;
		if (c.second % 2 == 0) {
			dfs(c.first, col);
		}
		else {
			dfs(c.first, col ^ 1);
		}
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
	}
	dfs(0);
	rep(i, n) cout << res[i] << endl;
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

struct UF{
    int par[200001];
    int runk[200001];
    void init(int n){
    for(int i=0;i<=n;i++){
        par[i] = i;
        runk[i] = 0;
    }
}
int find(int n){
    if(par[n] == n)return n;
    return par[n] = find(par[n]);
}
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y)return;
    if(runk[x]<runk[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(runk[x]==runk[y])runk[x]++;
    }
}
bool issame(int x,int y){
    return find(x)== find(y);
}

};


int main(){
    UF uni1,uni2;
    int N,K,L;
    cin >> N >> K >> L;
    uni1.init(N);
    uni2.init(N);
    int p,q;
    for(int i=0;i<K;i++){
        cin >> p >> q;
        p--,q--;
        uni1.unite(p,q);
    }
    int r,s;
    for(int i=0;i<L;i++){
        cin >> r >> s;
        r--,s--;
        uni2.unite(r,s);
    }
    using pint = pair<int,int>;
    map<pint,int> ma;
    for(int i=0;i<N;i++){
        pint p(uni1.find(i),uni2.find(i));
        ma[p]++;
    }
    for(int i=0;i<N;i++){
        pint p(uni1.find(i),uni2.find(i));
        cout << ma[p] << ' ';
    }

    
    
    return 0;

}

Measured memory_bytes: 15232
#include <stdio.h>
typedef long long ll;
int main() {
	int n, a, b;
	ll ans;
	scanf("%d%d%d", &n, &a, &b);
	if (a > b || (n == 1 && a != b)) {
		ans = 0;
	} else {
		ans = 1 + ((ll)b * (n - 1) + a) - ((ll)a * (n - 1) + b);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for j in range(H):
        for i in range(W):
            if (i + j) % 2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
if n < 3:
    print(max(x))
    exit()
x.sort(reverse=True)
k = n - 2
ans = x[0]
x.pop(0)
ans += 2*sum(x[:k//2])
if k%2:
    ans += x[k//2]
print(ans)

Measured memory_bytes: 92040
#include<stdio.h>
int main()
{
    char a[40],b[40];
    int i,len=0;
    scanf("%s %s",a,b);
    for(i=0;i<3;i++)
    {
        if(a[i]==b[i])

            len++;

    }
    printf("%d",len);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;
const ll MOD = 1000000007;

int main(){
  int r;
  cin >> r;
  if(r<1200){
    cout << "ABC" <<endl;
  }else if(r < 2800){
    cout << "ARC" <<endl;
  }else{
    cout << "AGC" <<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,i;
  int sum=0;
  cin >> n;
  i=n;
  while(n>0){
    sum+=n%10;
    n=n/10;
  }
    
  if(i%sum==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker,"/stack:200000000")
#include <bits/stdc++.h>
using namespace std;

#define PI 2*acos(0.0)
#define print(x) return cout<<x<<endl,0
#define watch(x) cerr<<#x<<"-> "<<x<<endl
#define CLEAR(x,val) memset(x,val,sizeof(x))
#define int long long

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MOD = 998244353;
const int INF = 1000000000;

int modpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)
			res = (res%MOD*a%MOD)%MOD,res%=MOD;
		a = (a%MOD*a%MOD)%MOD;
		b >>= 1;
	}
	return res%MOD;
}
signed main()
{	
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin.tie(0), cout.tie(0);
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int d[n];
	int maxi = 0;
	map<int,int> mp;
	for(int i=0;i<n;i++)
		cin >> d[i],mp[d[i]]++,maxi=max(maxi,d[i]);

	if(maxi==0||mp[0]>1||d[0]!=0)
		print("0");

	for(int i=0;i<=maxi;i++)
		if(mp[i]==0)
			print("0");

	int res = 1;
	for(int i=1;i<=n;i++)	
		res *= modpow(mp[i],mp[i+1])%MOD, res%=MOD;

	print(res%MOD);
	return 0;
}

Measured memory_bytes: 7296
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	auto nm = readln.split.map!(to!int);
	auto co = readln.split.map!(to!int);
	auto dp = new int[](nm[0] + 1);
	dp[] = int.max;
	foreach (c; co) {
		if (c > nm[0]) continue;
		dp[c] = 1;
	}
	foreach (i; 1..nm[0]) {
		foreach (c; co) {
			if (i+c > nm[0]) continue;
			dp[i+c] = min(dp[i+c], dp[i]+1);
		}
	}
	dp[nm[0]].writeln;
	
}

Measured memory_bytes: 1256
n, q = list(map(int, input().split()))
proc = []
[proc.append(input().split()) for _ in range(n)]
for i in range(n):
    proc[i][1] = int(proc[i][1])

answer = []
time = 0
while len(proc) != 0:
    target = proc.pop(0)

    if target[1] <= q:
        time += target[1]
        answer.append([target[0], time])
    else:
        time += q
        target[1] -= q
        proc.append(target)

[print(*answer[i]) for i in range(len(answer))]


Measured memory_bytes: 19288
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

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

    int ans[100] = {};
    ans[0] = arr[0];
    for (int i = 0; i < n - 1; i++)
        ans[i] = min(ans[i], arr[i]), ans[i + 1] = arr[i];
    ans[n - 1] = arr[n - 2];

    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += ans[i];
    cout << sum << '\n';

    return 0;
}


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

signed main(){
  
  string S;
  cin>>S;
  
  if( S[0] == S[1] && S[1] == S[2] ) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  
  return 0;
}


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

long long check(long long a,long long x){
  if (a == -1) return 0;
  else return (a + x) / x;
}

int main() {
  long long a,b,x;
  cin >> a >> b >> x;
  cout << check(b,x) - check(a - 1,x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[409],dp[409][409];
ll best(ll l,ll r)
{
    if(l==r) return 0;
    ll &ans=dp[l][r];
    if(ans!=-1)return ans;
    ans=LLONG_MAX;
    for(ll i=l;i<r;i++)
    ans=min(ans,best(l,i)+best(i+1,r)+a[r]-a[l-1]);
    return ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(dp,-1,sizeof dp);
cin>>n;
for(ll i=1;i<=n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
    dp[i][i]=0;
}
cout<<best(1,n);
return 0;
}


Measured memory_bytes: 4944
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    W(n/2*((n+1)/2));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

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

int main() 
{ 
    FIO
    int t;
    t = 1;
    while(t--)
    {
        long double n,b;
        cin >> n >> b;

        long double comp = floor(n*b);

        cout << (ll)comp << endl;
        
    }
    return 0; 
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

ll f(ll n)
{
	ll res{1};
	for (ll i = 2; i <= n; ++i)
		res *= i;
	return res;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<pair<ll, ll>> coo(N);
	for (ll i = 0; i < N; ++i) cin >> coo[i].first >> coo[i].second;
	sort(coo.begin(), coo.end());
	double res{0};
	do
	{
		ll px = coo[0].first;
		ll py = coo[0].second;
		for (ll i = 1; i < N; ++i)
		{
			res += sqrt(pow(px-coo[i].first, 2) + pow(py-coo[i].second, 2));
			px = coo[i].first;
			py = coo[i].second;
		}
	} while (next_permutation(coo.begin(), coo.end()));
	// std::cout << "res : " << res << std::endl;
	std::cout << fixed << setprecision(10) << res / f(N)  << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll x;
  cin>>x;
  int ans = 1;
  for(int i=1; i<=x; ++i){
    for (int j=2;pow(i,j)<=x&&j<=x; j++){
    ans =max(ans,(int)pow(i,j));
    
    
    }
  }
cout << ans <<endl;
}



  


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int A, B, C, D, E, F;
    scan(A, B, C, D, E, F);

    int ans_w = 100*A, ans_s = 0;

    foreach (x ; 0 .. 31) {
        foreach (y ; 0 .. 31) {
            int water = 100 * (A * x + B * y);

            if (water == 0) continue;

            int L = min((A*x + B*y) * E, F - 100*(A*x + B*y));
            if (L < 0) break;

            foreach (w ; 0 .. 3001) {
                if (L - C*w < 0) break;
                
                int z = (L - C*w) / D;

                //if (z < 0) break;

                int sugar = C*w + D*z;

                if (ans_s * (water + sugar) < sugar * (ans_w + ans_s)) {
                    ans_w = water;
                    ans_s = sugar;

                    debug {
                        writeln(ans_w, " ", ans_s);
                    }
                }
            }
        }
    }

    writeln(ans_w + ans_s, " ", ans_s);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	int sx,sy,tx,ty;
	string s;
	cin>>sx>>sy>>tx>>ty;
	rep(i,ty-sy)s+='U';
	rep(i,tx-sx)s+='R';
	rep(i,ty-sy)s+='D';
	rep(i,tx-sx)s+='L';
	s+='L';
	rep(i,ty-sy+1)s+='U';
	rep(i,tx-sx+1)s+='R';
	s+='D';
	s+='R';
	rep(i,ty-sy+1)s+='D';
	rep(i,tx-sx+1)s+='L';
	s+='U';
	cout<<s<<endl;
	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
#define N 123456
int main(void){
    int x; cin >> x;
    int p[N]={0};
    p[0]=1; p[1]=1;
    for(int i=2;i<=sqrt(N);i++){
        if(p[i]==0){
            for(int j=2*i;j<N;j+=i)
                p[j]=1;
        }
    }
    int ans = 99;
    for(int i=2;i<=1000000;i++){
        if(i>=x&&p[i]==0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 768