akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <string.h>
int main()
{
    char s[1002];
    int i,h,len,j,n;
        scanf(" %[^\n]", s);
        n=0;
        len=strlen(s);
        for(j=0;j<len;j++){
            if(s[j] =='+'){
                n=n+1;
            }
            else if(s[j] == '-'){
                n=n-1;
            }}
        printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
#define N 100000
#define inf 1
typedef long long ll;

unsigned long long x;
ll ans=0,a=100;



int main(){
    int i;
    cin>>x;
    while(1){
        ans++;
        a*=1.01;
        if(a>=x)
            break;
    }
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
from bisect import bisect_left


n, m = map(int, input().split())
a = list( map(int, input().split()))
a.sort()

bc = [tuple(map(int,input().split())) for i in range(m)]
bc = sorted(bc, reverse=True, key=lambda x: x[1])

i = 0
for b, c in bc:
    for _ in range(b):
        if c <= a[i]: break
        a[i] = c
        i += 1
        if i >= n :break
    else:
        continue
    break

print(sum(a))

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

int n;
int a[100];

int main()
{
	cin >> n;
	int key = 1234567890;
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int c = -100; c <= 100; ++c)
	{
		int cost = 0;
		for (int i = 0; i < n; ++i)
		{
			cost += (a[i] - c) * (a[i] - c);
		}
		if (key > cost)
		{
			key = cost;
		}
	}
	cout << key << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int X;
    int A, B;
    cin >> X;
    if (X == 1)
    {
        cout << "Hello World" << endl;
        return 0;
    }else
    {
        cin >> A >> B;
        cout << A + B << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long a, b;

	std::cin >> a >> b;

	if (a < b) {
		for (size_t i = 0; i < b; i++)
		{
			std::cout << a;
		}
	}
	else {
		for (size_t i = 0; i < a; i++)
		{
			std::cout << b;
		}
	}

	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long n;
    scanf("%lld",&n);
    long long ans = 0;

    for (long long i = 1; i <= n; ++i)
    {
        if (i % 3 == 0 || i % 5 == 0) {
		continue;}
        else {
		ans += i;
	}
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(k);
    auto ans = (k % 2 == 0)
            ?(k / 2) * (k / 2)
            :(k / 2 + 1) * (k / 2) ;
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int arr[MAX5];
int sz[MAX5];

int root(int i){
    while(arr[i] != i) {
        i = arr[i];
    }
    return i;
}

void unionW(int A,int B){
    int root_A = root(A);
    int root_B = root(B);
    if(root_A == root_B) return;
    if(sz[root_A] < sz[root_B]) {
        arr[root_A] = arr[root_B];
        sz[root_B] += sz[root_A];
    }
    else {
        arr[root_B] = arr[root_A];
        sz[root_A] += sz[root_B];
    }
}

void solve(){
    int n, m;
    cin >> n >> m;
    memset(sz, 0, sizeof(sz));
    for(int i = 1; i <= n; i++) {
        arr[i] = i;
        sz[i] = 1;
    }
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        unionW(a, b);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, sz[i]);
        // debug(i, sz[i]);
    }
    cout << ans;
} 
signed main(){  
//   freopen("output.txt", "r", stdin);
//   freopen("tt.txt", "w", stdout);
    // flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
		if(tc != t) cout << endl;
    }
}

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

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

using namespace std;

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

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

  double res = 0;
  for (int i = 1; i <= n; ++i) {
    int multiplier = 0;
    while ((i * pow(2, multiplier)) < k) {
      multiplier++;
    }
    res += (double) 1 / n * ((double) 1 / pow(2, multiplier));
  }
  cout << fixed << setprecision(10) << res << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

x = max(A)
hurui = [x]*(x+1)
for i in range(2, x+1):
    for j in range(i, x+1, i):
        hurui[j] = min(i, hurui[j])

cnt = Counter([1])
for i in range(N):
    num = A[i]
    while num > 1:
        x = hurui[num]
        while num%x == 0:
            num //= x
        cnt[x] += 1

a = cnt.most_common(1)[0][1]
if a == 1:
    print("pairwise coprime")
elif a < N:
    print("setwise coprime")
else:
    print("not coprime")


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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{";
	for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i];
	cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n";
	for (auto& vec : arr)cout << "  " << vec << ",\n";
	cout << "}";
	return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}

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

  ll x,k,d;cin >> x >> k >> d;
  x = abs(x);

  if(k <= (x / d)){
  	cout << x - k * d << '\n';
  	return 0;
  }else{
  	ll rest = k - (x / d);
  	k = (x / d);	
  	if(rest % 2 == 0){
  		cout << x - k * d << '\n';
  	}else{
  		cout << abs(x - (k+1)*d) << '\n';
  	}
  	return 0;
  }

}


