akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
int h,n,total;
cin>>h>>n;
total=0;
int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
for(int i=0;i<n;i++){
    total=total+arr[i];
}
if(total>=h)
    cout<<"Yes";
else
    cout<<"No";
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, K = MI()
P = LMI()
P.sort()
print(sum(P[:K]))

Measured memory_bytes: 62508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  string s;cin>>s;
  for(ll pos=0;pos<=n-3;++pos) if(s.substr(pos,3)=="ABC") ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
while 1:
	inp = raw_input()
	if inp == "0": break
	q1,b,c1,c2,q2 = map(int,inp.split())
	a1 = min(b/c1, q2)
	a2 = (b - a1*c1)/c2
	while a1 > 0  and (a1*c1 + a2*c2 > b or a1 + a2 < q1):
		a1 -= 1
		a2 = (b - a1*c1)/c2
	print "%d %d"%(a1,a2) if a1 > 0 else "NA"

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));
    int ans = 0;
    rep(i, k) ans += p[i];
    print(ans);




}



Measured memory_bytes: 3636
import sys
N,M = map(int,input().split())
if N>M:
    print(0)
    sys.exit()
Xs = sorted(list(map(int,input().split())))
ranges = sorted([abs(Xs[i]-Xs[i-1]) for i in range(1,len(Xs))],reverse=True)
ans = Xs[M-1]-Xs[0]
for n in range(N-1):
    ans-=ranges[n]
print(ans)

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

int main() {
  char c;
  cin >> c;

  if (c == 'a'){
      cout << "vowel" << endl;
  }
  else if (c == 'i'){
      cout << "vowel" << endl;
  }
  else if (c == 'u'){
      cout << "vowel" << endl;
  }
  else if (c == 'e'){
      cout << "vowel" << endl;
  }
  else if (c == 'o'){
      cout << "vowel" << endl;
  }
  else{
      cout << "consonant" << endl;
  }
}

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

