akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define N 8

void print(void);
void backtrack(int);

int a[N][N] = {{}};
int row[N] = {};
int l[15] = {};
int r[15] = {};
int s[N] = {};

int main(){


  int i,j,r,c,k;


  scanf("%d",&k);

  for(i = 0;i < k;i++){
    scanf("%d%d",&r,&c);
    a[r][c] = 1;
  }
  backtrack(0);

  return 0;
}

void backtrack(int i){
  int j;

  if(i == N){
    print();
    return;
  }

  for(j = 0;j < N;j++){
    if(s[j] == 1 || l[i + j] == 1 || r[i - j + N - 1] == 1) continue;

    row[i] = j;
    l[i + j] = r[i - j + N - 1] = s[j] = 1;

    backtrack(i + 1);

    row[i] = s[j] = l[i + j] = r[i - j + N - 1] = 0;

  }

}

void print(){

  int i,j;

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(a[i][j] == 1){
        if(row[i] != j) {
          return;
        }
      }
    }
  }
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }

}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;
const int INF=1e5;

int main(){
  long long n, c, k, t[100009];
  cin >> n >> c >> k;
  for(int i=0;i<n;i++)cin >> t[i];
  long long cnt=0;
  sort(t, t+n);
  long long last=0;
  long long cc=0;
  for(int i=0;i<n;i++){
    if(last<t[i] || cc+1>c){
      cnt++;
      cc=1;
      last=t[i]+k;
    }
    else{
      cc++;
    }
  }
  cout << cnt << endl;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll a, b;

int main()
{
  std::cin >> a >> b;

  std::cout << (a+b+1)/2 << std::endl;

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s;
  cin>>s;
  int n=s.size();
  bool ok = (n%2) == 0;
  for(auto&& i:irange(0,n)) {
    if (i%2) {
      ok = ok && s[i] == 'i';
    } else {
      ok = ok && s[i] == 'h';
    }
  }
  if(ok) {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		if (b == c) {
			cout << 1 << endl;
		}
		else {
			cout << 2 << endl;
		}
	}
	else {
		if (a == c) {
			cout << 2 << endl;
		}
		else {
			if (b == c) {
				cout << 2 << endl;
			}
			else {
				cout << 3 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random

n,m,c = map(int,input().split())
B = [int(i) for i in input().split()]
A = []
for i in range(n):
    a = [int(i) for i in input().split()]
    A.append(a)

A = np.array(A)
B = np.array(B)

ans = 0

# print(np.dot(A[0],B))
for i in range(n):
    if np.dot(A[i],B)+c>0:
        ans += 1

print(ans)


Measured memory_bytes: 24136
#include <bits/stdc++.h>
#include <string.h>
#define ll long long
using namespace std;
struct value
{
	ll x;
	ll y;
};
bool compare(value a, value b)
{
	//for descending order replace with a.roll >b.roll
	if (a.y < b.y)
		return 1;
	else
		return 0;
}
ll sum(ll n)
{
	ll c;
	ll sum1=0;
	while(n>0)
	{
		c=n%10;
		sum1=sum1+c;
		n=n/10;
	} return sum1;
}
ll minm(ll arr[],ll n)
{
	ll mi=arr[0];
	for(ll i=0;i<n;i++)
	{ 
		if(mi>arr[i])
	     mi=arr[i];
	}
	return mi;
}
ll maxm(ll arr[],ll n)
{
	ll ma=arr[0];
	for(ll i=0;i<n;i++)
	{ 
	if(ma<arr[i])
	     ma=arr[i];
	}
	return ma;
}
ll pos(ll arr[],ll n)
{
	ll o=maxm(arr,n);
	ll po;
	for(ll i=0;i<n;i++)
	{
		if(arr[i]==o)
		   po=i;
	}return po;
}
void pk()
{
	string s,t;
	cin>>s;
	cin>>t;
	ll flag=0;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			flag=1;break;
		}
	}
	if(flag==1)
	   cout<<"No";
	   else cout<<"Yes";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
		pk();
	//}
	
}

Measured memory_bytes: 3588
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int[,] b = new int[a, 4];
        for(int i = 0; i < a; i++)
        {
            int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            for(int j = 0; j < 3; j++)
                b[i, j] = c[j];
        }
        for(int i = 0; i < 3; i++)
        {
            int[] d = new int[a];
            int []f = new int[a];
            int z = 0;
            for(int j = 0; j < a; j++) {d[j] = b[j, i]; } 
            Array.Sort(d);
            for(int j = 0; j < a - 1; j++){if (d[j] == d[j + 1]) { f[z] = d[j]; z++; }}
            for(int j = 0; j < a; j++)
            {
                for(int x = 0; x < z; x++)
                {
                    if (b[j, i] == f[x]) goto stop;
                }
                b[j, 3] += b[j, i];
                stop:;
            }
        }
        for (int i = 0; i < a; i++)
        {
            Console.WriteLine(b[i, 3]);
        }
    }
}

Measured memory_bytes: 9900
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,Work=0,Max=0;
	cin >> N;
	vector<int> H(N);
	for (int i=0; i<N; i++){
		cin >> H.at(i);
	}
	
	for (int i=0; i<N-1; i++){
		if (H.at(i) >= H.at(i+1)){
			Work ++;
		}
		else {
			Work =0;
		}
		if (Work > Max) {
			Max = Work;
		}
	}
	cout << Max <<endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	static HashMap<Long, Long> memo;
	static int A,B,C,D;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int T = sc.nextInt();
		
		for(int i=0; i<T; i++) {
			long N = sc.nextLong();
			A = sc.nextInt();
			B = sc.nextInt();
			C = sc.nextInt();
			D = sc.nextInt();
			
			memo = new HashMap<>();
			memo.put(0l, 0l);
			memo.put(1l, (long)D);
			
			System.out.println(solve(N));
		}
		
		sc.close();
	}
	
	static long solve(long N) {
		if(memo.get(N)!=null)
			return memo.get(N);
		long min = Long.MAX_VALUE;
		if(N < Long.MAX_VALUE/D)
			min = N*D;
		
		for(int i=-1; i<=1; i++) {
			if((N+i)%2==0)
				min = Math.min(min, solve((N+i)/2)+Math.abs(i)*D+A);
		}
		for(int i=-1; i<=1; i++) {
			if((N+i)%3==0)
				min = Math.min(min, solve((N+i)/3)+Math.abs(i)*D+B);
		}
		for(int i=-2; i<=2; i++) {
			if((N+i)%5==0)
				min = Math.min(min, solve((N+i)/5)+Math.abs(i)*D+C);
		}

		memo.put(N, min);
		return min;
	}
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int cnt=0;
	string s;
	cin>>s;
	for(auto c: s) cnt+=c=='o';
	cout<<(15-s.size()+cnt>=8 ? "YES\n":"NO\n");
	return 0;
}

