akhauriyash/Code-Regression huggingface dataset:
abcd = input()

for i in range(2 ** 3):
    check = int(abcd[0])
    op_list = []
    for j in range(3):
        if i >> j & 1:
            check += int(abcd[j+1])
            op_list.append('+')
        else:
            check -= int(abcd[j+1])
            op_list.append('-')
    if check == 7:
        m = abcd[0] + op_list[0] + abcd[1] + op_list[1] + abcd[2] + op_list[2] + abcd[3] + '=7'
        print(m)
        break



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 999999999
const int mod = 1000000007;
ll cnt = 0;

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

 int n;   cin >> n;
 for(int i=0;i<5;i++){
     for(int j=i+1;j<5;j++){
         if(a[j] - a[i] > n){
             cout << ":(" << endl;
             return 0;
         }
     }
 }

cout << "Yay!" << endl;
  


}

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

const int N = 1e5 + 5;

#define pii pair<int, int>

int n, k;
pii tmp[N];
int a[N], b[N], c[N];

int main() {
	scanf("%d%d", &n, &k);
	if (2 * k - 1 > n) {
		puts("-1");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		a[i] = k + i;
		c[i] = a[i] + 2 * n; 
	}
	int hn = (n + 1) >> 1;
	for (int i = 0; i < hn - i - 1; i++) {
		swap(a[i], a[hn - i - 1]);
	}
	for (int l = hn, r = n - 1; l < r; l++, r--) {
		swap(a[l], a[r]);
	}
	for (int i = 0; i < n; i++)
		tmp[i] = pii(c[i] - a[i], i);
	sort(tmp, tmp + n);
	for (int i = 0; i < n; i++)
		b[tmp[i].second] = k + n + i;
	for (int i = 0; i < n; i++) {
		printf("%d %d %d\n", a[i], b[i], c[i]);
	} 
	return 0;
}


Measured memory_bytes: 4224
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	cnt := 0
	maxcnt := 0

	for i := 0; i < len(s); i++ {
		if s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T' {
			cnt++
			maxcnt = max(maxcnt, cnt)
		} else {
			cnt = 0
		}
	}

	fmt.Println(maxcnt)

}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;

}

Node treeMaximum(Node x){
 while(x->right!=NIL)
    x=x->right;
  return x;


}

Node treeSearch(Node u, int k){
  if(u==NIL||k==u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  if(x->right!=NIL)
    return treeMinimum(x->right);
  
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)
    y=z;
  else
    y=treeSuccessor(z);

  if(y->left!=NIL)
    x=y->left;
  else
    x=y->right;

  if(x!=NIL)
    x->parent=y->parent;

  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;
  
  if(y!=z)
    z->key=y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inorder(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if(b-a == c-b){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    bool deli[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            deli[i][j]=false;
        }
    }
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int a;
            cin >> a;
            deli[i][a-1]=true;
        }
    }
    int ans=0;
    for(int j=0;j<m;j++){
        bool all=true;
        for(int i=0;i<n;i++){
            if(deli[i][j]==false){
                all=false;
            }
        }
        if(all){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
s=input()
n=len(s)
MOD=2019
L=[0]
for i in range(n):
    l=(int(s[n-1-i])*pow(10,i,MOD)+L[i])%MOD
    L.append(l)
LC=Counter(L)
r=0
for v in LC.values():
    r+=v*(v-1)//2
print(r)

Measured memory_bytes: 16740
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << "\n";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

const ld pi = acos(-1);
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<Pll> v(n);
    rep(i,0,n){
        cin >> v[i].first >> v[i].second;
    }
    debug(pi);
    vector<ld> ans(n);
    rep(i,0,n){
        vector<ld> t;
        rep(j,0,n){
            if(v[i] == v[j])continue;
            t.emplace_back(atan2(v[i].second - v[j].second, v[i].first - v[j].first));
        }

        sort(all(t));
        t.emplace_back(t[0] + 2 * pi);
        if(t.size() == 2){
            ans[i] = 0.5;
            continue;
        }
        debug(t);
        ld ret = 0.0;
        rep(i,0,t.size()-1){
            if(t[i + 1] - t[i] > pi){
                ret = (t[i + 1] - t[i] - pi) / (2.0 * pi);
            }
        }

        ans[i] = ret;
    }

    cout << fixed << setprecision(15);
    print(ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    cin>>n;
    vector<int> p(n,0);
    n--;
    rep(i,n){
        int a;
        cin>>a;
        a--;
        p[a]++;
    }
    rep(i,n+1) cout<<p[i]<<endl;
}

Measured memory_bytes: 4048
using System;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            string msg = ((a < b) && (b < c)) ? "Yes" : "No";
            Console.WriteLine(msg);
        }
    }
}