int main(){

	typedef struct{
		double x, y;
	}_td;

	int n;
	_td p1, p2, p3, p4;
	double del, eps;
	eps = 10e-12;
	
	cin >> n;
	
	for(int i=0; i<n; i++){
		cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y;
		del = (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
		if(abs(del) < eps) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;

}

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

int main(void) {
  int x, n;
  cin >> x >> n;
  vector<int> ps(n);
  for (int &p : ps) cin >> p;

  // n == 0場合もあるる
  if (n == 0) {
    cout << x << endl;
    return 0;
  }

  int lower = -1;
  int upper = 0;
  while (true) {
    if (lower < -100 && upper > 100) break;

    auto result0 = find(ps.begin(), ps.end(), min(101, x + upper));
    if (result0 == ps.end()) {
      cout << min(101, x + upper) << endl;
      return 0;
    }
    upper += 1;
    
    auto result1 = find(ps.begin(), ps.end(), max(0, x + lower));
    if (result1 == ps.end()) {
      cout << max(0, x + lower) << endl;
      return 0;
    }
    lower -= 1;

  }

  return 0;
}

Measured memory_bytes: 3632
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll a,b;
	cin>>a>>b;
	if(a<=0&&b>=0)cout<<"Zero";else{
		ll dif=b-a+1;
		if(a>0)cout<<"Positive";else
		cout<<((dif%2==0)?"Positive":"Negative");
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  set<int> s;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if(h[a]<=h[b] and !s.count(a))
      s.insert(a);
    if(h[b]<=h[a] and !s.count(b))
      s.insert(b);
  }
  cout << n-s.size() << endl;
  return 0;
}


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

int main() {
  ll a,b;
  cin>>a>>b;
  string ans="Negative";
  if(a*b<0){
    ans="Zero";
  }else if(a>0){
    ans="Positive";
  }else{
    if((b-a)%2==1){
      ans="Positive";
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int fun(int a,int b){
	b=b%a;
	if(b==0) return a;
	else fun(b,a);
}

int main(){
	int a,b,gcd,mem;
	long long lcm;
	while(scanf("%d %d",&a,&b)!=EOF){
		if(a>b){
			mem=b;
			b=a;
			a=mem;
		}
		gcd=fun(b,a);
		lcm=a/gcd*b;
		printf("%d %lld\n",gcd,lcm);
	}

}

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

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

const int N = 100001;
int n, m, k, a, b;
int f[N];
int bcnt[N];
int fcnt[N];
int sz[N];

int find(int a) {
  if (f[a] == a)
    return a;
  return f[a] = find(f[a]);
}
void union_set(int i, int j) {
  int ri = find(i);
  int rj = find(j);
  if (ri != rj) {
    f[ri] = rj;
    sz[rj] += sz[ri];
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  iota(f, f + n, 0);
  fill(sz, sz + n, 1);
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    ++fcnt[a];
    ++fcnt[b];
    union_set(a, b);
  }
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    if (find(a) == find(b))
      ++bcnt[a], ++bcnt[b];
  }
  for (int i = 1; i <= n; ++i) {
    cout << sz[find(i)] - 1 - fcnt[i] - bcnt[i] << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3072
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr ll INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int r; cin>>r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 892
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int n, k;
	cin >> n >> k;
	vector<long> h(n), a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	a[0] = 0;
	for (int i = 1; i < k; ++i)
	{
		a[i] = abs(h[i] - h[i - 1]) + a[i - 1];
		for (int j = 2; j <= i; ++j)
		{
			auto tmp = abs(h[i] - h[i - j]) + a[i - j];
			if (a[i] > tmp)
			{
				a[i] = tmp;
			}
		}
	}
	for (int i = k; i < n; ++i)
	{
		a[i] = abs(h[i] - h[i - 1]) + a[i - 1];
		for (int j = 2; j <= k; ++j)
		{
			auto tmp = abs(h[i] - h[i - j]) + a[i - j];
			if (a[i] > tmp)
			{
				a[i] = tmp;
			}
		}
	}
	cout << a[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1920
N, K = map(int, input().split())
A = list(map(int, input().split()))

fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1) % 1000000007


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], 1000000005, 1000000007) * pow(fac[k], 1000000005, 1000000007) % 1000000007


A.sort(reverse=True)
result = 0
for i in range(N - K + 1):
    result += A[i] * mcomb(N - (i + 1), K - 1)
    result %= 1000000007

A.sort()
t = 0
for i in range(N - K + 1):
    t += A[i] * mcomb(N - (i + 1), K - 1)
    t %= 1000000007

result -= t
result %= 1000000007
print(result)


Measured memory_bytes: 14416
x = list(input())
first = 10 * int(x[0]) + int(x[1])
second = 10 * int(x[2]) + int(x[3])


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA")


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

int main() {
  int n; cin >> n;
  string ans = "No";
  for (int i = 1; i <= 9; i++) {
    if(n % i == 0 && 0 < n/i && n/i < 10) {
      ans = "Yes";
      break;
    }
  }
  cout << ans;
}

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

using namespace std;

using ull = unsigned long long;

int main() {
    int N, H[100000];
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> H[i];
    }
    for(int i = 1; i < N - 1; ++i) {
        if(H[i - 1] < H[i]) {
            H[i]--;
        }
        if(H[i + 1] < H[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

N = int(input())

def dfs(s):
	if int(s) > N:
		return 0
	ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1

	for c in '753':
		ret += dfs(s + c)
	return ret

print(dfs('0')) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
const ll LIM =1e9+7;

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}



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

    int n;cin>>n;
    string s; cin>>s;
    map<char,int> mp;
    mp['R']=1;
    mp['G']=1;
    mp['B']=1;
    rep(i,n){
        mp[s[i]]++;
    }
    ll ans =1;
    for(auto x:mp){
        ans *= x.second-1;
    }
    for(int gap=1; gap*2<=n+10;gap++){
        for(int p=0;p+2*gap<n;p++){
            int tmp = s[p]+s[p+gap]+s[p+2*gap];
            if(tmp==219)ans--;
        }
    }

    fin(ans);


}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n; string s, t;

	cin >> n >> s >> t;
	int ans = n + n;
	REPU(i, 0, n) {
		if (s.substr(i) == t.substr(0, n - i)) amin(ans, n + i);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val x = int()
    if (2 <= x && x <= 2*n - 2) {
        println("Yes")
        val ret = IntArray(n*2-1)
        if (n == 2) {
            ret[0] = 1
            ret[1] = 2
            ret[2] = 3
        } else if (x == 2) {
            ret[n-2] = 3
            ret[n-1] = 2
            ret[n] = 1
            ret[n+1] = 4
            var i = 5
            for (j in n*2-1) {
                if (j >= n-2 && j <= n+1) continue
                ret[j] = i++
            }
        } else {
            ret[n-2] = x-1
            ret[n-1] = x
            ret[n] = x+1
            ret[n+1] = x-2
            var i = 1
            for (j in n*2-1) {
                if  (i == x-2) i = x+2
                if (j >= n-2 && j<= n+1) continue
                ret[j] = i++
            }
        }
        for (i in 2*n-1) println(ret[i])
    } else {
        println("No")
    }
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 39488
#include "bits/stdc++.h"
using namespace std;
int main()
{
  int n;
  scanf("%d", &n);
  bool second = true;
  for(int i = 0, j; i < n; ++i)
  {
    scanf("%d", &j);
    second &= !(j % 2);
  }
  printf(second ? "second\n" : "first\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
int binary_search(int* a,long long k,int n){
    int R = n,L = 0;
    while(L < R){
        int mid = (L+R)/2;
        if (a[mid] == k) return 1;
        else if (k < a[mid]) R = mid;
        else L = mid+1;
    }
    return 0;
}
const int SIZE = 100005;
vector<int> vec[SIZE];
bool use[SIZE];
int dep[SIZE],deg[SIZE];

void dfs(int v = 0,int p = -1,int d = 0){
    use[v] = true;
    dep[v] = d;
    for(int i = 0; i < vec[v].size(); i++){
        int to = vec[v][i];
        if (to != p){
            if (!use[to]) dfs(to,v,d+1);
            else if (dep[to] < dep[v]){
                cout << v+1 << " " << to+1 << endl;
                deg[v]++;
            }
        }
    }
    if (p != -1){
        if (deg[v]%2 == 1){
            cout << v+1 << " " << p+1 << endl;
            deg[v]++;
        } else {
            cout << p+1 << " " << v+1 << endl;
            deg[p]++;
        }
    }
}

int main(){
    int n,m; cin >> n >> m; 
    for(int i = 0; i < m; i++){
        int a,b; cin >> a >> b;
        a--; b--;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    if (m % 2 == 1){
        cout << "-1" << endl;
        return 0;
    }
    dfs();
    return 0;
}

  



Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    string s;
    cin>>s;
    rep(i,(int)s.size()){
        s[i] = 'x';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input!(n:usize, mut vs:[i64;n]);

    vs.sort();
    vs.reverse();
    let a = vs[0];
    let mut b = vs[1];
    let mut stand = (a / 2 - b).abs();
    for i in 1..n {
        let tmp = (a / 2 - vs[i]).abs();
        if tmp < stand {
            b = vs[i];
            stand = tmp;
        }
    }

    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<ll> x(n),sortx(n);
    rep(i,n) cin>>x[i];
    sortx=x;
    sort(all(sortx));
    rep(i,n){
        if(x[i]<=sortx[(n-1)/2]) cout<<sortx[n/2]<<endl;
        else cout<<sortx[(n-1)/2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5376
using System;
class Program{
	static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			string[] a = s.Split(' ');
			s = Console.ReadLine();
			string[] b = s.Split(' ');
			int hit = 0, blow = 0;
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 4; j++){
					if(a[i] == b[j]){
						if(i == j) hit++;
						else blow++;
						break;
					}
				}
			}
			Console.WriteLine(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 9076
import sys

n = int(input())
a = [int (x) for x in input().split()]

T = 0
for i in range(2,n):
    T ^= a[i]

S = a[0] + a[1]
D = (S-T)//2
if S<T or (S-T)%2 or D&T:
    print(-1)
    sys.exit()

for i in range(T.bit_length()+1,-1,-1):
    if T&(1<<i)|D <= a[0]:
        D |= T&(1<<i)

if 0<D<=a[0]:
    print(a[0]-D)
else:
    print(-1)

Measured memory_bytes: 62112
from collections import defaultdict
import math

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k_bleu = map(int, input().split())
    red_num = num - k_bleu

    # ans = 0
    mod = 10 ** 9 + 7
    for i in range(k_bleu):
        kaisuu = i + 1
        if i >= min(k_bleu, red_num + 1):
            print(0)
        else:
            ans = combinations_count(red_num + 1, kaisuu) * combinations_count(k_bleu - 1, kaisuu - 1)
            ans %= mod
            print(ans)








if __name__ == '__main__':
    main()

Measured memory_bytes: 66392
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <fstream>
#define rep(i,a,b) for (long long i = a; i < b ; i++)

using namespace std;

int main(){
    int n;
    cin >> n;
    vector <int> h(n);
    rep(i,0,n){
        cin >> h[i];
    }
    int ma = 0, num = 0;
    rep(i,1,n){
        if (h[i]<= h[i-1]){
            //cout << "num" << endl;
            num++;
        } else {
            //cout << "ma" << endl;
            ma = max(ma, num);
            num = 0;
        }
        
    }
    ma = max(ma, num);
    cout << ma << endl;
}

Measured memory_bytes: 640
import math
import fractions
import copy
import numpy as np
import heapq
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n = ip()
a = iprow()
a.sort()
s = 0
for i in range(n-1):
    s = a[i]+a[i+1]
    s/=2
    a[i+1]  = s
print(a[n-1])

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

#define MOD 1000000007

int main(){
    int n,k,ans=INT_MAX,tep;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i) ;
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n-k+1;i++){
        tep=a.at(i+k-1)-a.at(i);
        ans=min(ans,tep);
    }
    cout << ans << endl;
}


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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

void solve() {

	const int pay = 800, refund = 200;

	int n;
	cin >> n;

	int total_paid = 800 * n;
	int total_refund = n / 15 * 200;

	int ans = total_paid - total_refund;

	cout << ans;

}

int main() {

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

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}

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

struct edge{
    int to;
    int num;
    int color;
};

bool operator< (const edge &e1, const edge &e2){
    return e1.num < e2.num;
};

bool operator> (const edge &e1, const edge &e2){
    return e1.num > e2.num;
};

int main(){
    int N;
    cin >> N;
    int a,b;
    vector <edge> G[N+1];
    int K,ktmp;

    for(int i=1; i<N; i++){
        cin >> a >> b;
        edge e = {b,i,0};
        G[a].push_back(e);
        e = {a, i, 0};
        G[b].push_back(e);
    }

    K=0;
    for(int i=1; i<=N; i++){
        vector <int> colorlist;
        for(auto& e: G[i]){
            if( e.color!=0 ){
                colorlist.push_back(e.color);
            }
            for(auto& f: G[e.to]){
                if( f.to==i && f.color!=0 ){
                    colorlist.push_back(f.color);
                }
            }
        }
        ktmp=1;
        for(auto& e: G[i]){
            if( e.color==0 && e.to > i ){
                bool flag;
                flag=true;
                while(flag){
                    flag=false;
                    for( auto x: colorlist ){
                        if(ktmp==x){
                            ktmp++;
                            flag=true;
                        }
                    }
                }
                colorlist.push_back(ktmp);
                e.color=ktmp;
                K=max(ktmp,K);
                //cout << "i e.to ktmp =" << i << " " << e.to << " " << ktmp << endl;
            }
        }
    }
    priority_queue < edge, vector<edge>, greater<edge> > que;
    for(int i=1; i<=N; i++){
        for(auto& e: G[i]){
            if(e.to>i){
                que.push(e);
            }
        }
    }

    cout << K << endl;

    while(!que.empty()){
        edge e=que.top();
        //cout << "e.num e.to e.color= " << e.num << " " << e.to << " " << e.color << endl; 
        cout << e.color << endl;
        que.pop();
    }

    return 0;
}

Measured memory_bytes: 8440
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<(n); ++i)

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

    if(last=="ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e5+5;
const ll mod = 1e9+7;
void solve(){
    ll l,r;
    cin>>l>>r;
    if(r-l>2222){
        cout<<0<<endl;
        return ;
    }
    ll ans = 1e9;

    for(ll i=l;i<=r;i++){
        for(ll j=i+1;j<=r;j++){
            ans = min(ans,(i*j)%2019);
        }
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

#define rep(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define repn(i, m, n) for (ll (i) = (m) ; (i) < (ll)(n) ; ++(i))
#define rep_rev(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define repn_rev(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= (m) ; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9+7

priority_queue<ll> thing;

int main(){
    ll i, n, m;
    cin >> n >> m;
    ll a[n];
    rep(i, n) cin >> a[i], thing.push(a[i]);
    
    ll ans = 0;

    rep(i, m){
        int k = thing.top();
        thing.pop();
        thing.push(k/2);
    }

    rep(i, n){
        ans += thing.top();
        thing.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1912
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N, M = map(int, input().split())
    print(2 ** M * (M * 1900 + (N - M) * 100))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <stdio.h>
#define MAX 100000
long long T[MAX];
int n,k;

int load(long long P) {
	int i=0,j=0;
	long long t;
	for(i = 0; i < k; i++) {
		t = 0;
		while( t+T[j] <=P) {
			t +=T[j];
			j++;
			if(j==n) return n;	
		}
	}
	return j;	
	
}

int solve() {
	long long right = MAX*10000,left=0,mid,s;
	
	while(right>left+1) {
		mid = (right + left)/2;
	     s=load(mid);
		 if(s>=n) right=mid;
		 else left = mid;
	}
		return right;			
}

int main(void)

{
	int i;
	scanf("%d %d%",&n,&k);
	
	for(i=0; i < n; i++) {
		scanf("%d",&T[i]);
	}
		printf("%llu\n",solve());
		return 0;
	
		
	
	
}


Measured memory_bytes: 2580
#include <iostream>
using namespace std;
int main(void){
    int n,m,l;
    long long A[100][100],B[100][100],C[100][100]={};
    cin>>n>>m>>l;
    for(int i=0;i<=n-1;i++){
        for(int j=0;j<=m-1;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<=m-1;i++){
        for(int j=0;j<=l-1;j++){
            cin>>B[i][j];
        }
    }
    for(int i=0;i<=n-1;i++){
        for(int j=0;j<=l-1;j++){
            for(int k=0;k<=m-1;k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(int i=0;i<=n-1;i++){
        for(int j=0;j<=l-1;j++){
            if(j!=0)cout<<" ";
            cout<<C[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin >> a;
    if(a.at(2) == a.at(3) && a.at(4) == a.at(5)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)

sum1 = 0
n.times do |i|
  if x[i] < y[i]
    sum1 = sum1 + y[i] - x[i]
  else sum1 = sum1 + x[i] - y[i]
  end
end
puts sum1

sum2 = 0
n.times do |j|
  sum2 = sum2 + ((x[j] - y[j])**2)
end
puts sum2 ** 0.5

sum3 = 0
n.times do |k|
  if x[k] < y[k]
    sum3 = sum3 + ((y[k] - x[k])**3)
  else sum3 = sum3 + ((x[k] - y[k])**3)
  end
end
puts sum3 ** (1/3.0)

max = 0
n.times do |l|
  if x[l] < y[l]
    len = y[l] - x[l]
  else len = x[l] - y[l]
  end

  if len > max
    max = len
  end
end
puts max

Measured memory_bytes: 8844
S = input()

a = int(S[:2])
b = int(S[2:])

## yymm
if 1 <= b and b <= 12:
  yymm = 1
else:
  yymm = 0
  
## mmyy
if 1 <= a and a <= 12:
  mmyy = 1
else:
  mmyy = 0
  
if yymm == 1 and mmyy == 1:
  print("AMBIGUOUS")
elif yymm == 1 and mmyy != 1:
  print("YYMM")
elif yymm != 1 and mmyy == 1:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    string N;
    cin >> N;
    if(N.find_first_of('7') == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long A = inputLongArray[0];
            long B = inputLongArray[1];
            long C = inputLongArray[2];
            long D = inputLongArray[3];
            while (true)
            {
                C = C - B;
                if (C > 0)
                {
                    A = A - D;
                }
                else
                {
                    break;
                }
                if (A <= 0)
                {
                    break;
                }
            }
            if ( C <= 0)
            {
                Console.WriteLine("Yes");
            }
            else if (A <= 0)
            {
                Console.WriteLine("No");
            }
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


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

long long int min(long long int a, long long int b){
    if(a<b){
        return a;
    }else{
        return b;
    }
}

long long int p(long long int a){
    if(a<0){
        a=-a;
    }
    return a;
}

int main()
{
    int n;
    long long int sum=0,ans=1000000000;
    long long int a[200000];
    long long int sm[200000];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
        sm[i]=sum;
    }
    for(int i=0;i<n-1;i++){
        ans=min(ans,p(sm[i]*2-sum));
    }
    if(n==2){
        ans=p(a[0]-a[1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
N=int(input())
K=int(input())
l = list(map(int,input().split()))
ans=0
for i in range(N):
  n=K-l[i]
  nn=abs(n)
  if nn<l[i]:
    ans+=nn*2
  else:
    ans+=2*l[i]
print(ans)

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

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

    int nxt = 1, ans = 0;
    rep(i,n) {
        if (nxt == a[i]) {
            nxt++;
        } else {
            ans++;
        }
    }

    if (ans == n) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import accumulate
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    R = [0] + list(accumulate(A))
    D = Counter(R)

    res = 0
    for v in D.values():
        if v >= 2:
            res += v * (v - 1) // 2
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 44576
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	while (true) {
		long long int q1, b, c1, c2, q2; std::cin >> q1; if (q1 == 0) break; std::cin >> b >> c1 >> c2 >> q2;
		int max_aizu = 0;
		int normal_with_max_aizu = 0;
		for (auto aizu = 0; aizu <= q2 && aizu * c1 <= b; ++aizu) {
			if ((b - (aizu * c1)) / c2 + aizu >= q1) {
				max_aizu = aizu;
				normal_with_max_aizu = (b - (aizu * c1)) / c2;
			}
		}
		if (max_aizu == 0) {
			std::cout << "NA\n";
		}
		else {
			std::cout << max_aizu << ' ' << normal_with_max_aizu << '\n';
		}
	}
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

const int MAX =2099999;
ll a[24][24];
ll n;
ll dp[MAX][22];



ll cnt(ll mask , ll pos ){
    //cout<<"mask == "<<mask<<" pos = "<<pos<<endl;
    if(pos  > n){
        if(mask == ((1ll<<n)-1))
            return 1;
        else
            return 0;
    }
    if(dp[mask][pos] != -1){
        return dp[mask][pos];
    }
    ll ans = 0;

    for(int i =0 ; i <n;i++){
        ll x= (1ll<<i);
       // cout<<x<<" mas = "<<mask<<"\n";
        x = (x&mask);
        if( x == 0) {
            //cout<<"ye[p\n";
            if(a[i+1][pos]){
                //cout<<"here\n";
                ll t= mask;
                t |= (1<<i);
                ans += cnt(t , pos+1);
                if(ans >= mod) ans -= mod;
            }
        }
    }
    return dp[mask][pos] = ans;

}
int main(){

   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   //ll n;
   cin>>n;
   rep(i ,1 , n+1){
    rep(j , 1 , n+1){
        cin>>a[i][j];
    }
   }
   memset(dp , -1, sizeof(dp));
  cout<<cnt( 0, 1);



}


Measured memory_bytes: 361216
N, M, K=map(int, input().split())

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]

    def root(self, x):
        p, seq = self.parent[x], list()
        while p >= 0:
            seq.append(x)
            x, p = p, self.parent[p]
        for c in seq: self.parent[c] = x
        return x

    def same(self, x, y): return self.root(x) == self.root(y)

    def count(self, x): return -self.parent[self.root(x)]

    def unite(self, x, y):
        if self.count(x) < self.count(y): x, y = y, x
        xr, yr = self.root(x), self.root(y)
        if xr == yr: return
        self.parent[xr] += self.parent[yr]
        self.parent[yr] = xr

friend_or_block = [set() for _ in range(N)]
friends_chain = UnionFindTree(N)

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    friends_chain.unite(a, b)
    friend_or_block[a].add(b)
    friend_or_block[b].add(a)

for _ in range(K):
    c, d = map(int, input().split())
    c, d = c-1, d-1
    if friends_chain.same(c, d):
        friend_or_block[c].add(d)
        friend_or_block[d].add(c)

print(' '.join(map(str, [friends_chain.count(i) - len(friend_or_block[i]) - 1 for i in range(N)])))


Measured memory_bytes: 113440
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int a,b;
  cin>>a>>b;
  int s=a+b;
  int d=a-b;
  int v=a*b;
  cout<<max({s,d,v})<<endl;
  return 0;
}

Measured memory_bytes: 3556
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Knight solver = new Knight();
        solver.solve(1, in, out);
        out.close();
    }

    static class Knight {
        public static int MOD = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            int y = in.nextInt();

            if ((x + y) % 3 != 0) {
                out.println(0);
                return;
            }

            int n = (2 * y - x) / 3;
            int m = (2 * x - y) / 3;

            out.println(combination(n + m, n, MOD));

        }

        static long modPow(long x, long n, long mod) {
            if (n == 0) {
                return 1;
            }
            long result = modPow(x, n / 2, mod);

            if (n % 2 == 0) {
                return (result * result) % mod;
            }
            return (((result * result) % mod) * x) % mod;
        }

        static long modInv(long a, long mod) {
            return modPow(a, mod - 2, mod);
        }

        static long modDiv(long a, long b, long mod) {
            return a * modInv(b, mod) % mod;
        }

        static long combination(long n, long k, long mod) {

            if (n < k || n < 0 || k < 0) {
                return 0;
            }

            long a = 1, b = 1;
            for (int i = 0; i < k; i++) {
                a = a * (n - i) % mod;
                b = b * (i + 1) % mod;
            }
            return modDiv(a, b, mod);
        }

    }
}



Measured memory_bytes: 35908
#include<bits/stdc++.h>
using namespace std;
const int N = 5005;

int n, k;
char a[N];
vector<string> v;

int main()
{
	scanf("%s%d",a+1,&k);
	n = strlen(a+1);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=k;j++) {
			if(i+j-1 > n) continue;
			string T;
			for(int x=0;x<j;x++) {
				T.push_back(a[i+x]);
			}
			v.push_back(T);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	cout << v[k-1] << endl;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int arr[505][505];
int main()
{
	int i,j,k;
	int a,b,c,d;
	sd(a);
	sd(b);
	sd(c);
	sd(d);
	int noofrect=(a/c)*(b/d);
	int extras=a*b - noofrect*c*d;
	if(extras == 0)
	{
		printf("No\n");
		return 0;
	}
	int val=(noofrect)/extras+1;
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
			arr[i][j]=val;
	}
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			if(i%c==0&&j%d==0)
				arr[i][j]=-((c*d-1)*val+1);
		}
	}
	printf("Yes\n");
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
			printf("%d ",arr[i][j] );
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2304
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
for _ in range(M):
  p,S=input().split()
  p=int(p)-1
  if S=='AC':
    ac[p]=1
  else:
    if ac[p]==0:
      wa[p]+=1
a=0
b=0
for i in range(N):
  if ac[i]:
    a+=1
    b+=wa[i]
print(*[a,b])


Measured memory_bytes: 4596
/* gcd 使い回しが思いつかなかった */

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl

ll gcd(ll a, ll b) {
	if(a < b) swap(a, b);
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	size_t bn = 0;

	ll a[n];
	rep(i, n) {
		cin >> a[i];
	}

	ll l[n];
	ll r[n];
	l[0] = a[0];
	r[n-1] = a[n-1];
	repd(i, 1, n) {
		l[i] = gcd(l[i-1], a[i]);
	}
	for(ll i = n - 2; i >= 0; --i) {
		r[i] = gcd(r[i+1], a[i]);
	}

	ll ret = max(l[n-2], r[1]);
	repd(i, 1, n-1) {
		ll tmp = gcd(l[i-1], r[i+1]);
		if(tmp > ret) ret = tmp;
	}

	rep(i, n) {
		cerr << "l[" << i << "] = " << l[i] << endl;
		cerr << "r[" << i << "] = " << r[i] << endl;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
using namespace std;
char s[55], t[55];
int main() {
	int i, j;
	int n;
	int slen, tlen;
	int cut;

	scanf("%s %s", s+1, t+1);
	slen=strlen(s+1), tlen=strlen(t+1);
	for(i=slen-tlen+1; i>=1; i--) {
		for(j=1; j<=tlen; j++)
			if(s[i+j-1]^'?' and s[i+j-1]^t[j])
				break;
		if(j>tlen)
			break;
	}
	cut=i;
	if(cut<1) {
		printf("UNRESTORABLE");
		return 0;
	}
	for(i=1; i<cut; i++)
		if(s[i]^'?')
			putchar(s[i]);
		else
			putchar('a');
	for(i=1; i<=tlen; i++)
		putchar(t[i]);
	for(i=cut+tlen; i<=slen; i++)
		if(s[i]^'?')
			putchar(s[i]);
		else
			putchar('a');
	return 0;
}

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

Measured memory_bytes: 256