akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        vector <ll> s;
        ll num,flag=0;
        for(int i=0;i<n;i++)
        {
            cin>>num;
            s.push_back(num);
        }
        for(int i=0;i<n;i++)
        {
            if(s[i]%2==0)
            {
                if(s[i]%3!=0&&s[i]%5!=0)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)
            cout<<"APPROVED"<<endl;
        else
            cout<<"DENIED"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
    ll n,ans=0,rn,a;
    vector<ll> v;
    scanf("%lld",&n);
    rn=sqrt(n);
    for(ll i=1;i<=rn;i++){
        if(n%i==0){
            if(i*i==n){
                v.push_back(i);
            }
            else{
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    for(int i=0;i<v.size();i++){
        a=(n-v[i])/v[i];
        if(a&&n/a==n%a){
            ans+=a;
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include <stdio.h>

int max(int a, int b){
  return a<b?b:a;
}

int main(void){
  int p,q,r;
  scanf("%d",&p);
  scanf("%d",&q);
  scanf("%d",&r);
  int ans = p+r+q;
  ans -= max(p,max(q,r));
  printf("%d\n",ans);

  return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	map<pair<int, int>, bool> boat;
	while(m--) {
		int a, b;
		cin >> a >> b;
		if( a > b) swap(a, b);
		boat[make_pair(a, b)] = 1;
	}	
	for(int v = 2; v < n; v++) {
		if(boat[make_pair(1, v)] & boat[make_pair(v, n)]) {
			cout << "POSSIBLE\n";
			return 0;
		}
	}
	cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626

 using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;




//----------------------------------------------------------------------------------------------------------------------

void swap(int &a,int &b){
    int temp = a;
    a = b;
    b = temp;
}

int findR(int a, int n){
    int i = 0;
    if( a*2 >= n) return 0;
    return n-1;
}


int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector< vector<int> > arr (n , vector<int> (3));
    for(int i = 0;i < n;i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    vector<int> pre (3);
    pre[0] = arr[0][0]; pre[1] = arr[0][1]; pre[2] = arr[0][2]; 
    vector<int> curr (3);
    for(int i = 1; i < n;i++){
        curr[0] = arr[i][0] + max(pre[1],pre[2]);
        curr[1] = arr[i][1] + max(pre[0],pre[2]);
        curr[2] = arr[i][2] + max(pre[1],pre[0]);
        pre = curr;
    }
    sort(rall(pre));
    cout << pre[0] << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

ll H, W;
ll ans;

int main()
{
  scanf( "%lld%lld", &H, &W );

  ans = H*W;

  repi( j, 1, W+1 )
  {
    ll arr[] = { H*j, (W-j)*(H/2), (W-j)*(int)ceil(H/2.0) };
      
    if( H >= 2 )
      ans = std::min( ans, *std::max_element( arr, arr+3 )-*std::min_element( arr, arr+3 ) );
    
    if( W-j >= 2 )
    {
      arr[1] = H*((W-j)/2);
      arr[2] = H*(int)ceil((W-j)/2.0);
      ans = std::min( ans, *std::max_element( arr, arr+3 )-*std::min_element( arr, arr+3 ) );  
    }
  }

  repi( i, 1, H+1 )
  {
    ll arr[] = { W*i, (H-i)*(W/2), (H-i)*(int)ceil(W/2.0) };
      
    if( W >= 2 )
      ans = std::min( ans, *std::max_element( arr, arr+3 )-*std::min_element( arr, arr+3 ) );

    
    if( H-i >= 2 )
    {
      arr[1] = W*((H-i)/2);
      arr[2] = W*(int)ceil((H-i)/2.0);
      ans = std::min( ans, *std::max_element( arr, arr+3 )-*std::min_element( arr, arr+3 ) );
    }
  }

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int height = inpt[0];
        int width = inpt[1];

        int colCount = int.Parse(Reader.ReadLine());
        int[] blocks = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        StringBuilder ans = new StringBuilder();
        int colIdx = 0;
        for (int i = 0; i < height; i++) {
            int[] lin = new int[width];
            for (int j = 0; j < width; j++) {
                lin[j] = colIdx + 1;
                blocks[colIdx]--;
                if(blocks[colIdx]<=0) {
                    colIdx++;
                }
            }
            if(i%2>0) {
                lin = lin.Reverse().ToArray();
            }
            ans.AppendLine(string.Join(" ", lin));
        }
        Console.Write(ans.ToString());

    }




    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



3 5
5
1 2 3 4 5


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


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

#define NIL NULL
/*
void inorder(NodePointer);
void preorder(NodePointer);
void insert(int);
*/
typedef struct node{
  int key;
  struct node *l;
  struct node *r;
  struct node *p;
} Node;

typedef struct node* NodePointer;
 
NodePointer root;

void insert(int key){

  NodePointer x, y, z;

  y = NIL;
  x = root;

  z = malloc(sizeof(struct node));
  z->key = key;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else x = x->r;
    z->p = y;
  }

  z->p = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z;

}

void inorder(NodePointer t){

  if(t->l != NIL) inorder(t->l);
  printf(" %d", t->key);
  if(t->r != NIL) inorder(t->r);

}

void preorder(NodePointer t){
 
  printf(" %d", t->key);
  if(t->l != NIL) preorder(t->l);
  if(t->r != NIL) preorder(t->r);

}

int main(){
     
  int i, n, x;
  char com[10];
  
  scanf("%d",&n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    } 
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;

}

Measured memory_bytes: 24040
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i = ((s.size()-1)/2)*2; 0 < i; i-=2){
    bool ok = true;
    for(int j = 0; i/2 > j; j++){
      if(s[j] != s[i/2+j]){
        ok = false;
        break;
      }
    }
    if(ok){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,data[1000000],age[7];
  while(cin >>n && n!=0){
    for(int i=0;i<7;i++)age[i]=0;
    for(int i=0;i<n;i++){
    cin >>data[i];
    if(data[i]<10) age[0]++;
    else if(data[i]>=10 && data[i]<20) age[1]++;
    else if(data[i]>=20 && data[i]<30) age[2]++;
    else if(data[i]>=30 && data[i]<40) age[3]++;
    else if(data[i]>=40 && data[i]<50) age[4]++;
    else if(data[i]>=50 && data[i]<60) age[5]++;
    else if(data[i]>=60) age[6]++;
    }
    for(int i=0;i<7;i++)
      cout <<age[i]<<endl;
  }
  return 0;}

Measured memory_bytes: 5068
import java.io.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long k = sc.nextLong();
    Long[] a = new Long[n];
    Long[] f = new Long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    for (int i = 0; i < n; i++) {
      f[i] = sc.nextLong();
    }
    Arrays.sort(a, Comparator.naturalOrder());
    Arrays.sort(f, Comparator.reverseOrder());

    long ok = 1;
    while (!canFinish(ok, n, k, a, f)) ok *= 2;
    long ng = ok / 2 - 1;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      if (canFinish(mid, n, k, a, f)) ok = mid;
      else ng = mid;
    }

    os.println(ok);
  }

  private static boolean canFinish(long time, int n, long k, Long[] a, Long[] f) {

    for (int i = 0; i < n; i++) {
      long c = time / f[i];
      k -= Math.max(a[i] - c, 0);
    }
    return k >= 0;
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
    }

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


Measured memory_bytes: 43416
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q;
    cin>>n>>q;
    vector<queue<long long > > Q(n);
    for(int i=0;i<q;i++){
        int k,t;
        cin>>k>>t;
        if(k==0){
            long long x;
            cin>>x;
            Q[t].push(x);
        }
        else if(k==1){
            if(!Q[t].empty()){
            cout<<Q[t].front()<<endl;
            }
        }
        else if(k==2){
            if(!Q[t].empty()){
            Q[t].pop();
            }
        }
    }
}



Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if ((int(s.size()) <= k))
    {
        cout << s << endl;
    }
    else
    {
        cout << s.substr(0, k) << "..." << endl;
    }
}

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

int main() {
    int N;  cin>>N;
    int min_val = 1000;
    int max_val = 0;
    
    for (int i = 0; i < N; ++i) {
        int x;  cin>>x;
        min_val = min(min_val, x);
        max_val = max(max_val, x);
    }
    
    cout<<max_val - min_val;
    
    return 0;
}

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

int main(){
  int n,m;
  bool flag = false;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  rep(i,m)cin >> s[i] >> c[i];
  int p = 0;
  if(n>1)p = pow(10,n-1);
  for(int i = p;i<pow(10,n);i++){
    string j = to_string(i);
    rep(di,m){
      if(j[s[di]-1]!=c[di])break;
      if(di==m-1){
	cout << i << endl;
	return 0;
      }
    }
  }
  if(m==0)cout << p << endl;
  else if(!flag)cout << "-1" << endl;
  return 0;
}


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

/**
 * 素因数分解を行う
 **/
map<int64, int64> get_prime_factors_list(int64 N)
{
    map<int64, int64> m;
    for (int64 i = 2; i * i <= N; i++)
    {
        if (N % i != 0)
            continue;
        while (N % i == 0)
        {
            m[i]++;
            N /= i;
        }
    }
    if (N > 1)
        m[N] = 1;
    return m;
}

int main()
{
    int64 N, P;
    cin >> N >> P;
    map<int64, int64> ret;

    ret = get_prime_factors_list(P);
    int64 ans = 1;
    for (auto it = ret.begin(); it != ret.end(); it++)
    {
        ans *= pow(it->first, it->second / N);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
class UnionFind:
    __slots__ = ["N", "root", "rank"]

    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        # 根を比較する
        # すでに同じ木に属していた場合は何もしない.
        # 違う木に属していた場合はrankを見てくっつける方を決める.
        # rankが同じ時はrankを1増やす
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}


import sys
input = sys.stdin.readline
n, q = map(int, input().split())
uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.union(u, v)


Measured memory_bytes: 75216
import collections

N = int(input())

l = list()
for i in range(N):
    l.append(int(input()))

c = collections.Counter(l)

la = list(c.values())
M = len(la)
ans = 0
for i in range(M):
    if la[i] % 2 == 1:
        ans += 1

print(ans)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

ll nCr[2001][2001];

int main() {
  nCr[0][0] = 1;
  rep(i, 2000) rep(j, i + 1) {
    nCr[i + 1][j] = (nCr[i + 1][j] + nCr[i][j]) % MOD;
    if (j + 1 <= 2000)
      nCr[i + 1][j + 1] = (nCr[i + 1][j + 1] + nCr[i][j]) % MOD;
  }

  int N, K;
  cin >> N >> K;

  int red = N - K;

  REP(i, 1, K + 1) {
    ll ans = 0;
    if (red + 1 < i)
      cout << ans << endl;
    else {
      ans = nCr[red + 1][i] * nCr[K - 1][i - 1] % MOD;
      cout << ans << endl;
    }
  }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

int N; vi A,B,C;
void input(){
    cin>>N;
    rep(i,N){
        int a; cin>>a; A.emplace_back(a-1);
    }
    rep(i,N){
        int b; cin>>b; B.emplace_back(b);
    }
    rep(i,N-1){
        int c; cin>>c; C.emplace_back(c);
    }
    int ans=0;
    rep(i,N-1){
        ans+=B[A[i]];
        if((A[i+1]-A[i])==1) ans+=C[A[i]];
    }
    ans+=B[A[N-1]];
    cout<<ans<<endl;
    return;
}

void solve(){

    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;

	cout << max(a,max(b, c))*((int)pow(2,k) - 1)+ a + b + c << endl;
}

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

signed main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<int>a(x), b(y), c(z);
	for (int i = 0; i < x; ++i)cin >> a[i];
	for (int i = 0; i < y; ++i)cin >> b[i];
	for (int i = 0; i < z; ++i)cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	vector<int> ab;
	for (int i = 0; i < x; ++i) {
		for (int j = 0; j < y; ++j) {
			ab.push_back(a[i] + b[j]);
		}
	}
	sort(ab.rbegin(), ab.rend());

	vector<int> index(x * y, 0);
	priority_queue<pair<int, int>> pq;
	for (int j = 0; j < x * y; ++j) pq.push({ ab[j] + c[index[j]],j });
	for (int i = 0, lab = 0, lc = 0; i < k; ++i) {
		auto p = pq.top();
		pq.pop();
		cout << p.first << endl;
		++index[p.second];
		if (index[p.second] < z)pq.push({ ab[p.second] + c[index[p.second]],p.second });
	}
}


Measured memory_bytes: 34412
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

uint64_t N;
vector<uint64_t> As;

uint64_t calc() {
  sort(As.begin(), As.end(), greater<uint64_t>());

  uint64_t sum = 0;
  for (uint64_t i = 1; i < 2 * N; i += 2) {
    sum += As[i];
  }

  return sum;
}

int main() {
  cin >> N;
  As.reserve(3 * N);

  for (uint64_t i = 0; i < 3 * N; ++i) {
    uint64_t a;
    cin >> a;
    As.push_back(a);
  }

  auto s = calc();

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }


ll N, K, A[212345], F[212345], AA[212345];

int main() {

	scanf("%lld%lld", &N, &K);
	rep(i, N) scanf("%lld", &A[i]);
	rep(i, N) scanf("%lld", &F[i]);
	sort(A, A + N);
	sort(F, F + N);
	ll l = 0, r = 1000000000001, m;

	for (;;) {
		m = (l + r) / 2;
		rep(i, N) {
			AA[i] = m / F[N - 1 - i];
		}
		ll Cost = 0;
		rep(i, N) {
			Cost += max(0ll, A[i] - AA[i]);
		}
		if (Cost > K) {
			if (r - l <= 1) {
				printf("%lld\n", r);
				break;
			}
			l = m;
		}
		else {
			if (r - l <= 1) {
				printf("%lld\n", l);
				break;
			}
			r = m;
		}
	}


	return 0;
}

Measured memory_bytes: 4992
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl A, B, K;

void solve(void) {
  auto t = min(K, A);
  K -= t;
  A -= t;
  t = min(K, B);
  K -= t;
  B -= t;
  cout << A << " " << B << endl;
}

int main(void) {
  cin >> A >> B >> K;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,w[101],v[101],ww,dp[101][10001];;
int dps(){
    for(int i=0;i<=ww;i++){
        if(i<w[0])dp[0][i]=0;
        else dp[0][i]=v[0]*(i/w[0]);
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<=ww;j++){
            if(j<w[i])dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],v[i]+dp[i][j-w[i]]);
        }
    }
    return dp[n-1][ww];
}
int main(){
    cin>>n>>ww;
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    dps();
    cout<<dp[n-1][ww]<<endl;
    return 0;
}




Measured memory_bytes: 7012
// inputに入力データ全体が入る
function Main(input) {
  var a,b,t;
  a = Number(input.split('\n')[0].split(' ')[0]);
  b = Number(input.split('\n')[0].split(' ')[1]);
  t = Number(input.split('\n')[0].split(' ')[2]);
  
  console.log(Math.floor((t+0.5) / a) * b);
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

struct card { 
	char suit; 
	int value; 
};

void print_cards(struct card *c, int N) {
	for (int i = 0; i < N; i++) {
		if (i) {
			cout << " ";
		}
		cout << c[i].suit << c[i].value;
	}
	cout << endl;
}

struct card * bubble_sort(struct card *c, struct card *bubblec, int N) {
	for (int i = 0; i < N; i++) {
		bubblec[i] = c[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1 - i; j++) {
			if (bubblec[j].value > bubblec[j + 1].value) {
				struct card tmp = bubblec[j];
				bubblec[j] = bubblec[j + 1];
				bubblec[j + 1] = tmp;
			}
		}
	}
	print_cards(bubblec, N);
	return bubblec;
}

void selection_sort(struct card *c, struct card *selectc, int N) {
	for (int i = 0; i < N; i++) {
		selectc[i] = c[i];
	}
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (selectc[minj].value > selectc[j].value) {
				minj = j;
			}
		}
		struct card tmp = selectc[i];
		selectc[i] = selectc[minj];
		selectc[minj] = tmp;
	}
	print_cards(selectc, N);
}

void isstable(struct card *bc, struct card *sc, int N) {
	int sw = true;
	for (int i = 0; i < N; i++) {
		if (bc[i].suit != sc[i].suit) {
			sw = false;
			break;
		}
	}
	if (sw) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
}

int main(void) {
	struct card c[36], bc[36], sc[36];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> c[i].suit >> c[i].value;
	}
	bubble_sort(c, bc, N);
	cout << "Stable" << endl;
	selection_sort(c, sc, N);
	isstable(bc, sc, N);
	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
int s[1<<15];
int main(void)
{
    int i, j, k, n;
    for(i=1;i*i<(1<<15);++i) s[i*i]=i;
    while (scanf("%d", &n), n) {
        int res=s[n]>0;

        for(i=1;i*i<n;++i) res+=(s[n-i*i]>=i);

        for(i=1;i*i<n-1;++i)
        for(j=i;i*i+j*j<n;++j) res+=(s[n-i*i-j*j]>=j);

        for(i=1;i*i<n-2;++i)
        for(j=i;i*i+j*j<n-1;++j)
        for(k=j;i*i+j*j+k*k<n;++k) res+=(s[n-i*i-j*j-k*k]>=k);

        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 728
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-07-11 21:04:40 +0900
# LastModified: 2020-07-11 21:08:13 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    for i, a in enumerate(A):
        if (i+1)%2 == 1 and a%2 == 1:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8980
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, a, b) = readLongList()
    val xList = readLongList()

    var pre = xList.first()
    var ans = 0L
    for (x in xList.drop(0)) {
        val diff = x - pre
        ans += min(diff * a, b)

        pre = x
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 52084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans = 0;
	rep(i,60){
		ll cnt = 0;
		rep(j,n){
			if(a.at(j) & (1LL << i)) cnt++;
		}
		ans += (1LL << i) % mod * cnt % mod * (n - cnt) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


a, b = input().split()
a = int(a)
b = list(b)
dot = 0
for i in range(len(b)):
    if b[-i - 1] == ".":
        dot = i
        del b[-1 - i]
        b = int("".join(b))
        break
ans = str(a * b)
if len(ans) <= dot:
    ans = 0
else:
    ans = ans[:-dot]
print(ans)


Measured memory_bytes: 68468
#include <climits>
#include <iostream>
#include <queue>
#include <vector>

const int INF = INT_MAX;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::vector<int>> r(n + 1, std::vector<int>(0));
  for (int i = 0; i < m; ++i) {
    int a, b;
    std::cin >> a >> b;
    --a, --b;
    r.at(a).push_back(b);
    r.at(b).push_back(a);
  }

  // for (int i = 0; i < n; ++i) {
  //   std::cout << i << ": ";
  //   for (auto j : r.at(i))
  //     std::cout << j << " ";
  //   std::cout << std::endl;
  // }

  std::queue<int> q;
  std::vector<int> dist(n, INF); // 部屋1までの距離
  std::vector<int> pre(n, -1);   // 前の部屋
  dist.at(0) = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : r.at(v)) {
      if (dist.at(u) != INF)
        continue;
      dist.at(u) = dist.at(v) + 1;
      pre.at(u) = v;
      q.push(u);
    }
  }

  std::cout << "Yes" << std::endl;
  for (int i = 0; i < n; ++i) {
    if (i == 0)
      continue;
    std::cout << pre.at(i) + 1 << std::endl;
  }
}


Measured memory_bytes: 10204
import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, d = list(map(int,ipti().split()))
    x = [0] * n

    for i in range(n):
        x[i] = list(map(int,ipti().split()))

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

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n,t = map(int,input().split())
a,b = [],[]
for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)
dp1 = [[0]*(t+1) for _ in range(n+2)]
dp2 = [[0]*(t+1) for _ in range(n+2)]
for i in range(1,n+1):
    w,v = a[i-1],b[i-1]
    for j in range(1,t+1):
        if j < w:
            dp1[i][j] = dp1[i-1][j]
        else:
            dp1[i][j] = max(dp1[i-1][j], dp1[i-1][j-w]+v)