Measured memory_bytes: 8872
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int a, b;
    a = H * W;
    b = H * w + W * h - h * w;
    cout << a - b;

    /* ====================================== */
    cout << 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);
		long X=sc.nextLong();

		long h =100L;
		int count = 0;
		sc.close();

		while(h < X) {
			h *= 1.01;
			count++;
		}

		System.out.println(count);




	}
}


Measured memory_bytes: 35524
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string S;
    char old_tail;
    set<string> st;
    for (int i=0;i<n;i++){
        cin >> S;

        auto it = st.find(S);
        if (it!=st.end()){
            cout << "No" << endl;
            return 0;
        }
        st.insert(S);

        if (i>0){
            if (S.front()!=old_tail){
                cout << "No" << endl;
                return 0;
            }
        }
        old_tail = S.back();
        
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL x;
    cin >> x;
    if(30 <= x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000, mod = 1e9 + 7;
int N, k, tot, ans, fac[maxn + 10], ifac[maxn + 10], inv[maxn + 10];
int a[100], pos[100], cnt[100];
char s[100];
bool vis[100];

void solve(int n) {
	memset(vis, 0, sizeof vis);
	for (int i = 1, p = 1; i <= n; ++i) {
		for (; p <= k && s[p] != 'r'; ++p);
		if (p > k) return;
		vis[p] = 1;
		pos[i] = p++;
	}
	for (int i = 1, p = 1; i <= n; ++i)
		if (a[i] >= 2) {
			for (; p <= k && (p <= pos[i] || s[p] != 'b'); ++p);
			if (p > k) return;
			vis[p] = 1; pos[i] = p++;
		}
	for (int i = 1, p = 1; i <= n; ++i)
		if (a[i] >= 3)
			for (int j = 1; j <= a[i] - 2; ++j) {
				for (; p <= k && (p <= pos[i] || vis[p]); ++p);
				if (p > k) return;
				++p;
			}
	int ans = fac[n];
	memset(cnt, 0, sizeof cnt);
	for (int i = 1; i <= n; ++i)
		++cnt[a[i]];
	for (int i = 1; i <= N; ++i)
		if (cnt[i])
			ans = 1ll * ans * ifac[cnt[i]] % mod;
	int x = N + 1, y = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] >= 2) x += 2;
		y += a[i] * 2;
	}
	if (x < y) return;
	ans = 1ll * ans * fac[x] % mod;
	ans = 1ll * ans * ifac[y] % mod;
	ans = 1ll * ans * ifac[x - y] % mod;
	(tot += ans) %= mod;
}

void dfs(int p, int l, int mx) {
	solve(p - 1);
	for (int i = mx; i >= 1; --i)
		if (max(i * 2 - 3, 1) <= l) {
			a[p] = i;
			dfs(p + 1, l - max(i * 2 - 3, 1), i);
		}
}

int main() {
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = i == 1 ? 1 : mod - 1ll * (mod / i) * inv[mod % i] % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
	}
	scanf("%d%d", &N, &k);
	scanf("%s", s + 1);
	dfs(1, N, N * 2);
	printf("%d", tot);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

vi cfs(100050, 1e15);
vi cft(100050, 1e15);
V(V(P)) yedge(100050);
V(V(P)) sedge(100050);


