akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void){
    int N,K,Q;
    cin >>N;
    cin >> K;
    cin >> Q;

    vector<int> points(N,K-Q);

    int num;
    for(int i=0;i<Q;i++){
        cin >> num;
        points[num-1] += 1;
    }

    string result;
    for(int i=0;i<N;i++){
        if(points[i]>0){
            result ="Yes";
        }
        else{
            result = "No";
        }

        cout << result << endl;
    }
}

Measured memory_bytes: 1024
import math
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
ans = 0
l = []
for i in range(m-1):
    l.append(x[i+1]-x[i])
l.sort(reverse=True)
print(x[-1]-x[0]-sum(l[:n-1]))


Measured memory_bytes: 20640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef pair<int, int> P;

int main()
{
	vector<P> ar;

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int h, k;
		cin >> h >> k;
		ar.push_back(P(h, k));
	}
	
	int m;
	cin >> m;
	for (int i = 0; i < m; ++i) {
		int h, k;
		cin >> h >> k;
		ar.push_back(P(h, k));
	}

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

	for (int i = 0; i < ar.size(); ++i) {
		if (i) {
			if (ar[i-1].first == ar[i].first && ar[i-1].second == ar[i].second) { continue; }
                       else { printf(" "); }
		}
		printf("%d:%02d", ar[i].first, ar[i].second);

	}
	cout << endl;
}

Measured memory_bytes: 1240
import java.util.Scanner;

/**
 * A - Where's Snuke?.
 */
public class Main {

    private static final String[] alpha = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

    public static void main( String[] args ) {

        Scanner scn = new Scanner( System.in );
        int height = scn.nextInt();
        int width = scn.nextInt();

        if ( height == 0 || width == 0 ) {
            System.out.println( "Input is invalid!" );
        }

        int count = 0;
        String str = null;

        int h_result = 0;
        int w_result = 0;

        while ( scn.hasNext() ) {
            count = count + 1;
            str = scn.next();
            if ( "snuke".equals( str ) ) {
                break;
            }
        }

        int k = count % width;
        if ( k == 0 ) {
            w_result = width;
            h_result = count / width;
        } else {
            w_result = k;
            h_result = (count / width) + 1;
        }
        System.out.println( alpha[w_result - 1] + Integer.toString( h_result ) );

    }

}


Measured memory_bytes: 9808
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        if (abc[0] == abc[1] && abc[1] != abc[2]
            || abc[0] != abc[1] && abc[1] == abc[2]
            || abc[0] == abc[2] && abc[0] != abc[1])
        {
            Console.WriteLine("Yes");
            return;
        }

        Console.WriteLine("No");
    }
}

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

using namespace std;

