akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int w,h;
char map[105][105];
void go(int y,int x){
	if(map[y][x]=='#'){
		printf("LOOP\n");
		return ;
	}
	else if(map[y][x]=='.'){
		printf("%d %d\n",x,y);
		return ;
	}
	else if(map[y][x]=='>'){
		map[y][x]='#';
		go(y,x+1);
	}
	else if(map[y][x]=='v'){
		map[y][x]='#';
		go(y+1,x);
	}
	else if(map[y][x]=='<'){
		map[y][x]='#';
		go(y,x-1);
	}
	else if(map[y][x]=='^'){
		map[y][x]='#';
		go(y-1,x);
	}
	else {
		printf("none\n");
	}
}
int main(){
	int i,j;
	for(;scanf("%d %d",&h,&w)&&(w||h);){
		for(i=0;i<h;i++){
			scanf("%s",map[i]);
		}
		go(0,0);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main(){
    fast();

/* you get what you work for not what you wish for */

    inp(n);
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            ll a = i;
            ll b = n/i;
            if(a>=1&&b>=1&&a<=9&&b<=9){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = {}

def LI():
  return [int(s) for s in input().split()]

a = LI()

for i in range(N):
  A[i] = a[i]
  
A = sorted(A.items(), key = lambda x: x[1])

for i in range(N):
  if i < N-1:
    print(A[i][0]+1,end = ' ')
  else:
    print(A[i][0]+1)

Measured memory_bytes: 25560
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int X, Y, Z;
  std::cin >> X >> Y >> Z;
  std::swap(X, Y);
  std::swap(X, Z);
  std::cout << X << ' ' << Y << ' ' << Z << '\n';
  return 0;
}


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

int main(){
    double a,b,c,d,e,f;
    while (cin>>a>>b>>c>>d>>e>>f) {
        double x = (b*f - c*e)/(b*d - a*e);
        double y = (a*f - c*d)/(a*e - b*d);
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 3048
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _005_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            var indexes = new int[n];
            var tree = new int[n];
            var size = new int[n];
            for (int i = 0; i < n; i++)
            {
                indexes[array[i] - 1] = i;
                tree[i] = -1;
                size[i] = 1;
            }

            long res = 0;
            for(long i = n - 1; i >= 0; i--)
            {
                int index = indexes[i];
                tree[index] = index;
                if (index < n - 1 && tree[index + 1] >= 0)
                    Unite(ref tree, ref size, index, index + 1);
                long r = size[index];
                if (index > 0 && tree[index - 1] >= 0)
                    Unite(ref tree, ref size, index, index - 1);
                long l = size[Root(ref tree, index)] - r + 1;
                //Console.WriteLine(l + " " + r);
                res += (i + 1) * l * r;
            }
            Console.WriteLine(res);
        }

        static int Root(ref int[] tree, int x)
        {
            int rx = x;
            while (tree[rx] != rx)
            {
                rx = tree[rx];
            }
            tree[x] = rx;
            return rx;
        }

        static bool IsSame(ref int[] tree, int x, int y)
        {
            return Root(ref tree, x)
                == Root(ref tree, y);
        }

        static void Unite(ref int[] tree,ref int[] size,
            int x, int y)
        {
            int rx = Root(ref tree, x);
            int ry = Root(ref tree, y);
            if (rx == ry) return;
            if (rx> ry)
            {
                int temp = rx;
                rx = ry;
                ry = temp;
            }
            tree[ry] = rx;
            size[rx] += size[ry];
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int N = int.Parse(s.Split(' ')[0]);
            int i = int.Parse(s.Split(' ')[1]);

            Console.WriteLine((N - i + 1));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int M(int x) { return x >= mod ? x - mod : x; }
void Add(int &x, int y) { (x += y) >= mod ? x -= mod : x; }

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
int n, A, B;
int f[5003][5003], g[5003][5003];
int pf[10004][5003], pg[10004][5003];

int S(int *p, int l, int r) { return M(p[r] - (l > 0 ? p[l - 1] : 0) + mod); }

int main() {
    // clock_t c = clock();
    // cerr << clock() - c << endl;
    n = read(), A = read(), B = read();
    if (A > B) swap(A, B);
    int res = 1;
    for (int i = 1; i <= n; ++i) res = M(res << 1);
    if (A == 1) return printf("%d\n", res), 0;

    for (int i = 1; i <= B; ++i)
        f[0][i] = pf[i + n][0] = g[0][i] = pg[i + n][0] = 1;

    for (int i = 1; i <= n; ++i) {
        int s = 0;
        for (int x = 1; x <= min(A - 1, i); ++x) Add(s, g[i - x][B]);
        for (int j = 1; j <= B; ++j) {
            f[i][j] = pf[j - i + n][i] = M(s + S(pg[j - i + n], i - j, i - A));
            g[i][j] = pg[j - i + n][i] = S(pf[j - i + n], i - j, i - 1);
        }

        for (int j = n - i + 1; j <= B + n - i - 1; ++j)
            Add(pf[j][i], pf[j][i - 1]), Add(pg[j][i], pg[j][i - 1]);
    }
    printf("%d\n", M(res + mod - M(g[n][B] + f[n][B])));
    // cerr << clock() - c << endl;
    return 0;
}

Measured memory_bytes: 466308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


// 1-A 標準出力にHelloWorldと出力する
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		//縦
		int intVertical = 0;

		//横
		int intHorizontal = 0;

		try{
			//キーボードからの入力準備
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			//キーボードからの入力をString型で受け取る
			String strLine = br.readLine();

			//文字列の分割:入力値を" "で分ける
			//分けた文字列はstrLineAry[0]とstrLineAry[1]に分けられる
			String[] strLineAry = strLine.split(" ");

			//入力値の１つ目は縦
			intVertical = Integer.parseInt(strLineAry[0]);

			//２つ目は横
			intHorizontal = Integer.parseInt(strLineAry[1]);

			//面積
			int intArea = intVertical * intHorizontal;

			//周
			int intZhou = (intVertical + intHorizontal) * 2;

			//結果を出力
			System.out.println(intArea + " " + intZhou);

		//例外処理
		}catch(IOException e) {

			//例外内容の表示
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 16892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int x, y;
	cin >> x >> y;

	int d[7] = { 1, 3, 5, 7, 8, 10, 12 };
	int e[4] = { 4, 6, 9, 11 };

	int a, b;
	a = 0;
	b = 0;
	rep(i, 7) {
		if (d[i] == x) {
			a = 1;
		}
		if (d[i] == y) {
			b = 1;
		}
	}
	rep(i, 4) {
		if (e[i] == x) {
			a = 2;
		}
		if (e[i] == y) {
			b = 2;
		}
	}
	if (a == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

	return 0;
}



Measured memory_bytes: 256
Keiro,T = map(int,input().split())

O = 1001
for i in range(Keiro):
    tmpC,tmpT = map(int,input().split())
    if(tmpT <= T and tmpC < O):
        O = tmpC


if(O == 1001):
    print("TLE")
else:
    print(O)

Measured memory_bytes: 3060
#include<bits/stdc++.h>//这题是倒着染色吧
using namespace std;

const int N = 1e5 + 10;
int n, m;
struct edge { int y, nxt; } e[N << 2];
int lin[N], len;
int ans[N][20];
struct QUE { int v, d, c; } q[N];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline void insert(int xx, int yy) {
	e[++len] = (edge) { yy, lin[xx] };
	lin[xx] = len;
}

inline void dfs(int v, int d, int c) {
	if(d == -1)	return ;
	if(ans[v][d])	return ;//因为是倒着染，所以不用再染一遍
	ans[v][d] = c;
	for(int i = lin[v]; i; i = e[i].nxt)	dfs(e[i].y, d - 1, c);
}

int main() {
	n = read(), m = read();
	for(int i = 1; i <= m; ++i) {
		int x = read(), y = read();
		insert(x, y);
		insert(y, x);
	}
	for(int i = 1; i <= n; ++i)	insert(i, i);
	int Q = read();
	for(int i = 1; i <= Q; ++i)	q[i].v = read(), q[i].d = read(), q[i].c = read();
	for(int i = Q; i >= 1; --i)	dfs(q[i].v, q[i].d, q[i].c);
	for(int i = 1; i <= n; ++i)	printf("%d\n", ans[i][0]);
	return 0;
}
//感谢ZJH大佬提供思路

Measured memory_bytes: 12928
N = int(input())

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

d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 0
    d[A[i]] += 1


ans = {0}
s1 = [k for k, v in d.items() if v >= 4]
if len(s1) > 0:
    s1.sort()
    ans.add(s1[-1] ** 2)

s2 = [k for k, v in d.items() if v >= 2]
if len(s2) >= 2:
    s2.sort()
    ans.add(s2[-1] * s2[-2])

print(max(ans)) 

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef double keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(){
    int n;
    double a[1005];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%lf", &a[i]);
    }

    double sum = 0;
    for(int i = 0; i < n; ++i){
        sum += (1 / a[i]);
    }

    printf("%f\n", 1 / sum);

    return 0;
}


Measured memory_bytes: 1740
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}


fn main() {
    let (a, b) = input_int_tuple();
    if a > b * 2 {
        println!("{}", a - b * 2);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible";
	}
	else { cout << "Impossible"; }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

int n;
string s;
vl a,b;

int main(){
	cin>>s;
	n=s.size();
	a=b=vl(n+1);
	int t=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='C') a[i]++;
		if(s[i]=='?') b[i]++,t++;
		a[i]+=a[i+1];
		b[i]+=b[i+1];
	}
	ll res=0,A=0,B=0;
	for(int i=0;i<n-1;i++){
		char c=s[i];
		if(c=='B'||c=='?'){
			int T=t;
			if(c=='?') T--;
			(res+=Pow(3,T)*A*a[i+1])%=mod;
			if(b[i]) (res+=Pow(3,T-1)*A*b[i+1])%=mod;
			if(B) (res+=Pow(3,T-1)*B*a[i+1])%=mod;
			if(B&&b[i]) (res+=Pow(3,T-2)*B*b[i+1])%=mod;
		}
		if(c=='A') A++;
		if(c=='?') B++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 2048
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vector<pair<ll, pii> > data;
int N;
vi A;
int igcd(int x,int y){
	if(x<y)swap(x,y);
	if(y==0)return x;
	else{
		return igcd(y,x%y);
	}
}
int main(){
	cin>>N;
	int cnt;
	rep(i,N){
		int x;
		cin>>x;
		A.pb(x);
	}
	int now=0;
	while(1){
		cnt=0;
		int memo;
		int cntone=0;
		rep(i,N){
			if(A[i]%2==0){
				cnt++;
			}else{
				memo=i;
			}
			if(A[i]==1)cntone++;
		}
		if(cntone==N){
			if(now==0)cout<<"Second"<<endl;
			else cout<<"First"<<endl;
			return 0;
		}
		if(cnt%2==1){
			if(now==0)cout<<"First"<<endl;
			else cout<<"Second"<<endl;
			return 0;
		}else{
			if((N-cnt)==1){
				A[memo]--;
				if(A[memo]==0){
					if(now==0)cout<<"Second"<<endl;
					else cout<<"First"<<endl;
					return 0;
				}
				int g=A[0];
				rep(i,N){
					g=igcd(g,A[i]);
				}
				rep(i,N){
					A[i]/=g;
				}
				//cout<<g<<endl;
			}else{
				if(now==0)cout<<"Second"<<endl;
				else cout<<"First"<<endl;
				return 0;
			}
		}
		now=1-now;
	}
	
}


Measured memory_bytes: 892
#include<stdio.h>
int main(){
    char s[11];
    int f=0;
    scanf("%s",s);
    if(s[5]>'0') f=1;
    else if(s[5]=='0'&&s[6]>'4') f=1;

    if(f==1)
        printf("TBD");
    else
        printf("Heisei");

    return 0;
}

Measured memory_bytes: 128
import math

H, N = list(map(int, input().split()))
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))

dp = [0]*(H+1)

dp[0] = 0

for i in range(1,H+1):
    dp_min = math.inf
    for j in range(N):
        dp_min = min(dp_min, dp[max(0,i-A[j])] + B[j])
    dp[i] = dp_min

print(dp[H])

Measured memory_bytes: 74284
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		int N = sc.nextInt();
		int m0 = sc.nextInt();
		int md = sc.nextInt();
		int n0 = sc.nextInt();
		int nd = sc.nextInt();
		int[] m = new int[M];
		int[] n = new int[N];
		m[0] = m0;
		n[0] = n0;

		for (int i = 1; i < M; ++i) {
			m[i] = (m[i - 1] * 58 + md) % (N + 1);
		}
		for (int i = 1; i < N; ++i) {
			n[i] = (n[i - 1] * 58 + nd) % (M + 1);
		}

		m = sort(m, N);
		n = sort(n, M);
		
		long[] accumN = new long[N + 1];
		long[] accumM = new long[M + 1];
		for (int i = 0; i < N; ++i) {
			accumN[i + 1] = accumN[i] + n[i];
		}
		for (int i = 0; i < M; ++i) {
			accumM[i + 1] = accumM[i] + m[i];
		}
		
		int cur = N;
		long sum = accumM[0] + accumN[cur] + (N - cur) * (M - 0);
		for (int i = 0; i <= M; ++i) {
			while (cur >= 1 &&  accumN[cur] >=  accumN[cur - 1]
					+  (M - i))
				--cur;
			sum = Math.min(sum, accumM[i] + accumN[cur] + (long)(N - cur) * (M - i));
		}
		
		System.out.println(sum);
		sc.close();
	}

	int[] sort(int[] a, int max) {
		int[] counter = new int[max + 1];
		for (int i = 0; i < a.length; ++i) {
			counter[a[i]]++;
		}
		int pos = 0;
		for (int i = 0; i < counter.length; ++i) {
			while (counter[i]-- > 0) {
				a[pos++] = i;
			}
		}
		return a;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 107840
input = gets.chomp.split(" ").map(&:to_i)

N = input[0]
K = input[1]

probability = 0
(1..N).each do |e|
  i = 0
  while e* (2 ** i) < K do
    i += 1
  end
  probability += 1 / (2 ** i).to_f
end

puts probability / N.to_f

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long dp[420][420], a[420], pref[420];

long long solve(int i, int j){
   if(i == j)
     return 0;
  
   long long &ans = dp[i][j];
   if(ans != -1)
     return ans;
   
   ans = 1e18;
   
   for(int k = i; k < j; k++){
     ans = min(ans, solve(i, k) + solve(k + 1, j) + pref[j] - pref[i - 1]);
   } 
   
   return ans;
}

int main(){
  int n; 
  cin >> n;
  
  for(int i = 1; i <= n; i++){
     cin >> a[i];
     pref[i] = pref[i - 1] + a[i];
  }
  
  memset(dp, -1, sizeof dp);
  cout << solve(1, n);
  
  return 0;
}


Measured memory_bytes: 5088
#include <iostream>
#include <vector>
#include <map>
#include <tuple>

using ull = unsigned long long;
static ull const Mod = 1000000007;

std::vector<ull> Fib;
std::map<std::tuple<int, int, int>, int> Memo;

ull Amida1(int W, int J, int K) {
  if (J < 1 || K < 1 || J > W || K > W || std::abs(J-K) > 1) {
    return 0;
  }

  auto s = std::min(J, K);
  auto l = std::max(J, K);

  return (Fib[s-1] * Fib[W-l]) % Mod;
}

ull Amida(int H, int W, int K) {
  if (K < 1 || K > W || std::abs(K-1) > H) {
    return 0;
  }

  auto key = std::make_tuple(H, W, K);
  if (Memo.count(key) > 0) return Memo.at(key);

  if (H == 1) {
    auto ans = Amida1(W, 1, K);
    Memo.insert(std::make_pair(key, ans));
    return ans;
  }

  ull ans;
  ans  = Amida(H-1, W, K-1) * Amida1(W, K-1, K);
  ans %= Mod;
  ans += Amida(H-1, W, K  ) * Amida1(W, K  , K);
  ans %= Mod;
  ans += Amida(H-1, W, K+1) * Amida1(W, K+1, K);
  ans %= Mod;

  Memo.insert(std::make_pair(key, ans));
  return ans;
}

int main() {
  int H, W, K;

  std::cin >> H >> W >> K;

  Fib.resize(W+1);
  Fib[0] = 1;
  Fib[1] = 1;

  for (size_t i=2; i<W+1; i++)
    Fib[i] = Fib[i-2] + Fib[i-1];

  std::cout << Amida(H, W, K) << std::endl;

  return 0;
}


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

int main()
{
  	string a, b; cin >> a >> b;
  	int n = a.length();
  	int ans = 0;
    for(int i = 0; i < n; ++i) ans += (a[i] != b[i]);
  cout << ans;
  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main(){
  int a,b;
  std::cin >> a>>b;
  if((b-1)%(a-1)==0)std::cout << (b-1)/(a-1) << '\n';
  else std::cout << (b-1)/(a-1)+1 << '\n';

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ld sum = 0;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        double  temp;
        cin >> temp;
        sum += 1/temp;
    }
    cout << setprecision(18);
    cout << fixed;
    cout << 1/sum;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,ans;
int main(){
    cin>>a>>b;
    if(a==0||b==0){
        if(a>b){
            cout<<abs(a-b)+1<<endl;
            exit(0);
        }
        cout<<abs(a-b)<<endl;
        exit(0);
    }
    if(a>0&&b>0){
        if(a<b)
        cout<<abs(a-b)<<endl;
        else
        cout<<abs(a-b)+2<<endl;
    }
    if(a>0&&b<0||a<0&&b>0)cout<<abs(abs(a)-abs(b))+1<<endl;
    if(a<0&&b<0){
        if(a==b)cout<<0<<endl;
        if(a>b)cout<<abs(abs(a)-abs(b))+2<<endl;
        if(a<b)cout<<abs(abs(a)-abs(b))<<endl;
    }
    return 0;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 3010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

char st[maxn];

int r[maxn],mn[maxn],mx[maxn],dp[maxn][maxn],sm[maxn],sm2[maxn];

void Work(){
	dp[0][0]=1;
	REP(i,0,n-1)
		REP(j,0,n)if(dp[i][j]&&j>=mn[i]&&j<=mx[i]){
			(dp[i+1][j]+=dp[i][j])%=mod;
			(dp[i+1][j+1]+=dp[i][j])%=mod;
		}
	iout(dp[n][mn[n]]);
}

void Init(){
	read(n,m);
	scanf("%s",st+1);
	REP(i,1,n)r[i]=i;
	REP(i,1,m){
		int x,y;
		read(x,y);
		r[x]=max(r[x],y);
	}
	REP(i,1,n)sm[i]=sm[i-1]+(st[i]=='1'),sm2[i]=sm2[i-1]+(st[i]=='0');
	int lst=0,now=0;
	REP(i,1,n){
		now=now+max(sm[r[i]]-sm[lst],0);
		lst=max(lst,r[i]);
		if(now)mx[i]=1,now--;
	}
	REP(i,1,n)mx[i]+=mx[i-1];
	lst=0;now=0;
	REP(i,1,n){
		now=now+max(sm2[r[i]]-sm2[lst],0);
		lst=max(lst,r[i]);
		if(now)now--;else mn[i]=1;
	}
	REP(i,1,n)mn[i]+=mn[i-1];
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 33920
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

long long Xd,Xu,D,N,Y,ans,i,j,K,temp,L,L2,A[200001],X;

int main()
{
  
  cin>>N>>K;
  Xu=1;
  for(i=0;i<N;i++)
  {
    cin>>A[i];
    Xu=max(Xu,A[i]);
  }
  
  if(K==0)
  {
    cout<<Xu;
    return 0;
  }
  
  Xd=0;
  X=(Xu+Xd)/2;
  while(Xd<X)
  {
    temp=0;
    for(i=0;i<N;i++)
    {
      temp+=(A[i]+X-1)/X-1;
    }
    
    if(temp<=K)
    {
      Xu=X;
    }
    else
    {
      Xd=X;
    }
    
    X=(Xu+Xd)/2;
  }
  
  cout<<Xu;
  
  
  
}



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



int main(){
  int64_t N,M,K;
  cin>>N>>M>>K;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }
  int64_t sum=0;
  int64_t hon=0;
  int64_t akaz=-1;
  int64_t bkaz=-1;
    
  for(int i=0;i<N;i++){
    if(sum+A.at(i)>K) break;
    else{
      sum+=A.at(i);
      hon++;
      akaz++;
    }
  }
  for(int i=0;i<M;i++){
    if(sum+B.at(i)>K) break;
    else{
      sum+=B.at(i);
      hon++;
      bkaz++;
    }
  }
  if(hon==N+M){
    cout<<hon<<endl;
    return 0;
  }
  if(akaz==-1&&bkaz==-1){
    cout<<0<<endl;
    return 0;
  }
  int64_t honm=hon;
  for(int i=akaz;i>=0;i--){
    sum-=A.at(akaz);
    akaz--;
    hon--;
    if(bkaz==M-1) break;
    while(bkaz<=M-2&&B.at(bkaz+1)<=K-sum){
      sum+=B.at(bkaz+1);
      bkaz++;
      hon++;
      honm=max(hon,honm);
      if(bkaz==M-1) break;
    }
  }
  cout<<honm<<endl;
    
    
    
}

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

int  main() {
    long long n,m;
   cin>>n>>m;
  vector<pair<int, int>> mp(n);
    long long a,b;
for(int i=0;i<n;i++)
  
{
    cin>>a>>b;
    mp[i]=make_pair(a,b);
}
   sort(mp.begin(), mp.end());
 long long count=0,ans=0;
for(int i=0;i<n;i++)
{
    int tmp;
    if(mp[i].second<= m)
             tmp= mp[i].second ;
            else
              tmp= m ;
        ans += (long long)mp[i].first * tmp;
        m -= tmp;
        if (m == 0) break;
    

}
       cout<<ans;
}


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll T;
  cin>>T;
  rep(i,T){
    ll N,M,A,B;
    cin>>N>>M>>A>>B;
    cout<<floor_sum(N,M,A,B)<<endl;
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
//#include <cassert>
//#include <stack>
//#include <queue>
//#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

ll n, m;

void solve() {
	cin >> n >> m;
	cout << (n * (n - 1) / 2) + (m * (m - 1) / 2);
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
ц*/

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

#define F first
#define S second
#define ll long long
#define ld long duoble
#define pb push_back
#define int long long

using namespace std;

const int N = 1001 * 1001 , MOD = 1e9 + 7 ; 

int get(int n)
{
	int sum = 0 ; 
	while(n) sum += n % 10 , n /= 10 ; 
	return sum ; 
}

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n ; 
	cin >> n ; 
	int NN = n ; 
	vector<int> v ; 
	while(n) v.pb(n%10) , n /= 10 ; 
	reverse(v.begin(),v.end()) ; 
	int ans = 9 * (v.size()-1) ; 
	int sum = 0 , cnt = v.size() ;
	for(auto u : v)
	{
		if(u)ans = max(ans,u-1+sum+(cnt-1)*9) ; 
		sum += u ;
		cnt -- ;
	}
	cout << max(ans,get(NN)) << endl ; 
}

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

#define _LL long long

_LL* mallocint(int si)
{
    return (_LL*) malloc(si * sizeof(_LL));
}

_LL* inputint(int n)
{
    _LL *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >>c;
    _LL *p = inputint(a);
    _LL *q = inputint(b);
    _LL *r = inputint(c);
    sort(p, p + a);
    sort(q, q + b);
    sort(r, r + c);
    int xindex = a - x;
    int yindex = b - y;
    int rindex = c - 1;
    while( ((xindex < a && r[rindex] > p[xindex]) ||  (yindex < b && r[rindex] > q[yindex])) && rindex >= 0 )
    {
        if( yindex >= b || p[xindex] < q[yindex] )
        {
            xindex++;
        }
        else
        {
            yindex++;
        }
        rindex--;
    }

    _LL ans = 0;
    for( int i = xindex; i < a; i++ ) ans += p[i];
    for( int i = yindex; i < b; i++ ) ans += q[i];
    for( int i = rindex + 1; i < c; i++ ) ans += r[i];
    cout << ans;
}

Measured memory_bytes: 5964
#include <stdio.h>

int main(){
  int in, i, j, weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512}, result[10];

  while(scanf("%d", &in) != EOF){
    j = 0;
    for(i = 9;i >= 0;i--){
      if(in == 0) break;
      if(in >= weight[i]){
	in -= weight[i];
	result[j++] = weight[i];
      }
    }


    for(i = j - 1;i >= 0;i--){
      if(i != j - 1) putchar(' ');
      printf("%d", result[i]);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {

int i,j,n,m;

cin >> n >> m;

vector<vector<int> > a(n,vector<int>(m));
vector<int> b(m);
vector<int> c(n);

for(i=0;i<=n-1;++i){
for(j=0;j<=m-1;++j){
cin >> a.at(i).at(j);
}
}

for(j=0;j<=m-1;++j){
cin >> b.at(j);
}


for(i=0;i<=n-1;++i){
for(j=0;j<=m-1;++j){
c.at(i) += a.at(i).at(j)*b.at(j);
}
}

for(i=0;i<=n-1;++i){
cout << c.at(i) << endl;
}

}


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M,cnt=0;
  string S;
  cin>>N>>M>>S;
  
  ll A[N],B[N];
  bool SEEN[N];
  REP(i,N){
    A[i]=0;
    B[i]=0;
    SEEN[i]=false;
  }
  
  Graph G(N);
  REP(i,M){
    int aa,bb;
    cin>>aa>>bb;
    aa--;
    bb--;
    G[aa].PB(bb);
    G[bb].PB(aa);
  }
  
  queue<int> Q;
  
  REP(i,N){
    FORE(j,G[i]){
      if(S.at(j)=='A') A[i]++;
      else B[i]++;
    }
    if(A[i]==0 || B[i]==0){
      cnt++;
      Q.push(i);
      SEEN[i]=true;
    }
  }
  
  while(!Q.empty()){
    int t=Q.front();
    Q.pop();
    SEEN[t]=true;
    A[t]=0;
    B[t]=0;
    FORE(i,G[t]){
      if(SEEN[i]) continue;
      if(S.at(t)=='A') A[i]--;
      else B[i]--;
      if(A[i]==0 || B[i]==0){
        cnt++;
        Q.push(i);
        SEEN[i]=true;
      }
    }
  }
  
  if(cnt==N) CONo;
  else COYe;
  return 0;
}

Measured memory_bytes: 13760
from sys import stdin
input = stdin.readline

def DFS(node):
    global time
    if discoveredtime[node] == -1:
        discoveredtime[node] = time
        time += 1

        for child in childlist[node]:
            DFS(child)
        
        finishedtime[node] = time
        time += 1

N = int(input())

childlist = [None]*(N+1)
for _ in range(N):
    u, k, *v = map(int, input().split())
    childlist[u] = v

discoveredtime = [-1]*(N+1)
finishedtime = [-1]*(N+1)
time = 1

for i in range(1, N+1):
    if discoveredtime[i] == -1:
        DFS(i)

for i in range(1, N+1):
    print(i, discoveredtime[i], finishedtime[i])


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

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z),ab,abc;
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];
    rep(i,x){
        rep(j,y) ab.push_back(a[i]+b[j]);
    }
    sort(ab.begin(),ab.end(),greater<ll>());
    rep(i,min(x*y,k)){
        rep(j,z) abc.push_back(ab[i]+c[j]);
    }
    sort(abc.begin(),abc.end(),greater<ll>());
    rep(i,k) co(abc[i]);
    return 0;

}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N, M;

ll P[MAX_N] = {};
//ll origin[MAX_N] = {};  // i のいる位置

class UnionFind {
    public:
        // size: Union-Find で扱いたい要素の数
        UnionFind(int size) { m_Data.assign(size, -1); }

        // x と y の属する集合を併合
        // 既に一緒な集合内にいるなら false を
        // 新たに併合されたなら true を返す
        bool Unite(int x, int y) {
            x = Find(x), y = Find(y);
            if(x == y) { return (false); }
            if(m_Data[x] > m_Data[y]) { swap(x, y); }
            m_Data[x] += m_Data[y];
            m_Data[y] = x;
            return (true);
        }

        // 要素 k が属する集合の根を返す
        int Find(int k) {
            if(m_Data[k] < 0) { return (k); }
            return (m_Data[k] = Find(m_Data[k]));
        }

        // 要素 k と同じ集合の要素数を返す
        int Size(int k) { return (-m_Data[Find(k)]); }

    private:
        vector<int> m_Data;
};

signed main()
{
    cin >> N >> M;
    REP(i, N) {
        cin >> P[i];
        //origin[P[i]] = i+1;
    }
    UnionFind uf(N+1);
    REP(i, M) {
        ll x, y;
        cin >> x >> y;
        uf.Unite(x, y);
    }
    ll ans = 0;
    REP(i, N) {
        if(uf.Find(P[i]) == uf.Find(i+1)) { ans++; }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

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

int main() {
	int h, w;
	while (1) {
		cin >> h >> w; if (h == 0 && w == 0) break;
		rep(i, h) {	rep(i, w) cout << "#" << flush; cout_e; } cout_e;
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll massiv[200010];
ll dp[200010];
ll n;

int main(){
FLASH;
cin>>n;
ll maxx=0;
for(ll i=1;i<=n;i++)cin>>massiv[i];
for(ll i=1;i<=n;i++)
{
  dp[massiv[i]]=max(dp[massiv[i]-1]+1,dp[massiv[i]]);
  maxx=max(maxx,dp[massiv[i]]);  	
}

cout<<n-maxx<<endl;






return 0;
} 


Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define MAXN 100005
#define reg register
#define inl inline
#define int long long
using namespace std;
const int Mod=1e9+7;
int n,m,a[MAXN],t[MAXN];
struct Matrix
{
	int cnt[5][5];
	inl void Init()
	{
		memset(cnt,0,sizeof(cnt));
		for(reg int i=0;i<3;i++) cnt[i][i]=1;
	}
	friend Matrix operator * (const Matrix &x,const Matrix &y)
	{
		reg Matrix res;
		memset(res.cnt,0,sizeof(res.cnt));
		for(reg int i=0;i<3;i++)
		{
			for(reg int j=0;j<3;j++)
			{
				for(reg int k=0;k<3;k++) res.cnt[i][j]=(res.cnt[i][j]+x.cnt[i][k]*y.cnt[k][j]%Mod)%Mod;
			}
		}
		return res;
	}
}A,B,ans;
inl Matrix Pow(reg Matrix x,reg int y)
{
	reg Matrix res;
	res.Init();
	for(;y;y>>=1,x=x*x) if(y&1) res=res*x;
	return res;
}
signed main()
{
	scanf("%lld %lld",&n,&m);
	for(reg int i=1;i<=m;i++) scanf("%lld",&a[i]);
	for(reg int i=1;i<=m;i++) t[i]=a[i]-a[i-1]-1;
    m++;
	t[m]=n-a[m-1];
	A.cnt[0][0]=1,A.cnt[0][1]=0,A.cnt[0][2]=0;
	A.cnt[1][0]=1,A.cnt[1][1]=1,A.cnt[1][2]=0;
	A.cnt[2][0]=1,A.cnt[2][1]=2,A.cnt[2][2]=1;
	for(reg int i=0;i<3;i++) B.cnt[i][2]=1;
	for(reg int i=0;i<3;i++)
	{
		for(reg int j=0;j<3;j++) B.cnt[i][j]+=A.cnt[i][j];
	}
	ans.Init();
	for(reg int i=1;i<=m;i++)
	{
		ans=ans*Pow(B,t[i]);
		if(i<m) ans=ans*A;
	}
	printf("%lld\n",ans.cnt[2][0]);
	return 0;
}

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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

	ll t, i, x, j, y, 	z, k, n;
	cin >> x >> y;
	ce(x * y)
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
// #include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif




int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n; std::cin >> n;
    std::vector<bool> P(n);
    for(int i = 0; i < n; ++i){
        char c, d; std::cin >> c >> d;
        P[i] = (c == d);
    }
    for(int i = 0; i + 2 < n; ++i){
        if(P[i] and P[i + 1] and P[i + 2]){
            std::cout << "Yes\n";
            return 0;
        }
    }
    std::cout << "No\n";


    

    return 0;
}

Measured memory_bytes: 3612
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
    a = list(map(int, input().split()))
    C.append(a[0])
    A.append(a[1:])

mini = 12 * 100000 + 1
for bit in range(1<<N):
    A_sum = [0] * M
    price = 0
    for i in range(N):
        if (bit >> i) & 1:
            price += C[i]
            for j in range(M):
                A_sum[j] += A[i][j]
    flug = True
    for i in A_sum:
        if i < X:
            flug = False
            break
    if flug:
        mini = min(mini, price)
if mini == 12 * 100000 + 1: print(-1)
else: print(mini)

Measured memory_bytes: 68260