akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#include <numeric>
#include<string_view>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
void a(){
    string s; cin >> s;
    ll ans = 0;
    ll cnt = s[0]=='R';
    if(s=="RRR") ans = 3;
    else if(s=="RRS") ans = 2;
    else if(s=="SRR") ans = 2;
    else if(s.find_first_of('R')!=string::npos){
        ans = 1;
    }else{
        ans = 0;
    }

    cout << ans << endl;
}

void b(){

}

void c(){

}

void d(){

}

void e(){
   
} 

int main(void){
    a();
    return 0;
 }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  map<string, int> cnt;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    cnt[s]++;
  }

  for(auto s:{"AC"s,"WA"s,"TLE"s,"RE"s})
    cout<<s<<" x "<<cnt[s]<<newl;
  return 0;
}


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

int rps(char hand, int r, int p, int s) {
  int score;
  if(hand=='r') score=p;
  else
  if(hand=='s') score=r;
  else
  if(hand=='p') score=s;
  return score;
}

int main() {
  int n, k, r, s, p;
  int ans = 0;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  vector<bool> isSameHand(t.size(),false);
  for(int i=0; i<n; i++){
    if(i<k) {
      ans+=rps(t[i], r, p, s);
    } else
    // k個前の手を現在の手が違う
    if(t[i]!=t[i-k]) {
      ans+=rps(t[i], r, p, s);
    } else
    if(t[i]==t[i-k]) {
      if(!isSameHand[i-k]) {
        isSameHand[i]=true;
      } else
      if(isSameHand[i-k]) {
        ans+=rps(t[i], r, p, s);
        isSameHand[i]=false;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int q1, q2;
	int b;
	int c1, c2;
	int i;
	int kanarazu;
	int buy1, buy2;
	int herasu;
	int ok;
	
	int buf_b;
	int buf_q1;
	
	while (1){
		scanf("%d", &q1);
		if (q1 == 0){
			break;
		}
		scanf("%d %d %d %d", &b, &c1, &c2, &q2);
		herasu = 0;
		ok = 0;
		while (herasu < q2){
			buf_b = b;
			buf_q1 = q1;
			
			/*会津地鶏をできるだけ買う*/
			kanarazu = 0;
			for (i = q2 - herasu; i > 0; i--){
				if (b >= i * c1){
					kanarazu = 1;
					buy1 = i;
					buf_b -= i * c1;
					buf_q1 -= i;
					break;
				}
			}
			
			/*ふつうの鶏肉をできるだけ買う*/
			buf_q1 -= buf_b / c2;
			/*buf_b -= c2 * (buf_b / c2);*/
			
			
			/*条件を満たせたか*/
			if (buf_q1 <= 0 && kanarazu == 1){
				ok = 1;
				printf("%d %d\n", i, buf_b / c2);
				break;
			}
			else {
				herasu++;
			}
		}
		if (ok != 1){
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    
    int k ,a, b;
    cin >> k >> a >> b;
    if(b -(b % k)>= a){
        cout << "OK";
    }else{
        cout << "NG";
    }
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int f = 0;
		int l = 0;
		for (int i = 1; i <= m; i++) {
			int a = Integer.parseInt(sc.next());
			if (a < x) {
				f++;
			}
			if (a > x) {
				l++;
			}
		}
		System.out.println(Math.min(f, l));
		sc.close();
	}
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int K; cin >> K;
	vector<string> I(K); rep(i, 0, K) { cin >> I[i]; }
	vector<string> N(K); rep(i, 0, K) { cin >> N[i]; }
	int tameI = 0;
	int tameN = 0;
	rep(i, 0, K) {
		bool fI = false;
		bool fN = false;
		if (I[i][0] == 't' && N[i][0] == 't') {
			tameI = min(5, tameI + 1);
			tameN = min(5, tameN + 1);
		}
		if (I[i][0] == 't' && N[i][0] == 'm') {
			tameI = min(5, tameI + 1);
		}
		if (I[i][0] == 't' && N[i][0] == 'k') {
			if (tameN == 0)fI = true;
			else fN = true;
			tameN = 0;
			tameI = min(5, tameI + 1);
		}
		if (I[i][0] == 'm' && N[i][0] == 't') {
			tameN = min(5, tameN + 1);
		}
		if (I[i][0] == 'm' && N[i][0] == 'm') {
		}
		if (I[i][0] == 'm' && N[i][0] == 'k') {
			if (tameN == 0)fI = true;
			else if (tameN == 5)fN = true;
			tameN = 0;
		}
		if (I[i][0] == 'k' && N[i][0] == 't') {
			if (tameI == 0)fN = true;
			else fI = true;
			tameI = 0;
			tameN = min(5, tameN + 1);
		}
		if (I[i][0] == 'k' && N[i][0] == 'm') {
			if (tameI == 0)fN = true;
			else if (tameI == 5)fI = true;
			tameI = 0;
		}
		if (I[i][0] == 'k' && N[i][0] == 'k') {
			if (tameI == 0)fN = true;
			if (tameN == 0)fI = true;

			if (tameI > tameN)fI = true;
			else if (tameI < tameN)fN = true;

			tameI = 0;
			tameN = 0;
		}
		if (fN&&fI)continue;
		if (fN) {
			cout << "Nakajima-kun" << endl;
			return 0;
		}
		if (fI) {
			cout << "Isono-kun" << endl;
			return 0;
		}
	}
	cout << "Hikiwake-kun" << endl;
	return 0;
}

Measured memory_bytes: 3216
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
int N;
cin>>N;
string S[N];
for(int i=0;i<N;i++)cin>>S[i];
set<string>a;
for(int i=0;i<N;i++)a.insert(S[i]);
cout<<a.size();

return 0;
}

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


int main(){
  int n;
  int A[100];
  cin >> n;
  for (int i=0;i<n;i++){
    cin >> A[i];
  }
  int a, b;
  a = 0;
  b = 0;
  for (int i=0;i<n;i++){
    int base = 0;
    int base_i = 0;
    for (int j=0;j<n;j++){
      if (A[j] > base){
        base = A[j];
        base_i = j;
      }
    }
    A[base_i] = 0;
    if (i % 2 == 0){
      a += base;
    }else{
      b += base;
    }
  }
  cout << a - b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <ctime>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>

#define pb push_back
#define mp make_pair
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ull unsigned long long
#define iloop(a,b) for(ll i = a; i < b; ++i)
#define jloop(a,b) for(ll j = a; j < b; ++j)
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeofa((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define p(a) cout << a << "\n";
#define p1(a) cout << a << " ";

#define PI 3.141592653589793
#define MOD (ll)(1e9 + 7)

using namespace std;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 

void solve()
{
	int n,k;
	cin >> n >> k;
	int arr[n];
	iloop(0,n)
	{
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int ans = 0;
	for(int i = n-1; i > n-1-k; --i)
	{
		ans += arr[i];
	}	
	p(ans)
}
int main()
{
	bool testing = false;
	IOS
	if(testing)
	{
		freopen("test.txt","rt",stdin);
		int start = clock();
		solve();
		int end = clock();
		cout << "time: " << (end - start)/(double)(CLOCKS_PER_SEC)*1000 << " milliseconds\n";
	}
	else
	{
		solve();
	}
} 

Measured memory_bytes: 256
from collections import *
a = sorted(int(input()) for _ in range(int(input())))
q = deque(a)
rq = deque([q.popleft()])
while q:
    rq.appendleft(q.pop())
    if q: 
        rq.append(q.pop())
    if q:
        rq.appendleft(q.popleft())
    if q: 
        rq.append(q.popleft())
r1 = sum(abs(i-j) for i, j in zip(rq, list(rq)[1:]))

q = deque(a[::-1])
rq = deque([q.popleft()])
while q:
    rq.appendleft(q.pop())
    if q: 
        rq.append(q.pop())
    if q:
        rq.appendleft(q.popleft())
    if q: 
        rq.append(q.popleft())
r2 = sum(abs(i-j) for i, j in zip(rq, list(rq)[1:]))
print(max(r1, r2))

Measured memory_bytes: 10520
n = int(input())
if n == 0:
    print(0)
    exit()

ans = list()
while n != 0:
    ans.append(str((n%-2)*(-1)))
    if n % (-2) < 0:
        n = (n-1) // (-2)
    else:
        n = n // (-2)

print(''.join(reversed(ans)))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> Vec;
		for(int i = 0; i < n; ++i)
		{
			int num, day1, day2;
			cin >> num >> day1 >> day2;
			Vec.push_back(make_pair(day1 + day2, num));
		}
		sort(Vec.begin(), Vec.end());
		cout << Vec[Vec.size() - 1].second << " " << Vec[Vec.size() - 1].first << endl;
	}
}

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

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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)

const double EPS = 1e-8;
// 点
typedef complex<double> P;
namespace std {
  bool isnan(const P&p){
    return isnan(p.real()) or isnan(p.imag());
  }
}

// 外積
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
// 内積
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

// 直線
// 線分は端点を入れる
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

// 円
struct C {
  P p; double r;
  C(const P &p_, double r_) : p(p_), r(r_) { }
};

// 交差判定
// 直線同士
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
    abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}

// 直線の交点
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) return P(nan(""),nan("")); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

// 点の線への射影
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

// 直線と点の距離
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}

// 直線lを垂線方向にdis移動
L slideL(L l, double dis){
  double deg = arg(l[1]-l[0]);
  P p = P(dis*sin(deg),-dis*cos(deg));
  l[0] += p;
  l[1] += p;
  return l;
}

signed main(){
  int n;
  double w,h,r;
  while(cin >> w >> h >> n >> r, n){
    // input
    vector<L> ls;
    vector<double> ts(n);
    rep(i,n){
      double a,b,c,d;
      cin >> a >> b >> c >> d;
      P x{a,b},y{c,d};
      ls.emplace_back(x,y);
      cin >> ts[i];
    }

    // 候補を列挙
    vector<P> can;
    // 四隅を追加
    can.push_back({r,r});
    can.push_back({r,h-r});
    can.push_back({w-r,r});
    can.push_back({w-r,h-r});
    // 2線に接する点を追加
    rep(i,n) FOR(j,i+1,n){
      // 交差しない
      if(not intersectLL(ls[i],ls[j])) continue;

      // 元の直線からr+t平行移動した直線l,rを用意
      // 交点が候補の候補となる
      L li = slideL(ls[i],-r-ts[i]), ri = slideL(ls[i],r+ts[i]);
      L lj = slideL(ls[j],-r-ts[j]), rj = slideL(ls[j],r+ts[j]);
      vector<P> tmpcan;
      tmpcan.push_back(crosspoint(li,lj));
      tmpcan.push_back(crosspoint(li,rj));
      tmpcan.push_back(crosspoint(ri,lj));
      tmpcan.push_back(crosspoint(ri,rj));

      // 枠の中にあるなら候補
      auto isin = [&](const P &p){
	return r < p.real()+EPS and p.real()-EPS < w-r and r < p.imag()+EPS and p.imag()-EPS < h-r;
      };
      rep(k,4){
	if((not isnan(tmpcan[k])) and isin(tmpcan[k]))
	  can.push_back(tmpcan[k]);
      }
    }

    // 各候補が全ての線からr+t以上離れているか
    bool f = false;
    rep(i,can.size()){
      bool g = true;
      rep(j,n){
	double d = distanceLP(ls[j],can[i]);
	if(r + ts[j] > d + EPS){
	  g = false;
	  break;
	}
      }
      if(g){
	f = true;
	break;
      }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

const int MAXN = 100010;
int n, m;
int num[MAXN], ans;
bool p[MAXN];

int main() {
	int i;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; i++) num[i] = 1;
	p[1] = true;
	for(i = 1; i <= m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if(p[x]) {
			if(num[x] == 1) {
				p[x] = false;
				p[y] = true;
				num[x] = 0, num[y]++;
			}
			else {
				p[y] = true;
				num[x]--, num[y]++;
			}
		}
		else {
			num[x]--;
			num[y]++;
		}
	}
	for(i = 1; i <= n; i++) 
		if(p[i]) ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> Vull;
typedef vector<ll> Vll;
typedef vector<ui> Vui;
typedef vector<int> Vi;

typedef pair<ull, ull> Pull;
typedef pair<ll, ll> Pll;
typedef pair<ui, ui> Pui;
typedef pair<int, int> Pi;

int main() {
    string str; cin >> str;
    for (char s: str) {
        if (s == '1') cout << 9;
        else          cout << 1;
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 888
//

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
#include <numeric>
#include<string>
#include <map>
#include <chrono>
#include <cstdlib>
#include <ctime>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793





int main() {
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for (int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second

int n, m, a, b, dist[100050][3], st, t;
vector<int> adj[100050];
queue<pi> q;

int main() {
	cin >> n >> m;
	FOR(i, 1, m) {
		cin >> a >> b;
		adj[a].push_back(b);
	}
	cin >> st >> t;
	q.push(pi(st, 0));
	memset(dist, -1, sizeof dist);
	dist[st][0] = 0;
	while (!q.empty()) {
		pi x = q.front(); q.pop();
		int nd = (x.s + 1) % 3;
		for (auto it:adj[x.f]) {
			if (dist[it][nd] != -1) continue;
			dist[it][nd] = dist[x.f][x.s] + (x.s == 0);
			q.push(pi(it, nd));
		}
	}
	cout << dist[t][0];
}



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

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll t[2],a[2],b[2];
    cin>>t[0]>>t[1];
    cin>>a[0]>>a[1];
    cin>>b[0]>>b[1];

    ll l1=t[0]*a[0] + t[1]*a[1];
    ll l2=t[0]*b[0] + t[1]*b[1];

    //cerr << l1 << " " << l2 << endl;

    if(l1==l2){
        cout << "infinity" << endl;
        return 0;
    }
    if(a[0]<b[0]){
        swap(a[0],b[0]);
        swap(a[1],b[1]);
        swap(l1,l2);
    }
    if(l1>l2){
        cout << 0 << endl;
        return 0;
    }
    ll dif = l2-l1;
    ll ans = (a[0]-b[0])*t[0];
    bool pos = false;
    cerr << ans << " " << dif << endl;
    if(ans%dif==0) pos = true;
    ans /= dif;
    ans*=2;
    if(pos)ans--;
    ans++;
    cout << ans << endl;
}

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

int main(){
	vector<pair<int,int>> ve;
	pair<int,int> p;
	int n;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>p.first>>p.second;
		ve.push_back(p);
	}
	
	sort(ve.begin(), ve.end());
	
	for(pair<int,int> y: ve) cout<<y.first<<" "<<y.second<<endl;
	
	return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    int testCases = 1;
    // cin>>testCases;
    while(testCases--){
       ll D, T, S;
       cin>>D>>T>>S;
       if(T>=((1.0*D)/S)) cout<<"Yes"<<endl;
       else cout<<"No"<<endl; 
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    int i;
    for(i=0;i<l/2;i++)
    {
        if(s[i]==s[l-i-1])
        continue;
        else
        break;
    }
    if(i==l/2)
    {
        string s1,s2;
        for(i=0;i<=l/2-1;i++)
        s1=s1+s[i];
        for(i=l/2+1;i<l;i++)
        s2=s2+s[i];
        l=s1.size();
        for(i=0;i<l/2;i++)
        {
        if(s1[i]==s1[l-i-1])
        continue;
        else
        break;
        }
        if(i==l/2)
        {
            for(i=0;i<l/2;i++)
            {
            if(s2[i]==s2[l-i-1])
            continue;
            else
            break;
            }
            if(i==l/2)
            cout<<"Yes";
            else
            cout<<"NO";
        }
        else
        cout<<"No";
    }
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int x=ci();
	int ans = x/500*1000+x%500/5*5;
	printf("%d\n",ans);
	return 0;
}


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

using static Input;
using static Util;
class Program
{
    static long N;

    static void INPUT()
    {
        N = NextLong();
    }
    static void OUT()
    {
        var f = new Func<long, int>(__ =>
        {
            var c = 1;
            var nn = __;
            while (nn >= 10)
            {
                nn /= 10;
                c++;
            }
            return c;
        }); 
        var n = f(N);
        var a = 20;
        for(var i = 1L; i * i <= N; i++ )
        {
            if (N % i == 0)
                a = Math.Min(a,Math.Max(f(i), f(N/i))); 
        }

        Console.WriteLine(a);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        N = 1000003;
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13268
i=0
while i<6:
    i+=1
    x=int(input())
    y=1000-x
    g=y//500
    h=(y-500*g)//100
    d=(y-500*g-100*h)//50
    z=(y-500*g-100*h-50*d)//10
    f=(y-500*g-100*h-50*d-10*z)//5
    i=y-500*g-100*h-50*d-10*z-5*f
    if x==0:
        break
    print(g+h+d+z+f+i)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
double ans = 0;

int n, m;
int cnt = 0;
void dfs(double par, int k)
{
    double val = 1900 * m + 100 * (n - m);
    val *= k;
    double h = par * 1.0 / pow(2, m);
    ans += h * val;
    double f = 1.0 - 1.0 / pow(2, m);
    if (cnt++ > 1000000) {
        return;
    }
    dfs(par * f, k + 1);
}
int main()
{
    cin >> n >> m;
    dfs(1.0, 1);
    cout << (lli)(ans + 0.5) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	//	BufferedReader reader1 = new BufferedReader(new InputStreamReader(System.in));
	//	BufferedReader reader2 = new BufferedReader(new InputStreamReader(System.in));

	int N = sc.nextInt();
	int A = sc.nextInt();
	int B = sc.nextInt();
	int sum = A+B;
	int OS = 0;
	String S = sc.next();
	    
	// String str1 = reader1.readLine();
	// String s_input1[] = str1.split("[\\s]+");
	// int N = Integer.parseInt(s_input1[0]);
	// int A = Integer.parseInt(s_input1[1]);
	// int B = Integer.parseInt(s_input1[2]);
	// int sum = A+B;
	// int OS = 0;
	// String S = reader2.readLine();

	    
	for(int i = 0; i < N; i++){
	    if(S.charAt(i) == 'a'){
		if(sum > 0){
		    System.out.println("Yes");
		    sum--; 
		}
		else
		    System.out.println("No");
	    }
	    else if(S.charAt(i) == 'b'){
		if(sum > 0 && (++OS) <= B){
		    System.out.println("Yes");
		    sum--;
		}
		else
		    System.out.println("No");		    
	    }
	    else
		System.out.println("No");
		
		    
	}
    }
}


Measured memory_bytes: 23700
/*+lmake
 * STD = c++14
 * DEFINE += MDEBUG
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
#define MAXN 200000
struct Edge
{
	int to,next,dis;
}e[2*MAXN+10];
int head[MAXN+10];
int c=0;
void addEdge(int from,int to,int dis)
{
	e[++c]=(Edge){to,head[from],dis};
	head[from]=c;
	e[++c]=(Edge){from,head[to],-dis};
	head[to]=c;
}
int ou[MAXN+10];
bool vis[MAXN+10];
int dis[MAXN+10];
bool ans=true;
void dfs(int now)
{
	for(int i=head[now]; i!=0; i=e[i].next) {
		if (vis[e[i].to]) {
			vis[e[i].to]=false;
			dis[e[i].to]=dis[now]+e[i].dis;
			dfs(e[i].to);
			if (!ans) return;
		} else {
			if (dis[e[i].to]!=dis[now]+e[i].dis) {
				ans=false;
				return;
			}
		}
	}
}
void solve(long long N, long long M, vector<long long> L, vector<long long> R, vector<long long> D){
	memset(vis,true,sizeof(vis));
	int n=N,m=M;
	for(int i=0; i<m; ++i){	
		addEdge(L[i],R[i],D[i]);
		ou[L[i]]++;
	}
	for(int i=1; i<=n; ++i) {
		if(vis[i]) {
			dfs(i);
			if (!ans) break;
		}
	}
	if (ans) puts("Yes");
	else puts("No");
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> R(M-1+1);
	vector<long long> L(M-1+1);
	vector<long long> D(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&L[i]);
		scanf("%lld",&R[i]);
		scanf("%lld",&D[i]);
	}
	solve(N, M, L, R, D);
	return 0;
}



Measured memory_bytes: 17920
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;




void solve() {
    int n;
    cin >> n;
    vector<int> v(n + 1), w(n + 1);
    int N = min(n + 1, 1024);
    int M = 100000 + 10;
    vector<vector<int> > a(N, vector<int>(M, 0));
    for (int i = 1; i <= n; ++i) {
        cin >> v[i] >> w[i];
    }
    for (int i = 1; i < N; ++i) {
        int p = i / 2;
        for (int j = 0; j < M; ++j) {
            a[i][j] = max(a[i][j], a[p][j]);
            if (j + w[i] < M) {
                a[i][j + w[i]] = max(a[i][j + w[i]], a[p][j] + v[i]);
            }
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j < M; ++j) {
            a[i][j] = max(a[i][j], a[i][j - 1]);
        }
    }
    int q;
    cin >> q;
    vector<int> vv(20), ww(20);
    for (int qq = 0; qq < q; ++qq) {
        int qv, l;
        cin >> qv >> l;
        if (qv < N) {
            cout << a[qv][l] << "\n";
            continue;
        }
        int id = 0;
        while (qv >= N) {
            vv[id] = v[qv];
            ww[id] = w[qv];
            ++id;
            qv /= 2;
        }
        int res = 0;
        for (int msk = 0; msk < (1 << id); ++msk) {
            int av = 0, aw = 0;
            for (int j = 0; j < id; ++j) {
                if ((msk >> j) & 1) {
                    av += vv[j];
                    aw += ww[j];
                }
            }
            if (aw <= l) {
                res = max(res, a[qv][l - aw] + av);
            }
        }
        cout << res << "\n";
    }

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 406804
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}

ll test[502][502];
signed main() {
	ll n, ans = 0; cin >> n;
	vector<ll> v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(all(v)); reverse(all(v));
	priority_queue<ll, vector<ll>, less<ll>> q;
	q.push(v[0]);
	for (int i = 1; i < n; i++) {
		ans += q.top(); q.pop();
		q.push(v[i]); q.push(v[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6972
#include <bits/stdc++.h>
using namespace std;
#define INF 1001001001
#define MAX_V 100000
typedef pair<int,int> P;

int N;
vector<int> G[MAX_V];
int d[2][MAX_V];

void dijkstra(int s, int t) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d[t], d[t]+N, INF);
    d[t][s] = 0;
    que.push(P(0,s));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[t][v] < p.first) continue;
        for(int i=0; i < G[v].size(); i++) {
            int e = G[v][i];
            if(d[t][e] > d[t][v] + 1) {
                d[t][e] = d[t][v] + 1;
                que.push(P(d[t][e], e));
            }
        }
    }
}

int main() {
    cin >> N;
    for(int i=0; i<N-1; ++i) {
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    dijkstra(0,0);
    dijkstra(N-1,1);

    int fcnt = 0;
    for(int i=0; i<N; ++i) {
        if(d[0][i] <= d[1][i]) ++fcnt;
    }
    if(fcnt > N / 2) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 >=22){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(all(A));
    reverse(all(A));
    if (A[0] < N) {
        cout << 0 << ln;
        return 0;
    }
    bool flag = true;
    ll ans = 0;
    while (flag) {
        ll cnt = 0;
        flag = false;
        rep(i,N) {
            if (i==0) {
                ll k = A[i]%N;
                cnt = (A[i]-k)/N;
                A[i] = k;
            } else {
                A[i] += cnt;
                if (A[i] >= N) flag = true;
            }
        }
        ans += cnt;
        sort(all(A));
        reverse(all(A));
    }

    cout << ans << ln;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long MOD = (long) (Math.pow(10, 9) + 7);
        int n = sc.nextInt();
        int odd = 0, even = 0, div4 = 0;
        while (n-- > 0) {
            long num = sc.nextLong();
            if (num % 2 != 0) {
                odd++;
            } else if (num % 4 == 0) {
                div4++;
            } else {
                even++;
            }
        }
        String s = "No";
        if (even == 0) {
            if (odd <= div4 + 1) {
                s = "Yes";
            }
        } else if (even > 0) {
            if (odd <= div4  ) {
                s = "Yes";
            }
        }
        System.out.println(s);
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 59568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      StringBuilder result = new StringBuilder();
      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      lines = br.readLine().split(" ");

      for(int i = n-1; i >= 0; i--){
        result.append(lines[i]);
        if(i != 0) result.append(" ");
      }
      System.out.println(result);
    }
  }
}


Measured memory_bytes: 24236
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

void dfs(long long d, long long N, long long &ans, long long f) {

    if (f >= 1 && d <= N) {
        string s = to_string(d);
        bool b1 = false, b2 = false, b3 = false;
        for(int i = 0;i<s.size();i++) if(s[i] == '7') b1 = true;
        for(int i = 0;i<s.size();i++) if(s[i] == '5') b2 = true;
        for(int i = 0;i<s.size();i++) if(s[i] == '3') b3 = true;
        if(b1 && b2 && b3) ans++;
    }
    if (d > N) return;

    vector<int> dd = {3, 5, 7};
    for (int i = 0; i < dd.size(); i++) {
        long long c = d;
        c *= 10;
        c += dd[i];
        dfs(c, N, ans, f + 1);
    }
}

int main() {

    long long N;
    cin >> N;

    long long ans = 0;
    dfs(0, N, ans, 0);

    cout << ans << endl;


    return 0;
}





























































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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;

//iostream::sync_with_stdio(false);

int p[maxn];

int main()
{
    int n;
    int m[maxn];
    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        cin >> m[i];
        p[m[i] - 1]++;
    }

    for(int i = 0; i < n; i++)
    {
        cout << p[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 5200
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt();
            ArrayList<Integer>[] tree = new ArrayList[n];
            for (int i = 0; i < n; i++) tree[i] = new ArrayList<>();
            for (int i = 0; i < n - 1; i++) {
                int x = inp.nextInt() - 1, y = inp.nextInt() - 1;
                tree[x].add(y);
                tree[y].add(x);
            }
            int[] topo = topologicalSort(tree);
            long[][] dp = new long[n][2];
            long MOD = 1000000007;
            for (int node: topo) {
                long white = 1;
                long black = 1;
                for (int child: tree[node]) {
                    if (dp[child][0] == 0) continue;
                    white = (white * (dp[child][0] + dp[child][1])) % MOD;
                    black = (black * dp[child][0]) % MOD;
                }
                dp[node][0] = white;
                dp[node][1] = black;
            }
            out.print((dp[topo[n-1]][0] + dp[topo[n-1]][1]) % MOD);
        }

        private static int[] topologicalSort(ArrayList<Integer>[] graph) {
            int n = graph.length;
            int[] in_degree = new int[n];
            for (int i = 0; i < n; i++) {
                for (int to: graph[i]) in_degree[to]++;
            }
            int[] res = new int[n];
            int j = 0;
            for (int i = 0; i < n; i++) {
                if (in_degree[i] == 1) res[j++] = i;
            }
            for (int i = 0; i < j; i++) {
                for (int to: graph[res[i]]) {
                    if (--in_degree[to] == 1) res[j++] = to;
                }
            }
            return res;
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}




Measured memory_bytes: 57360
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;

int main(void){
    int n, m;
    cin >> n >> m;
    vi H(n), A(n, 1);
    for(int &h : H) cin >> h;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1; b -= 1;
        if(H[a]<=H[b]) A[a] = 0;
        if(H[b]<=H[a]) A[b] = 0;
    }
    int cnt = 0;
    for(int &a : A) cnt += a;
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,d;
    scanf("%d%d%d",&n,&m,&d);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int x=(i+j)/d%2;
            int y=(m+i-j)/d%2;
            char c="RGBY"[2*x+y];
            printf("%c",c);
        }
        printf("\n");
    }    
    return 0;
}

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

#ifdef HOME
#define db(x) cerr << #x << " = " << x << endl
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
#define dbv(a) cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

using namespace std;
typedef long long ll;
typedef double dbl;


const int INF = (int)1.01e9;

string solve(int n, int k, string s) {
    if (k >= 30) return string(n, *min_element(s.begin(), s.end()));

    auto get_nt = [&](const string &t) {
        string nt = "";
        int z = n - 1;
        while (z > 0 && t[z - 1] == t[z]) z--;

        for (int j = z; j < n; j++) nt += t[j];
        for (int j = n - 1; (int)nt.length() < n; j--) nt += t[j];
        return nt;
    };

    string ans(n, 'z');
    for (int i = 0; i <= n; i++) {
        string t = s.substr(i);
        for (int j = n - 1; j >= 0; j--) if ((int)t.length() < n) t += s[j];

        for (int it = 1; it < k - 1; it++) {
            auto nt = get_nt(t);
            reverse(nt.begin(), nt.end());
            t = nt;
        }
        if (k > 1) {
            t = get_nt(t);
        }
        ans = min(ans, t);
    }
    return ans;
}

void stress() {

}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif
    stress();

    int n, k;
    string s;
    while (cin >> n >> k >> s) {
        cout << solve(n, k, s) << endl;
    }

#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


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

int A,B;
int main() {
	cin>> A >> B;
	if (A == B){
		cout<<"Draw"<<endl;
	} else if(A == 1 && B != 1){
		cout<< "Alice"<<endl;
	} else if (B == 1 && A != 1){
		cout<< "Bob"<<endl;
	} else if (A < B){
		cout<<"Bob"<<endl;
	} else{
		cout<<"Alice"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	stack<pii> stL, stR;
	vi l(n), r(n);
	rep(i, n) {
		auto& st = stL;
		while(st.size() != 0 && st.top().fi > a[i]) st.pop();
		if(st.size() == 0) l[i] = i;
		else l[i] = i - 1 - st.top().se;
		st.push(make_pair(a[i], i));
	}
	repr(i, n) {
		auto& st = stR;
		while(st.size() != 0 && st.top().fi > a[i]) st.pop();
		if(st.size() == 0) r[i] = n - 1 - i;
		else r[i] = st.top().se - i - 1;
		st.push(make_pair(a[i], i));
	}
	// rep(i, n) cout << l[i] << " " << r[i] << endl;
	ll ans = 0LL;
	rep(i, n) {
		ll tmp = l[i] + r[i] + (ll)l[i] * r[i] + 1LL;
		ans += tmp * a[i];
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
  int a, b;
  cin >> a >> b;
  int ans = max({
    a+b,
    a-b,
    a*b
  });
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256