Measured memory_bytes: 3644
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    inf = 10**18
    ans = 1
    if 0 in A:
        print(0)
        exit()
    for a in A:
        ans *= a
        if ans > inf:
            print(-1)
            exit()
    print(ans)


if __name__ == '__main__':
    main()


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

#define sc(x) scanf("%d",&x);
#define rep(x ,n) for(int x=0; x<n; x++)
#define ll long long
#define finish(x) return cout << x << endl,0;
#define scarr(a,n) for(int x=0; x<n; x++)scanf("%d",&a[x]);

#define MAX_N 100005

int n;
int a[MAX_N];

int main()
{
    sc(n)
    vector <int> ans(1);
    rep(i ,n){
        sc(a[i])
        ans.back() += (i&1 ? -1 : +1)*a[i];
    }

    a[0] -= ans.back()/2 ,a[n-1] -= ans.back()/2;
    for(int i=0; i<n-1; i++){
        ans.push_back(2*a[i]);
        a[i+1] -= a[i];
    }

    for(int i : ans)
        printf("%d ",i);
    printf("\n");
}


Measured memory_bytes: 2168
cnt = int(input())

color = input()

r_c = 0
b_c = 0

for i in range(cnt):
    if color[i] == 'R':
        r_c += 1
    elif color[i] == 'B':
        b_c += 1

if r_c > b_c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;
ll fact(ll n)
{
ll    res=1;
    for(int i = 1; i <= n;i++){
    res = res * i ;
}
return res;
}



