akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep (i, n) cin >> a[i];
    rep (i, n) cin >> b[i];
    rep (i, n) c[i] = b[i] - a[i];
    ll kp = 0, km = 0, k = 0;
    rep (i, n) k += c[i];
    rep (i, n) kp += (max(0LL, c[i]) + 1) / 2;
    rep (i, n) km -= min(0LL, c[i]);
    cout << (kp <= k && km <= k ? "Yes\n" : "No\n");
    return 0;
}

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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
    return 0;
}

Measured memory_bytes: 764
K = int(input())
ln = [["0"]]
ln.append([str(i) for i in range(1,10)])
for i in range(1,10):
  tmp = []
  for j in ln[i]:
    for k in range(-1,2):
      if int(j[-1])+k >=0 and int(j[-1])+k<10:
        tmp.append(j+str(int(j[-1])+k))
  ln.append(tmp) 
ln = sum(ln,[])
print(ln[K])

Measured memory_bytes: 19388
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
ll power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
void solve(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int lc[1000001]={0},ct,k;
	for(int i=0;i<n;i++){
		k=a[i];
		for(int j=2;j*j<=a[i];j++){
			ct=0;
			while(k%j==0&&k){
				k/=j;
				ct++;
			}
			if(ct)
				lc[j]=max(lc[j],ct);
		}
		if(k)
			lc[k]=max(lc[k],1);
	}
	ll l=1;
	for(int i=2;i<1000001;i++){
		l=(l*(ll)pow(i,lc[i]))%mod;
	}

	ll ans=0;
	for(int i=0;i<n;i++){
		ans=(ans+(power(a[i],mod-2)*l)%mod)%mod;
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--)
		solve();
}