int main(void)
{
	int s,r,l;

	bool yymm=false,mmyy=false,ambi=false,na=false;

	cin>>s;

	l=s/100;
	r=s%100;

	if(r>0&&r<13){
		yymm=!yymm;
	}
 	if(l>0&&l<13){
		mmyy=!mmyy;
	}
	if((yymm==false)&&(mmyy==false)){
		na=!na;
	}
	if(yymm&&mmyy){
		ambi=!ambi;
	}

	if(ambi){
		cout<<"AMBIGUOUS"<<endl;
	}
	else if(mmyy){
		cout<<"MMYY"<<endl;
	}
	else if(yymm){
		cout<<"YYMM"<<endl;
	}
	else if(na){
		cout<<"NA"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    
int a, b;
    
scanf("%d %d",&a,&b);
    
if (a==b) printf("a == b\n");
else if (a<b) printf("a < b\n");
else if (a>b) printf("a > b\n");
    
return 0;
}
     
  

Measured memory_bytes: 580
#include <stdio.h>
int main() 
{
	int N, K;
	scanf("%d",&N);
	scanf("%d",&K);
	int ans = 1;
	
	for (int i = 0; i < N; i++)
	{
		if (ans < K)
		{
			ans *= 2;
		} else {
			ans += K;
		}
	}
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1708
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,cos,radians,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
s=list(map(int,SI()))
if n==1:
    print(s[0])
    sys.exit()

def divi2(x):
    if x%2==1:
        return 0
    else:
        count=0
        while x%2==0:
            x//=2
            count+=1
        return count
#print(divi2(24))
pw2=[0 for i in range(n-1)]
for i in range(n-1):
    if i%2==1:
        pw2[i]=divi2(i+1)
#print(pw2)
#print(s)
cmbnk2=[0 for i in range(n)]
for i in range(n-1):
    cmbnk2[i+1]=cmbnk2[i]+pw2[n-2-i]-pw2[i]
#print(cmbnk2)
ans=0
'''if (s.count(1)==1 and not 2 in s ) or (s.count(3)==1 and not 2 in s ):
    ans=2
    print(ans)
    sys.exit()'''
if not 2 in s:
    for i in range(n):
        s[i]=(s[i]-1)//2
    for i in range(n):
        if cmbnk2[i]==0:
            ans+=s[i]%2
    if ans%2==0:
        print(0)
    else:
        print(2)
    sys.exit()
    
        
else:
    for i in range(n):
        if cmbnk2[i]==0:
            ans+=s[i]%2
            #print(s[i]%2)
        #print(cmbnk2[i]%2+1)
        #print(s[i])
print(ans%2)

Measured memory_bytes: 131788
#include <stdio.h>

int main()
{
  int i, N, tmp_n, ok_flag;
  scanf("%d", &N);
  ok_flag = 0;
  for (i=1;i<10;i++ ) {
    if ( (N % i) != 0 )
      continue;
    tmp_n = N / i;
    if ( tmp_n > 0 && tmp_n < 10 ) {
      ok_flag = 1;
      i = 10;
      break;
    }
  }
  if (ok_flag)
    printf("Yes\n");
  else
    printf("No\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int, int>
#define pll pair<ll , ll>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define N 200005
#define INF 1000000000000000

int dp[3005][3005];
int dir[3005][3005];
string s , t;
int n , m;

int main()
{   
    fastio

    
    cin>>s>>t;

    
    n = s.length();
    m = t.length();


    for(int i = 1;i<=n;i++)
    {
        for(int j =1;j<=m;j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = 1+dp[i-1][j-1];
                dir[i][j] = 3;
            }
            else
            {
                if(dp[i-1][j] >= dp[i][j-1])
                {
                    dp[i][j] = dp[i-1][j];
                    dir[i][j] = 1;
                }
                else
                {
                    dp[i][j] = dp[i][j-1];
                    dir[i][j] = 2;
                }
            }
        }
    }

    string ans ="";

    int i = n,j=m;

    while(i!=0 && j!=0)
    {
        if(dir[i][j] == 3)
        {
            ans = s[i-1]+ans;
            i--;j--;
        }
        else if(dir[i][j] ==1)i--;
        else j--;
    }

    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 70784
#include<iostream>

#define MAX 1000001

bool isPrime[MAX];

void init(){
	for (int i = 2; i < MAX; i++)isPrime[i] = true;

	for (int i = 2; i*i < MAX; i++){
		if (isPrime[i]){
			for (int j = i * 2; j < MAX; j += i)isPrime[j] = false;
		}
	}
	return;
}

int main(){

	init();

	int n, x;
	while (std::cin >> n >> x, n || x){
		int price[31];
		bool isMake[MAX];

		for (int i = 0; i <= x; i++)isMake[i] = false;
		for (int i = 0; i < n; i++){
			std::cin >> price[i];
			isMake[price[i]] = true;
		}

		for (int i = 0; i <= x; i++){
			if (isMake[i]){
				for (int j = 0; j < n; j++){
					if (i + price[j] <= x)isMake[i + price[j]] = true;
				}
			}
		}

		for (int i = x; i >= 0; i--){
			if (isMake[i] && isPrime[i]){
				std::cout << i << std::endl;
				break;
			}
			if (i == 0)std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3116
chomp (my $n = <STDIN>);
chomp (my @v = split / /, <STDIN>);
my (%p, %q);
for my $i (0..$n-1) {
  if ($i % 2 == 0) {
    $p{$v[$i]}++;
  } else {
    $q{$v[$i]}++;
  }
}
my @ps = sort {$p{$b}<=>$p{$a}} keys %p;
my @qs = sort {$q{$b}<=>$q{$a}} keys %q;
my ($x, $y) = (0, 0);
my $ans = 0;
my $f = 0;
for my $i (0..$n/2-1) {
  $x = $ps[$i];
  for my $j (0..$n/2-1) {
    if ($ps[$i] != $qs[$j]) {
      $y = $qs[$j];
      $f = 1;
      last;
    }
  }
  last if $f;
}
$ans = $n - $p{$x} - $q{$y} if $f;
($x, $y) = (0, 0);
my $f = 0;
for my $i (0..$n/2-1) {
  $x = $qs[$i];
  for my $j (0..$n/2-1) {
    if ($qs[$i] != $ps[$j]) {
      $y = $ps[$j];
      $f = 1;
      last;
    }
  }
  last if $f;
}
$ans = $n - $q{$x} - $p{$y} if $f && $ans > $n - $q{$x} - $p{$y};
print "$ans\n";

Measured memory_bytes: 28616
n = gets.to_i
a = []
b = 2
(n-2).times do
    b += 1 if b%2 != 0 && b%3 != 0
    a << b
    b += 1
end
sum = a.inject(:+)
c = sum%6
if c == 2 || c == 3 || c == 4
    a << 30000-c << 30000
elsif c == 1 || c == 5
    a << 29997 << 29998
else
    a << 29994 << 30000
end

if n != 3
    puts a.join(" ")
else
    puts "2 5 63"
end

Measured memory_bytes: 2300
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
const int N=205;

int n;
int dep[N];
char s[N][N];
queue<int>Q;

int Bfs(int st) {
	int ret=1;
	memset(dep,0,sizeof(dep));
	dep[st]=1;Q.push(st);
	while(!Q.empty()) {
		int u=Q.front(); Q.pop();
		ret=max(ret,dep[u]);
		for(int v=1;v<=n;v++)
			if(s[u][v]=='1') {
				if(!dep[v]) {
					dep[v]=dep[u]+1;
					Q.push(v);
				}
				else if(dep[v]!=dep[u]+1&&dep[v]!=dep[u]-1)
					return -1;
			}
	}
	return ret;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	int ans=-1;
	for(int i=1;i<=n;i++)
		ans=max(ans,Bfs(i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
def main():
    n,m = list(map(int, input().split()))
    pos_list = list(map(int, input().split()))
    pos_list.sort()

    if n >= m:
        return 0
    diff_list =[0]
    for i in range(m-1):
        diff_list.append(pos_list[i+1]-pos_list[i])
    diff_list.sort()
    #print(pos_list)
    #print(diff_list)
    if n==1:
        return sum(diff_list)
    return sum(diff_list[:-n+1])

print(main())

Measured memory_bytes: 20424
def smaller(x, y):
	if x < y:
		return x
	return y
def larger(x, y):
	if x > y:
		return x
	return y

prime = []
numberlist = []
for i in range(2, 100001):
	numberlist.append(i)
while numberlist[0] <= 316:
	now = numberlist.pop(0)
	prime.append(now)
	newnumberlist = []
	for i in range(0, len(numberlist)):
		if numberlist[i] % now != 0:
			newnumberlist.append(numberlist[i])
	numberlist = newnumberlist
prime = prime + numberlist

N = int(input())
M = N
countlist = []
for i in range(0, len(prime)):
	countlist.append(0)
for i in range(0, len(prime)):
	while N % prime[i] == 0:
		countlist[i] += 1
		N //= prime[i]
numberlist = [1]
for i in range(0, len(prime)):
	genlist = [1]
	for j in range(0, countlist[i]):
		genlist.append(prime[i]*genlist[-1])
	newnumberlist = []
	for j in range(0, len(genlist)):
		for k in range(0, len(numberlist)):
			newnumberlist.append(genlist[j]*numberlist[k])
	numberlist = newnumberlist
min = 5000000000000000
for i in range(0, len(numberlist)):
	min = smaller(min, larger(len(str(M//numberlist[i])), len(str(numberlist[i]))))
print(min)

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

#define DEBUG 0
 


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

    vector <long long> A(N);

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


    for(int i = K; i < N; i++ ){
         if(A.at(i) > A.at(i - K)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
 
    }





    return 0;

 
}



Measured memory_bytes: 4780
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import numpy as np
def main():
    N, M, C = input_nums()
    B = np.array(input_nums())
    cnt = 0
    for i in range(N):
        A = np.array(input_nums())
        if np.sum(A*B) + C > 0:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 367
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    REP(i,n)IN(a[i]);
    int j=1;
    ll cnt=0;
    int tmp=a[0];
    REP(i,n){
    while(j<n&&(tmp+a[j])==(tmp^a[j])){
        tmp^=a[j];
        j++;
    }
    cnt+=j-i;
    tmp^=a[i];    
    }
    OUT(cnt);
    return 0;
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    while(cin >> n) {
        string s;
        while (n) {
            n--;
            s.push_back('a' + n % 26);
            n /= 26;
        }
        reverse(ALL(s));
        cout << s << endl;
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n][n],s[n+1][n+1];
  for(ll i=0;i<n;i++)
    for(ll j=0;j<n;j++)
      cin>>a[i][j];
  for(int i=0;i<=n;i++) s[i][0]=s[0][i]=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      s[i+1][j+1]=s[i+1][j]+a[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<=n;j++)
      s[i+1][j]+=s[i][j];
  ll ans=a[0][0];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      for(ll k=i+1;k<=n;k++){
	for(ll l=j+1;l<=n;l++){
	  ans=max(ans,s[k][l]+s[i][j]-s[i][l]-s[k][j]);
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3184
#include<cstdio>
#include<set>
#include<iostream>
#include <iterator>
#include <utility>
#include<map>
#define max 100005
using namespace std;
struct tree
{
	int parent;
	int left;
	int  right;
};
struct tree T[1000];
void pre(int u)
{
	if(u==-1)
	return;
	cout<<" "<<u;
	pre(T[u].left);
	pre(T[u].right);
}
void ino(int u)
{
	if(u==-1)
	return;
	ino(T[u].left);
	cout<<" "<<u;
	ino(T[u].right);
}
void pos(int u)
{
	if(u==-1)
	return;
	pos(T[u].left);
	pos(T[u].right);
	cout<<" "<<u;
}
int main()
{
	int n;
	int id,left,right;
	cin>>n;
	for(int i=0;i<n;i++)
	T[i].parent=-1;
	for(int i=0;i<n;i++)
	{
		cin>>id>>left>>right;
		T[id].left=left;
		T[id].right=right;
		if(left!=-1)
		T[left].parent=id;
		if(right!=-1)
		T[right].parent=id;
	}
	int root;
	for(int i=0;i<n;i++)
	if(T[i].parent==-1)
	root=i;
	cout<<"Preorder"<<endl;
	pre(root);
	cout<<endl;
	cout<<"Inorder"<<endl;
	ino(root);
	cout<<endl;
	cout<<"Postorder"<<endl;
	pos(root);
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, M, L; std::cin >> N >> M >> L;

  constexpr ll INF = 1LL<<60;
  std::vector<std::vector<ll>> G(N, std::vector<ll>(N, INF));
  std::vector<std::vector<ll>> H(N, std::vector<ll>(N, INF));
  rep(i, N) G[i][i] = 0;
  rep(i, N) H[i][i] = 0;

  rep(i, M) {
    ll A, B, C; std::cin >> A >> B >> C;
    A--, B--;
    G[A][B] = C;
    G[B][A] = C;
  }

  rep(k, N) rep(i, N) rep(j, N) G[i][j] = std::min( G[i][j], G[i][k] + G[k][j] );
  rep(i, N) rep(j, N) if ( G[i][j] <= L ) H[i][j] = 1;
  rep(k, N) rep(i, N) rep(j, N) H[i][j] = std::min( H[i][j], H[i][k] + H[k][j] );

  int Q = 0; std::cin >> Q;
  std::vector<ll> ans(Q);
  rep(i, Q) {
    int s, t; std::cin >> s >> t;
    s--, t--;
    ans[i] = H[s][t];
  }

  rep(i, Q) if ( ans[i] == INF ) std::cout << -1 << std::endl;
  else std::cout << ans[i]-1 << std::endl;

  return 0;
}



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

int main(){
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	sort(a,a+n);
	int f=0,s=0;
	for(int i=0;i<n;i+=2){
		if(a[i]==a[i+1]){
			s=f;
			f=a[i];
		}else{
			i--;
		}
	}
	cout<<(long long)s*f<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int a,b,c,x,y;
    cin >>a>>b>>c>>x>>y;
    int ans = mINF;
    for(int i=0;i<=1e5;i++){
        int res = 0;
        res = i*2*c + max(0,x-i)*a + max(0,y-i)*b;
        chmin(ans,res);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int ans = 35;
	while(n--) {
		int x;
		cin>>x;
		int total = 0;
		while(x % 2 == 0) x /= 2, total++;
		ans = min(ans, total);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
   int n;
   cin>>n;
       n%=10;
   if(n==3) cout<<"bon"<<endl;
   else if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
   else cout<<"hon"<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
typedef long long LL;
priority_queue <int> q;
int n;
LL sum=0,f[300001],g[300001],a[300001];
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n*3;i++) scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++) {
        q.push(-a[i]);
        sum+=a[i];
    }
    f[n]=sum;
    for (int i=n+1;i<=2*n;i++) {
        q.push(-a[i]);
        sum+=a[i];
        int now=q.top();
        q.pop();
        sum+=now;
        f[i]=sum;
    }
    sum=0;
    while (!q.empty()) q.pop();
    for (int i=3*n;i>2*n;i--) {
        q.push(a[i]);
        sum+=a[i];
    }
    g[2*n+1]=sum;
    for (int i=2*n;i>n;i--) {
        q.push(a[i]);
        sum+=a[i];
        int now=q.top();
        q.pop();
        sum-=now;
        g[i]=sum;
    }
    LL max0=-1e15;
    for (int i=n;i<=2*n;i++) max0=max(max0,f[i]-g[i+1]);
    printf("%lld\n",max0);
    return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vii a(n); 
  vi v(n), c(n);
  rep(i,n) cin >> v[i];
  rep(i,n) cin >> c[i];

  rep(i,n){
    a[i].first = v[i];
    a[i].second = c[i];
  }
  sort(a.begin(), a.end(), [](ii a, ii b) {return a.first - a.second > b.first - b.second;});
  int ans = 0;
  rep(i,n) {
    if (a[i].first - a[i].second < 0) continue;
    ans += a[i].first - a[i].second;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int sum=0,n=0;
    for(int i=0;i<s.size();i++){
        sum+=(s.at(i)-'0');
        n+=(s.at(i)-'0')*pow(10,s.size()-i-1);
    }
    if(n%sum==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<string> svec;

ll mod_pow(ll x, ll n, ll m) {
	ll ret = 1;
	while (n) {
		if (n % 2)ret = ret * x%m;
		x = x * x%m; n >>= 1;
	}
	return ret;
}

int lenq(ll x) {
	string s = to_string(x);
	return (int)s.length();
}
ll t10[19];
void init() {
	t10[0] = 1;
	rep1(i, 18) {
		t10[i] = t10[i - 1] * 10;
	}
}
ll cur;
ll m;

typedef vector<vector<ll>> mat;
typedef vector<ll> vec;
mat mtmul(mat &A, mat &B) {
	mat C(A.size(), vec(B[0].size()));
	rep(i, (int)A.size()) {
		rep(k, (int)B.size()) {
			rep(j, (int)B[0].size()) {
				C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % m) % m;
			}
		}
	}
	return C;
}
mat mtpow(mat A, ll n) {
	mat B(A.size(), vec(A.size()));
	rep(i, (int)A.size()) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n&(ll)1)B = mtmul(B, A);
		A = mtmul(A, A);
		n >>= 1;
	}
	return B;
}
ll b;
ll na;
ll upd(int x,ll n) {
	ll z = t10[x] % m;
	mat A = { {z,0,1},{1,1,0},{0,0,1} };
	A = mtpow(A, n - 1);
	ll u = (na + b) % m;
	//cout << u << endl;
	ll t = ((A[0][0]+A[0][2])%m * ((na+b)%m) + (A[1][0]+A[1][2])*(b%m)) % m;
	/*cout << A[0][0] << endl;
	cout << "t "<<t << endl;*/
	ll nex = mod_pow(z, n, m);
	nex = nex * cur%m;
	nex += t;
	return nex % m;
}
void solve() {
	init();
	ll n, a; cin >> n >> a >> b >> m;
	cur = a%m;
	ll r = n-1;
	na = a;
	while (r>0) {
		//cout << na << " " << cur << endl;
		int c = lenq(na);
		ll sup = t10[c];
		ll dif = sup - na;
		ll d = (dif - 1) / b;
		if (d > r)d = r;
		if (d > 0) {
			cur=upd(c, d);
			r -= d;
			na += b * d;
			if (r == 0)break;
			//cout << na << " " << cur << endl;
		}
		r--;
		na += b;
		c = lenq(na);
		cur = cur * (t10[c] % m) % m + na%m;
		cur %= m;
	}
	cout << cur << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	//while (cin >> n>>m>>l,n)solve();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
import sys,math
import numpy as np

r=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

print(2*math.pi*r)


Measured memory_bytes: 27128
#include<bits/stdc++.h>
#define N 200100
using namespace std;
int beg[N],to[N],nex[N];
int sg[N];
int len,n;
inline void Add(int a,int b){
	nex[++len]=beg[a],beg[a]=len,to[len]=b;
	nex[++len]=beg[b],beg[b]=len,to[len]=a;
}
void dfs(int p,int fa){
	int A=0,B=0;
	for(int i=beg[p];i;i=nex[i]){
		if(to[i]!=fa){
			dfs(to[i],p);
			sg[p]^=sg[to[i]]+1;
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		Add(a,b);
	}
	dfs(1,-1);
	printf("%s\n",sg[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 7296
/*
 * Matheus Oliveira
 * 09:52:58 23/03/2019
 * a.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN 110
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');
typedef long long ll;
typedef pair<int, int> pii;

int ans[MAXN];
vector<int> elements;

int main() {
	int n, posToRemove, v;
	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		scanf("%d", &v);
		elements.pb(v);
	}
	
	for(int i = 0; i < n; i++) {
		posToRemove = -1;
		for(int j = 0; j < ((int) elements.size()); j++) {
			if( elements[j] == (j+1) ) posToRemove = j;
		}

		if(posToRemove == -1) {
			printf("-1\n");
			return 0;
		}

		ans[n-1 - i] = elements[posToRemove];
		elements.erase(elements.begin() + posToRemove);
	}

	for(int i = 0; i < n; i++) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<complex>
#define eps 10e-9
using namespace std;
typedef complex<double> p;

double cross(p x,p y)
{
	return x.real()*y.imag()-x.imag()*y.real();
}

int main()
{
	p a,b,c,d;
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&a.real(),&a.imag(),&b.real(),&b.imag(),&c.real(),&c.imag(),&d.real(),&d.imag())!=EOF) 
	{
		double tmp=1;
		tmp*=cross(b-a,d-a);
		bool flag=true;
		if(tmp*cross(c-b,a-b)<-eps||tmp*cross(d-c,b-c)<-eps||tmp*cross(a-d,c-d)<-eps) flag=false;
		cout<<(flag?"YES":"NO")<<endl;
	}
  return 0;
}

Measured memory_bytes: 1224
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
          `-.____`.___ \_____/___.-`___.-'
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    ADITI GOEL IS LOVE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// while(scanf("%d",&n)!=EOF)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <bits/stdc++.h>
#define ii int64_t
#define lli long long int
#define li long int
#define vi vector<int64_t>
#define mii unordered_map<int64_t,int64_t>
#define nl cout<<"\n"
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define mod 1000000007
ii n,t,i,j,k,l,x,y,z,cnt=0,sum=0,mx=-INFINITY,mn=INFINITY;
bool f,f1,f2;
using namespace std;
int main()
{fio;
    cin>>x;
    y=x%500;
    cout<<1000*(x/500)+5*(y/5);
    
    
    
    
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int mod=998244353;
const int N=2e5+10;
int a[N];
int c[N];
int dp[1010][(1<<12)+5];

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<=m; i++)
    {
        for(int j=0; j<(1<<n); j++)
        {
            dp[i][j]=1e9;
        }
    }
    for(int i=1; i<=m; i++)
    {
        int x;
        cin>>a[i]>>x;
        int temp=0;
        for(int j=1; j<=x; j++)
        {
            int y;
            cin>>y;
            y=1<<(y-1);
            temp|=y;
        }
        c[i]=temp;
    }
    dp[0][0]=0;
    for(int i=1; i<=m; i++)
    {
        for(int j=0; j<(1<<n); j++)
        {
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            int k=j|c[i];
            dp[i][k]=min(dp[i][k],dp[i-1][j]+a[i]);
        }
    }
    if(dp[m][(1<<n)-1]==1e9)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<dp[m][(1<<n)-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 19620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{
    int n;
    cin >> n;
    vi a(n);
    in(n,a);
    
    int t = 0,tt = 0;
    
    rep(i,n){
        if(a[i]%2==0) t++;
        if(a[i]%4==0) tt++;
    }
    //cout << t << "  " << tt << endl;
    if(n-t <= tt || n-tt == tt+1){
        out("Yes");
    }else{
        out("No");
    }



    return 0;
}


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

int main()
{
	int n;
	int a[3];
	cin >> a[0] >> a[1] >> a[2] >> n;
	int cnt = 0;
	for(int i = 0;i<=n;i++)
	{
		for(int j = 0;j<=n;j++)
		{
			if(n-a[0]*i-a[1]*j<0)continue;
			if((n-a[0]*i-a[1]*j)%a[2]==0)
			{
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();
int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e18+4);

void max_self(int &a, int b){
    a= max(a,b);
}

void min_self(ll &a, ll b){
    a=min(a,b);
}


ll run() {
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    int dp[h+1][w+1] = {0};

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }

    int ans =0;
    for(int i=1;i<=h;i++){
        dp[i][1]=1;
        if(a[i][1]=='#'){
            for(int j=i;j<=h;j++)
                dp[i][1]=0;
            break;
        }
    }

    for(int i=1;i<=w;i++){
        dp[1][i]=1;
        if(a[1][i]=='#'){
            for(int j=i;j<=w;j++)
                dp[1][j]=0;
            break;
        }
    }

    for(int i=2;i<=h;i++){
        for(int j=2;j<=w;j++){
            if(a[i][j]=='.'){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[h][w];

}


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

int main() {
  int n; cin >> n;
  vector<bool> colors(8);
  for (int i=0; i<8; i++) colors[i] = false;
  int min=0, max=0, pro=0;

  for (int i=0; i<n; i++) {
    int a; cin >> a;
    for (int j=0; j<8; j++) {
      if (a >= j*400 && a < (j+1)*400) {
        colors[j] = true;
        break;
      }
      else if (a >= 3200) {
        pro++;
        break;
      }
    }
  }
  for (int i=0; i<8; i++) 
    if (colors[i]) min++;
  max = min + pro;
  if (min == 0) min=1;
  cout << min << " " << max << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC 150B
int main() {
	int k, x;
	cin >> k >> x;

	if (500*k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int main(){
    int n,k;
    cin >> n>>k;
    vector<ll> h(n);
    vector<ll> dp(n);
    rep(i,n) cin >> h[i];
    rep(i,n) dp[i]=10000000000;
    dp[0]=0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<=min(i+k,n-1);++j){
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
    }

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
  string s; cin >> s;
  int cnt=0;
  for(int i=0; i < s.length(); i++){
    if(s[i] == '1') cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
num = []
for a_ in range(a+1):
    for b_ in range(b+1):
        for c_ in range(c+1):
            cal = a_ * 500 + b_ * 100 + c_ * 50
            num.append(cal)
print(num.count(x))

Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MOD=1e9+7;
typedef long long ll;
typedef pair<ll,ll> P;

const ll MAX_N=1e18;
const int MAX_LOG_N=60;

ll N;

ll memo[MAX_LOG_N+1][3];

ll dfs(int n,int i){
	if (n<0) return 1;
	if (memo[n][i]!=-1) return memo[n][i];
	ll res=0;
	REP(j,3){
		if ((i<<1)+(N>>n&1)-j>=0){
			res+=dfs(n-1,min((i<<1)+(int)((N>>n)&1)-j,2));
		}
	}
	res%=MOD;
	return memo[n][i]=res;
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%lld",&N);
	printf("%lld\n",dfs(MAX_LOG_N,0));
	return 0;
}

Measured memory_bytes: 256
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int a[10];

int main() {
	for (int i = 0; i < 10; i++) {
		cin >> a[i];
	}
	sort(a, a + 10);
	cout << a[9] << endl;
	cout << a[8] << endl;
	cout << a[7] << endl;
}

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

int main() {
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
        a[i]--;
    }
    int vis[n]{};
    int p=0;
    int cnt=0;
    while (1) {
        if (vis[p]) {
            cout<<-1<<endl;
            return 0;
        }
        vis[p]=1;
        p=a[p];
        cnt++;
        if (p==1) {
            cout<<cnt<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include<algorithm>
#include <set>
#include <stdlib.h>

using namespace std;

int main()
{
    int n,m,q,r=0;
    int arr[1005];
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<m;i++)
        r+=arr[i];
    cout<<r;

    return 0;
}


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

int main() {
    string s;
    cin>>s;
    string ans = s;
    rep(i,s.size()){
        if(s[i]=='?'){
            ans[i] = 'D';
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

int N, A, B, C, D; 
string S;
cin  >> N >> A >> B >> C >> D >> S;


rep(i, B, D - 2)
    if (S[i] == '#' && S[i + 1] == '#') {
        cout << "No\n";
        return 0;
    }
rep(i, A, C - 2)
    if (S[i] == '#' && S[i + 1] == '#') {
        cout << "No\n";
        return 0;
    }

if (C < D)
    cout << "Yes\n";
else {
    rep(i, B-1, D)
        if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
            cout << "Yes\n";
            return 0;
        }
    cout << "No\n";
}  


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main()
{
	string s;
	
	int q; 
	cin>>s>>q;
	int r = 0;
	int t;
	int f;
	char c;
	string p;
	for(size_t i = 0; i<q; i++)
	{
		cin>>t;
		if(t==1)
		{
			r++;
		}
		else
		{
			cin>>f>>c;
			if((r+f)%2==1)
			{
				p = c+p;
			}
			else
			{
				s += c;
			}
		}
	}
	s = p+s;
	if(r%2==1)
	{
		reverse(s.begin(),s.end());
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#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;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    string b;
    cin>>b;
    ll sum = 0;
    rep(i,b.size()){
        sum+=(b[i]-'0');
        sum%=9;
    }
    if(sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
 ll n,m,c=0,x;
 cin>>n>>m;
 for(int i=0;i<m;i++)
 {
     cin>>x;
     c+=x;
 }
 if(c>n)
 {
     cout<<-1<<endl;
 }
 else
    cout<<n-c<<endl;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;
using ll = long long;

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

int dp[100005];

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i, n) cin >> h[i];

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

  cout << dp[n - 1] << endl;
  return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include<unordered_set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n;
    cin>>n;
    lli a[n];
    for(int i = 0; i < n; i ++) {
        cin>>a[i];
    }
    lli ans = inf;
    for(int i = 0; i <= 100; i ++) {
        lli x = 0;
        for(int j = 0; j < n; j ++) {
            x += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, x);
    }
    cout<<ans;
    cout<<'\n';
    return ;
}

/*
*/

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

//    pre();

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


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parent = [i for i in range(self.n)]
    self.rank = [0] * self.n
  
  def find_root(self, x):
    if self.parent[x] == x:
      return x
    else:
      self.parent[x] = self.find_root(self.parent[x])
      return self.parent[x]
  
  def unite(self, x, y):
    rx = self.find_root(x)
    ry = self.find_root(y)
    if rx == ry:
      return
    if self.rank[rx] < self.rank[ry]:
      self.parent[rx] = ry
    else:
      self.parent[ry] = rx
      if self.rank[rx] == self.rank[ry]:
        self.rank[rx] += 1
  
  def is_same(self, x, y):
    return self.find_root(x) == self.find_root(y)

V, E = map(int, input().split())
edges = []
for _ in range(E):
  s, t, w = map(int, input().split())
  edges.append((w, s-1, t-1))
edges.sort()

uf = UnionFind(V)
total = 0
for e in edges:
  w, s, t = e
  if uf.is_same(s, t):
    continue
  uf.unite(s, t)
  total+= w
print(total)


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

int main() {
  int H, W, D, Q, N;
  cin >> H >> W >> D;
  N = H * W;
  vector<pair<int, int>> V(N);
  for (int i = 0; i < H; i++) {
    for (int j = 0, a; j < W && cin >> a; j++) V.at(--a) = {i, j};
  }
  vector<int> R(N, -1);
  for (int i = 0; i < N; i++) {
    if (R.at(i) == -1) {
      R.at(i) = 0;
      auto[a, b] = V.at(i);
      for (int j = i + D, sum = 0; j < N; j += D) {
        auto[c, d] = V.at(j);
        R.at(j) = sum += abs(a - c) + abs(b - d);
        a = c, b = d;
      }
    }
  }
  cin >> Q;
  for (int l, r; cin >> l >> r;) cout << R.at(--r) - R.at(--l) << "\n";
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;

    for (int i = 0; i < N; i++){
        int l,r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

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

using namespace std;

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

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

  int a[n+1];

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

  int dp[n+1];

  memset(dp, -1, sizeof(dp));

  dp[1]=0;
  dp[2]=abs(a[2]-a[1]);

  for(int i=3; i<=n; i++) {
    dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
    for(int j=2; j<=k && j<i; j++) {
      dp[i]=min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
  }
  }

  cout<<dp[n];
}


Measured memory_bytes: 1024