akhauriyash/Code-Regression huggingface dataset:
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
string s;
int main()
{
	cin>>s;
	for (int i=0;i<s.size()-1;++i)
	{
		if (s[i]=='A' && s[i+1]=='C')
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

static const int MAX = 1e9;

int  main(){
  int N;
  cin>>N;
  vector<int> A(N);
  map<int,int> cnt;
  for(int i=0; i<N; i++) cin>>A[i];

  for(int i=0; i<N; i++) cnt[A[i]]++;

  int ans = 0;

  for(auto a: cnt){
    if(a.second >= a.first) ans += a.second-a.first;
    else ans += a.second;
  }

  cout<<ans<<endl;

  return  0;
  
}


Measured memory_bytes: 5120
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

template<class T>
vector<pair<T, ll>> runlength(vector<T>& v) {
    T& t = v[0];
    ll count = 1;
    vector<pair<T,ll>> res;
    reps(i, 1, v.size()) {
        if (v[i] != t) {
            res.emplace_back(t, count);
            t = v[i];
            count = 0;
        }
        ++count;
    }
    res.emplace_back(t, count);
    return res;
}

void solve()
{
    IN(n);
    VIN(ll, v, n);
    sort(all(v));
    auto p = runlength(v);
    V<bool> dp(1000005, true);
    rep(i, p.size()) {
        if (!dp[p[i].first]) continue;
        for (ll k = 2; k * p[i].first <= 1000000; ++k) {
            dp[k*p[i].first] = false;
        }
    }
    ll res = 0;
    rep(i, p.size()) {
        if (dp[p[i].first] && p[i].second == 1) ++res;
    }
    cout << res << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 8988
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    //商品数n
    static int n = sc.nextInt();
    //ナップサック容量w これを超えないようにする
    static int w = sc.nextInt();
    //重さの配列
    static long weight[] = new long[n];
    //価値の配列
    static long value[] = new long[n];
    //dpの配列
    static long dp[][] = new long[110][100100];

    public static void main(String[] args) {
        for (int i = 0; i < n; i++){
            weight[i] = sc.nextInt();
            value[i] = sc.nextInt();
        }
        for (int i = 0; i < 110; i++){
            for (int j = 0; j < 100100; j++){
                dp[i][j] = 0;
            }
        }
        for (int i = 0; i < n; i++){
            for (int sum_w = 0; sum_w <= w; sum_w++){
                if (sum_w - weight[i] >= 0)
                    dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][(int)(sum_w - weight[i])] + value[i]);
                dp[i + 1][sum_w] = chmax(dp[i + 1][sum_w], dp[i][sum_w]);
            }
        }
        System.out.println(dp[n][w]);

    }
    static long chmax(long a, long b){
        if (a > b){
            return a;
        } else {
            return b;
        }
    }
}


Measured memory_bytes: 127572
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,all,w[10000005],v[10000005];
long long dp[50010005],ans;
int main()
{
	memset(dp,-0x3f,sizeof(dp));dp[0]=0;
	scanf("%d%d",&n,&all);for(int i=1;i<=n;++i) scanf("%d%d",&w[i],&v[i]);
	for(int i=1;i<=n;++i) {
		for(int j=all;j!=-1;--j) dp[j+w[i]]=max(dp[j+w[i]],dp[j]+(long long)v[i]);
	}
	for(int i=0;i<=all;++i) ans=max(dp[i],ans);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 393344
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char c;
    scanf("%c",&c);
    if(c=='A')
        printf("T\n");
    else if(c=='T')
        printf("A\n");
    else if(c=='C')
        printf("G\n");
    else if(c=='G')
        printf("C\n");
    return 0;
}


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

namespace atcoder
{
    class Solver
    {
        //Solve
        public void Solve()
        {
            cin = new Scanner();
            string b = cin.next;

            if(b == "A") Console.Write("T");
            if(b == "T") Console.Write("A");
            if(b == "C") Console.Write("G");
            if(b == "G") Console.Write("C");

            return;
        }


        //Main
        public Solver() { }
        Scanner cin;
        public static int Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Solver().Solve();
            Console.Out.Flush();
            return 0;
        }