Measured memory_bytes: 7952
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, x = map(int, input().split())
    r = (b // x) + 1
    if b > 0:
        r -= ((a - 1) // x) + 1
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let qhsd =  buf.split_whitespace().map(|x| x.parse().ok().unwrap()).collect::<Vec<u64>>();
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let n: u64 = buf.trim().parse().ok().unwrap();

    // println!("{:?}", qhsd);
    // println!("{}", n);

    let mut qhsd: Vec<(u64, u64)> = [1, 2, 4, 8].iter().cloned().zip(qhsd).collect();
    qhsd.sort_by_key(|t| t.1 * (8 / t.0));

    let mut rest = 4 * n;
    let mut cost = 0u64;

    if rest != 0 {
        let cop = rest;
        rest -= (cop / qhsd[0].0) * qhsd[0].0;
        cost += (cop / qhsd[0].0) * qhsd[0].1;
    }
    if rest != 0 {
        let cop = rest;
        rest -= (cop / qhsd[1].0) * qhsd[1].0;
        cost += (cop / qhsd[1].0) * qhsd[1].1;
    }
    if rest != 0 {
        let cop = rest;
        rest -= (cop / qhsd[2].0) * qhsd[2].0;
        cost += (cop / qhsd[2].0) * qhsd[2].1;
    }
    if rest != 0 {
        let cop = rest;
        rest -= (cop / qhsd[3].0) * qhsd[3].0;
        cost += (cop / qhsd[3].0) * qhsd[3].1;
    }

    println!("{}", cost);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

ll n;
vector<ll> a;

void solve_naive(){
	vector<ll> b(1LL<<n);
	rep(i, 1LL<<n) rep(j, n) if(1&(i>>j)) b[i]+=a[j];
	vector<P> p(1LL<<n);
	rep(i, 1LL<<n) p[i] = P(b[i], i);
	sort(all(b));
	cout<<b[1<<(n-1)]<<endl;
	sort(all(p));
	//rep(i, 1<<n) cerr<<p[i].fst<<" "<<p[i].snd<<endl;
}

#define N 2001
//bool dp[N*N];
bitset<N*N> bs;

int main(){
	cin>>n;
	a = vector<ll>(n);
	rep(i, n) cin>>a[i];
	sort(all(a));
	ll sum = 0;
	bs.set(0);
	rep(i, n){
		sum += a[i];
		bs |= bs << a[i];
	}
	ll l = 0, r = sum;
	ll res = r;
	while(l<=r){
		while(!bs[l]) l++;
		while(!bs[r]) r--;
		//cerr<<l<<" "<<r<<endl;
		if(r<l) break;
		res = r;
		l++; r--;
	}
	cout<<res<<endl;
	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++) cin >> a[i] >> b[i];

    vector<bool> from1(n+1, false), ton(n+1, false);
    for(int i = 0; i < m; i++){
        if(a[i] == 1) from1[b[i]] = true;
        if(b[i] == n) ton[a[i]] = true;
    }

    string ans = "IMPOSSIBLE";
    for(int i = 1; i <= n; i++){
        if(from1[i] && ton[i]) ans = "POSSIBLE";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
from itertools import combinations

N = int(input())
S = input()
counter_R = [0]
counter_G = [0]
counter_B = [0]
for s in S:
    counter_R.append(counter_R[-1] + (s == 'R'))
    counter_G.append(counter_G[-1] + (s == 'G'))
    counter_B.append(counter_B[-1] + (s == 'B'))
ans = 0
for i, j in combinations(range(N-1), 2):
    if S[i] == S[j]: continue
    l = j - i
    temp = [S[i], S[j]]
    if 'R' not in temp: cnt = counter_R
    elif 'G' not in temp: cnt = counter_G
    else: cnt = counter_B
    if j + l > N:
        ans += cnt[-1] - cnt[j]
    else:
        ans += cnt[j+l] - cnt[j] + (cnt[-1] - cnt[j + l + 1] if j + l + 1 <= N else 0)
print(ans)

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

int main(){
	int n;
	long min = 100000000;
	long max = -100000000;
	long long sum=0;
	long x;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		if(max < x) max = x;
		if(min > x) min = x;
		sum += x;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3104
# AtCoder Beginner Contest 043 - B
# -*- encoding: UTF-8 -*-
s = input().upper()

edited = []

for c in s:
  if c == "0" :
    edited.append("0")
  elif c == "1" : 
    edited.append("1")
  elif c == "B" :
    if len(edited) > 0:
      edited.pop()

print("".join(map(str, edited)))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int MOD = 1e9 + 7;

int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	printf("%.10lf", sqrt(d));
    cout<<endl;
}


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

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

    int n, q, l, r, tmp = 0, sum = 0;
    string s;
    cin >> n >> q >> s;
    int length = s.size();
    //vector<int> cnt(q), yes(length);
    vector<int> yes(length);

    for (int i = 0; i < length-1; i++) {
        if ((s[i] == 'A') && (s[i+1] == 'C')) {
            yes[i] = sum;
            yes[++i] = ++sum;
        }
        else yes[i] = sum;
    }
    yes[length-1] = sum;

    while (q--) {
        cin >> l >> r;
        cout << (yes[r-1] - yes[l-1]) << endl;


//        cin >> l >> r;
//        cnt[tmp++] = yes[r-1] - yes[l-1];
    }
//    for (int i = 0; i < tmp; i++) cout << cnt[i] << endl;
    return 0;
}


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

const int mod = 1e9 + 7;

struct combination {
	const int MAX = 1e6;
	const int MOD;
	vector<long long> fac, finv, inv;

	combination(int mod) :MOD(mod) {
		fac.resize(MAX);
		finv.resize(MAX);
		inv.resize(MAX);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < MAX; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	long long COM(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
};

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> mi;
	vector<ll> pu;
	ll ans = 0;
	combination comb(mod);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	sort(a.begin(), a.end());
	for (ll i = 0; i < n; ++i) {
		ll no = n - i - 1;
		if (no < k - 1)break;
		ans -= a[i] * comb.COM(no, k - 1);
		mi.push_back(a[i] * comb.COM(no, k - 1));
		ans = (ans % mod + mod) % mod;
	}
	sort(a.rbegin(), a.rend());
	for (ll i = 0; i < n; ++i) {
		ll no = n - i - 1;
		if (no < k - 1)break;
		ans += a[i] * comb.COM(no, k - 1);
		pu.push_back(a[i] * comb.COM(no, k - 1));
		ans = (ans % mod + mod) % mod;
	}
	cout << ans << endl;
}


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


mod = 10**9+7
MAX = N+1
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod


def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()


A.sort()
ans = 0
for i in range(N):
    plus = A[i] * cmb(i,K-1)
    minus = A[i] * cmb(N-i-1,K-1)
    ans += plus-minus
    ans %= mod

print(ans)



Measured memory_bytes: 19536
###
# 二分探索木2
###

class Node:
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None
        self.parent = None

class BinarySearchTree:
    def __init__(self):
        self.root = None
        self.count = 0
    
    def insert(self, node: Node):
        self.count += 1
        if not self.root:
            self.root = node
            return

        cur = self.root
        while cur:
            if node.val > cur.val:
                if cur.right:
                    cur = cur.right
                    continue
                else:
                    cur.right,node.parent = node,cur
                    return
            else:
                if cur.left:
                    cur = cur.left
                    continue
                else:
                    cur.left,node.parent = node,cur
                    return

    def find(self, val):
        cur = self.root
        while cur:
            if cur.val == val:
                return "yes"
            elif cur.val > val:
                cur = cur.left
            else:
                cur = cur.right
        return "no"


def main():

    ## preorder tree walk
    preorder = []

    def preorder_walk(node):
        preorder.append(str(node.val))
        if node.left:
            preorder_walk(node.left)
        if node.right:
            preorder_walk(node.right)

    ## inorder tree walk

    inorder = []

    def inorder_walk(node):
        if node.left:
            inorder_walk(node.left)
        inorder.append(str(node.val))
        if node.right:
            inorder_walk(node.right)


    n = int(input())
    
    bst = BinarySearchTree()
    
    for _ in range(n):
        op = input().strip().split()
        if op[0] == "insert":
            bst.insert(Node(int(op[1])))
        elif op[0] == "print":
            preorder,inorder = [],[]
            preorder_walk(bst.root)
            inorder_walk(bst.root)
            print(""," ".join(inorder))
            print("", " ".join(preorder))
        elif op[0] == "find":
            print(bst.find(int(op[1])))

if __name__ == "__main__":
    main()



Measured memory_bytes: 148844
require 'pp'
require 'set'

n, l = gets.chomp!.split(" ").map(&:to_i)

sum = 0
min = 999999
v = 99999
1.upto(n) do |i|
    aji = l + i - 1
    sum += aji
    if aji.abs < min
        min = aji.abs
        v = aji
    end
end

puts sum - v


Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    ll ret = 0;
    FOR(i, 1, n) if(i<n-i && i != n-i) ret++;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 764
//Author - Soumik Roy
//Date & Time - August 29, 2020 7:02 PM
//Problem name - D - Friends
//Problem url - https://atcoder.jp/contests/abc177/tasks/abc177_d
//Time limit - 2000 ms
//Memory Limit - 1024 MB    

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int dir[]={0,1,0,-1,1,0,-1,0};
int find(int v,vi &parent)
{
	return parent[v]=(v==parent[v])?v:find(parent[v],parent);
}
void solve()
{
	int n,m;
	cin>>n>>m;
	vi parent(n+1);
	for(int i=1;i<=n;i++)
		parent[i]=i;
	vi size(n+1,1);
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a=find(a,parent);
		b=find(b,parent);
		//cout<<a<<" "<<b<<" "<<size[a]<<" "<<size[b]<<endl;
		if(a!=b)
		{
			if(size[a]<size[b])
				swap(a,b);
			parent[b]=a;
			size[a]+=size[b];
		}
	}
	// for(int i=1;i<=n;i++)
	// {
	// 	int par=find(i,parent);
	// 	size[par]++;
	// }
	int mx=0;
	for(int i=1;i<=n;i++)
		mx=max(mx,size[i]);
	cout<<mx<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    ll rui[n+1];
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        rui[i+1] = rui[i] + a[i];
    }
    map<ll,ll> mp;
    for(int i = 0;i <= n;i++){
        mp[rui[i]]++;
    }
    ll ans = 0;
    for(auto i:mp){
        ll tmp = i.second;
        ans += tmp*(tmp-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);    
    int n = in.nextInt();
    int[] A = new int[n];
    for (int i = 0; n != 0; i++) {
      A[i] = in.nextInt();
      n--;
    }
    
    int q = in.nextInt();
    for (int i = 0; q != 0; i++) {
      System.out.println((dfs(0, A, in.nextInt())) ? "yes" : "no" );
      q--;
    }
  }
  static boolean dfs(int p, int[] A, int t) {
    if (p == A.length)           return t == 0;
    if (dfs(p + 1, A, t - A[p])) return true;
    if (dfs(p + 1, A, t))        return true;
    return false;
  }
}

Measured memory_bytes: 20260
fn solve(hs: Vec<i64>) -> i64 {
    use std::cmp::min;

    let n = hs.len();
    let mut dp = vec![0; n];

    dp[1] = (hs[1] - hs[0]).abs();

    for i in 2..n {
        dp[i] = min(
            dp[i - 2] + (hs[i] - hs[i - 2]).abs(),
            dp[i - 1] + (hs[i] - hs[i - 1]).abs(),
        );
    }

    dp[n - 1]
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![10, 30, 40, 20]), 30);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let hs = parse_vec!(i64);
    println!("{}", solve(hs));
}


