akhauriyash/Code-Regression huggingface dataset:
N = int(raw_input())
A = map(int, raw_input().split())

#N = 200000
#A = [200000]*N

count = [0]*(N+2)
for i in range(N):
    id = A[i]
    count[id] = count[id]+1

sumN = long(0)
for i in range(N+1):
    sumN = sumN + long(long(count[i]*(count[i]-1))/2)

#print answer
for i in range(N):
    id = A[i]
    sumz = sumN - (count[id] - 1)
    print(sumz)


Measured memory_bytes: 20052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
template <typename T>
struct Compress {
    vector<T> xs;

    Compress() = default;

    Compress(const vector<T> &vs) {
        add(vs);
    }

    Compress(const initializer_list<vector<T>> &vs) {
        for (auto &p : vs) add(p);
    }

    void add(const vector<T> &vs) {
        copy(begin(vs), end(vs), back_inserter(xs));
    }

    void add(const T &x) {
        xs.emplace_back(x);
    }

    void build() {
        sort(begin(xs), end(xs));
        xs.erase(unique(begin(xs), end(xs)), end(xs));
    }

    vector<int> get(const vector<T> &vs) const {
        vector<int> ret;
        transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
            return lower_bound(begin(xs), end(xs), x) - begin(xs);
        });
        return ret;
    }

    int get(const T &x) const {
        return lower_bound(begin(xs), end(xs), x) - begin(xs);
    }

    const T &operator[](int k) const {
        return xs[k];
    }
};