        //Util
        static bool IsOdd(long num) { return (num & 1) == 1; }
        static bool IsEven(long num) { return (num & 1) == 0; }
        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
    }

    class Scanner
    {
        string[] s; int i;
        readonly char[] cs = new char[] { ' ' };
        public Scanner() { s = new string[0]; i = 0; }
        public string[] scan => Console.ReadLine().Split();
        public int[] scanint => Array.ConvertAll(scan, int.Parse);
        public long[] scanlong => Array.ConvertAll(scan, long.Parse);
        public double[] scandouble => Array.ConvertAll(scan, double.Parse);
        public string next
        {
            get
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next;
            }
        }
        public int nextint => int.Parse(next);
        public long nextlong => long.Parse(next);
        public double nextdouble => double.Parse(next);
    }

    class Node<T>
    {
        private int m_height;
        private Node<T> m_parent;
        public T Item { get; private set; }
        public Node(T item)
        {
            m_height = 0;
            m_parent = this;
            Item = item;
        }
        public Node<T> Find()
        {
            if (m_parent == this) { return this; }

            Node<T> parent = m_parent.Find();
            m_parent = parent;
            return parent;
        }
        public static void Unite(Node<T> a, Node<T> b)
        {
            Node<T> p = a.Find();
            Node<T> q = b.Find();
            if (p.m_height < q.m_height)
            {
                p.m_parent = q;
                q.m_height = Math.Max(p.m_height + 1, q.m_height);
            }
            else
            {
                q.m_parent = p;
                p.m_height = Math.Max(q.m_height + 1, p.m_height);
            }
        }
    }
}

Measured memory_bytes: 9044
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,j,a[1000],b[1000],w;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(i=0;i<m-1;i++){
		for(j=i+1;j<m;j++){
			if(a[i]<a[j]){
				w=a[i];
				a[i]=a[j];
				a[j]=w;
				w=b[i];
				b[i]=b[j];
				b[j]=w;
			}
		}
	}
	w=0;
	for(i=0;i<m-1;i++){
		if(a[i]<n){
			w+=n-a[i];
		}
	}
	printf("%d\n",w);
	return 0;
}

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

using namespace std;

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


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

using namespace std;

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

int main() {

    int N, M, Q;
    cin >> N >> M >> Q;

    vector<vector<int>> B(N + 1, vector<int>(N + 1, 0));
    for (int i = 0; i < M; i++) {
        int L, R;
        cin >> L >> R;
        B[L][R]++;
    }

    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) B[i + 1][j + 1] += B[i][j + 1] + B[i + 1][j] - B[i][j];

    for (int i = 0; i < Q; i++) {
        int p, q;
        cin >> p >> q;
        int ans = B[q][q] - B[p - 1][q] - B[q][p - 1] + B[p - 1][p - 1];
        cout << ans << endl;
    }

    return 0;
}


























































































Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();
		char s = S.charAt(0);

		System.out.println(Character.isUpperCase(s)?"A":"a");

	}

}

Measured memory_bytes: 35652
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
// https://atcoder.jp/contests/abc167/tasks/abc167_b
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a,b,c,k;
    cin >> a >> b >> c >> k;

    if(k < a){
        cout << k;
    }
    else if(k >= a && k <= a+b){
        cout << a;
    }
    else{
        cout << a - (k-(a+b));
    }

	return 0;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
char str[N];
int main()
{
  
  int n;
  scanf("%s",str);
  n=strlen(str);
  for(int i=0;i<n;++i) if(str[i]==',') str[i]=' ';
  printf("%s",str);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){

  int n;

  scanf("%d",&n);

  double a[n],b[n];

  int i;

  for(i=0;i<=n-1;i++){

    scanf("%*c%lf",&a[i]);

  }

  for(i=0;i<=n-1;i++){

    scanf("%*c%lf",&b[i]);

  }

  double dist[4]={};

  double subdist[2]={};

  double use[n];

  for(i=0;i<=n-1;i++){

    use[i]=fabs(a[i]-b[i]);

    dist[0]+=use[i];//n=1

    subdist[0]+=pow((use[i]),2);//n=2

    subdist[1]+=pow((use[i]),3);//n=3

    if(dist[3]<=use[i])

      dist[3]=use[i];//n=inf.

  }

  dist[1]=sqrt(subdist[0]);

  dist[2]=cbrt(subdist[1]);

  for(i=0;i<=3;i++){

    printf("%f\n",dist[i]);

}

return 0;

}