Measured memory_bytes: 6396
n = int(input())
a = sorted(list(map(int, input().split())))

if n%2:
    a = a[1:]

x = n%2 + 1
for i in range(len(a))[::2]:
    if a[i] != x:
        print(0)
        exit()
    x += 2

print(2**(n//2) % (10**9+7))

Measured memory_bytes: 53036
using System;
using System.Collections.Generic;

namespace ABC140_A
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());

            long ans = (long)Math.Pow(n, 3);

            //long ans = 0;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll N=s.length();
  s.push_back('D');
  s.push_back('D');
  s.push_back('D');
  s.push_back('D');
  s.push_back('D');
  s.push_back('D');
  ll left=0ll;
  ll ans=0ll;
  ll nextA=0ll;
  while(true){
    ll sumA=nextA;
    ll nowA=0ll;
    ll sumBC=0ll;

    while(s[left]!='A'){
      sumA=0ll;
      left++;
      if(left>=N+2) break;
    }

    ll indexlastA=left;

    for(int i=left;i<N+2;i++){
      if(s[i]=='A'){
        sumA++;
        nowA++;
        indexlastA=ll(i);
      }else{
        break;
      }
    }

    for(int i=indexlastA+1;i<N+2;i+=2){
      if(s[i]=='B'&&s[i+1]=='C'){
        sumBC++;
      }else{
        break;
      }
    }
    
    left+=sumBC*2+nowA;
    ans+=sumA*sumBC;
    if(sumBC*sumA==0){
      nextA=0ll;
    }else{
      nextA=sumA;
    }
    if(left>=N+2)break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  int a,b[200]={},c=0;
  cin>>a;
  for(int i=1;i<=a;i++){
    cin>>b[i];
  }
  for(int i=1;i<=a;i++){
    for(int j=i+1;j<=a;j++){
      c+=b[i]*b[j];
    }
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void){
    int n,i,j,tmp,count;
    int e[10000];
    count = 0;
    scanf("%d",&n);

    for(i=1;i<=n;i++){
        if(i%3==0){
            e[count] = i;
            count++;
        }
        else{
            tmp = i;
            while(1){
                if(tmp%10==3){
                    e[count] = i;
                    count++;
                    break;
                }
                if(tmp/10==0){
                    break;
                }
                tmp = tmp/10;               
            }
        }
    }

    for(j=0;j<count;j++){
        printf(" %d",e[j]);
    }
    printf("\n");
    return 0;

}


Measured memory_bytes: 2136
#include <iostream>

int main()
{
  int a,b;
  std::cin >> a >> b;
  int r = a - (b*2);
  if(r<=0)
  {
    std::cout << 0 << std::endl;
  }
  else
  {
    std::cout << a-(b*2)<<std::endl; 
  }
  
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-08 20:32:33
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b, c; cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}

Measured memory_bytes: 892
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    A, B, P = map(int, readline().split())
    if A == B == P == 0:
        return False
    N = (B - A + 1)
    data = [0]*(N+1)
    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s % P
    *V, = range(A, B+1)
    V.sort(key = str)
    for v in V:
        k = v+1 - A
        x = get(k) + 1
        while k <= N:
            data[k] += x
            k += k & -k
    write("%d\n" % (get(N) % P))
    return True
while solve():
    ...


Measured memory_bytes: 17216
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	d := nextInt()
	c := nextInts(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = nextInts(26)
	}

	t := nextInts(d)

	last := make([]int, 26)

	ans := 0

	for i := 0; i < d; i++ {
		for j := 0; j < 26; j++ {
			last[j]++
		}
		last[t[i]-1] = 0

		for j := 0; j < 26; j++ {
			if j == t[i]-1 {
				ans += s[i][j]
			} else {
				ans -= c[j] * last[j]
			}
		}

		fmt.Fprintln(out, ans)
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	//fmt.Fprintln(out, ans)

}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}


Measured memory_bytes: 2036
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>
#include <map>
#include <set>
#include <boost/lexical_cast.hpp>

using namespace std;


using ULL = decltype(0ull);
constexpr auto DIV = 1000000007ull;
constexpr auto MAX = numeric_limits<ULL>::max();

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int v = max(a, max(b, c)) - min(a, min(b, c));
  if (a == v || b == v || c == v) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import collections, heapq, math, sys

n = int(sys.stdin.readline().rstrip())
w = map(int, sys.stdin.readline().rstrip().split(' '))

tot = sum(w)
curr = 0
diff = float('inf')
for i in range(n):
    curr += w[i]
    if abs(tot-curr-curr) < diff:
        diff = abs(tot-2*curr)
print(diff)



Measured memory_bytes: 2812
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100+5;
typedef long long ll;
int dp[maxn][maxn][3*maxn];
int v[maxn],w[maxn];
int n,c;
int main(){
	cin>>n>>c;
	ll mem=0;
	for (int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
		if (i==1) mem=w[1];
		w[i]-=mem;
	}
	memset(dp,0xf3,sizeof(dp));
	dp[0][0][0]=0;
	int ans=0;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=i;j++){
			for (int k=0;k<=3*100;k++){
				dp[i][j][k]=dp[i-1][j][k];
				if (k>=w[i]&&j>=1){
					dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k-w[i]]+v[i]);
				}
				if (j*mem+k<=c){
					ans=max(ans,dp[i][j][k]);
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 17176
N = int(input())
hs = list(map(int, input().split()))

INF = 10 ** 10

dp = [INF] * N
dp[0] = 0
dp[1] = abs(hs[1] - hs[0])

for i in range(1, N):
    dp[i] = min(dp[i - 1] + (abs(hs[i] - hs[i - 1])),
                dp[i - 2] + (abs(hs[i] - hs[i - 2])))

print(dp[N - 1])

Measured memory_bytes: 13924
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            int sum = 0;
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if((m == -1 && f == -1) && r == -1)
                break;
            sum = m + f;
            if(m == -1 || f == -1 || sum < 30)
                System.out.println("F");
            else if(sum < 50)
            {
                if(r >= 50)
                    System.out.println("C");
                else
                    System.out.println("D");
            }
            else if(sum < 65)
                System.out.println("C");
            else if(sum < 80)
                System.out.println("B");
            else
                System.out.println("A");
        }
    }
}