// Binary Indexed Tree (Fenwick Tree)
template <typename T>
struct BIT {
    ll n;
    vector<T> d;
    BIT(ll n = 0) : n(n), d(n + 1) {}
    void add(ll i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    T sum(ll i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    Compress<ll> C(A);
    sort(all(C.xs));
    C.build();

    BIT<ll> bt(N);
    ll ans = 0;
    rep(i, N){
        ll ci = C.get(A[i]);
        bt.add(ci);
        ans += ci - bt.sum(ci) + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATheNumberOfEvenPairs solver = new ATheNumberOfEvenPairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATheNumberOfEvenPairs {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            int m = ni();
            int ans = (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
            pn(ans);

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21460
H, W = map(int, input().split())
ans = H*W
#縦に3つ切る
if(W%3 == 0):
  ans = 0
else:
  ans = min(ans, H)

#横に3つ切る
if(H%3 == 0):
  ans = 0
else:
  ans = min(ans, W)
  
#始め縦に切り、その後二等分する
if(H % 2 == 0):
  sa = W*H//2
  sb = W*H//2
  sc = 0
  ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
  for i in range(W-1):
    sc += H
    sa -= H//2
    sb -= H//2
    ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
else:
  sa = W * (H//2)
  sb = W * (H//2 + 1)
  sc = 0
  ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
  for i in range(W-1):
    sc += H
    sa -= H//2
    sb -= H//2 + 1
    ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
    
#始め横に切り、その後二等分する
if(W % 2 == 0):
  sa = W*H//2
  sb = W*H//2
  sc = 0
  ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
  for i in range(H-1):
    sc += W
    sa -= W//2
    sb -= W//2
    ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
else:
  sa = H * (W//2)
  sb = H * (W//2 + 1)
  sc = 0
  ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
  for i in range(W-1):
    sc += W
    sa -= W//2
    sb -= W//2 + 1
    ans = min(ans, max(sa, sb, sc) - min(sa, sb, sc))
    
print(ans)

Measured memory_bytes: 40560
#include<iostream>
#include<vector> 
#include<queue>
#include<algorithm>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h,w,k;
	cin>>h>>w>>k;
	++k;
	int xb,yb,xe,ye;
	cin>>xb>>yb>>xe>>ye;
	--xb;--yb;--xe;--ye;
	vector<vector<char>>rec(h,vector<char>(w));
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			cin>>rec[i][j];
		}
	}
	vector<vector<int>>dis(h,vector<int>(w,1<<30));
	int dx[4]={0,0,-1,1};
	int dy[4]={1,-1,0,0};
	queue<vector<int>>que;
	que.push({xb,yb});
	dis[xb][yb]=0;
	while(!que.empty()){
		int x=que.front()[0],y=que.front()[1];
		que.pop();
		for(int r=0;r<4;++r){
			int u=x,v=y,s=dis[x][y]+1;
			for(int d=1;d<k;++d){
				u+=dx[r];
				v+=dy[r];
				if(0<=u&&u<h&&0<=v&&v<w&&rec[u][v]=='.'){
					if(dis[u][v]>s){
						dis[u][v]=s;
						que.push({u,v});
					}
                  	else if(dis[u][v]<s){
						break;
					}
				}else{
					break;
				}
			}	
		}
	}
	if(dis[xe][ye]==1<<30){
		cout<<-1<<endl;
	}else{
		cout<<dis[xe][ye]<<endl;
	}
	return 0;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n, k, ans, sum;
	cin >> k >> n;
	vector <ll> a(n);
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort (a.begin(), a.end());
	ans = a[0]+k-a[n-1];
	sum = ans;
	for (int i=1; i<n; i++) {
		ans = max(ans, a[i]-a[i-1]);
		sum += a[i]-a[i-1];
	}
	cout << sum-ans;
	return 0;
}


Measured memory_bytes: 1792
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt().distinct()
    println(if (A.size == N) "YES" else "NO")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 80808
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef print
#define print(...)
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//const int mod=998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }
int powm(int a, int b) { int res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
int a[1000004];
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int a, b;
	cin>>a>>b;
	if (a < b) {
		swap(a, b);
	} 
	if (abs(a - b) & 1) {
		cout << min((b - 1 + a) / 2, (n - b + n - a + 1) / 2);
	} else {
		cout << (a - b) / 2;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", max(c-(a-b), 0));
}


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

int main()
{
    std::string s;
    std::cin >> s;
    std::cout << std::string(s.length(), 'x');
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<cmath>

using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  //if(n >= k)
  cout<<ceil((double)n/k)-floor((double)n/k)<<endl;
    //else
    //cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N=int(input())
ABC=[]
for i in range(N):
    ABC.append(list(map(int,input().split())))
dp=[[0,0,0] for i in range(N)]
dp[0]=ABC[0]
for i in range(1,N):
    for j in range(3):
        dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+ABC[i][j]
print(max(dp[N-1]))

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

typedef long long ll; 
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< ll > 		vll;
typedef pair<int, int> 		pii;

#define int ll
#define pb push_back
#define sq(a) a*a
#define endl '\n'
#define iyas_salah ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(n)	v.begin(),v.end()
#define rall(n) n.rbegin(), n.rend()
#define rep(i,s,n) for(int i=s;i<int(n);i++)


int32_t main() 
{	iyas_salah
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	/* ---code--- */	 	    
	
	int k , a, b;
	cin >> k >> a >> b;
	for (int i = a; i <=b ;i++) { 
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	/* ---------- */
	return 0;		
}

Measured memory_bytes: 3652
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int temp[] = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			temp[i] = x[i]+y[i];
		}
		Arrays.sort(temp);
		int ans = temp[n-1]-temp[0];
		for(int i = 0; i < n; i++) {
			temp[i] = x[i]-y[i];
		}
		Arrays.sort(temp);
		if(ans<temp[n-1]-temp[0]) ans=temp[n-1]-temp[0];
		System.out.println(ans);
	}
}

Measured memory_bytes: 63680
n,x,y = map(int,raw_input().split(' '))

import collections
h = collections.Counter()
for i in range(1, n+1):
	for j in range(i+1, n+1):
		h[min(abs(j - i), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))] +=1
for distance in range(1, n):
	print h[distance]


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

int main(void){
	int n;
	double lo;
	int num[6]={0};
	cin>>n;

	for(int i=0;i<n;i++){
		cin>>lo;
		if(lo<165.0) num[0]++;
		if(lo>=165.0&&lo<170.0) num[1]++;
		if(lo>=170.0&&lo<175.0) num[2]++;
		if(lo>=175.0&&lo<180.0) num[3]++;
		if(lo>=180.0&&lo<185.0) num[4]++;
		if(lo>=185.0) num[5]++;
	}
	for(int i=0;i<6;i++){
		cout<<i+1<<":";
		for(int j=0;j<num[i];j++){
			cout<<"*";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

void a(){
    int A, P; cin >> A >> P;

    int p = A*3 + P;
    cout << p/2;

}

void b(){
    int N; cin >> N;
    vector<pair<string,int>> vec(N);
    for(int i = 0; i < N; i++){
        string s; cin >> s;
        int p; cin >> p;

        vec[i] = make_pair(s,-p);
    }
    vector<int> idx(N);
    for(int i = 0; i < N; i++){
        idx[i] = i;
    }

    sort(idx.begin(),
         idx.end(),
         [&vec](int idx1, int idx2){return (vec[idx1] < vec[idx2]);}
    );


    for(int i = 0; i < N; i++){

        cout << idx[i] + 1 << endl;
    }

}

bool is_mem(int bit, int i){

    return bit & (1 <<i);
}

bool is_lamp_on(int bit, const vector<int> &connected, int p){
    int on_switch = 0;
    for(int n: connected){
        if (is_mem(bit, n)) on_switch++;
    }

    return (on_switch%2 == p);

}
void c(){
    int N, M; cin >> N >> M;

    vector<vector<int>> connect(M);
    for(int i = 0; i < M; i++){

        int k; cin >> k;
        for(int j = 0;j<k; j++ ){
            int s_ij; cin >> s_ij; s_ij--;
            connect[i].push_back(s_ij);
        }
    }
    vector<int> p_vec(M);
    for(int i = 0; i < M; i++){
        cin >> p_vec[i];
    }

    int count = 0;
    for(int bit = 0; bit < (1<<N); ++bit){
        bool all_on = true;
        for(int m = 0; m < M; m++){// 全てonになるか？
            if (!is_lamp_on(bit, connect[m], p_vec[m])) {
                all_on = false;
                break;
            }
        }
        if (all_on) count++;
    }

    cout << count;

}

int calc_value(vector<int> & vec, int l, int r, int k){
    int N = vec.size();
    priority_queue<int, vector<int>, greater<int> > minus_value;
    int sum = 0;
    for(int i = 0; i < l; i++){
        sum += vec[i];
        if (vec[i] < 0) minus_value.push(vec[i]);
    }
    for(int i = N-1; N - r <= i; i--){
        sum += vec[i];
        if (vec[i] < 0) minus_value.push(vec[i]);
    }

    int remain = k - (l+r);
    while(remain >0 && !minus_value.empty()){
        remain--;
        int top = minus_value.top();
        sum += -top;
        minus_value.pop();
    }

    return sum;

}

int calc_value_bug(vector<int> & vec, int l, int r, int k){
    int N = vec.size();
    priority_queue<int, vector<int>, greater<int> > minus_value;
    int sum = 0;
    for(int i = 0; i < l; i++){
        sum += vec[i];
        if (vec[i] < 0) minus_value.push(vec[i]);
    }
    for(int i = N-1; N - r <= i; i--){
        sum += vec[i];
        if (vec[i] < 0) minus_value.push(vec[i]);
    }

    int remain = k - (l+r);
    while(remain >0 && !minus_value.empty()){
        remain--;
        sum += -minus_value.top();
        minus_value.pop();
    }

    return sum;


}
void d(){
    int N; int K; cin >> N >> K;

    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }
    int max_value = 0;
    for(int l = 0; l <=K; l++)
        for(int r = 0; l + r <= K && l + r <= N;r++){
            int value = calc_value_bug(vec, l,r,K);
            max_value = max(max_value, value);
        }

    cout << max_value;

}
int main(){
   d();
}

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

int main() {
	int h, w; cin >> h >> w;
	vector<vector<char>> s(h, vector<char>(w));
	rep(i, 0, h) rep(j, 0, w) cin >> s[i][j];

	string ans = "Yes";
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (s[i][j] == '#') {
				if (0 < i) {
					if (s[i - 1][j] == '#') continue;
				}
				if (i < h - 1) {
					if (s[i + 1][j] == '#') continue;
				}
				if (0 < j) {
					if (s[i][j - 1] == '#') continue;
				}
				if (j < w - 1) {
					if (s[i][j + 1] == '#') continue;
				}
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2019/03/20
 *      Author: maleicacid
 */

#include <climits>
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

long gcd(long a, long b)
{
	long g = (a>b)? a % b: b % a;
	if(g==0) return min(a,b);
	else
	{
		return gcd(g, min(a, b));
	}
}

int main()
{
	int n;
	scanf("%d",&n);

	set<long> s;
	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		s.emplace(a);
	}


	while(s.size() >1)
	{
		long a = gcd(*(s.begin()), *next(s.begin()));
		s.erase(s.begin());
		s.erase(s.begin());
		s.emplace_hint(s.begin(),a);
	}

	printf("%ld\n", *(s.begin()));

}


Measured memory_bytes: 4864
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
a = []
for i in range(n):
    a.append(int(input()))

l = {}
for _a in a:
    if _a in l:
        l.pop(_a)
    else:
        l.update(
            {_a: True}
        )

print(len(l))


Measured memory_bytes: 20600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int cnt = 0;
        int endCnt = 0;
        int startCnt = 0;
        int doubleCnt = 0;

        for (int i = 0; i < n; i++) {
        	String s = input.next();
        	if (s.startsWith("B")) {
        		startCnt++;
        	}
        	if (s.endsWith("A")) {
        		endCnt++;
        	}
        	if (s.startsWith("B") && s.endsWith("A")) {
        		doubleCnt++;
        	}
        	int index = s.indexOf("AB");
        	while (index != -1) {
        		cnt++;
        		index = s.indexOf("AB", index + 1);
        	}
        }

        int combiCnt = Math.min(startCnt, endCnt);

        if (startCnt != 0 && startCnt == endCnt && doubleCnt == endCnt) {
        	combiCnt = combiCnt - 1;
        }

        int ans = cnt + combiCnt;

        System.out.println(ans);
    }
}


Measured memory_bytes: 30048
import itertools

N, M = map(int, input().split())

graph = [[False]*N for _ in range(N)]

for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a][b] = True
    graph[b][a] = True

ans = 0

#頂点を並び替える順列を生成してループ
for path in itertools.permutations(range(N), N):
    if path[0] == 0: #先頭が頂点1の時
        for i in range(N):
            if i==N-1:
                ans += 1
                break
            if not graph[path[i]][path[i+1]]:
                break
print(ans)


Measured memory_bytes: 9232
#include <stdio.h>
static int a, b, c, arr[11];
int main(void) {
    scanf("%d%d%d", &a, &b, &c);
    ++arr[a];
    ++arr[b];
    ++arr[c];
    puts(arr[5] == 2 && arr[7] == 1 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 128
def p_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    m = max(A)
    a = A.index(m)
    A.pop(a)
    b = max(A)

    for i in range(N):
        if i == a:
            print(b)
        else:
            print(m)


if __name__ == '__main__':
    p_c()


Measured memory_bytes: 12532
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,m,count = 0;
    double sum = 0,ave = 0;
    cin >> n >> m;

    vector<double>v(n);

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

    ave = sum/(4.0*m);

    sort(v.begin(),v.end(),greater<int>());

    for(auto &i:v){
        if(i >= ave)count++;
    }

    if(count >= m)cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    long N, P;
    cin >> N >> P;

    // 割る数の初期値
    long  a = 2, count = 0, ans = 1;
    // √P ≧ a ( n ≧ a * a ) の間ループ処理
    while (P >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (P % a == 0) {
            count++;
            P /= a;
            if(count%N == 0){
                //cout << "OK" << endl;
                ans *= a;
            }
        } else {
            a++;
            //cout << a << endl;
            count = 0;
        }
    }
    if(N == 1) ans *= P;
    else if(count == N-1) ans *= P;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using ll=long long;
using pl  = pair<ll,ll>;
using pii  = pair<int,int>;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

map<ll,ll> M;

int main(){
  ll N,A[200007];
  cin >> N;
  rep(i,N){
    ll X;
    cin >> X;
    M[X]++;
    if(M[X]>1){
      cNO;
      return 0;
    }
  }
  cYES;
}

Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

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

int main() {
	IOS;
	int N,x;
	cin >> N;
	vector<int> v;
	REP(i, N) {
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end(),greater<int>());
	int ans = 0;
	REP(i, N) {
		ans += (v[i] - 1);
	}
	cout << ans << endl;
}



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

int main()
{
  string S;
  cin >> S;
  string ans = "Yes";

  rep(i, S.size())
  {
    if (S[i] == 'U' || S[i] == 'D')
      continue;

    if ((i + 1) % 2 == 1 && S[i] == 'R')
      continue;
    else if ((i + 1) % 2 == 0 && S[i] == 'L')
      continue;

    ans = "No";
    break;
  }

  cout << ans << endl;

  return 0;
}

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

#define o(output) cout << output << endl

using namespace std;

string s;
int a,b,c,d;

int main(){
  cin >> a>>b>>c>>d;
  if(a+b>c+d){
    o("Left");
  }else if(a+b==c+d){
    o("Balanced");
  }else{
    o("Right");
  }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])

    if A >= 13:
        return B
    if A >= 6:
        return B//2
    return 0


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n, k;

int main(int argc, char *argv[]){
    cin >> n >> k;
    double ans = 0;
    rep(i, n){
        int c = i + 1;
        if(c >= k) { ans += (double)1/n; continue; }
        int d = 0;
        while(c <= k - 1) {c *= 2; d++;}
        ans += (double)1/n * pow(0.5, d);
        // printf("%.16lf\n", ans);
    }
    printf("%.16lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
LL gcd(LL a, LL b)
{
	if (!a)
		return b;
	return gcd(b%a, a);
}
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
int main()
{
	int n,k;
	cin >> n>>k;
	VI v(n);
	rep(i, n)cin >> v[i];
	vector<int>dp(n);
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for (int i = 2; i < n; i++) {
		int mini = INT_MAX;
		for (int k1 = 1; k1 <=k; k1++) {
			if(i-k1>=0)
			mini = min(mini, dp[i - k1] + abs(v[i - k1] - v[i]));
		}
		dp[i] = mini;
	}

	cout << dp[n - 1] << endl;





}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
const db eps = 1e-8;

char io[1<<15],*is=io,*ie=io+1;
#define rd if(++is==ie)ie=(is=io)+fread(io,1,sizeof(io),stdin)
template<class T>
inline bool Cin(T &a){
	a=0;bool s=0;
	if(is==ie)return 0;
	do{rd;if(*is=='-')s=1;}while(!isdigit(*is)&&is!=ie);
	if(is==ie)return 0;
	do{(a*=10)+=*is&15;rd;}while(isdigit(*is)&&is!=ie);
	if(s)a=-a;;return 1;}

inline int Gets(char a[]){
	int p=0;
	if(is==ie)return 0;
	do rd; while(!isgraph(*is)&&is!=ie);
	if(is==ie)return 0;
	do {a[p++]=*is;rd;}while(isgraph(*is)&&is!=ie);
	a[p]=0;return p;}

#define maxn 10005

vector<int> p;
bool isp[maxn];
ll a[502][502];

ll lcm(ll x,ll y){return x/__gcd(x,y)*y;}

int main()
{
	int n;
	Cin(n);
	if(n==2)return !printf("4 7\n23 10\n");
	mst(isp,0);p.clear();
	for(int i=2;sz(p)<2000;++i)
	{
		if(!isp[i])p.pb(i);
		for(int j=0;j<sz(p)&&p[j]*i<maxn;++j)
		{
			isp[p[j]*i]=1;
			if(i%p[j]==0)break;
		}
	}
	repb(i,0,n+1)a[0][i]=a[n+1][i]=a[i][0]=a[i][n+1]=1;

	repb(i,1,n)repb(j,1,n)if((i+j)%2==0)
		a[i][j]=p[(i+j)/2-1]*p[n+(i+n-j)/2-1];
	
	repb(i,1,n)repb(j,1,n)if((i+j)%2==1)
		a[i][j]=lcm(a[i-1][j],lcm(a[i+1][j],lcm(a[i][j-1],a[i][j+1])))+1;
	
	repb(i,1,n)repb(j,1,n)printf("%lld%c",a[i][j]," \n"[j==n]);
	
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

bool isOk(string s)
{
    REP(i, 4)
    {
        string cp = s;
        if (i >= 1) 
        {
            char c1 = cp[i - 1];
            char c2 = cp[i];
            cp.replace(i - 1, 1, string("") + c2);
            cp.replace(i, 1, string("") + c1);
        }
        REP(j, 2) if (cp.substr(j, 3) == "AGC") return false;
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    string useS = "ACGT";
    vector<string> last3;
    REP(i, 4) REP(j, 4) REP(k, 4) last3.push_back(string("") + useS[i] + useS[j] + useS[k]);
    map<string, ll> dp[N + 1];
    for (int i = 3; i <= N; ++i) 
    {
        for (auto iter = last3.begin(); iter != last3.end(); ++iter)
        {
            if (i == 3)
            {
                if (*iter == "AGC" || *iter == "GAC" || *iter == "ACG") dp[i][*iter] = 0;
                else dp[i][*iter] = 1;
            }
            else
            {
                dp[i][*iter] = 0;
            }
        }
    }

    for (int i = 3; i < N; ++i) 
    {
        for (auto iter = last3.begin(); iter != last3.end(); ++iter)
        {
            REP(j, 4)
            {
                char c = useS[j];
                string check = *iter + c;
                string now = (*iter).substr(1, 2) + c;
                if (isOk((check))) dp[i + 1][now] = (dp[i + 1][now] + dp[i][*iter]) % MOD;
            }
        }
    }

    ll ans = 0;
    for (auto iter = last3.begin(); iter != last3.end(); ++iter) ans = (ans + dp[N][*iter]) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

#define X first
#define Y second

typedef pair<double,double> Pdd;

int main() {
  int n;
  double x, y;
  int cnt = 0;
  double ans;
  vector<Pdd> v;
  
  while(cin>>n, n) {
    v.clear();
    for(int i=0; i<n; i++) { cin>>x>>y; v.push_back(make_pair(x,y)); }
    
    ans = 0;
    for(int i=0; i<n; i++) {
      ans+=(v[(i+1)%n].X-v[i].X)*(v[(i+1)%n].Y+v[i].Y)/2;
    }
    
    printf("%d %.1f\n", ++cnt, ans);
  }
  
  return 0;
}

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


void solve(long long W, long long H, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> a){
    ll x_s, x_l, y_s, y_l;
    x_s = y_s = 0; x_l = W; y_l = H;
    for(ll i=0; i< N; i++){
        if(a[i]==1){
            x_s = max(x_s, x[i]);
            x_s = min(x_s, x_l);
        }
        if(a[i]==2){
            x_l = min(x_l,x[i]);
            x_l = max(x_s, x_l);
        }
        if(a[i]==3){
            y_s = max(y_s, y[i]);
            y_s = min(y_s, y_l);
        }
        if(a[i]==4){
            y_l = min(y_l, y[i]);
            y_l = max(y_s, y_l);
        }
    }
    cout << (max(0LL, x_l-x_s)*max(0LL, y_l-y_s)) << endl;
}

int main(){
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&a[i]);
    }
    solve(W, H, N, std::move(x), std::move(y), std::move(a));
    return 0;
}


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

using namespace std;


void func()
{
	int A, B, K;
	bool flag(false);
	cin >> K;
	cin >> A >>B;

	flag = (A % K == 0 || B % K == 0 || (int)(A / K) != (int)(B / K));

	if (flag)
		cout << "OK\n";
	else
		cout << "NG\n";

}

int main() {

//	while (1)
		func();
	return 0;
}


Measured memory_bytes: 3040
import sys
readline = sys.stdin.readline
from heapq import heapify, heappush, heappop

def dijkstra(path, N, start):
    visited = [False] * N
    que = [(0, start)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[start] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))

    return dist

def main():
    N = int(readline())
    path = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = map(int, readline().rstrip().split())
        path[u-1].append((w, v-1))
        path[v-1].append((w, u-1))
    
    dist = dijkstra(path, N, 0)
    for d in dist:
        if d % 2 == 0:
            print(0)
        else:
            print(1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 47840
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

typedef long long int ll;

int main() {
	optimizar_io
	int n, a[110], b[110], cnt = 0;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	bool ans = false;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans |= (cnt >= 3);
	}
	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main(void){
	
	int n,m;
	
	while(cin >> n,n){
		vector<int>v[101];
		for(int i=0;i<n;i++){
			cin >> m;
			int a;
			for(int j=0;j<m;j++){
				cin >> a;
				v[i].push_back(a);
			}
			sort(v[i].begin(),v[i].end());
		}
		int k;
		cin >> k;
		vector<int>l(k);
		for(int i=0;i<k;i++)cin >> l[i];
		
		int ans=0,id=-1;
		for(int i=0;i<n;i++){
			bool fg=true;
			for(int j=0;j<l.size();j++)
				if(!binary_search(v[i].begin(),v[i].end(),l[j]))fg=false;
			if(fg)ans++,id=i;
		}
		if(ans==1)cout << id+1 << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
string s;
int main(void){
    int sum = 700;
    cin >> s;
    rep(i, 3) {
        if (s[i] == 'o') sum += 100;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3620
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)[:x]
q = sorted(list(map(int, input().split())), reverse=True)[:y]
r = list(map(int, input().split()))
print(sum(sorted(p + q + r, reverse=True)[:x+y]))

Measured memory_bytes: 22504
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final long K = sc.nextLong();
			
			long[] as = new long[N];
			for(int i = 0; i < N; i++) {
				as[i] = sc.nextLong();
			}
			final long sum = Arrays.stream(as).sum();
			
			long l = 0, r = Arrays.stream(as).max().getAsLong() + 1;
			while(l + 1 < r) {
				final long m = (l + r) / 2;
				
				long count = 0;
				for(int i = 0; i < N; i++) {
					count += as[i] / m - (as[i] % m == 0 ? 1 : 0);
				}
				//System.out.println(m + " " + count);
				
				if(count <= K) {
					r = m;
				}else {
					l = m;
				}
			}
			
			System.out.println(r);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 57528
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	int* mon = new int[N];
	int* hest = new int[N];
	int maxH = 0;
	for (int i = 0; i < N; ++i)
	{
		scanf("%d",&mon[i]);
		maxH = max(maxH, mon[i]);
		hest[i] = maxH;
	}
	int count = 0;
	for (int i = 0; i < N; ++i)
	{
		if (mon[i] >= hest[i])
			count ++;
	}
	printf("%d\n", count);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_M 100'001

typedef long long ll;

using namespace std;

int X[MAX_M];
int _X[MAX_M];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    cin >> X[i];
  }
  if (M == 1) {
    printf("0\n");
    return 0;
  }
  sort(X, X + M);
  ll res = 0;
  for (int i = 0; i < M - 1; ++i) {
    _X[i] = abs(X[i + 1] - X[i]);
    res += _X[i];
  }
  sort(_X, _X + M - 1);
  for (int i = 0; i < min(N - 1, M - 1); ++i) {
    res -= _X[M - 2 - i];
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;

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

  vector<vector<int>> dp(401, vector<int>(401,INF));

  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {

    for (int j = 400; j >= 0; j--) {
      for (int k = 400; k >= 0; k--) {
        if (dp[j][k] == INF) continue;
        if (j + a[i] <= 400 && k + b[i] <= 400) {
          dp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
        }
      }
    }

  }
  int res = INF;
  for (int i = 1; i <= 400; i++) {
    for (int j = 1; j <= 400; j++) {
      if (i * mb == j * ma) res = min(res, dp[i][j]);
    }
  }
  if (res == INF) cout << -1 << endl;
  else cout << res << endl;
  return 0;  
} 

Measured memory_bytes: 896
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> N >> K;
	vector<long long int>v(N + 2);
	for (int i = 1; i <= N; i++)cin >> v[i];
	v[0] = -MOD * MOD;
	v.back() = MOD * MOD;
	cin >> T;
	N += 2;
	vector<vector<long long int>>ord_tapi(N, vector<long long int>(20, -1));
	vector<vector<long long int>>ord_sum(N, vector<long long int>(20));
	vector<vector<long long int>>rev_tapi(N, vector<long long int>(20, -1));
	vector<vector<long long int>>rev_sum(N, vector<long long int>(20));
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		while (cnt != -1 && v[cnt] - v[i] < K) {
			cnt++;
			if (cnt == N) {
				cnt = -1;
				break;
			}
		}
		ord_tapi[i][0] = cnt;
		ord_sum[i][0] = i;
	}
	for (int j = 1; j < 20; j++) {
		for (int i = 0; i < N; i++) {
			if (ord_tapi[i][j - 1] == -1)continue;
			ord_tapi[i][j] = ord_tapi[ord_tapi[i][j - 1]][j - 1];
			ord_sum[i][j] = ord_sum[i][j - 1] + ord_sum[ord_tapi[i][j - 1]][j - 1];
		}
	}
	cnt = N - 1;
	for (int i = N - 1; i >= 0; i--) {
		while (cnt != -1 && v[i] - v[cnt] < K) {
			cnt--;
			if (cnt == -1) {
				cnt = -1;
				break;
			}
		}
		rev_tapi[i][0] = cnt;
		rev_sum[i][0] = i;
	}
	for (int j = 1; j < 20; j++) {
		for (int i = 0; i < N; i++) {
			if (rev_tapi[i][j - 1] == -1)continue;
			rev_tapi[i][j] = rev_tapi[rev_tapi[i][j - 1]][j - 1];
			rev_sum[i][j] = rev_sum[i][j - 1] + rev_sum[rev_tapi[i][j - 1]][j - 1];
		}
	}
	while (T--) {
		cin >> L >> R;
		long long int ans = 0;
		int num = 0;
		int p = L;
		for (int cnt = 19; cnt >= 0; cnt--) {
			if ((ord_tapi[p][cnt] != -1 && ord_tapi[p][cnt] <= R)) {
				num |= 1 << cnt;
				ans -= ord_sum[p][cnt];
				p = ord_tapi[p][cnt];
			}
		}
		ans -= ord_sum[p][0];
	//	cout << num << endl;
	//	cout << ans << endl;
		num = 0;
		p = R;
		for (int cnt = 19; cnt >= 0; cnt--) {
			if ((rev_tapi[p][cnt] != -1 && rev_tapi[p][cnt] >= L)) {
				num |= 1 << cnt;
				ans += rev_sum[p][cnt];
				p = rev_tapi[p][cnt];
			}
		}
		ans += rev_sum[p][0];
		cout << ans + num + 1 << endl;
	}
}

Measured memory_bytes: 161004
#include <climits>
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	unsigned long long l, r;
	cin >> l >> r;
	
	int min = INT_MAX;
	int ct1 = 1;
	int ct2 = 1;
	for (unsigned long long i = l; i < r; i++) {
		if (ct1 > 2019) {
			ct1 = 1;
			break;
		}
		for (unsigned long long j = i + 1; j <= r; j++) {
			if (ct2 > 2019) {
				ct2 = 1;
				break;
			}
			int mul = (i * j) % 2019;
			if (mul < min) {
				min = mul;
			}
			ct2++;
		}
		ct1++;
	}
	
	cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int
main (
  int   argc,
  char *argv[ ]
  )
{
  int a, b;
 
  scanf ( "%d%d", &a, &b );
  printf ( "%d %d %.5f\n", a / b, a % b, (double)a / b );
 
  return ( 0 );
}

Measured memory_bytes: 640
N, K = map(int, input().split())
d = [0] * K
A = [0] * K
for i in range (K):
	d[i] = map ( int, input() .split())
	A[i] = list(map(int, input().strip().split())) 

S = [False] * N

for i in range (K):
	for j in A[i]:
		S[j-1] = True

print (S.count(False))
	

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ull L[87];

int main()
{
	int N;

	L[0] = 2;
	L[1] = 1;

	repc(i, 2, 87) L[i] = L[i - 1] + L[i - 2];

	cin >> N;
	cout << L[N] << endl;

	return 0;
}

Measured memory_bytes: 256