akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int r, g;
	string e;
	cin >> r >> e;
	g = r / 2;
	if (r % 2 == 0) {
		int ans = 0;
		for (int i = 0; i < g; i++) {

			if (e.at(i) == e.at(i + g)) {
				ans++;
			}
			else {
				break;
			}
		}
		if (ans == g)
			cout << "Yes" << endl;

		else
			cout << "No" << endl;

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

}

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

inline double calcDistance(double x, double y){
	return hypot(x, y);
}

int main(){
	int num;
	std::cin >> num;
	
	for(int i = 0; i < num; ++i){
		double xa, xb, ya, yb, ra, rb;
		std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = calcDistance(xa - xb, ya - yb);
		
		int answer = 1;
		if(ra + rb < d) //重なっていないとき
			answer = 0;
		else if(ra - rb > d) //BがAの中にあるとき
			answer = 2;
		else if(rb - ra > d) //AがBの中にあるとき
			answer = -2;
		std::cout << answer << std::endl;
	}
}

Measured memory_bytes: 1244
# Graph II - Minimum Spanning Tree
def mst(length, adj_m):
    """ Prims's Algorithm """
    cost = 0
    X,Y = [0], [i+1 for i in range(length-1)]
    while len(Y):
        min_cost = 2001
        ey = -1
        for x in X:
            for y in Y:
                t = adj_m[x][y]
                if not t == -1:
                    if min_cost > t:
                        min_cost = t
                        ey = y
        X.append(ey)
        Y.remove(ey)
        cost += min_cost
    return cost

n = int(input())
adj_m = [[-1 for _ in range(n)] for _ in range(n)]
for j in range(n):
    for i,v in enumerate(input().split()):
        adj_m[j][i] = int(v)
min_weight = mst(n, adj_m)
print(min_weight)


Measured memory_bytes: 8000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0026
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            Ink ink = new Ink();
            int zero = 0;
            int max = 0;
            while ((str = Console.ReadLine()) != null)
            {
                string[] str1 = str.Split(',');
                int x = int.Parse(str1[0]);
                int y = int.Parse(str1[1]);
                int s = int.Parse(str1[2]);
                switch (s)
                {
                    case 1:
                        ink.Small(x, y);
                        break;

                    case 2:
                        ink.Regular(x, y);
                        break;

                    case 3:
                        ink.Large(x, y);
                        break;
                }
            }
            zero = ink.CountZero();
            max = ink.HighNumber();
            Console.WriteLine(zero);
            Console.WriteLine(max);

        }
    }
    class Ink
    {
        Paper paper = new Paper();
        internal void Plus1(int a, int b)
        {
            if (0 <= a && a < 10 && 0 <= b && b < 10)
            {
                paper.paperList[a][b]++;
            }
        }
        internal void Small(int x, int y)
        {
            Plus1(x - 1, y);
            Plus1(x, y - 1);
            Plus1(x, y);
            Plus1(x + 1, y);
            Plus1(x, y + 1);
        }
        internal void Regular(int x, int y)
        {
            Plus1(x - 1, y - 1);
            Plus1(x, y - 1);
            Plus1(x + 1, y - 1);
            Plus1(x - 1, y);
            Plus1(x, y);
            Plus1(x + 1, y);
            Plus1(x - 1, y + 1);
            Plus1(x, y + 1);
            Plus1(x + 1, y + 1);
        }
        internal void Large(int x, int y)
        {
            Plus1(x, y - 2);
            Plus1(x - 1, y - 1);
            Plus1(x, y - 1);
            Plus1(x + 1, y - 1);
            Plus1(x - 2, y);
            Plus1(x - 1, y);
            Plus1(x, y);
            Plus1(x + 1, y);
            Plus1(x + 2, y);
            Plus1(x - 1, y + 1);
            Plus1(x, y + 1);
            Plus1(x + 1, y + 1);
            Plus1(x, y + 2);
        }
        internal int CountZero()
        {
            int i = 0;
            for (int j = 0; j < 10; ++j)
            {
                i += paper.paperList[j].Count(x => x == 0);
            }
            return i;
        }
        internal int HighNumber()
        {
            List<int> list = new List<int>();
            for (int i = 0; i < 10; ++i)
            {
                list.Add(paper.paperList[i].Max());
            }
            return list.Max();
        }
    }
    class Paper
    {
        internal List<int[]> paperList = new List<int[]>();
        public Paper()
        {
            for (int i = 0; i < 10; ++i)
            {
                paperList.Add(new int[10]);
            }
        }
    }
}