Measured memory_bytes: 732
import math
N, D = map(int, input().split())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

answer = [math.sqrt(a ** 2 + b ** 2) for (a, b) in zip(x, y)]
count = 0
for j in answer:
    if j <= D:
        count += 1
    else:
        continue
print(count)


Measured memory_bytes: 32688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, n; cin >> h >> w >> n;
    int sr, sc; cin >> sr >> sc; sr--; sc--;
    string s, t; cin >> s >> t;
    
    int di[4] = {};
    const string dir = "ULDR";
    map<char, int> m; m['U'] = 0; m['L'] = 1; m['D'] = 2; m['R'] = 3;
    reprev (i, n) {
        di[(m[t[i]] + 2) % 4] = max(0, di[(m[t[i]] + 2) % 4] - 1);
        // if (abs(m[s[i]] - m[t[i]] == 2)) continue;
        di[m[s[i]]]++;
        if (di[0] >= h - di[2] || di[1] >= w - di[3]) {
            cout << "NO\n";
            return 0;
        }
    }
    int u = di[0], l = di[1], d = h - di[2], r = w - di[3];
    if (u <= sr && sr < d && l <= sc && sc < r) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;
	int ans;
	vector<int> p(n);
	for (int i = 1; i < n; ++i)
	{
		if(s.at(i)=='E'){
			p.at(0)++;
		}
	}
  ans = p.at(0);
	for (int i = 0; i < n-1; ++i)
	{
		if(s.at(i)=='E'){
			if(s.at(i+1)=='E'){
				p.at(i+1)=p.at(i)-1;
			}
			else{
				p.at(i+1)=p.at(i);
			}
		}
		else{
			if(s.at(i+1)=='W'){
				p.at(i+1)=p.at(i)+1;
			}
			else{
				p.at(i+1)=p.at(i);
			}
		}
		ans = min(ans,p.at(i+1));
	}

cout << ans << endl;
	}

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

int main() {
  string sss;
  cin >> sss;
  if((sss.at(5) - '0') * 10 + (sss.at(6) - '0') < 5) {
    cout << "Heisei" << endl;
  }
  else {
    cout << "TBD" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    /*標準入力long*/
    static long inputLong() throws Exception {
        return Long.parseLong(br.readLine());
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        long n = inputLong();
        long ans = Integer.MAX_VALUE;
        for(long i=1; i<=Math.sqrt(n); i++){
            if(n % i == 0){
                ans = Math.min(ans,Math.max(i,n/i));
            }
        }

        System.out.println(String.valueOf(ans).length());


    }

}



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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;


void solve()
{
	ld w, h, x, y;
	cin >> w >> h >> x >> y;

	int mul = 0;
	if (x == w / 2 && y == h / 2)
		mul = 1;
	ld ans= (ld)(w * h) / 2;
	cout << ans << " " << mul;
}

int main()
{

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

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

	int t = 1;
	// cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}




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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

int v[510][510];
int x[510][510];
int main() {
	int n, m, q;
	cin >> n >> m >> q;
	
	REP(i, m) {
		int l, r;
		cin >> l >> r;
		v[l][r] ++;
	}
	REP(i, 505) REP(j, 505) x[i + 1][j + 1] = x[i + 1][j] + v[i][j];
	REP(j, 505) REP(i, 505) x[i + 1][j + 1] = x[i + 1][j + 1] + x[i][j + 1];
	

	REP(i, q) {
		int a, b;
		cin >> a >> b;
		cout << x[501][b + 1] - x[a][b + 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m, r;
  cin >> n >> m;
  vector<int> c(n);
  
  for (int i = 0; i < m * 2; i++) {
    cin >> r;
    c.at(r - 1)++;
  }
  
  for (int j = 0; j < n; j++)
    cout << c.at(j) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		System.out.println(solve(sc.next()) ? "VALID" : "INVALID");
	}

	static boolean solve(String s) {
		if (s.length() < 6) return false;
		int r = 0;
		for (char c : s.toCharArray()) {
			if (Character.isDigit(c)) r |= 1;
			if (Character.isUpperCase(c)) r |= 2;
			if (Character.isLowerCase(c)) r |= 4;
		}
		return r == 7;
	}

}

Measured memory_bytes: 17296
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K;cin>>N>>K;
  vector<long>P(N);
  for(long i=0;i<N;i++)cin>>P[i];

  long s=0;
  for(long i=0;i<K;i++)s+=P[i];
  long M=s;
  for(long i=K;i<N;i++){
    s+=P[i];
    s-=P[i-K];
    M=max(M,s);
  }
  cout<<fixed<<setprecision(10)<<(M+K)/2.0<<endl;
}





/**/

Measured memory_bytes: 1792
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long x; cin >> x;

    if(x == 0) cout << 1;
    else cout << "0";

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			String s = sc.next();
			
			
			boolean isRain = false;
			int duration = 0;
			for(int i = 0 ; i < s.length() ; i++ ) {
				
				if ( s.charAt(i) == 'R') {
					if ( isRain) {
						duration++;
					}
					else {
						duration = 1;
					}
					isRain = true;
				}
				else {
					isRain = false;
				}
								
			}
			
			System.out.println(duration);
		}
	}

}