Measured memory_bytes: 26228
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;
int main() {
  char ch;
  while(1) {
	scanf("%c", &ch);
	if(ch == '\n') { break; }
	
	if(islower(ch)) {
	  cout << char(toupper(ch));
	}
	else if(isupper(ch)) {
	  cout << char(tolower(ch));
	}
	else {
	  cout << ch;
	}
  }
  cout << endl;
  return 0;
}

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


int main()
{
    /*A
    int k,a,b;
    cin>>k>>a>>b;
    bool flag = false;

    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag = true;
            break;
        }
    }

    if(flag)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        cout<<"NG"<<endl;
    }
    */

    ll x,temp;
    cin>>x;
    temp = 100;
    int year = 0;
    bool flag = true;
    while(flag)
    {
        year++;
        temp=temp*1.01;
        if(temp>=x)
        {
            flag = false;
        }
    }

    cout<<year<<endl;
    
    return 0;
}

Measured memory_bytes: 3640
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
# import numpy as np

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

N, K, Q, *A = map(int, read().split())
point =[K-Q]*(N+1)

for i in A:
    point[i] += 1
print(*['Yes' if i > 0 else 'No' for i in point[1:]], sep='\n')


Measured memory_bytes: 12392
import random
D = int(input())
C = list(map(int, input().split()))