Measured memory_bytes: 16308
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d[26] = {};
    int n;
    cin >> n;
    rep(i, 0, 26) d[i] = INF;
    rep(i, 0, n){
        string s;
        cin >> s;
        int tmp[26] = {};
        rep(j, 0, s.size()){
            tmp[s[j] - 'a']++;
        }
        rep(j, 0, 26) chmin(d[j], tmp[j]);
    }
    string ans = "";
    rep(i, 0, 26){
        rep(j, 0, d[i]) ans += 'a' + i;
    }
    cout << ans << endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 18, INF = 0x3f3f3f3f;

int n, a[N], b[N], s[N];

int getv(int x, int k) {
	return (x & 1) == k ? a[x] : b[x];
}

int main() {
	read(n);
	for (int i = 0; i < n; ++i) {
		read(a[i]);
	}
	for (int i = 0; i < n; ++i) {
		read(b[i]);
	}
	int ans = INF;
	for (int S = 0; S < (1 << n); ++S) {
		std::vector<int> p[2];
		for (int i = 0; i < n; ++i) {
			p[S >> i & 1].push_back(i);
		}
		if ((int)p[1].size() != n / 2) {
			continue;
		}
		std::sort(p[0].begin(), p[0].end(), [&](int x, int y) {
			return getv(x, 0) < getv(y, 0);
		});
		std::sort(p[1].begin(), p[1].end(), [&](int x, int y) {
			return getv(x, 1) < getv(y, 1);
		});
		bool flag = 1;
		for (int i = 0; i < n; ++i) {
			s[i] = p[i & 1][i >> 1];
			if (i && getv(s[i], i & 1) < getv(s[i - 1], (i - 1) & 1)) {
				flag = 0;
				break;
			}
		}
		if (!flag) {
			continue;
		}
		int sum = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				sum += s[i] > s[j];
			}
		}
		ans = std::min(ans, sum);
	}
	if (ans == INF) {
		print(-1);
	} else {
		print(ans);
	}
}


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

int main(){
	
	
	int arr[6];
	for(int i=0;i<5;i++){
		cin >> arr[i];
	}
	int k;
	cin >> k;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			if(abs(arr[j]-arr[i])>k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,a[100001],b[100001],sum=0,age=0,sage=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
	}
	rep(i,N){
		scan(b[i]);
	}
	rep(i,N){
		if(a[i]-b[i]<0) age+=(b[i]-a[i])/2;
		else if(a[i]-b[i]>0) sage+=a[i]-b[i];
	}
	if(sage<=age) prin("Yes");
	else prin("No");
	return 0;
}


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

