akhauriyash/Code-Regression huggingface dataset:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()

td_1 = [0]*N
td_rem = []
for _ in range(N):
    t,d = rl()
    t -= 1
    if td_1[t] == 0:
        td_1[t] = d
    else:
        if d <= td_1[t]:
            td_rem += [d]
        else:
            td_rem += [td_1[t]]
            td_1[t] = d


td_1.sort(reverse=True)
td_rem.sort(reverse=True)
#print(td_1)
#print(td_rem)
import numpy as np
index_0 = td_1.index(0) if 0 in td_1 else len(td_1)
td_1 = list(np.cumsum([0] + td_1[:index_0]))
td_rem = list(np.cumsum([0]+td_rem))

ans = [0 for _ in range(K+1)]
sum_l = 0
for i in range(1,K+1):
    if len(td_1)-1 >= i and len(td_rem)-1>=K-i:
        ans[i] = i*i + td_1[i] + td_rem[K-i]

#print(td_1)
#print(td_rem)
#print(ans)
print(max(ans))


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

using namespace std;

//disjoint-set
int parent[100];

void init(int n){
  for(int i=0; i<n; i++) parent[i]=i;
}

int root(int a){
  if (parent[a] == a) return a;
  return (parent[a] = root(parent[a]));
}

bool same_set_p(int a,int b){
  return root(a) == root(b);
}

void unite(int a,int b){
  parent[root(a)] = root(b);
}

//graph
class Edge{
public:
  int cost,a,b;
  Edge(int c=0,int d=0,int e=0):cost(c),a(d),b(e){}
  bool operator< (const Edge& o) const {
    return cost < o.cost;
  }
};

//main
int n,m;
Edge graph[10000];

int main(){
  while(scanf("%d %d",&n,&m),n){
    for(int i=0; i<m; i++){
      int a,b,cost;
      scanf("%d %d %d",&a,&b,&cost);
      graph[i] = Edge(cost,a,b);
    }

    sort(graph,graph+m);

    int answer=0;
    init(n);

    for(int i=0; i<m; i++){
      Edge e = graph[i];
      if(!same_set_p(e.a,e.b)){
	answer += e.cost;
	unite(e.a,e.b);
      }
    }

    printf("%d\n",answer);
  }
}

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

int main()
{
    long long int N;
    cin >> N;
    int dig, sum = 0, num;
    num = N;
    while (num)
    {
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    if (N % sum == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007

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

    ll n, m;
    cin >> n >> m;
    vector<ll> v(n, 0);
    vector<ll> pre(n + 1, 0);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());

    for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + v[i - 1];

    // debug
    // cout << "sorted array: ";
    // for (auto ii : v) cout << ii << " ";
    // cout << "\n presum: ";
    // for (auto ii : pre) cout << ii << " ";
    // cout << endl;

    ll lo = v[0] << 1, hi = (v[n - 1] << 1) + 1;
    ll hap, cnt;

    while (hi - lo > 1) {
        ll c = (lo + hi) >> 1;
        // debug
        // cout << "checking " << c << endl;
        cnt = 0;
        hap = 0;
        // minimum happiness for each handshake is c
        for (int i = 0; i < n; i++) {
            auto it = lower_bound(v.begin(), v.end(), c - v[i]);
            cnt += v.end() - it;
            int ind = it - v.begin();
            // debug
            // cout << i << " " << ind << endl;
            // cout << "count: +" << (v.end() - it) << endl;
            // cout << "hap: +" << (pre[n] - pre[ind] + (n - ind) * v[i]) << endl;
            hap += pre[n] - pre[ind] + (n - ind) * v[i];
        }
        // debug
        // cout << "total shakes: " << cnt << endl;
        if (cnt >= m) {
            lo = c;
        } else {
            hi = c;
        }
    }

    hap -= (cnt - m) * lo;

    cout << hap;

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
        continue
      if L[i] + L[j] <= L[k] or L[j] + L[k] <= L[i] or L[i] + L[k] <= L[j]:
        continue
      ans += 1

print(ans)


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

signed main() {
  int N, K;
  string S;
  cin >> N >> K >> S;

  int cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == S[i + 1]) {
      cnt++;
    }
  }

  cout << min(N - 1, cnt + 2 * K) << endl;

  return 0;
}