for i in range(n,0,-1):
    w,v = a[i-1],b[i-1]
    for j in range(1,t+1):
        if j < w:
            dp2[i][j] = dp2[i+1][j]
        else:
            dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-w]+v)


ans = 0
for i in range(1,n+1):
    for j in range(t):
        ans = max(ans,dp1[i-1][j]+dp2[i+1][t-1-j]+b[i-1])
print(ans)

Measured memory_bytes: 216264
import sys
import itertools
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    loc = [list(map(int,input().split())) for _ in range(n)]
    arr = list(itertools.permutations(loc))
    p = math.factorial(n)
    dis = 0
    for i in range(p):
        for j in range(n-1):
            dis += math.sqrt((arr[i][j+1][1]-arr[i][j][1])**2+(arr[i][j+1][0]-arr[i][j][0])**2)
    print(dis/p)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7972
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int Q;
    cin >> Q;
    for(int q=0; q<Q; q++){
        int N;
        cin >> N;
        int cnt = 0;
        while(N >= 10){
            string S = to_string(N);
            int mx = 0;
            for(int i=1; i<S.size(); i++){
                int temp = stoi(S.substr(0,i)) * stoi(S.substr(i));
                chmax(mx,temp);
            }
            N = mx;
            // cout << N << enld;
            cnt++;
        }
        cout << cnt << enld;
    }
    return 0;
}