for i in range(D):
    input()

# # 0以下無視 -> ALL0を省く
# flg = list()
# if max(C) == 0:
#     for i in range(len(C)):
#         flg.append(1)
# else:
#     for i in range(len(C)):
#         if C[i] <= 0:
#             flg.append(0)
#         else:
#             flg.append(1)

j = 27
for i in range(D):
    c = 26
    while(True):
        j -= 1
        c -= 1
        if C[j-1] > 0 :
            break
        if c == 0:
            break
        if j == 1:
            j = 27
    print(j)
    if j == 1:
        j = 27


Measured memory_bytes: 9492
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){
    int n, k ; cin >> n >> k;
    cout << n - k +1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

vector<long long> x;

bool comp(int i, int j) {
  if (x[i] == x[j])
    return i < j;
  else
    return x[i] < x[j];
}

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  x.resize(N);
  vector<int> indices(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
    indices[i] = i;
  }

  sort(indices.begin(), indices.end(), comp);

  long long mediun = x[indices[N / 2]];
  long long mediun_m1 = x[indices[N / 2 - 1]];
  for (int i = 0; i < N; ++i) {
    if (x[i] >= mediun)
      cout << mediun_m1 << endl;
    else
      cout << mediun << endl;
  }


  return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include<algorithm>

using namespace std;

int N;

long long int A[200005], B[200005];

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i]; cin >> B[i];
	}

	int I; long long int Bmin = 100000000000;
	long long int sum_LARGE = 0; for (int i = 1; i <= N; i++) { sum_LARGE += abs(A[i] - B[i]); }
	for (int i = 1; i <= N; i++) {
		if (A[i] - B[i] > 0 && B[i] < Bmin) { I = i; Bmin = B[i]; }
	}

	long long int sum_A = 0;
	for (int i = 1; i <= N; i++) {
		if (i == I) { continue; }
		sum_A += A[i];
	}

	long long int ans;
	if (sum_LARGE == 0) {
		ans = 0;
	}
	else {
		ans = sum_A +A[I]-B[I];
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  int a[N+2];
  rep(i,N)cin >> a[i+1];
  a[0] = a[N+1] = 0;
  N+=1;
  int pre[N+1], suf[N+1];
  pre[0] = suf[N] = 0;
  rep(i,N) pre[i+1] = pre[i] + abs(a[i+1] - a[i]);
  per(i,N) suf[i] = suf[i+1] + abs(a[i+1] - a[i]);

  repp(i,1,N) cout << pre[i-1] + suf[i+1] + abs(a[i-1] - a[i+1])<< endl;
  return 0;
}