Measured memory_bytes: 512
n = int(input())
count = 0
for i in range(n):
    flag = 0
    N = float(input())
    if N == 1:
        flag = 1
    
    if N > 2 and N%2 == 0:
        flag = 1
    
    for j in range(2, int(1+N**0.5)):
        if flag == 1:
            break
        if float(N%(j)) == 0:
            flag = 1
    
    if flag == 0:
        count += 1

print(count)


Measured memory_bytes: 5436
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();

    if (r < 1200) {
      System.out.println("ABC");
    } else if (r < 2800) {
      System.out.println("ARC");
    } else {
      System.out.println("AGC");
    }

  }
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    if(s=="SUN"){
        cout << 7;
    }if(s=="MON"){
        cout << 6;
    }if(s=="TUE"){
        cout << 5;
    }if(s=="WED"){
        cout << 4;
    }if(s=="THU"){
        cout << 3;
    }if(s=="FRI"){
        cout << 2;
    }if(s=="SAT"){
        cout << 1;
    }

    return 0;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e3+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;
char grid[MAXN][MAXN];
ll dp[MAXN][MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>m;

    for(int i = 0; i < n; i++){
        cin>>grid[i];
    }
    if(grid[0][0] == '.') dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(i == 0 && j == 0) continue;
            if(grid[i][j] == '.'){
                //cout<<"ali";
                dp[i][j] = ((i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? dp[i][j - 1] : 0))%mod;
            }
            
        }
    }
    cout<<dp[n - 1][m - 1]<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
	int a,b,c,sum=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b+c)
	{
		printf("Yes");
		sum++;
	}
	if(b==a+c)
	{
		printf("Yes");
		sum++;
	}
	if(c==a+b)
	{
		printf("Yes");
		sum++;
	}
	if(sum==0)
	printf("No");
	return 0;
} 


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n =Integer.parseInt(sc.next());
		int q =Integer.parseInt(sc.next());

		ki anski = new ki(n);
		for(int i=0 ; i < n -1; i++) {
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
			anski.setBranch(a,b);
		}
		for(int i = 0 ; i < q ; i++) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			anski.setValue(a,b);
		}

		anski.add();
		anski.getAns();
	}
}

class ki{
	int ans[];
	List<Integer>[] branch;


	public ki(int n) {
		ans = new int[n];
		branch = new ArrayList[n];
		for (int i = 0 ; i < n ; i++) {
			ans[i] = 0;
			branch[i] = new ArrayList<Integer>();
		}
	}

	public void setBranch(int a,int b) {
			branch[a -1].add(b);
			branch[b -1].add(a);
	}


	public void setValue(int number,int value) {
		ans[number -1] += value;
	}

	public void getAns() {
		PrintWriter out = new PrintWriter(System.out);
		for(int i :ans) {
			out.println(i + " ");
		};
		out.flush();
	}

     public void add() {
		for(int i :branch[0]) {
			add(1,i);
		}

	}

	public void add(int root,int target) {
        ans[target - 1] += ans[root -1];
        for(int i : branch[target -1]) {
        	if(i == root) continue ;
        	add(target,i);
        }

	}
}