Measured memory_bytes: 3316
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>

using namespace std;

int main()
{
    int N;
    scanf("%d\n", &N);
    const int NN = N * N;
    vector<int> X(N);
    map<int, int> Xmap;
    vector<int> A(NN, -1);
    for (int i = 0; i < N; ++i){
        int Xi;
        scanf("%d", &Xi); --Xi; getchar();
        X[i] = Xi;
        Xmap.emplace(Xi, i);
        A[Xi] = i;
    }
    {
        int j = 0;
        for (auto& elem : Xmap){
            int Xi = elem.first;
            int i = elem.second;
            for (int k = 0; k < i; ++k){
                while (A[j] != -1){
                    if (j == Xi){
                        puts("No");
                        return 0;
                    }
                    ++j;
                }
                A[j] = i;
            }
        }
    }
    {
        int j = NN - 1;
        for (auto rit = Xmap.rbegin(), rend = Xmap.rend(); rit != rend; ++rit){
            int Xi = rit->first;
            int i = rit->second;
            for (int k = 0; k < N - 1 - i; ++k){
                while (A[j] != -1){
                    if (j == Xi){
                        puts("No");
                        return 0;
                    }
                    --j;
                }
                A[j] = i;
            }
        }
    }
    puts("Yes");
    for (int j = 0; j < NN - 1; ++j){
        printf("%d ", A[j] + 1);
    }
    printf("%d\n", A[NN - 1] + 1);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vll         vector<ll>
#define all(a)      (a).begin(),(a).end()
#define lol         1000000007
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)    cerr << #x << " = " << x << endl;
#define F             first
#define S             second
#define endl        '\n'
#define deci(n)     cout<<fixed<<setprecision(n);
const double         pi=acos(-1.0);