Measured memory_bytes: 256
/*
   TASK: nocows
   LANG: C++14
 */

#include "bits/stdc++.h"

//region Template

typedef long long ll;
typedef long double ld;

using namespace std;
#define finish(x) return cout << x, 0;
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

const string USCAO_TAG = "nocows";
void usaco() { setIn(USCAO_TAG + ".in"); setOut(USCAO_TAG + ".out"); }


template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
//endregion

/* Notes:
 * I didn't wanna do this round :/
 */

vector<int> v[100005];
multiset<int> s;

int main() {
	#ifdef LOCAL
	setIn("in.txt");
	#endif

	int n, m;
	cin >> n >> m;

	for(int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;

		if(a > m) continue;
		v[a].push_back(b);
	}


	ll ans = 0;

	for(int i = 1; i <= m; i++){
		for(auto x : v[i]){
			s.insert(-x);
		}

		if(s.size()) {
			ans += -*(s.begin());
			s.erase(s.begin());
		}
	}
	cout << ans;
}


Measured memory_bytes: 7808
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedInputStream(System.in));
		for (;;) {
			int N = in.nextInt(), D = in.nextInt();
			if (N == 0 && D == 0)
				break;
			double dx = 0, dy = 1;
			double x = 0, y = 0;
			for (int i = 0; i < N; i++) {
				double ls = in.nextDouble() / 180 * Math.PI, rs = in
						.nextDouble() / 180 * Math.PI, t = in.nextDouble();
				if (ls == rs) {
					x += dx * (ls + rs) / 2 * t;
					y += dy * (ls + rs) / 2 * t;
				}
				else if (rs != 0) {
					double R = rs / (rs - ls) * 2 * D;
					double vx = dy * (R - D), vy = -dx * (R - D);
					double ox = x - vx, oy = y - vy;
					double alpha = rs * t / R;
					double nx = ox
							+ (Math.cos(alpha) * vx - Math.sin(alpha) * vy), ny = oy
							+ (Math.sin(alpha) * vx + Math.cos(alpha) * vy);
					x = nx;
					y = ny;
					double ndx = Math.cos(alpha) * dx - Math.sin(alpha) * dy, ndy = Math
							.sin(alpha) * dx + Math.cos(alpha) * dy;
					dx = ndx;
					dy = ndy;
				} else {
					double R = ls / (rs - ls) * 2 * D;
					double vx = dy * (R + D), vy = -dx * (R + D);
					double ox = x - vx, oy = y - vy;
					double alpha = ls * t / R;
					double nx = ox
							+ (Math.cos(alpha) * vx - Math.sin(alpha) * vy), ny = oy
							+ (Math.sin(alpha) * vx + Math.cos(alpha) * vy);
					x = nx;
					y = ny;
					double ndx = Math.cos(alpha) * dx - Math.sin(alpha) * dy, ndy = Math
							.sin(alpha) * dx + Math.cos(alpha) * dy;
					dx = ndx;
					dy = ndy;
				}
			}
			if (Math.abs(x)<1e-5) x=0;
			if (Math.abs(y)<1e-5) y=0;
			System.out.printf("%.5f%n%.5f%n", x, y);
		}
	}
}