int main(void){
    int N;
    int sum=0;
    cin >> N;
    int V[N];
    int C[N];
    for(int i=0;i<N;++i){
        cin >> V[i];
    }
    for(int i=0;i<N;++i){
        cin >> C[i];
    }
    for(int i=0;i<N;++i){
        sum+=max(0,V[i]-C[i]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

struct edge {
	ll to;
	ll cost;
};

bool isBipartite(int pos, int poscol, vector<vector<edge>>& g, vector<int>& col) {
	bool flag = true;
	if (col[pos] != 0) {
		if (col[pos] == poscol)return true;
		else return false;
	}
	else {
		col[pos] = poscol;
		for (int i = 0; i < g[pos].size(); i++) {
			flag = flag & isBipartite(g[pos][i].to, poscol * -1, g, col);
		}
		return flag;
	}
}

int main() {
	int N;
	cin >> N;
	vector<vector<edge>> g(N, vector<edge>());
	vector<vector<ll>> m(N, vector<ll>(N, INF));
	for (int i = 0; i < N; i++) {
		string a;
		cin >> a;
		for (int j = 0; j < N; j++) {
			if (a[j] == '1') {
				g[i].push_back({ j,1 });
				m[i][j] = 1;
			}
			else {
				m[i][j] = INF;
			}
			if (i == j)m[i][j] = 0;
		}
	}
	
	vector<int> col(N, 0);
	if (isBipartite(0, 1, g, col)) {
		for (int k = 0; k < N; k++)for (int i = 0; i < N; i++)for (int j = 0; j < N; j++) {
			m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
		}
		ll ans = -INF;
		for (int i = 0; i < N; i++)ans = max(*max_element(m[i].begin(), m[i].end()), ans);
		cout << ans+1 << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1408
x, y = map(int, input().split())
f = [0] * 15
f[1] = f[3] = f[5] = f[7] = f[8] = f[10] = f[12] = 1
f[4] = f[6] = f[9] = f[11] = 2
print('Yes' if f[x] == f[y] else 'No')

Measured memory_bytes: 3064
fn main() {
    let n: usize = read();
    let mut a: Vec<f64> = read_vec();

    while a.len() > 1 {
        'a: loop {
            for i in 0..a.len()-1 {
                if a[i] > a[i+1] {
                    break;
                } else if i == a.len()-2 {
                    break 'a;
                } else { continue; }
            }
            for i in 0..a.len()-1 {
                if a[i] > a[i+1] {
                    a.swap(i, i+1);
                }
            }
        }
        let val = (a[0] + a[1]) as f64 / 2.0;
        a.remove(0);
        a.remove(0);
        a.push(val);
    }
    println!("{}", a[0]);
}

// ########################################################################################### //

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int i=1;
		while(true) {
			int x=scan.nextInt();
			if(x==0) break;
			System.out.println("Case "+i+": "+x);
			i++;
		}
		scan.close();
}
}


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

int main(){
    int N;cin>>N;
    vector<ll> a(N),b(N),c(N);
    rep(i,N)cin>>a[i]>>b[i]>>c[i];
    vector<vector<ll>> dp(N+1,vector<ll>(3));
    rep(i,3)dp[0][i]=0LL;
    rep(i,N){
        dp[i+1][0]=max(dp[i][1],dp[i][2])+a[i];
        dp[i+1][1]=max(dp[i][0],dp[i][2])+b[i];
        dp[i+1][2]=max(dp[i][0],dp[i][1])+c[i];
    }
    cout<<max(dp[N][0],max(dp[N][1],dp[N][2]))<<endl;
    return 0;
}

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

int main() {
  int n, m, correct = 0, pena = 0;
  cin >> n >> m;
  vector<int> ac(n+1, 0), tpena(n+1, 0);
  
  for (int i = 0; i < m; ++i) {
    int p;
    string s;
    cin >> p >> s;
   	if (ac[p]) continue;
    if (s == "AC") {
      ac[p] = 1;
      ++correct;
      pena += tpena[p];
    }
    else if (s == "WA")
      ++tpena[p];
  }
  printf("%d %d\n", correct, pena);
}

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

void solve(std::string S)
{
    int res = 0;
    for (size_t i = 0; i < S.size() / 2; i++)
    {
        res += static_cast<int>(S[i] != S[S.size() - i - 1]);
    }
    cout << res << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
using System;
class Tenka1_2019_A
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);

        if ((A <= C && C <= B) || (B <= C && C <= A))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
n=int(input())
h=list(map(int,input().split()))
count=0
ma=0
for i in range(1,n):
  if h[i]<=h[i-1]:
    count+=1
    continue
  elif count>ma:
    ma=count
  count=0
if count>ma:
  ma=count
print(ma)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	map<char,int> mp;
	rep(i,4)mp[s[i]]++;
	bool ans=true;
	for(auto x:mp)if(x.sc!=2)ans=false;
	Yn(ans);
}


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

using namespace std;

int main() {

    int n,x,t;
    cin >> n >> x >> t;

    int cur = 0;
    int ans = 0;
    while(cur < n) {
        cur += x;
        ans += t;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, ll> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, a[MAX_N], f, s;
    cin >> n;
    REP(i,n) {
        cin >> a[i];
        if(f < a[i]){
            s = f;
            f = a[i];
        }
        else if(s < a[i]){
            s = a[i];
        }
    }
    REP(i,n){
        if(a[i] < f){
            cout << f << endl;
        }
        else{
            cout << s << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

struct P {
  int a, b;
};
P ps[200000+10];
// bool operator<(const P& p1, const P& p2) {
//   if((p1.b-p1.a) != (p2.b-p2.a)) {
//     return (p1.b-p1.a) > (p2.b-p2.a);
//   } else {
//     return p1.b > p2.b;
//   }
// }

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d%d", &ps[i].a, &ps[i].b);
  }
  ll sum = 0;
  const ll INF = 1e15;
  ll mini = INF;
  REP(i, n) {
    sum += ps[i].a;
    if(ps[i].a > ps[i].b) {
      mini = min(mini, ll(ps[i].b));
    }
  }
  if(mini == INF) {
    cout << 0 << endl;
  } else {
    cout << sum - mini << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
n, y = map(int, input().split())

for i in range(0, n+1):
    for j in range(0, n+1-i):
            if (n-i-j)*10000+j*5000+i*1000==y:
                print(n-i-j, j, i)
                exit()
print(-1, -1, -1)

Measured memory_bytes: 9164
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


struct aa {
	int a, b;
	bool operator<(const aa& rhs)const {
		return b < rhs.b;
	}
}rifa[200010];
int main() {
	IOS;
	int n; cin >> n;
	repi(0, n)cin >> rifa[i].a >> rifa[i].b;
	sort(rifa, rifa + n);
	int ti = 0, f = 1;
	repi(0, n) {
		ti += rifa[i].a;
		if (ti > rifa[i].b) {
			f = 0;
			break;
		}
	}
	if (f)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int a,b,c;
	std::cin >> a>>b>>c;
	int ans=0;
	for (int i = a; i <=b; i++) {
		/* code */
		if(c%i==0)ans++;
	}
	std::cout << ans << std::endl;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    COMinit();
    for(ll i = 1;i<=K;i++){
//        cout << COM(N-K+1,i) << endl;
        pl(((COM(N-K+1,i)%MOD)*(COM(K-1,K-i)%MOD))%MOD)
    }

    return 0;
}


Measured memory_bytes: 12160
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

class UnionFind {
  public:
    // 親の番号を格納する。親の場合 -1 になる
    vector<int> Parent;

    // 宣言されたとき Parent の値はすべて -1 にする
    UnionFind(int N) { Parent = vector<int>(N, -1); }

    // 与えられた値 x がどの親であるか調べる
    int root(int x) {
        // x が親だったとき
        if (Parent[x] < 0)
            return x;
        // 辺の縮約をいっしょにおこなう
        return Parent[x] = root(Parent[x]);
    }

    // 木の全体の数を返す
    int size(int x) {
        // マイナスがついているのは root
        // 以下の数をマイナスの値で管理しているから
        return -Parent[root(x)];
    }

    // 2つの引数を同じ親にする
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);

        // 同じ親の場合くっつけない
        if (x == y)
            return false;

        // x のほうが必ず大きな size にしたい
        if (size(x) < size(y))
            swap(x, y);
        Parent[x] += Parent[y];
        Parent[y] = x;
        return true;
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    REP(i, M) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    int ans = 0;

    REP(i, M) {
        auto uni = UnionFind(N);
        REP(j, M) {
            if (i == j)
                continue;
            uni.merge(a[j], b[j]);
        }
        if (uni.size(0) < N)
            ans++;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int n, m, ans;
    cin >> n >> m;
    if (n >= 2 && m >= 2) {
        ans = n*(n-1)/2 + m*(m-1)/2;
    }else if(n <= 1 && m > 1) {
        ans = m*(m-1)/2;
    }else if(n > 1 && m <= 1) {
        ans = n*(n-1)/2;
    }else {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, a, b = LI()
    print("Borys" if (b - a) & 1 else "Alice")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include<string>
#include<iostream>
#include<algorithm>
#include<cctype>
using namespace std;
int main(){
    string a,b;
    char T[27]="abcdefghijklmnopqrstuvwxyz";
    int c,d=0,e=0,f,g;
    cin>>c;
    for(int i=0;i<c;i++){
        cin>>a>>b;
        for(int j=0;j<min(a.size(),b.size());j++){
            for(int k=0;k<26;k++){
                if(a[j]==T[k]){
                    f=k;
                }
                if(b[j]==T[k]){
                    g=k;
                }
            }
            if(f<g){
                e += 3;
                goto Exit;
            }
            else if(g<f){
                d += 3;
                goto Exit;
            }
        }
        if(a.size()<b.size()){
            e += 3;
        }
        else if(b.size()<a.size()){
            d += 3;
        }
        else{
            d += 1;
            e += 1;
        }
        Exit:;
    }
    cout<<d<<' '<<e<<endl;
    return 0;
}

Measured memory_bytes: 1204
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  bool found = false;
  for (int i = 0; i * 4 <= n; ++i) {
    int rem = n - i * 4;
    if (rem % 7 == 0) {
      found = true;
    }
  }
  cout << (found ? "Yes" : "No") << endl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

void solve() {
	string s,ans="";
	cin >> s;
	
	for(char c: s) {
		if(c == 'B') {
			ans = ans.substr(0, ans.length()-1);
		} else { 
			ans += c;
		}
	}
	cout << ans << endl;
 		
}
		
			
		

int32_t main() {
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main() {
  int n; 
  cin >> n; 
  int k; 
  cin >> k; 
  int t[10000];
  for (int i = 0; i< n; i ++) 
    cin >> t[i]; 
  sort(t, t + n); 
  int total = 0; 
  for (int i = 0; i < k; i ++) 
    total += t[i]; 
  cout << total << endl; 
  return 0; 
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,m;
  string s;
  cin >> n >> m >> s;
  reverse(ALL(s));
  vector<int> v;
  vector<int> res;
  rep(i,n+1)if(s[i] == '0')v.push_back(i);
  int pos = 0;
  while(pos != n){
    int l = 0,r = v.size();
    while(r-l > 1){
      int mid = (l+r)/2;
      if(v[mid] <= pos+m)l = mid;
      else r = mid;
    }
    if(pos == v[l]){
      cout << -1 << endl;
      return 0;
    }
    res.push_back(v[l]-pos);
    pos = v[l];
  }
  for(int i = res.size()-1;i >= 0;i--)cout << res[i] << endl;




  return 0;
}


Measured memory_bytes: 4236
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

counter = 0

for i in range(n-1):
    for j in range(i+1, n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] -  x[j][k]) ** 2

        distance = distance ** (1/2)
        if distance == int(distance):
            counter += 1

print(counter)


Measured memory_bytes: 3188
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        books: [[usize; m+1];n],
    }

    let mut ans = 100_000_00;
    for i in 0..1 << n {
        let mut score = vec![0; m];
        let mut price = 0;

        for j in 0..n {
            if i >> j & 1 == 1 {
                price += books[j][0];
                for k in 1..=m {
                    score[k - 1] += books[j][k];
                }
            }
        }

        if score.iter().all(|&v| v >= x) {
            ans = min(ans, price);
        }
    }

    if ans != 100_000_00 {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2160
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define maxn 10005
#define LL long long
using namespace std;
int n;
LL a[maxn],b[maxn],s;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++)
		if(a[i]>b[i]) s+=1ll*(a[i]-b[i]);
	for(int i=1;i<=n;i++)
		if(a[i]<b[i])
		{
			int t=(b[i]-a[i])/2;
			s-=t;
		}
	printf("%s\n",s<=0?"Yes":"No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
 		Scanner sc = new Scanner(System.in);

    int n=sc.nextInt();
    boolean ans=false;
    for(int i=0;i<=n/7;i++){
      if((n-i*7)%4==0){
        ans=true;
        break;
      }
    }

    if(ans==true){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

	}
}


Measured memory_bytes: 22992
import sys
sys.setrecursionlimit(10**6)

def dfs(G, v, p):
    for nv in G[v]:
        if nv == p:
            continue
        point[nv] += point[v]
        dfs(G, nv, v)

n, q = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(n-1):
    x, y =  map(int, input().split())
    x, y = x-1, y-1
    G[x].append(y)
    G[y].append(x)

point = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

dfs(G, 0, -1)
print(*point)

Measured memory_bytes: 232852
#include <iostream>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[]) {
  ll x,a,b;
  cin>>x>>a>>b;
  if(b<=a){
    cout<<"delicious"<<endl;
  }else if(a<b&&b<=a+x){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


const int MAX = 510000;
// const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    COMinit();
    reps(i,1,k) cout << COM(k-1,i-1) * COM(n-k+1,i) % MOD << "\n";
    return 0;
}


Measured memory_bytes: 15592
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<deque>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
const int mod=1e9+7;
const double eps=1e-6;
const double pi=acos(-1);
const int inf=0x7fffffff;
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

deque<int>Q;

int main()
{
    int n,t;
    scanf("%d",&n);
    bool normal=true;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&t);
        if(normal)
        {
            Q.push_back(t);
            normal=false;
        }
        else
        {
            Q.push_front(t);
            normal=true;
        }
    }
    if(~n&1)
        while(!Q.empty())
        {
            printf("%d",Q.front());
            Q.pop_front();
            if(!Q.empty())printf(" ");
            else printf("\n");
        }
    else
        while(!Q.empty())
        {
            printf("%d",Q.back());
            Q.pop_back();
            if(!Q.empty())printf(" ");
            else printf("\n");
        }
    return 0;
}


Measured memory_bytes: 2944
local l,r=io.read("*n","*n")

if l%2019+r-l>=2019 then
    print(0)
else
    local minmod=2019
    for i=l,r-1 do
        for j=i+1,r do
            minmod=math.min(minmod,(i%2019)*(j%2019)%2019)
        end
    end
    print(minmod)
end

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

char h[256] = {0};
int G[26][26] = {0};
int V;
int memo[26];

void dfs(int v){
	memo[v] = 1;
	
	for(int i=0 ; i < 26 ; i++ ){
		if( G[v][i] && memo[i] == 0 ){
			dfs( i );
		}
	}
}

int main(){
	int n;
	
	for(int i=0 ; i < 26 ; i++ ){
		h[i] = i + 'a';
		h[i+'a'] = i;
	}
	
	while( cin >> n , n ){
		for(int i=0 ; i < 26 ; i++ ){
			memo[i] = 0;
			for(int j=0 ; j < 26 ; j++ ){
				G[i][j] = 0;
			}
		}
		
		char s;
		char ch[26] = {0};
		for(int i=0 ; i < n ; i++ ){
			string s;
			cin >> s;
			
			int u = h[ s[0] ];
			int v = h[ s[s.size()-1] ];
			s = u;
			ch[u] = ch[v] = 1;
			G[u][v] += 1;
		}
		
		V = 0;
		for(int i=0 ; i < 26 ; i++ ){
			V += ch[i];
		}
		
		bool flag = true;
		for(int u=0 ; u < 26 ; u++ ){
			int out = 0, in = 0;
			for(int v=0 ; v < 26 ; v++ ){
				out += G[u][v];
				in += G[v][u];
			}
			if( in != out ){
				flag = false;
			}
		}
		dfs( s );
		int cnt = 0;
		for(int i=0 ; i < 26 ; i++ ){
			cnt += memo[i];
		}
		if( V != cnt ){
			flag = false;
		}
		cout << ((flag)? "OK" : "NG" ) << endl;
	}
}

Measured memory_bytes: 916
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/17/20 22:14:12
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w,n; cin>>h>>w>>n;
  map<ll,int> cnt;
  for (int i = 0; i < n; i++) {
    int a,b; cin>>a>>b; a--; b--;
    for (int i = -2; i <= 0; i++) {
      if (a+i < 0 or a+i+2 >= h)
        continue;
      for (int j = -2; j <= 0; j++) {
        if (b+j < 0 or b+j+2 >= w)
          continue;
        cnt[(ll(a+i)<<32) + (b+j)]++;
      }
    }
  }
  vector<ll> ans(10);
  ans[0] = ll(h-2)*(w-2);
  for (auto [p,k]:cnt) {
    ans[k]++;
    ans[0]--;
  }
  for (int i = 0; i <= 9; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main(){
  int64_t a,b,c,k;
  cin >>a>>b>>c>>k;
  if(a>=k)
    cout <<k<<endl;
  else if(a+b>=k){
    cout <<a<<endl;
  }
  else
    cout <<a-(k-a-b)<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;

int main() {

	int n; ll s = 0;
	cin >> n;
	int* arr = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		s += arr[i];
	}
	cout<< *min_element(arr,arr+n)<<" "<< *max_element(arr,arr+n)<<" "<<s<<endl;

}



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

class Euler{
public:
  
  int N, root;
  vector<vector<int> > G;
  vector<int> l;
  vector<int> r;
  
  Euler():N(-1){}
  Euler(int N, int root):N(N),root(root),G(N),l(N),r(N){}
  
  void add_edge(int a, int b){
    
    assert( 0 <= a && a < N );
    assert( 0 <= b && b < N );
    
    G[a].push_back(b);
    G[b].push_back(a);
    
  }
  
  void build(){
    
    int cnt = -1;
    
    dfs( root, root, cnt );
    
  }
  
  void dfs(int x, int px, int &cnt){
    
    l[x] = ++cnt;
    
    for(int nx : G[x] ){
      if( nx != px ) dfs( nx, x, cnt );
    }
    
    r[x] = cnt;
    
  }
  
  // [ res.first, res.second ]
  tuple<int,int> getRange(int x){
    return tuple<int,int>( l[x], r[x] );
  }
  
};

class Seg{
public:
  
  int N;
  vector<int> S;
  
  Seg(){}
  Seg(int n){
    
    N = 1;
    
    while( N < n ) N *= 2;
    
    S.resize( N * 2 - 1, 0 );
    
  }
  
  void add(int a, int b, int l, int r, int k, int w){
    
    if( r <= a || b <= l ) return ;
    
    if( a <= l && r <= b ){
      S[k] += w;
      return ;
    }
    
    add( a, b, l, ( l + r ) / 2, k * 2 + 1 , w );
    
    add( a, b, ( l + r ) / 2, r, k * 2 + 2 , w );
    
  }
  
  // [a, b)  
  void add(int a, int b, int w){
    add( a, b, 0, N, 0, w );
  }
  
  int get(int x){
    
    x += N - 1;
    
    int res = S[x];
    
    while( x ){
      
      x = ( x - 1 ) / 2;
      
      res += S[x];
      
    }
    
    return res;
  }
  
};

signed main(){
  
  int N;
  cin >> N;
  
  Euler euler( N, 0 );
  Seg seg( N );
  
  for(int i=0;i<N;i++){
    
    int k;
    cin >> k;
    
    for(int j=0;j<k;j++){
      
      int c;
      cin >> c;
      
      euler.add_edge( i, c );
      
    }
    
  }
  
  euler.build();
  
  int Q;
  cin >> Q;
  
  while( Q-- ){
    
    int flg;
    cin >> flg;
    
    if( flg == 0 ){
      
      int v, w;
      cin >> v >> w;
      
      int l, r;
      
      tie( l, r ) = euler.getRange( v );
      
      seg.add( l, r + 1, w );
      
    }
    else{
      
      int u;
      cin >> u;
      
      int l, r;
      
      tie( l, r ) = euler.getRange( u );
      
      cout << seg.get( l ) << endl;
      
    }
    
  }
  
  return 0;
}



Measured memory_bytes: 14676
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int A[N][3];
    
    for(int i = 0; i < N; i++){
        cin >> A[i][0] >> A[i][1] >> A[i][2];
    }
    
    int dp[N+1][3];
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = -1;
        }
    }
    dp[1][0] = A[0][0];
    dp[1][1] = A[0][1];
    dp[1][2] = A[0][2];
    
    for(int i = 1; i < N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j==k){
                    continue;
                }
                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + A[i][j]);
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < 3; i++){
        ans = max(ans, dp[N][i]);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(std::vector<long long> x){
    ll ans = 0;
    rep(i,x.size()){
        if(x[i] == 0) ans = i+1;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3644
import sys

N, K = map(int, input().split())
A_list = list(map(int, input().split()))

for k in range(N):
    if(A_list[k] == 1):
        k1 = k + 1
        break

ans = sys.maxsize

for k in range(k1 - K + 1, k1 + 1):
    # print(k1, k)
    if(k < 1):
        continue
    tmp_ans = 1
    tmp_ans += (k - 1) // (K - 1)
    if((k - 1) % (K - 1) != 0):
        tmp_ans += 1

    if(k + K <= N):
        tmp = N - k - K + 1
        tmp_ans += tmp // (K - 1)
        if(tmp % (K - 1) != 0):
            tmp_ans += 1

    # print(tmp_ans)
    if(ans > tmp_ans):
        ans = tmp_ans

print(ans)

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

#define INF 100000000

using namespace std;

int V,match[2001];
bool used[2001];
vector<int>G[2001];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  fill(match,match+2001,-1);
  for(int v=0;v<V;v++){
    if(match[v]<0){
      fill(used,used+2001,false);
      if(dfs(v))res++;
    }
  }
  return res;
}

int main(void){

  int n,m,l,u,v,d,graph[101][101],p[1001],t[1001];

  while(cin >> n >> m >> l,n|m|l){  

    for(int i=0;i<2001;i++)G[i].clear();

    fill(graph[0],graph[101],INF);
    for(int i=0;i<101;i++)graph[i][i]=0;
    for(int i=0;i<m;i++){
      cin >> u >> v >> d;
      graph[u][v]=graph[v][u]=d;
    }
    
    for(int i=0;i<l;i++){
      cin >> p[i] >> t[i];
    }
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);

    for(int i=0;i<l;i++){
      for(int j=0;j<l;j++){
	if(i!=j && graph[p[i]][p[j]]+t[i]<=t[j])add_edge(i,j+l);
      }
    }
    V=2*l;
    cout << l-bipartite_matching() << endl;
  }
  return 0;
}

Measured memory_bytes: 9740
N=int(input())
S=input()
ans=0
RGB=[0,0,0]
for i in range(N):
  if S[i]=="R":
    RGB[0]+=1
  if S[i]=="G":
    RGB[1]+=1
  if S[i]=="B":
    RGB[2]+=1
ans=RGB[0]*RGB[1]*RGB[2]    
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]
    t=k+k-i
    if s1==s2:
      continue
    if t<=N-1:
      s3=S[t]
      if s3!=s1 and s3!=s2:
        ans-=1  
    else:
      break
print(ans)        

Measured memory_bytes: 9068