akhauriyash/Code-Regression huggingface dataset:
def a():
    s = input()
    total = 700
    for i in s:
        total += 100 if i == 'o' else 0
    print(total)


def b():
    n, x = map(int, input().split())
    m = [int(input()) for _ in range(n)]
    print(len(m) + ((x - sum(m)) // min(m)))


def c():
    a, b, c, x, y = map(int, input().split())
    total = 0
    while x > 0 or y > 0:
        # compare a, b, c
        xi = min(x, 1)  # 0, 1
        yi = min(y, 1)  # 0, 1
        x -= xi
        y -= yi
        total += min(xi*a+yi*b, 2*c)
        # if xi*a+yi*b < 2*c:
        #     print(f'A pizza * {xi}, B pizza * {yi}')
        # else:
        #     print('AB pizza * 2')
    print(total)


c()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct SegmentTree{
    using F=function<T(T,T)>;
    F f;
    T init;
    int sz;
    vector<T> seg;
    SegmentTree(int n,T init,F f):init(init),f(f){
        sz=1;
        while(sz<n) sz<<=1;
        seg.resize(sz<<1,init);
    }
    // 代入
    void set(int id,T x){
        seg[id+sz]=x;
    }
    // 構築
    void build(){
        for(int k=sz-1;k>0;k--){
            seg[k]=f(seg[2*k],seg[2*k+1]);
        }
    }
    // 更新
    void update(int id,T x){
        id+=sz;
        seg[id]=x;
        while(id>>=1){
            seg[id]=f(seg[2*id],seg[2*id+1]);
        }
    }
    // [l,r)の結果を取得
    T get(int l,int r){
        T L=init,R=init;
        l+=sz,r+=sz;
        for(;l<r;l>>=1,r>>=1){
            if(l&1) L=f(L,seg[l++]);
            if(r&1) R=f(seg[--r],R);
        }
        return f(L,R);
    }
    // debug
    void debug(){
        int i=1;
        for(int r=1;r<2*sz;r<<=1){
            while(i<r){
                cout<<seg[i]<<" ";
            }
        }
        cout<<"\n";
    }
};
// verify
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
int main(){
    int n,q; cin>>n>>q;
    SegmentTree<int> seg(n,(1ll<<31)-1,[](int a,int b){return min(a,b);});
    while(q--){
        int com,x,y; cin>>com>>x>>y;
        if(com==0) seg.update(x,y);
        else cout<<seg.get(x,y+1)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3860
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    unordered_map<ll, ll> Ais;
    unordered_map<ll, ll> Bis;
    for (ll i = 0; i < M; i++) {
        ll Ai, Bi;
        cin >> Ai >> Bi;
        Ai--;
        Bi--;
        if (Ai > Bi) {
            swap(Ai, Bi);
        }
        Ais[Ai]++;
        Bis[Bi]++;
    }
    ll parity = 0;
    for (ll i = 0; i < N-1; i++) {
        parity += Ais[i] + Bis[i];
        if (parity % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 11200
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	SENTINEL = 2000000000
)

func main() {
	fmt.Println(answer(os.Stdin))
}

func answer(r io.Reader) int {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	A := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	return mergeSort(A, n, 0, n)
}

func merge(A []int, n, left, mid, right int) int {
	n1 := mid - left
	n2 := right - mid
	L, R := make([]int, n1+1), make([]int, n2+1)
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L[n1], R[n2] = SENTINEL, SENTINEL

	cnt := 0
	i, j := 0, 0
	for k := left; k < right; k++ {
		if L[i] <= R[j] {
			A[k] = L[i]
			i++
			continue
		}
		A[k] = R[j]
		j++
		cnt += n1 - i
	}
	return cnt
}

func mergeSort(A []int, n, left, right int) int {
	if left+1 < right {
		mid := (left + right) / 2
		v1 := mergeSort(A, n, left, mid)
		v2 := mergeSort(A, n, mid, right)
		v3 := merge(A, n, left, mid, right)
		return v1 + v2 + v3
	}
	return 0
}



Measured memory_bytes: 7800
#include<stdio.h>
int main()
{
  int a,b,c,d,n;
  scanf("%d",&a);
  b=a/100;
  c=(a-b*100)/10;
  d=a%10;
  if(b==9){
    b=1;
  }else if(b==1){
    b=9;
  }
  if(c==9){
    c=1;
  }else if(c==1){
    c=9;
  }
  if(d==9){
    d=1;
  }else if(d==1){
    d=9;
  }
  n=b*100+c*10+d;
  printf("%d",n);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

using P = pair<int, int>;
const int INF = 1e9;
const int NX[4] = {-1, 1, 0, 0};
const int NY[4] = {0, 0, -1, 1};

const int MAX_NM = 100;

int N, M;
map<string, int> s;

inline void input() {
	string x;
  decltype(s)::iterator its;

	cin >> N;
  rep(i, N) {
    cin >> x;
    its = s.find(x);
    if (its != s.end()) {
      its->second++;
    } else {
      s.insert(make_pair(x, 1));
    }
  }

  cin >> M;
  rep(i, M) {
    cin >> x;
    its = s.find(x);
    if (its != s.end()) {
      its->second--;
    } else {
      s.insert(make_pair(x, -1));
    }
  }
}


inline int solve() {
  input();

  int result = 0;

  for (auto p : s) {
    result = max(result, p.second);
  }

  return result;
}

inline void Main() {
  // code
  cout << solve() << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	lli n;
	cin >> n;
	cout << (n-1)*n/2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;
 
const int MOD = 998244353; // change if needed
 
struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}
 
  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }
 
  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }
 
  Modint operator- () const {
    return Modint(MOD - val);
  }
 
  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }
 
  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }
 
  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }
 
  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }
 
  bool operator== (Modint other) const {
    return val == other.val;
  }
 
  bool operator!= (Modint other) const {
    return val != other.val;
  }
};
 
Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}
 