Measured memory_bytes: 154160
#include<bits/stdc++.h>
#include<iomanip>
#include<string>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
#define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lcm(a,b) (a*b)/__gcd(a,b)
#define set_bit_count(x) __builtin_popcount(x)
#define leading_zero_count(x) __builtin_clz(x)
#define tailing_zero_count(x) __builtin_ctz(x)
#define str_rev(str) reverse(str.begin(),str.end())
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
using namespace std;
vector<vector<ll> > vec2d;
vector<pair<ll, ll> > vec_pair;
// unordered_map<ll, ll> ump;
multiset<ll> node[200003];
map<ll, ll> omp;
ll pown(ll a, ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	return pown(a,b/2)*pown(a,b-b/2);
}
int main()
{
	int n,a,b;
	cin>>n;
	int p=0;
	for(int i=1;i<10;i++)
	{
		a=i;
		if(n%a==0)
		{
			b=n/a;
			if(b>=1 and b<10)
			{
				p=1;
				break;
			}
		}
	}
	if(p)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    string s;
    cin>>s;
    if(s[0]>='2'&&s[1]>='0'&&s[2]>='1'&&s[3]>='9'&&(s[5]=='1'||s[6]>='5')) cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

int main() {
	double n;
	cin >> n;
	cout << ceil(n/2) << endl;
	return 0;
}

Measured memory_bytes: 3332
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

const int nmax = 8;
bool mat[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited = true;
    for(int i = 0; i < N; i++){
        if(visited[i] == false){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }
    int ret = 0;
    for(int i = 0; i < N; i++){
        if(mat[v][i] == false){
            continue;
        }else if(visited[i] == true){
            continue;
        }else{
            visited[i] = true;
            ret += dfs(i, N, visited);
            visited[i] = false;
        }
    }
    return ret;
}
int main(){
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++){
            mat[i][j] = false;
        }
    }
    for(int i = 0; i < M; i++){
        mat[a[i]-1][b[i]-1] = true;
        mat[b[i]-1][a[i]-1] = true;
    }

    // input done
    bool visited[N];
    for(int i = 0; i < N; i++){
        visited[i] = false;
    }
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    const int INF = ten(9);
    int H, W, K, xs, ys, xe, ye;
    vc<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
    vvc<int> dist;
    vc<string> grid;

    inline bool valid(int x, int y){
        return 0<=x and x<H and 0<=y and y<W and grid[x][y]=='.';
    }

    void bfs(){
        dist[xs][ys] = 0;
        queue<pii> que;
        que.emplace(xs, ys);
        while(not que.empty()){
            int cx = que.front().first, cy = que.front().second;
            que.pop();
            REP(i, 4) RREP(j, K){
                int nx = cx + j * dx[i], ny = cy + j * dy[i];
                if(not valid(nx, ny) or dist[nx][ny]<=dist[cx][cy]) break;
                if(dist[nx][ny]==INF){
                    dist[nx][ny] = dist[cx][cy] + 1;
                    que.emplace(nx, ny);
                }
            }
        }
    }

    void solve(istream& in, ostream& out){
        in>>H>>W>>K;
        in>>xs>>ys>>xe>>ye;
        xs--, ys--, xe--, ye--;
        dist.resize(H, vc<int>(W, INF));
        grid.resize(H);
        for(auto& g : grid) in>>g;
        bfs();
        if(dist[xe][ye]==INF) out<<"-1\n";
        else out<<dist[xe][ye]<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;

int b[maxn],a[maxn];

int main()
{
    int n;
    cin>>n;
    double ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==1)
            ans++;
    }
    printf("%lf",ans/n);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
	char a[3];
	int i,flag=0;
	gets(a);
	for(i=0;i<3;i++)
	{
		if(a[i]=='7')
		{
		flag++;
		}
	}
	if(flag==0) printf("No");
	else printf("Yes");
	return 0;
} 

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

using namespace std;

int main(){

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int power_2k = 1;
    for (int i = 0; i < k; i++){
        power_2k *= 2;
    }
    //cout << power_2k << endl;

    cout << a + b + c + max(a, max(b, c)) * (power_2k - 1) << endl;

    return 0;
}

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

using namespace std;

int main() {
  int n, x, m[100], total = 0, ans = 0;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d", &m[i]);
  }
  sort(m, m + n);
  for (int i = 0; i < n; i++) {
    total += m[i];
    ans++;
  }
  while (total + m[0] <= x) {
    total += m[0];
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
	int n;
  cin >> n;
	if(n==3) {
		cout << "2" << endl;
		cout << "1 3" << endl;
		cout << "2 3" << endl;
		return 0;
	}
	else if(n%2==0) {
		int cnt = (n-2)*n/2;
		cout << cnt << endl;
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				if(i==j) continue;
				if(i==(n+1-j)) continue;
				if(i>j) continue;
				cout << i << " " << j << endl;
			}
		}
		return 0;
	}
	else {
		int cnt = (n-3)*(n-1)/2+(n-1);
		cout << cnt << endl;
		for(int i = 1; i < n; i++) {
			for(int j = 1; j <= n; j++) {
				if(i==j) continue;
				if(i==(n-j)) continue;
				if(i>j) continue;
				cout << i << " " << j << endl;
			}
		}
		return 0;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> L[2000];int N,M,E,C[2000],x[2000],y[2000];bool U[2000];
bool DFS(int V){
U[V]=true;
for(int i=0;i<L[V].size();i++){
int u=L[V][i],w=C[u];
if(w<0||!U[w]&&DFS(w)){
C[V]=u;
C[u]=V;
return 1;
}
}
return 0;
}
int SM(){
int r=0;
memset(C,-1,8000);
for(int j=0;j<N+M;j++){
if(C[j]<0){
memset(U,0,8000);
if(DFS(j)){r++;}
}
}
return r;
}
int main(){
while(1){
for(int i=0;i<2000;i++){L[i].clear();}
cin>>N>>M;if(!N){break;}
for(int i=0;i<N;i++){
cin>>x[i];
}
for(int i=0;i<M;i++){
cin>>y[i];
}
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(__gcd(x[i],y[j])>1){
L[i].push_back(j+N);
}
}
}
cout<<SM()<<endl;
}
return 0;
}

