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

#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)

using namespace std;

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

double dp[301][301][301];

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12);
    cin.tie(nullptr);

    double N;
    cin >> N;

    int i0 = 0, j0 = 0, k0 = 0;
    forn(i, N) {
        int a;
        cin >> a;
        if (a == 1)
            i0++;
        if (a == 2)
            j0++;
        if (a == 3)
            k0++;
    }

    dp[0][0][0] = dp[i0][j0][k0] = 1;
    int total = i0 + 2 * j0 + 3 * k0;
    double wasted = 0;
    for (int s = total; s > 0; s--) {
        for (int k = 0; 3 * k <= s; k++) {
            for (int j = 0; 2 * j + 3 * k <= s; j++) {
                int i = s - 3 * k - 2 * j;
                if (i + j + k == 0 || i + j + k > N)
                    continue;
                double P  = dp[i][j][k],
                       p0 = (N - i - j - k) / N;
                wasted += P * p0 / (1 - p0);
                if (i > 0)
                    dp[i - 1][j][k]     += P * i / (i + j + k);
                if (j > 0)
                    dp[i + 1][j - 1][k] += P * j / (i + j + k);
                if (k > 0)
                    dp[i][j + 1][k - 1] += P * k / (i + j + k);
            }
        }
    }

    cout << total + wasted << endl;
}


Measured memory_bytes: 213248
input_lines = input()
items = input_lines.split()
N = int(items[0])
T = int(items[1])

input_lines = input()
items = input_lines.split()
As = [int(x) for x in items]

def my_func(N, T, As):
    buys = T // 2
    counts = 0
    val_earn = 0
    val_min = 10E10
    for val in As:
        if val < val_min:
            val_min = val
        else:
            diff = val - val_min
            if diff == val_earn:
                counts += 1
            elif diff > val_earn:
                val_earn = diff
                counts = 1
    print(counts)

my_func(N, T, As)

Measured memory_bytes: 16036
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long a=sc.nextLong();
	  String s=sc.next();
	  long b0=Long.valueOf(s.substring(0, 1)),b1=Long.valueOf(s.substring(2, 3)),b2=Long.valueOf(s.substring(3, 4));

	  long res0=a*b0,res1=a*b1;
	  res1=res1/10;
	  long m1=((a*b1)%10)*10,m2=a*b2,m3=(m1+m2)/100;
	  System.out.println(res0+res1+m3);
	  //System.out.println(m1);
  }
}



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

int main() {
    int n, a; cin >> n >> a;
    /*
    if (n-a % 500 == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    else cout << "No" << endl;
    */

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

    return 0;
}


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

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

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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int maxn = 1e5 + 5;
void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

set<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	set<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.insert(i);
	}
	return primes;
}
set<int> primeFactors(int  n)
{
	set<int> factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors.insert(2);

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors.insert(i);
			n /= i;
		}
	}
	if (n > 2)
		factors.insert(n);
	return factors;
}

int power(int x, unsigned int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;
	;
	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1; // y = y/2
		x = (x * x) % p;
	}
	return res;

}
vector<set<int> > graph(200001);
vector<bool> visited(200001, false);
int cnt = 0;
void dfs(int node)
{
	visited[node] = true;
	cnt++;
	for (auto child : graph[node])
	{
		if (!visited[child])
			dfs(child);
	}
}


// Graph------------------------------------------------------------------------


