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

typedef struct process{
  char name[256];
  int time;
} p;

int  head = 0, tail = 0, n;
p Q[max];

void enqueue(p);
p dequeue(void);

int main(){
  int i, q, temp, passage = 0;
  p dq;

  scanf("%d%d", &n, &q);

  head = 1; 
  tail = n + 1;

  for(i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].time);
  }

  while(tail != head){
    p dq = dequeue();
    if(q > dq.time)   temp = dq.time;
    else               temp = q;
    passage += temp;
    dq.time -= temp;
    if(dq.time > 0)   enqueue(dq);
    else                     printf("%s %d\n", dq.name, passage);
  }
      
  return 0;
}

void enqueue(p x){
  Q[tail] = x;
  if(tail + 1 == max)    tail = 0;
  else                           tail++;
}

p dequeue(void){
  p x = Q[head];
  if(head + 1 == max)    head = 0;
  else                              head++;
  return x;
}

Measured memory_bytes: 49748
#include <cstdio>
#include <vector>
#include <complex>
using namespace std;

#define X real()
#define Y imag()
#define EPS 1e-8
#define EQ(x, y) (abs((x)-(y)) < EPS)

typedef complex<double> Point;

struct Circle {
  Point c;
  double r;
};

int n;
Circle cs[100000];