using namespace std;

void MOD(ll &x)
{
    if (x >= lol) x -= lol;
    if (x < 0) x += lol;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }




void solve()
{
    int n;
    cin>>n;
    int k;
    rep(i,1,n+2)
    {
        int num = i*(i-1);
        num /= 2;
        if(num==n)
        {
            k = i;
            break;
        }
        else if(num>n)
        {
            cout<<"No";
            return;
        }
    }
    vi ans[k];
    int curr=1;
    rep(i,1,k+1)
    {
        rep(j,i+1,k+1)
        {
            ans[i-1].pb(curr);
            ans[j-1].pb(curr++);
        }
    }
    cout<<"Yes"<<endl;
    cout<<k<<endl;
    rep(i,0,k)
    {
        cout<<k-1<<" ";
        rep(j,0,k-1) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
    
}



// Remove  debugs!!

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    #endif
    int t=1;
//    cin>>t; int i=1;
    while(t--){
        //cout<<"Case #"<<i++<<": ";
        solve();
            //cout<<endl;    
      }
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        String line = stdin.readLine();
        int x = Integer.parseInt(line);

        if(x>=30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 32568
N, C = map(int, input().split())

left = []
right = []
for _ in range(N):
    x, v = map(int, input().split())
    left.append([x, v])
    right.append([C - x, v])

tmp1 = max(0, left[0][1] - left[0][0])
left_value = [0, tmp1]
tmp2 = max(0, left[0][1] - 2 * left[0][0])
left_value_back = [0, tmp2]
for i in range(1, N):
    left[i][1] += left[i - 1][1]
    tmp1 = max(tmp1 ,left[i][1] - left[i][0])
    left_value.append(tmp1)
    tmp2 = max(tmp2 ,left[i][1] - 2 * left[i][0])
    left_value_back.append(tmp2)

tmp1 = max(0, right[N - 1][1] - right[N - 1][0])
right_value = [0, tmp1]
tmp2 = max(0, right[N- 1][1] - 2 * right[N - 1][0])
right_value_bakc = [0, tmp2]
for i in range(N- 2, -1, -1):
    right[i][1] += right[i + 1][1]
    tmp1 = max(tmp1, right[i][1] - right[i][0])
    right_value.append(tmp1)
    tmp2 = max(tmp2, right[i][1] - 2 * right[i][0])
    right_value_bakc.append(tmp2)

# print (left)
# print (left_value)
# print (left_value_back)
# print ()
# print (right)
# print (right_value)
# print (right_value_bakc)

ans = 0
for i in range(N + 1):
    tmp = max(left_value[i], right_value[N - i])
    tmp = max(tmp, left_value_back[i] + right_value[N - i], left_value[i] + right_value_bakc[N - i])
    ans = max(ans, tmp)

print (ans)

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

using namespace std;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    string r;
    r.push_back(a[0]-'a'+'A');
    r.push_back(b[0]-'a'+'A');
    r.push_back(c[0]-'a'+'A');
    cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    vector<vector<P>> G(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(make_pair(b, 1));
        G[b].pb(make_pair(a, 1));
    }
    
    vl dist1(n, -1);  // dist1[v] : 頂点vの頂点0からの距離
    queue<ll> Q1;
    dist1[0] = 0;
    Q1.push(0);
    while(!Q1.empty()) {
        ll v = Q1.front();
        Q1.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist1[u] != -1) {
                continue;
            }
            dist1[u] = dist1[v] + cost;
            Q1.push(u);
        }
    }

    vl dist2(n, -1);  // dist2[v] : 頂点vの頂点n-1からの距離
    queue<ll> Q2;
    dist2[n-1] = 0;
    Q2.push(n-1);
    while(!Q2.empty()) {
        ll v = Q2.front();
        Q2.pop();
        for(auto p : G[v]) {
            ll u = p.first;
            ll cost = p.second; 
            if(dist2[u] != -1) {
                continue;
            }
            dist2[u] = dist2[v] + cost;
            Q2.push(u);
        }
    }
    
    ll cntF = 0, cntS = 0;
    rep(v, n) {
        if(dist1[v] <= dist2[v]) {
            cntF++;
        }
        else {
            cntS++;
        }
    }

    if(cntF > cntS) {
        out("Fennec");
    }
    else {
        out("Snuke");
    }
    
    re0;
}

