akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var rdx = ReadInts();
            var x = rdx[2];
            for (int i = 1; i <= 10; i++)
            {
                WriteLine(rdx[0] * x - rdx[1]);
                x = rdx[0] * x - rdx[1];
            }
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


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

int main() {
    int N;
    cin >>N;
    int V[N];
    for(int i=0; i<N; i++){
        cin >> V[i];
    }

    long ans = 0;
    for(int i=0; i<N; i++){
        int c;
        cin >> c;
        if(V[i]-c > 0){
            ans += V[i]-c;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
    let n: Vec<i32> = read_vec();
    println!("{}", n[0] * n[1] / 2);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
// =====================================================================================
//
//       Filename:  at.cpp
//
//    Description:  
//
//        Version:  1.0
//        Created:  19/04/20 05:21:38 PM IST
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Kiran Bhanushali (), kiranbhanushali143.kb143@gmail.com
//   Organization:  
//
// =====================================================================================

#include<bits/stdc++.h>


using namespace std;

#define int long long 
#define pb push_back
//#define _SHOW_TIME

void solve(){
    //your code here;
    int n,m ;
    cin>>n;
   double d = 22/7.0;
  d*=2;
  d*=n;
  cout<<d<<endl;
    
}
int32_t main(){
 /////////////////////////////////////
    #ifdef _SHOW_TIME
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
    solve();
    /////////////////////////////////////
    #ifdef _SHOW_TIME
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
    return 0;

}



Measured memory_bytes: 3800
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 2147483647
#define LLINF 2000000000000000000LL
#define PI 3.141592653589793

#define SIZE 200000

/* Binary Indexed Tree(1-index) */
struct BIT{
    typedef int Type; //?????¨?????????
    int bit_size;
    vector<Type> data;

    BIT(int n){
        bit_size = n;
        data.assign(n+1,0);
    }
    
    //k?????????????´????x????????????
    void add(int k,Type x){
        while(k<=bit_size){
            data[k]+=x;
            k+= k&(-k);
        }
    }

    //[1,k]??????
    int query(int k){
        int rec=0;
        
        while(k>0){
            rec+=data[k];
            k-= k&(-k);
        }
        
        return rec;
    }
};


int main(){
    int n,q,a,b,c;
    BIT rmq(100000);
    
    scanf("%d%d",&n,&q);
    
    for(int i=0;i<q;i++){
        scanf("%d%d%d",&a,&b,&c);
        
        if(a==0){
            rmq.add(b,c);
        }else{
            printf("%d\n",rmq.query(c)-rmq.query(b-1));
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 1532
//Author : Gaara
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define endl "\n"
#define fo(i,n) for(ll i=0;i<n;i++)
#define ro(i,n) for(ll j=n-1;i>=0;i--)
#define vll vector<long long>
#define mod 1000000007
 
int main(){
    int t=1;
    //cin>>t;
    while(t--){
	  ll n; cin>>n;
      ll a[n];
      fo(i,n) cin>>a[i];
      ll sum[n];
      sum[n-1] = a[n-1];
      for(int i=n-2;i>=0;i--){
        sum[i] = (sum[i+1] + a[i])%mod;
      }
      ll ans = 0;
      for(int i=0;i<n-1;i++){
        ans+= (a[i]*sum[i+1])%mod;
        ans %= mod;
      }
      cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6732
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
using namespace std;

typedef long long li;
typedef pair<int, int> pii;

const int mod = 1e9 + 7;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (li)x * y % mod; }
inline int Mul(int x, int y, int z) { return Mul(Mul(x, y), z); }

inline void Max(int &x, int y) { if (y > x) x = y; }
inline void Min(int &x, int y) { if (y < x) x = y; }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

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

const int maxn = 300, maxnum = 2 * maxn + 1;
int n;
int limited[maxnum], fake[maxnum], spicy[maxnum];
int dp[maxn + 2][maxn + 2], old[maxn + 2][maxn + 2];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    if (y == -1) {
      // emm
    } else if (x == -1) {
      limited[y] = 1;
      spicy[y] = 1;
    } else {
      limited[x] = 2;
      limited[y] = 3;
      fake[x] += 1;
      fake[y] -= 1;
      spicy[x] = 1;
    }
  }
  for (int i = 1; i <= n * 2; ++i) {
    fake[i] += fake[i - 1];
  }
  for (int i = n * 2; i >= 1; --i) {
    spicy[i - 1] += spicy[i];
  }

  dp[0][0] = 1;
  for (int num = 1; num <= n * 2; ++num) {
    COPY(dp, n + 1, old);
    FILL(dp, n + 1, 0);
    for (int bin = 0; bin <= n; ++bin) {
      for (int sz = 0; sz <= n; ++sz) {
        int em = n * 2 - (bin + fake[num - 1]) - (num - 1 - sz);
        if (em & 1) continue;
        em >>= 1;
        em -= spicy[num];
        if (em < 0) continue;

        int val = old[bin][sz];
        // if (val == 0) continue;
        // printf("old[%d][%d][%d] = %d (em = %d)\n", num, bin, sz, val, em);
        if (limited[num] == 0) {
          Add(dp[bin][sz + 1], Mul(val, sz + 1));
          if (bin) {
            Add(dp[bin - 1][sz], val);
          }
          if (em) {
            Add(dp[bin + 1][sz], Mul(val, em));
          }
        } else if (limited[num] == 1) {
          Add(dp[bin + 1][sz], val);
          if (sz) {
            Add(dp[bin][sz - 1], val);
          }
        } else if (limited[num] == 2) {
          Add(dp[bin][sz], val);
        } else if (limited[num] == 3) {
          Add(dp[bin][sz], val);
        }
      }
    }
  }

  int ans = dp[0][0];
  printf("%d\n", ans);
  return 0;
}


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

int main(){
	int n, p;
	cin >> n >> p;
	int64_t dp[n + 1][100 * n + 1]{};
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		for(int j = 0; j < 100 * n + 1; j++){
			dp[i + 1][j] = dp[i][j];
			if(0 <= j - a) dp[i + 1][j] += dp[i][j - a];
		}
	}
	int64_t ans = 0;
	for(int j = p; j < 100 * n + 1; j += 2) ans += dp[n][j];
	cout << ans << endl;
}

Measured memory_bytes: 2176
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t Q;
  cin >> Q;
  for (int64_t q = 0; q < Q; ++q) {
    string s, t;
    cin >> s >> t;
    const int64_t SL = static_cast<int64_t>(s.length());
    const int64_t TL = static_cast<int64_t>(t.length());
    vector<vector<int64_t>> dp(SL + 1, vector<int64_t>(TL + 1, 0));
    for (int64_t i = 1; i <= SL; ++i) {
      for (int64_t j = 1; j <= TL; ++j) {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        if (s[i - 1] == t[j - 1]) {
          dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]);
        }
      }
    }
    cout << dp[SL][TL] << endl;
  }
  return 0;
}



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

const int MAXN = 200005;
int x[MAXN], a[MAXN];

int main()
{
	int n;
	long long ans = 0;
	scanf("%d", &n);
	for (register int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (register int i = n; i >= 1; i--)
	{
		x[i] = max(0, x[i+1] - 1);
		if (x[i] > a[i]) { printf("-1"); return 0; }
		else if (x[i] < a[i]) {
			if (a[i] >= i) { printf("-1"); return 0; }
			else ans += (long long)a[i], x[i] = a[i];
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int N, m, q;
int vector[100000][100];
int count[100000];
int group[100000];
int ID = 1;
 
void dfs(int s){
    int i;
    group[s]=ID;
    for(i = 0; i < count[s]; i++ ) {
        if ( group[vector[s][i]] == 0 ) dfs(vector[s][i]);
    }
}
 
int main(void) {
    int i, j, a, b; 
    scanf("%d%d", &N, &m);
    for ( i = 0; i < m; i++ ) {
        scanf("%d%d", &a, &b);
        vector[a][count[a]++] = b;
        vector[b][count[b]++] = a;
    }
    for ( i = 0; i < N; i++ ) {
        if ( group[i] == 0 ) {
            dfs(i);
            ID++;
        }
    } 
    scanf("%d",&q);
    for ( i = 0; i < q; i++ ) {
        scanf("%d%d", &a, &b);
        if ( group[a] == group[b] ) printf("yes\n");
        else printf("no\n");
    }
 
    return 0;
}

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

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

    if (s == "ABC") {cout << "ARC" <<endl;}
    else if (s == "ARC") {cout << "ABC" << endl;}
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

	
int main() {

	ll N,L;
	cin >> N >> L;

	ll pie = (L + L + N - 1)*N / 2;

	if (L + N - 1 < 0) { cout << pie - (L + N - 1); }
	else if (L > 0) { cout << pie - L; }
	else { cout << pie; }
	
	

	
	system("PAUSE");
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, X; cin >> N >> X;
  vector<int> L(N); REP(i, N) cin >> L[i];

  int ans = 1;
  int tmp = 0;
  REP(i, N) {
    tmp = tmp + L[i];
    if(tmp > X) break;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@numba.njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@numba.njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def first_strategy(D, C, S):
    return np.ones(D, np.int32)

def output(T):
    T += 1
    print(*T, sep='\n')

D,C,S = get_input()

T = first_strategy(D,C,S)
output(T)


Measured memory_bytes: 107416
N = int(input())
task = [list(map(int,input().split())) for _ in range(N)]
task = sorted(task, key = lambda x:x[1])

flag = 0
sums = 0
for i in range(N):
    sums += task[i][0]
    if(sums > task[i][1]):
        flag = 1
        
if flag:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 55264
import bisect

n = int(input())
a = sorted(list(map(lambda x: int(x),input().split())))
b = sorted(list(map(lambda x: int(x),input().split())))
c = sorted(list(map(lambda x: int(x),input().split())))

count = 0
for mid in b:
    upper_count = bisect.bisect_left(a,mid)
    lower_count = len(c) - bisect.bisect_right(c,mid)
    count += upper_count * lower_count
print(count)

Measured memory_bytes: 23092
#include<stdio.h>

int fib(int);

int Fib[44];

int main() {

  int i,a;

  scanf("%d",&a);
  for(i=0;i<44;i++) Fib[i]=0;

  printf("%d\n",fib(a));

  return 0;

}

int fib(int a) {

  if(a == 0 || a == 1) return Fib[a] = 1;
  if(Fib[a] != 0) return Fib[a];
  return Fib[a] = fib(a-1)+fib(a-2);

}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007ll 
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std;
#define pi (long double)3.14159265358979323846 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 struct sch{
  ll s,e,t;
};
bool sortinrev(const struct sch &a, const struct sch &b) 
{ 
    return (a.s < b.s); 
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll lcm(ll a,ll b)
{
  return a*b/gcd(a,b);
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; 
    x = x % p;  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}
bool check(ll a[],ll n,ll k,ll len)
{
    ll cnt = 0;
    for(ll i=0;i<n;i++)
    {
        ll x = (a[i]+len-1)/len-1;
        if(x>0)
            cnt += x;
    }
    if(cnt<=k)
        return true;
    return false;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    if(k==0)
    {
       cout<<*max_element(a,a+n)<<endl;
        return 0;
    }
    ll x = *max_element(a,a+n);
    ll l = 1,r = x,mid;
    while(1)
    {
          //cout<<l<<" "<<r<<endl;
        mid = (l+r)/2;
        if(check(a,n,k,mid))
        {
            if(mid == 1 || !check(a,n,k,mid-1))
                break;
            r = mid-1;
        }
        else
        {
            l = mid+1;
        }
      
    }
    cout<<mid<<endl;
}

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

 int binarysearch(int arr[],int l,int r,int x){
   while(l<=r)
   {
      int m=(l+r)/2;
       if(arr[m]==x)
        return m;
       else if(arr[m]>x)
        r=m-1;
       else if(arr[m]<x)
        l=m+1;

   }

   return -1;



 }
 int main()
 {
     int n;
     scanf("%d",&n);
     int a[n];
     for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
     int m,result,count=0;
     scanf("%d",&m);
     int b[m];
     for(int i=0;i<m;i++)
     {
         scanf("%d",&b[i]);
         result=binarysearch(a,0,n-1,b[i]);
         if(result!= -1)
            count++;
     }
     if(count==m)
        printf("1\n");
     else
        printf("0\n");
     return 0;
 }



Measured memory_bytes: 4724
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    vint a(M), b(M);
    unordered_map<int, int> cnt;
    rep(i, M) {
        cin >> a[i] >> b[i];
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    for (auto& c : cnt) {
        if (c.second % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4772
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;

	vector<int>H(N);
	IN(H);
	int ans = 0;
	while (true) {
		int L = N;
		for (int i = 0; i < N; ++i) {
			if (H[i]) {
				L = i;
				break;
			}
		}
		if (L == N) {
			cout << ans << endl;
			return;
		}
		++ans;
		for (int i = L; i < N; ++i) {
			if (H[i] == 0) {
				break;
			}
			H[i]--;
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  int d,e;
  
  while(cin >> d >> e){
    if(d == 0 and e == 0) break;

    double ans = abs(d-e);
    for(int x=0;x<=d;x++){
      int y = d-x;
      ans = min(ans, abs(sqrt(x*x + y*y) - e));
    }
    cout << fixed << setprecision(9) << ans << endl;
  }

}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

/*
    Sushi
*/

double dp[305][305][305];

int main() {
    int n;
    cin >> n;
    int goal = 0;
    int a[4] = {};
    rep(i,n){
        int a_; cin >> a_;
        a[a_]++;
        goal += a_;
    }
    rep(i,305){
        rep(j,305){
            rep(k,305){
                dp[i][j][k] = -1;
            }
        }
    }

    dp[0][0][0] = 0;

    rep(sum, goal){
        rep(k,n+1){
            rep(j,n+1){
                int i = sum - k * 3 - j * 2;
                int zero = n - (i+j+k);
                if(i<0)continue;
                if(n<i)continue;
                if(dp[i][j][k] == -1)continue;
                if(0 < zero){
                    if(dp[i+1][j][k] == -1)dp[i+1][j][k] = 0;
                    dp[i+1][j][k] += (double)(i + 1) / (n - (zero - 1)) * (dp[i][j][k] + (double)n / (n - (zero - 1)));
                }
                if(0 < i){
                    if(dp[i-1][j+1][k] == -1)dp[i-1][j+1][k] = 0;
                    dp[i-1][j+1][k] += (double)(j + 1) / (n - zero) * (dp[i][j][k] + (double)n / (n - zero));
                }
                if(0 < j){
                    if(dp[i][j-1][k+1] == -1)dp[i][j-1][k+1] = 0;
                    dp[i][j-1][k+1] += (double)(k + 1) / (n - zero) * (dp[i][j][k] + (double)n / (n - zero));
                }
            }
        }
    }

    cout << fixed << setprecision(10) << dp[a[1]][a[2]][a[3]] << endl;
    return 0;
}
 
 


Measured memory_bytes: 222080
#include<iostream>
using namespace std;
int main(){
  int n,age,data[7];
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<7;i++){
      data[i]=0;
    }
    for(int i=0;i<n;i++){
      cin>>age;
      if(age>=0&&age<=9)data[0]++;
      if(age>=10&&age<=19)data[1]++;
      if(age>=20&&age<=29)data[2]++;
      if(age>=30&&age<=39)data[3]++;
      if(age>=40&&age<=49)data[4]++;
      if(age>=50&&age<=59)data[5]++;
      if(age>=60)data[6]++;
    }
    for(int i=0;i<7;i++){
      cout<<data[i]<<endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct node{
	struct node *parent;
	struct node *right;
	struct node *left;
	long key;
}node;

typedef struct{
	struct node *root;
}tree;

node *createNode(long n){
	node *node;
	mymalloc(node,1);
	node->parent=NULL;
	node->right=NULL;
	node->left=NULL;
	node->key=n;
	return node;
}

void insert(tree *T, node *z){
	node *x,*y;
	y=NULL;
	x=T->root;
	while(x!=NULL){
		y=x;
		if(z->key<x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;
	if(y==NULL){
		T->root=z;
	}else{
	if(z->key<y->key){
		y->left=z;
	}else{
		y->right=z;
	}}
}

node *find(tree *T,long key){
	node *x;
	x=T->root;
	while(x!=NULL){
		if(key==x->key){
			return x;
		}
		if(key<x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	return NULL;
}

node *findNext(node *x){
	node *y;
	y=x->right;
	while(y->left!=NULL){
		y=y->left;
	}
	return y;
}

void delete(node *x){
	int dim;
	node *y;
	y=NULL;dim=0;
	if(x->left!=NULL){
		y=x->left;
		dim++;
	}
	if(x->right!=NULL){
		y=x->right;
		dim++;
	}
	if(dim==2){
		y=findNext(x);
		x->key=y->key;
		delete(y);
	}else{
		if(x->parent!=NULL){
			if(x==x->parent->left){
				x->parent->left=y;
			}else{
				x->parent->right=y;
			}
		}
		if(dim==1){
			y->parent=x->parent;
		}
		free(x);
	}
}
	
void preorder(node *root){
	printf(" %ld",root->key);
	if(root->left!=NULL){
		preorder(root->left);
	}
	if(root->right!=NULL){
		preorder(root->right);
	}
}

void inorder(node *root){
	if(root->left!=NULL){
		inorder(root->left);
	}
	printf(" %ld",root->key);
	if(root->right!=NULL){
		inorder(root->right);
	}
}


void freeNode(node *root){
	if(root->left!=NULL){
		freeNode(root->left);
	}
	if(root->right!=NULL){
		freeNode(root->right);
	}
	free(root);
}

void printTree(node *root){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
}

main(){
	long i,n,m;
	tree *T;
	node *obj;
	char s[10];
	mymalloc(T,1);
	T->root=NULL;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf(" %s",s);
		if(strcmp(s,"print")==0){
			printTree(T->root);
		}else{
			scanf(" %ld",&m);
			if(strcmp(s,"insert")==0){
				obj=createNode(m);
				insert(T,obj);
			}else{
			if(strcmp(s,"find")==0){
				if(find(T,m)!=NULL){puts("yes");}
				else{puts("no");}
			}else{
			if(strcmp(s,"delete")==0){
				delete(find(T,m));
			}}}}
	}
	freeNode(T->root);
	free(T);
	return 0;
}

Measured memory_bytes: 19364
function Main(s) {
  s = s.split(" ").map(a => +a);
  var ans = s[0] * s[3];
  ans += s[1] * s[4];
  if(s[0] + s[1] > s[2] * 2){
    var m = Math.min(s[3], s[4]);
    ans -= (s[0] + s[1] - s[2] * 2) * m;
    s[3] -= m;
    s[4] -= m;
  }
  if(s[3]>0 && s[0]>s[2]*2)ans -= (s[0] - s[2] * 2) * s[3];
  if(s[4]>0 && s[1]>s[2]*2)ans -= (s[1] - s[2] * 2) * s[4];
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
//bayemirov                                       
#include <bits/stdc++.h>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef long long ll;
 
#define pb push_back
 
const int MOD = 1e9 + 7;
const int N = 1e5;
 
int dp[N][100];
 
void add(int& x, int y) {
	x += y;
	if (x > MOD) x -= MOD;
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string a;
	cin >> a;
	int b;
	cin >> b;
	int k = a.size();
	dp[0][0] = 1;
	for (int i = 1; i < k; i++) 
		for (int j = 0; j < b; j++) 
			for(int x = 0; x < 10; ++x)
				add(dp[i][j], dp[i - 1][((j - x) % b + b) % b]);
	int ans = 0;
	int sum = 0;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < (a[i] - '0'); j++)
			add(ans, dp[k - i - 1][((b - sum - j) % b + b) % b]);
		sum += (a[i] - '0');
		sum %= b;
	}
	if(sum == 0)
		ans++;
	cout << ans - 1;
	return 0;
}                    
 

Measured memory_bytes: 7552
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AX solver = new AX();
        solver.solve(1, in, out);
        out.close();
    }

    static class AX {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int a = s.nextInt(), b = s.nextInt();
            w.println(Math.max(a + b, Math.max(a - b, a * b)));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,k;
  cin >> n >> k;
  cout << (n-1)*(k-1) << endl;
}


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

A = [int(i) for i in input().split() ]



for ai in A:
  if ai == 0 :
    print('0')
    exit()
	    
ans = A[0]      
for i in range(1,N):
  
  ans *= A[i]
  
  ansCp = ans
  ansCnt = 1
  while ansCp >= 10:
    ansCp /= 10
    ansCnt += 1
    
  if (ansCnt > 19) or ( ansCnt == 19 and ans%10 > 0 ) :
    print("-1")
    exit()
  
  
      
print(str(ans))

Measured memory_bytes: 21620
##B - 0 or 1 Swap
#1行目
hoge = gets.chomp.to_i

#2行目読み込み
x = gets.chomp.split(" ").map!{|i | i.to_i} 

y = x.min(hoge)

unchi = 0

for i in 0..(hoge-1) do
  if x[i] != y[i]
    unchi = unchi + 1
  end
end

if unchi == 0 or unchi == 2
  print "YES"
else
  print "NO"
end

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

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	map <string, int> mp;
	for(int i = 1; i <= n; i++) {
		string str; cin >> str;
		mp[str]++;
	}
	string s[] = {"AC", "WA", "TLE", "RE"};
	for(int i = 0; i < 4; i++) {
		cout << s[i] << " x " << mp[s[i]] << endl;
	}
}

Measured memory_bytes: 3664
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset> 
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
// RAJJI KI MEHER 
#define fio ios_base::sync_with_stdio(false)
//#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll int
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%lld",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 100000000000000005
#define MINN -10000000000000000
#define INTMAX 1000001000
#define pii pair<li,li>
#define pdd pair<double,double>
#define pic pair<int,char>
//#define N 5005
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
using namespace std;
int main(){li n,s,i,j,t;readl(n);li a[n+5]={0};li b[n+5][n+5];
for(i=1;i<=n;i++){readl(a[i]);a[i]=a[i-1]+a[i];}
li ans=100000000000000000;
for(s=1;s<=n;s++){
    for(i=1;i<=(n-s+1);i++){t=100000000000000000;
        if(s==2){b[i][s]=a[i+s-1]-a[i-1];}
        else if(s==1) b[i][s]=0;
        else{for(j=i+1;j<=(i+s-1);j++){t=min(t,b[i][j-1-i+1]+b[j][i+s-1-j+1]+a[i+s-1]-a[i-1]);}
b[i][s]=t;}
//cout<<b[i][s]<<" "<<i<<" "<<s<<endl;
}
}
ans=b[1][n];
cout<<ans;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

main(){
  int y[N],i ,x ;
  char s[N];
  
  while( scanf("%s", s) != EOF ){
    
    if ( s[0] == '+' ){
      y[i-2] = y[i-2] + y[i-1];
      i--;
    }
    
    else if ( s[0] == '-' ){
      y[i-2] = y[i-2] - y[i-1];
      i--;
    }
    
    else if ( s[0] == '*' ){
      y[i-2] = y[i-2] * y[i-1];
      i--;
    }
    
    else {
      x = atoi(s);
      y[i] = x;
      i++;
    } 
    
  }
  
  printf("%d\n",y[i-1]);
  return 0;
  
}

Measured memory_bytes: 548
N = int(input())
cord_list = [[0, 0, 0]]
flag = 0
for i in range(N):
    cord_list.append(list(map(int, input().split())))
    
for j in range(N):
    a = cord_list[j+1][0] - cord_list[j][0]
    b = abs(cord_list[j+1][1] - cord_list[j][1])
    c = abs(cord_list[j+1][2] - cord_list[j][2])
    if ((a - (b+c))%2 ==0) & ((b+c) <= a):
        pass
    else:
        print("No")
        flag += 1
        break
        
if flag == 0:
    print("Yes")

Measured memory_bytes: 27300
import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
(N,M) = map(int, input().split())
PY = []

for i in range(1,M+1):
    (P,Y) = map(int, input().split())
    PY += (i,P,Y),

sorter = lambda x: (x[1], x[2], x[0])
PY = sorted(PY, key=sorter)

result = {}

order = 1
last = 0
for (i, P, Y) in PY:
    if last != P:
        order = 1
        last = P
    result.update({i:('{:0>6}'.format(P) + '{:0>6}'.format(order))})
    order += 1

for i in range(1,M+1):
    print(result[i])


Measured memory_bytes: 58464
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

use std::f64::consts::PI;

fn main() {
    scan!(a, b, h, m; f64);

    let a_rad = 2_f64 * PI * ((h + m / 60_f64) / 12_f64);
    let b_rad = 2_f64 * PI * (m / 60_f64);

    let rad = if a_rad > b_rad {
        a_rad - b_rad
    } else {
        b_rad - a_rad
    };

    let res = ((a*a + b*b) - 2_f64 * a * b * rad.cos()).sqrt();
    println!("{}", res);
}


Measured memory_bytes: 3032
#include<stdio.h>
int main(){

  int x, y, r;
  int tmp;

  scanf("%d%d",&x,&y);

  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = x % y;
  
  while(r != 0){
    x=y;
    y=r;
    r=x%y;
  }

  printf("%d\n",y);



  return 0;
  
}

Measured memory_bytes: 592
#include <iostream>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

bool isPrime(int x) {
  if (x < 2) {
    return false;
  } else if (x == 2) {
    return true;
  } else if (x % 2 == 0) {
    return false;
  }

  int s = sqrt(x);
  for (int i = 3; i <= s; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int N;
  cin >> N;

  int count = 0;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (isPrime(x)) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    string s,t;
    cin >> s >> t;
    string msg = "No";
    auto n = s.size();
    for (int i=0; i < n; ++i){
        bool is = equal(s.begin()+i, s.end(), t.begin()) && equal(s.begin(), s.end()-(n-i), t.begin()+(n-i));
        if (is){
            msg = "Yes";
            break;
        }
    }
    
    cout  << msg << endl;
    return 0;
}

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

int main(){
    vector<int> a(3);
    long long ans = 1e18;
    for (int i = 0; i < 3; i++) cin >> a[i];
    for (int i = 0; i < 3; i++){
        for (int j = i + 1; j < 3; j++){
            int x = 3 - i - j;
            ans = min(ans, (a[x] % 2) * (long long)a[i] * a[j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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(void){

    int N;
    string S;
    cin >> N;
    cin >> S;

    REP(i,S.size()){
        char c = (S.at(i)-'A' + N)%26 + 'A';
        printf("%c", c);
        //cout << to_string(((S.at(i)-'A') + N)%26 + 'A');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
/**
 *
 * @author kke2
 */
public class Main {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int weight  =sc.nextInt();
    int time    =sc.nextInt();
    int i = weight-time;
    if(weight<time){
    i =0;
    }
    System.out.println(i);
    }
}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            int x = 1;
            while(x <= n)
            {
                if (x % 3 == 0 || x % 10 == 3 || x.ToString().Contains("3"))
                {
                    Console.Write(" {0}", x);
                }
                x++;
            }

            Console.WriteLine();

        }
    }
}

Measured memory_bytes: 20588
using System;

public class Hello
{
    public static void Main()
    {
        var a = new bool[10000000];
        generatePrime(a);
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            Console.WriteLine(getAns(a, n));
        }
    }
    public static void generatePrime(bool[] f)
    {
        var pL = f.Length;                                           // prime :  false
        f[0] = true; f[1] = true;
        for (int i = 2; i < pL; i++)
            if (!f[i])
                for (int j = i + i; j < pL; j += i) f[j] = true;
    }
    public static int getAns(bool[] a, int n)
    {
        for (int i = n - 8; i >= 2; i--)
            if (!a[i] && !a[i + 2] && !a[i + 6] && !a[i + 8]) return i + 8;
        return 0;
    }
}


Measured memory_bytes: 19096
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N, Q = map(int, input().split())
    edges = {}
    for i in range(N-1):
        a, b = map(int, input().split())
        edges[b] = a # 子: 親

    questions = {}
    for i in range(Q):
        p, x = map(int, input().split())
        if questions.get(p) is None: 
            questions[p] = x
        else:
            questions[p] += x

    qustions = sorted(questions.items(), key=lambda x:x[0])

    points = [0] * (N + 1)
    if questions.get(1) is None:
        points[1] = 0
    else:
        points[1] = questions[1]

    for i in range(2, N+1):
        if questions.get(i) is None:
            points[i] = points[edges[i]]
        else:
            points[i] = points[edges[i]] + questions[i]

    for i in range(1, N+1):
        print(points[i], end="")
        if i != N:
            print(end=" ")
    print("")



if __name__ == '__main__':
    main()

Measured memory_bytes: 88208
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
inline ll add(ll a,ll b){a+=b;if(a>=MOD)a-=MOD;return a;}
inline ll sub(ll a,ll b){a-=b;if(a<0)a+=MOD;return a;}
inline ll mul(ll a,ll b){return (a*1ll*b)%MOD;}
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     cin>>n;
     for(i=-1000;i<=1000;i++)
     {
       for(j=-1000;j<=1000;j++)
       {
         if(power(i,5)-power(j,5)==n)
          return cout<<i<<" "<<j,0;
       }
     }
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 3648
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 505
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int n, m;
	scanf("%d %d", &n, &m);
	printf("%d\n", (1900 * m + (100 * (n - m))) * (1 << m));
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    for(int i = n-1; i != 0; i--){
        if(v.at(i) < v.at(i - 1)){
            if(v.at(i) < v.at(i - 1) - 1){
                cout << "No" << endl;
                return 0;
            }
            else{
                v.at(i - 1)--;
            }
        }
    }
    cout << "Yes" << endl;
}
    


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

int H, W, K, r[1009][1009], rec[19];
char c[1009][1009];

int main() {
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cin >> c[i][j];
	}

	int ans = (1 << 30);
	for (int i = 0; i < (1 << (H - 1)); i++) {
		for (int j = 0; j < 10; j++) {
			rec[j] = 0;
			for (int k = 0; k < 1009; k++) r[j][k] = 0;
		}
		for (int j = 0; j < W; j++) {
			int cnt = 0;
			for (int k = 0; k < H; k++) {
				if (c[k][j] == '1') r[cnt][j]++;
				if ((i / (1 << k)) % 2 == 1) cnt++;
			}
		}
		bool flag = false; int wari = 0;
		for (int k = 0; k < W; k++) {
			for (int l = 0; l < H; l++) rec[l] += r[l][k];
			bool fl = false;
			for (int l = 0; l < H; l++) {
				if (rec[l] > K) fl = true;
			}
			if (fl == true) {
				wari++;
				for (int l = 0; l < H; l++) rec[l] = r[l][k];
				for (int l = 0; l < H; l++) { if (rec[l] > K) flag = true; }
			}
		}
		if (flag == true) continue;

		int retx = wari;
		int rety = 0; for (int j = 0; j < H - 1; j++) { if ((i / (1 << j)) % 2 == 1) rety++; }
		ans = min(ans, retx + rety);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256