akhauriyash/Code-Regression huggingface dataset:
#
# abc064 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
2100 2500 2700 2700"""
        output = """2 2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
1100 1900 2800 3200 3200"""
        output = """3 5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """20
800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990"""
        output = """1 1"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    C = [0] * 9
    for a in A:
        for i in range(8):
            if 400*i <= a <= 400*i+399:
                C[i] = 1
                break
        else:
            C[8] += 1

    print(f"{max(1, C[:8].count(1))} {C[:8].count(1)+C[8]}")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16252
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra
    map<ll,ll> visit;
    void dfs(vl &count,ll now,vvl &vec){
        visit[now]++;
        rep(i,Size(vec[now])){
            if(visit[vec[now][i]]!=0)continue;
            count[vec[now][i]]+=count[now];
            dfs(count,vec[now][i],vec);
        }
        return;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,q;
        cin>>n>>q;
        vvl vec(n,vl(0));
        vl count(n,0);
        rep(i,n-1){
            ll a,b;
            cin>>a>>b;
            a--;b--;
            vec[a].pb(b);
            vec[b].pb(a);
        }
        rep(i,q){
            ll p,x;
            cin>>p>>x;
            p--;
            count[p]+=x;
        }
        dfs(count,0,vec);
        rep(i,n)cout<<count[i]<<endl;
    }


Measured memory_bytes: 46208
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int n, k;
        scanf("%d %d", &n, &k);
        getchar();
        char prev = '1';
        int cnt = 0;
        V a;
        rep(i, 0, n){
                char c = getchar();
                if(prev==c) cnt++;
                else {
                        a.push_back(cnt);
                        cnt = 1;
                }
                prev = c;
        }
        a.push_back(cnt);
        if(prev=='0') a.push_back(0);

        if(a.size()<k*2+1){
                ll ans = 0;
                for(ll x: a) ans += x;
                printf("%ld\n", ans);
                return 0;
        }

        ll ans = 0;
        rep(i, 0, a.size()-k*2){
                ll tmp = 0;
                rep(j, i, i+k*2+1){
                        tmp += a[j];
                }
                ans = std::max(ans, tmp);
                i++;
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 1400
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt().let { if (it == 1) 14 else it }
    val b = sc.nextInt().let { if (it == 1) 14 else it }
    println(when {
        a == b -> "Draw"
        a > b -> "Alice"
        else -> "Bob"
    })
}

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

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  998244353;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;
string s = "";

void solve(){
    cin>>n;
    while(n){
        n -= 1;
        s += n%26 + 'a';
        n /= 26;
    }
    reverse(s.begin(), s.end());
    deb1(s)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 3648
def main():
    import sys
    buf = sys.stdin.buffer

    class SegmentTree:
        def __init__(self, target, no_effect):
            target_size = len(target)
            leaves_size = 1
            while leaves_size < target_size:
                leaves_size *= 2
            self.tree_size = leaves_size * 2 - 1
            self.to_leaf = self.tree_size//2
            self.tree = [no_effect] * self.tree_size
            self.no_effect = no_effect
            self.initialize_tree(target)

        @classmethod
        def initialize_func(cls, value):
            return 1 << (ord(value) - 97)

        @classmethod
        def merge_func(cls, a, b):
            return a | b

        def merge_child_data(self, node):
            child1 = node * 2 + 1
            child2 = node * 2 + 2
            return self.merge_func(self.tree[child1], self.tree[child2])

        def initialize_tree(self, target):
            initial_leaf = self.tree_size // 2
            leaves = range(initial_leaf, initial_leaf+len(target))
            for value, leaf in zip(target, leaves):
                self.tree[leaf] = self.initialize_func(value)

            for parent in range(initial_leaf-1, -1, -1):
                self.tree[parent] = self.merge_child_data(parent)

        def update(self, new_value, index):
            leaf = self.tree_size//2 + index
            new_data = self.initialize_func(new_value)
            if self.tree[leaf] == new_data:
                return
            self.tree[leaf] = new_data

            parent = (leaf-1) // 2
            while parent >= 0:
                new_data = self.merge_child_data(parent)
                if self.tree[parent] == new_data:
                    break
                self.tree[parent] = new_data
                parent = (parent-1) // 2

        def resolve_query(self, _from, to):
            result = self.no_effect
            left, right = _from + self.to_leaf, to + self.to_leaf
            while left <= right:
                result = self.merge_func(result, self.tree[left])
                result = self.merge_func(result, self.tree[right])
                left //= 2
                right = right//2 - 1

            return bin(result).count('1')

    n, S, _, *queries = buf.read().split()
    S = S.decode()
    seg_tree = SegmentTree(target=S, no_effect=0)

    for type, a, b in zip(*[iter(queries)]*3):
        if type == b'1':
            index, new = int(a)-1, b
            seg_tree.update(new, index)

        elif type == b'2':
            _from, to = int(a)-1, int(b)-1
            print(seg_tree.resolve_query(_from, to))


if __name__ == '__main__':
    main()

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	if(((n/100)-7)*(((n/10)%10)-7)*((n%10)-7)==0){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

struct edge{ int to,cost; };

const int INF = 1e9+7;

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

    vector<pi> a(n),b(n);
    rep(i,n){
        cin >>a[i].fi;
        a[i].se = i;
    }
    rep(i,n){
        cin >>b[i].fi;
        b[i].se = i;
    }

    sort(all(a));
    sort(all(b));

    vector<vector<edge>> G(n);
    rep(i,n-1){
        int u = a[i].se, v = a[i+1].se;
        int d = a[i+1].fi-a[i].fi;
        G[u].pb({v,d});
        G[v].pb({u,d});
    }
    rep(i,n-1){
        int u = b[i].se, v = b[i+1].se;
        int d = b[i+1].fi-b[i].fi;
        G[u].pb({v,d});
        G[v].pb({u,d});
    }

    vector<int> d(n,INF);
    d[0] = 0;
    priority_queue<pi, vector<pi>, greater<pi>> pq;
    pq.push({0,0});
    while(!pq.empty()){
        pi c = pq.top();
        pq.pop();
        int v = c.se;
        if(c.fi > d[v]) continue;
        for(const auto &e:G[v]){
            if(d[e.to] > d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                pq.push({d[e.to],e.to});
            }
        }
    }

    rep(i,n) cout << d[i] << "\n";
    return 0;
}



Measured memory_bytes: 13448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl

void solve(){
	int n; cin>>n;
	vi A(n);
	rep(i,0,n-1) cin>>A[i]; 
  
    int XOR = 0; 
    for (int i = 0; i < n; i++) 
        XOR ^= A[i]; 
  
    for (int i = 0; i < n; i++) 
        A[i] = XOR ^ A[i];
        
	rep(i,0,n-1) cout << A[i] << " "; 
}

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;


int main() {
    long long n, d, a;
    priority_queue<pair<long long, long long>> q;
    cin >> n >> d >> a;
    vector<pair<long long, long long>> v;

    for(int i=0; i<n; i++) {
        long long x, h;
        cin >> x >> h;
        v.push_back({x, h});
    }    
    sort(v.begin(), v.end());

    long long num = 0;
    long long count = 0;
    for(int i=0; i<n; i++) {
        while(!q.empty()) {
            pair<long long, long long> f = q.top();
            long long loc = -(f.first);
            long long tmp = (f.second);
            if(loc <= v[i].first) {
                num = num - tmp;
                q.pop();
            } else {
                break;
            }
        }

       // cout << v[i].first << " " << num << " " << count << "\n";
        long long cur = v[i].second;
        cur = cur - (num * a);
        if(cur < 0) {
            continue;
        }
        else {
            long long req = (cur + a - 1) / a;
            num = num + req;
            count = count + req;
            q.push({-(v[i].first + (2 * d) + 1), req});
        }
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 7404
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N), F(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        cin >> F[i];
    }

    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());

    // (l, r]
    ll l = -1, r = 1000000LL * 1000000LL;
    while(r - l > 1){
        ll mid = (l + r) / 2;

        ll used = 0;
        for(int i=0;i<N && used <= K;i++){
            if(A[i] * F[i] > mid){
                ll need = mid / F[i];
                assert(need < A[i]);
                used += A[i] - need;
            }
        }
        if(used <= K){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	return __gcd(a,b);
}
int main()
{
	long long ans=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				ans+=gcd(gcd(i,j),k);
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
M, D = map(int, input().split())

count=0
if D<=10:
  print(0)
else:
  for m in range(1,M+1):
    for d in range(22,D+1):
      a = int(str(d)[-1])
      b = int(str(d)[-2])
      if a>=2:
      	if m==a*b:
        	count+=1
  print(count)



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

int main() {
	int l, a, b, c, d, s, t;
	cin >> l >> a >> b >> c >> d;
	
	if (a % c)
		s = a / c + 1;
	else
		s = a / c;
	if (b % d)
		t = b / d + 1;
	else
		t = b / d;
	
	if (s > t)
		cout << l - s << endl;
	else
		cout << l - t << endl;
	
	return 0;
}

Measured memory_bytes: 3076
import sys

sys.setrecursionlimit(10 ** 7)

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

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

if N == 2:
    print(A[0])
    exit()
elif N == 3:
    print(A[0] + A[1])
    exit()

ans = A[0]
N -= 2

for i in range(1, N):
    if N == 0:
        break
    a = A[i]
    c = min(2, N)
    ans += a * c
    N -= c

print(ans)


"""
if N == 2:
    print(A[0])
    exit()