int main()
{   IOS;
    int n; cin >> n; vector<pair<ll,ll> > A; ll a;
    for (int i=0;i<n;i++)
    {
        cin >> a;
        A.push_back(make_pair(a,i));
    }
    sort(A.begin(),A.end());
    vector <ll> ans(n,0);
    for (int i=0;i<n;i++)
    {
        if (i<n/2) ans[A[i].second]=A[n/2].first; else ans[A[i].second]=A[(n-1)/2].first;
    }
    for (int i=0;i<n;i++)
    {
        cout << ans[i] << "\n";
    }



    cout.precision(30);
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

int main()
{
    ll M;
    cin >> M;
    ll cnt1 = 0;
    ll cnt2 = 0;
    rep(i, M) {
        ll d,c;
        cin >> d >> c;
        cnt1 += d*c;
        cnt2 += c;
    }
    print(cnt2-1 + (cnt1-1)/9);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265


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

    string str1 , str2 , temp;
    cin >> str1 >> str2;
    int n = str2.size();
    for (int i = 0; i < n; i++) {
        temp = str1.substr(n - i , i);
        temp += str1.substr(0 , n - i);
        //cout << temp << endl;
        if (!temp.compare(str2)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String s = sc.next();

      int[] leftBlackCnt = new int[n];
      for(int i = 0; i < s.length(); i++) {
        if(i > 0)
          leftBlackCnt[i] = leftBlackCnt[i-1];
        if(s.charAt(i) == '#')
          leftBlackCnt[i]++;
      }

      int[] rightWhiteCnt = new int[n];
      for(int i = s.length() - 1; i >= 0; i--) {
          if(i < s.length() - 1)
            rightWhiteCnt[i] = rightWhiteCnt[i+1];
          if(s.charAt(i) == '.')
            rightWhiteCnt[i]++;
      }
      int cnt = rightWhiteCnt[0];
      for(int i = 0; i < s.length() - 1; i++) {
        cnt = Math.min(cnt, leftBlackCnt[i] + rightWhiteCnt[i+1]);
      }
      cnt = Math.min(cnt, leftBlackCnt[n-1]);
      System.out.println(cnt);
  }
}

Measured memory_bytes: 28644
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

max_a = a.max
a.delete(max_a)
center = max_a / 2

min_diff = 10000000000000000000000
max_num = 0
a.each do |elem|
  diff = (elem - center).abs
  min_diff, max_num = diff, elem if diff < min_diff
end

puts "#{max_a} #{max_num}"


Measured memory_bytes: 9476
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = sum(a)
A = Counter(a)
for _ in range(int(input())):
    b, c = map(int, input().split())
    val = A[b]
    del A[b]
    A.setdefault(c, 0)
    A[c] += val
    ans = ans - b * val + c * val
    print(ans)



Measured memory_bytes: 90664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5+100;
ll a[MAXN];
int main(){
	int N;
	scanf("%d",&N);
	ll sum=0;
	for(int i=0;i<N;i++){
		scanf("%lld",a+i);
		sum+=a[i];
	}
	ll x,y;
	x=0;
	ll Min=0xffffffffff;
	for(int i=0;i<N-1;i++){
		x+=a[i];
		y=sum-x;
		Min=min(Min,abs(x-y));
	}
	printf("%lld",Min);
	return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

int n;
int c;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(i!=x) c++;
	}
	if(c<=2) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/dp/tasks/dp_t
//参考：
//https://emtubasa.hateblo.jp/entry/2019/03/16/000319

//例えば文字列<><が与えられたとき

//前から1文字目まで見たとき p1<p2 より 
//(1,2)の1通り

//前から2文字目まで見たとき p1<p2,p3<p2より
//(1,3,2),(2,3,1)の2通り

//前から3文字目まで見たとき p1<p2,p3<p2,p3<p4より
//(1,3,2,4),(1,4,2,3),(2,3,1,4),(2,4,1,3),(3,4,1,2)の5通り

//ポイント：
//できている順列の、一番最後についている数をdpのキーにしてみる

//Sのi文字目が<の時：
//新たにpi,pi+1間に大小関係が導入されても、
//p0~piの大小関係については影響を及ぼさないことに注目

//Sのi文字目が>の時：

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

int H,N;
vector<pair<int,int>> magic;

LL ans = 0;
 
void solve(){
	//体力をi削るのに必要な最小の魔力をdp[i]とする
	vector<int> dp(H+1,INF_INT);
	dp[0] = 0;
	//配るイメージのDP
	for(int i=0;i<H;i++){
		for(auto m : magic){
			int damage = m.first;
			int mp = m.second;
			int ds = min(i+damage,H);
			dp[ds] = min(dp[ds],dp[i]+mp);
		}
	}
	ans = dp[H];
}
 
int main(){
    cin >> H >> N;
    for(int i=0;i<N;i++){
    	int a,b;
    	cin >> a >> b;
    	magic.push_back(pair<int,int>(a,b));
    }
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = getLine >> solve <$> f >>= putStrLn
  where
    f = readil B.readInt <$> B.getLine

solve :: [Int] -> String
solve xs =
  let ss = sort xs in
  case find f $ zip ss $ tail ss of
   Just _ -> "NO"
   Nothing -> "YES"
  where
    f (a, b) = a == b

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


Measured memory_bytes: 31100
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
/*
struct Team {
    char t;
    int win, lose;
    bool operator < (const Team& team_) const {
        return win == team_.win ? lose > team_.lose : win < team_.win;
    }
};

Team team[11];
*/
int score[11];
int score2[11];
char team[11];
bool check[11];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n && n){
        for(int i = 0; i < n; ++i){
           // cin >> team[i].t;
            cin >> team[i];
            score[i] = 0;

            for(int j = 0; j < n - 1; ++j){
                int a;
                cin >> a;
                /*if(a == 0) ++team[i].win;
                if(a == 1) ++team[i].lose;*/
                if(a == 0) score[i] += 100;;
                if(a == 1) score[i] --;
            }
            score2[i] = score[i];
            check[i] = true;
        }

        sort(score, score + n, greater<int>());
/*
        for(int i = n - 1; i >= 0; --i){
            cout << team[i].t << endl;
        }*/
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                if(score[i] == score2[j] && check[j]){
                    cout << team[j] << endl;
                    check[j] = false;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.read();
    let mut bottom: (usize, usize) = (0, 0);
    for _i in 0..n {
        let (a, b): (usize, usize) = (sc.read(), sc.read());
        bottom = max(bottom, (a, b));
    }
    let (br, bv) = bottom;
    println!("{}", br + bv);
}

Measured memory_bytes: 4352
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
ll x,rs;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>x;
	rs=(x/500LL)*1000LL;
	x%=500LL;
	rs+=(x/5LL)*5LL;
	cout<<rs<<endl;
	return 0;
}


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

bool is_sosu(int x){
	int i;
	if(x<2) return false;
	for(i=2;i<=sqrt((float)x);i++){
		if(x%i==0) return false;
	}
	return true;
}
	


int main()
{
	int i=0,n;
	cin>>n;
	while(n!=0){
		int ans=0;
		for(i=n+1;i<=n*2;i++){
			if(is_sosu(i)==true) ans++;
		}
		cout<<ans<<endl;
		cin>>n;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using ll = long long;

int main(){
        ll n;
        scanf("%lld", &n);
        std::multiset<ll> st;
        for(ll i=0; i<n; i++){
                ll tmp;
                scanf("%lld", &tmp);
                st.insert(tmp);
        }

        ll m, ans = 1;;
        scanf("%lld", &m);
        for(ll i=0; i<m; i++){
                ll tmp;
                scanf("%lld", &tmp);
                if(st.find(tmp)==st.end()) ans = 0;
                else st.erase(st.find(tmp));
        }

        if(ans) puts("YES");
        else puts("NO");
        return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;



int main(int argc, char* argv[])
{
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int A, B, C;
  cin >> A >> B >> C;

  int res = B + C;
  if (C > (A+B))
    res = A+2*B+1;

  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
c = S.count("R")*S.count("G")*S.count("B")
# print(c)

i,j = 0,1
while 2*j < N:
    while i+2*j < N:
        # print(i,i+j,i+2*j)
        if S[i] != S[i+j] and S[i+j] != S[i+2*j] and S[i+2*j] != S[i]:
            c -= 1
        i += 1
    i = 0
    j += 1
print(c)

Measured memory_bytes: 9092
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>
#include <climits>
#include <ctime>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef double db;
#define lowbit(x) (x)&(-x)
#define gcd(a,b) __gcd(a,b)
#define sqre(x) (x)*(x)
#define mem(x,y) memset(x,y,sizeof(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
const int MaxN = 1e6 + 1005;
const int inf = 1e8;
const double PI = acos(-1.0);
const LL mod = 100000007;

priority_queue<int,vector<int> ,greater<int> > que;
vector<int> t[MaxN];

int main()
{
	int n,m,x,y;cin >> n >> m >> x >> y;
	int Min = y;
	int Max = x;
	for(int i = 1 ;i <= n;i++){
		int x ; cin >> x;
		Max = max(Max,x);
	}
	for(int i = 1; i <= m ;i++){
		int x ; cin >> x;
		Min = min(Min,x);
	}
	if(Min <= Max)cout << "War" << endl;
	else cout << "No War" << endl;
	return 0;
}

Measured memory_bytes: 23928
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let n = io.read::<usize>();
    let mut a = io.readn::<i64>(n);

    let mut q = VecDeque::new();
    for (i, &x) in a.iter().enumerate() {
        if i % 2 == 0 {
            q.push_back(x);
        } else {
            q.push_front(x);
        }
    }
    // io.debug(&q);
    // io.debug(&q[1]);
    if n % 2 != 0 {
        for &x in q.iter().rev() {
            io.writeln(x);
        }
    } else {
        for &x in q.iter() {
            io.writeln(x);
        }
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 5848
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#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 FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int dp[31];

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

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

    vector<int> A(N);
    vector<int> B(N);
    REP(i, N) cin >> A[i] >> B[i];

    REP(i, N) {
        if ((K | A[i]) == K) {
            dp[0] += B[i];
        }
        FOR(j, 1, 30) {
            if ((K & (1 << j)) == 0) continue;
            int t = K;
            t ^= 1 << j;
            t |= (1 << j) - 1;
            if ((t | A[i]) == t) {
                dp[j] += B[i];
            }
        }
    }

    int ans = 0;
    REP(j, 31) {
        ans = max(ans, dp[j]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(void) {

    string s;

    cin >> s;

    for (int i = 1; i < s.length() + 1; i++) {
        if (i % 2 == 1) {
            //output.push_back(s[i]);
            cout << s[i-1];
        }
    }
    cout << endl;

}



Measured memory_bytes: 512
a=['Wednesday','Thursday','Friday','Saturday','Sunday','Monday','Tuesday',0]
while True:
    q=map(int,raw_input().split())
    if sum(q) == 0: break
    print a[(sum([0,31,29,31,30,31,30,31,31,30,31,30,31][:q[0]])+q[1])%7]

Measured memory_bytes: 4224
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

#define mod (1000000000+7)

int main(){
	ll N,K;
	cin>>N>>K;
	vector<ll> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	vector<pair<ll,ll>> cntA(N);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(A[j]<A[i]){
				cntA[i].first++;
				if(i<j){
					cntA[i].second++;
				}
			}
		}
		//cout<<cntA[i].first<<cntA[i].second<<endl;
	}
	ll ans=0;
	for(int i=0;i<N;i++){
		ans+=(cntA[i].second*K)%mod;
		ans%=mod;
		ans+=((K*(K-1)/2)%mod)*cntA[i].first%mod;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


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

#define pb push_back
#define sz size() 
#define ll long long

ll binpow(ll a, ll b, ll mod) {
    a %= mod;
    ll res = 1ll;
    while (b>0) {
        if (b & 1)
            res = res * a % mod;
        a = a*a % mod;
        b>>= 1; 
    }
    return res;
}

int main() {
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    
    int n;
    string s;
    cin>>n;
    cin>>s;

    n = s.size();

    int i;
    int nuli = 0;
    for (i=0;i<n;i++)
    if (s[i] == '1') {
        nuli++;
    }

    int n1 = nuli - 1;
    int n2 = nuli + 1;

    ll presm1 = 0;
    ll presm2 = 0;

    int powBuck[20001];
    memset(powBuck, -1, sizeof(powBuck));

    for (i=0;i<n;i++)
    if (s[i] == '1') {
        if (n1>0) presm1 += binpow(2, n-i-1, n1);
        presm2 += binpow(2, n-i-1, n2);
    }

    if (n1>0) presm1 %= n1;
    if (n2>0) presm2 %= n2;

    for (i=0;i<n;i++) {

        int curr=0;

        if (s[i] == '1') {
            
            if (nuli == 1) {
                cout<<"0\n";
                continue;
            }
            if (n1>0) {    
                curr = presm1;
                ll kolku = binpow(2, n-i-1, n1);
                curr = (curr + n1 - kolku) % n1;   
            }
        } else {
            curr = presm2;
            ll kolku = binpow(2, n-i-1, n2);
            curr = (curr + kolku) % n2;
        }

        int br=1;
        while (curr) {
            curr = curr % __builtin_popcount(curr);
            br++;
        }
        cout<<br<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3812
#include <stdio.h>

int main(void) {

  int n, i, temp;

  scanf("%d", &n);

  for(i = 1; i <= n; i++) {
    if(i % 3 == 0) {
      printf(" %d", i);
      continue;
    }
    else {
      temp = i;
      while(temp) {
	if(temp % 10 == 3) {
	  printf(" %d", i);
	  break;
	}
	else
	  temp /= 10;
      }
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tri;

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

int r,w,h,x,y;
int g[555][555];
bool vis[555][555];

int main(){
  while(cin >> r, r){
    vector<pii> num[2];

    for(int id=0;id<2;id++){
      cin >> w >> h >> x >> y;
      x--; y--;
      for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cin >> g[i][j];
      }

      memset(vis,0,sizeof(vis));
      vis[y][x] = true;
      priority_queue<tri> q;
      q.push(tri(-g[y][x],y,x));

      int cnt = 0, val = 0;
      while(q.size()){
	num[id].push_back(pii(cnt,val));
	
	do{
	  cnt++;
	  y = get<1>(q.top()); x = get<2>(q.top());
	  val = min(val, get<0>(q.top()) );
	  q.pop();
	  
	  for(int i=0;i<4;i++){
	    int ny = y+dy[i], nx = x+dx[i];
	    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
	    if(vis[ny][nx])continue;
	    vis[ny][nx] = true;
	    q.push(tri(-g[ny][nx],ny,nx));
	  }
	}while(q.size() && get<0>(q.top()) >= val);
      }
      num[id].push_back(pii(cnt,val));
    }
    
    int ans = 1e9, rev_ite = num[1].size() - 1;
    for(int i=0;i<(int)num[0].size();i++){
      while(rev_ite>=0 && num[0][i].first + num[1][rev_ite].first >= r)rev_ite--;
      rev_ite++;
      if(num[0][i].first + num[1][rev_ite].first >= r){
	ans = min(ans, - num[0][i].second - num[1][rev_ite].second);
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INFTY) {
        continue;
      }
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INFTY) {
          continue;
        }
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int e, u, v, c;
  cin >> n >> e;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = ((i == j) ? 0 : INFTY);
    }
  }

  for (int i = 0; i < e; i++) {
    cin >> u >> v >> c;
    d[u][v] = c;
  }

  floyd();

  bool negative = false;
  for (int i = 0; i < n; i++) {
    if (d[i][i] < 0) {
      negative = true;
    }
  }

  if (negative) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j) {
          cout << " ";
        }
        if (d[i][j] == INFTY) {
          cout << "INF";
        } else {
          cout << d[i][j];
        }
      }
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3172
import java.util.*;

public class Main {

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

    int x = n * a;

    int y = Math.min(b,x);

    System.out.println(y);

  }

}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) {
  return p1.first > p2.first;
}
int main(void) {
  int n;
  cin >> n;
  vector <pair <int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end(), cmp);
  vector<ll> cnt(n, 0LL);
  int minpos = n;
  for (int i = 0; i < n - 1; i++) {
    if (a[i].second < minpos) {
      minpos = a[i].second;
    }
    if (a[i].first != a[i + 1].first) {
      cnt[minpos] += 1LL * (a[i].first - a[i + 1].first) * (i + 1);
    }
  }
  cnt[0] += 1LL * a[n - 1].first * n;
  for (int i = 0; i < n; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 2688
def push(x):
  S.append(x)

def pop():
  return int(S.pop())

list = list(input().split())
S = []

for i in range(len(list)):
  if list[i] == '+':
    a = pop()
    b = pop()
    push(a + b)
  elif list[i] == '-':
    b = pop()
    a = pop()
    push(a - b)
  elif list[i] == '*':
    a = pop()
    b = pop()
    push(a * b)
  else :
    push(list[i])

print(S.pop())



Measured memory_bytes: 5600
#include <iostream>
const int N=1e6+5;
using namespace std;
long long a[N];
void pre_done(){
	for(int i=3;i<N;i=i+3)
		a[i]=1;
	for(int i=5;i<N;i=i+5)
		a[i]=1;
}
int main(){
	pre_done();
	long long ans=0;
	int n; cin>>n;
	for(int i=1;i<=n;i++)
		if(a[i]==0) ans+=i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11432
# -*- coding: utf-8 -*-

a = int(input()) #500:10
b = int(input()) #100:2
c = int(input()) #50:1
x = int(input())

x /=50
ans_num=0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			if(i*10+j*2+k == x):
				ans_num+=1

				#print("--")
				#print(i)
				#print(j)
				#print(k)
				#print(x)

print(ans_num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  if(1!=a&&1!=b){cout << 1 << endl;}
  if(2!=a&&2!=b){cout << 2 << endl;}
  if(3!=a&&3!=b){cout << 3 << endl;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;


#define pi 3.141592653589793

vector<pair<int64_t,int64_t>> soinsuu(int64_t n){
    vector<pair<int64_t,int64_t>> ret;
    for(int64_t i=2;i*i<=n;i++){
        if(n%i !=0) continue;
        int64_t ex=0;
        while(n%i ==0){
            ex++;
            n /= i; //n変更することで、それ以降の約数で割り切れることはない
        }
        ret.push_back(make_pair(i,ex));
    }
    //nが素数だった場合
    if(n!=1) ret.push_back(make_pair(n,1));
    return ret;
}



int main(int argc,char **argv){
  int k,a,b;
  cin>>k>>a>>b;

  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }

  cout<<"NG"<<endl;
  }

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 int M;
 cin >> N >> M;
 int s[M];
 int c[M];
 int i;
 int j;
 for(i=0;i<M;i++)cin >> s[i] >> c[i];
 int ans=0;
 int flag=0;
  for(i=0;i<M;i++){
    if(((s[i]==1) && (c[i]==0)) && (N!=1)){
          flag++;
          break;
    }
 }
 for(i=0;i<M-1;i++){
     for(j=i+1;j<M;j++){
         if((s[i]==s[j]) && (c[i]!=c[j]) ){
             flag++;
             break;
         }
     }
 }
 if(flag>0)cout << "-1" << endl;
 else{
    int a;
    int b;
    for(i=0;i<M;i++){
        a=c[i];
        b=ans;
        for(j=0;j<N-s[i];j++)b/=10;
        b = (b%10);
        if(b!=a){
            for(j=0;j<N-s[i];j++)a*=10;
            ans+=a;
        }
    }
    int c=1;
    for(j=0;j<N-1;j++)c*=10;
    if(N==1&&ans==0)cout << ans << endl;
    else{
    if(c>ans)ans+=c;
 cout << ans << endl;
 }}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long a,b,c,d;

	scanf("%ld %ld %ld %ld", &a, &b, &c, &d);

	if(a * b > c * d){
		printf("%ld\n", a*b);
	}else{
		printf("%ld\n", c*d);
	}

	return 0;
}


Measured memory_bytes: 128
from collections import Counter

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

c = Counter(a)

total = 0
for i in c.items():
    x = i[1]
    total += x*(x-1)//2

for i in a:
    ans = total
    ans -= (c[i] - 1)
    print(ans)


Measured memory_bytes: 26780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;

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


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<map>
#include<iostream>
#include<stack>
#define fi(a,b)for(int i=a;i<=b;i++)
#define fj(a,b)for(int j=a;j<=b;j++)
#define fk(a,b)for(int k=a;k<=b;k++)
#define XY system("pause")
#define in1(a)scanf("%d",&a)
#define out1(a)cout<<a
#define in2(a,b)scanf("%d%d",&a,&b)
#define out2(a,b)cout<<a<<" "<<b
#define in3(a,b,c)scanf("%d%d%d",&a,&b,&c)
#define mem(a,b)memset(a,b,sizeof(a));
#define hang cout<<endl
#define kong cout<<" "
using namespace std;
int main(){
//int n,a[100001]={0};
//cin>>n;
//cout<< <<endl;
long long a[100001]={0};
long long n;
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
long long maxn=0,minn=0;
long long s=0;
a[0]=a[1];a[n+1]=-1;
for(int i=1;i<=n+1;i++){
    if(a[i]==a[i-1])s++;
	else {
		if(s>=4){
			maxn=minn=a[i-1];
		}
		else if(s>=2){
			minn=maxn;
			maxn=a[i-1];
		}
		s=1;
	}     	
	}
	cout<<minn*maxn;
return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
cb = []
for i in range(m):
    b, c = map(int, input().split())
    cb.append([c, b])
cb.sort(reverse=True)

now = 0
for i in range(n):
    if a[i] < cb[now][0] and cb[now][1] > 0:
        a[i] = cb[now][0]
        cb[now][1] -= 1
    if cb[now][1] == 0:
        now += 1
    if now >= len(cb):
        break
print(sum(a))

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

int main(){
    int N;cin>>N;
    int info[N],flag=0;
    rep(i,N){
        cin>>info[i];
        if(info[i]==1)flag=1;
    }
    if(!flag){
        cout<<-1<<endl;
        return 0;
    }
    int k=1;
    rep(i,N)if(info[i]==k)k++;
    cout<<N-k+1<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#include <atcoder/all>
using namespace atcoder;

struct S { ll zero; ll one; ll inversion; };
S op(S x, S y) {
	return S { x.zero + y.zero, x.one + y.one, x.inversion + y.inversion + x.one * y.zero };
}
S e() { return S{ 0, 0, 0 }; }
using F = bool;
S mapping(F f, S x) {
	auto [zero, one, inversion] = x;
	ll l = zero + one;
	ll new_inversion = zero * one - inversion;
	// ll new_inv = l * (l - 1) / 2 - zero * (zero - 1) / 2 - one * (one - 1) / 2 - inversion;
	if (f) return S{ one, zero, new_inversion };
	else return x;
}
F composition(F f, F g) { return (f and !g) or (!f and g); }
F id() { return false; }

int N;

void show(lazy_segtree<S, op, e, F, mapping, composition, id> s) {
	cout << endl << "[";
	rep(i, N) {
		cout << s.get(i).one << ", ";
	}
	cout << "]" << endl;
}

int main() {
	int Q; cin >> N >> Q;
	vector<S> A(N);
	rep(i, N) {
		int A_value; cin >> A_value;
		if (A_value == 0) A[i] = S{ 1, 0, 0 };
		else if (A_value == 1) A[i] = S{ 0, 1, 0 };
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> s(A);
	// show(s);
	while (Q--) {
		int T, L, R; cin >> T >> L >> R;
		L--; R--;
		if (T == 1) s.apply(L, R + 1, true);
		else if (T == 2) cout << s.prod(L, R + 1).inversion << endl;
		// show(s);
	}
}

Measured memory_bytes: 20136
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let v: Vec<i32> = (0..n)
        .map(|_| {
            iter.next().unwrap().parse().unwrap()
        })
        .collect();
    let c: Vec<i32> = (0..n)
        .map(|_| {
            iter.next().unwrap().parse().unwrap()
        })
        .collect();
    let mut ans: i64 = 0;
    for i in 0..v.len() {
        if v[i] - c[i] > 0 {
            ans += (v[i] - c[i]) as i64;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int n,a;
int t[10];
int main(){
  while(cin>>n&&n){
    for(int i=0;i<10;i++)t[i]=0;
    for(int i=0;i<n;i++){
      cin>>a;
      t[a]++;
    }
    for(int i=0;i<10;i++){
      for(int j=0;j<t[i];j++)cout<<'*';
      if(t[i]==0)cout<<'-';
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    int N=in();
    string S;
    int a=0, b=0, c=0;
    int cnt=0;
    rep(i, N){
        cin>>S;
        rep(j, S.size()-1){
            if(S.at(j)=='A'&&S.at(j+1)=='B'){
                cnt++;
            }
        }
        if(S.at(0)=='B'&&S.at(S.size()-1)=='A'){
            c+=1;
        }
        else if(S.at(S.size()-1)=='A'){
            a+=1;
        }
        else if(S.at(0)=='B'){
            b+=1;
        }
    }
    if(a>0||b>0||c==0){
        cout<<cnt+c+min(a, b)<<endl;
    }
    else if(c>0){
        cout<<cnt+c-1<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 100100;
int N, L, Q;
int X[MAXN];

int nxt[20][MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N; 
    for (int i = 0; i < N; i++)
        cin >> X[i];
    cin >> L;
    memset(nxt, -1, sizeof(nxt));
    for (int i = 0; i < N; i++) {
        if (i == N-1) {
            nxt[0][i] = N-1;
            continue;
        }
        int low = i+1, high = N;
        while (high-low > 1) {
            int med = (high+low)/2;
            if (X[med] - X[i] <= L) low = med;
            else high = med;
        }
        nxt[0][i] = low;
    }
    for (int i = 0; i < 20-1; i++) {
        for (int j = 0; j < N; j++) {
            if (nxt[i][j] == -1) nxt[i+1][j] = -1;
            else nxt[i+1][j] = nxt[i][nxt[i][j]];
            assert(nxt[i][j] != -1);
        }
    }
    cin >> Q;
    for (int t = 0; t < Q; t++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        if (a < b) {
            int ans = 0;
            for (int i = 20-1; i >= 0; i--) {
                if (nxt[i][a] < b) {
                    a = nxt[i][a];
                    ans |= 1<<i;
                }
            }
            cout << ans+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;

int main() {
  char x, y;
  cin >> x >> y;
  if (x > y) {
    dump(">");
  }
  else if (x < y) {
    dump("<");
  }
  else {
    dump("=");
  }
  return 0;
}


Measured memory_bytes: 256