Measured memory_bytes: 4136
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	X, Y, Z, K := scanInt(), scanInt(), scanInt(), scanInt()
	A, B, C := make([]int, X), make([]int, Y), make([]int, Z)
	for i := 0; i < X; i++ {
		A[i] = scanInt()
	}
	sort.Ints(A)
	for i := 0; i < Y; i++ {
		B[i] = scanInt()
	}
	sort.Ints(B)
	for i := 0; i < Z; i++ {
		C[i] = scanInt()
	}
	sort.Ints(C)

	ans := make([]int, 0)
	for i := 1; i <= X; i++ {
		for j := 1; j <= Y; j++ {
			for k := 1; k <= Z; k++ {
				if i*j*k <= K {
					ans = append(ans, A[X-i]+B[Y-j]+C[Z-k])
				}
			}
		}
	}
	sort.Ints(ans)

	for i := 0; i < K; i++ {
		fmt.Println(ans[len(ans)-1-i])
	}
}


Measured memory_bytes: 7424
N,M,K = map(int,input().split())

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

a = [0]
b = [0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

    
ans,j = 0,M

for i in range(N+1):
    if a[i] > K:
        break
    while K < a[i] + b[j]:
        j -= 1
    ans = max(ans,i+j)
    
print(ans)

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

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;

	for(int i = 0; i < s.size(); i++)
	{
		s[i] += n;

		if(s[i] > 'Z')
		{
			int a = s[i] - 'Z';
			s[i] = 'A' + (a-1);
		}
	}

	cout << s << endl;

	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
  	cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3640
n, m = gets.chomp.split(" ").map(&:to_i)
ab = []
n.times do
  ab << gets.chomp.split(" ").map(&:to_i)
end

cd = []
m.times do
  cd << gets.chomp.split(" ").map(&:to_i)
end

ab.each do |a, b|
  cp = cd.map{|c, d| (a - c).abs + (b - d).abs}
  puts cp.index(cp.min) + 1
end


Measured memory_bytes: 1788
#include <stdio.h>

using namespace std;

int main(){
	int n,m,l;
	scanf("%d %d %d",&n,&m,&l);
	int A[n][m],B[m][l];
	long long int C[n][l];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			C[i][j] = 0;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			scanf("%d",&B[i][j]);
		}
	}

	for(int i = 0; i < n; i++){
		for(int k = 0; k < l; k++){
			for(int j = 0; j < m; j++){
				C[i][k] += A[i][j]*B[j][k];
			}
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l-1; j++){
			printf("%lld ",C[i][j]);
		}
		printf("%lld\n",C[i][l-1]);
	}
}



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

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

    long long x;
    x = a * b;

    long long tmp, r;
    if (a < b){
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a % b;
    while (r != 0){
        a = b;
        b = r;
        r = a% b;
    }

    cout << x / b << endl;
    return 0;
}

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

int main() {
  int n, *p, i, m[101][101], l, j, k, q;
  
  scanf( "%d" , &n );
  p = malloc((n+1) * sizeof(int));
  for ( i=0; i<n; i++ ) scanf( "%d %d" , &p[i] , &p[i+1] );
  
  for ( i=1; i<=n; i++ ) m[i][i] = 0;
  for ( l=2; l<=n; l++ )
    for ( i=1; i<=(n-l+1); i++ ) {
      j = i+l-1;
      m[i][j] = m[i][i] + m[i+1][j] + p[i-1]*p[i]*p[j] ;
      for ( k=i; k<=(j-1); k++ ) {
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        if ( m[i][j] > q ) m[i][j] = q;
	  }
    }

  printf( "%d\n" , m[1][n] );
  
  return 0;
}



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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 3e5 + 5;
int n;
ll a[maxn];

