akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,K,H;
cin>>N>>K;
vector<long long> v;
for(int i=0;i<N;++i){
  cin>>H;
  v.push_back(H);
}
std::sort(v.begin(), v.end(), std::greater<long long>());

long long ans=0;
for(int i=0;i<N;++i){
  if(i<K){
    ans+=0;
  }
  else{
    ans+=v[i];
  }
}
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=4e5+500;
int n,w[N],q[N];
int main()
{
    scanf("%d",&n);int top=0;long long ans=0,s=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&w[i]);
        while(top&&w[i]<w[q[top]])s-=1ll*(q[top]-q[top-1])*w[q[top]],--top;
        q[++top]=i,s+=1ll*w[i]*(q[top]-q[top-1]);
        ans+=s;
    }
    cout<<ans<<endl;
}

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

int main() {
    string s;cin>>s;
    int n = s.size();
    int c1,c2;
    rep(i,n)if(s[i]=='A'){
        c1=i;
        break;
    }
    rep(i,n)if(s[n-1-i]=='Z'){
        c2=n-1-i;
        break;
    }
    cout<<c2-c1+1<<endl;
	return 0;
}



Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int a[200005],n,b[200005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int x=b[n/2],y=b[(n/2)+1];
	for(int i=1;i<=n;i++){
		if(a[i]<=x)printf("%d\n",y);
		else printf("%d\n",x);
	}
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


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

int main()
{
  long long n,d,a,b,z=0;
  cin>>n>>d;

  for(int i=1; i<=n; i++)
  {
      cin>>a>>b;
      if(a*a + b*b <= d*d)
        z+=1;
  }
  cout<<z<<endl;

  return 0;

}



Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

double dp[302][302][302];
int n;

double rec(int i, int j, int k) {
	if (dp[i][j][k] >= 0) return dp[i][j][k];
	if (i == 0 && j == 0 && k == 0) return 0.0;

	double res = 0.0;
	// 1枚のが減る
	if (i > 0) res += rec(i - 1, j, k) * i;
	// 2
	if (j > 0) res += rec(i + 1, j - 1, k) * j;
	if (k > 0) res += rec(i, j + 1, k - 1) * k;
	res += n;
	// 最後にまとめてかける
	res *= 1.0 / (i + j + k);
	return dp[i][j][k] = res;
}

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

	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	double ans = 1.0;

	// dp[i][j][k];=残りの皿の数が0枚の個数がi個，1枚がj，2枚がk個
	// からすべての寿司がなくなるまでの操作回数の期待値

	rep(i, n + 1) {
		rep(j, n + 1) {
			rep(k, n + 1) {
				dp[i][j][k] = -1;
			}
		}
	}
	vector<int> num(3, 0);
	rep(i, n) {
		num[a[i] - 1]++;
	}

	cout << fixed << setprecision(10) << rec(num[0],num[1],num[2]) << endl;

	return 0;
}


Measured memory_bytes: 215296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    cout << str[0] << str.length() - 2 << str[str.length() - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
count = 0


def solve(i, a, ans):
    global count
    if ans[i][0] == 0:
        count += 1
        ans[i][0] = count

    for x in range(a[i][1]):
        if ans[a[i][2 + x] - 1][0] == 0:
            solve(a[i][2 + x] - 1, a, ans)

    if ans[i][1] == 0:
        count += 1
        ans[i][1] = count


N = int(input())
a = []
for _ in range(N):
    a.append([int(x) for x in input().split()])

ans = [[0 for i in range(2)] for j in range(N)]

for i in range(N):
    if ans[i][0] == 0:
        solve(i, a, ans)

for i, x in enumerate(ans):
    print(i + 1, *x)






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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int a, b, c;
    cin>>a>>b>>c;
    int x;
    cin>>x;
    int ans=0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1)
    if(i*500+100*j+50*k==x) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n,u,v = map(int,input().split())

import sys
input = sys.stdin.readline
from collections import deque

graph = [set() for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int,input().split())
    graph[a].add(b)
    graph[b].add(a)

def bfs(graph, root):
    depth = [None] * (n+1)
    depth[0] = (-1,None)

    d = deque()
    d.append((root,0))
    max_dep = 0
    while(d):
        child,parent = d.popleft()
        depth[child] = (depth[parent][0] + 1, parent)
        if( max_dep < depth[child][0] ):
            max_dep = depth[child][0]
        for i in graph[child]:
            if i != parent:
                d.append( (i,child) )

    return depth,max_dep