int32_t main()
{
	FIO;
	// c_p_c();
	// --------------------------------------------------
	// Never GIVE UP !!!!
	int n, m;
	cin >> n >> m;
	int u, v;
	for (int i = 0; i < m; i++)
	{
		cin >> u >> v;
		graph[u].insert(v);
		graph[v].insert(u);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (!visited[i])
		{
			dfs(i);
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 37472
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int nextInt(){int a;cin>>a;return a;}

int main(){
  int n,m,onum,count;
  char c;
  vector<pair<int,int>> mp;
  vector<int> juel;
  int robx,roby;

  while(cin>>n){
    if(!n)break;
    
    mp.resize(n);
    juel.resize(n,1);
    REP(i,n){
      mp[i].first = nextInt();
      mp[i].second = nextInt();
    }
    cin >> m;
    robx = 10;roby = 10;count = 0;
    REP(i,m){
      cin >> c >> onum;
      REP(j,onum){
	if(c=='N')roby++;
	else if(c=='S')roby--;
	else if(c=='E')robx++;
	else if(c=='W')robx--;
	REP(k,n){
	  if(robx==mp[k].first && roby==mp[k].second){
	    count += juel[k];
	    juel[k]=0;
	  }
	}
      }
    }
    if(count==n)cout << "Yes" << endl;
    else cout << "No" << endl;
    juel.clear();
    mp.clear();
  }
  
  return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int a=0,b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') a++;
  }
  int ans = max(a,b);
  for(int i=0;i<n;i++){
    if(s[i]=='R') a--;
    else b++;
    int now = max(a,b);
    ans = min(ans,now);
  }
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 3720
n = int(input())
A= 'a'
# 文字数を増やして, その各々の元に対して文字を追加する.
for _ in range(n - 1):
    A = {a + s for a in A for s in a + chr(ord(max(a)) + 1)}
    # print(A)
# 最後にsortして調整する.
#print(*A, sep = '\n')
print(*sorted(A), sep='\n')

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    string libra;
    if (a+b > c+d) libra = "Left";
    else if (a+b < c+d) libra = "Right";
    else libra = "Balanced";

    cout << libra << endl;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
ai = [0]
bi = [0]
for i in range(n):
    ai.append(ai[i] + a[i])
for i in range(m):
    bi.append(bi[i] + b[i])

ans, j = 0, m
for i in range(n + 1):
    if ai[i] > k:
        break
    while ai[i] + bi[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47512
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b, k;
	cin >> a >> b >> k;
	
	for (int i = a; i <= b; i++) {
		if (i <= a + k - 1 || i >= b - k + 1) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
<?php
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  list($s) = explode(" ", trim(fgets(STDIN)));

  if(substr($s, $a, 1) != '-'){
    echo "No";
    exit;
  }

  $A = substr($s, 0, $a);
  if(!ctype_digit($A)){
    echo "No";
    exit;
  }

  $B = substr($s, $a+1, $b);
  if(!ctype_digit($B)){
    echo "No";
    exit;
  }
  echo "Yes";


Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n), c(n, LONG_LONG_MAX);
    rep(i, n) cin >> a[i];
    ll ans = LONG_LONG_MAX;
    rep(i, n) {
        ll cost = i * x;
        rep(ii, n) {
            c[ii] = min(c[ii], a[(ii + n - i) % n]);
            cost += c[ii];
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 1e3 + 3, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

char grid[N][N];
int dp[N][N];

class HGrid1 {
public:
    void init() {
        clr(dp, 0);
    }

    void solve(istream &cin, ostream &cout) {
        init();
        int n, m;
        cin >> n >> m;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                cin >> grid[i][j];
            }
        }
        dp[1][1] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if(i == 1 && j == 1)
                    continue;
                if (grid[i][j] == '#')
                    continue;
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
        cout << dp[n][m] << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	HGrid1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5120
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b = map(int,input().split())
print(a*b)

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

int main(){
	int n;
	cin >> n;
	vector<int> vec(n);
	for(int i=0;i<n;i++){
		cin >> vec.at(i);
	}
	int ans =0;
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			ans+=vec[i]*vec[j];
		}
	}
	cout << ans << endl;
    return 0;
}
			

Measured memory_bytes: 256
/**
 *    author: yuhongtao
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
#define fi first
#define se second
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=2147483647;
const int maxn=2e5+5;
const int mod=1e9+7;//greater<ll>//小根堆 
//priority_queue<ll,vector<ll>,less<ll> > q;
//vector<int> vt[205];
//pair<int,int> p,tmp;
//map<int,int> m;
int main(){
	ios::sync_with_stdio(false);
	int n;string s;
	cin>>n>>s;
	if(s.length()>n){
		for(int i=0;i<n;i++){
			cout<<s[i];
		}
		cout<<"...\n";
	}else{
		cout<<s<<endl;
	}
	
}

Measured memory_bytes: 3656
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan =new Scanner(System.in);

int a=scan.nextInt();
int b=scan.nextInt();
int c,d;
double e;
c=a/b;
d=a%b;
e=(double)a/(double)b;
System.out.print(c+" "+d+" ");
System.out.printf("%f\n",e);
}
}

Measured memory_bytes: 26528
import numpy as np
from copy import deepcopy
from heapq import heappop, heappush
from bisect import bisect_left, bisect
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations

S = input()
T = input()

m = len(T)

for i in range(len(S) - len(T) + 1):
    c = 0

    for j in range(len(T)):
        if (S[i + j] != T[j]):
            c += 1

    m = min(c, m)

print(m)
exit()


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

using namespace std;
typedef long long int ll;
int digitcnt(int n){
	return to_string(n).length();
}

int main(){
	ll n;
	cin>>n;
	int ans=1000;
	for(ll i=1; i*i<=n; i++){
		if(n%i==0){
			ans=min(ans,max(digitcnt(i),digitcnt(n/i)));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char sh[202020];
int sum=0,i,n;
int main()
{
    scanf("%s",sh);
    n=strlen(sh);
    for(i=0;i<n;i++)
        sum=sum+sh[i];
    sum=sum-n*'0';
    if(sum%9)printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 3940
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int const INF = 1000000;
int n;
vector<ll> v;


int main(){
    cin>>n;
    rep(i,n){
        ll x;cin>>x;
        v.push_back(x);
    }
   
    set<ll> s;
    s.insert(v[0]);
    
    for(int i=1;i<n;i++){
        set<ll> ss=s;
        int ssize=s.size();
        auto itr=s.begin();
        
        
        for(int j=0;j<ssize;j++){
            ss.insert(*itr+v[i]);
            itr++;
        }
        ss.insert(v[i]);
        s=ss;
    }

   /* for(auto itr=s.begin();itr!=s.end();itr++){
        cout<<*itr<<endl;
    }*/
    
    
    
    ll ans=0;
    for(auto itr=s.begin();itr!=s.end();itr++){
        ll u=*itr;
        if(u%10!=0){
            ans=max(ans,u);
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

const int N = 1e5;

int a[N + 1];
int b[N + 1];

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	long long ans = 0;

	int left, right, t;
	left = 1, right = n, t = 0;
	while (left + 1 < right) {
		b[++t] = a[right--];
		b[++t] = a[left++];
	}
	if (left == right) b[0] =  a[right];
	else b[0] = a[right], b[++t] = a[left];
	long long ans1 = 0;
	for (int i = 0; i < n - 1; i++) ans1 += abs(b[i + 1] - b[i]);
	ans = max(ans, ans1);
	memset(b, 0, sizeof(b));
	left = 1, right = n, t = 0;
	while (left + 1 < right) {
		b[++t] = a[left++];
		b[++t] = a[right--];
	}
	if (left == right) b[0] =  a[right];
	else b[0] = a[right], b[++t] = a[left];
	long long ans2 = 0;
	for (int i = 0; i < n - 1; i++) ans2 += abs(b[i + 1] - b[i]);
	ans = max(ans, ans2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(){
    int a;cin >> a;
    string s,t;cin >> s >> t;
    string n = "";
    cin >> s >> t;
    for(int i = 0; i < a; i++){
        n = n + s.at(i);
        n = n + t.at(i);
    }
    cout << n << "\n";
}

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

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main(void) {
    int i, j;
    int n;
    int a[200000];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    qsort(a, n, sizeof(a[0]), asc);

    for (i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            printf("NO\n");
            return 0;
        }
    }

    printf("YES\n");

    return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 k;
  cin >> k;
  int32 cur = 0;
  REP(d,k+1){
    cur *= 10;
    cur += 7;
    cur %= k;
    if(cur == 0){
      ANS(d+1);
      return 0;
    }
  }
  ANS(-1);
  return 0;
}

Measured memory_bytes: 3612
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
if N % 2 == 0:
    d = int(N/2)
    print(A[0] + 2 * sum(A[1:d]))
else:
    b = int((N-1)/2)
    c = int((N-1)/2)
    print(A[0] + 2 * sum(A[1:b]) + A[c])

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

long long f(long long a, long long b)
{
	if(a > b) swap(a, b);
	long long d = b / a;
	if(b % a == 0)
		return (2*d - 1) * a;
	return d * 2 * a + f(a, b % a);
}

long long n, x;

int MAIN()
{
	cin >> n >> x;
	cout << n + f(x, n - x) << endl;
	
	return 0;
}

int main()
{
	int start = clock();
	#ifdef LOCAL_TEST
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int ret = MAIN();
	#ifdef LOCAL_TEST
		cout << "[Finished in " << clock() - start << " ms]" << endl;
	#endif
	return ret;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    matrix = []
    matrix.append([int(num) for num in input().split()])
    matrix.append([int(num) for num in input().split()])

    candies = [sum(matrix[0][:d+1]) + sum(matrix[1][d:]) for d in range(n)]
    print(max(candies))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <cstdio>
using namespace std;

#define ll long long
#define vecint vector<int>
#define listint list<int>
#define Pii pair<int, int>

#define REP(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define print(a) cout << a << endl

#define MOD 1000000007;
#define NIL -1

int main(){
  string S[3];
  rep(i,3){
    cin>>S[i];
  }
  rep(i,3){
    cout<<S[i][0];
  }
  cout<<endl;
  return 0;
}


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

using namespace std;

typedef long long int64;
typedef vector<int,int> vec;
#define read(a) scanf("%d",&a)
#define printarr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";

const int rmax = 1e5 + 10;
const int inf = INT_MAX;
set<string> myset;

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

    for(int i=0;i<s.length();i++)
    {
        for(int j=1;j<=s.length() - i and j<=5;j++)
        {
        string temp = s.substr(i,j);
        myset.insert(temp);
        }
    }

    set<string>::iterator it;

    int x = 1;

    it = myset.begin();

    while(x<k)
    {
        it++;
        x++;
    }

    cout<<*it<<endl;

    return 0;
}


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

int main() {
  int A, B, C;
  char op;
  cin >> A >> op >> B;
  if(op == '+'){
  C = A + B;
  }
  else if(op == '-'){
  C = A - B;
  }
  else if(op == '*'){
  C = A * B;
  }
  else{
  C = A / B;
  }
  cout << C << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    ll x;
    cin >> x;
    ll ans = x/500*1000 + x%500/5*5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000 * 2;
ll A[MAX_N], B[MAX_N];

int main(void){
    ll N;
    vector<pair<ll, ll>> works;

    cin >> N;

    rep(i, N){
        ll a, b;
        cin >> a >> b;
        works.push_back(make_pair(b, a));
    }

    sort(all(works));
    
    ll time = 0;
    rep(i, N){
        time += works[i].second;
        if (time > works[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

int main() {
  int N, X, i;
  cin >> N;
  i=N;
  
  while (i>0){
    X+=i%10;
    i/=10;
  }
  
  if (N%X==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>vi;
vector<ll> :: iterator vt;
ll arr[200009];
int main()
{
    ll n,t,x,y,z,j,i,k,flag =0,maxi=LONG_LONG_MIN ,mini=LONG_LONG_MAX,sum=0,c=0;
    map<ll,ll>mp;
    map<ll,ll> :: iterator mt;
    string s, ss;
    cin>>x>>y>>z;
    if(y-x<2*z)
    {
        for(i = x ;i<=y ;i++)
            cout<<i<<endl;
    }else{
    for(i = x;i<x+z ;i++)
    cout<<i<<endl;
    for(i = y-z+1 ;i<=y ;i++)
        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
int max, min;
int A, B, C;
scanf("%d %d %d", &A, &B, &C);

max = (A>B) ? A:B;
min = (A>B) ? B:A;

if ((C>min) && (C<max)) printf("Yes \n");
else printf("No \n");

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
	string s,t;
	cin >> s >> t;
	int ls=s.length(),lt=t.length();
	int min1=0x3f3f3f3f;   //无穷大 
	for(int i=0;i<=ls-lt;i++){
		int sum=0;
		for(int j=0;j<lt;j++){
			if(s[i+j]!=t[j]){
				sum++;
			}
		}
		min1=min(sum,min1);
	}
	cout << min1 << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int A;
  int S = 0;
  for (int i = 0; i < M; i++) {
    cin >> A;
    S += A;
  }
  if (N - S < 0)
    cout << -1 << endl;
  else if (N - S >= 0)
    cout << N-S << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
vector< lli > v;
vector< vector< lli > > g;
vector< bool > flg;
lli N, K;

lli ans = 1;
lli counter = 1;
queue< lli > q;

void bfs() {
  while (!q.empty()) {
    lli now = q.front();
    q.pop();
    //  cout << " " << counter << endl;

    // cout << "id " << now.id << " cost " << now.cost << "\n";
    lli tmp = K - 2;
    FORA(x, g[now]) {
      if (!flg[x]) {
        q.push(x);
        ans *= tmp;
        ans %= MOD;
        tmp--;

        flg[x] = true;
        counter++;
        if (counter == N) {
          return;
        }
      }
    }
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  v.resize(N);
  g.resize(N, vector< lli >());
  flg.assign(N, false);
  REP(i, N - 1) {
    lli p, q;
    cin >> p >> q;
    p--;
    q--;
    g[p].push_back(q);
    g[q].push_back(p);
  }

  flg[0] = true;
  ans = K;
  lli tmp = K - 1;
  FORA(v, g[0]) {
    // cout << v << endl;
    if (!flg[v]) {
      q.push(v);
      flg[v] = true;
      ans *= tmp;
      ans %= MOD;
      tmp--;
      counter++;
    }
  }
  bfs();

  cout << ans << "\n";
}

Measured memory_bytes: 8180
a,b = map(int,input().split())

n = b - a + 1


if n % 2 == 0:
  if a % 2 == 1:
    ans = a ^ (((n - 2) // 2) % 2) ^ b
  else:
    m = n // 2
    ans = (m + 1) % 2 ^ 1
else:
  nn = (n - 1) // 2
  if a % 2 == 1:
    ans = (nn % 2) ^ a
  else:
    ans = (nn % 2) ^ b
    
print(ans)

Measured memory_bytes: 3060
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    d = na()
    m = ni()
    t = na()

    d_set = set(d)
    d_cnt = collections.Counter(d)

    for ti in t:
        if ti in d_set and d_cnt[ti] > 0:
            d_cnt[ti] -= 1
        else:
            print("NO")
            exit(0)

    print("YES")


if __name__ == '__main__':
    main()


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

int N;
vector<string> s;

void solve() {
  map<string, ll> mp;
  for (int i = 0; i < N; i++) {
    sort(s[i].begin(), s[i].end());
    mp[s[i]]++;
  }
  ll res = 0;
  for (auto p : mp) {
    if (p.second >= 2) {
      res += p.second * (p.second - 1) / 2;
    }
  }
  cout << res << '\n';
}

int main() {
  cin >> N;
  s.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 18176
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define ll long long
#define chushihua(x,y) memset(x,y,sizeof x)
using namespace std;
const int MAXX = 100000 + 10;
const double PI = 3.14159265358979323846;
const ll mod = 1000000007;
int main() {
	int a, b, c;
	while (cin >> a) {
		cout << a * (a + 1) / 2 << endl;
	}
	return 0;
}

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

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

    cout << int(((N)/2.0)+0.5) << endl;
}


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

int main(){
    int n;
    cin>>n;
    int cnt=0;
    
    vector <int> vt(n);

    for (int i=0;i<n;i++){
        cin>>vt.at(i);
        // cout<<vt.at(i)<<endl;
    }
    while(1){
        bool ans=false;
        for (int j=0;j<n;j++){
            if (vt.at(j) % 2 ==1){
                ans=true;
            }
        }
        if(ans) break;
        cnt++;
        // cout<<cnt<<endl;
        
        for(int j=0;j<n;j++) {
                vt.at(j)/=2;
//                cout<<vt.at(j)<<endl;
        
        }
    }
    cout<<cnt<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
  cin >> n;
  
  for(int i=1;i<=9;i++)
  {
    if(n%i==0 && (n/i>0 && n/i<10)){
       cout << "Yes";
      return 0;}
  }
  cout << "No";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll ans = N * (N - 1) / 2 + M * (M - 1) / 2;
    OUT(ans)
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto FP = new COM(2001, 1000000007);
	foreach(i; 1..K+1) {
		writeln((FP.nCr(N-K+1, i) * FP.nCr(K-1, i-1)) % 1000000007);
	}
}

class COM {
	long[] fact, finv, inv;
	private ulong MAX;
	private ulong MOD;

	this(ulong MAX, ulong MOD) {
		this.MAX = MAX;
		this.MOD = MOD;
		fact = new long[](MAX);
		finv = new long[](MAX);
		inv = new long[](MAX);

		// initialize the arrays
		fact[0] = fact[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		foreach(i; 2..MAX) {
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

	ulong nCr(long n, long k) {
		if(n < k) return 0;
		if(n < 0 || k < 0) return 0;
		assert(n < MAX && k < MAX);
		return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
	ulong factorial(long n) {
		return fact[n];
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2428
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vi a(n), sumf(n+1), sumb(n+1);
    rep(i, n) {
        cin >> a[i];
    }

    if(!(n&1)) {
        rep(i, n) {
            if(i&1) {
                sumb[n-1-i] = sumb[n-i];
                sumf[i+1] = sumf[i];
            }
            else {
                sumf[i+1] = sumf[i] + a[i];
                sumb[n-1-i] = sumb[n-i] + a[n-i-1];
            }
        }

        rep(i, n+1) {
            //cout << sumf[i] << ' ' << sumb[i] << endl;
        }

        ll ans = -LINF;
        rep(i, n/2+1) {
            ll now = sumf[i*2] + sumb[i*2];
            //cout << now << endl;
            ans = max(ans, now);
        }
        cout << ans << endl;
    } else {
        vvi dp(3, vi(n+2, -LINF));
        dp[0][0] = 0;
        rep(i, n){
            rep(j, 3) {
                if((i+j)&1) continue;
                dp[j][i+2] = max(dp[j][i] + a[i], dp[j][i+2]);
                if(j != 2 and i+3 != n+2) {
                    dp[j+1][i+3] = max(dp[j][i] + a[i+1], dp[j+1][i+3]);
                }
                if(j == 0 and i+2 != n) {
                    dp[2][i+4] = max(dp[0][i] + a[i+2], dp[2][i+4]);
                }
            }
        }


        cout << max({dp[0][n-1], dp[1][n], dp[2][n+1]}) << endl;
    }
}

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
using P = pair<double, double>;

const double eps = 1e-6;

bool equal(P a, P b) {
    return max(abs(a.first - b.first), abs(a.second - b.second)) < eps;
}

bool tan_equal(P a1, P a2, P b1, P b2) {
    return abs((a2.first - a1.first) * (b2.second - b1.second) - (b2.first - b1.first) * (a2.second - a1.second)) < eps;
}

bool move(vector<P>& a, int ai, const P& b) {
    if (tan_equal(a[ai], b, a[(ai + 1) % 3], a[(ai + 2) % 3])) {
        a[ai] = b;
        return true;
    }
    return false;
}

bool move(vector<P>& A, int ai1, int ai2, const P& B) {
    double a = A[ai1].first, b = A[ai1].second;
    double c = A[(ai1 + 2) % 3].first - A[(ai1 + 1) % 3].first, d = A[(ai1 + 2) % 3].second - A[(ai1 + 1) % 3].second;
    double e = A[3 - ai1 - ai2].first, f = A[3 - ai1 - ai2].second;
    double g = B.first - A[ai2].first, h = B.second - A[ai2].second;

    if (abs(d * g -  c * h) < eps) return false;

    double x = (a * h - b * g - e * h + f * g) / (d * g -  c * h);
    A[ai1].first += c * x;
    A[ai1].second += d * x;
    return true;
}


int main() {
    vector<vector<int>> va, vb;
    {
        vector<int> v = { 0, 1, 2 };
        do {
            va.push_back({ v[0], v[1], v[0], v[2] });
            va.push_back({ v[0], v[1], v[2], v[0] });
            va.push_back({ v[0], v[1], v[2], v[1] });
        } while (next_permutation(v.begin(), v.end()));
    }
    {
        vector<int> v = { 0, 1, 2, 3 };
        do {
            vb.push_back(v);
        } while (next_permutation(v.begin(), v.end()));
    }

    while (true) {
        vector<P> a(3), b(3);
        for (auto& i : a) cin >> i.first >> i.second;
        for (auto& i : b) cin >> i.first >> i.second;
        if (!cin) return 0;

        vector<P> tmp = a;
        int ans = 5;
        for (auto& ai : va) {
            for (auto& bi : vb) {
                a = tmp;
                for (int i = 0; i < 4; ++i) {
                    if (bi[i] == 3) {
                        if (i == 3) {
                            ans = 3;
                            goto B;
                        }
                        if (!move(a, ai[i], ai[i + 1], b[bi[i + 1]])) goto A;
                    }
                    else if (!move(a, ai[i], b[bi[i]])) goto A;
                }
                ans = 4;
                A: continue;
            }
        }
        B:
        if (ans == 5) cout << "Many\n";
        else cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{

    int N = 0;
    cin >> N;
    int sum = 0;
    int tmp = 0;
    int result = 0;
    int target = 0;
    int dif1 = 0;
    int dif2 = 0;
    int sum1 = 0;
    int sum2 = 0;

    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >>a.at(i);
        sum = sum + a.at(i);
    }

    target = sum / 2;

    for(int i = 0; i < N; i++){
        
        tmp = tmp + a.at(i);

        dif2 = target - tmp;

        if(dif2 < 0){

            if(dif1 > abs(dif2)){
                result = i;
                break;
            }else{
                result = i - 1;
                tmp = tmp - a.at(i);
                break;
            }
            

        }

        dif1 = dif2;

    }

    cout << abs((sum - tmp) -tmp) << endl;

}


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

using namespace std;

int main()
{
    int N;
    long long sum = 0;
    vector<long long> vec;
    cin >> N;
    for (int i = 0; i <= N; i++) {
        if (i == 0)
            vec.push_back(2);
        else if (i == 1)
            vec.push_back(1);
        else {
            sum = vec.at(i - 1) + vec.at(i - 2);
            vec.push_back(sum);
        }
    }
    cout << vec.at(N) << endl;
}

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

int n,a[100010];

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,k;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	for (k=1;k<=a[k]&&k<=n;k++);
	for (k-=2,i=1;i+k<=n;i++) a[i]=a[i+k];
	for (n-=k,i=1;i<=n;i++) a[i]-=k;
	while (a[n]<=0) n--; n--; a[1]--;
	puts((n&1)||(a[1]&1)?"First":"Second");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  if(n<=9){
    cout << n << endl;
  }
  else if(n<=99){
    cout << 9 << endl;
  }
  else if(n<=999){
    cout << 9+(n-99) << endl;
  }
  else if(n<=9999){
    cout << 909 << endl;
  }
  else if(n<=99999){
    cout << 909 +(n-9999) << endl;
  }
  else{
    cout << 90909 << endl;
  }

}

Measured memory_bytes: 3584
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

# Xor
# ビット毎に独立
# k-bit目を二分探索


N = int(input())

A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)


mask = 1

ans = 0
for i in range(29):
    NA = A & mask
    NB = B & mask
    NA.sort()
    NB.sort()

    T = 2 ** i
    x1, x2, x3 = [np.searchsorted(NB, t - NA).sum() for t in [T, 2 * T, 3 * T]]
    zero_cnt = x1 + (x3 - x2)
    if (N*N - zero_cnt) % 2 == 1:
        ans += 2 ** i

    mask = mask * 2 + 1

print(ans)


Measured memory_bytes: 37480
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#define pb push_back
#define ll long long
#define inf 0x3f3f3f3f
#define fill(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> inline bool MIN(T &a,const T &b) {return a>b? a=b,1:0;}
template<typename T> inline bool MAX(T &a,const T &b) {return a<b? a=b,1:0;}
#define mod 1000000007
inline int plu(int a,int b) {return a+b>=mod? a+b-mod:a+b;}
inline int sub(int a,int b) {return a-b<0? a-b+mod:a-b;}
inline int mul(int a,int b) {return (ll)a*b%mod;}
inline int inc(int &a,int b) {a+=b;if (a>=mod) a-=mod;}
inline int dec(int &a,int b) {a-=b;if (a<0) a+=mod;}
#define mp make_pair
#define SZ(a) ((int)a.size())
#define BK(a) (a[SZ(a)-1])
#define fi first
#define se second
#define N 100010
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

int n,A[N];

vi q;

int main()
{

    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        scanf("%d",&A[i]);

    }
    sort(A+1,A+n+1);
    for (int i=1,j=1;i<=n;i=j) {

        for (;j<=n&&A[i]==A[j];++j);
        
        if (j-i>1) q.pb(A[i]);
        if (j-i>3) q.pb(A[i]);
    }
    sort(q.begin(),q.end());
    if (SZ(q)>1) cout<<(ll)q[SZ(q)-1]*q[SZ(q)-2];
    else printf("0\n");
    return 0;
}


Measured memory_bytes: 1024
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define deb(x) cerr <<#x<<" = "<<x<<"\n"
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////



/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n, k;cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	ll ans  = 0 ;
	for(int i=0;i<k;i++){
		ans += a[i];
	}
	cout << ans <<"\n";
}


int main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
	/* #ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif  */
}

Measured memory_bytes: 3560
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

INF = -(2 ** 31)

N, C = [int(_) for _ in input().split()]
X = [[int(x) for x in input().split()] for _ in range(N)]


def spam():
    L = [0] * N
    pre = 0
    pre_max = -(2 ** 31)
    for i in range(N):
        x, v = X[-i - 1]
        L[i] = max(pre_max, pre + v - (C - x))
        pre += v
        pre_max = L[i]

    ans = max(pre_max, 0)
    pre = 0
    for i in range(N):
        x, v = X[i]
        tmp = pre + v - x

        if i < N - 1:
            tmp2 = max(L[N - i - 2] - x, 0)
        else:
            tmp2 = 0
        ans = max(ans, tmp + tmp2)
        pre += v
    return ans


def main():
    global X
    ans = spam()
    X = X[::-1]
    for i in range(N):
        X[i][0] = C - X[i][0]
    ans = max(ans, spam())
    print(ans)


main()


Measured memory_bytes: 25120
MOD = 1000000007
n,k = (int(x) for x in input().split())
ans = 0

arrow = k
left = (k - 1) * k // 2
right = n * k - k * (k - 1) // 2
while(arrow <= n + 1):
    #print("[%d,%d]" % (left,right))
    ans += (right - left + 1)
    ans %= MOD
    left += arrow
    right += n - arrow
    arrow+=1

print(ans)

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=2e5+10;

int n;
vector <int> edge[maxn];
ll f[maxn],ans[maxn];
int sz[maxn];
ll tmp[maxn];

ll p0w(ll base,int p) {
	ll res=1;
	while (p) {
		if (p%2==1) (res*=base)%=mod;
		base=base*base%mod;
		p/=2;
	}
	return res;
}

ll C(int x,int y) {
	if (x==y||y==0) return 1;
	return tmp[x]*p0w(tmp[y],mod-2)%mod*p0w(tmp[x-y],mod-2)%mod;
}

void dfs1(int u,int fa) {
	ll tmp1=1,tmp2=1;
	sz[u]=0;
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (v==fa) continue;
		dfs1(v,u);
		tmp1=tmp1*f[v]%mod;
		tmp2=tmp2*C(sz[u]+sz[v],sz[v])%mod;
		sz[u]+=sz[v];
	}
	sz[u]++;
	f[u]=tmp1*tmp2%mod;
}

ll pre[maxn],suf[maxn];
	
void dfs2(int u,int fa) {
	int cnt=0;
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (i!=0) pre[i]=pre[i-1];
		else pre[i]=1;
		if (v==fa) continue;
		(pre[i]*=f[v]*C(cnt+sz[v],sz[v])%mod)%=mod;
		cnt+=sz[v];
	}
	cnt=0;
	for (int i=SZ(edge[u])-1;i>=0;i--) {
		int v=edge[u][i];
		if (i!=SZ(edge[u])-1) suf[i]=suf[i+1];
		else suf[i]=1;
		if (v==fa) continue;
		(suf[i]*=f[v]*C(cnt+sz[v],sz[v])%mod)%=mod;
		cnt+=sz[v];
	}
	cnt=0;
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (v==fa) continue;
		if (i!=0) (ans[v]*=pre[i-1])%=mod;
		if (i!=SZ(edge[u])-1) (ans[v]*=suf[i+1])%=mod;
		(ans[v]*=C(sz[u]-1-sz[v],cnt))%=mod;
		(ans[v]*=ans[u]*C(sz[1]-sz[v]-1,sz[1]-sz[u])%mod)%=mod;
		cnt+=sz[v];
	}
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (v==fa) continue;
		dfs2(v,u);
	}
}

int main(){
	tmp[0]=1;
	for (int i=1;i<maxn;i++) tmp[i]=tmp[i-1]*(ll)i%mod,ans[i]=1;
	scanf("%d",&n);
	for (int i=0;i<n-1;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs1(1,-1);
	dfs2(1,-1);
	for (int i=1;i<=n;i++) 
		printf("%d\n",f[i]*ans[i]%mod*C(sz[1]-1,sz[i]-1)%mod);
	return 0;
}


Measured memory_bytes: 22516
import math
in1=input()
in2=in1.split()
a=int(in2[0])
b=int(in2[1])
c=int(in2[2])
d=int(in2[3])
taka=math.ceil(a/d)
ao=math.ceil(c/b)
if taka<ao:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9188
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int button[] = new int[N];
		int button_check[] = new int[N];
		for(int i = 0 ; i < N; i++) {
			button[i] = sc.nextInt();
			button_check[i] = 0;
		}
		
		int button_now = 0;
		int count = 0;
		int j = 0;
		int flag = 0;
		
		while(button_now != 2) {
			button_now = button[j];
			button_check[j] = 1;
			count++;
			
			j = button_now - 1;
			if(button_check[j] == 1) {
				System.out.println(-1);
				flag = 1;
				break;
			}
		}
		
		if(flag == 0) {
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 50964
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    n = (1<<n);
    multiset<int> st;
    multiset<int,greater<int>> used;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        st.insert(a);
    }
    auto it = st.end(); it--;
    used.insert(*it);
    st.erase(it,st.end());
    while(st.size()){
        vector<int> v;
        for(auto i:used){
            auto it = st.lower_bound(i);
            if(it == st.begin()){
                cout << "No\n";
                return 0;
            }
            auto nx = it;
            it--;
            v.push_back(*it);
            st.erase(it,nx);
        }
        for(auto i:v)used.insert(i);
 
    }
    cout << "Yes\n";
}

Measured memory_bytes: 16288
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_029
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            long res = 0;
            int bCnt = 0;
            for(int i=s.Length-1;i>=0; i--)
            {
                if (s[i] == 'B')
                {
                    res += s.Length - 1 - i - bCnt;
                    bCnt++;
                }
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11616