Measured memory_bytes: 2432
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main{

public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){arr[i]=s.nextInt();}
       	Arrays.sort(arr);
       long count=0;
        for(int h=0;h<n-2;h++){
            int k1=h+2;
            for(int j=h+1;j<n-1;j++){
                while(k1<n &&arr[h]+arr[j]>arr[k1]){
                    k1++;
                }
                if(k1>j){count+=k1-j-1;}
            }
        }
       	
       System.out.println(count); 
    }
}
    
  












Measured memory_bytes: 27004
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ll((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
int main()
{
    ll n,W;
    cin>>n>>W;
    vl w(n), v(n);
    loop(i,0,n) cin>>w[i]>>v[i];
    ll dp[W+1]={0};
    loop(i,0,n)
    {
    	revloop(j,W,w[i]) dp[j] = max(dp[j], v[i]+dp[j-w[i]] );
	}
	cout<<dp[W];
	return 0;
}

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

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

  if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b == c + d) {
    cout << "Balanced" << endl;
  }

  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<numeric>

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

int main() {

   int N, X;
   std::cin >> N >> X;
   int x[N];
   int x2[N];
   for (int i = 0; i < N; i++) {
      std::cin >> x[i];
      x2[i] = std::abs(x[i] - X);
   }

   int ans = x2[0];
   for (int i = 1; i < N; i++) {
      ans = gcd(ans, x2[i]);
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  int N, M, C;
  C = 0;
  cin >> N;
  vector<string> blue(N);
  REP(i, N) {
    cin >> blue[i];
  }
  cin >> M;
  vector<string> red(M);
  REP(i, M) {
    cin >> red[i];
  }
  REP(i, N) {
    int cnt = 0;
    int j = 0;
    REP(j, N) {
      if (blue[i] == blue[j]) {
        cnt++;
      }
    }
    j = 0;
    REP(j, M) {
      if (blue[i] == red[j]) {
        cnt--;
      }
    }
    C = max(C, cnt);
  }
  cout << C;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(Math.Max(0, A - 2 * B));
	}
	int A,B;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int n, a, b, c;
		
		n = sc.nextInt();
		
		for(int i=0; i < n; i++)
		{
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			
			System.out.println((a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)?"YES":"NO");
		}
		
	}

}