ll cal(int l , int r){
    if(l == r)return a[l] - a[l - 1];
    return a[r] - a[l - 1] - cal(l + 1 , r - 1);
}

int res[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
        a[i] *= 2;
        a[i] += a[i - 1];
    }
    res[1] = a[n] / 2 - cal(2 , n - 1);
//    cout << cal(2 , n - 1) << endl;
    for(int i = 2 ; i <= n ; ++i){
        res[i] = a[i - 1] - a[i - 2] - res[i - 1];
    }
    for(int i = 1 ; i <= n ; ++i)cout << res[i] << " ";
}


Measured memory_bytes: 2560
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int a[100010];
bool diff[100010];
signed main() {
    cin >> N;
    rep(i,0,N) {
        cin >> a[i];
        if(a[i] != i + 1) diff[i] = true;
    }

    int cnt = 0, ans = 0;
    rep(i,0,N) {
        if(!diff[i]) cnt++;
        else if(cnt > 0) ans += (cnt - 1) / 2 + 1, cnt = 0;
    }
    if(cnt > 0) ans += (cnt - 1) / 2 + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
long long n,j,rd;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>rd;
		if(rd%2==1)
			j++;
	}
	if(j%2==0)
		cout<<"YES";
	else
		cout<<"NO";
}

Measured memory_bytes: 256
import math
n,d = map(int, input().split())
li = [list(map(int, input().split())) for i in range(n)]

cnt=0
f=0
for i in range(n-1):
    for j in range(n-i-1):
        for k in range(d):
            f+=(li[i][k]-li[n-j-1][k])**2
        f=math.sqrt(f)
        if f.is_integer()==True:
            cnt+=1
        f=0
        #print(i,n-j-1)

print(cnt)

Measured memory_bytes: 3064
n, x, y = gets.split.map(&:to_i)
hash = Hash.new(0)
(0...n).each do |start|
  (start + 1...n).each do |goal|
    dist_to_x = ((x - 1) - start).abs
    dist_to_y = ((y - 1) - start).abs
    dist_to_x = dist_to_y + 1 if dist_to_x > dist_to_y + 1
    dist_to_y = dist_to_x + 1 if dist_to_y > dist_to_x + 1
    dist_from_x = (goal - (x - 1)).abs + dist_to_x
    dist_from_y = (goal - (y - 1)).abs + dist_to_y
    hash[[dist_from_x, dist_from_y, (goal - start).abs].min] += 1
  end