Measured memory_bytes: 9216
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        List<string> list = new List<string>();
        InitList(list, "S");
        InitList(list, "H");
        InitList(list, "C");
        InitList(list, "D");


        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++) {
            string v = Console.ReadLine();

            list.Remove(v);
        }

        for (int i = 0; i < list.Count; i++) {
            Console.WriteLine(list[i]);
        }

        return 0;
    }

    static void InitList(List<string> list, string type) {
        for (int i = 1; i <= 13; i++) {
            list.Add(type + " " + i.ToString());
        }
    }
}



Measured memory_bytes: 15864
n, s = [int(i) for i in  raw_input().split()]
weights = []
values = []

f = [float("inf") for i in xrange(100001)]
f[0] = 0

for _ in xrange(n):
    w, v = [int(i) for i in raw_input().split()]
    
    for x in range(100000-v, -1, -1):
        f[x+v] = min(f[x+v], f[x] + w)

# print f[:100]

a = max([i for i in xrange(100001) if f[i] <= s])
print a

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

def solve() :
  if A[0] != 0 :
    return -1

  for i in range(1, N) :
    if A[i] - A[i-1] >= 2:
      return -1

  ret = 0
  for i in range(1, N) :
    if A[i] == 0 :
      continue

    ret += 1
    if A[i] != A[i-1] + 1 :
      ret += A[i] - 1
  
  return ret