Measured memory_bytes: 35720
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
LL N,ans;
LL A[310][310];
LL B[310][310];
bool D[310][310];
int main(){
    std::cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            std::cin>>A[i][j];
            B[i][j]=A[i][j];
        }
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==j||i==k||j==k)continue;
                if(B[i][k]+B[k][j]==A[i][j]){
                    D[i][j]=true;
                    D[j][i]=true;
                }
                B[i][j]=std::min(B[i][j],B[i][k]+B[k][j]);
                if(B[i][j]<A[i][j]){
                    std::cout<<-1<<std::endl;
                    return 0;
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            if(!D[i][j])ans+=A[i][j];
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

signed main() {
  ll N;
  cin >> N;
  vll B(N);
  rep(i, N) {
    cin >> B[i];
  }

  ll sum = 0;
  rep(i, N) {
    if (i == 0) {
      sum += B[0];
      continue;
    }
    if (i == N - 1) {
      sum += B[N - 2];
      continue;
    }
    sum += min(B[i - 1], B[i]);
  }
  COUT(sum);

  return 0;
}

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

const int INF = 1<<29;

const int MAX_N = 100;

int N; 
vector<int> G[100];
bool visited[100];

int dfs(int pos, int dist){
    int ret = dist;
    visited[pos] = true;
    for(auto &e : G[pos]){
        if(visited[e]) continue;
        ret = max(ret, dfs(e, dist+1));
    }
    visited[pos] = false;
    return ret;
}


int main(){
    while(scanf("%d", &N), N){
        for(int x = 0; x < 100; x++){
            G[x].clear();
        }
        for(int x = 0; x < N; x++){
            int a, b;
            scanf("%d%d", &a, &b);
            --a; --b;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        int dist = 0;
        fill(visited, visited+N, false);
        for(int x = 0; x < 100; x++){
            dist = max(dist, dfs(x, 1));
        }
        printf("%d\n", dist);
    }
    return 0;
}

Measured memory_bytes: 1040
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n,m = map(int,input().split())
	ab = defaultdict(int)
	for i in range(n):
		tmp =  list(map(int,input().split()))
		ab[tmp[0]]  += tmp[1]
	ab = list(reversed(sorted(ab.items(), key=lambda x:x[0])))
	ans = 0
	while m > 0:
		t = ab.pop()
		ans += t[0] * min(t[1],m)
		m-=t[1]
	print(ans)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 90644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

double dist(pint a, pint b){
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<pint> t;
    for(int i=0; i<n; i++){
        int x,y; cin>>x>>y;
        t.emplace_back(pint(x,y));
    }
    vector<int> vv;
    for(int i=1; i<=n; i++) vv.emplace_back(i);
    double ans=0;
    int count=0;
    do{
        for(int i=0; i<n-1; i++){
            int first=vv[i]-1;
            int second=vv[i+1]-1;
            ans+=dist(t[first],t[second]);
        }
        count++;
    }
    while(next_permutation(vv.begin(),vv.end()));
    cout<<fixed<<setprecision(50)<<ans/(double)count<<endl;
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    int n, m;
    while(cin>>n>>m) {
        if (n<m) {
            cout << n << " " << m << endl;
        } else if ( n == 0 && m == 0){
            break;
        } else {
            cout << m << " " << n << endl;
        }
    }
}


Measured memory_bytes: 3004
#include <iostream>
using namespace std;
int main()
{
	int n ,y;
	cin >> n >> y;
	for (int a = 0; a <= n; a++)
	{
		for (int b = 0; b <= n; b++)
		{
			int c = y - ((a * 10000) + (b * 5000));
			if (c < 0) {
				continue;
			}
			c /= 1000;
			if ((a + b + c) == n && (a*10000 + b*5000 + c*1000) == y)
			{
				cout << a << " " << b << " " << c << endl;
				return 0;
			}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n, 0);
  REP(i, q)
  {
    int p;
    cin >> p;
    a[p - 1] = a[p - 1] + 1;
  }
  REP(i, n)
  {
    if (k - (q - a[i]) > 0)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

vector<int> abc(3, 0);
int k;

int main(void){
    
    scanf("%d %d %d %d", &abc[0], &abc[1], &abc[2], &k);
    for(int i = 0; i < k; ++i){
        auto itr = max_element(abc.begin(), abc.end());
        *itr *= 2;
    }
    int sum = 0;
    for(int i = 0; i < 3; ++i) sum += abc[i];
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int digit_sum(int x);

int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    
    int ans = 0;
    for(int i = 1; i < n + 1; i++){
        if(digit_sum(i) >= a && digit_sum(i) <= b) ans += i;
    }
    printf("%d\n", ans);
    return 0;
}

int digit_sum(int x){
    int sum = 0;
    while(x > 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,c=0,m=0;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(N-1)-a.at(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

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

int N, K;

int Sum[200010];
map<int,int> counter;

int f(int a)
{
	a += K * (int)1e9;
	return a % K;
}

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}

	counter[Sum[0] - 0]++;

	rep1(i, N) {
		if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
		ans += counter[f(Sum[i] - i)];
		counter[f(Sum[i] - i)]++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 14336
#include <iostream>

using namespace std;

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

	long long ans = 0;
	if (N % 2 == 0) {
		N /= 2;
		while (N != 0) {
			ans += N / 5;
			N /= 5;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
    int N=0,i=0,C0 = 0,C1 = 0,C2 = 0,C3 = 0;
    char S[4];
    scanf("%d",&N);
    
    for(i;i < N;i++){
        scanf("%s",S);
        if(S[0] =='A'){C0+=1;}
        if(S[0] =='W'){C1+=1;}
        if(S[0] =='T'){C2+=1;}
        if(S[0] =='R'){C3+=1;}


    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",C0,C1,C2,C3);
    return 0;



}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n;
vector<int> a, b, c;

void getVector (vector<int> &vec) {
    vec.resize(n);
    REP (i, n) {
        int d;
        cin >> d;
        vec[i] = d;
    }
    sort(vec.begin(), vec.end());
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> n;

    getVector(a);
    getVector(b);
    getVector(c);

    ll ans = 0;
    for (auto v : b) {
        ll szu = lower_bound(a.begin(), a.end(), v) - a.begin();
        ll szd = c.end() - upper_bound(c.begin(), c.end(), v);

        ans += szu * szd;
    }

    cout << ans << endl;

}


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

typedef long long LL;
LL n, k, t, ans;

int main() {
	scanf("%lld%lld", &n, &k);
	t=n/k;
	ans+=t*t*t;
	if(k%2==0) {
		t=(n+k/2)/k;
		ans+=t*t*t;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def fib_memo(n):
    memo = [0] * (n+1)
    def fib(n):
        if n <= 1:
            return 1
        if memo[n] != 0:
            return memo[n]
        memo[n] = fib(n-1) + fib(n-2)
        return memo[n]
    return fib(n)
print(fib_memo(ni()))




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

int main()
{
	char n[5] = {'A','B','C','D','E'};
	int a[5],b[5];
	int name,max;
	while(cin >> a[0] >> b[0]){
		if(a[0] == 0 && b[0] == 0)
			break;
		max = a[0]+b[0];
		name = 0;
		for(int i=1;i<5;i++){
			cin >> a[i] >> b[i];
			if(max < a[i]+b[i]){
				max = a[i]+b[i];
				name = i;
			}
		}
		cout << n[name] << " " << max << endl;
	}
	return 0;
}

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

using namespace std;

long long dp[200005][3];

int sto(char c) {
	if (c == 'r') return 2;
	if (c == 's') return 0;
	return 1;
}

int main() {
	int n, k; cin >> n >> k;
	int rsp[3]; cin >> rsp[0] >> rsp[1] >> rsp[2];
	string t; cin >> t;
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i < k) ans += rsp[sto(t[i])];
		else if (t[i - k] == t[i]) t[i] = '-';
		else ans += rsp[sto(t[i])];
	}
	cout << ans << endl;

	return 0;
}

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

const int MOD = 1e9 + 7;
const int MAX = 2e5 + 10;

long long fac[MAX], finv[MAX], inv[MAX];

void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int n, k; cin >> n >> k;
    COMBinit();
    ll ans = 1;
    for (int i = 1; i <= min(n, k); i++) {
        ans += COMB(n, i) * COMB(n-1, i);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> imos;
    imos.push_back(0LL);
    rep(i,n){
        ll x;
        cin >> x;
        imos.push_back((imos[i]+x)%k);
    }
    rep(i,n+1){
        imos[i] = (i-imos[i]+k)%k;
    }
    map<ll,ll> m;
    ll lim = 0;
    ll ans = 0;
    for(ll i = 0;i<=n;i++){
        while(lim<i+k&&lim<=n){
            m[imos[lim]]++;
            lim++;
        }
        ll t = m[imos[i]];
        ans+=(t-1);
        m[imos[i]]--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14320
import java.io.*;

public class Main {
    private static int MAX = 10000001;
    private static int divisor[] = new int[MAX];
    static void precompute()
    {
        for (int pos = 2; pos*pos < MAX; pos++) {
            for (int i = pos*pos; i < MAX; i+=pos) {
                    divisor[i]++;
                    if(i/pos != pos)
                        divisor[i]++;
                }
            }

    }
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(buffer.readLine());
        long sum = 1;
        precompute();
        for (int num = 2; num < n + 1; num++) {
            sum += (long)num*(divisor[num]+2);
//            System.out.println(num+" "+(divisor[num]+2));
        }
        sb.append(sum);
        System.out.println(sb);
    }
}


Measured memory_bytes: 71752
from collections import deque


INFINITY = 10 ** 10
WHITE = 0
GRAY = 1
BLACK = 2


def breadth_first_search(u_start = 0):
    color[u_start] = GRAY
    d[u_start] = 0
    que.append(u_start)

    while que:
        u = que.popleft()
        for v in range(n):
            if matrix[u][v] and color[v] == WHITE:
                color[v] = GRAY
                d[v] = d[u] + 1
                que.append(v)
        color[u] = BLACK


# INPUT
n = int(input())


matrix = [[0] * n for _ in range(n)]

for i in range(n):

    u, k, *V = map(int, input().split())

    for v in V:
        v -= 1
        matrix[i][v] = 1


color = [WHITE] * n
d = [INFINITY] * n
que = deque([])

# PROCESS
breadth_first_search()


# OUTPUT
for i in range(n):
    if d[i] == INFINITY:
        distance = -1
    else:
        distance = d[i]

    print(i + 1, distance)



Measured memory_bytes: 6100
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static List <Integer>[] Edge ;
	static long[] sum;
	static boolean[] visit;
	static Deque <Integer>que;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());

		Edge = new ArrayList [n];
		for(int i = 0 ; i < n ;i++) {
			Edge[i] = new ArrayList <Integer>();
		}
		
		for(int i = 0 ; i < n-1 ;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			Edge[a].add(b);
			Edge[b].add(a);
		}
		
		sum = new long [n];
		visit = new boolean [n];
		
		for(int i = 0 ; i < q ; i++){
			int p = Integer.parseInt(sc.next());
			long x = Long.parseLong(sc.next());
			sum[p-1] += x;
		}
		que = new ArrayDeque <Integer>();
		visit[0] = true;
		BFS(0);
		
		
		for(int i = 0 ; i < n ;i++) {
			System.out.println(sum[i]);
		}
		
	}
	
	static void BFS(int now) {
		
		if(Edge[now].isEmpty()) {
			return;
		}
		
		for(int i : Edge[now]) {
			if(visit[i]) {
				continue;
			}
			que.addLast(i);
			sum[i] += sum[now];

		}
		if(que.size() == 0) {
			return;
		}
		//System.out.println(now);
		visit[now] = true;
		BFS(que.pollFirst());
		
		
	}
	

}


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

int main() {
    int N, L;
    string a[110]; 
    cin >> N >> L;
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a, a + N);
    string W = ""; 
    for (int i = 0; i < N; ++i)
      W = W + a[i]; 
    cout << W << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

void solve(){
	int r; cin>>r;
  cout<<3*r*r<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S,T;
    cin >> S >> T;
    int ans=0;
    rep(i,3){
        if(S[i]==T[i]) ans++;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
#define MAXN 2005
#define INF 1000000007
 
 
int main()
{ 
	FIN;
	
	#ifdef input
		//freopen("test1.txt", "r", stdin);
	#endif
	
	vector <int> v(5);
	forn(i,5) cin >> v[i];
	int ans = -1;
	forn(i,5) if(v[i]==0) ans=i+1;
	cout << ans << endl;
	
	
	
	return 0;
}

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

#define ull unsigned long long int
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define itr vll::iterator
#define all(c) c.begin(),c.end()
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define inf 1000000000000000001

#define rep(i, n)      for(ll i = 0; i <  n; ++i)
#define repA(i, a, n)  for(ll i = a; i <= n; ++i)
#define repD(i, a, n)  for(ll i = a; i >= n; --i)

using namespace std;

bool func(const pll &a, const pll &b){
    return a.s < b.s;
}

ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}

void solve(){
    ll a, b, c; cin >> a >> b >> c;
    ll k; cin >> k;
    if(k > a){
        if(k-a > b){
            cout << a-(k-a-b);
        }else cout << a;
    }else cout << k;
}
    

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

    int t = 1, tmp = 0;
    // cin >> t;
    while(t--){
        // cout << "Case #" << ++tmp << ": ";
        solve();
        if(t) cout << "\n";
    }
    cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3804
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h> 
using namespace std; 

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int a;
    cin>>a;
    string s1, s2;
    cin>>s1>>s2;
    for(int i=0; i<s1.length(); i++)
    {
    	cout<<s1[i]<<s2[i];
	}
	cout<<endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  int route[m*2 + 1][2];
  int route_first[n];
  int sign[n];
  int depth_node[n];
  for(int i = 0; i < n; i++){
    sign[i] = -1;
    depth_node[i] = -1;
    route_first[i] = 0;
  }
  sign[0] = 0;

  int a, b;
  for(int i = 1; i <= m; i++){
    scanf("%d %d", &a, &b);
    a--;
    b--;
    route[i][0] = b;
    route[i][1] = route_first[a];
    route_first[a] = i;
    route[i + m][0] = a;
    route[i + m][1] = route_first[b];
    route_first[b] = i + m;
  }

  int queue_init = 0;
  int queue_last = 0;
  int c_node = 0;
  depth_node[queue_init] = 0;
  int t;
  while(queue_init <= queue_last){
    c_node = depth_node[queue_init];
    t = route_first[c_node];
    while(t != 0){
      if(sign[route[t][0]] == -1){
        queue_last++;
        depth_node[queue_last] = route[t][0];
        sign[route[t][0]] = c_node;
      }
      t = route[t][1];
    }
    queue_init++;
    //printf("%d, %d\n", queue_init, queue_last);
  }
  for(int i = 1; i < n; i++){
    if(sign[i] == -1){
      printf("no\n");
      return 0;
    }
  }

  printf("Yes\n");
  for(int i = 1; i < n; i++){
    printf("%d\n", sign[i] + 1);
  }
  return 0;
}


Measured memory_bytes: 5988