elif N == 3:
    print(A[0] + A[1])
    exit()

ans = sum(A[:-2]) + A[1]
print(ans)
"""


Measured memory_bytes: 31496
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N,Ma,Mb;
  cin>>N>>Ma>>Mb;
  vector<int>  a(N),b(N),c(N);
  for(int i=0;i<N;i++) cin>>a[i]>>b[i]>>c[i];

  int dp[41][500][500];
  for(int i=0;i<=N;i++){
    for(int j=0;j<500;j++){
      for(int k=0;k<500;k++){
        dp[i][j][k]=1e9;
      }
    }
  }
  dp[0][0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<410;j++){
      for(int k=0;k<410;k++){
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  int ans=1e9;
  for(int i=1;i<410;i++){
    for(int j=1;j<410;j++){
      if(i*Mb==j*Ma) ans=min(ans,dp[N][i][j]);
    }
  }
  
  if(ans==1e9) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n, x;
    cin >> n;
    
    long long left = 0;
    priority_queue<int, vector<int>, greater<int>> left_que;
    for (int i = 0; i < n; i++) {
        cin >> x;
        left += x;
        left_que.push(x);
    }

    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    long long right = 0;
    priority_queue<int> right_que;
    for (int i = 0; i < n; i++){
        cin >> x;
        right += x;
        right_que.push(x);
    }

    vector<long long> ans(n + 1, 0);
    
    ans[0] += left;
    for (int i = 0; i < n; i++){
        left += a[i];
        left_que.push(a[i]);
        left -= left_que.top(); left_que.pop();
        ans[i + 1] += left;
    }

    ans[n] -= right;
    for (int i = n - 1; i >= 0; i--){
        right += a[i];
        right_que.push(a[i]);
        right -= right_que.top(); right_que.pop();
        ans[i] -= right;
    }

    cout << *max_element(ans.begin(), ans.end()) << endl;
}

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

using namespace std;

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

#define ri(X) scanf("%d", &(X))
#define rii(X, Y) scanf("%d%d", &(X), &(Y))
#define riii(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))

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

int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    if(n==1) {
    	if(a==b) cout << 1 << endl;
    	else cout << 0 << endl;
    	return 0;
    } else if(a>b) {
    	cout << 0 << endl;
    	return 0;
    }

    ll bot = (n-1) * a + b;
    ll top = (n-1) * b + a;

    ll ans = top - bot + 1;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numMon = scanner.nextInt();
        int special = scanner.nextInt();
        int[] hps = new int[numMon];
        for(int i = 0; i < numMon; i++) {
            hps[i] = scanner.nextInt();
        }
        scanner.close();

        Arrays.sort(hps);
        int removeNum = Math.min(special, numMon);
        long remainSum = 0;
        for(int i = 0; i < numMon-removeNum; i++) {
            remainSum += hps[i];
        }

        System.out.println(remainSum);
    }
}


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

#define BR "\n"
#define SP " "

int main() {
  ll N, M;
  cin >> N >> M;

  vector<vector<ll>> A(N, vector<ll>(M, 0));
  vector<ll> B(M);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }

  for (int i = 0; i < N; i++) {
    ll ans = 0;
    for (int j = 0; j < M; j++) {
      ans += A[i][j] * B[j];
    }
    cout << ans << BR;
  }

  return 0;
}


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

using namespace std;

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

  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int res = 1e9;
  for (int i = 0; i < (1 << (2 * n)); i++) {
    int x = 0, y = 0, z = 0, cost = 0;
    for (int j = 0; j < n; j++) {
      int mask = (1 << (2 * j)) | (1 << (2 * j + 1));
      int id = (i & mask) >> (2 * j);
      if (id == 1) x += h[j];
      if (id == 2) y += h[j];
      if (id == 3) z += h[j];
      if (id != 0) cost += 10;
    }
    if (x == 0 || y == 0 || z == 0) continue;
    cost += abs(a - x);
    cost += abs(b - y);
    cost += abs(c - z);
    res = min(res, cost - 30);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
# ABC115C - Christmas Eve
def main():
    n, k = list(map(int, input().rstrip().split()))
    lst = sorted(list(map(int, [input().rstrip() for _ in range(n)])))
    ans = lst[k - 1] - lst[0]
    for i, j in zip(lst, lst[k - 1 :]):
        ans = min(ans, j - i)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14236
using System;

namespace ITP_6_D{
    public class Program{
        public static void Main(string[] args){
            string temp = Console.ReadLine();
            string[] data = temp.Split(' ');
            int retu = int.Parse(data[0]);
            int gyou = int.Parse(data[1]);

            int[][] gyouretu = new int[retu][];
            int[] vector = new int[gyou];

            //???????????±?????????
            for(int i=0; i<retu; i++){
                string[] gyouString = Console.ReadLine().Split(' ');
                int k = 0;
                gyouretu[i] = new int[gyou];
                for (k=0; k<gyou; k++){
                    gyouretu[i][k] = int.Parse(gyouString[k]);
                }
            }
            //?????????????????±????????????
            for(int i=0; i<gyou;i++ ){
                vector[i] = int.Parse(Console.ReadLine());
            }

            //?¨????
            for(int i=0; i<retu; i++){
                int answer = 0;
                for(int k=0; k<gyou; k++){
                    answer += gyouretu[i][k] * vector[k];
                }
                Console.WriteLine(answer);
            }
        }
    }
}

Measured memory_bytes: 9304
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main(int argc, const char * argv[]) {
    int y,x;
    scanf("%d%d",&x,&y);
    for(int i=0;i<=200;i++){
        for(int j=0;j<=200;j++){
            if(i*2+j*4==y&&i+j==x){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    
    
    return 0;
}


Measured memory_bytes: 1732
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
war = True
for i in range(X+1,Y+1) :
        if x[-1] < i and y[0] >= i :
                        war = False
if war == True :
        print('War')
else :
        print('No War')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;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 pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#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 all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


int dp[404][404], cum[404];
int func(int l,int r) {
	if (dp[l][r] != 0)return dp[l][r];
	ll ans = INF;
	if (l == r) {
		dp[l][r] = 0;
		return 0;
	}
	if (r == l + 1) {
		dp[l][r] = 0;
		return 0;
	}
	FOR(j, l+1, r) {
		int res = func(l, j) + func(j, r) + cum[r] - cum[l];
		ans = min(ans, res);
	}
	dp[l][r] = ans;
	return ans;
}
int a[404];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	REP(i, N) {
		cin >> a[i];
		cum[i + 1] = cum[i] + a[i];
	}
	print(func(0, N));
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <vector>
using namespace std;

const long long mod = 1000000007;
long long inv[100100] = { 0,1 }, fact[100100] = { 1,1 }, ifact[100100] = { 1,1 };
long long comb(int n, int k)
{
	if (n < 0 || k < 0 || k > n) return 0;
	return fact[n] * ifact[n - k] % mod;
}

int n, k;
vector<int> g[100100];

long long count(int x, int l)
{
	long long r = 1;

	int c = 0;
	for (auto &y : g[x]) if (y != l){
		r = r * count(y, x) % mod; c++;
	}
	r = r * comb(k - 1 - (l > 0), c) % mod;
	
	return r;
}

int main()
{
	for (int i = 2; i < 100100; i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i - 1] * i % mod;
		ifact[i] = ifact[i - 1] * inv[i] % mod;
	}

	scanf ("%d %d", &n, &k);
	for (int i = 1; i < n; i++){
		int x, y; scanf ("%d %d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}

	printf ("%lld\n", count(1, 0) * k % mod);

	return 0;
}


Measured memory_bytes: 12800
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
h = "";
i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n, k;
	cin >> n >> k;
	cout << mod_pow(k, n, Mod) << endl;
}


Measured memory_bytes: 3088
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        int[] barr = new int[n];
        for(int i = 0; i < n; i++) {
            barr[i] =scanner.nextInt();
        }
        int sz = 51;
        int maxMask = 1 << n;
        int[][] dp = new int[maxMask][sz];
        for(int[] dd: dp) Arrays.fill(dd, Integer.MAX_VALUE/3);
        int[][] swapVals = new int[n][n];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j< n; j++) {
                swapVals[i][j] = (i % 2 == j % 2) ? arr[j] : barr[j];
            }
        }
        dp[0][0] = 0;
        for(int mask = 0; mask < maxMask; mask++) {
            //position corresponds the number of bits that are highlighted in the mask
            int ind = Integer.bitCount(mask);
            for(int val = 0; val < sz; val++) {
                int cost = 0;
                for(int i = 0;i < n; i++) {
                    if(((1 << i) & mask) > 0) continue;
                    //which face is the card that i can put here?
                    //and is it greater than my prev?
                    if (swapVals[ind][i] >= val) dp[mask | (1 << i)][swapVals[ind][i]] = Math.min(dp[mask][val] + cost, dp[mask|(1<<i)][swapVals[ind][i]]);
                    cost++;
                }
            }
        }
        int ans = Integer.MAX_VALUE/3;
        maxMask--;
        for(int i = 0; i < sz; i++) {
            ans= Math.min(ans, dp[maxMask][i]);
        }
        out.println(ans == Integer.MAX_VALUE/3 ? -1 : ans);
        out.flush();
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

using namespace std;

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

	int n;  cin >> n;
    bool ch = 0;

	while(n--)  {
		int x;  cin >> x;
        ch |= (x & 1);
    }
  	
  	puts(ch ? "first" : "second");
}

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

int main() {
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i, n) for(int i = 0; i < n; i++)

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

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

int main()
{
	int n;
	cin >> n;
	vector <vector<int> > a(n, vector<int>(3, 0));
	rep(i, n) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}

	vector<vector<ll> > dp(n + 1, vector<ll>(3, 0));  //初期化  i日目
	//初期条件済
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (k == j)  continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	ll ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
	cout << ans << endl;
}

Measured memory_bytes: 11136
n = int(input())
from collections import defaultdict as dd
Dic = dd(lambda: 0)
for i in range(n):
  Dic[input()] += 1
#Lis = [[key, value] for (key, value) in zip(Dic.keys(), Dic.values())]
#print(Lis)

max_val = max(Dic.values())
Cands = [key for key, value in zip(Dic.keys(), Dic.values()) if value == max_val]
Cands.sort()
print(*Cands, sep="\n")

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

x = 100000
n = int(input())

for i in range(n):
    x = x + x*0.05
    a = x // 1000
    r = x % 1000
    if r != 0:
        x = 1000*a + 1000
    else:
        x = 1000*a
        
print(int(x))

Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    ll N , K;
    cin >> N >> K;
    vector <ll> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    sort(H.begin() , H.end());
    ll T = N - K;
    ll attack = 0;
    for(int i = 0; i < T; i++){
        attack+=H.at(i);
    }
    cout << attack << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  ll red[a];
  ll green[b];
  ll colorless[c];
  for (ll i = 0; i < a; i++) {
    cin >> red[i];
  }
  for (ll i = 0; i < b; i++) {
    cin >> green[i];
  }
  for (ll i = 0; i < c; i++) {
    cin >> colorless[i];
  }
  sort(red,red+a,greater<int>());
  sort(green,green+b,greater<int>());
  sort(colorless,colorless+c,greater<int>());
  vector<ll> v;
  for (ll i = 0; i < x; i++) {
    v.push_back(red[i]);
  }
  for (ll i = 0; i < y; i++) {
    v.push_back(green[i]);
  }
  for (ll i = 0; i < c; i++) {
    v.push_back(colorless[i]);
  }
  ll sum=0;
  sort(v.rbegin(),v.rend());
  for (ll i = 0; i < x+y; i++) {
    sum+=v[i];
  }
  cout << sum;


}


Measured memory_bytes: 8560
#include <stdio.h>

int main()
{
    int		a, b, out;
    char	op;

    while(1)
    {
	scanf("%d %c %d", &a, &op, &b);

	if ( op == '?' )
	{
	    break;
	}

	switch (op){
	case '+':
	    out = a + b;
	    break;
	case '-':
	    out = a - b;
	    break;
	case '*':
	    out = a * b;
	    break;
	case '/':
	    out = a / b;
	    break;
	}
	printf("%d\n", out);
    }
}
	    

Measured memory_bytes: 1028
#include <cstdio>
#include <algorithm>
#include <vector>

int testcase_ends() {
  size_t n;
  int m;
  scanf("%zu %d", &n, &m);
  if (n == 0 && m == 0) return 1;

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  std::vector<int> b;
  for (size_t i = 0; i < n; ++i)
    for (size_t j = 0; j < i; ++j)
      b.push_back(a[i]+a[j]);

  std::sort(b.begin(), b.end());
  auto it = std::upper_bound(b.begin(), b.end(), m);
  if (it == b.begin()) return puts("NONE"), 0;
  printf("%d\n", *--it);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 6356
#include<iostream>
#include<string>
using namespace std;
int main(){
	char s;
	int i=0,a[127];
	for (int j = 7; j < 123; j++)
		a[j] = 0;
	while (cin >> s){
		if (s < 'a')
			a[s + 32]++;
		else a[s]++;
	}
	
	for (i = 97; i < 123; i++)
		cout  << (char)i << " : " << a[i] << endl;

	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main(){
    int n, a, b, c, d;
    while(scanf("%d", &n) != EOF){
        int counter = 0;
        for(a = 0; a < 10; ++a){
            for(b = 0; b < 10; ++b){
                for(c = 0; c < 10; ++c){
                    for(d = 0; d < 10; ++d){
                        if(a + b + c + d == n){
                            ++counter;
                        }
                    }
                }
            }
        }
        printf("%d\n", counter);
    }
    return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(" ").map(String::toInt)
    val nodes = Array(n) { Node() }
    for (i in 1.until(n)) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        nodes[b - 1].parent = nodes[a - 1]
    }
    for (i in 1..q) {
        val (p, x) = readLine()!!.split(" ").map(String::toInt)
        nodes[p - 1].num += x
    }

    nodes.forEach { it.addParent() }
    println(nodes.joinToString(" ") { String.format("%.0f", it.num) })
}

class Node () {
    var num: Double = 0.0
    var parent: Node? = null

    fun addParent() {
        if (this.parent != null) {
            this.num += this.parent!!.num
        }
    }
}

Measured memory_bytes: 138112
#include "bits/stdc++.h"

#define rep(loop, N) for (int loop = 0; loop < N; loop++)
using namespace std;

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_November_30(void) {

	int M1, D1, M2, D2; cin >> M1 >> D1 >> M2 >> D2;

	cout << (M1 != M2 ? 1 : 0) << endl;
	return;
}

void B_Tax_Rate(void) {

	int N; cin >> N;

	for (int X = int(N / 1.08); X <= N; X++) {
		if (int(X * 1.08) == N) {
			cout << X << endl;
			return;
		}
	}
	cout << ":(" << endl;
	return;
}

void C_100_to_105(void) {

	int X; cin >> X;
	
	cout << (X % 100 <= X / 100 * 5) << endl;
	return;
}

int main(void) {

	//A_November_30();
	//B_Tax_Rate();
	C_100_to_105();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cassert>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

const int inf = 1e9;

int D;
VI c;
VVI s;
VI lastday;

VI calc_scores(const VI &t) {
	VI scores(D, 0);
	VI lastday(26, 0);

	int score = 0;
	for (int i = 0; i < D; i++) {
		int day = i + 1;
		int contest = t[i] - 1;
		lastday[contest] = day;
		score += s[i][contest];

		for (int j = 0; j < 26; j++) {
			score -= c[j] * (day - lastday[j]);
		}
		scores[i] = score;
	}

	return scores;
}

int calc_day(int day, int contest) {
	int ret = s[day][contest];
	for (int i = 0; i < 26; i++) {
		if (i != contest) {
			ret -= c[i] * (day - lastday[contest]);
		}
	}

	return ret;
}

int calc_day_greedy(int day) {
	int contest = -1;
	int maxi = -inf;

	for (int i = 0; i < 26; i++) {
		auto tmp = calc_day(day, i);
		if (tmp > maxi) {
			maxi = tmp;
			contest = i;
		}
	}

	return contest;
}

VI solve_simple() {
	VI t(D, 1);

	return t;

}

VI solve() {
	VI scores(D, 0);
	VI t(D, -1);

	for (int i = 0; i < D; i++) {
		int contest = calc_day_greedy(i);
		// printf("i %3d, contest %d\n", i, contest);
		t[i] = contest + 1;
		assert(0 <= contest && contest < 26);
	}

	return t;

}

int main() {
	cin >> D;

	c.assign(26, 0);
	for (int i = 0; i < c.size(); i++) {
		cin >> c[i];
	}
	s.assign(D, VI(26, 0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < s[i].size(); j++) {
			cin >> s[i][j];
		}
	}
	lastday.assign(26, 0);

	VI t = solve();

	// auto scores = calc_scores(t);
	// for (auto x: scores) {
	// 	cout << x << endl;
	// }

	for (auto x: t) {
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 3244
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<vector>
#include<utility> 
#include<queue> 
#include<algorithm>
using namespace std;
long long a[1005],b[1005],c[1005],d[1005],e[1005],f[1005],dir[5]={-1,0,1,0,-1};
bool used[3005][3005]={0},up[3005][3005]={0},down[3005][3005]={0},left[3005][3005]={0},right[3005][3005]={0}; 
vector<long long> x,y;
queue<pair<long long,long long>> que;
long long id_x(long long v){
	return lower_bound(x.begin(),x.end(),v)-x.begin();
}
long long id_y(long long v){
	return lower_bound(y.begin(),y.end(),v)-y.begin();
}
int main(){
	x.emplace_back(100000000000000000);
	x.emplace_back(-100000000000000000);
	y.emplace_back(100000000000000000);
	y.emplace_back(-100000000000000000);
	long long i,j,n,m;
	scanf("%lld%lld",&n,&m);
	for(i=0;i<n;i++){
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
		x.emplace_back(a[i]);
		x.emplace_back(b[i]);
		y.emplace_back(c[i]);
	}
	for(i=0;i<m;i++){
		scanf("%lld%lld%lld",&d[i],&e[i],&f[i]);	
		x.emplace_back(d[i]);
		y.emplace_back(e[i]);
		y.emplace_back(f[i]);
	}
	x.emplace_back(0);
	y.emplace_back(0);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	x.erase(unique(x.begin(),x.end()),x.end());
	y.erase(unique(y.begin(),y.end()),y.end());
	for(i=0;i<n;i++){
		a[i]=id_x(a[i]);
		b[i]=id_x(b[i]);
		c[i]=id_y(c[i]);
		for(j=a[i];j<b[i];j++){
			up[j][c[i]-1]=1;
			down[j][c[i]]=1;
		}
	}
	for(i=0;i<m;i++){
		d[i]=id_x(d[i]);
		e[i]=id_y(e[i]);
		f[i]=id_y(f[i]);
		for(j=e[i];j<f[i];j++){
			right[d[i]-1][j]=1;
			left[d[i]][j]=1;
		}
	}
	que.push({id_x(0),id_y(0)});
	used[id_x(0)][id_y(0)]=1;
	while(que.size()){
		auto z=que.front();
		que.pop();
		for(i=0;i<4;i++){
			if((!i&&left[z.first][z.second])||(i==1&&up[z.first][z.second])||(i==2&&right[z.first][z.second])||(i==3&&down[z.first][z.second]))
				continue;
			long long r=z.first+dir[i],c=z.second+dir[i+1];
			if(r<0||c<0||r>=(int)x.size()||c>=(int)y.size()||used[r][c])
				continue;
			used[r][c]=1;
			que.push({r,c});
		} 
	}
	for(i=0;i<(int)x.size();i++){
		if(used[i][0]||used[i][y.size()-1]){
			puts("INF");
			return 0;
		}
	}
	for(i=0;i<(int)y.size();i++){
		if(used[0][i]||used[x.size()-1][i]){
			puts("INF");
			return 0;
		}
	}
	long long ans=0;
	for(i=0;i<(int)x.size()-1;i++)
		for(j=0;j<(int)y.size()-1;j++)
			if(used[i][j])
				ans+=(x[i+1]-x[i])*(y[j+1]-y[j]);
	printf("%lld\n",ans);
}


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

int main() {
  int N, c, i;
  cin >> N;
  c = 0;
  for (i = 0;i < N;i++) {
    string color;
    cin >> color;
    if (color == "Y") c++;
}
  if (c == 0) cout << "Three" << endl;
  else cout << "Four" << endl;
}

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

int main()
{
	int n;
	long long ans=0LL;
	cin>>n;
	for(int i=1; i*i<=n; i++)
	{
		for(int j=i; j<=n/i+1; j++)
		{
			int k=i*j;
			if(k<=n)
			{
				if(i==j)
					ans+=k;
				else
					ans+=k*2;
			}
		}
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
    int a , b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;

  Solver(LL n) : n(n){};

  void solve() {
    LL digit = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
      LL c, d;
      cin >> d >> c;
      digit += c;
      sum += c * d;
    }
    cout << digit - 1 + (sum - 1) / 9 << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#define INF 1000001LL
#define INF2 100000001000000LL
using namespace std;

typedef long long ll;
typedef vector<ll> cord;

#define N 100000

ll dis(cord &a, cord &b){
  if(a.size() != b.size())return INF;
  ll res = 0;
  for(int i=0;i<a.size();i++)res += (a[i]-b[i]) * (a[i]-b[i]);
  return res;
}

struct KDTree{
  int n,d;
  vector<cord> v,tmp;

  void merge(int l,int r,int &k){
    if(r-l<=1)return;
    int mid = (l+r)/2;
    
    merge(l,mid,k); merge(mid,r,k);
    int x=l,y=mid,pos=l;

    while(x<mid && y<r){
    if(v[x][k]>v[y][k])tmp[pos++] = v[y++];
    else tmp[pos++] = v[x++];
    }
    while(x<mid)tmp[pos++] = v[x++];
    while(y<r)tmp[pos++] = v[y++];
    
    for(int i=l;i<r;i++)v[i] = tmp[i];
  }

  void compose(int l, int r, int depth){
    if(r-l<1)return;
    merge(l,r,depth);

    compose(l,(l+r)/2,(depth+1)%d);
    compose((l+r)/2+1,r,(depth+1)%d);
  }

  void search(int l,int r,vector<ll>& b, cord& p, int depth, ll& dist){
    if(r-l<1)return;

    int mid = (l+r)/2;
    ll tmp;
    dist = min(dist,dis(p,v[mid]));

    for(int i=0;i<d;i++){
      tmp = b[2*i]-p[i];
      if(tmp>0 && tmp*tmp >= dist)return;
      tmp = b[2*i+1]-p[i];
      if(tmp<0 && tmp*tmp >= dist)return;
    }

    for(int i=0;i<3;i++){
      if(p[depth]>v[mid][depth] && i==2)continue;
      if(p[depth]<=v[mid][depth] && i==0)continue;
      int f = i&1;
      tmp = b[2*depth+f];
      b[2*depth+f] = v[mid][depth]; 
      if(f)search(l,mid,b,p,(depth+1)%d,dist);
      else search(mid+1,r,b,p,(depth+1)%d,dist);
      b[2*depth+f] = tmp;
    }
  }
};

int n,q,m;
cord p(3),r(3);
KDTree kd;

int main(){
  vector<ll> box;
  for(int i=0;i<3;i++){
    box.push_back(-INF); 
    box.push_back(INF);
  }

  while(scanf("%d%d",&n,&q)!=EOF,n||q){
    kd.v.resize(n); kd.tmp.resize(n);
    kd.n = n; kd.d = 3;

    for(int i=0;i<n;i++){
      kd.v[i].resize(3);
      for(int j=0;j<3;j++)scanf("%lld",&kd.v[i][j]);
    }

    kd.compose(0,n,0);

    for(int i=0;i<q;i++){
      scanf("%d",&m);
      double ans = 0;
      ll now,prv;

      for(int j=0;j<3;j++)scanf("%lld",&p[j]);
      prv = INF2;
      kd.search(0,n,box,p,0,prv);

      for(int j=1;j<m;j++){
	for(int k=0;k<3;k++)scanf("%lld",&r[k]);
	now = INF2;
	kd.search(0,n,box,r,0,now);

	ans += min( sqrt(prv) + sqrt(now), sqrt(dis(p,r)) );
	prv = now; p = r;
      }
      printf("%.9lf\n",ans);
    }
  }
}

Measured memory_bytes: 11936