akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        h: [i64; n],
    }

    let mut ans = 0;
    let mut l = 0;
    while l < n {
        let mut r = l;
        while r + 1 < n && h[r] >= h[r + 1] {
            r += 1;
        }
        ans = std::cmp::max(ans, r - l);
        l = r + 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0
is_bob_turn = 0

for _ in range(len(a)):
  if not is_bob_turn:
    is_bob_turn = 1
    alice += max(a)
    del a[a.index(max(a))]
  else:
    is_bob_turn = 0
    bob += max(a)
    del a[a.index(max(a))]
print(alice-bob)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include<cmath>
using namespace std;
#define mod 1000000007
#define fr(i, a, b) for (int i = a; i < b; i++)
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n,m; cin>>n>>m;
    char a[n][m];
    fr(i,0,n) fr(j,0,m) cin>>a[i][j];
    int dp[n][m]={};
    fr(i,1,n+1) if(a[0][i]=='.') dp[0][i]=1; else break;
    fr(i,0,n) if(a[i][0]=='.') dp[i][0]=1; else break;
    fr(i,1,n){
        fr(j,1,m){
            if(a[i][j]=='#'){
                dp[i][j]=0;
            } else{
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 5120
a=list(map(int,input().split('/')))
#print(a)
if a[0]==2019:
    if a[1]==4:
        if 30>=a[2]:
            print("Heisei")
        else:
            print("TBD")
    elif 5>a[1]:
        print("Heisei")
    else:
        print("TBD")
elif 2019>=a[0]:
    print("Heisei")
else:
        print("TBD")

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

int main() {
  string w;
  cin >> w;
  
  if(w.at(0)=='R' && w.at(1)=='R'){
    if(w.at(2)=='R'){
      cout << 3 << endl;
    }
    else{
      cout << 2 << endl;
    }
  }
  else if(w.at(1)=='R' && w.at(2)=='R'){
    cout << 2 << endl;
  }
  else if(w.at(0)=='R' && w.at(2)=='R'){
    cout << 1 << endl;
  }
  else if(w.at(0)=='R' || w.at(1)=='R'){
    cout << 1 << endl;
  }
  else if(w.at(2)=='R'){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3624
package main

import (
   "fmt"
)

func solution(n int) string {
   out := []byte{}
   for n > 0 {
        y := n % 26
        if y != 0 {
                out = append([]byte{byte(y-1) + 'a'}, out...)
                n /= 26
        } else {
                out = append([]byte{'z'}, out...)
                n /= 26
                n--
        }
   }

   return string(out)
}

func main() {
   var n int
   fmt.Scan(&n)
   fmt.Println(solution(n))
}

Measured memory_bytes: 1768
read = input 
rn = lambda :list(map(int, read().split()))
[n] = rn()
A = rn()
S = [0 for i in range(n)]
S[0] = A[0]
for i in range(1, n):
    S[i] = S[i-1] + A[i]
ans = S[n-1]
for i in range(1, n):
    ans = min(ans, abs(S[n-1] - S[i-1] - S[i-1]))
print(ans)

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

int main() {
  int n, y;
  cin >> n >> y;
  int a = -1, b = -1, c = -1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; i + j <= n; j++) {
      int k = n - i - j;
      if (10000 * i + 5000 * j + 1000 * k == y) {
        a = i;
        b = j;
        c = k;
      }
    }
  }
  printf("%d %d %d\n", a, b, c);
  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll X;
  cin >> X;

  cout << ((X == 7 || X == 5 || X == 3) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import math
n = int(input())
arr = input().split(' ')
arr = [0] + [int(a) for a in arr] + [0]

cost = 0
for j in range(1, len(arr)):
	cost += math.fabs(arr[j] - arr[j - 1])

for i in range(len(arr) - 2):
	print(int(cost - math.fabs(arr[i + 1] - arr[i]) - math.fabs(arr[i + 2] - arr[i + 1]) + math.fabs(arr[i + 2] - arr[i])))

Measured memory_bytes: 14816
#include <iostream>
#include <queue>
#include <utility>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int n,x,l,sum=0,i;
    cin >> n >> x;
    for(i=0;i<n;i++) {
        cin >> l;
        sum += l;
        if (sum>x) break;
    }
    
    cout << i+1 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split();
            int[] reverse = new int[n];
            for (int i = 0; i < n; i++)
            {
                reverse[n - 1 - i] = int.Parse(str[i]);
            }

            for (int i = 0; i < n; i++)
			{
                Console.Write("{0}", reverse[i]);
                if(n-1 != i) {
                    Console.Write(" ");
                }
			}
            Console.WriteLine();
        }
    }

}

Measured memory_bytes: 5644
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool arr[10000007];
vector<unsigned long long>vec;

void solve()
{
    unsigned long long i,j;
    for(i=4;i<=10000002;i+=2)
    {
        arr[i]=1;
    }
            //cout << i << endl;

    for(i=3;i*i<=10000002;i+=2)
    {
        if(arr[i]==0)
        for(j=i*i;j<=10000002;j+=i)
        {
            arr[j]=1;
        }


    }
    for(i=2;i<=10000002;i++)
    {
        if(!arr[i]){
                //cout << i << endl;
            vec.push_back(i);
        }
    }
   // cout << vec.size() << endl;







}



int main(){
    fast;
   unsigned long long a,i,j,m=0,sum,k;

 solve();
 cin >> a;
 unsigned long long sum2=1;
for(i=2;i<=a;i++)
{
    j=i;
    m=0;
    sum=1;
    for(k=0;k<vec.size() && vec[k]<j;k++)
    {
        if(j%vec[k]==0)
        {
            m=0;
            while(j%vec[k]==0)
            {
                j/=vec[k];
                m++;
            }
            sum*=(m+1);
        }
        if(arr[j]==0)
        {
            break;
        }




    }
    if(j>1)
    {
        sum*=2;
    }
    sum2+=sum*i;
    //cout << sum2 << endl;
    //cout << "i  " <<i << "   " << sum << endl;




}
cout << sum2 << endl;

}


Measured memory_bytes: 21332
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := 0
    for i:=n; i<1000; i++{
        if i%10 == i/100 && (i-i/100*100)/10 == i%10{
            ans = i
            break
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
struct TCard
{
    char Suit;
    int  Num;
    bool operator==(const TCard& C)const
    {
        return Suit == C.Suit && Num == C.Num;
    }
};
typedef std::vector<TCard> TList;
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i].Suit;
        std::cin >> List[i].Num;
    }
    return List;
}
bool Compare(const TCard& Left, const TCard& Right)
{
    return Left.Num < Right.Num;
}

int BubbleSort(TList& List)
{
    int Count = 0;
    bool Flag = true;
    while(Flag){
        Flag = false;
        for(std::size_t i = 0; i+1 < List.size(); ++i)
        {
            if(List[i].Num > List[i+1].Num){
                std::swap(List[i], List[i+1]);
                Flag = true;
                Count++;
            }
        }
    }
    return Count;
}

int SelectionSort(TList& List)
{
    typedef TList::iterator TIt;
    int Count = 0;
    for(TIt It = List.begin(); It != List.end(); ++It){
        TIt Min = std::min_element(It, List.end(), Compare);
        if(It != Min){
            std::swap(*It, *Min);
            ++Count;
        }
    }
    return Count;
}

void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << It->Suit << It->Num;
    for(++It; It != List.end(); ++It){
        std::cout << " " << It->Suit << It->Num;
    }
    std::cout << std::endl;
}
void Check(const TList& List, const TList& Stable)
{
    if(std::equal(List.begin(), List.end(), Stable.begin())){
        std::cout << "Stable" << std::endl;
    }else{
        std::cout << "Not stable" << std::endl;
    }
}
int main()
{
    const TList List = Input();
    TList StableList = List;
    std::stable_sort(StableList.begin(), StableList.end(), Compare);

    TList BubbleList = List;
    BubbleSort(BubbleList);
    Output(BubbleList);
    Check(BubbleList, StableList);
    
    TList SelectionList = List;
    SelectionSort(SelectionList);
    Output(SelectionList);
    Check(SelectionList, StableList);
    return 0;
}

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

int main()
{
    int a, b, x;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        x = (a + b) / 2;
    }
    else
    {
        x = (a + b + 1) / 2;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}


int main()
{ 
  IOS;

string s;

cin>>s;

string t="";

for(int i=0;i<3;i++)t+=s[i];


cout<<t<<endl;

 return 0;
 
 
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e5;
const int inf = 1<< 30;
typedef long long LL;
int main(){
	int n,m,a;
	cin >> n >> m;
	for(int i = 0;i<n;i++)
		cin >> a;
	int ans = 1;
	n -= m;
	ans += n/(m-1);
	if(n%(m-1)) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""
 

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
   	int n;
   	cin >> n;
   	int ans = 0;
   	for (int i = 1; i <= n; i++) {
   		if (i % 2 != 0) ++ans; 	
   	}
   	cout << fixed << setprecision(10);
   	cout << (double) ans/n;
    return 0;
}

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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll A[n];
    ll sum = 0;
    rep(i,0,n){
    	cin >> A[i];
    	sum ^= A[i];
    }
    rep(i,0,n){
    	cout << (sum ^ A[i]) << " ";
    }
    cout << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

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

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

signed main(){
    int N;
    string S;
    cin>>N>>S;

    int ans=0;
    rep(i,N-2)if(S.substr(i,3)=="ABC")ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker,"/stack:200000000")
#include <bits/stdc++.h>
using namespace std;

// #define DEBUG
#ifndef DEBUG 
	#define endl "\n"
#endif

#define PI 2*acos(0.0)
#define INFLL 1e18
#define CLEAR(x,val) memset(x,val,sizeof(x))
#define print(x) cout << x << endl, exit(0)
#define watch(x) cerr << #x << " -> " << x << endl
// #define int long long

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

const int INF = 1000000000;
const int MOD = 1000000007; //998244353

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

signed main()
{	
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin.tie(0), cout.tie(0);
	ios::sync_with_stdio(0);
	int a,b,c;
	cin >> a >> b >> c;
	if(a + b + c >= 22)
		print("bust");
	print("win");	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  if(a==b)cout << "Yes" << endl;
  else cout << "No" << endl;
}
                     

Measured memory_bytes: 256
// B - Mix Juice.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <set>

int main()
{
    std::multiset<int> fruits;
    int f, k;
    std::cin >> f >> k;

    for (int i = 0; i < f; i++)
    {
        int q;
        std::cin >> q;
        fruits.insert(q);
    }

    int s = 0;
    auto iter = fruits.begin();
    for (int i = 0; i < k; i++)
    {
        s += *iter;
        iter++;
    }

    std::cout << s;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 3680
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		long[] p = new long[w];
		for (int i=0;i<w;i++) {
			p[i]=sc.nextInt();
		}

		long[] q = new long[h];
		for (int j=0;j<h;j++) {
			q[j]=sc.nextInt();
		}

		Arrays.sort(p);
		Arrays.sort(q);

		int i=0;
		int j=0;


		long ans = 0;

		while (i<w || j<h) {
			if(i>=w || (j<h && p[i]>q[j])) {
				//draw a vertical line
				ans += (q[j]*(w+1-i));
				j++;

			} else {
				//draw a horizontal line
				ans += (p[i]*(h+1-j));
				i++;

			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 84804
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;


public class Main {

    public static void main(String[] args) {
    
    	FastScanner scan = new FastScanner();
    	
    	int n = scan.nextInt();
    	char [] ch = String.valueOf(n).toCharArray();
    	int x = ch[ch.length-1] - '0';
    	if(x == 2 || x == 4 || x==5 || x== 7 || x==9) System.out.println("hon");
    	else if(x == 3) System.out.println("bon");
    	else System.out.println("pon");
    }

   
    static class FastScanner{
    	
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
    	String next() {
    		while(!st.hasMoreTokens())
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e){
    				e.printStackTrace();
    			}
    		return st.nextToken();
    	}
    	
    	int nextInt() {
    		return Integer.parseInt(next());
    	}
    	
    	int [] readArray(int n) {
    		int [] a = new int[n];
    		for(int i=0; i<n ; i++) a[i] = nextInt();
    		return a;
    	}
    	
    	long nextLong() {
    		return Long.parseLong(next());
    	}
    	
    	
    }
    
   
}



Measured memory_bytes: 32400
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 101;

int dp[maxn];

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

    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0] = 1000;
    for (int i = 1; i <= n; i++) {
        int mx = 0;
        for (int j = 0; j <= i; j++) {
            mx = max(mx, dp[j]);
        }
        int cnt = mx / a[i];
        for (int j = i + 1; j <= n; j++) {
            if (a[j] > a[i]) {
                dp[j] = max(dp[j], cnt * a[j] + mx % a[i]);
            }
        }
    }
    int ans = 1000;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;
int main() {
	int machi[4] = {0, 0, 0, 0};

	int a, b;
	for(int i = 0; i < 3; i++){
		cin >> a >> b;
		machi[a - 1]++;
		machi[b - 1]++;
	}

	for (int i = 0; i < 4; i++) {
		if (machi[i] >= 3){
			cout << "NO";
			return 0;
		}
		
		if (machi[i] == 0) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int X = getint(), Y = getint(), A = getint(), B = getint(), C = getint();

	int abc[400000];
	auto a = abc;
	auto b = abc + A;
	auto c = abc + A + B;

	rep(i, A + B + C) a[i] = getint();

	nth_element(a, b - X, b);
	nth_element(b, c - Y, c);
	if (X + Y > B) memcpy(b, b - X, (B - Y) * sizeof(int));
	else memcpy(c - X - Y, b - X, X * sizeof(int));
	nth_element(c - X - Y, c + C - X - Y, c + C);

	ll kotae = 0;
	for (auto kari = c + C - X - Y; kari < c + C; kari++) kotae += *kari;
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int dp[maxn];
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        dp[i] = 0;
    }
    for(int i=2; i<=n; i++)
    {
        if(a[i]<=a[i-1])
            dp[i] = dp[i-1] + 1;
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        ans = max(ans,dp[i]);
    }
    printf("%d",ans);
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>

typedef long long ll;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<ll> sx(n);
  std::vector<ll> sy(n);
  std::vector<ll> cx(m);
  std::vector<ll> cy(m);

  for (int i = 0; i < n; i++) {
    std::cin >> sx[i] >> sy[i];
  }
  for (int i = 0; i < m; i++) {
    std::cin >> cx[i] >> cy[i];
  }

  for (int i = 0; i < n; i++) {
    ll min = -1;
    ll min_idx = -1;
    for (int j = 0; j < m; j++) {
      if (j == 0) {
        min = std::abs(sx[i] - cx[j]) + std::abs(sy[i] - cy[j]);
        min_idx = 0;
      } else {
        ll tmp_min = std::abs(sx[i] - cx[j]) + std::abs(sy[i] - cy[j]);
        if (tmp_min < min) {
          min = tmp_min;
          min_idx = j;
        }
      }
    }
    std::cout << min_idx + 1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
loop do
    a, b, d = gets.split.map(&:to_i)
    break if a == 0 && b == 0 && d == 0
    l = 0
    r = d
    x = y = 0
    while (r - l) % b != 0
        x += 1
        l += a
    end
    y = ((r - l) / b).abs
    l = 0
    r = d
    x2 = y2 = 0
    while (r - l) % a != 0
        y2 += 1
        l += b
    end
    x2 = ((r - l) / a).abs
    x, y = x2, y2 if x2 + y2 < x + y || a * x2 + b * y2 < a * x + b * y
    l = 0
    r = d
    x2 = y2 = 0
    while l <= d
        if (r - l) % b == 0
            y2 = (r - l) / b
            x, y = x2, y2 if x2 + y2 < x + y || a * x2 + b * y2 < a * x + b * y
        end
        x2 += 1
        l += a
    end
    puts [x,y] * " "
end

Measured memory_bytes: 6124
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	x := scanInts(5)
	answer := findZero(x)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	fmt.Println(a...)
}

func findZero(x []int) int {
	for i := 0; i < len(x); i++ {
		if x[i] == 0 {
			return i + 1
		}
	}
	return -1
}


Measured memory_bytes: 1756
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')

    @cc.export('is_ok', '(u8[:],u8[:],u8,u8)')
    def is_ok(A, F, x, k):
        tmp = 0
        for a, f in zip(A, F):
            y = a * f
            if y > x:
                tmp += a - x // f
        return tmp <= k

    cc.compile()
    sys.exit()
from my_module import is_ok

n, k = map(int, input().split())
A = np.array(input().split(), dtype="u8")
F = np.array(input().split(), dtype="u8")

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 12
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 52088
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

fact = [1] * (n + 1)
revfact = [1] * (n + 1)
for i in range(n):
    fact[i + 1] = ((i + 1) * fact[i]) % mod
revfact[n] = pow(fact[n], mod - 2, mod)
for i in reversed(range(n)):
    revfact[i] = ((i + 1) * revfact[i + 1]) % mod
def combination(n, k, p):
    return (fact[n] * revfact[k] * revfact[n - k]) % p

a.sort()
max_x = 0
min_x = 0
for i in range(n - k + 1):
    temp = combination(k - 1 + i, k - 1, mod)
    max_x += (temp * a[k - 1 + i])
    min_x += (temp * a[n - k - i])
    max_x %= mod
    min_x %= mod
print((max_x - min_x) % mod)

Measured memory_bytes: 15320
#include<iostream>
#include <stdio.h>
using namespace std;
int main(){
    int a,b,ans;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        
        if (op == '?'){break;
        
        }else if(op == '+'){
            ans = a + b;
            
        }else if(op == '-'){
            ans = a - b;
            
        }else if(op == '*'){
            ans = a * b;
            
        }else if(op == '/'){
            ans = a / b;
        }
        
        cout << ans << endl;
    }
    return 0;
}



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

// int -> string の変換
string i_to_s(int n){
	string s;
	do{
		s.push_back( (n%10)+'0' );
		n /= 10;
	}while( n != 0 );
	reverse( s.begin() , s.end() );
	return s;
}

// string -> int の変換
int s_to_i(string s){
	int n = 0;
	for(int i=0 ; i < s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}


int main(){
	string a_0;
	int l;
	// 初項 a_0 と 桁数 l の入力
	while( cin >> a_0 >> l ){
		if( a_0 == "0" && l == 0 ) break;
		
		int ans_i, ans_j, ans_a;
		string a[21];
		a[0] = a_0;
		// m[n] := 値 n が何番目の項か返すようにメモしていく.
		map<string,int> m;
		
		// 桁数が l になるまで先頭に 0 をつける.
		while( a[0].size() < l ) a[0] = "0" + a[0];
		
		// a[0] は 0 番目の項
		m[ a[0] ] = 0;
		
		sort( a[0].begin() , a[0].end() );
		// A := 並び替えたときの小さい方
		int A = s_to_i( a[0] );
		// B := 並び替えたときの大きい方
		reverse( a[0].begin() , a[0].end() );
		int B = s_to_i( a[0] );
		// a[1] が決まる.
		a[1] = i_to_s( B - A );
		
		// a[i] == a[j](j < i) となる a[j] がみつかるまで数列を計算する. 
		for(int i=1 ; ; i++ ){
			// 桁数が l になるまで先頭に 0 をつける.
			while( a[i].size() < l ) a[i] = "0" + a[i];
			
			if( m.count(a[i]) ){ // a[i] == a[j](j < i) となる a[j] が存在するとき.
				ans_a = s_to_i( a[i] );
				ans_i = i;
				ans_j = m[ a[i] ];
				break;
			}else{
				m[ a[i] ] = i;
			}
			// A := 並び替えたときの小さい方
			sort( a[i].begin() , a[i].end() );
			int A = s_to_i( a[i] );
			// B := 並び替えたときの大きい方
			reverse( a[i].begin() , a[i].end() );
			int B = s_to_i( a[i] );
			// a[i+1] が決まる.
			a[i+1] = i_to_s( B - A );
		}
		// 解の出力.
		cout << ans_j << " " << ans_a << " " << (ans_i - ans_j) << endl;
	}
}

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


namespace _20180502_pra
{
    class Program
    {
        static void Main(string[] args)
        {

            // var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var input = Console.ReadLine().Split(' ');
            var dislikenumber = Console.ReadLine().Split(' ');

            var answer = 0;
            //var flag = false;
            //for (int i = int.Parse(input[0]); i <= 99999; i++)

                for(int j = 0; j< dislikenumber.Length; j++)
                {

                    if (input[0].Contains(dislikenumber[j]))
                    {
                    
                    input[0] = (int.Parse(input[0]) + 1).ToString();
                    j = -1;
                    }
                }
                Console.WriteLine(input[0]);


 

        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int b = 1000000010;
		for (int i = 0; i < n - 1; i++) {
			if (Math.abs((double) a[n - 1] / 2 - (double) a[i]) < Math.abs((double) a[n - 1] / 2.0 - (double) b)) {
				b = a[i];
			}
		}
		System.out.println(a[n - 1] + " " + b);

	}
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int col[35][35];

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

    int n, c;
    cin >> n >> c;
    for(int i = 1; i <= c; ++i) {
        for(int j = 1; j <= c; ++j) {
            cin >> col[i][j];

        }
    }

    int grid[505][505];
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            cin >> grid[i][j];

        }
    }
    vector<int> mod[3];
    for(int i = 0; i < 3; ++i) {
        for(int j = 1; j <= c; ++j) {
            int sum = 0;
            for(int k = 1; k <= n; ++k) {
                for(int l = 1; l <= n; ++l) {
                    if((k + l) % 3 == i) sum += col[grid[k][l]][j];

                }
            }
            mod[i].pb(sum);
        }
    }

    int res = INF;
    for(int i = 0; i < c; ++i) {
        for(int j = 0; j < c; ++j) {
            for(int k = 0; k < c; ++k) {
                if(i == j || j == k || i == k) continue;
                res = min(res, mod[0][i] + mod[1][j] + mod[2][k]);

            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1280
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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 pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    V vec1(n+1);
    V vec2(m+1);
    rep(i, n) cin >> vec1[i];
    rep(i, m) cin >> vec2[i];
    sort(all(vec1),greater<ll>());
    sort(all(vec2),greater<ll>());
    ll sum = 1;
    ll s=0;
    ll t=0;
    for (int i = n * m; i >= 1; i--)
    {
        if(vec1[s]>i){
            cout<<0<<endl;
            return 0;
        }
        if(vec2[t]>i){
            cout<<0<<endl;
           // cout<<"hello"<<endl;
            return 0;
        }
        
        ll temp=1;
        if (vec1[s]==i && vec2[t]==i)
        {
            temp=1;
            s++;t++;
        }
        else if (vec1[s]==i)
        {
            temp=t;
            s++;
        }
        else if (vec2[t]==i)
        {
            temp=s;
            t++;
        }else{
            temp=(s*t)-(n*m-i);
            if(temp<=0){
                cout<<0<<endl;
                return 0;
            }
        }
        sum*=temp;
        sum%=MOD;
      //  cout<<i<<" "<<s<<" "<<t<<" "<<sum<<endl;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); 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) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;

int n;
int main(void) {
	cin >> n;
	int tm;
	map<int, int> mp;
	rep(i, n) {
		cin >> tm;
		mp[tm]++;
	}
	vector<ll> vc;
	int cnt = 0;
	for(auto kv:mp){
		if (mp[kv.first] > 1) {
			vc.push_back(kv.first);
			cnt++;
		}
	}
	if (cnt < 2) {
		cout << 0 << endl;
	}
	else {
		sort(all(vc));
		if (mp[vc[vc.size() - 1]] >= 4) {
			cout << vc[vc.size() - 1] * vc[vc.size() - 1] << endl;
		}
		else {
			cout << vc[vc.size() - 1] * vc[vc.size() - 2] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(void)
{
  int X;
  cin >> X;
  int iBuf;
  int ans;
  iBuf = X %2;
  ans = X /2;
  if(iBuf == 1)
  {
    cout << ans+1 << endl;
  }
  else
  {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d)cout<<"Left"<<endl;
  else if(a+b==c+d)cout<<"Balanced"<<endl;
  else cout<<"Right"<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S = input()
stack = []
ans = 0
for ch in S:
    if len(stack) == 0 or stack[-1] == ch:
        stack.append(ch)
    else:
        ans += 2
        # stack = stack[:-1]  # 遅い??
        del stack[-1]
print(ans)




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

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        string s[n];
        int t[n];
        for(int i = 0; i < n; i++)  cin >> s[i] >> t[i];
        int ans = 0;
        while(m-- > 0){
            string k;   cin >> k;
            for(int i = 0; i < n; i++){
                int cnt = 0;
                for(int j = 0; j < 8; j++)  if(s[i][j]=='*' || s[i][j]==k[j])   cnt++;
                if(cnt == 8)    ans += t[i];
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
	int yama[10];
	// int first = 0;
	// int second = 0;
	// int third = 0;

	for(int i=0; i<10; i++){
		cin >> yama[i];
	// 	if(yama[i] > first){
	// 		third = second;
	// 		second = first;
	// 		first = yama[i];
	// 	}
	// 	if(yama[i] > second && yama[i] < first)second = yama[i];
	// 	if(yama[i] > third && yama[i] < second)third = yama[i];
	}

	// cout << first << endl;
	// cout << second << endl;
	// cout << third << endl;
	
	int one,two;//??????????????¨
	for(int k=0; k<10; k++){
		for(int i=0; i<9; i++){
			if(yama[i] > yama[i+1]){
				one = yama[i];
				two = yama[i+1];
				yama[i] = two;
				yama[i+1] = one;

				// for(int j=0; j<10; j++){
				// cout << yama[j] << " ";
				// }
				// cout << endl;
			}
		}
	}

	cout << yama[9] << endl;
	cout << yama[8] << endl;
	cout << yama[7] << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <climits>

using namespace std;

struct Card {
    char suit;
    int num;
};

int partition(Card A[], int p, int r) {
    int x = A[r].num;
    int i = p - 1;
    for(int j = p; j < r; j++) {
        if(x >= A[j].num) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quickSort(Card A[], int p, int r) {
    if(p < r) {
        int x = partition(A, p, r);
        quickSort(A, p, x - 1);
        quickSort(A, x + 1, r);
    }
}

void merge(Card A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    Card L[n1 + 1], R[n2 + 1];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].num = INT_MAX;
    R[n2].num = INT_MAX;
    int l = 0, r = 0;
    for (int i = left; i < right; i++) {
        if (L[l].num <= R[r].num) A[i] = L[l++];
        else A[i] = R[r++];
    }
}

void mergeSort(Card A[], int left, int right) {
    if(right > 1 + left) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

bool isStable(Card A1[], Card A2[], int n) {
    for(int i = 0; i < n; i++) {
        if(A1[i].suit != A2[i].suit) return false;
    }
    return true;
}


int main() {
    int n;
    cin >> n;
    Card A1[n], A2[n];
    for(int i = 0; i < n; i++) cin >> A1[i].suit >> A1[i].num;
    for(int i = 0; i < n; i++) {A2[i].suit = A1[i].suit; A2[i].num = A1[i].num;}

    quickSort(A1, 0, n - 1);
    mergeSort(A2, 0, n);

    if(isStable(A1, A2, n)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    for(int i = 0; i < n; i++) {
        cout << A1[i].suit << " " << A1[i].num << endl;
    }
}


Measured memory_bytes: 5340
n,k = map(int, input().split())

def base(n, b):
    k = 97 + abs(b - 10)
    dic= {}
    k2 = ""
    k3 = 10
    for i in range(97, k +1):
        dic[k3] = chr(i)
        k3 +=1
    while n>=b:
        mod= int(n%b)
        n = int(n//b)
        if mod in dic.keys():
            k2 += dic[mod]
            continue
        k2 += str(mod)
    k2 += dic[n] if n in dic.keys() else str(n)
    return k2[::-1]
print(len(base(n, k)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    set<int> s;
    rep(i, N){
        int a;
        cin >> a;
        s.insert(a);
    }
    if(s.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

vector<mint> modpow(200000);

mint f(int k) {
    if (k == 0) return modpow[0] = 1;
    if (modpow[k].a != 0) return modpow[k];
    return modpow[k] = f(k-1)*k;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;

    int m = M;
    map<int, int> dic;
    for (int i = 2; i*i <= M; i++) {
        while (m % i == 0) {
            dic[i]++;
            m /= i;
        }
    }
    if (m != 1) dic[m]++;
    
    mint ans = 1;
    for (auto i : dic) {
        ans *= (f(N+i.second-1) / (f(N-1)*f(i.second)));
    }

    cout << ans.a << endl;



}

Measured memory_bytes: 4224
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
typedef long long ll;
int n,k;
ll num[MAXN],ans;
int main(){
	SF("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		num[i%k]++;
	for(int i=0;i<k;i++)
		if((k-i+k-i)%k==0)
			ans+=num[i]*num[(k-i)%k]*num[(k-i)%k];
	PF("%lld",ans);
}	

Measured memory_bytes: 896