Measured memory_bytes: 35968
#include <iostream>
#include <algorithm>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end() 
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout  
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';


const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ll MOD = 998244353;
const int N = (int)(3e5) + 1;


ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, a[3030];
ll dp[3001][3001][2];
bool mark[3001][3001][2];

ll dfs(int l, int r, bool t)
{
	if (l > r || r < l)return 0;
	ll& dp = ::dp[l][r][t];
	if (mark[l][r][t])return dp;
	mark[l][r][t] = 1;
	ll x = (t ? -1 : 1) * a[l] + dfs(l + 1, r, !t);
	ll y = (t ? -1 : 1) * a[r] + dfs(l, r - 1, !t);

	return dp = (!t ? max(x, y) : min(x, y));
}

int main()
{
	cin >> n;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++)
	{
		scanf("%d", a + i);
	}

	printf("%lld", dfs(0, n - 1, 0));
}

Measured memory_bytes: 158848
#include <iostream>
#include <string>

using namespace std;

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

	int k =0;
	int l =0;

	for (int i=0;i<=str.size();i++){
	if (str[l] == 'C'){
		k = l; 
		for (int j=l; j<=str.size(); j++){
			if (str[k] == 'F') {
				cout <<"Yes\n";
			 	return 0;}
			else {k++;}
		}
	}
		else {l++;}
	}
	cout << "No\n";
	
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
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);
        AProgrammingEducation solver = new AProgrammingEducation();
        solver.solve(1, in, out);
        out.close();
    }

    static class AProgrammingEducation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 1) {
                out.println("Hello World");
                return;
            }

            int a = in.nextInt(), b = in.nextInt();
            out.println(a + b);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <cstring>
#include <sstream>
#include <stdlib.h>

using namespace std;

int main (void)
{
	long r;
	cin >> r;
	
	if (r < 1200)
	{
		cout << "ABC" << endl;
	}
	else if (r < 2800)
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "AGC" << endl;
	}
}



Measured memory_bytes: 256
n,k=map(int,input().split())
num,count=[0]*((10**5)+1),0
for _ in range(n):
  a,b=map(int,input().split())
  num[a]+=b
for i in range(len(num)):
  count+=num[i]
  if count >= k:
    print(i)
    break