end
(1...n).each do |i|
  puts hash[i]
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    vector<int> deg(4);
    REP(i, 3) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        deg[a]++;
        deg[b]++;
    }
    REP(i, 4) {
        if (!(deg[i] == 1 || deg[i] == 2)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

string alphabet_up = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char to_upper(char s){
    char t;
    int count = 0;
    for (char i = 'a'; i <= 'z'; i++) {
        if (s == i) {
            t = alphabet_up[count];
            break;
        } 
        count++;
    }
    return t;
}

string alphabet_lo = "abcdefghijklmnopqrstuvwxyz";
char to_lower(char s){
    char t;
    int count = 0;
    for (char i = 'A'; i <= 'Z'; i++) {
        if (s == i) {
            t = alphabet_lo[count];
            break;
        } 
        count++;
    }
    return t;
}

int main() {
    
    string a,b,c; cin >>a>>b>>c;
    string s = "";

    s += to_upper(a[0]);
    s += to_upper(b[0]);
    s += to_upper(c[0]);

    cout << s << endl;
    return 0;

}




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

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

	int n = S.size();
	string now;
	string last;
	int ans = 0;
	for( int i = 0; i < n; i++ ) {
		now += S[i];
		if( now != last ) {
			ans++;
			last = now;
			now = "";
		}
	}

	cout << ans <<  endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int gcd(int a, int b){
	int m;
	while(b != 0){
		m = a % b;
		a = b;
		b = m;
	}
	return a;
}

int main(){
    int a, b;
    while(cin>>a>>b){
    	int g = gcd(a,b);
    	printf("%d %d\n", g, a*(b/g));
    }
}


Measured memory_bytes: 3128
import sys
_dict = {1: [],
         2: [],
         3: []}
n, m = map(int, input().split())
for _ in range(m):
    _s, _c = map(int, input().split())
    if _s > n:
        print(-1)
        sys.exit()
    _dict[_s].append(_c)

for i in range(n):
    if _dict[i + 1]:
        if min(_dict[i + 1]) != max(_dict[i + 1]):
            print(-1)
            break
    else:
        if i == 0:
            if n == 1:
                _dict[1].append(0)
            else:
                _dict[1].append(1)
        else:
            _dict[i + 1].append(0)
else:
    if n == 1:
        print(_dict[1][0])
    elif n == 2:
        if _dict[1][0] == 0:
            print(-1)
        else:
            print(_dict[1][0] * 10 + _dict[2][0])
    else:
        if _dict[1][0] == 0:
            print(-1)
        else:
            print(_dict[1][0] * 100 + _dict[2][0] * 10 + _dict[3][0])

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int mm=2e5+11;
int a[mm+11];
int main() {
	int n,t;
	scanf("%d%d",&n,&t);
	for(int i=0;i<n;++i) scanf("%d",&a[i]);
	LL ans=0;
	for(int i=0;i<n-1;++i) {
	    ans+=min(t,a[i+1]-a[i]);
	}
	ans+=t;
	printf("%lld\n",ans); 
	return 0;
}  

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll f = min({a, b, c, d, e});
  //cout << n / f << " ";
  cout << (n + f - 1) / f + 4 << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/priority_queue.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define endl '\n'
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
#define lowbit(x) x &(-x)
#define all(x) (x).begin(), (x).end()
#define sf(x) scanf("%d", &x)
#define pf(x) printf("%d", x)
#define debug(x) cout << x << endl
#define mod(x) (x % mod + mod) % mod

template <typename T>
void read(T &x)
{
	x = 0;
	char ch = getchar();
	ll f = 1;
	while (!isdigit(ch))
	{
		if (ch == '-')
			f *= -1;
		ch = getchar();
	}
	while (isdigit(ch))
	{
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	x *= f;
}

const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e2 + 7;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;

#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//template<typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
ll qpow(ll a, ll n)
{
    ll re = 1;
    while(n)
    {
        if(n & 1)
            re = (re * a) % mod;
        n >>= 1;
        a = (a * a) % mod;
    }
    return re % mod;
}
int main() {
    int n,m;
    cin>>n>>m;
    cout<<qpow(m,n)<<endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <array>
#include <cstdint>
#include <algorithm>

int main()
{
	std::uint64_t SizeOfTriangle;
	std::uint64_t InputMysteriousLight;

	std::cin >> SizeOfTriangle >> InputMysteriousLight;

	std::uint64_t LocusLength = SizeOfTriangle;

	std::uint64_t a = InputMysteriousLight;
	std::uint64_t b = (SizeOfTriangle - InputMysteriousLight);

	std::uint64_t l = (a > b) ? a : b;
	std::uint64_t s = (a < b) ? a : b;

	while (true) {
		if (l == s) {
			LocusLength += s;
			break;
		}
		if (s == 1) {
			LocusLength += l * 2 - 1;
			break;
		}
		if (s == 0) {
			LocusLength -= l;
			break;
		}

		std::uint64_t m = l / s;
		LocusLength += (2 * s * m);

		std::uint64_t t = l % s;
		l = s;
		s = t;
	}

	std::cout << LocusLength << std::endl;

	return 0;
}

Measured memory_bytes: 256
def same_count(str_list):
    standard_str = min(str_list, key=lambda x: len(x))
    return [all([c in str_ for str_ in str_list]) for c in set(standard_str)].count(True)

n = int(input())
s = input()

print(max([same_count([s[:i+1], s[i+1:]]) for i in range(n)]+[0]))

Measured memory_bytes: 3060
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int E;
int solve(int E) {
  int ans = 1e9;
  for (int z=0; z*z*z<=E; ++z)
    for (int y=0; y*y<=E-z*z*z; ++y) {
      int x = E-y*y-z*z*z;
      if (x+y*y+z*z*z == E)
        ans = min(ans, x+y+z);
    }
  return ans;
}

int main() {
  while (cin >> E && E>0)
    cout << solve(E) << endl;
}



Measured memory_bytes: 3028
#include <cstdio>

inline long long in() {
  long long n = 0;
  char c = getchar_unlocked();
  while ('0' <= c && c <= '9') {
    n *= 10;
    n += (c - '0');
    c = getchar_unlocked();
  }
  return n;
}

inline void out(long long n) {
  long long N = n, rev; int count = 0;
  rev = N;
  if (N == 0) { putchar_unlocked('0'); return; }
  while ((rev % 10) == 0) { count++; rev /= 10;}
  rev = 0;
  while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10; }
  while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10; }
  while (count--) putchar_unlocked('0');
}

int main() {
  long long I = in(), O = in(), T = in(), J = in(), L = in();
  long long n = (I&1?I-1:I) + (J&1?J-1:J) + (L&1?L-1:L);
  if (I && J && L) {
    long m = (I&1?I-1:I-2) + (J&1?J-1:J-2) + (L&1?L-1:L-2) + 3;
    out((n<m?m:n) + O);
  } else {
    out(n + O);
  }
}

Measured memory_bytes: 128
from itertools import groupby
N, K = map(int,input().split())
S = '1' + input() + '1'
acc = [0]
for i, (k, v) in enumerate(groupby(S)):
    acc.append(acc[i] + len(list(v)))
sz = len(acc)
l = [acc[min(sz - 1, i + 2 * K + 1)] - acc[i] - (i == 0) - (i + 2 * K + 1 >= sz - 1) for i in range(sz)]
print(max(l[::2]))

Measured memory_bytes: 11620
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

ll ans=1;
ll K;
vector<vecl> ADJ;
void dfs(ll u,ll dep,ll p=-1)
{
	ll col=K;
	if (dep==0)
	{
		ans=(ans*K)%MOD;
		col=K-1;
	}
	else
	{
		col=K-2;
	}
	trav(v,ADJ[u])
	{
		if(v!=p)
		{
			ans=(ans*col)%MOD;
			col--;
			dfs(v,dep+1,u);
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	READV(N);
	READ(K);
	rz(ADJ,N+1);
	FORI(i,0,N-1)
	{
		READV(u);
		READV(v);
		ADJ[u].pb(v);
		ADJ[v].pb(u);
	}
	dfs(1,0);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1);
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    val n = readInt()
    var dices = List.empty[Array[Int]]
    for(_ <- 1 to n){
      dices :+= readLine().split(" ").map(_.toInt)
    }
    println(if(differentFromEachOther(dices)) "Yes" else "No")
  }

  def differentFromEachOther(dices:List[Array[Int]]): Boolean ={
    for(i <- 0 until dices.size; j <- (i + 1) until dices.size){
      if(diceEqual(dices(i),dices(j))) return false
    }
    return true
  }

  def diceEqual(dice1:Array[Int], dice2:Array[Int]) : Boolean = {
    for(i <- createDiceArray(dice1,"WNNNW"); j <- createDiceArray(i,"HHH")){
      if((j zip dice2).forall(x => x._1 == x._2)) return true
    }
    return false
  }

  def createDiceArray(dice:Array[Int],commands:String) : List[Array[Int]] = {
    var dices = List(dice)
    for(cmd <- commands.toCharArray){
      dices :+= getNextStatus(cmd,dices.last)
    }
    dices
  }

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd match {
    case 'N' => Array(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
    case 'H' => Array(dice(0), dice(2), dice(4), dice(1), dice(3), dice(5))
    case 'W' => Array(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  }
}

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

using namespace std;

int MAX = 999999999;
int MIN = 1000000009;
int N = 1000009;

int k, x;

int main()
{
  cin >> k >> x;
  cout << ((k * 500 >= x) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
// Here is the top-down approach of
// dynamic programming
#include <bits/stdc++.h>
#define ll long long
using namespace std;

// Returns the value of maximum profit
ll int knapSackRec(ll int W, ll int wt[], ll int val[],
                   ll int i, ll int** dp)
{
    // base condition
    if (i < 0)
        return 0;
    if (dp[i][W] != -1)
        return dp[i][W];

    if (wt[i] > W) {

        // Store the value of function call
        // stack in table before return
        dp[i][W] = knapSackRec(
                       W, wt, val, i - 1, dp);
        return dp[i][W];
    }
    else {

        // Store value in a table before return
        dp[i][W] = max(
                       val[i] + knapSackRec(
                           W - wt[i], wt, val, i - 1, dp),
                       knapSackRec(W, wt, val, i - 1, dp));

        // Return value of table after storing
        return dp[i][W];
    }
}

ll int knapSack(ll int W, ll int wt[], ll int val[], ll int n)
{
    // double poll inter to declare the
// table dynamically
    ll int** dp;
    dp = new ll int*[n];

    // loop to create the table dynamically
    for (ll int i = 0; i < n; i++)
        dp[i] = new ll int[W + 1];

    // loop to initially filled the
// table with -1
    for (ll int i = 0; i < n; i++)
        for (ll int j = 0; j < W + 1; j++)
            dp[i][j] = -1;
    return knapSackRec(W, wt, val, n - 1, dp);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll int n, W;
    cin >> n >> W;
    ll int wt[n], val[n];
    for (ll int i = 0; i < n; i++)
    {
        cin >> wt[i] >> val[i];
    }
    cout << knapSack(W, wt, val, n);
    return 0;
}

Measured memory_bytes: 81860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int l1, l2, l3, num;
    ll ans = 0;
    rep(i,n-2) {
        l1 = l[i];
        for(int j = i+1; j < n-1; j++) {
            l2 = l[j];
            l3 = l1 + l2;
            num = lower_bound(l.begin(), l.end(), l3) - l.begin();
            num = max(num-j-1, 0);
            ans += num;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>

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

using namespace std;

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

  //int A[b+1], B[a+1];
  int A,B, sum=0;
  for(int i=b-1;i>=0;i--)
    sum+=a*pow(10,i);
  A=sum;
  sum=0;

  for(int i=a-1;i>=0;i--)
    sum+=b*pow(10,i);
  B=sum;

  string str_a = to_string(A);
  string str_b = to_string(B);


  int res = strcmp(str_a.c_str(), str_b.c_str());
  if (res < 0)
    cout << str_a << endl;
  else
    cout << str_b << endl;

  return 0;
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>b)a=b;
    if(c>d)c=d;
    cout<<a+c<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n,m;
  cin>>n>>m;
  map<int,int> r;
  for(int i=1;i<=n;++i)r[i]=0;
  for(int i=0;i<m;++i){
    int a,b;
    cin>>a>>b;
    ++r[a]; ++r[b];
  }
  for(auto p:r)cout<<p.second<<"\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

struct UnionFind {
  vector<int> par;
  vector<int> size;
  UnionFind(int n): par(n), size(n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      size[i] = 1;
    }
  }
  int find(int x) {
    if(par[x] == x) {
      return x;
    }
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if(size[x] < size[y]) {
      par[x] = y;
      size[y] += size[x];
    } else {
      par[y] = x;
      size[x] += size[y];
    }
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int getSize(int x) {
    return size[find(x)];
  }
};

int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<PI> br(m);
  FOR(p,br) {
    cin >> p.first >> p.second;
    p.first--;
    p.second--;
  }
  reverse(br.begin(), br.end());
  VL ans;
  UnionFind uf(n);
  ll x = ((ll)n) * (n - 1) / 2;
  FOR(ab,br) {
    ans.push_back(x);
    int a = ab.first;
    int b = ab.second;
    if (!uf.same(a, b)) {
      ll sa = uf.getSize(a);
      ll sb = uf.getSize(b);
      x -= sa * sb;
      uf.unite(a, b);
    }
  }
  reverse(ans.begin(), ans.end());
  FOR(a,ans) {
    cout << a << endl;
  }

  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

long double PI = acosl(-1);

int main() {
	fast_io;
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	long double x = PI * 2 * (h * 60 + m) / (12 * 60);
	long double y = PI * 2 * m / 60;
	long double d = abs(x - y);
	if (d > PI)
		d = PI * 2 - d;
	cout << fixed << setprecision(10) << sqrtl((a + b * cosl(PI - d)) * (a + b * cosl(PI - d)) + b * sinl(PI - d) * b * sinl(PI - d)) << '\n';
}


Measured memory_bytes: 4172
#include<bits/stdc++.h>
using namespace std;
bool solve(int n)
{
	while(n>9)
	{
		if(n%10==7)
			return true;
		n /= 10;
	}
	return (n==7);
}
int main()
{
	int n;
	cin>>n;
	if(solve(n))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3636