depth_v,_ = bfs(graph, v)
now = list(depth_v[u])
u_depth = now[0]
limit = (u_depth+2)//2
while(now[0] > limit):
    u = now[1]
    now = depth_v[ u ]

if(len(graph[u]) == 1):
    print( depth_v[u][0]//2 )
    exit()

graph[u].discard( now[1] )
depth_new,max_dep = bfs(graph, u)
ans = limit + max_dep - 1
print(ans)

Measured memory_bytes: 75168
w, h, n = map(int, input().split())
rec = [0, 0, w, h]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        rec[0] = max(rec[0], x)
    if a == 2:
        rec[2] = min(rec[2], x)
    if a == 3:
        rec[1] = max(rec[1], y)
    if a == 4:
        rec[3] = min(rec[3], y)
print(max(0,(rec[2]-rec[0]))*max(0,(rec[3]-rec[1])))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		String s[]=new String[h];
		char c[][] = new char[h][w];
		boolean isvirtical[]=new boolean[w];
		boolean ishorizontal[]=new boolean[h];


		for(int i=0;i<h;++i){
			s[i]= sc.next();
			c[i]=s[i].toCharArray();
		}

		for (int i=0;i<h;++i){
			ishorizontal[i]=true;
			for (int j=0;j<w&&ishorizontal[i]==true;++j){
				if (c[i][j]=='#' ) ishorizontal[i] = false;
			}
		}


		for (int i=0;i<w;++i){
			isvirtical[i]=true;
			for (int j=0;j<h&&isvirtical[i]==true;++j){
				if (c[j][i]=='#' ) isvirtical[i] = false;
			}


		}
		for (int i=0;i<h;++i){
			if (ishorizontal[i]==false){
				for(int j=0;j<w;++j){
					if(isvirtical[j]==false){
						System.out.print(c[i][j]);
					}
				}
				if(i!=h)System.out.println();

			}
		}

	}
}

Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int up[2010][2010],l[2010][2010],r[2010][2010],down[2010][2010];

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    for (int i = 0; i < h; ++i) {
        int tmp = 0;
        for (int j = 0; j < w; ++j) {
            if(s[i][j] == '#') tmp = 0;
            else tmp++;
            l[i][j] = tmp;
        }
    }
    for (int i = 0; i < h; ++i) {
        int tmp = 0;
        for (int j = w-1; j >= 0; --j) {
            if(s[i][j] == '#') tmp = 0;
            else tmp++;
            r[i][j] = tmp;
        }
    }
    for (int i = 0; i < w; ++i) {
        int tmp = 0;
        for (int j = 0; j < h; ++j) {
            if(s[j][i] == '#') tmp = 0;
            else tmp++;
            up[j][i] = tmp;
        }
    }
    for (int i = 0; i < w; ++i) {
        int tmp = 0;
        for (int j = h-1; j >= 0; --j) {
            if(s[j][i] == '#') tmp = 0;
            else tmp++;
            down[j][i] = tmp;
        }
    }
    int ans = 0;
    for (int i = 0;i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans = max(ans,up[i][j]+down[i][j]+l[i][j]+r[i][j]-3);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67456
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(Math.max(c + b - a,0));
        
    } 
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, M; cin >> N >> M;
  
  int X[M]; rep(i,M) cin >> X[i];
  sort(X, X+M);
  if (N>M){
    cout << 0 << endl;
    return 0;
  }  

  int a[M];
  rep(i,M){
    if (i==0) a[0] = 0;
    else a[i] = X[i] - X[i-1];
  }
  
  sort(a,a+M,greater<int>());
  int tot = X[M-1] - X[0];
  rep(i,N-1) tot -= a[i];

  cout << tot << endl;




  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n , m ; cin >> n >> m;
    rep(i,m){
        ll a; cin >> a;
        n-=a;
    }
    if(n>=0){
        cout << n << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

vector <int> group_idx(100005, -1);
vector <bool> visited(100005, false);
vector<vector<int>> friends(100005);

int dfs(int cur, int par, int idx) {
    group_idx[cur] = idx;
    visited[cur] = true;

    int sz = 1;
    for (int ch : friends[cur]) {
        if (ch == par) continue;
        if (visited[ch]) continue;
        sz += dfs(ch, cur, idx);
    }

    return sz;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
    }

    vector<vector<int>> blocks(n);
    for (int i = 0; i < k; i++) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }

    int idx = 0;
    vector <int> sz;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            int graph_size = dfs(i, -1, idx);
            sz.push_back(graph_size);
            idx++;
        }
    }

    for (int i = 0; i < n; i++) {
        int ans = sz[group_idx[i]] - friends[i].size() - 1;
        for (int nxt : blocks[i]) {
            if (group_idx[i] == group_idx[nxt]) {
                ans--;
            }
        }
        cout << ans << ' ';
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if(N % 2 == 1) {
        cout << B[(N-1)/2] - A[(N-1)/2] + 1 << endl;
    }
    else {
        cout << (B[N/2] + B[N/2-1]) - (A[N/2] + A[N/2-1]) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

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



Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int NMAX=100*1000+1;
int permutation[NMAX],n,nbModif=0;

int main(){
	cin >> n;
	
	for(int i=1;i<=n;i++){
		cin >> permutation[i];
	}
	
	for(int i=1;i<n;i++){
		if(permutation[i]==i && permutation[i+1]==i+1){
			nbModif++;
			swap(permutation[i],permutation[i+1]);
		}
	}
	
	for(int i=1;i<=n;i++){
		if(permutation[i]==i){
			nbModif++;
		}
	}
	
	cout << nbModif << endl;
}


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

int main(){
    using namespace std;
    unsigned long H, W;
    cin >> H >> W;
    unsigned long a{0};
    for(unsigned long i = 0; i < H; ++i){
        string s;
        cin >> s;
        a += count(s.begin(), s.end(), '#');
    }
    puts(a == H + W - 1 ? "Possible" : "Impossible");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c,x,y; cin>>a>>b>>c>>x>>y; c*=2;
  cout<<min(a+b,c)*min(x,y)+(x<y? min(b,c):min(a,c))*abs(x-y);
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m;
int bl[120000];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        bl[a] ^= 1;
        bl[b] ^= 1;
    }
    for (int i = 0; i < n; ++i) {
        if (bl[i]) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}




Measured memory_bytes: 640
N=gets.to_i
A=N.times.map{gets.to_i}.sort

index = N/2
ans=0
if N == 2
    ans = A[1] - A[0]
elsif N == 3
    a = A[0] * (-2) + A[1] + A[2]
    b = A[2] * 2 - A[0] - A[1]
    ans = a > b ? a : b
elsif N % 2 == 0
    ans = A[0..index-2].inject(:+) * (-2) + A[index+1..-1].inject(:+) * 2 - A[index-1] + A[index]
else
    a = A[0..index-1].inject(:+) * (-2) + A[index+2..-1].inject(:+) * 2 + A[index] + A[index+1]
    b = A[0..index-2].inject(:+) * (-2) + A[index+1..-1].inject(:+) * 2 - A[index-1] - A[index]

    ans = a > b ? a : b
end

p ans


Measured memory_bytes: 4656
#include<stdio.h>
int main(void){
  int k,x,a=-1000000,b=1000000,i;
  scanf("%d%d",&k,&x);
  for(i=x-k+1;i<=x+k-1;i++){
    printf("%d ",i);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
import math

n = int(input())

prev = list(map(int, input().split()))
max_disA = -1
max_disB = -1
min_timeA = 10**9
min_timeB = 10**9

for _ in range(n-1):
    curr = list(map(int, input().split()))
    if prev[1] != curr[1] and prev[2] == curr[2]:
        dis = math.sqrt((prev[3] - curr[3])**2 + (prev[4] - curr[4])**2)
        if max_disA < dis and prev[2] == 0:
            max_disA = dis
            min_timeA = curr[0] - prev[0]
        elif max_disB < dis and prev[2] == 1:
            max_disB = dis
            min_timeB = curr[0] - prev[0]
        elif dis == max_disA and prev[2] == 0 and min_timeA > curr[0] - prev[0]:
            max_disA = dis
            min_timeA = curr[0] - prev[0]
        elif dis == max_disB and prev[2] == 0 and min_timeB > curr[0] - prev[0]:
            max_disB = dis
            min_timeB = curr[0] - prev[0]
    prev = curr

if max_disA == -1:
    print(-1, -1)
else:
    print(max_disA, min_timeA / 60)

if max_disB == -1:
    print(-1, -1)
else:
    print(max_disB, min_timeB / 60)


Measured memory_bytes: 5684
#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
	num = int(input())
	sum = 0
	for i in range(num):
		if not (i+1) % 3 == 0 and not (i+1) % 5 == 0:
			sum += (i+1)
	
	print (sum)

if __name__ == '__main__':
	main()


Measured memory_bytes: 9040
import sys
a=sys.stdin.readline()
res = [int(i) for i in a.split() if i.isdigit()] 
N,K = [res[i] for i in (0,1)]
S=sys.stdin.readline(N)
K-=1
if N<0 or N>50:
  print("Error")
else:
  x=S[:K]
  y=S[K].lower()
  z=S[K+1:]
  print(x+y+z)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
template<class T,class U>constexpr bool bit(const T n,const U k){return (n>>k)&1;}

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"start"<<endl;
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));



int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A,B;
    cin>>A>>B;
    if(abs(A-B)>=2) cout<<"Alice"<<endl;
    else cout<<"Brown"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[100005]; 
int main (){
	scanf ("%s",s+1);
	int n=strlen(s+1),ans=0;
	for (int i=1;i<=n/2;i++)
		if (s[i]!=s[n-i+1]) ans++;
	printf ("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int h,A[2000000];

void maxheapify(int A[],int i){
  int l,r,largest,tmp;

  l=2*i;
  r=2*i+1;

  if(l<=h && A[l]>A[i]) largest = l;
  else largest = i;

  if(r<=h && A[r]>A[largest]) largest = r;

  if(largest != i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;

    maxheapify(A,largest);
  }
}

void increkey(int A[],int i,int key){
  int tmp;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i = i/2;
  }
}

void insert(int A[],int key){
  h=h+1;
  increkey(A,h,key);
}

int extract(int A[]){
  int max;

  max=A[1];
  A[1]=A[h];
  h--;
  maxheapify(A,1);
  return max;
}

int main(){

  int key;
  char o[20];

  while(1){
    scanf("%s",o);
    if(o[2]=='d') break;

    if(o[2]=='s') {
      scanf("%d",&key);
      insert(A,key);
    }

    if(o[2]=='t') printf("%d\n",extract(A));
  }

  return 0;
}



Measured memory_bytes: 5608
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
a = [list(map(int, input().split())) for i in range(2)]

ans = 0
up_count = 0
for i in range(N):
    down_count = 0
    up_count += a[0][i]
    for j in range(i, N):
        down_count += a[1][j]
    ans = max(ans, up_count + down_count)

print(ans)

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

namespace ConsoleApp3
{
    class Program
    {

        public static int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), (x) => Convert.ToInt32(x));
        }

        public static int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }

        static void Main(string[] args)
        {
            var dic = new Dictionary<string, int>();

            var Num = ReadInt();           
            for(int i = 0; i < Num; i++)
            {
                var key = Console.ReadLine();
                if (dic.ContainsKey(key))
                    dic[key]++;
                else
                    dic[key] = 1;
            }

            Num = ReadInt();
            for (int i = 0; i < Num; i++)
            {
                var key = Console.ReadLine();
                if (dic.ContainsKey(key))
                    dic[key]--;
                else
                    dic[key] = -1;
            }

            var max =  dic.Values.Max();
            if (max < 0)
                Console.WriteLine(0);
            else
                Console.WriteLine(max);
        }
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int   a = int.Parse(Console.ReadLine());
          Console.Write(a*a);
        }
    }
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll i;
    string S;
    ll K;
    cin >> S >> K;
    for(i = 0;i < K;i++) {
        if(S[i] != '1') {
            i++;
            break;
        }
    }
    cout << S[i - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
const int MAX_N = 200005;
const ll MOD = 1e9+7;
ll A[MAX_N];
vector<P> ab;

int main()
{
	ll N,K;
	cin >> N >> K;
	ll p = 0, n = 0, z = 0;
	rep(i,N)
	{
		cin >> A[i];
		if (A[i] > 0)
		{
			ab.push_back(P(abs(A[i]),0));
			p++;
		}
		else if (A[i] < 0)
		{
			ab.push_back(P(abs(A[i]),1));
			n++;
		}
		else 
		{
			//ab.push_back(P(abs(A[i]),2));
			z++;
		}
	}
	//cout << p << " " << n << endl;
	sort(ab.begin(), ab.end());
	reverse(ab.begin(), ab.end());
	if (p+n < K)
	{
		cout << 0 << endl;
		return 0;
	}
	ll cntp = 0, cntn = 0, ans = 1;
	rep(i,K)
	{
		ans = ans * ab[i].first % MOD;
		if (ab[i].second == 1) cntn++;
	}

	if (cntn % 2 == 0)
	{
		cout << ans << endl;
		return 0;
	}
	else
	{
		if (n+p == K)
		{
			if (n+p == N) 
			{
				cout << (ans * -1 + MOD) % MOD << endl;
				return 0;
			}
			else cout << 0 << endl;
			return 0;
		}
		else
		{
			int a1 = MAX_N,a2 = MAX_N,b1 = MAX_N,b2 = MAX_N;
			bool flag1 = false, flag2 = false;
			rep(i,K)
			{
				if (ab[K-1-i].second == 0)
				{
					a1 = K-1-i;
					break;
				}
			}
			for (int i = K; i < n+p; ++i)
			{
				if (ab[i].second == 1)
				{
					a2 = i;
					break;
				}
			}
			if (a1 != MAX_N && a2 != MAX_N) flag1 = true;

			rep(i,K)
			{
				if (ab[K-1-i].second == 1)
				{
					b1 = K-1-i;
					break;
				}
			}
			for (int i = K; i < n+p; ++i)
			{
				if (ab[i].second == 0)
				{
					b2 = i;
					flag2 = true;
					break;
				}
			}
			if (b1 != MAX_N && b2 != MAX_N) flag2 = true;

			if (!flag2 && cntn == K)
			{
				if (n+p < N)
				{
					cout << 0 << endl;
					return 0;
				}
				ans = 1;
				rep(i,K)
				{
					ans = ans * ab[n+p-1-i].first % MOD;
				}
				ans = (ans * -1 + MOD) % MOD;
				cout << ans << endl;
				return 0;
			}
			//cout << flag1 << flag2 << endl;
			//cout << a1 << " " << a2 << " " << b1 << " " << b2 << " " << endl;
			int s,t;
			if (flag1 && !flag2)
			{
				s = a1; t = a2;
			}
			else if (!flag1 && flag2)
			{
				s = b1; t = b2;
			}
			else if (flag1 && flag2)
			{
				if (ab[a2].first * ab[b1].first > ab[a1].first * ab[b2].first)
				{
					s = a1; t = a2;
				}
				else
				{
					s = b1; t = b2;
				}
			}

			ans = 1;
			rep(i,K)
			{
				if (i != s)
				{
					ans = ans * ab[i].first % MOD;
				}
			}
			ans = ans * ab[t].first % MOD;
			cout << ans << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 8780
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  st t;
  ci(t);
  rev(i, sz(t)){
    if(t.at(i) == '?'){
      t.at(i) = 'D';
    }
  }
  co(t);
}

Measured memory_bytes: 3924
# d日目の満足度の増加が最大になるものを選ぶ
d=int(input())
c= list(map(int, input().split()))
D= [list(map(int, input().split())) for i in range(d)]

ans=[0]*d
# 最後にどの試験がいつ行われたか？
PL=[0]*26

for i in range(d):
    cnt=0
    cntt=-10**9
    x=1
    for k in range(len(c)):
        v=PL[:]
        cnt = D[i][k]
        v[k] = i + 1
        for j in range(len(c)):
            cnt-=(i+1-v[j])*c[j]
        if cnt>cntt:
            x=k+1
            cntt=max(cnt,cntt)
    ans[i]=x
    PL[x-1]=i


for i in range(d):
    print(ans[i])

Measured memory_bytes: 85676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll i,t,m,j,x,y,l,n,k;
    char c;
    cin>>c;
    c++;
    cout<<c;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<cmath>
#include<memory.h>
#include<algorithm>
#include<map>
#define ll long long
#define ld long double
#define maxn 310
#define For(i,j,k)  for(ll i=j;i<=k;++i)
#define FOr(i,j,k)  for(ll i=j;i>=k;--i)
const ll inf=1e9;
const ld eps=1e-7;
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; }
inline void wrote(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) wrote(x/10);   putchar(x%10+'0');  }
void writeln(ll x){ wrote(x);   puts("");   }
ll n,m,ans=1,mod=1e9+7;
int main(){
	n=read(),m=read();
	if (abs(n-m)>1)	ans=0;
	For(i,1,n)	ans=ans*i%mod;
	For(i,1,m)	ans=ans*i%mod;
	writeln(ans*((abs(n-m)^1)+1)%mod);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    char s;
    cin>>s;
    if(s=='A'){
        cout<<'T'<<endl;
    }
    else if(s=='T'){
        cout<<'A'<<endl;
    }
    else if(s=='G'){
        cout<<'C'<<endl;
    }
    else{
        cout<<'G'<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli a,b,c;
int main() {
  cin >> a >> b >> c;
  lli ans = b + min(c, a+b+1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a=list(input())
b=list(input())
c=list(input())
now="a"
while True:
    if now=="a":
        if len(a):
            now=a[0]
            del a[0]
        else:
            break
    if now=="b":
        if len(b):
            now=b[0]
            del b[0]
        else:
            break
    if now=="c":
        if len(c):
            now=c[0]
            del c[0]
        else:
            break
if now=="a":
    print("A")
if now=="b":
    print("B")
if now=="c":
    print("C")


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

int main(){
 long long a,b;

 cin >> a >> b;

   for(int i=1; i<=a; i++){
 	  if((b*i)%a == 0){
        cout << b*i << endl;
     	break;
     }
   }
  
}


Measured memory_bytes: 256
import * as fs from 'fs';

const [x, y]: number[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(Number);

const group1 : number[] =[1,3,5,7,8,10,12];
const group2 : number[] =[4,6,9,11];

if (x===2 || y===2) {
    console.log('No');
} else {

    if (group1.find(g=>g===x)&&group1.find(g=>g===y)) {
        console.log('Yes');
    } else if (group2.find(g=>g===x)&&group2.find(g=>g===y)) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

Measured memory_bytes: 7372
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(true){
     int H = scan.nextInt();
        int W = scan.nextInt();
if(H == 0 && W == 0)break;

for(int i = 0; i < H; i++){
    for(int x = 0; x < W;  x++){
       if(i == 0 || x == 0 || i == H - 1 || x == W - 1){
           System.out.print("#");
       }else{
           System.out.print(".");
       }
    }
  System.out.println();
}
System.out.println();
}
        
    }
}
    
    


Measured memory_bytes: 32588
import scala.io.Source

object Main extends App {
  val src = Source.stdin.getLines

  def shuffleCards(sx: List[String] = Nil): List[String] = {
    val originalOrder = src.next

    if (originalOrder == "-") sx
    else {
      val suffleNumber = src.next.toInt

      def shuffle(times: Int, str : String): String = {
        if (times > 0) {
          val splitCardNum = src.next.toInt
          shuffle(times - 1, str.drop(splitCardNum) + str.take(splitCardNum))
        } else str
      }

      shuffleCards(sx :+ shuffle(suffleNumber, originalOrder))
    }
  }
  shuffleCards().foreach(println)
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }


signed main() {
  int A, B, K;
  cin >> A >> B >> K;

  int count = 0;
  vi ans;
  FOR(i, 1, 101) {
    if (A % i == 0 && B % i == 0)
      ans.PB(i);
  }
  sort(ALL(ans), greater<int>());
  print(ans[K-1]);
}


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

using namespace std;

char buf[10];

void recurse(int length, int pos, int char_used) {
    if (length == pos) {
        for (int i = 0; i < length; i++) {
            cout << buf[i];
        }
        cout << endl;
        return;
    }
    for (int i = 1; i <= char_used + 1; i++) {
        buf[pos] = 'a' + i - 1;
        recurse(length, pos + 1, max(char_used, i));
    }
}

int main() {
    int n;
    cin >> n;
    recurse(n, 0, 0);
    return 0;
}

Measured memory_bytes: 1536
/*
 * C?¨??????????
 * Aizu Online Judge - No.0000 QQ
 *
 * 2017.8.26.Sat
 * @auther moniwa
 */
 
#include <stdio.h>
int main(void){
    int i,j;
    
    for(i=1; i<10; ++i){
        for(j=1; j<10; ++j){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }
    
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    while (a % 2 == 0) {
      a /= 2;
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a=[['.',',','!','?',' '],['a','b','c'],['d','e','f'],['g','h','i'],['j','k','l'],['m','n','o'],['p','q','r','s'],['t','u','v'],['w','x','y','z']]
for _ in range(int(input())):
    b=list(filter(lambda x: x!='',input().split('0')))
    for c in b:
        d=int(c[0])-1
        print(a[d][(len(c)-1)%len(a[d])],end='')
    print()

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	for(int i = 0; i < n; i++)
		cin >> p[i];

	sort(p.begin(), p.end());
	int i = 0;
	while(binary_search(p.begin(), p.end(), x+i)) {
		i++;
	}
	int j = 0;
	while(binary_search(p.begin(), p.end(), x-j)) {
		j++;
	}
	if (i < j) {
		cout << x+i << '\n';
	}
	else {
		cout << x-j << '\n';
	}
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <functional>
#include <ostream>
#include <queue>
#include <random>
#include <string>
#include <map>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

// #define DEBUG

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T>& v) {
  os << "[";
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << (i == int(v.size()) - 1 ? "" : ", ");
  }
  os << "]";

  return os;
}

template <typename T, typename U>
std::ostream& operator << (std::ostream& os, std::pair<T, U>& p) {
  os << "(" << p.first << ", " << p.second << ")";

  return os;
}

int main() {
  init();

  int n;
  std::vector<int> a;

  cin >> n;
  a.resize(n);

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  std::sort(a.begin(), a.end());

  std::pair<int, int> ans = { a[1], a[0] };

  if (n == 2) {
    cout << ans.first << " " << ans.second << endl;
    return 0;
  }

  for (int i = 1; i < n; ++i) {
    int l = 0, r = i, m1, m2;

    while (r - l > 2) {
      m1 = (2 * l + r) / 3;
      m2 = (l + 2 * r) / 3;

      int abs1 = abs(a[m1] - a[i] / 2), abs2 = abs(a[m2] - a[i] / 2);

      if (abs1 < abs2) {
        r = m2;
      }
      else {
        l = m1;
      }
    }

    int min_idx = 0, abs_ = 999999999;

    for (int j = l; j < r; ++j) {
      if (abs_ > abs(a[i] / 2 - a[j])) {
        min_idx = j;
      }
    }

    ans = { a[i], a[min_idx] };
  }

  cout << ans.first << " " << ans.second << endl;
  //cin >> n;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> IN(h);
    for (auto & in : IN) {
        cin >> in;
    }
    vector<bool> col(h, true), row(w, true);

    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            if (IN[i][j] == '#') {
                col[i] = false;
                row[j] = false;
            }
        }
    }

    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            if (!col[i] && !row[j]) {
                cout << IN[i][j];
            }
        }
        if (!col[i]) {
            cout << endl;
        }
    }
}


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
    }
    ll ans = 0ll;
    for(int a = 0; a <= min(n,k); ++a){
        for(int b = 0; b <= min(n,k); ++b){
            if(a+b > min(n, k)) break;
            priority_queue<ll, vector<ll>, greater<ll>> nq;
            ll sm = 0ll;
            rep(i, a) {
                sm += v[i];
                if(v[i] < 0) nq.push(v[i]);
            }
            rep(i, b) {
                sm += v[n-1-i];
                if(v[n-1-i] < 0) nq.push(v[n-1-i]);
            }
            int rem = k-a-b;
            while(!nq.empty() and rem--) {
                sm -= nq.top(); nq.pop();
            }
            ans = max(sm, ans);
        }
    }
    ppp(ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  ll AA = -1, BB = -1;
  FOR(i, 1, 100001) {
    if ((ll)((long double)i * 0.08) == A && (ll)((long double)i * 0.10) == B) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

const int MAX_FRAME = 10000;

int makeLinerCongRand(int a, int b, int c, int x) {
	return (a * x + b) % c;
}


int main(void) {
	int n, a, b, c, x;
	while (cin >> n >> a >> b >> c >> x, n) {
		vector<int> reel(n);
		for (int i = 0; i < n; i++) {
			cin >> reel[i];
		}
		
		int frame = 0;
		int nowReel = 0;
		while (true) {
			if (reel[nowReel] == x) {
				nowReel++;
				if (nowReel == n) {
					break;
				}
			}
			if (++frame > MAX_FRAME) {
				break;
			}
			x = makeLinerCongRand(a, b, c, x);
		}

		cout << (frame <= MAX_FRAME ? frame : -1) << endl;
	}

	return 0;
}

Measured memory_bytes: 1196