Measured memory_bytes: 11696
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  int n = S.length();

  vector<int> s(n + 1, 0);
  rep(i, n){
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
      s[i + 1] = s[i] + 1;
    }
    else{
      s[i + 1] = 0;
    }
  }
  int ans = 0;
  rep(i, n + 1){
    ans = max(ans, s[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0
using namespace std;
using ll = long long;

void testcase() {
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    bool yes = false;
    if (a < b) {
        a += (v * t);
        b += (w * t);
        if (a >= b) {
            yes = true;
        }
    } else if (a > b) {
        a -= (v * t);
        b -= (w * t);
        if (a <=b ) {
            yes = true;
        }
    } else {
        yes = true;
    }
    cout << (yes ? "YES" : "NO");
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

int main(){
    FAST;
    ll  n, ans = 0, k, m, j = 0, t = 1, x = 0, y = 0, c = 0, i, z = 0;
    cin >> x >> y >> z ;
    if ( x + y + z >= 22 ) cout << "bust";
    else cout << "win";
    
    
}

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

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

  if (-a + b <= 0)
    cout << "delicious" << endl;
  else if (-a + b >= 0 && -a + b <= x)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}


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 b = false;
    for(int i = 1; i<=9; i++){
      if(N%i==0){
        int temp = N/i;
        if(temp<=9&&temp>=1){
          b = true;
        }
      }
    }
    if(b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define reps(i,a,b) for(long long int i=a;i<b;i++)
#define rep(i,a) for(long long int i=0;i<a;i++)
typedef long long int ll;
using namespace std;
ll MOD = 1000000007;

const int MAX = 510000;

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main(){
    int N;
    cin>>N;
    ll A[N],B[N],C[N];
    rep(i,N){
        cin>>A[i];
    }
    rep(i,N){
        cin>>B[i];
    }
    rep(i,N){
        cin>>C[i];
    }
    sort(A,A+N);
   
    sort(C,C+N);
    ll num=0;
    rep(i,N){
        ll* it = lower_bound(A,A+N,B[i]);
        ll* itt = upper_bound(C,C+N,B[i]);
            num += (it-A)*(C+N-itt);
        }
    

cout<<num;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> b[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += i ? min(b[i - 1], b[i]) : b[i];
    }
    ans += b[n - 2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> a(N,0);
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		int e;
		for (int j = 0; j < d; j++) {
			cin >> e;
			a.at(e - 1)++;
		}
	}
	int f = 0;
	for (int i = 0; i < N; i++) {
		if (a.at(i) == 0) {
			f++;
		}
		else {}
	}
	cout << f << endl;
}

Measured memory_bytes: 3596
MOD = (10 ** 9) + 7

f_list = [1] * 100001
f_r_list = [1] * 100001

for i in range(100000):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

def power(n, x):
	if x == 1:
		return n
	elif x % 2 == 0:
		return power(int((n * n) % MOD), int(x / 2))
	else:
		return int((n * power(n, x - 1)) % MOD)

f_r_list[-1] = power(f_list[-1], MOD - 2)

for i in range(2, 100002):
	f_r_list[-i] = int((f_r_list[-i + 1] * (100003 - i)) % MOD)

def comb(n, r):
	if n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 

n = int(input())
a = list(map(int, input().split()))
a_r = list(reversed(a))


doubled = sum(a) - n * (n + 1) / 2
x = a.index(doubled)
y = a_r.index(doubled)
num = x + y

print(n)

for i in range(2, n + 2):
	if num >= i - 1:
		print(int((comb(n + 1, i) - comb(num, i - 1)) % MOD))
	else:
		print(comb(n + 1, i))

Measured memory_bytes: 57964
#include <iostream>

using namespace std;

int main(){
    int a,b; cin >> a >> b;
    int num;
    int count=1;

    int k=b;
    while(k/10 != 0){
        k = k/10;
        count++;
    }
    for(int i=0;i<count;i++){
        a=a*10;
    }
    num = a+b;

    for(int i=1; i<=num/2;i++){
        if(num == i*i){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(){
    string S;
    cin>>S;
    int count = 0;

    int N = S.length();
    stack<char> s;
    for(int i=0; i<N; ++i){
        if(s.empty()){
            s.push(S[i]);
        }else{
            if(s.top() != S[i]){
                s.pop();
            }else{
                s.push(S[i]);
            }
        }
    }
    count = N - s.size();
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
A_list = [int(a) for a in input().split()]
B_list = [int(b) for b in input().split()]
C_list = [int(c) for c in input().split()]
A_list.sort()
B_list.sort()
C_list.sort()

i = j = N-1
count_B_gt_A = [0] * N
while i >= 0 and j >= 0:
    if B_list[i] > A_list[j]:
        count_B_gt_A[i] = j+1
        i -= 1
    else:
        j -= 1

i = j = 0
count_B_lt_C = [0] * N
while i < N and j < N:
    if B_list[i] < C_list[j]:
        count_B_lt_C[i] = N - j
        i += 1
    else:
        j += 1
    
result = sum([B_gt_A * B_lt_C for B_gt_A, B_lt_C in zip(count_B_gt_A, count_B_lt_C)])
print(result)

Measured memory_bytes: 27456
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	arr := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Strings(arr)
	fmt.Println(strings.Join(arr, ""))
}


Measured memory_bytes: 640
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const B = input[1].split(" ").map((val) => parseInt(val, 10));

function insert(ary, number) {
  ary.splice(number - 1, 0, number);
}

const ans = [];

for (let i = 0; i < N; i++) {
  if (B[i] > i + 1) {
    console.log("-1");
    return;
  }

  insert(ans, B[i]);
}

ans.forEach((val) => console.log(val));


Measured memory_bytes: 21956
from bisect import bisect

N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

A, B = zip(*AB)
B = sorted(B)

max_A = max(A)
knifes = B[bisect(B, max_A):]

count = 0
while H > 0 and knifes:
    H -= knifes.pop()
    count += 1
if H > 0:
    count += -(-H//max_A)

print(count)

Measured memory_bytes: 36084
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  if(S.at(0)!=S.at(1)&&S.at(1)!=S.at(2)&&S.at(2)!=S.at(0)){
  
  cout<<"Yes"<<endl;
  }
else{
  cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main() {
	int N;
	double x;
	std::string u;
	double r{};
	std::cin >> N;
	for (int i = 0; i < N; ++i) {
		std::cin >> x >> u;
		if (u == "BTC")
			r += x * 380000.0;
		else
			r += x;
	}
	std::cout << r << std::endl;
}

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

const int DIM = 105;

bool adj[DIM][DIM];

int main (void) 
{
	int N; cin >> N;
	for (int i = 1; i <= N; ++i) 
		for (int j = i + 1; j <= N; ++j) 
			adj[i][j] = true; 
	if (N % 2) {
		for (int i = 1, j = N - 1; i < j; ++i, --j) 
			adj[i][j] = false;
	} else {
		for (int i = 1, j = N; i < j; ++i, --j)
			adj[i][j] = false;
	}
	vector<pair<int, int>> edges;
	for (int i = 1; i <= N; ++i) 
		for (int j = i + 1; j <= N; ++j) 
			if (adj[i][j]) 
				edges.push_back(make_pair(i, j));
	cout << edges.size() << "\n";
	for (pair<int, int> &edge : edges)
		cout << edge.first << " " << edge.second << "\n";
	return 0;
}


Measured memory_bytes: 384
#include <cstdio> 
#include <iostream> 
using namespace std;
typedef long long ll;            //>10^18
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
ll n;
ll a[MAXN];
int main(int argc, char *argv[]){
	scanf("%lld", &n);
	ll cnt = 0;
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		cnt += a[i];
	}
	ll ans = 0, cot, save;
	for(int i = 1; i <= n; i++){
		save = cnt - a[i];
		cnt -= a[i];
		cot = ((a[i] % MOD) * (save % MOD)) % MOD;
		ans = ((ans % MOD) + (cot % MOD)) % MOD;
	} 
	cout << ans;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long x, y;
  cin >> x >> y;
  
  if(abs(x - y) >= 2) cout << "Alice\n";
  else cout << "Brown\n";
}

Measured memory_bytes: 256
N,A,B,C = list(map(int,input().split()))
L = [int(input()) for i in range(N)]
MIN = 99999999999
def solve(a,b,c,an,bn,cn,k):
    global MIN
    if k == N:
        if not (an == 0 or bn == 0 or cn == 0):
            MIN = min(MIN,abs(A-a)+abs(B-b)+abs(C-c)+10*(an+bn+cn-3))
        return
    else:
        solve(a+L[k],b,c,an+1,bn,cn,k+1)
        solve(a,b+L[k],c,an,bn+1,cn,k+1)
        solve(a,b,c+L[k],an,bn,cn+1,k+1)
        solve(a,b,c,an,bn,cn,k+1)
solve(0,0,0,0,0,0,0)
print(MIN)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Data
{
public:
    int a, b;
    bool operator<(const Data& other) const
    {
        long long x = other.a * (b + 1LL);
        long long y = a * (other.b + 1LL);
        if(x != y)
            return x < y;
        else
            return b < other.b;
    }
};

const int MAX = 50;

int main()
{
    int n, t;
    cin >> n >> t;
    vector<Data> v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i].a >> v[i].b;
    sort(v.begin(), v.end());

    vector<long long> dp(MAX+1, t+1);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        if(v[i].a == 0)
            continue;
        for(int j=MAX-1; j>=0; --j){
            long long x = dp[j] + 1;
            x += x * v[i].a + v[i].b;
            dp[j+1] = min(dp[j+1], x);
        }
    }

    int ans = 0;
    for(int i=0; dp[i]<=t; ++i){
        int cnt = i;
        long long x = dp[i];
        for(int j=0; j<n; ++j){
            if(v[j].a == 0 && x + v[j].b + 1 <= t){
                x += v[j].b + 1;
                ++ cnt;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

#define MAX 100005
#define NIL -1

struct Node {
  int p;
  int l;
  int r;
};

int n;
struct Node T[MAX];
int D[MAX];

void print(int u);
void rec(int u, int p);

int main(){

  int i,j;
  int d,v,c,l,r;
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d %d", &v, &d);
    for(j=0; j<d; j++){
      scanf("%d", &c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l=c;
      T[c].p = v;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for(i=0; i<n; i++) print(i);
  
  return 0;
}


void print(int u){

  int i;
  int c;

  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if(T[u].p == NIL)
    printf("root, ");

  else if(T[u].l == NIL)
    printf("leaf, ");
  
  else
    printf("internal node, ");

  
  printf("[");

  for(i=0,c=T[u].l; c!=NIL; i++, c=T[c].r){
    if(i!=0) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

void rec(int u, int p){

  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}



Measured memory_bytes: 6392
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
sx, sy, tx, ty = map(int, input().split())
up = ty - sy
right = tx - sx
first = "U" * up + "R" * right
second = "D" * up + "L" * right
up += 1
right += 1
third = "L" + "U" * up + "R" * right + "D"
fourth = "R" + "D" * up + "L" * right + "U"
print(first + second + third + fourth)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull N,K;		cin>>N>>K;
	ull R,S,P;		cin>>R>>S>>P;
	string str;		cin>>str;
	//0:r 1:s 2:p
	ull sum=0;
	
	FOR(i,0,K){
		if(str[i]=='r')	sum+=P;
		else if(str[i]=='s')	sum+=R;
		else if(str[i]=='p')	sum+=S;
	}
	FOR(i,K,N){
		if(str[i]!=str[i-K]){
			if(str[i]=='r')	sum+=P;
			else if(str[i]=='s')	sum+=R;
			else if(str[i]=='p')	sum+=S;
		}
		else	str[i]='a';
	}
	
	cout<<sum<<endl;

    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,l;
	cin>>n>>l;
	string s[100];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++){
		cout<<s[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

long long int gcd(long long int a, long long int b) {
    if(a < b) std::swap(a, b);
    if(b == 0) return a;
    else return gcd(b, a%b);
}

long long int lcm(long long int a, long long int b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N; scanf("%d", &N);
    long long int V = 1;
    for(int i=0; i<N; i++) {
        long long int T; scanf("%lld", &T);
        V = lcm(V, T);
    }
    printf("%lld\n", V);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int n = 0, i;
    char Sarray[5];
    char Tarray[5];
    scanf("%s %s", Sarray, Tarray);
    for(i = 0; i < 3;i++){
        if(Sarray[i] == Tarray[i]){
            n++;
        }
    }
    printf("%d\n",n);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>>
#include<string>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;
int main() {
	string S;
	cin >> S;
	char head_c = S[0];
	int group_i = 1;
	for (int i = 1;i<S.size(); i++)
	{
		if (head_c != S[i])
		{
			group_i++;
			head_c = S[i];
		}
	}
	cout << group_i-1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

char map[104][104];
int dist[104][104];
int H, W;

void init(){
  for (int i=0; i<104; i++){
    for (int j=0; j<104; j++){
      dist[i][j]=1000000;
    }
  }
  return;
}

void dp(){
  if (map[0][0]=='#'){
    dist[0][0]=1;
  } else {
    dist[0][0]=0;
  }
  for (int hw=0; hw<=H+W; hw++){
    for (int h=0; h<=hw; h++){
      int w = hw-h;
      if(h>=H || w>=W) continue;
      if (h==0 && w==0) continue;
      if (h==0){
        if (map[h][w-1]=='.'&&map[h][w]=='#'){
          dist[h][w] = dist[h][w-1]+1;
        } else {
          dist[h][w] = dist[h][w-1];
        }
      } else if (w==0){
        if (map[h-1][w]=='.'&&map[h][w]=='#'){
          dist[h][w] = dist[h-1][w]+1;
        } else {
          dist[h][w] = dist[h-1][w];
        }        
      } else {
        if (map[h-1][w]=='.'&&map[h][w]=='#'){
          dist[h][w]=std::min(dist[h][w], dist[h-1][w]+1);
        } else {
          dist[h][w]=std::min(dist[h][w], dist[h-1][w]);
        }
        if (map[h][w-1]=='.'&&map[h][w]=='#'){
          dist[h][w]=std::min(dist[h][w], dist[h][w-1]+1);
        } else {
          dist[h][w]=std::min(dist[h][w], dist[h][w-1]);
        }
      }
    }
  }
  return;
}

int main(){
  scanf("%d", &H);
  scanf("%d", &W);
  for (int i=0; i<H; i++){
    std::string s;
    std::cin >> s;
    for (int j=0; j<W; j++){
      map[i][j]=s[j];
    }
  }
  init();
  dp();
  /*for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      printf("dist[%d][%d]=%d\n",i,j,dist[i][j]);
    }
    }*/
  printf("%d\n", dist[H-1][W-1]);
  return 0;
}


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

typedef long long lint;
const int mod = 924844033, Phi = mod - 1, G = 5;
const int maxn = 1000005;

int n;
int fac[maxn], ifac[maxn];
int a[maxn], b[maxn], c[maxn];

struct edge {
	int to, next;
} e[maxn * 2];
int h[maxn], tot;

int cnt[maxn], siz[maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int Pow(int x, int k)
{
	int res = 1;
	while (k) {
		if (k & 1) res = (lint)res * x % mod;
		x = (lint)x * x % mod; k >>= 1;
	}
	return res;
}

inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs(int u, int fa)
{
	siz[u] = 1;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa) {
			dfs(v, u);
			siz[u] += siz[v];
			++cnt[siz[v]]; ++cnt[n - siz[v]];
		}
}

namespace NTT
{

	int n, L, R[maxn], A[maxn], B[maxn];

	void NTT(int *a, int f)
	{
		for (int i = 0; i < n; ++i)
			if (i < R[i]) swap(a[i], a[R[i]]);
		for (int i = 1; i < n; i <<= 1) {
			int wn = Pow(G, Phi / (i << 1)), t;
			if (f == -1) wn = Pow(wn, mod - 2);
			for (int j = 0; j < n; j += (i << 1)) {
				int w = 1;
				for (int k = 0; k < i; ++k, w = (lint)w * wn % mod) {
					t = (lint)a[j + i + k] * w % mod;
					a[j + i + k] = a[j + k] - t;
					if (a[j + i + k] < 0) a[j + i + k] += mod;
					a[j + k] = a[j + k] + t;
					if (a[j + k] >= mod) a[j + k] -= mod;
				}
			}
		}
	}
	
	void mul(int *a, int *b, int len1, int len2, int *c)
	{
		for (n = 1, len1 += len2 - 1; n < len1; n <<= 1) ++L;
		--L;
		for (int i = 0; i < n; ++i) R[i] = (R[i >> 1] >> 1) | ((i & 1) << L);

		for (int i = 0; i < n; ++i) A[i] = a[i], B[i] = b[i];
		NTT(A, 1); NTT(B, 1);
		for (int i = 0; i < n; ++i) A[i] = (lint)A[i] * B[i] % mod;
		NTT(A, -1);

		int inv = Pow(n, mod - 2);
		for (int i = 0; i < n; ++i) c[i] = (lint)A[i] * inv % mod;
	}

}
	
int main()
{
	n = gi();
	for (int i = 1; i < n; ++i) add(gi(), gi());

	dfs(1, 0);

	fac[0] = ifac[0] = ifac[1] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = (lint)fac[i - 1] * i % mod;
	for (int i = 2; i <= n; ++i) ifac[i] = (lint)(mod - mod / i) * ifac[mod % i] % mod;
	for (int i = 1; i <= n; ++i) ifac[i] = (lint)ifac[i - 1] * ifac[i] % mod;

	for (int i = 1; i <= n; ++i) a[i] = (lint)cnt[i] * fac[i] % mod;
	for (int i = 1; i <= n; ++i) b[i] = ifac[n - i];

	NTT::mul(a, b, n + 1, n + 1, c);

	for (int i = 1; i <= n; ++i)
		printf("%lld\n", ((lint)n * fac[n] % mod * ifac[i] % mod * ifac[n - i] % mod - (lint)ifac[i] * c[n + i] % mod + mod) % mod);
	
	return 0;
}


Measured memory_bytes: 53120
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M = rl()
S = []
for i in range(M):
    p, s = rs().split()
    S.append((int(p), s))
ans = 0
pena = 0
penas = [0] * (N+1)
flags = [False] * (N+1)
for p, s in S:
    if flags[p]: continue
    if s == 'AC':
        flags[p] = True
        pena += penas[p]
        ans += 1
    else:
        penas[p] += 1
print(ans, pena)


Measured memory_bytes: 56632
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll NA,NB,NC,K;
	while(cin>>NA>>NB>>NC>>K) {
		VI A(NA), B(NB), C(NC);
		REP(i, NA) cin>>A[i];
		REP(i, NB) cin>>B[i];
		REP(i, NC) cin>>C[i];
		VI AB;
		REP(i, NA) REP(j, NB) AB.PB(A[i]+B[j]);
		sort(ALLR(AB));
		VI ABC;
		REP(i, min(K, (ll)AB.size())) REP(j, NC) ABC.PB(AB[i]+C[j]);
		sort(ALLR(ABC));
		REP(i, min(K, (ll)ABC.size())) {
			cout<<ABC[i]<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 43368
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最小値を求める関数
Int Min(const Int a, const Int b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    const Int MOD = 2019;
    Int l, r;
    cin >> l >> r;
    r = Min(r, l + MOD);
    Int result = MOD;
    for (Int i = l; i <= r; ++i) {
        for (Int j = i + 1; j <= r; ++j) {
            result = Min(result, (i * j) % MOD);
        }
    }
    cout << result << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
using System;

namespace ABC20191027
{
    class Program
    {
        static void Main(string[] args)
        {
            string st1 = Console.ReadLine();
            string st2 = Console.ReadLine();
            int n = int.Parse(st1);
            int count = 0;
            for (int i = 0; i < n - 2; i++)
            {
                if (st2[i] == 'A')
                {
                    if (st2[i + 1] == 'B')
                    {
                        if (st2[i + 2] == 'C')
                        {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9+7;
const ll INF = 1<<30;

int main(){
	ull dp[105][4][2];
	string s;
	int k;
	
	cin>>s;
	cin>>k;
	
	memset(dp, 0, sizeof dp);
	dp[s.size()][0][0] = 1;
	dp[s.size()][0][1] = 1;

	for(int i=s.size()-1;i>=0;i--){
		//cout<<i<<":";
		dp[i][0][0] = dp[i+1][0][0];
		dp[i][0][1] = dp[i+1][0][1];
		//cout<<dp[i][0][0]<<","<<dp[i][0][1]<<" ";
		for(int j=1;j<=k;j++){
			dp[i][j][1] = 9*dp[i+1][j-1][1] + dp[i+1][j][1];
			if(s[i] == '0'){
				dp[i][j][0] = dp[i+1][j][0];
			} 
			else{
				dp[i][j][0] = (s[i]-'0'-1)*dp[i+1][j-1][1] + dp[i+1][j][1] + dp[i+1][j-1][0];
			}
			//cout<<dp[i][j][0]<<","<<dp[i][j][1]<<" ";
		}
		//cout<<"\n";
	}

	cout<<dp[0][k][0]<<"\n";
	
	return 0;
}

/*

dp[i][j] = No. of numbers possible with j non-zero digit such that d[i+j]<=s[i+j];i<=i+j<=|s|


*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin>>N;
  va.resize(N+1);
  rep(i,2,N){
    cin>>va[i];
  }
  ;
}
void solve() {
  map<int,int> mp;
  rep(i,1,N){
    mp[i] = 0;
  }
  rep(i,2,N){
    mp[va[i]]++;
  }
  for(auto x : mp){
    cout<<x.second<<endl;
  }
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 17200
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

//値の更新にまじ注意して！！
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int ans = 1<<30;
    for(int a_ = 1 ; a_ <= N - 1 ; a_++) {
        int a = a_;
        int b = N - a;
        int res = 0;
        while(a > 0) {
            res += (a % 10);
            a /= 10;
        }
        while(b > 0) {
            res += (b % 10);
            b /= 10;
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import(
    "bufio"
    "fmt"
    "os"
)

var r=bufio.NewReader(os.Stdin)

func main(){
    var x,h,m,s int
    fmt.Fscan(r, &x)
    
    h=x/60/60
    m=(x-h*60*60)/60
    s=x-h*60*60-m*60
    fmt.Printf("%d:%d:%d\n",h,m,s)
}



Measured memory_bytes: 1172
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[110][5][2];

int main(){
    string N; cin >> N;
    int K; cin >> K;
    int n = N.size();
    dp[0][0][0] = 1;
    rep(i,n)rep(j,4){
        if(N[i] == '0'){
            dp[i+1][j][0] += dp[i][j][0];
            dp[i+1][j][1] += dp[i][j][1];
            dp[i+1][j+1][1] += 9*dp[i][j][1];
        }
        else{
            int k = N[i]-'0';
            dp[i+1][j][1] += dp[i][j][0]+dp[i][j][1];
            dp[i+1][j+1][0] += dp[i][j][0];
            dp[i+1][j+1][1] += 9*dp[i][j][1]+(k-1)*dp[i][j][0];
        }
    }
    //repr(i,1,n+1)rep(j,K+1){
      //cout << i << " " << j << " " << dp[i][j][0]+dp[i][j][1] << endl;
    //}
    cout << dp[n][K][0]+dp[n][K][1] << endl;
}


Measured memory_bytes: 256
import itertools
n=int(input())
ball=[]
for i in range(n):
    ball.append([int(i) for i in input().split()])

ball.sort()

# p,qの候補取得
pq_cand=set()
for v in itertools.combinations(ball,2):
    xdiff=v[0][0]-v[1][0]
    ydiff=v[0][1]-v[1][1]
    pq_cand.add((xdiff,ydiff))
    
cost=n
for pq in pq_cand:
    cost_tmp=0
    for point in ball:
        if [point[0]+pq[0],point[1]+pq[1]] not in ball:
            cost_tmp+=1
    cost=min(cost,cost_tmp)
print(cost)

Measured memory_bytes: 3188