akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Collections.Generic;

namespace AGC024C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var A = ss.Next(long.Parse, N);

            if (A[0] != 0)
            {
                sw.WriteLine(-1);
                return;
            }

            var ans = 0L;
            for (var i = 1; i < N; i++)
            {
                if (A[i] > A[i - 1] + 1)
                {
                    sw.WriteLine(-1);
                    return;
                }

                if (A[i] == A[i - 1] + 1) continue;
                if (A[i] <= A[i - 1]) ans += A[i - 1];
            }
            ans += A[N - 1];

            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 17440
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

ll comb[55][55];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  comb[0][0]=1;
  rep(i,52)rep(j,52){
    comb[i+1][j]+=comb[i][j];
    comb[i+1][j+1]+=comb[i][j];
  }
  int n,p;
  cin>>n>>p;
  vector<int> cnt(2);
  rep(i,n){
    int x;
    cin>>x;
    cnt[x%2]++;
  }
  ll re=0;
  rep(i,cnt[1]+1)if(i%2==p) re+=comb[cnt[1]][i];
  rep(i,cnt[0]) re*=2;
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

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

	ll n, m;
	cin >> n >> m;

	ll a[n];
	ll sum = 0;
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
		sum += a[i];
	}

	ll x = 0;
	for ( int i = 0; i < n; i++ ) {
		if ( ((double)sum / (m * 4)) <= a[i] ) {
			x++;
		}
	}

	if ( x >= m ) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  string s;
  bool flag=true;
  cin>>n>>s;
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2]){
	flag=false;
	break;
      }
    }
  }
  else flag=false;
  
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<pair<int, ll> > >edge(N);
  int L, R;
  ll C;
  for(int i=0;i<M;++i) {
    cin>>L>>R>>C;
    L--;
    R--;
    edge[L].push_back(mp(R, C));
  }
  for(int i=0;i<N-1;++i) {
    edge[i+1].push_back(mp(i, 0));
  }
  priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > que;
  que.push(mp(0, 0));
  pair<ll, int> state;
  ll cost;
  int node;
  map<int, ll> amap;
  for(int i=0;i<N;++i) {
    amap[i] = big;
  }
  while(!que.empty()) {
    state = que.top();que.pop();
    node = state.se;
    cost = state.fi;
    if(amap[node]<=cost) continue;
    amap[node] = cost;
    for(int i=0;i<edge[node].size();++i) {
      if(amap[edge[node][i].fi]<=cost+edge[node][i].se) continue;
      que.push(mp(cost+edge[node][i].se, edge[node][i].fi));
    }
  }
  if(amap[N-1]==big) cout<<-1<<endl;
  else cout<<amap[N-1]<<endl;
}



Measured memory_bytes: 17872
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] b = new int[n - 1];
		for (int i = 0; i < n - 1; i++)
			b[i] = in.nextInt();
		System.out.println(solve(n, b));
		in.close();
	}

	private static int solve(int n, int[] b) {
		int r = b[0];
		for (int i = 0; i < n - 2; i++)
			if (b[i] <= b[i + 1])
				r += b[i];
			else
				r += b[i + 1];
		r += b[n - 2];
		return r;
	}
}