print(solve())

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

#define INF 1001001001
typedef long long ll;


int main(){
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> dist(n, vector<int>(n, INF));
    rep(i, n) dist[i][i] = 0;
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }

    rep(k, n)rep(i, n)rep(j, n) dist[i][j]= min(dist[i][j], dist[i][k] + dist[k][j]);

    vector<vector<int>> dist2(n, vector<int>(n, INF));
    rep(i, n)rep(j, n){
        if (dist[i][j] <= l){
            dist2[i][j] = 1;
        }
    }
    
    rep(k, n)rep(i, n)rep(j, n) dist2[i][j]= min(dist2[i][j], dist2[i][k] + dist2[k][j]);
    int q;
    cin >> q;
    rep(i, q){
        int s, t;
        cin >> s >> t;
        --s; --t;
        if (dist2[s][t] == INF){
            cout << "-1" << endl;
        } else {
            cout << dist2[s][t] - 1 << endl;
        }
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 998244353;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;


int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust\n";
	else
		cout<<"win\n";
	return 0;
	
}

Measured memory_bytes: 256
import Control.Monad

main = do
    [n, m, c] <- map read <$> words <$> getLine
    b <- map read <$> words <$> getLine
    a <- forM [1..n] $ \i -> do
        map read <$> words <$> getLine
    putStrLn $ show $ solve n m c a b

solve :: Int -> Int -> Int -> [[Int]] -> [Int] -> Int
solve n m c a b = length $ filter ((> 0) . prog) a
  where
    prog a = (sum $ map (uncurry (*)) $ zip a b) + c

Measured memory_bytes: 1020
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;


main(){
    int n=in();
    vec a;
    rep(i,n){
        a.pb(in());
    }
    int ans=INT_MAX;
    rep2(i,-100,100){
        int tmp=0;
        rep(j,n){
            tmp+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,tmp);
    }
    cout<<ans;
}

Measured memory_bytes: 256