Measured memory_bytes: 12000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int A = Integer.parseInt(tokens[1]);
		int B = Integer.parseInt(tokens[2]);
		int C = Integer.parseInt(tokens[3]);
		int D = Integer.parseInt(tokens[4]);
		String S = in.readLine();
		if (D > C) {
			// 移動できればよい
			int typeA = check(S, A - 1, C);
			int typeB = check(S, B - 1, D);
			if (typeA >= 0 && typeB >= 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			int typeA = check(S, A - 1, C);
			int typeB = check(S, Math.max(B - 2, 0), Math.min(D + 1, S.length()));
			if (typeA < 0 || typeB < 0) {
				// 移動できない
				System.out.println("No");
			} else {
				if (typeB > 0) {
					// 抜かせる
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		}
		in.close();
	}

	static int check(String S, int start, int end) {
		int whiteSeqNum = 0;
		int blackSeqNum = 0;
		int maxWhiteSeqNum = 0;
		int maxBlackSeqNum = 0;
		for (int i = start; i < end; ++i) {
			if (S.charAt(i) == '.') {
				++whiteSeqNum;
				maxWhiteSeqNum = Math.max(maxWhiteSeqNum, whiteSeqNum);
				blackSeqNum = 0;
			} else {
				++blackSeqNum;
				maxBlackSeqNum = Math.max(maxBlackSeqNum, blackSeqNum);
				whiteSeqNum = 0;
			}
		}
		if (maxBlackSeqNum >= 2) {
			return -1;
		} else if (maxWhiteSeqNum <= 2) {
			return 0;
		} else {
			return 1;
		}

	}

}

Measured memory_bytes: 25172
using System;
using System.Linq;

namespace arc071_b
{
	class Program
	{
		static void Main(string[] args)
		{
			long mod = (long)Math.Pow(10, 9) + 7;
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long asum = 0;
			for (int i = 1; i < x[0]; i++)
			{
				long now = a[i] - a[i - 1];
				now *= i; now %= mod;
				now *= x[0] - i; now %= mod;
				asum += now; asum %= mod;
			}
			long[] b = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long bsum = 0;
			for (int i = 1; i < x[1]; i++)
			{
				long now = b[i] - b[i - 1];
				now *= i; now %= mod;
				now *= x[1] - i; now %= mod;
				bsum += now; bsum %= mod;
			}
			Console.WriteLine(asum * bsum % mod);
		}
	}
}

Measured memory_bytes: 39332
#include <iostream>
using namespace std;
static const int N = 100;

int main(){
  int M[N][N];
  int n, u, k, v;

  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++)
      M[i][j] = 0;
  }

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j)
	cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }

  return 0;
}



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

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    cin >> n >> m;

    vector<string> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    rep(i, n - m + 1) {rep(j, n - m + 1) {
        bool z = true;
        rep(k, m) {rep(l, m) {
            if(a[i + k][j + l] != b[k][l]) {
                z = false;
                break;
            }
        }if(!z) break;}
        if(z) return cout << "Yes" << endl, 0;
    }}

    cout << "No" << endl;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  int d;
  while (cin >> d, cin) {
    int sum = 0;
    for (int x = d; x < 600; x += d) {
      sum += x * x * d;
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,L,Q;

int main(){
  cin>>N;
  vector<ll> x;
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    x.push_back(a);
  }
  cin>>L;
  cin>>Q;

  int next[N+1][18]={};
  for(int i=0;i<N;i++){
    int z=lower_bound(x.begin(),x.end(),L+x[i]+1)-x.begin();
    z--;
    next[i][0]=z;
  }

  for(int k=0;k<17;k++){
    for(int i=0;i<N;i++){
      if(next[i][k]==N-1) next[i][k+1]=N-1;
      else next[i][k+1]=next[next[i][k]][k];
    }
  }

  for(int i=0;i<Q;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    if(a>b) swap(a,b);
    int ng=0,ok=b-a+1;
    while(ok-ng>1){
      int mid=(ng+ok)/2;
      int p=a;
      for(int k=17;k>=0;k--){
        if(p>=b) break;
        if((mid>>k)&1){
          p=next[p][k];
        }
      }

      if(p>=b) ok=mid;
      else ng=mid;
    }
    cout<<ok<<endl;
  }

  return 0;
}


Measured memory_bytes: 8820
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int p = 0;
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (j < A) sb.append(p);
        else sb.append(1 - p);
      }
      sb.append('\n');
      if (i == B - 1) p = 1 - p;
    }
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 33464