Modint inv (Modint a) {
  return exp(a, MOD - 2);
}
 
ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 3e3 + 5;

Modint dp [MAX_N][MAX_N];
Modint cdp [MAX_N][MAX_N];

int arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n, S;
  cin >> n >> S;

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }

  Modint ans (0);
  for (int i = 1; i <= n; i++) {
    dp[i][arr[i]] = Modint(i);
    for (int j = arr[i] + 1; j < MAX_N; j++) {
      dp[i][j] = cdp[i - 1][j - arr[i]];
    }

    for (int j = 0; j < MAX_N; j++) {
      cdp[i][j] = cdp[i - 1][j] + dp[i][j];
    }

    ans += dp[i][S] * Modint(n - i + 1);
  }
  cout << ans << endl;
}


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

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


Measured memory_bytes: 3632
import java.util.*;
class Main {
     
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        Dice dice = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        String a = stdIn.next();
        for(int i = 0; i < a.length(); i++) {
            if(a.charAt(i) == 'N') {
                dice.TurnN();
            }
            else if(a.charAt(i) == 'W') {
                dice.TurnW();
            }
            else if(a.charAt(i) == 'E') {
                dice.TurnE();
            }
            else {
                dice.TurnS();
            }
        }
        System.out.println(dice.Top);
    }
     
     
}

class Dice {
    int Top; 
    int Bottom; 
    int N; 
    int S; 
    int W;
    int E; 
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
    public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
     
}


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

using namespace std;

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

#define F first
#define S second

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y; cin >> x >> y;
	if (x % y == 0)
		cout << "-1\n";
	else
		cout << x << "\n";
	return 0;
}


Measured memory_bytes: 256
#

import sys
from collections import deque
input=sys.stdin.readline

def main():
    H,W=map(int,input().split())
    masu=[input().strip("\n") for i in range(H)]
    
    di=[(-1,0), (1,0), (0,-1), (0,1)]
    dist=[[-1]*W for i in range(H)]
    ans=0
    
    for i in range(H):
        for j in range(W):
            if masu[i][j]=="#" and dist[i][j]==-1:
                bcnt=0
                wcnt=0
                qu=deque([(i,j)])
                dist[i][j]=0
                while(len(qu)>0):
                    v=qu.popleft()
                    if masu[v[0]][v[1]]=="#":
                        nex="."
                        bcnt+=1
                    else:
                        nex="#"
                        wcnt+=1
                    for d in di:
                        nv=(v[0]+d[0],v[1]+d[1])
                        if 0<=nv[0]<H and 0<=nv[1]<W and dist[nv[0]][nv[1]]==-1 and masu[nv[0]][nv[1]] == nex:
                            dist[nv[0]][nv[1]]=dist[v[0]][v[1]]+1
                            qu.append(nv)
                ans+=bcnt*wcnt
    print(ans)
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 14788
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int ctoi(char c){
  if(c>='0'&&c<='9'){
    return c-'0';
  }
  return 0;
}
int xoror(int a,int b){
  return 0;
}


