akhauriyash/Code-Regression huggingface dataset:
/* 
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int    int64_t
const int M = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
  //#endif
  int x,y,l,m,n,ai;
  cin>>x>>y>>l>>m>>n;
  vector <pair<int,int>> a;
  for(int i=1;i<=l;i++) {
    cin>>ai;
    a.push_back({ai,1});
  }
  for(int i=1;i<=m;i++) {
    cin>>ai;
    a.push_back({ai,2});
  }
  for(int i=1;i<=n;i++) {
    cin>>ai;
    a.push_back({ai,3});
  }
  sort(a.begin(),a.end());
  int cnt=x+y,ans=0;
  while(cnt&&!a.empty()) {
    if(x==0&&a.back().second==1) {
      a.pop_back();
      continue;
    }
    if(y==0&&a.back().second==2) {
      a.pop_back();
      continue;
    }
    cnt--;
    ans+=a.back().first;
    if(a.back().second==1)
      x--;
    if(a.back().second==2)
      y--;
    a.pop_back();
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 10348
def main(n: int, a_1: list, a_2: list):
    ans = 0

    for i in range(n):
        res = sum(a_1[: i + 1]) + sum(a_2[i:])

        if ans < res:
            ans = res

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a_1 = list(map(int, input().split()))
    a_2 = list(map(int, input().split()))

    main(n, a_1, a_2)



Measured memory_bytes: 3060
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        long N = int.Parse(str[0]);
        long M = int.Parse(str[1]);
        str = Console.ReadLine().Split(' ');
        long LR = 0;
        for(int i=0;i<N-1;i++){
            long D = long.Parse(str[i+1])-long.Parse(str[i]);
            LR = (LR + D*(i+1)%Define.mod*(N-1-i))% Define.mod;
        }
        str = Console.ReadLine().Split(' ');
        long UD = 0;
        for(int i=0;i<M-1;i++){
            long D = long.Parse(str[i+1])-long.Parse(str[i]);
            UD = (UD + D*(i+1)%Define.mod*(M-1-i))% Define.mod;
        }
        long ans = LR*UD % Define.mod;
        sb.Append(ans+"\n");
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 32732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using T = tuple<ll, ll, ll>;
constexpr int MOD = 1e9+7, MX = 200005;
int n;
ll t, d, e;
vector<int> G[MX];
T dfs(int p, int u){
	ll t1 = 0, d1 = 0, e1 = 2, t2, d2, e2;
	for(auto nx: G[u]) if(nx != p){
		tie(t2, d2, e2) = dfs(u,nx);
		t1 = (t1 * e2 + t2 * e1 + e2 - 1) % MOD;
		d1 = (d1 + d2 + e2 - 1) % MOD;
		e1 = e1 * e2 % MOD;
	}
	return T{t1, d1, e1};
}
ll inv(ll n){
	ll res = 1;
	for(ll e = MOD-2; e; e/=2,(n*=n)%=MOD) if(e%2) (res *= n) %= MOD;
	return res;
}
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		int v, u;
		scanf("%d%d", &v, &u);
		v--; u--;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	tie(t, d, e) = dfs(0,0);
	printf("%lld\n", (t - d + MOD) * inv(e) % MOD);
}

Measured memory_bytes: 26752
import java.util.*;



public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        final int A=scanner.nextInt();
        final int B=scanner.nextInt();
        final int C=scanner.nextInt();
        final String kString=scanner.next();
        int K=Integer.parseInt(kString.split("")[kString.length()-1]);
        if(K%2==0){
            System.out.println(A-B);
        }else{
            System.out.println(B-A);
        }

    }
}

Measured memory_bytes: 22612
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    int count = 0;

    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }

    for (int i = 1; i < n-1; i++) {
      if(p[i-1] < p[i] && p[i] < p[i+1] || p[i-1] > p[i] && p[i] > p[i+1]) count++;
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 20948
#include<stdio.h>
void BubbleSort(int array[],int N) //バブルソート(小さい順) O(N^2)
{
    int i, j, temp;
    for (i = 0;i < N - 1;i++) {
        for (j = 0;j < N - 1;j++) {
            if (array[j + 1] < array[j]) {
                temp = array[j];array[j] = array[j + 1];array[j + 1] = temp;
            }
        }
    }
}

int main()
{
  int N,L[110];
  scanf("%d",&N);
  for(int i=0;i<N;i++){scanf("%d",&L[i]);}
  
  int count=0,A,B,C;

  for(int a=0;a<N;a++){
    for(int b=a;b<N;b++){
      for(int c=b;c<N;c++){
        A = L[a]; B = L[b]; C = L[c];
        if(A==B || B==C || C==A) continue;
        if(A+B<=C || B+C<=A || C+A<=B) continue;
        count++;
      }
    }
  }
  printf("%d",count);
}

Measured memory_bytes: 1728
import sys
input = sys.stdin.readline


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.tree = [no_effect] * self.tree_size
        self.no_effect = no_effect
        self.initialize_tree(target, no_effect)

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

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

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

    def initialize_tree(self, target: list, no_effect=0):
        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.tree_size//2, to + self.tree_size//2
        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 = int(input())
S = input().replace('\n', '')
seg_tree = SegmentTree(target=S, no_effect=0)

Q = int(input())
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        index, new = int(query[1])-1, query[2]
        seg_tree.update(new, index)

    elif query[0] == '2':
        _from, to = int(query[1])-1, int(query[2])-1
        print(seg_tree.resolve_query(_from, to))


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    VSORT(a); VSORT(b); VSORT(c);
    vll bc(n);
    repr(i, n) {
        auto itr = lower_bound(all(c), b[i]+1);
        bc[i] = c.end() - itr;
        if (i < n-1) bc[i] += bc[i+1];
    }
    ll ans = 0;
    rep(i, n) {
        auto itr = lower_bound(all(b), a[i]+1);
        ans += bc[itr-b.begin()];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
a = [9, 99, 999, 9999, 99999, 999999]

str = input()
org = int(str)
c = len(str)

if c == 1:
  ans = org
elif c == 2:
  ans = a[0]
elif c == 3:
  ans = a[0] + org - a[1]
elif c == 4:
  ans = a[0] -a[1] + a[2]
elif c == 5:
  ans = a[0] -a[1] + a[2] - a[3] + org
else:
  ans = a[0] -a[1] + a[2] - a[3] + a[4]

print(ans)

Measured memory_bytes: 3064
//Never stop chasing!-MD.SOURAV.

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li              ong int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define MOD 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
 #define sex(a,b,n)   ( n>=a && n<=b)
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll>msll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

    int n,k;
    cin>>n>>k;
    vll v;
    enter(v,n);
    for(int i=k;i<n;i++)
	{
		if(v[i]>v[i-k])
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}



}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
   // cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 5300
import java.util.Scanner;


public class Main {



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		int min = n+1;
		for (int i=0;i<n;i++) {
			int p = sc.nextInt();
			if (p<min) {
				count++;
				min=p;
			}
		}
		System.out.println(count);
	}

}

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

using namespace std;

int main()
{
	int n;
	long long a[200000], s[200000], x = 1000000000000000000;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		s[i] = a[i] + (i ? s[i-1] : 0);
	}
	
	for (int i = 0; i < n-1; i++)
		x = min(x, abs(s[i]*2-s[n-1]));
		
	cout << x;
}

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

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  vector<mint> a(n);
  rep(i,n) cin >> a.at(i);

  mint sum=0;
  rep(i,n) sum+=a.at(i);

  mint ans=0;
  rep(i,n){
    sum-=a.at(i);
    ans += sum*a.at(i);
  }

  cout << ans;
  
}

Measured memory_bytes: 4792
from collections import defaultdict

n = int(input())
aa = tuple(map(int, input().split()))

x = {0: 1000}
for i in range(n):
    xx = defaultdict(int)
    for stock, money in x.items():
        xx[0] = max(xx[0], money + stock * aa[i])
        ns = money // aa[i]
        xx[stock + ns] = max(xx[stock + ns], money - ns * aa[i])
    x = xx
print(x[0])

Measured memory_bytes: 9460
#include <bits/stdc++.h>
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; }
const long long INF = 1LL << 60;

int main(){
  int N;
  long long h[100010];
  long long dp[100010];
  
  cin >> N;
  for(int i=0;i<N;i++) cin >> h[i];
  
  for(int i=0;i<100010;i++) dp[i] = INF;
  
  dp[0] = 0;
  
  for(int i=1;i<N;i++){
    chmin(dp[i], dp[i-1] + abs(h[i-1] - h[i]));
    if(i>1) chmin(dp[i], dp[i-2] + abs(h[i-2] - h[i]));
  }
  
  cout << dp[N-1] << endl;
  
  
}

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

int main() {
    int n, k, a;
    map<int, int> mp;
    pair<int, int> p[200010];

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a;
        mp[a]++;
    }

    int num = 0;
    for(auto u:mp) {
        p[num] = make_pair(u.second, u.first);
        num++;
    }

    sort(p, p+num);

    int t_num = num, ans = 0;
    for (int i = 0; i < num; i++) {
        if (t_num > k) {
            ans += p[i].first;
            t_num--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 14488
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

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

int main() {
	string S;
	cin >> S;
	string rev(S);
	reverse(rev.begin(), rev.end());
	double tmp = S.length() / 2.0;
	int end = std::ceil(tmp);
	int sum = 0;
	rep(i, end) {
		if (S[i] != rev[i]) sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int INF = 1000000000;
const int MOD = 1000000007;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

int n;
int a[11];
int p[11];

int main()
{
	
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	p[0] = 0, p[1] = 1, p[2] = 2;
	int ans = INF;
	while (1)
	{
		ans = min(ans, abs(a[p[0]]-a[p[1]])+abs(a[p[1]]-a[p[2]]));
		if (!next_permutation(p, p+3)) break;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        ans += max(0, V[i] - C[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s = [LIST() for i in range(M)]
p = LIST()

num = N
bits = product([0, 1], repeat=num)

co = 0
for x in bits:
	a = [0]*M
	for i in range(len(s)):
		for j in range(len(s[i]) - 1):
			if x[s[i][j + 1] - 1] == 1:
				a[i] += 1
	f = True
	for i in range(len(a)):
		if a[i]%2 == p[i]:
			pass
		else:
			f = False
	if f:
		co += 1

print(co)

Measured memory_bytes: 63980
#include <stdio.h>
 
#define MAX 25
 
typedef struct{
  int l,r,par;
} node;
 
node N[MAX];
 
void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);
 
int main(){
  int n,i,id,l,r;
  int p;
   
  scanf("%d" ,&n); 
  init(n);  
 
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);
 
    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }
 
  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
      p = i;
      break;
    }
  }
  
  puts("Preorder");
  Preorder(p);
  puts("");
 
  puts("Inorder");
  Inorder(p);
  puts("");
 
  puts("Postorder");
  Postorder(p);
  puts("");
 
  return 0;
}
 
void init(int n){
  int i;
 
  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}
 
void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}
 
void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}
 
void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#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;

struct Dinic{
	struct Edge{int to,cap,rev;};
	vector<vector<Edge>>G;
	vector<int>level,iter;
	void addEdge(int from,int to,int cap){
		G[from].push_back({to,cap,len(G[to])});
		G[to].push_back({from,0,len(G[from])-1});
	}
	void bfs(int s){
		fill(all(level),-1);
		level[s]=0;
		queue<int>que;que.push(s);
		while(len(que)){
			int p=que.front();que.pop();
			for(Edge e:G[p]){
				if(e.cap>0&&level[e.to]==-1){
					level[e.to]=level[p]+1;
					que.push(e.to);
				}
			}
		}
	}
	int dfs(int v,int t,int f){
		if(v==t)return f;
		for(int &i=iter[v];i<len(G[v]);i++){
			Edge &e=G[v][i];
			if(e.cap>0&&level[e.to]>level[v]){
				int d=dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					i++;
					return d;
				}
			}
		}
		return 0;
	}
	int maxFlow(int s,int t){
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			fill(all(iter),0);
			int f=0;
			while((f=dfs(s,t,mod))>0){
				flow+=f;
			}
		}
	}
	Dinic(int N):G(N),level(N),iter(N){}
};

int H,W;
char c[105][105];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char ans[105][105];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>H>>W;
	Dinic F(H*W+2);
	rep(i,H)rep(j,W){
		cin>>c[i][j];ans[i][j]=c[i][j];
		if((i+j)%2)F.addEdge(H*W,i*W+j,1);
		else F.addEdge(i*W+j,H*W+1,1);
	}
	rep(i,H)rep(j,W)if((i+j)%2&&c[i][j]=='.')rep(k,4){
		int nx=i+dx[k],ny=j+dy[k];
		if(nx<0||ny<0||nx>=H||ny>=W||c[nx][ny]=='#')continue;
		F.addEdge(i*W+j,nx*W+ny,1);
	}
	cout<<F.maxFlow(H*W,H*W+1)<<"\n";
	rep(i,H){
		rep(j,W){
			if(c[i][j]=='#'||(i+j)%2==0)continue;
			for(auto e:F.G[i*W+j])if(e.cap==0&&e.to/W<H){
				if(e.to/W==i-1){ans[i][j]='^';ans[i-1][j]='v';}
				else if(e.to/W==i+1){ans[i][j]='v';ans[i+1][j]='^';}
				else if(e.to%W==j-1){ans[i][j]='<';ans[i][j-1]='>';}
				else {ans[i][j]='>';ans[i][j+1]='<';}
				break;
			}
		}
	}
	rep(i,H){rep(j,W)cout<<ans[i][j];cout<<"\n";}
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#include<vector>
#include<set>
using namespace std;
int main()
{
	int x[3];
	for(int i=0;i<3;i++)
	{
		cin>>x[i];
	}
	int count=0;
	while(x[0]!=x[1]||x[0]!=x[2]||x[1]!=x[2])
	{
		sort(x,x+3);
		if(x[2]-x[0]>=2)
		{
			x[0]+=2;
			count++;
		}
		else
		{
			x[0]+=1;
			x[1]+=1;
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

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

int main(void){
    int n, wcnt[55][50];
    for(int i=0;i<55;++i) for(int j=0;j<50;++j) wcnt[i][j] = 0;
    cin >> n;
    string s[55];
    for(int i=0;i<n;++i) cin >> s[i];
    for(int i=0;i<n;++i){
        int len = s[i].size();
        for(int j=0;j<len;++j){
            int tar = s[i][j];
            ++wcnt[i][tar-97];
        }
    }
    for(int j=0;j<27;++j){
        int min = 10000;
        for(int i=0;i<n;++i){
            if(min > wcnt[i][j]) min = wcnt[i][j];
        }
        for(int i=0;i<min;++i){
            cout << (char)(j+97);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
   ll a;
   cin >> a;
   string s;
   cin >> s;
   if(a>=3200)cout << s;
   else cout << "red";
}

Measured memory_bytes: 256
import math
a,b,C = map(float,input().split())
C_rad=math.pi*C/180
print("{0:.8f}".format(math.sin(C_rad)*a*b/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C_rad))))
print("{0:.8f}".format(b*math.sin(C_rad)))

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

int main()
{
  ll n,m;
  cin >> n >> m;
  vector<pair<ll,ll> > v,d ;
  for(int i=0; i<n; i++)
  {
      ll a,b;
      cin >> a >> b;
      v.push_back({a,b});
  }for(int i=0; i<m; i++)
  {
      ll a,b;
      cin >> a >> b;
      d.push_back({a,b});
  }
  for(int i=0; i<n; i++)
  {
      ll x=v[i].first;
      ll y=v[i].second,mx=INT_MAX,pos;
      for(int j=0; j<m; j++)
      {
          ll a = d[j].first;
          ll b = d[j].second,dis;
          dis = abs(x-a) + abs(y-b);
          //cout << a << " " << b << endl;
        //  cout << dis << endl;
         if(dis<mx)
         {
             mx = dis;
             pos = j+1;
         }

      }
    //  cout << mx << endl;
      cout << pos << endl;
  }

}


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

int main(void){
    long double a,b,x;
    cin >> a >> b >> x;

    // xが容器の半分以上かどうかで場合分け
    long double ans;
    if(a*a*b/2 <= x){
        ans = atan(( (2*b) - ( (2*x)/(a*a) )) / a);
        ans = ans * (180.00000/PI);
    }
    else{
        ans = atan( (a*b*b) / (2*x) );
        ans = ans * (180.00000/PI);
    }

    cout << setprecision(11) << ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);

int main() {
    // source
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b;
	cin >> a >> b;

	cout << max({a + b, a - b, a * b}) << endl;
}

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

	solve();
}

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

void chaek(int *x,int *y,int w,int h){
  if(*x > w)*x = w;
  if(1 > *x)*x = 1;
  if(*y > h)*y = h;
  if(1 > *y)*y = 1;
}
int main(){
  int go,back;
  int w,h;
  while( cin >> w >> h, w + h ){
    int dx = 0,dy = 1;
    int px = 1,py = 1;
    string odr;
    for(;;){
      cin >> odr;
      if(odr[0] == 'F') {
	cin >> go;
	px += go*dx;
	py += go*dy;
	chaek(&px,&py,w,h);
      }else if(odr[0] == 'B') {
	cin >> back;
	px -= back*dx;
	py -= back*dy;
	chaek(&px,&py,w,h);
      }else if(odr[0] == 'R') {
	swap(dx,dy);
	  dy = -dy;
      }else if(odr[0] == 'L') {
	swap(dx,dy);
	dx = -dx;
      }else break;
    }
  cout << px << " " << py << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double A,B,C;
  cin>>A>>B>>C;
  long double a,b,c;
  a=sqrt(A)+0.00000000000001;
  b=sqrt(B)+0.00000000000001;
  c=sqrt(C)+0.00000000000001;
  if(a+b<c){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
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)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    string ans = "";
    if (S == "Sunny") {
        ans = "Cloudy";
    } else if (S == "Cloudy") {
        ans = "Rainy";
    } else {
        ans = "Sunny";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int left = a + b;
    int right = c + d;

    if (left > right){
        cout << "Left" << endl;
    }else if (left == right){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }

    return 0;
}




















Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int sum(int N) {
    int res = 0;
    while (N) {
        res += N % 10;
        N /= 10;
    }
    return res;
}

signed main() {
    int N;
    cin >> N;
    int ans = (sum(N) == 1 ? 10 : sum(N));
    cout << ans << endl;
    return 0;
}


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

int main(){
	long long X,use_limit,calc_mod;
	cin>>X;
	use_limit=X/100;
	
	if(X%100==0){
		cout<<1<<endl;
	}else{
		calc_mod=X%100;
		if(calc_mod%5==0 && calc_mod/5<=use_limit){
			cout<<1<<endl;
		}else if(calc_mod/5+1<=use_limit){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
	}
}


Measured memory_bytes: 256
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]

for j in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)
    

Measured memory_bytes: 118104
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n % 4 == 0){
    cout << "Yes" << endl;
  }else{
    if(((4 - (n % 4)) * 7) <= n){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
lst = [
    1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15,
    2, 2, 5, 4, 1, 4, 1, 51
]
print(lst[int(input()) - 1])


Measured memory_bytes: 2940
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

A,B = inm()

print(A*B-A-B+1)


Measured memory_bytes: 9004
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

  cout << ((s == "ABC") ? "ARC" : "ABC") << endl;
  return 0;
}

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

template<typename T>
istream &operator>>(istream &is, pair<T, T> &p) {
	return is >> p.first >> p.second;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m, k; cin >> n >> m >> k;
	vector<pair<int, int>> a(k); cin >> a;
	vector<int> m1(n), m2(m);
	for (int i = 0; i < k; i++) {
		a[i].first--;
		a[i].second--;
		m1[a[i].first]++;
		m2[a[i].second]++;
	}
	//cout << "slm" << endl;
	int mh = *max_element(m1.begin(), m1.end()), mw = *max_element(m2.begin(), m2.end());
	//cout << "slm2" << endl;
	int ans = mh + mw, num = count(m1.begin(), m1.end(), mh) * count(m2.begin(), m2.end(), mw);
	//cout << "slm2" << endl;
	for (int i = 0; i < k; i++) {
		if (m1[a[i].first] + m2[a[i].second] == mh + mw) num--;
	}
	cout << ans - (num == 0) << '\n';
	return 0;
}



Measured memory_bytes: 7932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[55];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int sum=0;
    sort(arr,arr+n);
    for(int i=0;i<k;i++){
        sum+=arr[n-1-i];
    }
    cout<<sum;
}


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

#define all(x) begin(x), end(x)
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll MOD = 1e9 + 7;
const int N = 200500; // are you sure?

void solve(){
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a+b+c<=21) System.out.println("win");
        else System.out.println("bust");
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
(function(stdin) {
  // Define Function

  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');
  const cols = inputs[0].split(' ').map(Number);

  // Main Procedure
  const result = (function(a, b, c) {

    return (a < b && b < c) ? 'Yes' : 'No';

  }(cols[0], cols[1], cols[2]));

  // Display
  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15480
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
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); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<"  "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)

map<int, int> mp;
int N;
int M;

int main() {
  cin >> N;
  REP(i,N) {
    int d; cin >> d;
    mp[d]++;
  }
  cin >> M;
  REP(i,M) {
    int d; cin >> d;
    mp[d]--;
    if (mp[d]<0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  double l[10];
  double v1, v2;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)==12) {
    double dis = 0;
    REP(i,10)
      dis += l[i];
    double t = dis/(v1+v2);
    double x = v1 * t;
    int j = 0;
    for (int i=0; i<10; i++) {
      j+=l[i];
      if (j>=x) {
        cout << i+1 << endl;
        break;
      }
    }
  }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(n+2);
    rep(i,m) {
        int a;
        cin >> a;
        broken[a+1] = 1;
    }
    vector<int> dp(n+2);
    const int mod = 1e9+7;
    dp[1] = 1;
    for (int i = 2; i <= n+1; i++) {
        if (broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i-1]+dp[i-2])%mod;
    }
    cout << dp[n+1] << endl;
    return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sign cout<<"-----------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll


signed main(){
  int a[3005];
  int n;
  cin>>n;
  int sum=0;
  for(int i=0; i<n; i++){
    cin>>a[i];
    sum+=a[i]-1;
  }
  cout<<sum<<en;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int H,N;

vector<int> fie;

vector<vector<int>> dp;

int dfs(int h,int state){
    if(h == H) return 0;
    if(dp[h][state] != -1) return dp[h][state];

    int ans = dfs(h + 1,fie[h]);

    for(int i = 0;i < 3;i++){
        if((state >> i) & 3) continue;
        if((fie[h] >> i) & 3) continue;
        ans = max(ans , dfs(h + 1,fie[h] | (3 << i)) + 1);
    }

    if(state == 0 && fie[h] == 0){
        ans = max(ans , dfs(h + 1,(1 << 4) - 1) + 2);
    }

    return dp[h][state] = ans;
}

int main(){
    cin >> H >> N;
    fie.resize(H);
    dp.resize(H,vector<int>((1 << 4),-1));
    rep(i,0,N - 1){
        int x,y;
        cin >> x >> y;
        fie[y] |= (1 << x);
    }

    cout << dfs(1,fie[0]) << endl;
}



Measured memory_bytes: 4732
from math import factorial

N = int(input())
li = [[int(zz) for zz in input().split()] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += ((li[i][0]-li[j][0])**2+(li[i][1]-li[j][1])**2)**(1/2)

print(ans*2/N)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rev(p) make_pair(p.second,p.first)
int main(){
  int N;
  cin>>N;
  vector<int> a(N,N*(N+1)/2);
  vector<pair<int,int>> vres;
  for(auto&& c:a)c-=&c-&a[0]+1;
  for(int S=a[N-1];S>=N;--S){
    vector<pair<int,int>> ans;
    vector<int> b=a;
    auto r = [&](int t){return b[t]-S;};
    for(int i=0;i<N;++i){
      if(b[i]==S)continue;
      if(r(i)==i+1)break;
      if(i+1==r(r(i)-1)){
        ans.push_back(make_pair(i+1,r(i)));
        b[i]=b[r(i)-1]=S;
      }
    }
    sort(b.begin(),b.end());
    if(b[0]==b[N-1]){vres=ans;break;}
  }
  int M = N*(N-1)/2 - vres.size();
  cout<<M<<"\n";
  map<pair<int,int>,bool> mres;
  for(auto&& c:vres){
    mres[c]=true;
    mres[rev(c)]=true;
  }
  for(int i=1;i<N;++i)for(int j=i+1;j<=N;++j){
    if(!mres[make_pair(i,j)])cout<<i<<" "<<j<<"\n";
  }
  cerr<<"er\n";
  for(auto&& c:vres){
    cerr<<c.first<<" "<<c.second<<"\n";
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int[] array = {0,2,0,1,0,1,0,0,1,0,1,0};
    if (array[a-1]==array[b-1]){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 25172
date=[[],[],[]]
a,b,c=0,0,0
while True:
   if a < 0 and b < 0 and c < 0:
      break
   else:
      a,b,c =[int(i) for i in input().split()]
      date[0].append(a)
      date[1].append(b)
      date[2].append(c)
for h in range(0,len(date[0])-1):
   if date[0][h] == -1 or date[1][h] == -1:
      print("F")
   elif date[0][h] == date[1][h] == date[2][h]:
      break
   else:
      if date[0][h] + date[1][h] >= 80:
         print("A")
      else:
         if date[0][h] + date[1][h] >= 65:
            print("B")
         else:
            if date[0][h] + date[1][h] >= 50:
               print("C")
            else:
               if date[0][h] + date[1][h] >=30:
                  if date[2][h] >= 50:
                     print("C")
                  else:
                     print("D")
               else:
                  print("F")

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

int main(){
  
  int a,b,c;
  cin >> a >> b;
  c = a * b;
  
  if(c % 2 == 0){
    cout << "Even" << endl;
  }else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }

int n;

vector<int> a;
int c[4];
ll sum = 1;


signed main() {
	
	cin >> n;
	a.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for(int i = 0; i < n; i++) {
		ll cnt = 0, id = -1;
		for(int j = 0; j < 3; j++) {
			if(a[i] == c[j]) {
				cnt++;
				id = j;
			}
		}

		if(id == -1) {
			cout << "0\n" ;
			return 0;
		}
		sum *= cnt;
		c[id]++;
		sum %= SMOD;
	}

	cout << sum << endl;

    return 0;
}



Measured memory_bytes: 640
N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)
C = sorted(map(int, input().split()), reverse=True)

Closed = [False] * (N+1)
q = [1]
A = [0] * (N)
Closed[1] = True
for c in C:
    v = q.pop()
    A[v-1] = c
    for u in E[v]:
        if not Closed[u]:
            q.append(u)
            Closed[u] = True
print(sum(C[1:]))

print(*A)


Measured memory_bytes: 6168