Measured memory_bytes: 22228
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], long long int first, long long int last){
    long long int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main() {
    char s[100];
    int i;
    scanf("%s",s);
    
    for(i=0;i<strlen(s);i++) {
        printf("x");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);


    int n,m;
    cin >> n >> m;
    int ary[n];
    rep(i,n) cin >> ary[i];

    int sum = 0;
    rep(i,n) sum += ary[i];
    int border;
    if (sum%(4*m)==0)
    {
        // sum = 12, m=1ならborderは3-1の2
        border = sum / (4*m) -1;
    }
    else
    {
        // sum = 13ならborderは3
        border = sum / (4*m);
    }
    
    sort(ary, ary+n, greater<int>());
    // cout << "sum: " << sum << endl;
    // cout << "ary[m-1]: " << ary[m-1] << endl;
    // cout << "border: " << border << endl;
    if (ary[m-1] > border)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}




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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  long long ans;
  if(a*b*c%2==0) ans=0;
  else if (a>=b && a>=c) ans = b*c;
  else if (b>=a && b>=c) ans = a*c;
  else ans = a*b;
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

X, K, distance = map(int, input().split())

X = abs(X)

max_distance = K * distance

if max_distance <= X:
    print(X - max_distance)
else:
    # Xをdistanceで割って、何回の移動で0を超えるのかを判断
    over_zero_movecount = math.ceil(X / distance)

    # 0を超えたときの座標の絶対値(1)
    over_zero_x = abs(X - over_zero_movecount * distance)
    # 1つ前の移動の絶対値(2)
    over_zero_x_before = abs(X - (over_zero_movecount - 1) * distance)

    # 0を超えた後の残りの移動回数が偶数回の場合
    if (K - over_zero_movecount) % 2 == 0:
        print(over_zero_x)
    # 0を超えた後の残りの移動回数が奇数回の場合
    else:
        print(over_zero_x_before)

Measured memory_bytes: 9072
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int r;
  cin>>r;
  cout<<3*r*r<<endl;

  return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#include<bitset>
#define MAX_N 60
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
vector<ll> vs(MAX_N*2),depth(MAX_N*2,-1),id(MAX_N),par(MAX_N,-1);
vector<ll> sum(MAX_N),rm(MAX_N);
vector<ll> G[MAX_N];
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
template <typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid,Monoid) >;

  ll sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M;

  SegmentTree(ll n,const F f,const Monoid &M) : f(f),M(M){
    sz = 1;
    while(sz<n) sz<<=1;
    seg.assign(sz*2,M);
  }
  void set(ll k,const Monoid &v){
    seg[k+sz] = v;
  }
  void build(){
    for(ll k=sz-1;k>0;k--){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  void update(ll k,const Monoid &v){
    k += sz;
    seg[k] = v;
    while(k >>= 1){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  Monoid que(ll a,ll b){
    Monoid L=M,R=M;
    for(a+=sz, b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }
  Monoid operator[](const ll &k) const{
    return seg[k+sz];
  }
};
ll tmp;
void dfs(ll v,ll prev,ll d,ll &c){
  par[v] = prev;
  id[v] = c;
  vs[c] = v;
  depth[c] = d;
  c++;
  for(auto nv:G[v]){
    if(nv!=prev){
      dfs(nv,v,d+1,c);
      vs[c] = v;
      depth[c] = d;
      c++;
    }
  }
}
ll calc_sum(ll v,ll prev){
  ll res = 0,ret;
  for(auto nv:G[v]){
    if(prev!=nv){
      ret = calc_sum(nv,v);
      if(ret>0) tmp++;
      res += ret;
    }
  }
  return res+sum[v]+rm[v];
}
signed main(){
  init_io();
  ll n,m,ans=1,btc;
  cin >> n;
  vector<ll> a(n-1),b(n-1),reaf;
  SegmentTree<P> seg(n*2,[](P a,P b)
      {
      if(a.first<b.first) return a;
      else return b;
      },P(10000000,-1));
  for(int i=0;i<n-1;i++){
    ans *= 2;
  }
  for(ll i=0;i<n-1;i++){
    cin >> a[i]>>b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  for(ll i=1;i<n;i++){
    if(G[i].size()==1){
      reaf.push_back(i);
    }
  }
  cin >> m;
  vector<ll> v(m),u(m);
  for(ll i=0;i<m;i++){
    cin >> u[i] >> v[i];
    u[i]--;
    v[i]--;
  }
  ll c=0;
  dfs(0,-1,0,c);
  for(ll i=0;i<2*n-1;i++){
    seg.update(i,P(depth[i],i));
  }
  for(ll i=1;i<(1ll<<m);i++){
    btc=0;
    fill(sum.begin(),sum.end(),0);
    fill(rm.begin(),rm.end(),0);
    for(ll j=0;j<m;j++){
      if(i&(1ll<<j)){
        btc++;
        ll a= id[u[j]],b=id[v[j]];
        if(a>=b) swap(a,b);
        P q = seg.que(a,b+1);
        ll p = vs[q.second];
        if(p!=u[j]){
          sum[u[j]]++;
          rm[p]--;
        }
        if(p!=v[j]){
          sum[v[j]]++;
          rm[p]--;
        }
      }
    }
    tmp = 0;
    calc_sum(0,-1);
    ll adv = 1;
    for(ll j=0;j<(n-1-tmp);j++){
      adv*=2;
    }
    if(btc%2==1) ans -= adv;
    else ans += adv;
//    cout <<bitset<20>(i)<<" "<<tmp<<" "<<adv<<" "<<ans<<endl;
  }
  cout << ans<< endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll X,Y;
const int MAX_N = 110;
map<pii, bool> dp;

bool memo(int x, int y){
  if (x < 2 and y < 2){
    return false;
  }
  if (dp.count(mp(x, y))){
    return dp[mp(x, y)];
  }
  dp[mp(x, y)] = false;
  bool win = false;
  for (int i = 1; 2 * i <= x; i++){
    win |= !memo(x - 2 * i, y + i);
  }
  for (int i = 1; 2 * i <= y; i++){
    win |= !memo(x + i, y - 2 * i);
  }
  dp[mp(x, y)] |= win;
  return win;
}


int main() {
  cin >> X >> Y;
  if (abs(X-Y) <= 1){
    cout << "Brown" << endl;
  }else{
    cout << "Alice" << endl;
  }
  // bool win = memo(X, Y);
  // string result = "";
  // result = win ? "Alice" : "Brown";
  // cout << result << endl;
  // const int MAX_N = 1000;
  // for (int i = 0; i < MAX_N; i++){
  //   for (int j = i; j < MAX_N; j++){
  //     bool win = memo(i, j);
  //     string result = "";
  //     result = win ? "Alice" : "Brown";
  //     cout << "X = " << i << " Y = " << j << " " << result << endl;
  //   }
  // }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ_20190210
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            Console.WriteLine(x * x * x);
        }
    }
}



Measured memory_bytes: 15908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

const int MAX_V = 100000;

struct UnionFindTree {
    int par[MAX_V];
    int rank[MAX_V];

    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

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

struct edge {
    int u, v, cost;
};

bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }

vector<edge> es;
int V, E;

int kruskal() {
    sort(es.begin(), es.end(), comp);
    UnionFindTree a;
    a.init(V);
    int res = 0;
    for (int i = 0; i < es.size(); i++) {
        edge e = es[i];
        if (!a.same(e.u, e.v)) {
            a.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}
int main() {
    while(cin >> V >> E, V){
        REP(i,E){
            int a, b, c;
            cin >> a >> b >> c;
            es.push_back({a,b,c});
        }
        cout << kruskal() << endl;
        es.clear();
    }
    return 0;
}



Measured memory_bytes: 3072
from collections import Counter

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [map(int, input().split()) for i in range(m)]
d1 = Counter(a)
d2 = {}
ans = 0

for i, j in bc:
    if j in d2:
        ref = d2[j]
        d2[j] = ref + i
    else:
        d2[j] = i

d = Counter(d1) + Counter(d2)
key = sorted(d)[::-1]

for i in key:
    qty = d[i]
    if qty < n:
        ans += qty*i
        n -= qty
    else:
        ans += n*i
        break

print(ans)

Measured memory_bytes: 97776
s = input()

"""A, C, G, T"""
res = 0
cha = 0
for i in range(len(s)):
  if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
    cha = 1
    for j in range(i+1,len(s)):
      if s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T":
        cha += 1
      else:
        #print("c")
        break
    if cha > res:
      res = cha
    if res >= len(s[res:]):
      break

print(res)
    

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var v = readLine()!!.split(" ").map(String::toInt)
    var c = readLine()!!.split(" ").map(String::toInt)
    var ans = 0

    (0 until 1.shl(n)).forEach { bit ->
        var f = 0
        (0 until n).forEach { i ->
            if (bit.shr(i).and(1) == 1) f += v[i] - c[i]
        }
        if (f > ans) ans = f
    }
    println(ans)
}

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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  scanf("%d", &n);
  int last = -1, answer = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    if (x == last) {
      ++answer;
      last = -1;
    } else {
      last = x;
    }
  }
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
///*
ll fact[101010];
ll invfact[101010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

int main(){
	makefact(101000,MOD);
	int n,m;
	scanf("%d%d",&n,&m);
	ll ans=1;
	for(int p=2;p*p<=m;p++)if(m%p==0){
		int cnt=0;
		while(m%p==0)m/=p,cnt++;
		//cnt個をN個に割り振る
		ans=ans*choose(n-1+cnt,cnt,MOD)%MOD;
	}
	if(m!=1)ans=ans*n%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main( )
{
	string w, p;
	int i;
	
	cin>>w;
	
	int cnt = 0;
	while( true ) {
		cin>>p;
		if( "END_OF_TEXT" == p ) { break; }
		
		for( i=0; i<p.length(); i++ ) {
			p[i] = tolower( p[i] );
		}
		if( p == w ) {
			cnt++;
		}
	}
	
	cout<<cnt<<endl;
	
	return 0;
}

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

int main(){
    int n, i, j, tem;
    vector<int> v;
    cin >> n;
    int dp[n+1] = {};
    for(i=0; i<=n; i++){
        dp[i] = MOD;
    }
    tem = 1;
    while(tem <= n){
        v.push_back(tem);
        tem *= 6;
    }
    tem = 9;
    while(tem <= n){
        v.push_back(tem);
        tem *= 9;
    }
    sort(v.begin(), v.end());
    dp[0] = 0;
    for(i=0; i<v.size(); i++){
        for(j=v[i]; j<=n; j++){
            dp[j] = min(dp[j], dp[j-v[i]] + 1);
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n-1) cin >> c[i];
    ll ans = 0;
    REP(i, n) {
        if (i > 0 && a[i] - a[i - 1] == 1) ans += c[a[i-1]-1];
        ans += b[a[i]-1];
    }
    cout << ans << endl;
    getchar(); getchar();
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  cout << vec[n-1] - vec[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

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

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
    int n;
    cin >> n;
    ll ans = 1LL;
    for(int i = 0; i < n; i++){
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005
vector<int> pre_G[MAX_N];
vector<int> G[MAX_N];
int par_[MAX_N];
int flag_netsukigi[MAX_N];
void make_netsukigi(int r){
    queue<int> que;
    que.push(r);
    flag_netsukigi[r] = 1;
    par_[r] = -1;

    while(que.size() > 0){
        int x = que.front();
        que.pop();
        flag_netsukigi[x] = 1;
        rep(i,pre_G[x].size()){
            if(flag_netsukigi[pre_G[x][i]] == 0){
                par_[pre_G[x][i]] = x;
                G[x].push_back(pre_G[x][i]);
                que.push(pre_G[x][i]);
            }
        }
    }
}

const int INF = 1001001001;
int n;
int a[MAX_N];
int dp[MAX_N];
int ans[MAX_N];

void dfs(int x){
    int ite = lower_bound(dp, dp+n, a[x]) - dp;
    int keep = dp[ite];
    dp[ite] = a[x];
    ans[x] = lower_bound(dp, dp+n, INF) - dp;


    rep(i,G[x].size()){
        int y = G[x][i];
        dfs(y);
    }

    dp[ite] = keep;
}

int main() {
    cin >> n;
    rep(i,n){
        scanf("%d", &a[i]);
    }

    rep(i,n-1){
        int x, y;
        scanf("%d%d", &x, &y);
        x--; y--; // 0-indexにするため.
        pre_G[x].push_back(y);
        pre_G[y].push_back(x);
    }

    make_netsukigi(0);

    fill(dp, dp+n, INF);


    dfs(0);

    rep(i,n){
        printf("%d\n", ans[i]);
    }
    
    return 0;
}
 
 




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

using namespace std;


int main(){
	while(1){
		int N;
		cin>>N;
		if(N==0)
			break;
		int person[N];
		for(int i=0;i<N;i++)
			person[i]=0;
		int mcount=0;
		for(int i=0;i<100;i++){
			char c;
			cin>>c;
			switch(c){
				case 'M':
					person[i%N]++;
					break;
				case 'L':
					person[i%N]=mcount+person[i%N]+1;
					mcount=0;
					break;	
				case 'S':
					mcount=person[i%N]+mcount+1;
					person[i%N]=0;
					break;
			}
		}		
		sort(person,person+N);
		for(int i=0;i<N;i++)
			cout<<person[i]<<' ';
		cout<<mcount<<endl;
		
	}
	return 0;
}
	

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT { BIT() {}  // [L, R)
    int NV;vector<V> bit;BIT(int n){init(n);}void init(int n){NV=1;while(NV<n)NV*=2;bit.resize(NV);}
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;}
    V get(int L, int R) {assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;}
    void clear() { bit.clear(); }};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int offset = 100000;
int N, A[101010];
//---------------------------------------------------------------------------------------------------
int check(int x) {
    BIT<int> bit(201010);

    ll sm = 0;
    int tot = 0;
    bit.add(offset, 1);
    rep(i, 0, N) {
        if (x <= A[i]) tot++;
        else tot--;

        sm += bit.get(0, tot + offset + 1);
        bit.add(tot + offset, 1);
    }

    return (1LL * N * (N - 1) / 2 + N + 1) / 2 <= sm;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    int ok = 0, ng = inf;
    while (ok + 1 != ng) {
        int md = (ng + ok) / 2;
        if (check(md)) ok = md;
        else ng = md;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N+2];

		for(int i = 1 ; i <= N ; i++){
			A[i] = sc.nextLong();
		}
		A[0] = 0;
		A[N+1] = 0;

		sc.close();

		long maxgcd = 0;
		long maxgcd2 = 0;

		long[] memo = new long[N+2];
		memo[0] = 0;
		memo[1] = A[1];
		memo[N] = A[N];
		memo[N+1] = 0;

		for(int i = N-1 ; i>=2 ; i--){
			memo[i] = gcd(memo[i+1],A[i]);
		}
/*
		for(int i = 0 ; i <= N+1 ; i++){
			System.out.println(memo[i]);
		}
*/
		long ans = 0;
		for(int i = 1 ; i <= N ; i++){
			if( i == 1){
				maxgcd = 0;
				maxgcd2 = memo[i+1];
			}
			else if(i == N){
				maxgcd = memo[i-1];
				maxgcd2 = 0;
			}
			else{
				memo[i] = gcd(memo[i-1],A[i]);
				maxgcd = memo[i-1];
				maxgcd2 = memo[i+1];

			}
			if(ans < gcd(maxgcd,maxgcd2)){
				ans = gcd(maxgcd,maxgcd2);
			}
		}
		System.out.println(ans);
	}


	static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}


Measured memory_bytes: 61444
/******************** Beginning of Template **************************/
/************ ALL HEADER FILE ***********/

#include <iostream>
using namespace std;

/************************************ ALL DEFINE ****************************************************/
#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++)
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k, step) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define RREP(i, k) for(int i = j; i >= (k); i-- )

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define RESET(a, b) memset(a, b, sizeof(a))
#define INF (int)MAX_INT
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007
#define fango using
#define ganteng namespace
#define sekali std

/*********************************Debug DEFINE  ********************************/
#define TESTING
//#define FILE_INPUT
//#define FILE_OUTPUT
/*********************************END of Debug DEFINE  ********************************/

#ifdef TESTING
#define VALUE(x) cout << ">>>> The value of " << #x << " is " << x << "<<<<" << endl
#define NEWLINE cout << "---------------------------------------------" << endl
#define DUMP_STR cout << ">>>>FANGO IS THE MOST HANDSOME MANKIND IN THE ENTIRE WORLD<<<<" << endl;
#define DUMP_CHAR cout << " YO ";
#endif //TESTING_ON_CONSOLE



/************************************ END OF DEFINE ****************************************************/

/************************************ ALL TYPEDEF ****************************************************/
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;



/************************************ ALL DEFINE ****************************************************/

/************************************ END OF PREHEADER ***********************************************/



void solve() {

	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	if ((a1 + a2 + a3) >= 22) {
		cout << "bust";
	}
	else {
		cout << "win";
	}


}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int TC = 1;
	//cin >> TC;

	while (TC--) {

		solve();
	}
}

Measured memory_bytes: 3048
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]

dic = [[] for _ in range(N+1)]
for p,y in PY:
    dic[p].append(y)

for a in dic:
    a.sort()

dic2 = [{} for _ in range(N+1)]
for p in range(N+1):
    dic2[p] = {y:i+1 for i,y in enumerate(dic[p])}

for p,y in PY:
    y = dic2[p][y]
    print(str(p).zfill(6)+str(y).zfill(6))


Measured memory_bytes: 129700
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {

	int N, M, C;
	int A[50][50],B[50];
	int cnt = 0,sum = 0;


	scanf("%d %d %d", &N, &M, &C);
	for (int i = 0; i < M; i++) {
		scanf("%d", &B[i]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			scanf("%d", &A[i][j]);
		}

		for (int j = 0; j < M; j++) {
			sum += A[i][j] * B[j];
		}
		sum += C;
		if (sum > 0)cnt++;
		sum = 0;
	}
	printf("%d", cnt);

	return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(ll u = 0, char c = getchar(), bool f = false) {
	for (;!isdigit(c); c = getchar()) f |= c == '-';
	for (; isdigit(c); c = getchar()) u = (u << 1) + (u << 3) + c - '0';
	return f ? -u : u;
}

const int maxn = 1e5 + 10;
ll x[maxn], v[maxn];
ll f[maxn][2], g[maxn][2];
int main() {
	int n = read(); ll c = read();
	for (int i = 1; i <= n; i++)
		x[i] = read(), v[i] = read();
		
	for (int i = 1; i <= n; i++) 
		f[i][0] = f[i - 1][0] - (x[i] - x[i - 1]) + v[i],
		f[i][1] = f[i - 1][1] - (x[i] - x[i - 1]) * 2 + v[i];
	
	for (int i = 1; i <= n; i++)
		f[i][0] = max(f[i][0], f[i - 1][0]),
		f[i][1] = max(f[i][1], f[i - 1][1]);
	
	x[n + 1] = c;
	
	for (int i = n; i >= 1; i--)
		g[i][0] = g[i + 1][0] - (x[i + 1] - x[i]) + v[i],
		g[i][1] = g[i + 1][1] - (x[i + 1] - x[i]) * 2 + v[i];
		
	for (int i = n; i >= 1; i--)
		g[i][0] = max(g[i][0], g[i + 1][0]),
		g[i][1] = max(g[i][1], g[i + 1][1]);
	
	ll ans = 0;
	for (int i = 0; i <= n; i++)
		ans = max(ans, max(f[i][0] + g[i + 1][1], f[i][1] + g[i + 1][0]));
	cout << ans << endl;
}

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

const int N = 45;
const int M = (1 << 17) + 10;
const int MOD = 1e9 + 7;

int n, x, y, z;
int f[N][M];

void add(int &x,int y) { x = x + y < MOD ? x + y : x + y - MOD; }

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> x >> y >> z;
	int needmask = (1 << (z - 1)) + (1 << (y + z - 1)) + (1 << (x + y + z - 1));
	int endmask = 1 << (x + y + z);
	
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int mask = 0; mask <= endmask; ++mask) {
			if (f[i - 1][mask] == 0) continue;
			
			for (int nxt = 1; nxt <= 10; ++nxt) {
				if (mask == endmask) {
					add(f[i][mask], f[i - 1][mask]);
					continue;
				}
				
				int nmask = ((mask << nxt) | (1 << (nxt - 1))) & (endmask - 1);
				if ((nmask & needmask) == needmask) nmask = endmask;
				add(f[i][nmask], f[i - 1][mask]);
			}
		}
	}
	cout << f[n][endmask];
}

Measured memory_bytes: 20864
#include<stdio.h>
int main()
{
    int P,Q,R,C=100000;
    scanf("%d%d%d",&P,&Q,&R);
    if(P+Q<C) C=P+Q;
    if(P+R<C) C=P+R;
    if(R+Q<C) C=Q+R;
    printf("%d",C);
    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s,s1,s2;
int t,n,m,tmp,cnt=0,p,pp;
int a[2][500001];
char c[2][100001];
int cut(int p,int r){
	int i=p-1,j,tmp,x; char ch;
	tmp=a[1][r];
    for (j=p; j<r; j++){
    	if (a[1][j]<=tmp){
    		i++;
    		x=a[1][j]; a[1][j]=a[1][i]; a[1][i]=x; 
			ch=c[1][i]; c[1][i]=c[1][j]; c[1][j]=ch;
		}
	}
	x=a[1][i+1]; a[1][i+1]=a[1][r]; a[1][r]=x; 
	ch=c[1][i+1]; c[1][i+1]=c[1][r]; c[1][r]=ch;
	return i+1;
}
void qsort(int l,int r){
	 int q;
	 if (l<r){
	 	q=cut(l,r);
	 	qsort(l,q-1);
	 	qsort(q+1,r);
	 }
}
int x[500001],y[500001];
char xx[500001],yy[500001];
void merge_sort(int l,int r){
	 int mid,n1,n2;
	 if (r-l==1) return;
	 mid=(l+r)/2; 
	 merge_sort(l,mid);
	 merge_sort(mid,r);
	 n1=mid-l; n2=r-mid;
	 for (int i=0; i<n1; i++){
	 	x[i]=a[0][l+i];
	 	xx[i]=c[0][l+i];
	 }
	 for (int i=0; i<n2; i++){
	  	 y[i]=a[0][mid+i];
	  	 yy[i]=c[0][mid+i];
	 }
	 x[n1]=2000000001; y[n2]=2000000001;
	 int i=0,j=0;
	 for (int k=l; k<r; k++){
	 	 if (x[i]<=y[j]){
	 	 	a[0][k]=x[i];
	 	 	c[0][k]=xx[i];
	 	 	i++;
		  }
	 	 else{
	 	 	a[0][k]=y[j];
	 	 	c[0][k]=yy[j];
	 	 	j++;
		  }
	 	  cnt++;
	 }
   
}
int main(){
	bool ok=true;
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++){
    	 cin>>c[0][i]>>a[0][i];
    	 c[1][i]=c[0][i];
    	 a[1][i]=a[0][i];
	}
    merge_sort(0,n);
    qsort(0,n-1);
    for (int i=0; i<n; i++){
    	if (c[0][i]!=c[1][i]){
    		ok=false; break;
		}
	} 
	if (ok)
	   cout<<"Stable"<<endl;
	else
	   cout<<"Not stable"<<endl;
	for (int i=0; i<n; i++){
		cout<<c[1][i]<<' '<<a[1][i]<<endl;
	}
	return 0;
} 


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, k, ans = INF;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(ALL(h));
    rep(i, n-k+1) {
        if(ans > h[i+k-1]-h[i]) ans = h[i+k-1]-h[i];
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

int main() {
    long long a, b, c; cin >> a >> b >> c;

    cout << (long long)(sqrt(pow(a * a + b * b + c * c, 2) - 2 * (pow(a, 4) + pow(b, 4) + pow(c, 4))) + 1e-9) / 4 << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

vector<int> data[200005];
int ans[200005];
void dfs(int root,int child){
	ans[child] += ans[root];
	for(int i:data[child]){
		if(i!=root){
			dfs(child, i);
		}
	}

}


int main(){
	int n, q;
	cin >> n >> q;
	int a, b;
	for (int i = 0; i < n - 1;i++){
		cin >> a >> b;
		a--;
		b--;
		data[a].push_back(b);
		data[b].push_back(a);
	}
	for (int i = 0; i < q;i++){
		cin >> a >> b;
		a--;
		ans[a]+=b;
	}
	for (int i:data[0]){
		if(i)dfs(0, i);
	}

	for (int i = 0; i < n;i++){
		cout << ans[i];
		if(i!=n-1)
			cout << " ";
	}

		cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 23424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;

void solve(){
  int a, b; cin >> a >> b;
  if(b % a == 0) cout << a + b << endl;
  else cout << b - a << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  
  int res = S.size();
  for (size_t i = 0, size = S.size() - T.size()+1; i < size; ++i) {
    int diff = 0;
    for (size_t j = 0, size_j = T.size(); j < size_j; ++j) {
      if (S[i+j] != T[j]) {
        ++diff;
      }
    }
    res = min(res, diff);
  }
  cout << res << endl;

  return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = a; i<b; ++i)
#define pb push_back
#define INF 1000000000


int main(){
	IO
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool f = true;
	while(1){
		if(f)
			c-=b;
		else
			a-=d;
		f = !f;
		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}
		else if(a<=0){
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,a,b[100010];

int main(){
	cin >> n;
	
	bool f=false;
	int a=4;
	if(n>0){
		if(n%4==0) n/=4,a=1;
		for(int i=n;1;i+=n){
			REP(j,1,3501){
				REP(k,1,3501){
					if(a*i*j*k/n==i*j+j*k+k*i) cout << i << " " << j << " " << k << endl,f=true;
				}
				if(f) break;
			}
			if(f) break;
		}
	}else{
		n*=-1;
		if(n%4==0) n/=4,a=1;
		for(int i=n;1;i-=n){
			REP(j,1,3501){
				REP(k,1,3501){
					if(4*i*j*k/n==i*j+j*k+k*i) cout << -i << " " << -j << " " << -k << endl,f=true;
				}
				if(f) break;
			}
			if(f) break;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define pb push_back
#define mp make_pair
#define NMAX 105

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n;
pii red[NMAX],blue[NMAX];
int visited[NMAX],married[NMAX],cnt;
vector <int> adj[NMAX];
int id;
inline bool DFS(int u){
    if(visited[u]!=id) visited[u]=id;
    else return false;
    for(int v:adj[u]){
        if(!married[v]||DFS(married[v])){
            married[v]=u;
            return true;
        }
    }
    return false;
}
int main(){
 //   freopen("C.inp","r",stdin);
    read(n);
    for(int i=1;i<=n;i++){
        read(red[i].first);read(red[i].second);
    }
    for(int i=1;i<=n;i++) read(blue[i].first),read(blue[i].second);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(red[i].first<blue[j].first&&red[i].second<blue[j].second) adj[i].pb(j);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        id++;
        ans+=DFS(i);
  //      cout<<ans<<" ";
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101],b[101];
int main()
{
	int n;cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++){
		if(a[i]==b[i])sum++;
		else sum=0;
		if(sum==3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include<queue>
#include<cstdio>
#include <stdio.h>
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_H 100
#define MAX_W 100
using namespace std;
const int INF = 100000000;

typedef pair<int, int> P;

int H, W;
char maze[MAX_H][MAX_W + 1];
bool check[MAX_H][MAX_W];

//移動4方向のベクトル
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int main(){
  while (true){
    cin >> W >> H;
    if(W == 0 && H == 0)
      break;
    int b = 0;
    int w = 0;
    rep(i,H)
      cin >> maze[i];
    rep(i,H){
      rep(j,W){
        if(maze[i][j] == '.'){
          int flagb = 0;
          int flagw = 0;
        rep(i,H){
          rep(j,W){
            check[i][j] = false;
          }
        }
        queue<P> que;
        que.push(P(j,i));
        while(que.size()){
          P p = que.front();que.pop();
          int x = p.first;
          int y = p.second;

          rep(k,4){
                int nx = p.first + dx[k], ny = p.second + dy[k];
                if(0 <= nx && nx < W && 0<= ny && ny < H && maze[ny][nx] == 'B'){
                  flagb = 1;
                }
                if(0 <= nx && nx < W && 0<= ny && ny < H && maze[ny][nx] == 'W'){
                  flagw = 1;
                }
                if(0 <= nx && nx < W && 0<= ny && ny < H && maze[ny][nx] == '.' && check[ny][nx] == false){
                  if(flagb*flagw == 0){
                    que.push(P(nx,ny));
                    check[ny][nx] = true;
                  }
                  else{
                    queue<P> que;
                  }
                }
              }
            }
            if(flagb == 1 && flagw == 0){
              b += 1;
            }
            else if(flagw == 1 && flagb == 0){
              w += 1;
          }
        }
      }
    }
    printf("%d %d\n",b,w);
  }
}


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

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

using namespace std;

int main(){
	int x,n; scanf("%d%d",&x,&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	for(int d=0;;d++){
		if(count(a.begin(),a.end(),x-d)==0) return printf("%d\n",x-d),0;
		if(count(a.begin(),a.end(),x+d)==0) return printf("%d\n",x+d),0;
	}

	return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> h(n+1);
    for(int i = 1;i<n+1;i++){
        cin >> h[i];
    }
    vector<int> memo(n+1, 1e9+5);
    memo[0] = memo[1] = 0;
    for(int i = 1; i<n+1;i++){
        for(int j = 1; j <= k;j++){
            if(i - j > 0){
                memo[i] = min(memo[i], memo[i-j] + abs(h[i] - h[i - j]));
            }
            else{
                break;
            }
        }
  }
  cout << memo[n] <<endl;
    
    return 0;

}


Measured memory_bytes: 3876