akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#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 all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

//??§?¨???§???
//index()??¨??????????????????
template<typename T>
vector<T> compress(vector<T> v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	return v;
}

//??§????????????????????????????????????
//index(??§???????????????, ????´?)
template<typename T>
int index(const vector<T> &v, T i) { return lower_bound(v.begin(), v.end(), i) - v.begin(); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, V; cin >> N >> V;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	vector<int> b(N); rep(i, 0, N) { cin >> b[i]; }
	vector<int> c(N); rep(i, 0, N) { cin >> c[i]; }
	vector<int> d(N); rep(i, 0, N) { cin >> d[i]; }
	vector<int>	A, B;
	rep(i, 0, N)rep(j, 0, N) {
		A.emplace_back(a[i] + b[j]);
		B.emplace_back(c[i] + d[j]);
	}
	sort(all(A));
	sort(all(B));
	unordered_map<int, int> cntA, cntB;
	rep(i, 0, A.size()) {
		cntA[A[i]]++;
		cntB[B[i]]++;
	}
	A.erase(unique(A.begin(), A.end()), A.end());
	int ans = 0;
	rep(i, 0, A.size()) {
		ans += cntA[A[i]] * cntB[V - A[i]];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 137292
n = int(input())
a = [int(i) for i in input().split()]
#print(n)
dp=[]
#print(dp)
dp+=[[0,-1234567890123]]
i=0
#print(a)
while i<n:
    
    i+=1
    dp+=[[0,0]]
    dp[i][0]= max(dp[i-1][0]+a[i-1],dp[i-1][1]-a[i-1])
    #print(dp)
    dp[i][1]= max(dp[i-1][0]-a[i-1],dp[i-1][1]+a[i-1])
    #print(dp)
print(dp[n][0])
#print(dp)


Measured memory_bytes: 25572
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	long long n; cin >> n;
	vector<long long> luka_num(n + 1);
	luka_num[0] = 2;
	luka_num[1] = 1;
	for (int i = 2; i <= n; ++i) {
		luka_num[i] = luka_num[i - 1] + luka_num[i - 2];
	}
	cout << luka_num[n] << endl;
	return;
}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        for(int i = 0; i < 50; i++){
            
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
        
            if(m == -1 && f == -1 && r == -1){
                break;
            }
            else if((m == -1 || f == -1) || (m + f < 30)){
                System.out.println("F");
            }
            else if(m + f >= 80){
                System.out.println("A");
            }
            else if(65 <= m + f && m + f < 80){
                System.out.println("B");
            }
            else if(50 <= m + f && m + f < 65){
                System.out.println("C");
            }
            else if(30 <= m + f && m + f < 50){
                if(r >= 50){
                    System.out.println("C");
                }
                else{
                    System.out.println("D");
                }
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26072
N = int(input())
A = [int(input()) for i in range(N)]
n = 0
t = 0
while t<N:
    n = A[n]-1
    t +=1
    #print(n)
    if n == 1:
        print(t)
        exit()
    if n == A[n]-1:
        print(-1)
        exit()
print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6+5;
int nxt[MAXN][30];
int dp[MAXN];
int main(){
    string s;
    cin>>s;
    int n = s.length();
    s='#'+s;
    for(int i=0;i<26;i++){
        nxt[n+1][i] = n+2;
    }
    for(int i=n;i>=0;i--){
        for(int j=0;j<26;j++){
            nxt[i][j] = nxt[i+1][j];
        }
        if(i){
            nxt[i][s[i]-'a'] = i;
        }
    }
   
    dp[n+1] = 1;
    for(int i=n;i>=0;i--){
        dp[i] = MAXN;
        for(int j=0;j<26;j++){
            dp[i] = min(dp[i],dp[nxt[i][j]+1]+1);
        }
    }
    
    int ind = 0;
   
    while(true){
        for(int i=0;i<26;i++){
            //cout<<i<<" "<<nxt[ind][i]+1<<endl;
            if(dp[ind] == dp[nxt[ind][i]+1]+1){
                cout<<(char)('a'+i);
                ind = nxt[ind][i]+1;
                break;
            }
        }
        if(ind>n){
            break;
        }
    }
}


Measured memory_bytes: 27968
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 200000 + 239;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

ll bin_pow(ll a, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        p >>= 1;
    }
    return res;
}

ll rev(ll x) {
    return bin_pow(x, MOD - 2);
}

ll fact[N], rfact[N];

ll C(int n, int k) {
    return fact[n] * rfact[k] % MOD * rfact[n - k] % MOD;
}

ll cnt_paths(int x, int y) {
    return C(x + y, x);
}

void init() {
    fact[0] = 1;
    rep(i, 1, N) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    rfact[N - 1] = rev(fact[N - 1]);
    repb(i, N - 2, -1) {
        rfact[i] = rfact[i + 1] * (i + 1) % MOD;
    }
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    init();
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    ll ans = 0;
    for (int i = 1; i <= n - a; i++) {
        ans = (ans + cnt_paths(i - 1, b - 1) * cnt_paths(n - i, m - (b + 1))) % MOD;
    }
    cout << ans << "\n";
    return 0;
}

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

count = 0
backslash_index = []
area_pond = []
pending_area=[]
for index,symbol in enumerate(input()):
	if symbol == "\\":
		backslash_index += [index]
	elif symbol == '/' and backslash_index:
		last_bs_index = backslash_index.pop()
		diff = index - last_bs_index 
		count += diff 
		while area_pond and area_pond[-1] > last_bs_index:
			diff += pending_area.pop()
			area_pond.pop()

		area_pond += [last_bs_index]
		pending_area += [diff]

print(count)
print(len(area_pond),*(pending_area))



Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int DP[3010]; // 水+砂糖の重量がiの時の、砂糖の重量の最大値

void init()
{
  for (int i = 0; i < 3010; i++)
  {
    DP[i] = -1;
  }
  DP[0] = 0;
}

bool ok(int s, int w, int E)
{
  return (100 * s) <= (E * w);
}

bool gt(int sw, int s, int msw, int ms)
{
  return s * msw > ms * sw;
}

int main()
{
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  init();
  for (int i = 0; i <= F; i++)
  {
    if (DP[i] == -1)
      continue;
    if (i + 100 * A <= F)
      DP[i + 100 * A] = DP[i];
    if (i + 100 * B <= F)
      DP[i + 100 * B] = DP[i];
    if (i + C <= F && ok(DP[i] + C, i - DP[i], E))
      DP[i + C] = DP[i] + C;
    if (i + D <= F && ok(DP[i] + D, i - DP[i], E))
      DP[i + D] = DP[i] + D;
  }
  int ms = 0, msw = 100 * A;
  for (int i = 0; i <= F; i++)
  {
    if (DP[i] == -1)
      continue;
    if (gt(i, DP[i], msw, ms))
    {
      ms = DP[i];
      msw = i;
    }
  }
  cout << msw << ' ' << ms << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int n; cin >> n;
    int x = 0;
    reps(i,1,9){
        x = i * 111;
        if(n <= x) break;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll K;
    cin>>K;
    ll now = 0;
    ll now7 = 7;
    rep(i,0,K+1){
        now += now7;
        now%=K;
        now7*=10;
        now7%=K;
        if(now==0){
            cout<<i+1;
            break;
        }
        if(i==K)cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 3632
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int x, a, b;
	cin >> x >> a >> b;

	int ans = x - a;

	while(ans - b >= 0){
		ans -= b;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# Highway Toll

PRICE_LIST = (
    (0, 0, 0, 0, 0, 0, 0, 0),
    (0, 0, 300, 500, 600, 700, 1350, 1650),
    (0, 6, 0, 350, 450, 600, 1150, 1500),
    (0, 13, 7, 0, 250, 400, 1000, 1350),
    (0, 18, 12, 5, 0, 250, 850, 1300),
    (0, 23, 17, 10, 5, 0, 600, 1150),
    (0, 43, 37, 30, 25, 20, 0, 500),
    (0, 58, 52, 45, 40, 35, 15, 0),
)

while True:
    i = int(raw_input())
    if i == 0:
        break

    it = int(raw_input().strip().replace(' ', ''))
    o = int(raw_input())
    ot = int(raw_input().strip().replace(' ', ''))

    half = False
    price = PRICE_LIST[i][o]
    if (1730 <= it <= 1930 or 1730 <= ot <= 1930) and PRICE_LIST[o][i] <= 40:
        half = True
        price /= 2
        if price % 50:
            price = price - (price % 50) + 50

    print price

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

const int mod=1e9+7;

signed main()
{
    int N,M; cin>>N>>M;
    vector<bool> ng(N);
    for(int i=0;i<M;i++){
        int a; cin>>a;
        ng[a]=true;
    }
    
    vector<int> dp(N+1);
    dp[0]=1;
    for(int i=0;i<N;i++){
        if(ng[i]) continue;
        if(i+1<=N){
            dp[i+1]+=dp[i];
            dp[i+1]%=mod;
        }
        if(i+2<=N){
            dp[i+2]+=dp[i];
            dp[i+2]%=mod;
        }
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    deque<int> deq;
    deq.push_back(A[0]);

    int ans = 1;

    for (int i = 1; i < N; i++) {
        if (A[i] <= deq[0]) {
            ans++;
            deq.push_front(A[i]);
        }
        else {
            auto it = lower_bound(deq.begin(), deq.end(), A[i]);
            *(it - 1) = A[i];
        }
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 3928
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N){
  string n = to_string(N);
  ll x = (ll)(n[0] - '0');
  if(N == (x+1)*(pow(10,(n.length()-1)))-1)cout << x + (9*(n.length()-1)) << endl;
  else cout << (x-1) + (9 * (n.length()-1)) << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
    solve(N);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int N;

		N = scanner.nextInt();

		int[] min_dist = new int[N];
		Node[] nodes = new Node[N];
		for(int i = 0; i < N; i++)nodes[i] = new Node();

		int node_id,num,to,dist;

		for(int loop = 0; loop < N; loop++){
			node_id = scanner.nextInt();
			num = scanner.nextInt();

			for(int i = 0; i < num; i++){
				to = scanner.nextInt();
				dist = scanner.nextInt();
				nodes[node_id].ADJ.add(new Edge(to,dist));
			}
		}

		min_dist[0] = 0;
		for(int i = 1; i < N; i++)min_dist[i] = BIG_NUM;

		PriorityQueue<Info> Q = new PriorityQueue<Info>();
		int next_node,next_dist;

		Q.add(new Info(0,0));

		while(!Q.isEmpty()){

			if(Q.peek().sum_dist > min_dist[Q.peek().node_id]){
				Q.remove();
			}else{

				for(int i = 0; i < nodes[Q.peek().node_id].ADJ.size(); i++){
					next_node = nodes[Q.peek().node_id].ADJ.get(i).to;
					next_dist = Q.peek().sum_dist+nodes[Q.peek().node_id].ADJ.get(i).dist;

					if(min_dist[next_node] > next_dist){
						min_dist[next_node] = next_dist;
						Q.add(new Info(next_node,next_dist));
					}
				}
				Q.remove();
			}
		}

		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < N; i++){
			ans.append(Integer.toString(i)).append(" ").append(Integer.toString(min_dist[i])).append("\n");
		}

		System.out.print(ans.toString());
	}
}

class Node{
	public ArrayList<Edge> ADJ;

	Node(){
		ADJ = new ArrayList<Edge>();
	}
}

class Edge{
	public int to;
	public int dist;

	Edge(int arg_to,int arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
}

class Info implements Comparable<Info>{
	public int node_id;
	public int sum_dist;

	Info(int arg_node_id,int arg_sum_dist){
		this.node_id = arg_node_id;
		this.sum_dist = arg_sum_dist;
	}

	public int compareTo(Info arg){
		if(this.sum_dist < arg.sum_dist)return -1;
		if(this.sum_dist > arg.sum_dist)return 1;
		return 0;
	}
}




Measured memory_bytes: 274544
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int c[100010];
int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        c[a]++, c[b]++;
    }
    rep(i, n+1){
        if (c[i] % 2 != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll read(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void wri(ll x){write(x);pc(' ');}
inline void writeln(ll x){write(x);pc('\n');}
typedef vector<int> ve;
ve vec[233];
int n,k;
ve mul(ve a,ve b){
	ve c(n);
	rep(i,0,n) c[i]=a[b[i]];
	return c;
}
ve inv(ve a){
	ve b(n);
	rep(i,0,n) b[a[i]] = i;
	return b;
}
ve qpow(ve a,int b){
	ve ans(n);rep(i,0,n)ans[i]=i;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}
void print(ve x){
	rep(i,0,n) wri(x[i]+1);puts("");
}
int main(){
	n = read(),k = read();
	Rep(t,1,2) Rep(i,1,n) vec[t] . push_back(read()-1);
	Rep(i,3,6) vec[i] = mul(vec[i-1],inv(vec[i-2]));
	ve A=mul(mul(vec[2],inv(vec[1])),mul(inv(vec[2]),vec[1]));
	A  = qpow(A,(k-1)/6);
	print(mul(mul(A,vec[(k-1)%6+1]),inv(A)));
	return 0;
}

Measured memory_bytes: 6112
using System;

class Program
{
  public static void Main(string[] args)
  {
    string[] tmp = Console.ReadLine().Split(' ');
    int[] rectangle = new int[2];
    int[] circle = new int[3];
    rectangle[0] = int.Parse(tmp[0]);
    rectangle[1] = int.Parse(tmp[1]);
    circle[0] = int.Parse(tmp[2]);
    circle[1] = int.Parse(tmp[3]);
    circle[2] = int.Parse(tmp[4]);

    bool judge = true;

    if(circle[0] + circle[2] > rectangle[0] || circle[0] - circle[2] < 0){
      judge = false;
    }
    if(circle[1] + circle[2] > rectangle[1] || circle[1] - circle[2] < 0){
      judge = false;
    }
    if(judge) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}

Measured memory_bytes: 9008
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b

    if n <= a:
        print(n)
        return

    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

if doTest==0:
    resolve()
    sys.exit()

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

int main() {

    int N;
    cin >> N;

    vector<int> a_vec;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a ;
        a_vec.push_back(a);
    }

    int cnt = 0;

    int idx = 0;

    int total = 0;

    //cout << "a_vec: " << a_vec.size() <<endl;

    do{
        cnt++;
        total++;

        int next = a_vec.at(idx);
        //cout << "next: " << next <<endl;

        if(next == 2){
            cout << cnt << endl;
            return 0;
        }
        idx = next -1;

    }while (total < N);

    cout << "-1" << endl;
 
    
}


Measured memory_bytes: 3892
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll A, B, N, ans;
    cin >> A >> B >> N;
    if (N >= B) {
        if (A % B == 0) {
            ans = A - A / B;
        }
        else {
            ans = A - A / B - 1;
        }
    }
    else {
        ans = A * N / B;
    }
    cout << ans << endl;
}

    






    


   









    


















































































































































































































































































































Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define itn int
#define tin int
#define tni int
#define a first
#define b second
bool dbg = false;
int ans, N, M, A[100010], B[100010];
typedef struct {
    int i;
    int a;
    int b;
} arb;
vector<arb> V;
void solve()
{
    priority_queue<int> que;
    sort(all(V), [](arb x, arb y) { return x.a < y.a; });
    /*
    for (int i = 0; i < N; i++) {
        cout << V[i].i << " " << V[i].a << " " << V[i].b << endl;
    }
    */

    int t = 0;

    for (int k = 1; k <= M; k++) {
        while (t < N && k == V[t].a) {
            que.push(V[t].b);
            t++;
        }
        if (!que.empty()) {
            //cout << que.top() << endl;
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    FOR(i, 0, N)
    {
        int a, b;
        cin >> a >> b;
        V.pb(arb{i, a, b});
    }

    solve();
    return 0;
}


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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef pair<int,int> Paint;

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}

#define anyfill(n,s) setw(n) << setfill(s)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007


/*
確認ポイント
to_string() はC++11以降の実装;
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
length(),size()に括弧をつけ忘れてないか;
sort()が使える型//vector,string...
大文字小文字間違えてないか
cout << fixed << 小数計算//正しい小数表記になる(基本6桁)(e記法回避にも使える)
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
*/
int main() { 
  int n;cin>>n;
  vector<string> a;
  string s[n];
  int m[n];
  for(int i = 0; n > i; i++){
    cin>>s[i]>>m[i];
    bool ok = true;
    for(int j = 0; a.size() > j; j++){
      if(a[j] == s[i]){
        ok = false;
        break;
      }
    }
    if(ok)a.push_back(s[i]);
  }
  sort(a.begin(),a.end());
  vector<Paint> hai;
  for(int i = 0; a.size() > i; i++){
    hai.clear();
    for(int j = 0; n > j; j++){
      if(a[i] == s[j])hai.push_back(make_pair(m[j],j+1));
    }
    sort(hai.begin(),hai.end(),greater<Paint>());
    for(int j = 0; hai.size() > j; j++){
      cout << hai[j].second  << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <tuple>
using namespace std;

bool comp(tuple<int, int, int> lh, tuple<int, int, int> rh) {
	return get<2>(lh) > get<2>(rh);
}

int main() {
	int N, dummy;
	dummy = scanf("%d", &N);

	vector<tuple<int, int, int>> vt;

	int tmp1, tmp2, tmp3;
	for (int i = 0; i < N; i++) {
		dummy = scanf("%d %d %d", &tmp1, &tmp2, &tmp3);
		vt.push_back(make_tuple(tmp1, tmp2, tmp3));
	}

	sort(vt.begin(), vt.end(), comp);

	// 中心座標[x:0, y:0]～[x:100, y:100]の10100点を総当たり試行
	for (int x = 0; x < 101; x++) {
		for (int y = 0; y < 101; y++) {
			bool NG = false;
			// 1つ目の観測データと中心座標でピラミッドの高さが算出できる
			int h = abs(get<0>(vt[0]) - x) + abs(get<1>(vt[0]) - y) + get<2>(vt[0]);
			for (int i = 1; i < vt.size(); i++) {
				// 2つ目以降の観測データからもピラミッドの高さを算出
				int tmph = abs(get<0>(vt[i]) - x) + abs(get<1>(vt[i]) - y) + get<2>(vt[i]);
				// 算出したピラミッド高さに矛盾があれば、中心座標の仮定が誤り
				if (!(h == tmph || (get<2>(vt[i]) == 0 && h <= tmph))) {
					NG = true;
					break;
				}
			}
			// 「ピラミッドの中心座標と高さをちょうど1つに特定することができる」ので
			// チェックをくぐり抜けた座標があればそれが即答えとなる
			if (!NG) {
				printf("%d %d %d\n", x, y, h);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
def main():
    n, y = map(int, input().split())
    print(*solve(n, y))

def solve(n, y):
    for i in range(y // 10000 + 1):
        if (y - 9000 * i - 1000 * n) % 4000 != 0:
            continue
        j = (y - 9000 * i - 1000 * n) // 4000
        k = n - i - j
        if i >= 0 and j >= 0 and k >= 0:
            return i, j, k

    return -1, -1, -1

main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


ll solve(vector<int> A) {
  const int N = A.size();
  sort(ALL(A));
  deque<int> ans;
  int l = 0, r = N-1;
  ans.push_back(A[l]);
  l++;
  while ((int)ans.size() < N) {
    int val = -1;
    int move = 0;
    if (val < abs(ans.back() - A[l])) {
      val = abs(ans.back() - A[l]);
      move = 0;
    }
    if (val < abs(ans.back() - A[r])) {
      val = abs(ans.back() - A[r]);
      move = 1;
    }
    if (val < abs(ans.front() - A[l])) {
      val = abs(ans.front() - A[l]);
      move = 2;
    }
    if (val < abs(ans.front() - A[r])) {
      val = abs(ans.front() - A[r]);
      move = 3;
    }

    if (move == 0) { ans.push_back(A[l]); l++; }
    if (move == 1) { ans.push_back(A[r]); r--; }
    if (move == 2) { ans.push_front(A[l]); l++; }
    if (move == 3) { ans.push_front(A[r]); r--; }
  }

  ll d = 0;
  for (int i = 1; i < N; i++) {
    d += abs(ans[i-1] - ans[i]);
  }
  return d;
}

int main2() {
  int N = nextInt();
  vector<int> A(N);
  REP(i, N) A[i] = nextInt();

  ll ans1 = solve(A);
  cout << ans1 << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 998244353;
int cost[12];
int arr[12][12];
int final[12];
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int n,m,x,mincost=INF;
	sd(n);sd(m);sd(x);
	for(int i = 0; i < n; i++){
		sd(cost[i]);
		for(int j = 0; j < m; j++) sd(arr[i][j]);
	}
	for(int i = 0; i < (1<<n); i++){
		int k=i,ans=0;
		for(int j = 0; j < n; j++){
			int temp=k&1;
			k>>=1;
			if(temp){
				ans+=cost[j];
				for(int k = 0; k < m; k++) final[k]+=arr[j][k];
			}
		}
		bool check=true;
		for(int j = 0; j < m; j++){
			check&=(final[j]>=x);
			final[j]=0;
		}
		if(check) mincost=min(mincost,ans);
	}
	if(mincost==INF) pd(-1);
	else pd(mincost);
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
//const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=2005;
ll n,mod,C[M][M];

ll Pow(ll x,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*x)%mod;
		x=(x*x)%mod;
	}
	return r;
}

int main(){
	cin>>n>>mod;
	C[0][0]++;
	for(int i=0;i<M-1;i++) for(int j=0;j<=i;j++){
		(C[i+1][j]+=C[i][j])%=mod;
		(C[i+1][j+1]+=C[i][j])%=mod;
	}
	ll res=0;
	for(ll i=1;i<n;i++){
		ll j=n-i,tmp=0;
		for(ll k=0;k<=j;k++){
			ll t=(k%2==0?1:mod-1);
			(t*=C[j][k])%=mod;
			(t*=Pow((Pow(2,j-k)-1+mod)%mod,i))%=mod;
			(tmp+=t)%=mod;
		}
		(tmp*=C[n][i])%=mod;
		(tmp*=Pow(2,i*(i-1)/2+j*(j-1)/2))%=mod;
		(res+=tmp)%=mod;
	}
	cout<<res<<endl;
}


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

using i8   = int8_t;
using u8   = uint8_t;
using i16  = int16_t;
using u16  = uint16_t;
using i32  = int32_t;
using u32  = uint32_t;
using i64  = int64_t;
using u64  = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;

using f32  = float;
using f64  = double;
using f80  = __float80;
using f128 = __float128;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'000LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// {{{ util
#define FOR(i, start, end) for(i64 i = (start), i##_end=(end); i < i##_end; ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cc) { return (f)(begin(cc), end(cc), ## __VA_ARGS__); })(c))

template<typename T, typename U>
bool chmax(T& xmax, const U& x) {
    if(xmax < x) {
        xmax = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T, typename U>
bool chmin(T& xmin, const U& x) {
    if(x < xmin) {
        xmin = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T>
void RD(T& x) {
    cin >> x;
#ifdef PROCON_LOCAL
    assert(cin);
#endif
}

template<typename T>
void RD(vector<T>& v, int n) {
    v.reserve(n);
    REP(_, n) {
        T e; RD(e);
        v.emplace_back(e);
    }
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for(auto first = begin(v), it = first; it != end(v); ++it) {
        if(it != first)
            out << ' ';
        out << *it;
    }
    return out;
}

template<typename T>
void PRINT(const T& x) {
    cout << x;
}

template<typename T>
void PRINTLN(const T& x) {
    PRINT(x);
    cout << '\n';
}

template<typename T>
void DBG_IMPL(i64 line, const char* expr, const T& value) {
#ifdef PROCON_LOCAL
    cerr << "[LINE " << line << "]: ";
    cerr << expr << " = " << value << "\n";
#endif
}

#define DBG(expr) DBG_IMPL(__LINE__, #expr, (expr))
// }}}

//--------------------------------------------------------------------

string S;

void solve() {
    i64 a = ALL(count, S, '0');
    i64 b = ALL(count, S, '1');

    i64 ans = min(a,b) * 2;

    PRINTLN(ans);
}

signed main() {
    RD(S);

    solve();

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#define  WHITE 0
#define  BLACK 1
#define  GRAY 2
int n,time;

typedef struct graph{
    int u;//vertex;
    int v[100];
    int k;
    int color;
    int f;
    int d;
}Graph;

void visit(Graph G[],int u){
    int i,m;
    G[u].color=GRAY;
    G[u].d=++time;
    for(i=0;i<G[u].k;i++){
        if(G[G[u].v[i]].color==WHITE){
            visit(G,G[G[u].v[i]].u);
        }
    }
    G[u].color=BLACK;
    G[u].f=++time;
}

void dfs(Graph G[]){
    int i;
    for(i=1;i<=n;i++){
        G[i].color=WHITE;
    }
    for(i=1;i<=n;i++){
        if(G[i].color==WHITE){
            visit(G,G[i].u);
        }
    }
}

int main(){
    int i,j;
    Graph G[100];
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d %d",&G[i].u,&G[i].k);
        for(j=0;j<G[i].k;j++){
            scanf("%d",&G[i].v[j]);
        }
    }
    dfs(G);
    for(i=1;i<=n;i++){
        printf("%d %d %d\n",G[i].u,G[i].d,G[i].f);
    }
    return 0;
}




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


int main()
{
  int N;
  double A;
  double sum = 0;
  
  cin >> N;
  
  for (int i=0;i<N;i++){
  cin >> A;
  sum += 1 / A;    
  }
  
  cout << 1 / sum << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,w,i,a,c=0,b[100010]={};
  scanf("%d %d %d",&n,&m,&w);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(i%2){
      b[i    *w  -a]++;
      b[(i+1)*w-a]--;
    }
    else{
      b[i    *w  +a]++;
      b[(i+1)*w+a]--;
    }
    //for(a=0;a<n*w;a++)printf("%d ",b[a]);printf("\n");
  }
  for(i=1;i<n*w;i++)b[i]+=b[i-1];
  for(i=0;i<n*w;i++){//printf("%d ",b[i]);
    if(b[i]==0)c++;
  }//printf("\n");
  printf("%d\n",c*m);
  return 0;
}



Measured memory_bytes: 3132
#include<stdio.h>
int main(){
char a[100000]={0};
int cnt=0,i;
  
scanf("%s",a);
for(i=0;i<100000;i++){
if(a[i]=='0'&&i%2==0){
  cnt++;   
}
if(a[i]=='1'&&i%2!=0){
  cnt++;}

 if(a[i]=='\0'){
    break;}
} 
if(cnt*2<i){ 
 printf("%d\n",cnt);}
  else{
 printf("%d\n",i-cnt);}
 
  return(0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC155A - Poor

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        String ans = "No";
        if ((a == b && a == c) ||
            (a != b && a != c && b != c)) {

        } else {
            ans = "Yes";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main (){
  int a,b;
   cin>>a>>b;
    if(a==1&&b!=1){
    cout<<"Alice"<<endl;
    return 0;
  }
  if(b==1&&a!=1)
  {
     cout<<"Bob"<<endl;
    return 0;
  }
  if(a>b)
   cout<<"Alice"<<endl;
  else if(b>a)
    cout<<"Bob"<<endl;
  else
    cout<<"Draw"<<endl;
}


Measured memory_bytes: 256
N,L = map(int,input().split())
apple = []
for i in range(N):
    apple.append(L+i)
if L >= 0:
    print(sum(apple)-min(apple))
else:
    if 0 <= N+L-1:
        print(sum(apple))
    else:
        print(sum(apple)+abs(N+L-1))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int i,n,a[214514];
	cin>>n;
	for(i=0;i<n;cin>>a[i++]);
	for(i--;i>=0;i-=2)cout<<a[i]<<" ";
	for(i=n%2;i<n;i+=2)cout<<a[i]<<" ";
}

Measured memory_bytes: 2944
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    ll money=1000;
    ll kabu=0;
    ll tmp;
    REP(i,N) cin>>A[i];
    REP(i,N-1){
        if(A[i+1]>A[i]){
            tmp=money;
            kabu+=money/A[i];
            money-=A[i]*(tmp/A[i]);
        }
        if(A[i+1]<A[i]){
            money+=A[i]*kabu;
            kabu=0;
        }
    }

    money+=A[N-1]*kabu;
    cout<<money<<endl;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
                        
vector< int > g[N];
int n, q;
ll ans[N];
void dfs(int v, int p){	
	for(auto to : g[v]){
		if(to == p)
			continue;
		ans[to] += ans[v];
		dfs(to, v);
	}
}                        
int main()
{                   
	scanf("%d%d", &n, &q);
	for(int i = 1; i < n; i++){
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].pb(u);
		g[u].pb(v);
	}
	for(int i = 1; i <= q; i++){
		int v, x;
		scanf("%d%d", &v, &x);
		ans[v] += x;
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i++)
		printf("%lld ", ans[i]);
	return 0;
}


Measured memory_bytes: 24320
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int main(){
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    long sum=0;
    int r=0,g=0,b=0;
    F(i,0,n){
        if(s[i]=='R') r+=1;
        else if(s[i]=='G') g+=1;
        else if(s[i]=='B') b+=1;
    }
    F(i,0,n){
        if(r>0 && g>0 && b>0){
            if(s[i]=='R'){
                r-=1;
                sum+=g*b;
                for(int j=1; i+2*j<n; j++){
                    if((s[i+j]=='G' && s[i+2*j]=='B') || (s[i+j]=='B' && s[i+2*j]=='G')){
                        sum-=1;
                    }
                }
            }
            else if(s[i]=='G'){
                g-=1;
                sum+=r*b;
                for(int j=1; i+2*j<n; j++){
                    if((s[i+j]=='R' && s[i+2*j]=='B') || (s[i+j]=='B' && s[i+2*j]=='R')){
                        sum-=1;
                    }
                }
            }
            else{
                b-=1;
                sum+=g*r;
                for(int j=1; i+2*j<n; j++){
                    if((s[i+j]=='G' && s[i+2*j]=='R') || (s[i+j]=='R' && s[i+2*j]=='G')){
                        sum-=1;
                    }
                }
            }
        }
    }
    printf("%ld\n",sum);
    
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define ddl pair<double,double>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
#define GCD(x,y)  __gcd(x, y)
using namespace std;


int main(){
    //fast
    ll n,m,k,x,cnt,cn,c,value,sum,sum2;
    vector<ll> a,b,v;
        cin>>n>>m>>k;
    cnt = cn = c = 0;
    sum = 0;sum2 = 0;
    while(n--){
        cin>>value;
        a.push_back(value);
        sum+=value;
        if(sum<=k)cnt++;
    }
    while(m--){
        cin>>value;
        b.push_back(value);
        sum2+=value;
        if(sum2<=k)cn++;
    }
    v.push_back(cnt);
    v.push_back(cn);
    n = a.size() - 1;
    c = n + 1;
    for(int i=n,j=0;i>=0;){
        if(sum + b[j]>k){
            sum-=a[i];
            i--;
            c--;
        }
        if(j==b.size())break;
        if((sum + b[j])<=k){
            sum+=b[j];
            j++;
            c++;
            v.push_back(c);
        }
    }
    n = b.size() - 1;
    c = n + 1;
    for(int i=n,j=0;i>=0;){
         if(sum2 + a[j]>k){
            sum2-=b[i];
            i--;
            c--;
        }
        if(j==a.size())break;
        if(sum2 + a[j]<=k){
            sum2+=a[j];
            j++;
            c++;
            v.push_back(c);
        }
    }
        s(v);
    n = v.size() - 1;
        cout<< v[n] <<endl;



    return accepted;
}


Measured memory_bytes: 10576
def f(x):
    return x**2

while 1:
    try:
        d0 = raw_input()
        if d0 == '':
            break
        area = []
        d = int(d0)
        for i in range(d, 600, d):
            area.append(d*f(i))
        Sumpoyo = sum(area)
        print Sumpoyo
    except EOFError:
        break

Measured memory_bytes: 5440
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        for(int j = i; j < s.size(); j++){
            bool f = true;
            for(int k = i; k <= j; k++){
                if(!(s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T')){
                    f = false;
                    break;
                }
            }
            if(f) ans = max(ans, j - i + 1);
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
n = int(input())
say = []
a = []
ans = 0
for i in range(n):
    ai = int(input())
    a.append(ai)
    say.append([])
    for j in range(ai):
        xi, yi = map(int, input().split())
        say[i].append((xi, yi))
for i in range(2**n):
    trueman = []
    mujun = False
    for j in map(int, list("0"*(n - len(bin(i)[2:])) + bin(i)[2:])):
        trueman.append(j)
    for j in range(n):
        if trueman[j] == True:
            for k in range(a[j]):
                if say[j][k][1] == 1:
                    if trueman[say[j][k][0]-1] == 0:
                        mujun = True
                if say[j][k][1] == 0:
                    if trueman[say[j][k][0]-1] == 1:
                        mujun = True
    if not mujun:
        ans = max(ans, sum(trueman))
print(ans)

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

int main()
{
    priority_queue<pair<ll, ll> > pq;
    ll n, m;
    cin >> n >> m;

    for (ll i = 0; i < n; i++) {
        ll coin, num;
        cin >> coin >> num;

        pq.push({-coin, num});
    }

    ll cnt = 0;
    ll koyta_nilam = 0;
    while (!pq.empty()) {
        auto tmp = pq.top();
        pq.pop();

        ll curcoin = -tmp.first;
        ll curnum = tmp.second;

        if (curnum + koyta_nilam > m) cnt += (m - koyta_nilam) * curcoin, koyta_nilam = m;
        else cnt += curnum * curcoin, koyta_nilam += curnum;

        if (koyta_nilam == m) break;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 2420
from bisect import bisect_left
n = int(input())
a = list(map(int,input().split()))
a.append(1000000001)
q = int(input())
for i in range(q):
    k = int(input())
    p = bisect_left(a,k)
    print(1 if a[p] == k else 0)


Measured memory_bytes: 17220
N = int(input())
a = list(map(int,input().split()))

i = 1
count = 0
bool = "False"
for n in a:
  if n == i:
    i += 1
    bool = "True"
  else:
    count += 1

if bool == "False":
  print("-1")
else:
	print(count)
  

Measured memory_bytes: 26140
while 1:
    w,h = map(int,raw_input().split())
    if w == h == 0:
        break
    for i in range(w-1):
        if i == 0:
            print "#"*h
        if i == w-2:
            print "#"*h
        else:
            print "#"+"."*(h-2)+"#"
    print ""

Measured memory_bytes: 6224
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
int main(){
  int n,z,w,x;cin >> n >> z >> w;
  int ans = 0;
  x;
  rep(i,n){
    int a; cin >> a;
    if(n == 1){cout << abs(w-a) << endl; return 0;}
    if(i == n-2) x = a;
    if(i == n-1)
      ans = max(ans,abs(x-a)),x=a;
  }
  cout << (ans=max(ans,abs(w-x)),ans) << endl;
}

Measured memory_bytes: 256