vector<Point> CrossPointCC(Circle a, Circle b) {
  vector<Point> ret;
  double d = abs(b.c-a.c);
  double rc = (d*d + a.r*a.r - b.r*b.r) / (2*d);
  double dfr = a.r*a.r - rc*rc;
  if (EQ(dfr, 0.0)) dfr = 0.0;
  else if (dfr < 0.0) return ret;

  double rs = sqrt(dfr);

  Point sgn = (b.c-a.c) / d;
  ret.push_back(a.c + sgn * Point(rc, rs));
  if (dfr > 0.0) {
    ret.push_back(b.c + sgn * Point(rc, -rs));
  }
  return ret;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;
    
    for (int i=0; i<n; i++) {
      double x, y;
      scanf("%lf,%lf", &x, &y);
      cs[i] = {Point(x, y), 1.0};
    }

    vector<Point> candidates;
    for (int i=0; i<n; i++) {
      for (int j=i+1; j<n; j++) {
        vector<Point> ps = CrossPointCC(cs[i], cs[j]);
        candidates.insert(candidates.end(), ps.begin(), ps.end());
      }
    }

    int ans = 1;
    for (int i=0; i<candidates.size(); i++) {
      Point p = candidates[i];
      if (p.X < 0.0 || p.X > 10.0) continue;
      if (p.Y < 0.0 || p.Y > 10.0) continue;

      int cnt = 0;
      for (int i=0; i<n; i++) {
        if (abs(cs[i].c-p) < 1.0+EPS) cnt++;
      }

      ans = max(ans, cnt);
    }

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

Measured memory_bytes: 5016
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X, Y;
string S, T;

signed main(){
  vi A(3);
  rep(i,3) cin >> A[i];
  sort(all(A));
  int ans = A[2]-A[0];
  COUT(ans);
  return 0;

}

Measured memory_bytes: 3588
#include <stdio.h>

int main(){
  int a, b;  scanf("%d%d", &a, &b);
  char s[33];  scanf("%s", s);
  for(int i=0; i<a+b+1; i++){
    if((i!=a && s[i]=='-') || (i==a && s[i]!='-')){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
//code by 27.
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h>
using namespace std;
char a[3][100];
int main()
{
	long long s=1;
	int n;
	cin>>n;
	for(int i=1;i<=2;i++)
	{
		scanf("\n");
		for(int j=1;j<=n;j++)
		{
			scanf("%c",&a[i][j]);
		}
	}
	if(a[1][1]!=a[2][1])
	{
			s*=6;
		for(int i=3;i<=n;i++)
		{
			if(a[1][i-1]!=a[2][i-1])
			{
				if(a[1][i]==a[2][i])
				{
					s*=1;
					s=s%1000000007;
				}
				else
				{
					s*=3;
					s=s%1000000007;
				}
			}
			else
			{
				if(a[1][i]==a[2][i])
				{
					s*=2;
					s=s%1000000007;
				}
				else
				{
					s*=2;
					s=s%1000000007;
				}
			}
			//cout<<i<<" "<<s<<endl;
			if(a[1][i]!=a[2][i])i++;
		}
	}
	else
	{
		s*=3;
		for(int i=2;i<=n;i++)
		{
			if(a[1][i-1]!=a[2][i-1])
			{
				if(a[1][i]==a[2][i])
				{
					s*=1;
					s=s%1000000007;
				}
				else
				{
					s*=3;
					s=s%1000000007;
				}
			}
			else
			{
				if(a[1][i]==a[2][i])
				{
					s*=2;
					s=s%1000000007;
				}
				else
				{
					s*=2;
					s=s%1000000007;
				}
			}
			//cout<<i<<" "<<s<<endl;
			if(a[1][i]!=a[2][i])i++;
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

#define MAX 1000000

void makelist(int *list, int x) {
  for (int i = x; i <= MAX; i++) {
    list[i] = min(list[i], list[i-x]+1);
  }
}

int main() {
  int list1[MAX+10], list2[MAX+10], x, n;
  for (int i = 1; i <= MAX; i++) {
    list1[i] = list2[i] = INF;
  }
  for (int i = 1; ; i++) {
    x = i*(i+1)*(i+2)/6;
    if (x >= MAX) break;
    makelist(list1, x);
    if (x & 1) makelist(list2, x);
  }
  while (cin >> n, n) {
    cout << list1[n] << " " << list2[n] << el;
  }
}

Measured memory_bytes: 8972
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, a, b;
    cin >> n;
    unordered_map<int, set<int>> e;
    for(int i = 0; i < n-1; i++) {
        cin >> a >> b;
        e[a].insert(b);
        e[b].insert(a);
    }
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    auto arr_cpy = arr;
    sort(arr_cpy.begin(), arr_cpy.end());
    vector<int> ans(n+1, 0);
    int S = accumulate(arr_cpy.begin(), arr_cpy.end()-1, 0);
    vector<int> dq;
    for(auto& p: e) {
        if (p.second.size() == 1) {
            dq.push_back(p.first);
        }
    }
    int used = 0;
    while(!dq.empty()) {
        vector<int> new_dq;
        for(int node: dq) {
            int neibor = *e[node].begin();
            e.erase(node);
            ans[node] = arr_cpy[used++];
            e[neibor].erase(node);
            if (e[neibor].size() == 1) {
                new_dq.push_back(neibor);
            }
        }
        dq.swap(new_dq);
    }
    cout << S << endl;
    for(int i = 1; i <= n; i++)
        cout << ans[i] << " ";
    return 0;
}



Measured memory_bytes: 2432
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.07.07 20:59:32
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, d;
    int x[30][30];
    scanf("%d%d", &n, &d);
    rep(i, n) rep(j, d) {
        scanf("%d", &x[i][j]);
    }

    int ret = 0;
    rep(i, n) {
        rep(j, n) {
            if (j <= i)
                continue;
            int su = 0;
            rep(k, d) {
                su += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int sqs = sqrt((double)su);

            if (sqs * sqs == su) {
                ret++;
            }
        }
    }
    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ds = gets.split.map{|d| d.to_i}

sum = 0
len = ds.length

def recovery(x, y)
  return x * y
end

0.upto(len-1) do |idx|
  0.upto(len-1) do |jdx|
    next if idx == jdx
    sum += recovery(ds[idx], ds[jdx])
  end
end

puts sum / 2

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>

using namespace std;


#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
int main() {
   /* map<int,pair<int,int>> mp;
    int n,m,problem;
    string s;
    cin >>n>>m;
    for(int i=0;i<m;i++){
        cin>>problem;
        cin >> s;
        if(s=="AC")mp[problem].first=1;
        else{
            if(mp[problem].first==0) mp[problem].second++;
        }
    }
    int ACs=0,WAs=0;
    for(auto i=mp.begin();i!=mp.end();i++){
        ACs+=i->second.first;
        WAs+=i->second.second;
    }
    cout << ACs <<" "<<WAs;*/

    int a,b;
    cin >>a>>b;
    if(max(a,b)<= (16-max(a,b))) cout <<"Yay!";
    else cout <<":(";


    return 0;


}


Measured memory_bytes: 3092
from itertools import product
import copy

H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

ans = 0
for x in product([0,1], repeat=W):
    for y in product([0,1], repeat=H):
        c_cp = copy.deepcopy(C)
        #print(c_cp)
        #print(x)
        #print(y)
        for idx, i in enumerate(x):
            if i == 1:
                for n in range(H):
                    c_cp[n][idx] = "r"
        for idx, j in enumerate(y):
            if j == 1:
                for n in range(W):
                    #print(idx, n)
                    c_cp[idx][n] = "r"
        cnt = 0
        #print(c_cp)
        for s in c_cp:
            for t in s:
                if t == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9372
import sys
input=sys.stdin.readline
x,y,a,b,c=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
arr3=list(map(int,input().split()))
arr1.sort(reverse=True)
arr2.sort(reverse=True)
sum=0
for i in range(x):
    arr3.append(arr1[i])
for j in range(y):
    arr3.append(arr2[j])
arr3.sort(reverse=True)
for k in range(x+y):
    sum+=arr3[k]
print(sum)

Measured memory_bytes: 99564
f = lambda: map(int,input().split())


class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


n,m = f()
p = list(f())

u = UnionFind(n)
for _ in range(m):
    x,y = f()
    u.unite(x-1, y-1)

gnum = [set() for _ in range(n)]
pnum = [set() for _ in range(n)]
for i in range(n):
    root = u.find(i)
    gnum[root].add(i)
    pnum[root].add(p[i]-1)
ans = 0
for i in range(n):
    ans += len(gnum[i]&pnum[i])
print(ans)


Measured memory_bytes: 77916
N, K = map(int, input().split())
X = list(map(int, input().split()))

sorted_X = sorted(X, key=abs)

centers = []

if sorted_X[0] == 0:
    # 0がある場合
    centers.append(X.index(0))
else:
    for x in sorted_X:
        if x > 0:
            centers.append(X.index(x))
            break

    for x in sorted_X:
        if x < 0:
            centers.append(X.index(x))
            break


#edge_pairs = []
lefts = []
# ひだりエッジ
for center_index in centers:
    left_edge = center_index - (K - 1)
    if left_edge >= 0:
        start_left_edge_index = left_edge
        start_right_edge_index = center_index
    else:
        start_left_edge_index = 0
        start_right_edge_index = K-1

    for move in range(K):
        left_edge = start_left_edge_index + move
        right_edge = start_right_edge_index + move
        if right_edge >= N:
            break
        #edge_pairs.append((left_edge, right_edge))
        lefts.append(left_edge)
lefts = list(set(lefts))

start_left = min(lefts)
search_num = len(lefts)

pos_max = 0
neg_max = 0

propose = []
for i in range(start_left, start_left + K):
    target = X[i]
    if target > 0:
        if pos_max < target:
            pos_max = target

    if target < 0:
        if neg_max < abs(target):
            neg_max = abs(target)

propose.append(pos_max + 2 * neg_max)
propose.append(neg_max + 2 * pos_max)


for slide in range(search_num-1):
    start_left += 1
    left = start_left
    right = start_left + K - 1

    left_target = X[left]
    if left_target < 0:
        neg_max = abs(left_target)
    elif target == 0:
        neg_max = 0

    right_target = X[right]
    if right_target > 0:
        pos_max = right_target
    elif right_target == 0:
        pos_max = 0

    propose.append(pos_max + 2 * neg_max)
    propose.append(neg_max + 2 * pos_max)


print(min(propose))





Measured memory_bytes: 14600
#include <iostream>

using namespace std;

int main()
{
	int n, k;
	int h[100001];
	int dp[100001];

	cin >> n >> k;

	h[0] = 1 << 30;
	for(int i = 1; i <= n; ++i)
	{
		cin >> h[i];
	}
	
	dp[0] = dp[1] = 0;
	for(int i = 2; i <= n; ++i)
	{
		dp[i] = 1 << 30;
		for(int j = min(k, i - 1); j > 0; --j)
		{
			dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
		}
	}

	/*
	for(int i = 0; i < n; ++i)
	{
		cout << dp[i] << endl;
	}
	*/

	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(ll i=(a);i<=(b);i++)
#define repi(i,n) fori(i,0,(n)-1)
#define forr(i,a,b) for(ll i=(b);i>=(a);i--)
#define repr(i,n) forr(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(string s, string t){
    cout<<t<<s<<endl;
}

int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    solve(s, t);
    return 0;
}


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

int main()
{
    int r, c;
    int sheet[101][101]={};
    cin >> r >> c;
    for(int i=0; i<r; ++i)
    {
        for(int j=0; j<c; ++j)
        {
            cin >> sheet[i][j];
            sheet[i][c] += sheet[i][j];
            sheet[r][j] += sheet[i][j];
            sheet[r][c] += sheet[i][j];
        }
    }
    
    for(int i=0; i<=r; ++i)
    {
        for(int j=0; j<=c; ++j)
        {
            if(j) cout << " ";
            cout << sheet[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
count = 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] and l[j] != l[k] and l[i] != l[k] and l[k] < l[i] + l[j]:
                count += 1

print(count)

Measured memory_bytes: 9196
#include "bits/stdc++.h"
using namespace std;
typedef  long long ll;
const ll MAXN=1e3+100,OO=1e16;
ll dp[MAXN][(1<<12)],n,a[MAXN],m,b[(1<<12)];
ll solve(int idx,ll msk){
    if(__builtin_popcount(msk)==n)return 0;
    if(idx==m)return OO;
    ll &ret=dp[idx][msk];
    if(~ret)
        return ret;
    ret=solve(idx+1,msk);
    ret=min(ret,solve(idx+1,msk|b[idx])+a[idx]);
    return ret;
}
int main(){
ll c,x; cin>>n>>m;
 for(int i=0;i<m;i++){
  cin>>a[i]>>c;
  while(c--)
      cin>>x,x--,b[i]+=(1LL<<x);
 }
 memset(dp,-1, sizeof(dp));
 ll ans=solve(0,0);
 if(ans>=OO)cout<<-1;
 else cout<<ans;
}

Measured memory_bytes: 35584
#include <iostream>

using namespace std;

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

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int[] s = new int[100001];
        int[] e = new int[100001];
        int[][] ca = new int[c][100001];
        for (int i = 0; i < n; i++) {
            int sd = sc.nextInt();
            int ed = sc.nextInt();
            int cd = sc.nextInt()-1;
            if(ca[cd][sd] < 0){
                e[sd]--;
            }else{
                s[sd-1]++;
                ca[cd][sd]++;
            }
            if(ca[cd][ed] > 0){
                s[ed-1]--;
            }else{
                e[ed]++;
                ca[cd][ed]--;
            }
        }

        int ans = 0;
        int cnt = 0;
        for (int i = 0; i < 100001; i++) {
            cnt += s[i];
            cnt -= e[i];
            if(ans < cnt) ans = cnt;
        }
        System.out.println(ans);
        sc.close();

    }

}


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

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

    string s; cin >> s;
    stack<char> P;
    for(auto u:s){
        if(u!='B'){
            P.push(u);
        }
        else{
            if(!P.empty()) P.pop();
        }
    }
    string ans = "";
    while(!P.empty()){
        ans += P.top();
        P.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

//CHECK FOR N = 1 OR OTHER DUMB TESTS 

using namespace std;

int n, q, x, y;
ll val[200100];
vector<int> v[200100]; 
int viz[200100];

void dfs(int x, ll add) {
	ll aux = val[x];
	val[x] += add;
	viz[x] = 1;
	for (auto y : v[x])
		if (!viz[y])
			dfs(y, add + aux);
}

int main() {
	//ifstream cin("tst.in");
	//ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n >> q;
	for (int i = 1; i < n; i++) {
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	for (int i = 1; i <= q; i++) {
		cin >> x >> y;
		val[x] += y;
	}
	
	dfs(1, 0);
	
	for (int i = 1; i <= n; i++)
		cout << val[i] << ' ';
	return 0;
}

Measured memory_bytes: 20864
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll mul(ll a, ll b) {
	return (a * b) % MOD;
}

bool cmp(int a, int b) {
	return abs(a) < abs(b);
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	int less = 0, eq = 0, more = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > 0)more++;
		else if (a[i] < 0)less++;
		else eq++;
	}
	sort(a.begin(), a.end());
	ll res = 1, l = 0, r = n - 1;
	bool ok = false;
	for (int i = 0; i <= more; i++) {
		if ((k - i) % 2 == 0 && less >= (k - i))ok = true;
	}
	if (ok) {
		while (k) {
			if (k > 1) {
				if (a[l] * a[l + 1] > a[r] * a[r - 1]) {
					res = mul(res, mul(a[l], a[l + 1]));
					k -= 2;
					l += 2;
				}
				else {
					res = mul(res, a[r]);
					r--;
					k--;
				}
			}
			else {
				res = mul(res, a[r]);
				r--;
				k--;
			}
		}
		res = (res + MOD) % MOD;
		assert(res >= 0);
		cout << res;
	}
	else if (eq > 0) {
		cout << 0;
	}
	else {
		sort(a.begin(), a.end(), cmp);
		for (int i = 0; i < k; i++) {
			res = mul(res, a[i]);
		}
		cout << (res + MOD) % MOD;
	}
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int  k;
ll ans;
int main()
{

cin>>k;
for(int a=1;a<=k;a++)
   for(int b=1;b<=k;b++)
        for(int c=1;c<=k;c++)
{
ans+=__gcd(__gcd(a,b),c);	
}
cout<<ans;
return 0;

}

Measured memory_bytes: 3608
#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 k; cin >> k;
    string s; cin >> s;
    int l = s.length();
    if(k >= l){ cout << s << endl;}
    else {
        cout << s.substr(0,k) << "..." << endl;
    }
}

Measured memory_bytes: 3632
N = int(input())
a = list(map(int, input().split()))

#操作回数が奇数回で逆順、偶数回で元の順
b = []
for i in range(N-1, -1, -2):
    b.append(a[i])
if N % 2:
    s = 1
else:
    s = 0
for i in range(s, N, 2):
    b.append(a[i])

print(*b)

Measured memory_bytes: 26360
#include <stdio.h>

int main(void)
{
    int a, b, sum, n;
    while (scanf("%d %d", &a, &b) == 2) {
        n = 0;
        sum = a + b;
        while (sum) {
            n++;
            sum /= 10;
        }
        printf("%d\n", n);
    }

    return 0;
}


Measured memory_bytes: 2044
import itertools
n = int(input())
test = list(itertools.permutations([i for i in range(n)]))
data = []
for i in range(n):
    x,y = map(int,input().split())
    data.append([x,y])
total = 0
for i in test:
    for k in range(n-1):
        total += ((data[i[k]][0] - data[i[k+1]][0])**2 + (data[i[k]][1] - data[i[k+1]][1])**2 )**0.5
print(total/len(test))

Measured memory_bytes: 13880
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    string n;
    cin>>n;
    if(n[0] == '7' || n[1] == '7'|| n[2] == '7'){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cmath>
#include <regex>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ba back
#define ppb pop_back
#define eb emplace_back
#define eps 1e-6
#define vll vector<long long int>
#define sz(x) (int((x.size())))
#define all(x) (x).begin(),(x).end()
#define FAST ios_base :: sync_with_stdio (false); cin.tie (NULL)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,n) for(int i=1;i<n;i++)
using namespace std;
typedef long long int ll;
ll M=1000000007;
vll dp(2005,-1);
ll mod(ll x){
    return (x%M);
}
ll mod_minus(ll a, ll b){
    ll ans=mod(mod(a)-mod(b));
    if(ans<0) ans= mod(ans+M);
    return ans;
}
ll mod_mul(ll a,ll b){
    return mod(mod(a)*mod(b));
}
ll mod_add(ll a,ll b){
    return mod(mod(a)+mod(b));
}

ll fill(ll s){
     if(s==0)
            return 1LL;
        else if(s==1 || s==2)
            return 0LL;
        else if(s>=3 && s<=5)
            return 1LL;
        else if(dp[s]!=-1)
            return dp[s];
ll total=0;
for(int i=3;i<=s;i++){
    if(s-i>=0){  
     total= mod_add(fill(s-i),total);
    }
}   
dp[s]=total;
return dp[s];
}

void solve() {
    ll n;
    cin>>n;
   dp[0]=1; 
//    dp[1]=0;dp[2]=0;
//    dp[3]=1; dp[4]=1;dp[5]=1;
   cout<<fill(n); 
   
}
int main(){
    FAST;

solve();


}

Measured memory_bytes: 3532
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N,M;
string S;

vector<int> ans;
 
void solve(){
	//iマス目からNマスめに到達するのに必要な最小手数をdp[i]とおく
	vector<int> dp(N+1,INF_INT);
	dp[N] = 0;
	queue<int> q;
	q.push(0);
	for(int i=N-1;i>=0;i--){
		while(1){
			if(q.size()==0){
				ans = vector<int>(1,-1);
				return;
			}
			if(q.front()!=INF_INT && q.size()<=M) break;
			q.pop();
		}
		if(S[i]=='0') dp[i] = q.front()+1;
		q.push(dp[i]);
	}

	int x = 0;
	int rest = dp[0];
	while(x<N){
		rest--;
		int i=1;
		while(dp[x+i]!=rest) i++;
		ans.push_back(i);
		x += i;
	}
}
 
int main(){
    cin >> N >> M;
    cin >> S;
 
    solve();
 
    for(int i=0;i<ans.size();i++) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  bool ok = true;
  int n = s.length();
  rep(i, n) {
    if(i % 2 == 0) {
      if(s[i] == 'L') ok = false;
    } else {
      if(s[i] == 'R') ok = false;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=200010;
#define ll long long 
int n,m; ll k;
ll sa[maxn],sb[maxn];
int ans;
int main(){
    scanf("%d%d%lld",&n,&m,&k);
    for (int i=1;i<=n;++i){
        scanf("%lld",&sa[i]); sa[i]+=sa[i-1];
    }
    for (int i=1;i<=m;++i){
        scanf("%lld",&sb[i]); sb[i]+=sb[i-1];
    }
    int rem;
    for (int i=0;i<=n;++i){
        if (k-sa[i]<0) break;
        rem=upper_bound(sb+1,sb+1+m,k-sa[i])-sb-1;
        ans=max(ans,i+rem);
    }
    cout<<ans;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a>0){
        cout << "Positive" << endl;
    }else{
        if(a==0||b>=0){
            cout << "Zero" << endl;
        }else{
            if((b-a)%2==0){
                cout << "Negative" << endl;
            }else{
                cout << "Positive" << endl;
            }
        }
    }
    return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int answer = 0;
  for (int A = 1; A <= N; ++A) {
    for (int B = 1; A * B <= N; ++B) {
      if (A * B < N) answer++;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3648
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 2005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	// cases
	{
		ll n;
		cin >> n;
		vl a(n);
		unordered_map<ll, ll> pres;
		loop(i, n)	cin >> a[i] , ++pres[a[i]];
		ll ans = 0;
		loop(i, n)
		{
			bool ok = 1;
			ll temp = a[i];
			--pres[a[i]];
			FOR(j, 1, sqrt(temp))
			{
				if (temp % j == 0)
				{
					if (pres[j] > 0 || pres[temp / j] > 0)
					{
						// cout << j << " " << temp / j << END;
						ok = 0;
						break;
					}
				}
			}
			++pres[a[i]];
			if (ok)
				++ans;
		}
		cout << ans << END;
	}



	return 0;
}

Measured memory_bytes: 33232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Main main = new Main();
		main.exec();

	}

	private void exec() {

		int a;
		String s;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		sc.nextLine();
		s = sc.nextLine();
		if(a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}
		sc.close();

	}

}


Measured memory_bytes: 21844
// ABC061 B - Counting Roads
#include <stdio.h>

int main(void) {
    int N, M;
    int roads[51] = { 0 };
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        roads[a] += 1;
        roads[b] += 1;
    }
    for (int i = 1; i <= N; i++) {
        printf("%d\n", roads[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  mat a(n,vec(n-1));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n-1;j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  vec bn(n);
  set<ll> end;
  ll ans=0;
  queue<ll> q;
  for(ll i=0;i<n;i++) {
    q.push(i);
  }
  while(end.size()<n&&q.size()) {
    ans++;
    q.push(n);
    set<ll> al;
    while(1) {
      ll i=q.front();
      q.pop();
      if(i==n) break;
      if(al.count(i)) continue;
      if(end.count(i)) continue;
      ll op=a[i][bn[i]];
      if(al.count(op)) continue;
      if(a[op][bn[op]]==i) {
        al.insert(i);
        al.insert(op);
        q.push(i);
        q.push(op);
        bn[i]++;
        bn[op]++;
        if(bn[i]==n-1) {
          end.insert(i);
        }
        if(bn[op]==n-1) {
          end.insert(op);
        }
      }
    }
    if(!al.size()||ans>1000000) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

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

int main () {
    int n;
    cin >> n;
    int res = 0;
    while (n > 1) {
        if (n == 2) {
            res++;
            break;
        }
        n = (n % 3) ? (n / 3) + 1 : (n / 3);
        res++;
    }
    cout << res << endl;
}

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

string LCS(string s, string t){
    int m = s.size() ;
    int n = t.size() ;
    vector<int> temp(n+1) ;
    vector<vector<int>> dp(m+1,temp) ;
    for(int i = 1 ; i <= m ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1 ;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]) ;
        }
    } 
    string ans ;
    int i = m, j = n;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans = s[i-1] + ans ;
            i-- ; j-- ;
        }
        else if(dp[i-1][j] > dp[i][j-1]) i-- ;
        else j-- ;
    }
    return ans ;
}

int main(){
    string s,t ;
    cin >> s >> t ;
    cout << LCS(s,t) << endl ;
}

Measured memory_bytes: 35584
#! /usr/bin/env python3

def maximizeVacation(swimming, bugs, homework):
    '''
    Each of swimming, bugs, and homework represents a list of values for that activity on day i of the list.
    Return the maximum value possible such that an activity cannot be performed consecutively.
    '''
    n = len(swimming) 
    '''
    justSwam =      [0] * n
    justBugged =    [0] * n
    justDidHw =     [0] * n

    justSwam[0] = swimming[0]
    justBugged[0] = bugs[0]
    justDidHw[0] = homework[0]
    '''
    justSwam = swimming[0]
    justBugged = bugs[0]
    justDidHw = homework[0]

    for i in range(1, n):
        tmpSwam, tmpBugged, tmpHw = justSwam, justBugged, justDidHw
        justSwam = max(tmpBugged, tmpHw) + swimming[i]
        justBugged = max(tmpSwam, tmpHw) + bugs[i]
        justDidHw = max(tmpSwam, tmpBugged) + homework[i]

        '''
        justSwam[i] = max(justBugged[i-1], justDidHw[i-1]) + swimming[i]
        justBugged[i] = max(justSwam[i-1], justDidHw[i-1]) + bugs[i]
        justDidHw[i] = max(justSwam[i-1], justBugged[i-1]) + homework[i]
        '''

        '''
        justSwam[i] = max(justBugged[i-1], justDidHw[i-1]) + justSwam[i-1] 
        justBugged[i] = max(justSwam[i-1], justDidHw[i-1]) + justBugged[i-1]
        justDidHw[i] = max(justSwam[i-1], justBugged[i-1]) + justDidHw[i-1]
        '''

    return max(justSwam, justBugged, justDidHw)

def main():
    '''
    print("Vacation dynamic programming problem")
    print(maximizeVacation([10, 20, 30], [40, 50, 60], [70, 80, 90]))
    print(maximizeVacation([100], [10], [1]))
    print(maximizeVacation([6, 8, 2, 7, 4, 2, 7], [7, 8, 5, 8, 6, 3, 5], [8, 3, 2, 6, 8, 4, 1]))
    '''
    n = int(input())

    swimming = [0] * n
    bugs = [0] * n
    homework = [0] * n

    for i in range(n):
        values = input()
        values = values.split()
        swimming[i] = int(values[0])
        bugs[i] = int(values[1])
        homework[i] = int(values[2])

    print(maximizeVacation(swimming, bugs, homework))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14892
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<pair<string, int>> sp(N);
    vector<int> v(101);

    string s;
    int p;
    for(int i = 0; i < N; i++){
        cin >> s >> p;
        sp[i] = make_pair(s, -p);
        v[p] = i + 1;
    }

    sort(sp.begin(), sp.end());

    for(int i = 0; i < N; i++){
        auto temp = sp[i];
        cout << v[-temp.second] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
    int a,b,c,x,i,j,k,ans=0;
    cin>>a>>b>>c>>x;
    for(i=0;i<=a&&500*i<=x;i++){
        for(j=0;j<=b&&100*j+500*i<=x;j++){
            for (k=0;k<=c&& 50*k+100*j+500*i<=x;k++){
                if (500*i+100*j+50*k==x){
                    ans++;}}}}
                    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	string n;	cin >> n;
	ll sum = 0;

	REP(i, n.length())	sum += n[i] - '0';

	if( sum % 9 == 0 )	cout << "Yes" << endl;
	else				cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3716
#include <stdio.h>

int main() {
  int n,i;
  int h, m;
  int deg;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d:%d", &h, &m);
    deg = h * 30 + m / 2.0 - m * 6;
    if(deg < 0) deg *= -1;
    if(deg > 180) deg = 360 - deg;
    if(deg >= 0 && deg < 30)         printf("alert\n");
    else if(deg >= 90 && deg <= 180) printf("safe\n");
    else                             printf("warning\n");
  }
  return 0;
}

Measured memory_bytes: 0
# ANSHUL GAUTAM
# IIIT-D

from math import *
from string import *
from itertools import *

N,X = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
happy = 0
for i in range(len(l)):
	if(X-l[i] == 0):
		X -= l[i]
		happy += 1
	elif(X-l[i] > 0 and i!=len(l)-1):
		X -= l[i]
		happy += 1
	else:
		break
print(happy)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans = 0;
ll mod = 1e9 + 7;
ll dp[105][4][4][4];

int main() {
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	dp[0][3][3][3]=1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					if (dp[i][j][k][l] == 0) continue;
					for (int m = 0; m < 4; m++) {
						if (m == 2 && l == 1 && k == 0) continue;
						if (m == 2 && l == 0 && k == 1) continue;
						if (m == 1 && l == 2 && k == 0) continue;
						if (m == 2 && l == 1 && j == 0) continue;
						if (m == 2 && k == 1 && j == 0) continue;
						dp[i + 1][k][l][m] += dp[i][j][k][l];
						dp[i + 1][k][l][m] %= mod;
					}
				}
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += dp[N][i][j][k];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

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

    ll ac = 0, wa = 0, tle = 0, re = 0;

    rep (i, N)
    {
        string s;
        cin >> s;

        if (s == "AC") { ++ac; }
        if (s == "WA") { ++wa; }
        if (s == "TLE") { ++tle; }
        if (s == "RE") { ++re; }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int m = scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			int i = 0;
			int ret = 0;
			while (i < s.length) {
				if (s[i] == 'O') {
					i++;
					continue;
				}
				int cnt = 0;
				i++;
				while (i + 1 < s.length && s[i] == 'O' && s[i + 1] == 'I') {
					cnt++;
					i += 2;
				}
				ret += (cnt - n + 1 < 0 ? 0 : cnt - n + 1);
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 32724
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <bitset>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <random>
#include <cassert>

using namespace std;

//#define FAST_ALLOCATOR_MEMORY 1e8
#undef LOCAL
//#include "optimization.h"

int main() {
	iostream::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	int l = 0;
	while (l < n - 2 && a[l] * 2 < a.back()) l++;
	cout << a.back() << ' ';
	if (!l) {
		cout << a[0];
	}
	else {
		if (abs(a.back() - 2 * a[l - 1]) < abs(a.back() - 2 * a[l]))
			cout << a[l - 1];
		else
			cout << a[l];
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    int N; cin>>N;
    int x[N], y[N], h[N]; REP(i,N) cin>>x[i]>>y[i]>>h[i];
    int ans[3];
    REP(cx,101) {
        REP(cy,101) {
            bool flag = true;
            int h_tmp = 0;
            int h_tmp_max = 2*INF;
            REP(i,N) {
                int dist = abs(x[i]-cx)+abs(y[i]-cy);
                if (h[i]==0) {
                    h_tmp_max = min(h_tmp_max, dist);
                    if (h_tmp>dist) {
                        flag = false;
                        break;
                    }
                } else {
                    if (h_tmp!=0 && h_tmp!=h[i]+dist) {
                        flag = false;
                        break;
                    }
                    if (h_tmp_max<h[i]+dist) {
                        flag = false;
                        break;
                    }
                    h_tmp = h[i]+dist;
                }
            }
            if (flag) {
                ans[0] = cx;
                ans[1] = cy;
                ans[2] = h_tmp;
                goto end;
            }
        }
    }
    end:
    REP(i,3) {
        cout<<ans[i]<<" ";
    }
}


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

int main() {
    int A, B, ans = -1;
    cin >> A >> B;
    for (int x = 0; x < 1010; x++) {
        if ((int)(x * 0.08) == A && (int)(x * 0.10) == B) {
            ans = x;
            break;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
map<int,int>freq,freq1;
int main(){
	//freopen("readin.txt","r",stdin);
	int n;
	scanf("%d",&n);
	while(n--){
		int a;
		scanf("%d",&a);
		freq[a]++;
	}
	scanf("%d",&n);
	while(n--){
		int a;
		scanf("%d",&a);
		freq1[a]++;
	}
	for(auto i : freq1)if(i.second > freq[i.first])return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 18944
import numpy as np
import sys

input = sys.stdin.readline

N,x = map(int,input().split())

a = list(map(int,input().split()))

a.sort()

ans = 0
for i in range(N):
    if x >= a[i]:
        x-= a[i]
        ans+=1
    else:
        print(i)
        exit()

if ans == N and x > 0:ans-=1

print(ans)



Measured memory_bytes: 21936
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<complex>
 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
 
class RmQ{
    private:
        ll *st;
        static const ll INF = 1000000000000000; 
        ll N;
        ll recursion_min(int i,int a,int b,int p,int q){//[a,b) [p,q)
            if(a <= p && q <= b)
                return st[i];
            if(b <= p || q <= a)
                return INF;
 
            return min(recursion_min(i * 2,a,b,p,(p + q) / 2),recursion_min(i * 2 + 1,a,b,(p + q) / 2,q));
        }
 
    public: 
        RmQ(int n){
            N = 1;
            while(N < n)
                N *= 2;
            st = (ll*)malloc(N * 2 * sizeof(ll));
            REP(i,N * 2)
                st[i + 1] = INF;
        }
 
        ll range_min(int a,int b){
            if(a > b)
                swap(a,b);
 
            if(a < 0)
                a = 0;
            if(b > N)
                b = N - 1;
 
            return recursion_min(1,a,b,0,N);
        }
 
        void update(ll a,int i){
            i += N;
            st[i] = a;
            i /= 2;
 
            while(i > 0){
                st[i] = min(st[i * 2],st[i * 2 + 1]);
                i /= 2;
            }
        }

        void print(){
            ll m = N;
            FOR(i,1,N * 2){
                if(__builtin_popcountll(i) == 1){
                    printf("\n");
                    m /= 2;
                    REP(j,m)
                        printf(" ");
                }
                printf("%lld ",st[i]);
            }
        }
 
        ~RmQ(){
            free(st);
        }
};
 
int main(void){
  
    ll n,q;
    scanf("%lld%lld",&n,&q);
  
    RmQ a(n);
  
    REP(i,n){
        a.update((1 << 31) - 1,i);
    }
  
    REP(i,q){
        ll com,x,y;
        scanf("%lld%lld%lld",&com,&x,&y);
  
        if(com == 0)
            a.update(y,x);
        else{
            printf("%lld\n",a.range_min(x,y + 1));
        }
    }
    return 0;
}

Measured memory_bytes: 4904
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()

N = ni()
L = [na() for i in range(N)]

L.sort(key=lambda x:x[1])
t = 0
for a,b in L:
    t+=a
    if b<t:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 90456
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX 200001
const llong mod = 1000000000 + 7;

int main()
{
  int N, K;
  scanf("%d%d", &N, &K);
  llong A[MAX];

  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }

  for (int i = 0; i < N - K; i++)
  {
    if (A[i] < A[K + i])
      printf("Yes\n");
    else
      printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 3208