void dijkstra(int s, vi &cost, V(V(P)) &edge) {
    priority_queue<P, V(P), greater<P>> q;
    cost[s] = 0;
    q.push(P(0, s));
    while(!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.se;
        if(cost[v] < p.fi) continue;
        rep(i, edge[v].size()) {
            if(cost[edge[v][i].fi] > cost[v]+edge[v][i].se) {
                cost[edge[v][i].fi] = cost[v] + edge[v][i].se;
                q.push(P(cost[edge[v][i].fi], edge[v][i].fi));
            }
        }
    }
}

signed main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        yedge[u].pb(P(v, a));
        yedge[v].pb(P(u, a));
        sedge[u].pb(P(v, b));
        sedge[v].pb(P(u, b));
    }

    dijkstra(s, cfs, yedge);
    dijkstra(t, cft, sedge);

    vi res(n, 1e15);
    rep(i, n) res[i] = cfs[i] + cft[i];
    //rep(i, n) cout << res[i] << endl;
    //cout << endl;
    for(int i=n-2; i>=0; i--) res[i] = min(res[i], res[i+1]);

    rep(i, n) {
        cout << 1000000000000000-res[i] << endl;
    }



    return 0;
}

Measured memory_bytes: 20804
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;

	rep(i, n){
		bool first = true;

		rep(j, i + 1, n){
			int pos = 1;
			while(1) {
				const int mask = (1 << pos) - 1;
				if ((i & mask) != (j&mask)) break;
				pos++;
			}
			const int level = pos;
			if(first == false) cout << " ";
			first = false;
			cout << level;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int a[3][3];
bool c[3][3];
int main()
{
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
            c[i][j]=0;
        }
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int r;
        cin>>r;
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(a[i][j]==r)
                    c[i][j]=1;
            }
        }
    }
    for(int i=0;i<3;i++)
    {
        if(c[i][0] and c[i][1] and c[i][2])
        {
            cout<<"Yes\n";
            return 0;
        }
        if(c[0][i] and c[1][i] and c[2][i])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if(c[0][0] and c[1][1] and c[2][2])
    {
        cout<<"Yes\n";
        return 0;
    }
    if(c[2][0] and c[1][1] and c[0][2])
    {
        cout<<"Yes\n";
        return 0;
    }
    cout<<"No\n";
    return 0;
}


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

C = [0 for _ in range(9)]