//cout << setprecision(123)<<ans;
//int a=atoi(S.c_str());
//string S=to_string(a);
//int &a=b;
int main(){
  int N,M,ansans=0;
  cin>>N>>M;
  vector<int>P(M);
  vector<string>S(M);
  vector<pair<int,int>>A(N,pair<int,int>(0,0));
  
  REP(i,M){
    cin>>P[i]>>S[i];
    if(A[P[i]-1].second==0){
      A[P[i]-1].first++;
      if(S[i]=="AC"){
        A[P[i]-1].second++;
        A[P[i]-1].first--;
        ansans++;
      }
    }
  }
  
  int ans=0;
  REP(i,N){
    if(A[i].second>0){
      ans+=A[i].first;
    }
  }
  
  cout<<ansans<<' '<<ans<<endl;
  
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	char c;
	cin >> c;
	c += 1;
	put(c);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> v;
    std::vector<int> p;
    for (int i = 0; i < n; i++) {
        int x, y;
        std::cin >> x >> y;
        v.emplace_back(x, y);
        p.push_back(i);
    }

    double sum = 0;
    do {
        for (int i = 1; i < n; i++) sum += std::hypot(v[p[i]].first - v[p[i - 1]].first, v[p[i]].second - v[p[i - 1]].second);
    } while (std::next_permutation(p.begin(), p.end()));

    for (int i = 1; i <= n; i++) sum /= i;
    std::cout << std::fixed << std::setprecision(10) << sum << std::endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
count=0
def check(now,v,n):
    global count
    v[now]=1
    if sum(v)==n:
        count+=1
    else:
        for i in range(8):
            if v[i]==0 and g[now][i]==1:
                check(i,v[:],n)

n,m=map(int,input().split())
g=[[0 for i in range(8)]for i in range(8)]
for i in range(m):
    a,b=map(int,input().split())
    g[a-1][b-1]=1
    g[b-1][a-1]=1
check(0,[0,0,0,0,0,0,0,0][:],n)
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<string>
int main(){
	int Number;
	std::cin>>Number;
	std::map<std::string,int> answer;
	std::string tmp;
	for(int i=0;i<Number;i++){
		std::cin>>tmp;
		answer[tmp]++;
	}
	std::cout<<"AC x "<<answer["AC"]<<std::endl;
	std::cout<<"WA x "<<answer["WA"]<<std::endl;
	std::cout<<"TLE x "<<answer["TLE"]<<std::endl;
	std::cout<<"RE x "<<answer["RE"]<<std::endl;
	return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  for (int num = 0; num <= 999; ++num) {
    string num_s = to_string(num);
    if (num_s.size() != n) continue;
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      if (num_s[s[i]] - '0' != c[i]) {
        ok = false;
      }
    }
    if (ok) {
      cout << num_s << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] k = new int[M];
        int[][] s = new int[M][];
        for (int i = 0; i < k.length; i++) {
            k[i] = sc.nextInt();
            s[i] = new int[k[i]];
            for (int j = 0; j < s[i].length; j++) {
                s[i][j] = sc.nextInt();
            }
        }
        int[] p = new int[M];
        for (int i = 0; i < p.length; i++) {
            p[i] = sc.nextInt();
        }
        
        int res = 0;
        for (int bit = 0; bit < (1 << N); bit++) {
            boolean ok = true;
            for (int i = 0; i < k.length; i++) {
                int on_counter = 0;
                for (int j = 0; j < s[i].length; j++) {
                    if ((bit & (1 << (N - s[i][j]))) != 0) {
                        on_counter++;
                    }
                }
                if (on_counter % 2 != p[i]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                res++;
            }
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <stdio.h>

void shuffle(int a,int b,int c,int d,int dice[6])
{
    int box;
    box = dice[a];
    dice[a] = dice[b];
    dice[b] = dice[c];
    dice[c] = dice[d];
    dice[d] = box;
}

int main()
{
    int dice[6];
    char when[100]={};
    for(int i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    scanf("%s",when);
    int i = 0,flg = -1,box;
    while(1)
    {
        switch(when[i]){
            case 'W':
                shuffle(5,3,0,2,dice);
                break;
            case 'E':
                shuffle(5,2,0,3,dice);
                break;
            case 'S':
                shuffle(5,1,0,4,dice);
                break;
            case 'N':
                shuffle(4,0,1,5,dice);
                break;
            default:
                flg = 1;
                break;
        }
        if(flg == 1) break;
        i++;
    }
    printf("%d\n",dice[0]);
    return 0;
}


Measured memory_bytes: 2116
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    cnt = 0
    if 2 * N < M:
        cnt += N
        cnt += (M - 2 * N) // 4
    else:
        cnt += M // 2
    print(cnt)

main()



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

using namespace std;
#define ll long long
int main(){
    int ans=0;
    string s,t;
    cin >>s;
    cin >>t;
    int a=0;
    bool flag=false;
    for(int i=0;i<s.size();i++){
        a=0;
        flag=true;
        for(int j=(i+1)%s.size();j!=i;j=(j+1)%s.size()){
//            cout <<s[a]<<t[j]<<endl;
            if (s[a]!=t[j]){
                flag=false;
                break;
            }
            a++;
        }
        if(flag)break;
    }
    if(flag){
        cout <<"Yes"<<endl;
    }else{
        cout <<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static final long x = (long) Math.pow(10, 18);

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();

		if (a.length() > b.length()) {
			System.out.println("GREATER");
			return;
		} else if (a.length() < b.length()) {
			System.out.println("LESS");
			return;
		}

		if (a.equals(b)) {
			System.out.println("EQUAL");
		} else if (a.compareTo(b) > 0) {
			System.out.println("GREATER");
		} else {
			System.out.println("LESS");
		}

		sc.close();
	}

}


Measured memory_bytes: 35868
import numpy

tmp=input()
list=input().split(" ")
list=[int(x) for x in list]
array=numpy.array(list,dtype=">i4")
sum=numpy.sum(array)
all=numpy.zeros(100001,dtype=">i4")
for i in array:
  all[i]+=1
#for i in range(len(list)):
#  array[i]=int(list[i])

a=int(input())

for i in range(a):
  b=input().split(" ")
  b0=int(b[0])
  b1=int(b[1])
  diff=all[b0]*(b1-b0)
  sum+=diff
  all[b1]+=all[b0]
  all[b0]=0
  print(sum)

Measured memory_bytes: 38844
// re-lcs
#include <iostream>
#include <string>
#include <vector>
#define ll int

using namespace std;

void print(vector<vector<ll> > &arr)
{
    for (int i = 0; i < arr.size(); i++)
    {
        for (int j = 0; j < arr[0].size(); j++)
        {
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}

int main()
{
    string s, t;
    cin >> s >> t;
    ll m = s.length(), n = t.length();
    vector<vector<ll> > dp(m + 1, vector<ll>(n + 1, 0));
    for (int i = 0; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            }
            else
            {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }
    // print(dp);
    ll index = dp[m][n];
    char arr[index + 1];
    arr[index] = '\0';
    int i = m, j = n;
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            arr[index - 1] = s[i - 1];
            i--;
            j--;
            index--;
        }

        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;
    }
    cout << arr << endl;
    return 0;
}


Measured memory_bytes: 35584
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
//#define int long long
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
int main()
{
	fast;
	int test=1;
	//cin>>test;
	while(test--)
	{
		ll k,a,b;
		cin>>k>>a>>b;
		for(ll i=a;i<=b;i++)
		{
			if(i%k==0)
			{
				cout<<"OK";
				return 0;
			}
		}
		cout<<"NG";
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/



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

int main(){
    int A[5][4][11],n;
    for(int i=1;i<=4;i++)
        for(int j=1;j<=3;j++)
            for(int k=1;k<=10;k++) A[i][j][k]=0;

    cin >> n;
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }
    for(int f=1;f<=4;f++){
        if(f>1) cout << "####################\n";
        for(int b=1;b<=3;b++){
            for(int r=1;r<=10;r++){
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;

int main(){
    string A,B,C;
    cin >> A >> B >> C;
    queue<char> qa,qb,qc;
    for(int i=0;i<A.size();i++){
        qa.push(A[i]);
    }
    for(int i=0;i<B.size();i++){
        qb.push(B[i]);
    }
    for(int i=0;i<C.size();i++){
        qc.push(C[i]);
    }
    char n=qa.front();
    qa.pop();
    while(true){
        if(n=='a'){
            if(qa.empty()){
                cout << 'A' << endl;
                return 0;
            }
            n=qa.front();
            qa.pop();
        }else if(n=='b'){
            if(qb.empty()){
                cout << 'B' << endl;
                return 0;
            }
            n=qb.front();
            qb.pop();
        }else if(n=='c'){
            if(qc.empty()){
                cout << 'C' << endl;
                return 0;
            }
            n=qc.front();
            qc.pop();
        }
        
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18 + 1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
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;
}
//ll f[101010], rf[101010];
//ll inv(ll x) {
//	ll res = 1;
//	ll k = mod - 2;
//	ll y = x;
//	while (k) {
//		if (k & 1) res = (res * y) % mod;
//		y = (y * y) % mod;
//		k /= 2;
//	}
//	return res;
//}
//void init() {
//	f[0] = 1;
//	for (ll i = 1; i < 101010;i++) f[i] = (f[i - 1] * i) % mod;
//	for(ll i = 0; i < 101010; i++) rf[i] = inv(f[i]);
//}
////---------------------------------------------------------------------------------------------------
//ll C(int n, int k) {
//	ll a = f[n]; // = n!
//	ll b = rf[n - k]; // = (n-k)!
//	ll c = rf[k]; // = k!
//
//	ll bc = (b * c) % mod;
//
//	return (a * bc) % mod;
//}

//小文字=大文字+32
int main() {
	int N; cin >> N;
	vector<ll>a(N); rep(i, N) { cin >> a[i];}
	vector<ll>c(N); rep(i, N) { cin >> c[i];}
	ll ans = 0;
	rep(i, N) {
		if (a[i] - c[i] > 0) {
			ans += a[i] - c[i];
		}
	}
	cout << ans;
	
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// Binary Index Treeは長さnの数列に対して
// 1. 区間[a,b)に値xを加算する
// 2. 区間[a,b)の合計値を取得する
// という操作をO(log(n))で処理できる

// 区間加算にも対応したBinary Index Tree(1-indexで使うことに気をつける)
template <class Abel> struct BIT {

    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;
    
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    // 区間[a,b)にxを加算する(a, bは1-index)
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    // 区間[a,b)の総和を計算する(a, bは1-index)
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
};

int main() {
    ll n, d, a;
    cin >> n >> d >> a;

    vector<P> p(n);
    rep(i, n) {
        ll x, h;
        cin >> x >> h;
        p[i] = make_pair(x, h);
    }
    sort(all(p));

    vl x(n), h(n);
    rep(i, n) {
        x[i] = p[i].first;
        h[i] = p[i].second;
    }
    
    BIT<ll> bit(n+10);
    rep(i, n) {
        bit.add(i+1, i+2, h[i]);  // bit[i]をh[i]で初期化
    }
    
    ll ans = 0;
    exrep(i, 1, n) {  // BITは1-indexで使う
        ll hp_i = bit.sum(i, i+1);  // モンスタiの体力
        if(hp_i <= 0) {  // モンスタiの体力が0以下の場合
            continue;  // モンスタiはおしまい
        }
        ll cnt = (hp_i + a - 1)/a;  // モンスタiを倒すのに必要な操作回数
        //　モンスタiのいる座標を左端とした爆発が届く範囲を求める
        ll right = x[i-1] + 2*d;  // 爆発が届く右端の座標
        ll id = upper_bound(all(x), right) - x.begin();  // 爆発が届かないモンスタの中で最も左にいるモンスタの番号 
        id++;
        bit.add(i, id, -a*cnt);  // モンスタiからモンスタid-1の体力をa*need減らす
        ans += cnt;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 9600
#include <iostream>
#include<string>
using namespace std;
int main(){
    string S;
    
    int N,K;
    cin>>N>>K;
    cin>>S;
    K=K-1;
    if(S[K]=='A'){
        S[K]='a';
    }
    else if(S[K]=='B'){
        S[K]='b';
    }
    else if(S[K]=='C'){
        S[K]='c';
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
 
ans = 'APPROVED'
for a in A:
  if a%2 == 1:
    continue
  else:
    if a%3 == 0:
      continue
    elif a%5 == 0:
      continue
    else:
      ans = 'DENIED'
      break
      
print(ans)

Measured memory_bytes: 38384
#include <cstdio>
#include <vector>
using namespace std;
using pii = pair<int, int>;

const int maxn = 100005;
int n, ans[maxn], a;
vector<pii> v[maxn];

void dfs(int x, int p, int b){
    if(a < b) a = b;
    int c = 1;
    for(pii z: v[x]) if(z.first != p){
        if(c == b) c++;
        dfs(z.first, x, c);
        ans[z.second] = c++;
    }
}

int main(){
    scanf("%d", &n);
    for(int i = 1, a, b; i < n; i++){
        scanf("%d %d", &a, &b);
        v[a].push_back({b, i}), v[b].push_back({a, i});
    }
    dfs(1, 0, 0);
    printf("%d\n", a);
    for(int i = 1; i < n; i++) printf("%d\n", ans[i]);
    return 0;
}

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

typedef long long ll;

ll N, K;
const ll MOD = 1e9 + 7;
const ll MAX = 2e5;
ll Inv[MAX + 1], Fact[MAX + 1], InvFact[MAX + 1];
ll R;

ll choose(ll n, ll k) {
  ll res = Fact[n] * InvFact[k] % MOD * InvFact[n - k] % MOD;
  return res;
}
// x部屋空いている配置の数
ll calc(ll x) { return choose(N, N - x) * choose(N - 1, N - 1 - x) % MOD; }
int main() {
  cin >> N >> K;
  Inv[1] = Fact[0] = Fact[1] = InvFact[0] = InvFact[1] = 1;
  for (ll i = 2; i <= MAX; ++i) {
    Inv[i] = MOD - MOD / i * Inv[MOD % i] % MOD;
    Fact[i] = i * Fact[i - 1] % MOD;
    InvFact[i] = Inv[i] * InvFact[i - 1] % MOD;
  }
  for (ll x = 0; x <= min(N - 1, K); ++x) {
    (R += calc(x)) %= MOD;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 4992
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Set<Integer> a = new TreeSet<>();
		Set<Integer> b = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		for (int i = 0; i < m; i++) {
			b.add(sc.nextInt());
		}
		int[][] grid = new int[n][m];
		long count = 1;
		long mod = 1000000007;
		int yoko = 0;
		int tate = 0;
		int used = 0;
		for (int i = n * m; i > 0; i--) {
			if (a.contains(i) && b.contains(i)) {
				yoko++;
				tate++;
			} else if (a.contains(i)) {
				count *= yoko;
				tate++;
			} else if (b.contains(i)) {
				count *= tate;
				yoko++;
			} else {
				count *= tate * yoko - used;
			}
			count %= mod;
			used++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 41764
#include<bits/stdc++.h>
// using namespace std;
typedef long long ll;
const int mod=998244353;
const int N=2e5+5;//,M=2e5+5;
int n,k;
int a[N];

bool check(int len){
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i]>len) cnt+=(a[i]-1)/len;//8变4要1刀
    }
    return cnt<=k;
}

int main()
{
    // ios::sync_with_stdio(false);std::cin.tie(0);cout.tie(0);
    // freopen("a.in","r",stdin);
    // while(~scanf("%d",&n)){
    if(true){
    // int T;scanf("%d",&T);for(int tttt=1;tttt<=T;tttt++){
    scanf("%d%d",&n,&k);
    int l=1,r=-1,ans=0;
    for(int i=1;i<=n;i++)scanf("%d",a+i),r=std::max(r,a[i]);
    while(l<=r){
        int mid=l+r>>1;
        if(check(mid)) r=mid-1,ans=mid;
        else l=mid+1;
    }
    printf("%d\n",ans);
    }return 0;
}


Measured memory_bytes: 4520
//17
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    string n,s,u;
    cin>>n>>s;
    int e;
    string us[]={"yotta","zetta","exa","peta","tera","giga","mega","kilo","hecto","deca","deci","centi","milli","micro","nano","pico","femto","ato","zepto","yocto"};
    int x=find(us,us+20,s)-us;
    if(x==20){
      u=s;
      e=0;
    }else{
      int b[]={24,21,18,15,12,9,6,3,2,1,-1,-2,-3,-6,-9,-12,-15,-18,-21,-24};
      e=b[x];
      cin>>u;
    }
    if(n.find('.')==string::npos){
      n+='.';
    }
    if(n[1]=='.'){
      while(n[0]=='0'){
	n.erase(0,1);
	swap(n[0],n[1]);
	e--;
      }
      if(n.end()[-1]=='.'){
	n.erase(n.size()-1);
      }
    }else{
      while(n[1]!='.'){
	int p=n.find('.');
	swap(n[p],n[p-1]);
	e++;
      }
    }
    cout<<n<<" * 10^"<<e<<' '<<u<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
<?php
    $k = trim(fgets(STDIN));

    // 12までは素直に返す
    if ($k <= 12){
        echo $k;
        return;
    }

    // 10桁までとりあえず作る
    $tmp = [1,2,3,4,5,6,7,8,9];
    $lunlun = [1,2,3,4,5,6,7,8,9];

    $keta = 1;
    while (true) {
        $tmp2 = [];
        for ($i=0; $i < count($tmp); $i++) { 
            $d = substr($tmp[$i], -1);
            if ($d == 0) {
                $tmp2[] = $tmp[$i].'0';
                $tmp2[] = $tmp[$i].'1';
            } else if ($d == 9) {
                $tmp2[] = $tmp[$i].'8';
                $tmp2[] = $tmp[$i].'9';
            } else {
                $tmp2[] = $tmp[$i]. ($d - 1);
                $tmp2[] = $tmp[$i]. $d;
                $tmp2[] = $tmp[$i]. ($d + 1);
            }
        }

        $tmp = $tmp2;
        $lunlun = array_merge($lunlun, $tmp);
        // echo max($lunlun) . PHP_EOL;
        // echo count($lunlun) . PHP_EOL;
        // if(count($lunlun) >= $k){
        //     break;
        // }
        $keta++;
        if ($keta == 10) {
            break;
        }
    }

    sort($lunlun);
    echo $lunlun[$k - 1];
    return;
?>

Measured memory_bytes: 31216
#include <bits/stdc++.h>
#define N 101
using namespace std;

struct card{
  int num;
  char ch;
  bool operator < (card a)const{return num<a.num;}
  bool operator == (card a)const{return num==a.num&&ch==a.ch;}
};

void BubbleSort(card *A,int n){
  for(int i=0;i<n-1;i++)
    for(int j=n-1;j>=i+1;j--)
      if(A[j] < A[j-1]) swap(A[j],A[j-1]);
}

void SelectionSort(card *A,int n){
  for(int i=0;i<n-1;i++){
    int idx = i;
    for(int j=i;j<n;j++)if(A[j]<A[idx])idx = j;
    swap(A[i],A[idx]);
  }
}

void pr(card *A,int n){
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<A[i].ch<<A[i].num;
  }
  cout<<endl;

}

bool isStable(card *A,card *B,int n){
  for(int i=0;i<n;i++) if(!(A[i]==B[i])) return 0;
  return 1;
}

int main(){
  int n;
  cin>>n;
  card A[N],B[N];
  for(int i=0;i<n;i++) cin>>A[i].ch>>A[i].num,B[i] = A[i];
  BubbleSort(A,n);
  SelectionSort(B,n);
  
  pr(A,n);
  cout<<"Stable"<<endl;
  pr(B,n);
  cout<<(isStable(A,B,n)? "Stable":"Not stable")<<endl;
    
  return 0;
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]==s[s.length()-1])
	{
		if(s.length()%2==1)
		{
			cout<<"Second";
		}else
		{
			cout<<"First";
		}
	}else
	{
		if(s.length()%2==1)
		{
			cout<<"First";
		}else
		{
			cout<<"Second";
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  cin>>n ;
  map<string,ll> p;
  p["AC"]=0 ;
  p["WA"]=0 ;
  p["RE"]=0 ;
  p["TLE"]=0 ;
  while(n--)
  {
      string s ;
      cin>>s ;
      p[s]++ ;
  }
  cout<<"AC x "<<p["AC"]<<"\n" ;
  cout<<"WA x "<<p["WA"]<<"\n" ;
  cout<<"TLE x "<<p["TLE"]<<"\n" ;
  cout<<"RE x "<<p["RE"]<<"\n" ;
  return 0; }



Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
public class abc079b {

}

 */
public class Main {
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int n = in.readInteger();
    
    long[] l = new long[n + 1];
    
    l[0] = 2;
    l[1] = 1;
    
    for(int i = 2; i <= n; i++)
    {
      l[i] = l[i - 1] + l[i - 2];
    }

    System.out.println(l[n]);
    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new Main()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


Measured memory_bytes: 22484
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return !f?x:-x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int cnt[MAXN+5];
vector<int> G[MAXN+5];
void DFS(int u,int fa){
	cnt[u]+=cnt[fa];
	for(int i=0;i<int(G[u].size());i++){
		int v=G[u][i];
		if(v==fa) continue;
		DFS(v,u);
	}
	return ;
}
int main(){
	int n=read(),q=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=q;i++){
		int p=read(),x=read();
		cnt[p]+=x;
	}
	DFS(1,0);
	for(int i=1;i<=n;i++)
		printf("%d",cnt[i]),putchar(i==n?'\n':' ');
	return 0;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-10
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	int n, m, x = 0, a;
	scanf( "%d%d", &n, &m );
	while( m-- ) {
		scanf( "%d", &a );
		x += a;
	}
	if( x >= n )
		printf( "Yes" );
	else
		printf( "No" );
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[100];
    for(int i=0;i<n;i++)cin >> a[i];
    int ans=0;
    for(int i=0;i<n;i++)ans += a[i];
    if(ans%10 == 0){
        sort(a,a+n);
        for(int i=0;i<n;i++)if(a[i]%10){
            cout << ans - a[i] << endl;
            return 0;
        }
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

if c1[0]-c1[1] != c2[0]-c2[1] or c1[0]-c1[1] != c3[0]-c3[1]:
    print('No')
    exit()

if c1[0]-c1[2] != c2[0]-c2[2] or c1[0]-c1[2] != c3[0]-c3[2]:
    print('No')
    exit()

if c1[0]-c2[0] != c1[1]-c2[1] or c1[0]-c2[0] != c1[2]-c2[2]:
    print('No')
    exit()

if c1[0]-c3[0] != c1[1]-c3[1] or c1[0]-c3[0] != c1[2]-c3[2]:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3064
N,K=gets.split.map(&:to_i)
A=[1]+gets.split.map(&:to_i)

S=Hash.new{|h,k|h[k]=[]}
A.each.with_index.inject(0) do |s,(a,i)|
  s=(s+a-1)%K
  S[s]<<i
  s
end

ans=0
S.each do |k,v|
  r=1
  v.size.times do |l|
    r+=1 while r<v.size && v[r]-v[l]<=K-1
    ans+=r-l-1
  end
end
p ans

Measured memory_bytes: 42864
#include <iostream>
#include <vector>
#include <cmath>
#include <atcoder/modint>

#include <atcoder/math>
#include <atcoder/fenwicktree>
#include <atcoder/convolution>
#include <atcoder/scc>
#include <atcoder/twosat>

#include <cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

using namespace atcoder;

ll mod2 = 998244353;

int main()
{
    int n, d;
    scanf("%d %d", &n, &d);

    vector<int> x(n), y(n);
    FOR (i, 0, n) {
        scanf("%d %d", &x[i], &y[i]);
    }

    // ts[i] = (i-th flag is located on x[i])
    two_sat TS(n);

    FOR (i, 0, n) {
        FOR (j, i + 1, n) {
            if (abs(x[i] - x[j]) < d) {
                TS.add_clause(i, false, j, false);
            }
            if (abs(x[i] - y[j]) < d) {
                TS.add_clause(i, false, j, true);
            }
            if (abs(y[i] - x[j]) < d) {
                TS.add_clause(i, true, j, false);
            }
            if (abs(y[i] - y[j]) < d) {
                TS.add_clause(i, true, j, true);
            }
        }
    }

    if (!TS.satisfiable()) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    auto answer = TS.answer();
    for (int i = 0; i < n; i++) {
        if (answer[i]) {
            printf("%d\n", x[i]);
        } else {
            printf("%d\n", y[i]);
        }
    }

    return 0;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int dp[15][100005];

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % 13;
        a = a * a % 13;
        n >>= 1;
    }
    return res;
}

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

    int n = s.size();

    dp[0][0] = 1;

    for (int i = 0; i < n; i++) {
        if(s[i]!='?'){
            ll rem = (ll)(s[i] - '0') * modpow(10, n-i-1) % 13;
            rep(j, 13){
                dp[(j+rem)%13][i+1] += dp[j][i];
                dp[(j+rem)%13][i+1] %= MOD;
            }
        }else{
            rep(k, 10){
                rep(j, 13){
                    ll rem = (ll)k * modpow(10, n-i-1) % 13;
                    dp[(j+rem)%13][i+1] += dp[j][i];
                    dp[(j+rem)%13][i+1] %= MOD;
                }
            }
        }
    }
    
    cout << dp[5][n] << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
ll A, B, C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
void TwoColorsCardGame() {
	cin >> N;
	map<string, int> m;
	for (size_t i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	cin >> M;
	for (size_t i = 0; i < M; i++)
	{
		string s;
		cin >> s;
		m[s]--;
	}
	int res = 0;
	for (map<string,int>::iterator it = m.begin(); it != m.end(); it++)
	{
		res = max(res, it->second);
	}
	cout << res << endl;
}
int main() {
	TwoColorsCardGame();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int n,a[N<<1];
bool check(int x){
	for(int i=1;i<n;i++){
		if(a[n+i]>=x&&a[n+i-1]>=x)return 1;
		if(a[n-i]>=x&&a[n-i+1]>=x)return 1;
		if(a[n+i]<x&&a[n+i-1]<x)return 0;
		if(a[n-i]<x&&a[n-i+1]<x)return 0;
	}
	return (a[n]<x)^(n&1);
}
int main(){
	n=read();
	for(int i=1;i<2*n;i++)a[i]=read();
	int l=1,r=n*2-1;
	while(l<r){
		int mid=(l+r)>>1; mid++;
		//cout<<check(mid)<<" "<<l<<" "<<r<<endl;
		if(check(mid))l=mid; else r=mid-1;
	}
	writeln(l);
}
/*
1
101
10101
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
const int M = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define endl "\n"
using namespace std;

//vector<ll> adj[1000001];
//int vis[1000001]; 
//
//int dfs(int node){
//	vis[node]=1;
//	for(int child: adj[node]){
//		if(!vis[child])
//		dfs(child);
//	}
//}

void solve()
{	
	int n; cin>>n;
	if(400<=n && n<=599){
		cout<<"8"<<"\n";
		return;
	}
	if(600<=n && n<=799){
		cout<<"7"<<"\n";
		return;
	}
	if(800<=n &&n<=999){
		cout<<"6"<<"\n";
		return;
	}
	if(1000<=n &&n<=1199){
		cout<<"5"<<"\n";
		return;
	}
	if(1200<=n && n<=1399){
		cout<<"4"<<"\n";
		return;
	}
	if(1400<=n&&n<=1599){
		cout<<"3"<<"\n";
		return;
	}
	if(1600<=n&&n<=1799){
		cout<<"2"<<"\n";
		return;
	}
	if(1800<=n&&n<=1999){
		cout<<"1"<<"\n";
		return;
	}
	
			
}
int main(void)
{
    fast;
//    ll t;
//    cin>>t;
//    while(t--)
        solve();
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
int n, a[N];
int main(){
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (i % 2 == 1 && a[i] % 2 == 1) ans++;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632