akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//------------------------------------------

//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) cin >> x
#define CO(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
//------------------------------------------

int main() {
  LL N;
  IN(N);
  CO(1110-N);
  
  return 0;
}


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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var l = new List<int>();
        for(int i=0; i<n; i++) {
            l.Add(int.Parse(input.ReadLine()));
        }

        l.Sort();

        int c = 1;
        for(int i=1; i<n; i++) {
            if (l[i] > l[i - 1]) c++;
        }

        return c;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msll = M<string, LL>;

LL factorial(int x,int m=0){
    LL a=1;
    if(m==0){REPD2(i,x,1){a*=i;}}else{REPD2(i,x,1){a=(a*i)%m;}}
    return a;
}

int main(){
    int n;
    cin>>n;
    Vs s(n);
    REP(i,n){
        cin>>s[i];
        sort(ALL(s[i]));
    }

    sort(ALL(s));

    // cout<<endl;
    // REP(i,n){
    //     cout<<s[i]<<endl;
    // }

    Msll s_num;
    REP(i,n){
        s_num[s[i]]++;
    }

    LL cnt = 0;
    for(auto m : s_num){
        // cout<<m.fi<<" : "<<m.se<<endl;
        if(m.se == 1) continue;
        cnt += m.se*(m.se-1) / 2;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define Fi first
#define Se second
signed main(){
    int n,m,ans=0;
    cin>>n>>m;
    vector<int>a;
    rep(i,n){
        int x;cin>>x;
        a.push_back(x);
    }
    vector<P>vec;
    rep(i,m){
        int b,c;
        cin>>b>>c;
        vec.push_back(make_pair(c,b));
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int cnt=0;
    vector<int>vt;
    rep(i,m){
        rep(j,vec[i].Se)vt.push_back(vec[i].Fi);
        cnt+=vec[i].Se;
        if(cnt>=n)break;
    }
    int l=vt.size();
    rep(i,l)a.push_back(vt[i]);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6128
import java.util.Scanner;


public class Main {
  public static void main(String[] args){
    Scanner sc= new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int [] tower = new int[999];
    tower[0]=1;
    for (int i=0;i<998;i++){
        
        tower[i+1]=tower[i]+i+2;
    }
    
    for (int i=0;i<998;i++){
        if(tower[i]-a>0 && tower[i+1]-b>0 && tower[i]-a == tower[i+1]-b){
            System.out.println(tower[i]-a);
            break;
        }
    }
    
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		long C[] = new long[27];
		for (int i = 1; i <= 26; i++) {
			C[i] = sc.nextLong();
		}
		long S[][] = new long[D+1][27];
		for (int i = 1; i <= D; i++) {
			for (int j = 1; j <= 26; j++) {
				S[i][j] = sc.nextLong();
			}
		}
		int T[] = new int[D+1];
		for (int i = 1; i <= D; i++) {
			T[i] = sc.nextInt();
		}

		long ans = 0;
		int d[] = new int[27];
		for (int i = 1; i <= D; i++) {
			ans += S[i][T[i]];
			for (int j = 1; j <= 26; j++) {
				if (j == T[i]) {
					d[j] = 0;
				} else {
					ans -= C[j] * ++d[j];
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 46956
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

const int INF = 1e9;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m, r;
	cin >> n >> m >> r;
	vi v(r); cin >> v;
	for (auto &i : v) i--;
	vector<vi> dist(n, vi(n, INF));
	REP(i, n) dist[i][i] = 0;
	REP(i, m)
	{
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		dist[a][b] = dist[b][a] = c;
	}
	REP(k, n)REP(i, n)REP(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
	sort(ALL(v));
	int ans = INF;
	do
	{
		int tmp = 0;
		REP(i, r - 1)
		{
			tmp += dist[v[i + 1]][v[i]];
		}
		chmin(ans, tmp);
	} while (next_permutation(ALL(v)));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
from collections import Counter
if __name__ == "__main__":
    N=int(input())
    lista=list(map(int,input().split()))
    mii=Counter(lista)
    si=set(lista)
    listb=[i for i in si]
    listb.sort()
    ans=0
    while(len(listb)>0):
        x=listb.pop()
        if mii[x]>0:
            k=1
            while k<=x:
                k*=2
            y=k-x
            if x==y:
                ans+=mii[x]//2
            elif y<x and y in si:
                m=min(mii[x],mii[y])
                ans+=m
                mii[y]-=m
            mii[x]=0
    print(ans)

Measured memory_bytes: 39988
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main(){

	long N, M; cin >> N >> M;
	string res = "IMPOSSIBLE";
	vector<vector<long>> tree(N);

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

	for (long e : tree[0]) {//経由する島のインデックス
	
		for (long f : tree[e]) if (f == N - 1) res = "POSSIBLE";
	
	}

	cout << res << endl;
}

Measured memory_bytes: 12776
N=int(input())
K=[[0 for i in range(9)] for j in range(9)]

for i in range(1,N+1):
  if int(str(i)[-1])==0:
    pass
  else:
    h=int(str(i)[0])
    t=int(str(i)[-1])
    K[h-1][t-1] += 1


ans=0
for i in range(9):
  for j in range(i+1):
    if i==j:
      ans += K[i][j]* K[j][i]
    else:
      ans += 2*K[i][j]* K[j][i]
      #print(i,j,K[i][j],K[j][i],K[i][j]*K[j][i])
      
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

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

	if (s.size() <= k) cout << s << endl;
	else {
		rep (i, k) cout << s[i];
		cout << "..." << endl;
	}

	return 0;
}

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

int main() {
  int n,m;
  string s,t;
  cin >> n >> m >> s >> t;
  ll gcd = __gcd(n,m);
  ll ans = n/gcd*m;
  rep(i,0,gcd){
    if(s[i*n/gcd] != t[i*m/gcd]){cout << -1 << endl;return 0;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N;
	cin >> N;
	cout << N / 3 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>

struct Vector {
	double x, y;
};


void Koch(Vector p1, Vector p2, int i) {
	if (i < 1)return;
	Vector s, t, u;
	s.x = (2 * p1.x + p2.x) / 3;
	s.y = (2 * p1.y + p2.y) / 3;

	u.x = (p1.x + 2 * p2.x) / 3;
	u.y = (p1.y + 2 * p2.y) / 3;

	const double root3 = sqrt(3);
	t.x = (u.x - s.x) / 2 - (u.y - s.y) * root3 / 2;
	t.x += s.x;
	t.y = (u.x - s.x) * root3 / 2 + (u.y - s.y) / 2;
	t.y += s.y;

	Koch(p1, s, i - 1);
	printf("%.8f %.8f\n", s.x, s.y);

	Koch(s, t, i - 1);
	printf("%.8f %.8f\n", t.x, t.y);

	Koch(t, u, i - 1);
	printf("%.8f %.8f\n", u.x, u.y);

	Koch(u, p2, i - 1);
}

int main() {
	int n;
	std::cin >> n;
	printf("%.8f %.8f\n", 0.0, 0.0);
	Koch({ 0,0 }, { 100,0 }, n);
	printf("%.8f %.8f\n", 100.0, 0.0);

	return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
int k;
int dis[maxn];
struct edge
{
	int v,w;
	edge(int v=0,int w=0):v(v),w(w){}
};
vector<edge>adj[maxn];
bool vis[maxn];
void bfs()
{
	queue<int>q;
	memset(dis,0x3f,sizeof(dis));
	dis[1]=1;vis[1]=true;
	q.push(1);
	int u,v,w;
	while(!q.empty())
	{
		u=q.front();
		q.pop();
		vis[u]=0;
		int sz=adj[u].size();
		for(int i=0;i<sz;i++)
		{
			v=adj[u][i].v;
			w=adj[u][i].w;
			if(dis[u]+w<dis[v])
			{
				dis[v]=dis[u]+w;
				if(!vis[v])
				{
					vis[v]=1;
					q.push(v);
				}
			}
		}
	}
}
int main()
{
	scanf("%d",&k);
	for(int i=1;i<k;i++)
	{
		adj[i].push_back(edge((i+1)%k,1));
		adj[i].push_back(edge(i*10%k,0));
	}
	bfs();
	printf("%d\n",dis[0]);
	return 0;
}

Measured memory_bytes: 6272
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line1 = reader.readLine();
		int n = Integer.parseInt(line1);//1stLine
		String line2 = reader.readLine();//2ndLine
		String[] sarray = line2.split(" ", -1);
		for(int i = 0; i < (n - 1); i++){
			System.out.print(Integer.parseInt(sarray[(n - i - 1)]) + " ");
		}
		System.out.println(Integer.parseInt(sarray[0]));
	}
}

Measured memory_bytes: 24292
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, m, xx, yy, maxx = -MOD, miny = MOD;
	cin >> n >> m >> xx >> yy;
	vector<int> x(n), y(m);
	for (int i = 0; i < n; i++){
		cin >> x[i];
		maxx = max(maxx, x[i]);
	}
	for (int i = 0; i < m; i++){
		cin >> y[i];
		miny = min(miny, y[i]);
	}

	if (max(xx, maxx) < min(yy, miny)) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b,c,d;
   cin >> a >> b >> c >>d; 
   if(abs(a-b)<=d && abs(b-c)<=d || abs(c-a)<=d)
   cout << "Yes" << endl;
   else 
   cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> t(N,0);
  int a;
  for(int i = 0; i < M * 2; i++){
  	cin >> a;
    t[a - 1] += 1;
  }
  for(int i = 0; i < N; i++){
  	cout << t[i] << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  int l = S.length();
  bool used[26] = {}; rep(i,l) used[S[i]-'a'] = true;

  string result;
  if (S=="zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }
  else if (l!=26) {
    int now = 0; while(used[now]) now++;
    result = S; result += 'a'+now;
  }
  else {
    int pos = l-1;
    bool ok = true;
    while (ok) {
      used[S[pos]-'a'] = false;
      pos--;
      if (S[pos]<S[pos+1]) ok = false;
    }
    result = S.substr(0,pos+1);
    while (used[result[pos]-'a']) result[pos]++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#coding=UTF-8
#最小公倍数の要素を増やすときみたいに、上手くいかなくなったときにk倍す
#る感じかな

N=int(input())

hihyo=[]
for idx in range(0,N,1):
    mojir=input()
    hyo=mojir.split(' ')
    hihyo.append((int(hyo[0]),int(hyo[1])))

taka=hihyo[0][0]
aoki=hihyo[0][1]

for idx in range(1,N,1):
#    print('高橋 {} 青木 {}'.format(taka,aoki))
    takahi= taka//hihyo[idx][0]  + (0 if  taka%hihyo[idx][0]==0 else 1)
    aokihi= aoki//hihyo[idx][1]  + (0 if  aoki%hihyo[idx][1]==0 else 1)
#    print('比 高橋 {} 青木 {}'.format(takahi,aokihi))

    k=max(takahi,aokihi)
    taka=k*hihyo[idx][0]
    aoki=k*hihyo[idx][1]

ans=taka+aoki
print(ans)
#テストケースが優しい


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

struct wUF{
	int n;
	vector<int>pr;
	vector<lint>df;
	wUF(){};
	wUF(int n_){
		n=n_;
		pr.resize(n,-1);
		df.resize(n,0);
	};
	int root(int x){
		if(pr[x]<0)return x;
		else{
			 int r=root(pr[x]);
			df[x]+=df[pr[x]];
			return pr[x]=r;
		}
	}
	void unify(int x,int y,lint w){
		w+=depth(x)-depth(y);
		x=root(x),y=root(y);
		if(x==y)return;
		if(size(x)<size(y)){swap(x,y);w=-w;}
		pr[x]+=pr[y];
		pr[y]=x;
		df[y]=w;
	}
	int size(int x){return -pr[root(x)];}
	bool same(int x,int y){return root(x)==root(y);}
	lint depth(int x){root(x);return df[x];}
	lint dist(int x,int y){return depth(y)-depth(x);}
};

signed main(){
	int n,q;cin>>n>>q;
	wUF wuf(n);
	while(q--){
		int c,x,y;
		lint z;
		cin>>c>>x>>y;
		if(c==0){ 
			cin>>z;
			wuf.unify(x,y,z);
		}else{
			if(!wuf.same(x,y))cout<<"?"<<endl;
			else cout<<wuf.dist(x,y)<<endl;
		}		
	}
}


Measured memory_bytes: 3816
#include<stdio.h>

int main(){
	int n,d,j;
	int i = 0;
	scanf("%d",&n);
	scanf("%d",&d);
	for(j = 1;j <= n;j = j +( 2 * d) + 1){
		i++;}
		
		printf("%d",i);
		return 0;
}

Measured memory_bytes: 128
// C - Stonens
// https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c?lang=en

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MAX 200000 + 4
ll n;
char s[MAX];

int main() {
  scanf("%lld %s", &n, s);

  ll w=0, b=0;
  for (ll i=0; i<n; i++) {
    if (s[i] == '.')
      w++;
  }

  ll ans = w+b;
  for (int i=0; i<n; i++) {
    if (s[i] == '.') {
      w--;
    }
    if (s[i] == '#') {
      b++;
    }
    ans = min(ans, w+b);
  }

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


Measured memory_bytes: 384
from collections import Counter
import random

N = int(input())
s = []
for n in range(N):
    s.append(input())

M = int(input())
T = []
for m in range(M):
    T.append(input())

# 単語数が辞書で帰ってくる
count_s = Counter(s)

for t in range(len(T)):
    if T[t] in count_s:
        count_s[T[t]] -= 1
    else:
        count_s[T[t]] = -1

count_s[str(random.random())] = 0

print(max(count_s.values()))


Measured memory_bytes: 4976
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	int N;
	cin >> N;
	vector<int> h(N);
	int cnt = 0;
	rep(i, N) cin >> h[i];

	rep(i, N) {
		while (h[i] > 0) {
			cnt++;
			rep(j, N-i) {
				if (h[i+j] > 0) h[i+j]--;
				else break;
			}
		}
/*rep(j, N) cout << h[j] << endl;*/
	}
	
	cout << cnt << endl;



	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	string a,b;
	cin>>a>>b;
	int len1=a.length();
	int len2=b.length();
	if(len1>len2)
	   cout<<"GREATER"<<endl;
	else if(len1<len2)
	   cout<<"LESS"<<endl;
	else
	{
		if(a>b)
		   cout<<"GREATER"<<endl;
		else if(a<b)
		   cout<<"LESS"<<endl;
		else
		   cout<<"EQUAL"<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
import sys
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
# L = len(S)
# T = str(input())
ans = 0
prev = S[0]
for s in S:
    if(s != prev):
        ans+=1
    prev = s
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	int r=1;
	while(r!=0){
		r=1;
	for(int i=2; i<=sqrt(n); i++){
		if(n%i==0){
			r++;
		break;
		}
	}
	if(r==1){
		cout<<n;
	r=0;
	}
	n++;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	string A,B;
	cin >> A >> B;
	if(A < B)cout << '<' << "\n";
	else if(A == B)cout << '=' << "\n";
	else cout << '>' << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, a, b; cin >> n >> a >> b;
    ll res = 0;
    ll MOD = 1000000007;
    res = modpow(2, n, MOD) - 1;
    res = mod(res,MOD);
    if (a > b) swap(a,b);
    // nCa
    ll X = 1;
    for (ll i = n; i >= n - a + 1; i--) {
        X *= i;
        X %= MOD;
    }
    ll Y = 1;
    rep(i,a) Y *= (i+1), Y %= MOD;
    Y = modpow(Y, MOD - 2, MOD);
    ll Z = X * Y % MOD;
    res -= Z;
    res = mod(res, MOD);

    // nCb 
    // Reuse X. Since b is always bigger than a, you can continue from X
    for (ll i = n - a; i >= n - b + 1; i--) {
        X *= i;
        X %= MOD;
    }
    Y = 1;
    rep(i,b) Y = Y * (i+1) % MOD;
    Y = modpow(Y, MOD - 2, MOD);
    Z = X * Y % MOD;
    res -= Z;
    res = mod(res, MOD);

    cout << res << endl;
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Scanner;
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();
		int d = sc.nextInt(); 
		
		if((Math.abs(a-b)<=d&&Math.abs(b-c)<=d)||Math.abs(a-c)<=d) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 21204
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long

using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;

const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	string a;

	cin>>a;
	reverse(all(a));
	std::vector<int> occ(2020);
	ll curr = 0;
	ll pw = 1;
	ll ans = 0;
	occ[0]=1;
	for(int i=0;i<sz(a);i++){
		curr = pw*(a[i]-'0')+curr;
		curr%=2019;
		pw*=10;
		pw%=2019;
		ans+=occ[curr];
		occ[curr]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3776
s = input()
p = input()

# 前から順に検索
searching = True
s_index = 0;
p_index = 0;

loop = False

while searching:
    # print(s_index, p_index, s[s_index : s_index + 1], p[p_index : p_index + 1])
    if s[s_index : s_index + 1] == p[p_index : p_index + 1]:
        p_index += 1
        
        if p_index >= len(p):
            searching = False
            print('Yes')
            break
        
    elif loop:
        print('No')
        break
    else:
        s_index = s_index - p_index
        p_index = 0
    
    s_index += 1
    if s_index >= len(s):
        s_index = 0;
        loop = True



Measured memory_bytes: 5560
import numpy as np


def read():
    N = int(input().strip())  # N <= 10**5
    edges = dict()
    for i in range(N-1):
        # u[i] < v[i] は保証されている
        u, v, w = list(map(int, input().strip().split()))
        if u - 1 in edges.keys():
            edges[u - 1].update({v - 1: w % 2})
        else:
            edges.update({u - 1: {v - 1: w % 2}})
        if v - 1 in edges.keys():
            edges[v - 1].update({u - 1: w % 2})
        else:
            edges.update({v - 1: {u - 1: w % 2}})
    return N, edges


def solve(N, edges):
    c = [-1] * N  # -1: unvisited, 0: white, 1: black
    stack = list()
    c[0] = 0
    stack.append(0)
    while len(stack) > 0:
        s = stack.pop()
        for t in edges[s].keys():
            if c[t] == -1:
                if edges[s][t]:
                    c[t] = 1 - c[s]
                else:
                    c[t] = c[s]
                stack.append(t)
    return c


if __name__ == '__main__':
    inputs = read()
    colors = solve(*inputs)
    for col in colors:
        print("%d" % col)


Measured memory_bytes: 59336
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main() {
	int n;cin >> n;
	set<string> st;
	for (int i =0;i<n;++i){
		string s;cin>>s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19232
import java.lang.Math.max

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var (a, b) = Pair(0, 0)
    for (i in 1..N) {
        val (Ai, Bi) = readLine()!!.split(' ').map(String::toInt)
        if (a < Ai) {
            a = Ai
            b = Bi
        }
    }
    print(a + b)
}

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

using namespace std;

void solve() {
    long long h;
    cin >> h;
    long long curhealth = h, cnt = 1, ans = 0;
    while (curhealth) {
        curhealth /= 2;
        ans += cnt;
        cnt *= 2;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n){
        cin >> x[i];
    }

    ll ans = 0; 
    rep(i, n-1){
        ans += min((x[i+1]-x[i])*a, b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    int D;
    cin >> D;

    cout << "Christmas ";
    rep (i, 25 - D)
    {
        cout << " Eve";
    }

    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define all(i) i.begin(),i.end()
#define fix(i) fixed<<setprecision((i))
#define Max( i , j ) (i)=max((i),(j))
#define Min( i , j ) (i)=min((i),(j))
#define pii pair<int,int>
using namespace std;

const long long maxn = 1e5+100;
const long long INF = 3e18+1191;
const long long mod = 1e9+7;

int32_t main()
{
  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	    
  int n,a;
  cin>>n>>a;

  n%=500;
  if(n<=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::*;
use proconio::marker::*;

pub trait MoOperator {
    type Value;
    type Query;
    type Answer;
    fn init(&mut self);
    fn insert(&mut self, v: &Self::Value);
    fn delete(&mut self, v: &Self::Value);
    fn answer(&mut self, q: Self::Query) -> Self::Answer;
    fn solve(
        &mut self,
        array: &[Self::Value],
        mut query: Vec<(usize, usize, Self::Query)>,
        answer: &mut [Self::Answer],
    ) {
        let state = self;
        let size = array.len();
        assert!(query.len() <= answer.len());
        assert!(query.iter().all(|p| p.0 < p.1 && p.1 <= size));
        if query.is_empty() {
            return;
        }
        let batch = (size as f64 / (query.len() as f64).sqrt()).ceil() as usize;
        let mut q = vec![];
        std::mem::swap(&mut q, &mut query);
        let mut query = (0..(size / batch + 1)).map(|_| vec![]).collect::<Vec<_>>();
        for (i, (l, r, op)) in q.into_iter().enumerate() {
            query[l / batch].push((r, l, i, op));
        }
        state.init();
        let mut x = 0;
        let mut y = 0;
        for (i, mut query) in query.into_iter().enumerate() {
            query.sort_unstable_by_key(|p| p.0);
            if i & 1 == 1 {
                query.reverse();
            }
            for (r, l, k, op) in query.into_iter() {
                while l < x {
                    x -= 1;
                    state.insert(&array[x]);
                }
                while y < r {
                    state.insert(&array[y]);
                    y += 1;
                }
                while x < l {
                    state.delete(&array[x]);
                    x += 1;
                }
                while r < y {
                    y -= 1;
                    state.delete(&array[y]);
                }
                answer[k] = state.answer(op);
            }
        }
    }
}

struct State {
    cnt: Vec<u32>,
    ans: usize,
}

impl MoOperator for State {
    type Value = usize;
    type Query = ();
    type Answer = usize;
    fn init(&mut self) {
        for c in self.cnt.iter_mut() {
            *c = 0;
        }
        self.ans = 0;
    }
    fn insert(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&mut self, _q: Self::Query) -> usize {
        self.ans
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ask: Vec<_> = ask.into_iter().map(|(l, r)| (l, r, ())).collect();
    let mut ans = vec![0; q];
    State {
        cnt: vec![0; n],
        ans: 0,
    }.solve(&c, ask, &mut ans);
    for a in ans {
        println!("{}", a);
    }
}


fn main() {
    run();
}


Measured memory_bytes: 41608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
#define show(x) cout<<(#x)<<" is "<<(x)<<endl

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<vector<int>> matrix;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=5e5+123;
const int M=1e6+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int cnt[5];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    for(int i=1;i<=3;i++){
        cin>>a>>b;
        cnt[a]++;
        cnt[b]++;
    }
    sort(cnt+1,cnt+5);
    if(cnt[1]==1 && cnt[2]==1 && cnt[3]==2 && cnt[4]==2){
        cout<<"YES";
    }
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
int a,b;
char op;

for(int i=0;i<20000;i++){
    
   cin >> a >> op >> b;
   
    if(op=='?'){
        break;
    }
    else if(op=='+'){
        cout<<a+b<<endl;
    }
   else if(op=='-'){
        cout<<a-b<<endl;
    }
    else if(op=='*'){
        cout<<a*b<<endl;
    }
   else if(op=='/'){
        cout<<a/b<<endl;
    }
    
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        ans += i;
    }
    cout << ans << endl;
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/

string S;

//#define int int64_t
signed main()
{
	unsigned long long dp[13] = { 0 }, dp_next[13];
 
	dp[0] = 1;
	cin >> S;
 
	for (const char& s : S) {
		for (int i = 0; i < 13; i++) dp_next[i] = 0;
 
		if (s == '?') {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 13; j++) {
					dp_next[((j * 10 + i) % 13)] += dp[j];
				}
			}
		}
		else {
			for (int i = 0; i < 13; i++) {
				dp_next[(i * 10 + s-'0') % 13] += dp[i];
			}
		}
 
		for (int i = 0; i < 13; i++) {
			dp[i] = dp_next[i] % MOD;
		}
	}
 
	cout << dp[5];	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    string s,t;
    LL count;
    cin >> s;
    cin >> t;
    count = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

using namespace std;

vector <int> d;

int main()
{
    #ifdef HOME
        freopen("input.txt", "rt", stdin);
    #endif // HOME
    int n;
    scanf("%d", &n);
    d.resize(n);
    int ans = 0;
    for (int i = 0; i < n; i++){
        scanf("%d", &d[i]);
    }
    for (int i = 0;i < n - 1; i++){
        if (d[i] == i + 1 && d[i + 1] == i + 2){
            swap(d[i], d[i + 1]);
            ans++;
        }
        else if (d[i] == i + 1){
            swap(d[i], d[i + 1]);
            ans++;
        }
    }
    if (d[n - 1] == n){
        ans++;
        swap(d[n - 2], d[n - 1]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int N;
vector<long long> A;

int main() {
  scanf("%d", &N);
  long long ai;
  long long sum = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &ai);
    sum += ai;
    A.push_back(ai);
  }
  long long snuke_nums = 0;
  vector<long long> Diffs;
  for (int i = 0; i < N - 1; ++i) {
    snuke_nums += A[i];
    long long raccoon_nums = sum - snuke_nums;
    Diffs.push_back(abs(snuke_nums - raccoon_nums));
  }
  vector<long long>::iterator iter = min_element(Diffs.begin(), Diffs.end());
  int target_index = distance(Diffs.begin(), iter);
  printf("%lld", Diffs[target_index]);
}


Measured memory_bytes: 4848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	/*
	int n;
	cin >> n;
	
	vi x(n); rep(i, n)cin >> x[i];
	//list<int> x(n);

	rep(i, n) {
		int a;
		cin >> a;
		x.push_back(a);
	}

	vi t = x;
	sort(all(t));

	sort(all(t));
	rep(i, (n / 2)) {
		cout << t[(n / 2)] << endl;
	}
	repr(i, n / 2, n) {
		cout << t[(n / 2) - 1] << endl;
	}

	
	rep(i, n) {
		auto itr = find(all(t), x[i]);
		t.erase(itr);
		cout << t[(n/2)-1] << endl;
		t.insert(itr, x[i]);
	}
	*/

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	
	int m = a[a.size() - 1];
	auto itr = find(all(a), m);
	a.erase(itr);
	int t = -INF;
	rep(i, n-1) {
		int s = min(m - a[i], a[i]);
		if (t < s) {
			t = a[i];
		}
		
	}

	cout << m << " " << t << endl;

	return 0;
}


Measured memory_bytes: 640
def main():

   N = int(input())
   seList = input()
   a_seList = []
   ans = len(seList)-1
   reW = seList.count('W')
   reE = seList.count('E')
   if seList[0] == 'W':
      reW -= 1
      a_seList.append(1+reE-reW)
   else:
      reE -= 1
      a_seList.append(-1+reE-reW)
   
   for k,i in enumerate(seList[1:]):
      if i=='W':
         reW -= 1
         a_seList.append(a_seList[k]+1)
      else :
         reE -= 1
         a_seList.append(a_seList[k]-1)
         
   
   leader = a_seList.index(min(a_seList))         
   ans=seList[:leader].count('W')+seList[leader+1:].count('E')
   print(ans)








if __name__== "__main__":
    main() 



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int 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
local io_read = io.read
local math_abs = math.abs
local H, W, D = io_read("*n", "*n", "*n")
local AH = {}
local AW = {}
for h=1,H do
  for w=1,W do
    local a = io_read("*n")
    AH[a] = h
    AW[a] = w
  end
end
local CC = {}
for i=1,H*W-D do
  CC[i] = math_abs(AH[i] - AH[i+D]) + math_abs(AW[i] - AW[i+D])
end
local CCC = {}
for i=1,D do
  CCC[i] = 0
end
for i=1,H*W-D do
  CCC[i+D] = CCC[i] + CC[i]
end

local Q = io_read("*n")
local C = {}
for q=1,Q do
  local l, r = io_read("*n", "*n")
  local cost = CCC[r] - CCC[l]
  C[q] = cost
end
print(table.concat(C, "\n"))


Measured memory_bytes: 17876
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

vector<pair<int,int>> G[100002];

int x[100002];
int cnt = 0;
void dfs(int id) {
	//繋がってるノードをぜんぶ展開
	for (pair<int, int> p : G[id]) {
		//未訪問なら
		if (x[p.first] == LL_HALFMAX) {
			x[p.first] = x[id] + p.second;
			dfs(p.first);
		}
		//訪問済みなら
		else {
			//矛盾検査
			if (x[p.first] - x[id] != p.second) cnt++;
		}
	}
}

signed main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		G[l].push_back(make_pair(r, d));
		G[r].push_back(make_pair(l, -d));
	}

	//絶対に取らない値(未訪問)でxを初期化
	for (int i = 0; i < 100002; i++) x[i] = LL_HALFMAX;

	//非連結な場合も考えて全点スタートのdfs
	for (int i = 0; i < 100002; i++) {
		if (x[i] != LL_HALFMAX) continue;
		x[i] = 0;
		dfs(i);
	}
	if (cnt == 0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

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

#include <math.h>





int main(){

	int N, D, **X, i, j, k, count=0, dis, a;	
    long long int sum = 1, result;

	scanf("%d %d", &N, &D);

	X = (int **)malloc(sizeof(int *)* N);


	for (i = 0; i<N; i++) {
		X[i] = (int *)malloc(sizeof(int)* D);
	}
	for (i = 0; i < N; i++){
		for (j = 0; j < D; j++){
			scanf("%d", &X[i][j]);
		}
	}

	for (i = 0; i < N; i++){
		for (j = i + 1; j < N; j++){
			dis = 0.0;
			for (k = 0; k < D; k++){
				dis += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			a = (int)sqrt((double)dis);
			if (a*a == dis)
				count++;
				
		}
	}

	printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int N;
	cin >> N;

	if (N < 1000) {
		printf("ABC\n");
	}
	else {
		printf("ABD\n");
	}

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
    ll n,m,j,y,i,k,x,d,c=0,z,p,q;
    cin>>n;
    ll a[n+1],b[n+1];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    ll mx=-1;
    for(i=0;i<n;i++)
    {
        if(a[i]==b[i])c++;
        else
        {
            mx=max(c,mx);
            c=0;
        }
    }
    if(max(mx,c)>=3)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;



}
int main()
{
    int T=1;
    //cin>>T;
    while(T--)solve();
    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int main(){
  int a,b,c,x,op=0;
  cin>>a>>b>>c>>x;
  for (int i=0;i<=a;i++)
  for (int j=0;j<=b;j++)
  for (int q=0;q<=c;q++)
  if (i*500+j*100+q*50==x)
  op++;
  cout<<op;
  system ("pause");
  return 0;
  }

Measured memory_bytes: 504