for i in range(N):
    if a[i] // 400 < 8:
        C[a[i]//400] = 1
    else:
        C[8] += 1

ans_min = max(1,sum(C[:8]))
ans_max = sum(C)
print(ans_min,ans_max)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	int n,temp;
	cin >> n;
	vector<int> a(100005);
	for(int i=0; i<n; i++){
		cin >> temp;
		a[temp]++;
	}
	int ans=0;
	for(int i=2; i<=100000; i++){
		ans=max(ans,a[i]+a[i-1]+a[i-2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

struct Seg {
    int n;
    vector<vector<int>> dat;

    Seg(int _n) {
        n = 1;
        while(n < _n) n *= 2;
        dat.resize(2*n-1, vector<int>(26,0));
    }

    void update(int k, int a) {
        k += n-1;
        rep(i,26) dat[k][i] = 0;
        dat[k][a] = 1;
        while(k > 0) {
            k = (k-1)/2;
            rep(i,26) dat[k][i] = dat[k*2+1][i] + dat[k*2+2][i];
        }
    }

    void query(int a, int b, int k, int l, int r, vector<int>& v) {
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) {
            rep(i,26) v[i] += dat[k][i];
        }
        else {
            query(a, b, k*2+1, l, (l+r)/2, v);
            query(a, b, k*2+2, (l+r)/2, r, v);
        }
    }

    void query(int a, int b, vector<int>& v) {
        query(a, b, 0, 0, n, v);
    }
};

int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    Seg seg(N);
    rep(i,N) seg.update(i, S[i] - 'a');
    vector<int> ans;
    rep(_q,Q) {
        int qtype; cin >> qtype;

        if(qtype == 1) {
            int i; char c;
            cin >> i >> c;
            seg.update(i-1, c - 'a');
        } else {
            int l, r;
            cin >> l >> r;
            --l;
            vector<int> v(26 ,0);
            seg.query(l, r, v);
            int res = 0;
            rep(i,26) if(v[i] > 0) ++res;
            ans.push_back(res);
        }
    }
    for(auto e : ans) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 142084
#include <stdio.h>

int dp[50];

int fib(int );

int main(){
  int n,i;
  for(i=0;i<50;i++)
    dp[i]=-1;

    scanf("%d",&n);
    printf("%d\n",fib(n));

    return 0;
}

int fib(int n){
  if(n==0 || n==1) return dp[n]=1;
  if(dp[n] != -1) return dp[n];
  return dp[n] =  fib(n-1) + fib(n-2);
}



Measured memory_bytes: 2052
### coding: UTF-8
import sys

head = sys.stdin.readline()
[n, m] = head.split(" ")
n = long(n)  # 店の件数
m = long(m)  # 購入本数

amount = 0

# 店の件数分読み込み
rows = [sys.stdin.readline() for _ in range(n)]
rows.sort(key=lambda x: long(x.split(" ")[0]))
for row in rows:
    [a, b] = row.strip().split(" ")
    ai = long(a) # 金額
    bi = long(b) # 購入可能な数量
    # 購入可能な最大数まで買う
    x = bi if m >= bi else m
    for var in range(x):
        amount += ai
    m -= x
    if m == 0:
        break

print amount


Measured memory_bytes: 18008
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 998244353;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> B(N);
    B[0] = A[0];
    for(int i = 1; i < N; i++){
        B[i] = B[i-1] + A[i];
    }
    ll ans = INF;
    rep(i,N-1){
        ll left = B[i];
        ll right = B[N-1] - B[i];
        ans = min(ans, abs(left-right));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6408
#include<bits/stdc++.h>
#pragma GCC target ("avx")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

template<class T>
struct RollingHash{
	int Base=283;
	const int MASK30=(1ll<<30)-1;
	const int MASK31=(1ll<<31)-1;
	const int MOD=(1ll<<61)-1;
	vector<int>hash,power;
	int calcmod(int v){
		v=(v&MOD)+(v>>61);
		if(v>MOD)v-=MOD;
		return v;
	}
	int mul(int x,int y){
		int xu=x>>31,xd=x&MASK31;
		int yu=y>>31,yd=y&MASK31;
		int mid=xd*yu+xu*yd,midu=mid>>30,midd=mid&MASK30;
		return calcmod(xu*yu*2+midu+(midd<<31)+xd*yd);
	}
	RollingHash(T s){
		int sz=s.size();
		hash.resize(sz+1,0);power.resize(sz+1,1);
		rep(i,sz){
			hash[i+1]=calcmod(mul(hash[i],Base)+s[i]);
			power[i+1]=calcmod(mul(power[i],Base));
		}
	}
	int get(int l,int r){
		return calcmod(hash[r]-mul(hash[l],power[r-l])+MOD);
	}
	int lcp(int x,int y){
		int len=min(hash.size()-1-y,hash.size()-1-x);
		int ok=0,ng=len+1;
		while(ng-ok>1){
			int mid=(ok+ng)/2;
			if(get(x,x+mid)==get(y,y+mid))ok=mid;
			else ng=mid;
		}
		return ok;
	}
};

int N;
string S[200005];
signed main(){
	cin>>N;
	rep(i,N){
		cin>>S[i];reverse(all(S[i]));
	}
	unordered_map<int,int>has;
	int ans=0;
	int cnt[26];
	rep(i,N){
		RollingHash<string>RH(S[i]);
		has[RH.hash[len(S[i])]]++;
	}
	rep(i,N){
		RollingHash<string>RH(S[i]);
		memset(cnt,0,sizeof(cnt));
		for(char c:S[i])cnt[c-'a']++;
		rep(j,26)if(cnt[j]){
			if(has.find((int)('a'+j))==has.end())continue;
			ans+=has[(int)('a')+j];
		}
		rep(j,len(S[i])){
			cnt[S[i][j]-'a']--;
			rep(k,26){
				if(cnt[k]){
					int p=(RH.mul(RH.hash[j+1],RH.Base)+(int)('a'+k))%RH.MOD;
					if(has.find(p)==has.end())continue;
					ans+=has[p];
				}
			}
		}
	}
	cout<<ans-N<<endl;
}


Measured memory_bytes: 26764
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	string S; cin >> S;
	ll ans = 0;
	ll now = 0;
	REP(i, 3) {
		if (S[i] == 'R') {
			now++;
			chmax(ans, now);
		}
		else now = 0;
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3656
#include <stdio.h>
int main(){
  long int n;
  scanf("%ld",&n);
  long int sum=0;
  for(long int i=1;i*(i+1)+1<=n;i++){
    if((n-i)%i==0)     
    	sum+=(n-i)/i;
  }
  printf("%ld\n",sum);
  return 0;
}


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

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) (x&(-x))

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

const ld inf = 2e18;
const int N = 3e6 + 10;
const int maxn = 400020;
const ll mod = 1e9 + 7;

inline ll power(ll x,ll y){
	if ( y < 0 ) return 1;
	ll res = 1;
	while ( y ){
		if ( y & 1 ) res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int n,T,a[maxn],mx,mn,k,cnt[maxn],M;
ll fac[maxn],inv[maxn],f[20][1 << 17];

void init(){
	fac[0] = inv[0] = 1;
	int tmp = M;
	rep(i,1,tmp) fac[i] = fac[i - 1] * i % mod;
	inv[tmp] = power(fac[tmp],mod - 2);
	repd(i,tmp - 1,1) inv[i] = inv[i + 1] * (i + 1) % mod;
}

inline void up(ll &x,ll y){ x = (x + y) % mod; }
inline ll C(int n,int m){
	if ( n < 0 || m < 0 || n < m ) return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
inline int getsz(int S){
	int res = 0;
	rep(i,0,n - 1) if ( S & (1 << i) ) res += 1 << i;
	return res;
}
int main(){
	scanf("%d %d",&n,&k);
	rep(i,1,k) scanf("%d",&a[i]);
	sort(a + 1,a + k + 1) , reverse(a + 1,a + k + 1);
	M = 1 << n;
	init();
	f[0][0] = 1;
	rep(i,0,k){
		rep(j,0,M - 1){
			if ( !f[i][j] ) continue;
			int c = getsz(j);
			rep(l,0,n - 1){
				if ( j & (1 << l) ) continue;
				up(f[i + 1][j ^ (1 << l)],f[i][j] * C(M - a[i + 1] - c,(1 << l) - 1) % mod * fac[(1 << l)]);
			}
			up(f[i + 1][j],f[i][j]);
		}
	}
	ll ans = 0;
	rep(i,0,M - 1){
		int tp = (__builtin_popcount(i) & 1) ? -1 : 1;
		int c = M - getsz(i) - 1;
		up(ans,tp * f[k][i] * fac[c]);
	}
	cout<<(ans * M % mod + mod) % mod<<endl;
}




Measured memory_bytes: 22784
#include <iostream>
#include <vector>

using namespace std;

typedef unsigned long long ull;
const ull MAX = 1000000000;

int main()
{
    ull S;
    cin >> S;
    ull x1 = 0, y1 = 0, x2 = MAX, y2, x3 = 1, y3;
    // 面積 x2y3 - x3y2 = S
    y3 = (S-1) / MAX + 1;
    y2 = x2 * y3 - S;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    
}


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

using namespace std;

int main(){
	ll n, a, b, c, d, x, y;
	
	cin>>n;
	cin>>a>>b>>c>>d;
	
	x=(n-1)/a;
	y=(n-1)/c;
	x++;
	y++;
	x=x*b;
	y=y*d;
	
	
	cout<<min(x,y)<<"\n";
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll f(ll a, ll b) {
    string sa = to_string(a);
    string sb = to_string(b);
//    cerr << sa << " " << sb << endl;
    return max(sa.size(), sb.size());
}

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i != 0) continue;
        ans = min(ans, f(i, n/i));
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  
  string s;
  cin>>s;
  
  int c=count(s.begin(),s.end(),'W');
  int d=s.size()-c;
  if(c==d)
  {
      
      int temp1=0,temp2=0;
      
      for(int i=0;i<c;++i)
      {
          if(s[i]=='R')
          {
              temp1++;
          }
      }
      reverse(s.begin(),s.end());
      for(int i=0;i<c;++i)
      {
          if(s[i]=='W')
          {
              temp2++;
          }
      }
      
      int tot=0;
      tot=min(d-temp1,c-temp2);
      cout<<tot<<endl;
  }
  else
  {
      if(c>d)
      {
          int temp1=0;
          for(int i=0;i<d;++i)
          {
              if(s[i]=='R')
              {
                  temp1++;
              }
          }
          
          cout<<(d-temp1)<<endl;
      }
      else
      {
          int temp1=0; 
          reverse(s.begin(),s.end());
          for(int i=0;i<c;++i)
          {
              if(s[i]=='W')
              {
                  temp1++;
              }
          }
          
          cout<<(c-temp1)<<endl;
      }
  }

}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define MOD 1e9+7
#define ll long long
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||

signed main(){
	acc_io;
	ll n,m;
	cin>>n>>m;
	vl h(n+1);
	rep(i,1,n+1) cin>>h[i];
	vl a(m+1),b(m+1);
	rep(i,1,m+1) cin>>a[i]>>b[i];

	vl good(n+1,1);
	rep(j,1,m+1){
		if(h[a[j]]<=h[b[j]]){
			good[a[j]]=0;
		}
		if(h[a[j]]>=h[b[j]]){
			good[b[j]]=0;
		}
	}
	ll cnt=0;
	rep(i,1,n+1){
		if(good[i]) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    for(int i = 0; i < k; i++){
        if(a >= b){
            b *= 2;
            continue;
        }

        if(b >= c){
            c *= 2;
            continue;
        }
    }
    if(a < b && b < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
  String a=sc.next();
int n=a.length();
char x=a.charAt(n-1);



if(x=='2'||x=='4'||x=='5'||x=='7'||x=='9'){
    System.out.println("hon");
}
        if(x=='0'||x=='1'||x=='6'||x=='8'){
            System.out.println("pon");
        }
        if(x=='3'){
            System.out.println("bon");
        }



    }
}

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

using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	if(n&1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
import math
from decimal import Decimal
from sys import stdin
data = stdin.readline().rstrip()

a = Decimal(data.split()[0])
b = Decimal(data.split()[1])

h = int(data.split()[2])
m = int(data.split()[3])

h_angle = Decimal(30*h + 0.5*m)
m_angle = Decimal(6*m)

dis = abs(h_angle - m_angle)
if 180 < dis <= 360:
    dis = 360 - dis

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Decimal(math.cos(math.radians(dis)))))

Measured memory_bytes: 10372
N = int(input())
Wn = list(map(int, input().split()))

min_diff = 10000
for T in range(1,N):
    s1 = sum(Wn[:T])
    s2 = sum(Wn[T:])
    diff = abs(s1-s2)
    if diff < min_diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main()
{
  while (1)
  {
    string s;
    cin >> s;
    if (s == "-")
      break;
    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
      int h;
      cin >> h;
      string s2;
      s2 = s.substr(0, h);
      s.erase(0, h);
      s += s2;
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3156
## abc070d: Transit Tree Path

n = int(input())

T = [[] for _ in range(n+1)]
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    T[v1].append([v1,v2,d])
    T[v2].append([v2,v1,d])

q,k = map(int, input().split())

visit = [False]*(n+1)
depth = [0]*(n+1)
stack = [[0,k,0]]
while stack:
    p,c,d = stack.pop()
    if visit[c]: continue
    visit[c] = True
    depth[c] = depth[p] + d
    for pp,cc,dd in T[c]:
        if not visit[cc]: stack.append([pp,cc,dd])

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1]+depth[v2])

Measured memory_bytes: 54968
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x,y;
		while(true){
			x=sc.nextInt();
			y=sc.nextInt();
			if(x==0&&y==0)break;
			if(x>y)System.out.println(y+" "+x);
			else System.out.println(x+" "+y);
		}
		sc.close();
	}
}



Measured memory_bytes: 35612
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: i32,
        b: i32,
        p: [i32; n],
    }

    let mut count = [0; 3];
    for p in p {
        if p <= a {
            count[0] += 1;
        } else if p <= b {
            count[1] += 1;
        } else {
            count[2] += 1;
        }
    }

    if let Some(ans) = count.iter().min() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2156
#include "bits/stdc++.h"
using namespace std;
vector<int>A[100005];
int main() {
	int N, M;
	cin >> N >> M;
	for (int n = 0; n < N ; ++n) {
		int a, b;
		cin >> a >> b;
		if (a > M) {
			continue;
		}
		A[M-a].push_back(b);
	}	
	priority_queue<int> q;
	long long ans = 0;
	for (int i = M - 1;i>=0;--i) {
		for (int m = 0; m < A[i].size();++m) {
			q.push(A[i][m]);
		}
		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 8924
#include <iostream>
#include <ctype.h>

typedef long long ll;

#define FOR(i,a,b) for(ll i = (a);i < (b);++i)
#define REP(i,n) FOR(i,0,n)

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int A, B;
  cin >> A >> B;
  int len = A;
  string str;
  cin >> str;

  REP(i,(int)str.size()){
    if(i == len){
      if(str[i] != '-'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(!isdigit(str[i])){
        cout << "No" << endl;
        return 0; 
      }
    }
  }

  cout << "Yes" << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#define ll long long 
#define pb push_back
#define pf push_front

using namespace std;

void solve(){
    int n,k; cin>>n>>k; int p[n]; for(int i=0; i<n;i++) cin>>p[i];
    sort(p,p+n);
    int sum=0;
    for(int i=0; i<k; i++) sum+=p[i];
    cout<<sum<<endl;

}

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

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

void solve(){
   int k,x;
   cin>>k>>x;
   int minMax = -1000000;
   int maxMax = 1000000;
   int minVal = x-k+1, maxVal = x+k-1;
   if(minVal < minMax) minVal = minMax;
   if(maxVal > maxMax) maxVal = maxMax;
   for(int i=minVal;i<=maxVal;i++) cout << i << " ";

}


int main(){
   solve();
}

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

int n,k,num=0;
ll a[1005],s[1005],ans=0;
vector <ll> d;

int main(void){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]),s[i]=s[i-1]+a[i];
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++)
		d.push_back(s[j]-s[i-1]);
	}
	for(int i=50;i>=0;i--){
		vector <ll> e;
		int cnt=0;
		for(int j=0;j<d.size();j++){
			ll x=d[j];
			if((x>>i)&1){
				e.push_back(x);
				cnt++;
			}	
		}
		if(cnt>=k){
			ans+=(1ll<<i);
			d=e;
		}
	}
	printf("%lld",ans);
}
/*
1-->1
2-->10
3-->11
5-->101
*/ 

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<setiosflags(ios::fixed)<<setprecision(12);
    double L;
    cin>>L;
    double cur=L/3;
    double ans=cur*cur*cur;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n;
    cin >> n;
    struct restaurant {string s; int p; int n;};
    vector<restaurant> v;
    
    repeat (i, n) {
        restaurant r;
        cin >> r.s >> r.p;
        r.n = i + 1;
        v.push_back(r);
    }
    
    sort(v.begin(), v.end(), [](restaurant a, restaurant b) {
        if (a.s != b.s) return a.s < b.s;
        else return a.p > b.p;
    });
    
    for (auto r: v) {
        cout << r.n << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>

int main(){
    int N;
    std::cin >> N;
    std::set<int> s;
    for(int i = 0; i < N; i++){
        int d;
        std::cin >> d;
        s.insert(d);
    }

    std::cout << s.size() << std::endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

signed main(void)
{
  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));

  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256