akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

int increase(vector<int>& a, int i) {
    int res = 0;
    while(a[i] <= a[i + 1] && i < a.size()) {
        res++;
        i++;
    }
    return res;
}

int decrease(vector<int>& a, int i) {
    int res = 0;
    while(a[i] >= a[i + 1] && i < a.size()) {
        res++;
        i++;
    }
    return res;
}

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int i = 0;
    int ans = 0;
    while(i < n) {
        int step = (increase(a, i) > decrease(a, i) ? increase(a, i) : decrease(a, i));
        i += step + 1;
        ans++;
    }

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector< int > >;
using pi = pair<int,int>;
using st = set<int>;
using kiwi = queue<int>;
using mp = map<int,int>;
using ump = unordered_map<int,int>;
#define MOD 1000000007
const ll mx = 1e5+123;
#define REP(i,n) for (ll i=1;i<=n;++i)

#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

#define dbg(args...) do {cerr<<#args<<" : "; faltu(args); } while(0)
void faltu ()  {        cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr<<arg<< ' ';faltu(rest...);}

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    string za; cin>>za;

    for(ll i=0;i<=za.size()-3;++i)
    {
        if((za[i]>=97&&za[i]<=122)&&(za[i+1]>=97&&za[i]<=122)&&(za[i+2]>=97&&za[i]<=122)){cout<<za.substr(i,3)<<endl; return 0;
        }
    }

return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define INT long long
#define oo 987654231
using namespace std;
INT n, m;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    if( n == 1 and m == 1 ) cout<<1<<endl;
    else if( n == 1 ) cout<<max(0ll, m-2)<<endl;
    else if( m == 1 ) cout<<max(0ll, n-2)<<endl;
    else cout<<(n-2)*(m-2)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 /*
 int stringToint(const string S)
 {  
    int result=0;
    if(S[0]=='-')
    {
      for(int i=1;i<S.length();i++)
      {
        result=10*result+(S[i]-'0');        
      }             
      result=-result;
    }
    else
    {
      for(int i=0;i<S.length();i++)
      { 
        result=10*result+(S[i]-'0');      
      }
    }  
    return result;  
 }  
 */
 
 int main()
 {
   string s;
   string word;
   stack<double> mm;   
   while(cin>>word)
   {    
       if(word=="+"||word=="-"||word=="*"||word=="/")
       {
         double a=mm.top();
         mm.pop();
         double b=mm.top();
         mm.pop();
         double result;
         if(word=="+") result=b+a;
         else if(word=="-") result=b-a;
         else if(word=="*") result=b*a;
         else result=b/a;
         mm.push(result);     
       }
       else 
       {
         //double kk=1.0*(stringToint(word));
         mm.push(atoi(word.c_str()));
         //mm.push(kk);                                                          
       }  
       if(getchar()=='\n')
       {     
         double final_result=mm.top();
         printf("%.10lf\n",final_result);
         mm.pop();
       }           
   }  
   //while(1);
   return 0;
 }

 
  

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std; 
int main()
{
  int a=0,b=0;
  string s;

  cin>>s;

  for(int i=0;i<s.size();i++){
    if(s[i]=='0') a++;
    else b++;
  }

  cout<<min(a,b)*2<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int numberCount = sc.nextInt();
        int count = 0;
        while (numberCount-- > 0) {
            long number = sc.nextLong();
            while (number % 2 == 0) {
                number /= 2;
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 33616
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int M = Integer.parseInt(st.nextToken());
         int[] arr = new int[N+1];
         Arrays.fill(arr,-1);
         boolean bad = false;
         for(int i=0; i < M; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            if(arr[a] != -1 && arr[a] != b)
               bad = true;
            arr[a] = b;
         }
         if(bad)
            System.out.println(-1);
         else
         {
            if(arr[1] == 0 && N >= 2)
               System.out.println(-1);
            else
            {
               int[] res = new int[N+1];
               res[1] = arr[1];
               if(res[1] == -1)
                  res[1] = 1;
               for(int i=2; i <= N; i++)
                  res[i] = Math.max(0,arr[i]);
               String lol = "";
               for(int i=1; i <= N; i++)
                  lol+=res[i];
               if(arr[1] <= 0 && N == 1)
                  lol = "0";
               System.out.println(lol);
            }
         }
      }
   }

Measured memory_bytes: 21332
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int MAXN = 200010;
struct UnionFind {
    int node[MAXN];
    UnionFind() {
        memset(node, -1, sizeof(node));
    }
    int find(int x) {
        return node[x] < 0 ? x : node[x] = find(node[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return;
        node[x] += node[y];
        node[y] = x;
    }
};
 
UnionFind road, rail;
signed main() {
    int N, K, L; cin >> N >> K >> L;
    for(int i=0; i<K; i++) {
        int u, v; cin >> u >> v;
        road.unite(u, v);
    }

    for(int i=0; i<L; i++) {
        int u, v; cin >> u >> v;
        rail.unite(u, v);
    }

    map< pair<int, int>, int > hash;
    for(int i=1; i<=N; i++) {
        int A = road.find(i), B = rail.find(i);
        hash[ make_pair(A, B) ]++;
    }

    for(int i=1; i<=N; i++) {
        int A = road.find(i), B = rail.find(i);
        int ans = hash[ make_pair(A, B) ];

        printf("%lld%c", ans, " \n"[i==N]);
    }
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int32> cnt(3,0);
    REP(i,s.size())cnt[s[i]-'a']++;
    // REP(i,3)ANS(cnt[i]);
    YES(*max_element(ALL(cnt)) - *min_element(ALL(cnt)) < 2);
    return 0;
}

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

int ss(int x){
    int n, t = 0;
    if(x % 3 == 0)
    t = 1;
    do{
        if(x % 10 == 3){
            t = 1;
            break;
        }
        x /= 10;
    } 
    while(x);
    return t;
}
int main(){
    int x, n;
    scanf("%d", &n);
    int t;
    for(x = 3; x <= n; x++){
        t = ss(x);
        if(t == 1)
        printf(" %d",x);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;

int main() {
	string t = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans += (t[i] != s[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<double> dp(n), tmp(n);
    vector<vector<int>> g(n);
    vector<pair<int, int>> e(m);
    rep(i, 0, m) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        e[i] = {s, t};
        g[s].emplace_back(t);
    }
    for (int i = n - 2; i >= 0; i--) {
        double res = 0, cnt = 0;
        for (int j : g[i]) {
            res += dp[j];
            cnt++;
        }
        if (cnt == 0) continue;
        dp[i] = res / cnt + 1;
    }
    tmp = dp;
    for (int i = n - 2; i >= 0; i--) {
        double mx = 0, sum = 0;
        for (int j : g[i]) {
            mx = max(mx, dp[j]);
            sum += dp[j];
        }
        if (g[i].size() > 1) {
            tmp[i] = (sum - mx) / (g[i].size() - 1) + 1;
        }
    }
    debug(dp, tmp);
    double ans = tmp[0];
    rep(t, 1, n - 1) {
        vector<double> x = dp;
        x[t] = tmp[t];
        for (int i = t - 1; i >= 0; i--) {
            double res = 0, cnt = 0;
            for (int j : g[i]) {
                res += x[j];
                cnt++;
            }
            if (cnt == 0) continue;
            x[i] = res / cnt + 1;
        }
        ans = min(ans, x[0]);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 2816
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll l[87];
    l[0] = 2;
    l[1] = 1;
    for(ll i = 2; i < 87; i++){
        l[i] = l[i - 2] + l[i - 1];
    }

    cout << l[N] << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    ll cnt = 0;
    for (ll i = 100; i>=1; i--){
        if(a%i == 0 && b%i == 0){
            cnt++;
            if(cnt == k){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       s: String,
    }

    let mut ans: usize = 0;
    if s == "ABC" {
        echo!("ARC");
    } else {
        echo!("ABC");
    }
}


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {

            var s = Console.ReadLine();
            var key = true;
            var ans = "";

            for(int i = 0; i < s.Length/2; i++)
            {
                if (s[i] != s[s.Length - 1 - i])
                {
                    //Console.WriteLine("n1 " + i);
                    key = false;
                }
            }

            for (int i = 0; i < (s.Length-1) / 4; i++)
            {
                if (s[i] != s[(s.Length - 1) / 2 - 1-i])
                {
                    //Console.WriteLine("n2 " + i);
                    key = false;
                }
            }

            for (int i = (s.Length+1)/2; i < s.Length; i++)
            {
                if (s[i] != s[s.Length - 1 - i])
                {
                   // Console.WriteLine("n3 " + i);
                    key = false;
                }
            }

            if (key) ans = "Yes";
            else ans = "No";

                Console.WriteLine(ans);




        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public ulong[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            ulong[] res = new ulong[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = ulong.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 13140
/*input
1
*/
#include "bits/stdc++.h"
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long x; cin >> x;
	for(long long b = -3e3; b <= 3e3; ++b){
		long long k = x + b*b*b*b*b;

		for(long long a = -4e3; a <= 4e3; ++a)
			if(a*a*a*a*a == k)
				return cout << a << ' ' << b << endl,0;
	}
}

Measured memory_bytes: 3648
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
ans = 0
red = sorted(red, key = lambda x:x[1] * -1)
blue = sorted(blue)
for b in blue:
	for r in red:
		if b[0] > r[0] and b[1] > r[1]:
			ans += 1
			red.remove(r)
			break
print(ans)

Measured memory_bytes: 3064
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>

using namespace std ;

typedef long long ll ;

// }}}

int P[222222];
int dp[222222];

int main()
{
    int N, K;
    cin >> N >> K;
    for (int i = 0 ; i != N ; i++)
        scanf("%d", P+i);
    dp[0] = 1;
    for (int i = 1 ; i < N ; i++) {
        if (P[i] > P[i-1])
            dp[i] = dp[i-1]+1;
        else
            dp[i] = 1;
    }
    set<int> S;
    for (int i = 1 ; i < K ; i++)
        S.insert(P[i]);
    int l = 0, r = K;
    int cnt = 0;
    bool asc = false;
    if (dp[K-1] == K) {
        asc = true;
    }
    cnt++; // for [0, K-1]
    while (r < N) {
        if (P[l] < *S.begin() && *S.rbegin() < P[r])
            ; // shift doesn't perturb
        else {
            if (!asc && dp[r] >= K) {
                cnt++;
                asc = true;
            }
            if (dp[r] < K)
                cnt++;
            else
                ; // already counted
        }
        l++;
        S.erase(P[l]);
        S.insert(P[r]);
        r++;
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 11136
N = int(input())
S = input()

ans = 0
len_s = 1
for i in range(N):
    tmp_s = S[i:i+len_s]
    while tmp_s in S[i+len_s:]:
        len_s += 1
        tmp_s = S[i:i+len_s]
        ans += 1
print(ans)


Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	v := iSScan(n)
	c := iSScan(n)
	ans := 0
	for i := 0; i < n; i++ {
		ans += larger(0, v[i]-c[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll n, i, ans = 0, cnt = 1;
	cin >> n;
	vl a(n);
	rep(i, 0, n)
		cin >> a[i];
	sort(rall(a));
	ans += a[0];
	i = 1;
	while(cnt + 2 <= n - 1)
	{
		ans += (2LL * a[i]);
		i++;
		cnt += 2;
	}
	if(cnt != (n - 1))
		ans += a[i];
	cout << ans << endl;
}

Measured memory_bytes: 4784
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	
	string s;


    cin >> s;
    
	(s[0] == 'Y' &&  s[1] == 'A' && s[2] == 'K' && s[3] == 'I' )? Yes :No ;

	return  0;
}

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

int N, C, K;
int T[100010];

int comp(const void * p1, const void * p2) {
	return *(int *)p1 - *(int *)p2;
}

int main(void) {
	int i, first, count, ans = 0;
	scanf("%d%d%d", &N, &C, &K);
	for (i = 0; i < N; i++) {
		scanf("%d", &T[i]);
	}
	qsort(T, N, sizeof(int), comp);

	first = T[0];
	count = 1;
	for (i = 1; i < N; i++) {
		if (T[i] - first > K || count >= C) {
			first = T[i];
			count = 1;
			ans++;
		}
		else
			count++;
	}
	ans++;
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 892
#N = map(int, input())
N = int(input())
A_list = list(map(int, input().split()))



res_list = [0] * N

syu = 1
for a in A_list:
        res_list[a-1]  = syu
        syu+=1

#print(res_list)

print(' '.join(map(str, res_list)))

Measured memory_bytes: 18372
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
    int n;
    std::cin >> n;
    std::vector<std::string> s(n);
    rep(i,n) std::cin >> s[i];
    std::sort(all(s));
    int max=0;
    for(int i=0;i<n;) {
        int start=i;
        while(i<n && s[i]==s[start]) i++;
        max=std::max(max,i-start);
    }
    for(int i=0;i<n;) {
        int start=i;
        while(i<n && s[i]==s[start]) i++;
        if(i-start==max) print(s[start]);
    }
	return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define f(i,a, b) for (int i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ld float
#define fd(i,a, b) for (ll i = a; i >= b; i--)

 /*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
bool chk(string ss){

   int sz=ss.size();
   f(i,0,sz/2)if(ss[i]!=ss[sz-1-i])return false;
   return true;

}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   string ss;
   cin>>ss;
   int sz=ss.size();

   if( chk(ss.substr(0, (sz-1)/2)) && chk(ss) && chk(ss.substr(((sz+3)/2)-1,(sz+5)/2)) )
      cout<<"Yes";
      else cout<<"No";


}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b, allSum int
	fmt.Scan(&n, &a, &b)
	for i := 0; i <= n; i++ {
		v := i
		digitSum := 0
		for v > 0 {
			digitSum += v % 10
			v /= 10
		}
		if a <= digitSum && digitSum <= b {
			allSum += i
		}
	}
	fmt.Println(allSum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <tuple>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    int n;
    cin >> n;

    vector<LL> A(n, 0);

    REP(i, n) {
        cin >> A[i];
    }

    int res = 0;

    sort(ALL(A));
    set<tuple<LL, LL, LL>> s;

    for(int i = 0; i < n - 2; ++i) {
        for(int j = i + 1; j < n - 1; ++j) {
            for(int k = j + 1; k < n; ++k) {
                if (A[i] != A[j] && A[j] != A[k] && A[i] + A[j] > A[k]) {
                    // auto t = make_tuple(A[i], A[j], A[k]);
                    res++;
                    // if (s.find(t) == s.end()) {
                    //     s.insert(t);
                    //     res++;
                    // }
                }
            }
        }
    }

    cout << res << endl;

}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double N,K,S=0.0;
    cout<<fixed<<setprecision(12);
    cin>>N>>K;
    vector<double> pn(N+1);
    for(int i=1;i<N+1;i++){
        if(i>=K){
            S+=(N-K+1)/N;
            break;
        }
        else{
            int t=(K-1)/i;
            double p=1/N;
            while(t>0){
                t=t/2;
                p=p/2;
            }
            pn.at(i)=p;
        }
        S+=pn.at(i);
    }
    cout<<S<<endl;
}


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

using namespace std;

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

int main()
{
  int N; cin >> N;
  int x[9] = {111,222,333,444,555,666,777,888,999,};
  rep(i,9)
  {
    if (x[i] >= N)
    {
      cout << x[i] << endl;
      break;
    }
  }
  return 0;
}


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

#define PB emplace_back
#define mid ((be+en)/2)
#define cl c*2
#define cr cl+1

using namespace std;

const int N = (1e5+100)*16;

long long int mx[N], dp[N], h[N], a[N], n;

long long int que(int l, int r, int be=0, int en=n, int c=1) {
    if(r<=be||en<=l)return 0;
    if(l<=be&&en<=r)return mx[c];
    return max(que(l,r,be,mid,cl),que(l,r,mid,en,cr));
}

long long int up(int l, long long int val, int be=0, int en=n, int c=1) {
    if(be+1==en) mx[c]=val;
    else if(l<mid)up(l,val,be,mid,cl);
    else up(l,val,mid,en,cr);
    if(be+1!=en)mx[c]=max(mx[cl],mx[cr]);
}

int main () {
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) cin >> h[i];
    for(int i = 0 ; i < n ; i++ ) cin >> a[i];
    for(int i = 0 ; i < n ; i++ ) {
        long long int xm = que(0,h[i]);
        up(h[i],xm+a[i]);
    }
    cout << que(0,*max_element(a,a+n)+1);
}


Measured memory_bytes: 9984
// abc098_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    REPN(i, 1, N){
        string a = S.substr(0, i);
        string b = S.substr(i, N-i);

        set<int> st;
        REP(k, i){
            if (b.find(a[k]) != string::npos){
                st.insert(a[k]);
            }
        }
        ans = max(ans, (int)st.size());
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 256
rooms = [[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],
         [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
         ]
n = int(input())
for i in range(n):
    b, f, r, v = map(lambda x: int(x), input().split(" "))
    B, F, R = b - 1, f - 1, r - 1
    new = rooms[B][F][R] + v
    rooms[B][F][R] = new < 0 if 0 else new
for i in range(4):
    if 0 < i:
        print("####################")
    for j in range(3):
        print(" " + " ".join(map(lambda x: str(x), rooms[i][j])))



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

vector<int> input(int N){
    int i;
    vector<int> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

void disp(vector<int> cave,int tail){
    int i;
    for(i=0;i<=tail;i++)cout<<cave[i]<<" ";
    cout<<endl;
}

int main(){
    int L,i;
    int tail=0;
    int result=-1;
    vector<int> list,cat_in(100),cave(100);

    cin>>L;
    list=input(L);

    for(i=0;i<L;i++){
        if(list[i]<0){
            list[i]=abs(list[i]);
            if(cave[tail-1]!=list[i] || cat_in[list[i]-1]==0){
                result=i+1;
                break;
            }else{
                cat_in[list[i]-1]=0;
                tail-=1;
            }
        }else{
            if(cat_in[list[i]-1]==1){
                result=i+1;
                break;
            }else{
                cave[tail]=list[i];
                cat_in[list[i]-1]=1;
                tail+=1;
            }
        }
    }

    if(result==-1){
        cout<<"OK"<<endl;
    }else{
        cout<<result<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); }
ll freq[2005]; 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	// cout<<0<<endl;
	while(t--){
		ll k;
		cin>>k;
		zero(freq);
		ll ans=0;
		for(int i=1;i<=k;i++){
			for(int j=1;j<=k;j++){
				freq[__gcd(i,j)]++;
			}
		}
		for(int i=1;i<=k;i++){
			for(int j=1;j<=k;j++){
				ans+=(freq[i]*(__gcd(i,j)));
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3568
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <numeric> 
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;
 
int main() {
    ll a,b,c; cin >> a >> b >> c;
  	string ans = ( c-a-b>0 && ( 4*a*b < (c-a-b)*(c-a-b) ) ? "Yes":"No");
  	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int H, A;
  cin >> H >> A;
  int ans = 0;
  while(H > 0){
      ans++;
      H -= A;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int x;
    int count;
    rep(i,5){
        cin >> x;
        if(x==0){
            cout << i+1 << endl;
        }
    }

}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N+1);
  for(int i = 0; i < N; ++i)
    cin >> A[i];

  for(int i = 0; i < K; ++i){
    vector<int> B(N+1);
    for(int j = 0; j < N; ++j){
      int d = A[j];
      ++B[max(0,j-d)];
      --B[min(N,j+d+1)];
    }
    int mi = N;
    for(int j = 0; j < N; ++j){
      B[j+1] += B[j];
      mi = min(mi,B[j]);
    }
    swap(B,A);
    if(mi >= N) break;
  }
  for(int i = 0; i < N; ++i)
    cout << A[i] << (i+1 < N ? " " : "\n");
}


Measured memory_bytes: 5128
#include <stdio.h>

int main(void){

int c,n,x;
int l=0;
int i,j,k;

for(c=1;c>0;c++){
  scanf("%d %d",&n,&x);
  if(n==0 && x==0){
  break;}
  for(i=1;i<=n;i++){
  //printf("i %d\n",i);
  for(j=i;j<=n;j++){
  //printf("j %d\n",j);
  for(k=j;k<=n;k++){
  //printf("k %d\n",k);
  if(i+j+k==x && i!=j && j!=k){
  /*printf("%d ",i);
  printf("%d ",j);
  printf("%d ",k);
  printf("%d\n",i+j+k);*/
  l++;
  }}}}
  printf("%d\n",l);
  l=0;}
return 0;}


Measured memory_bytes: 2040
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	S := sc.nextStr()
	s := []byte(S)
	s[5] = ' '
	s[13] = ' '

	fmt.Println(string(s))

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


using namespace std;


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n;
	cin >> n;
	long long int k;
	cin >> k;
	long long int arr[n];
	for (long long int i = 0; i < n; i++)
		cin >> arr[i];

	long long int start = 0;
	while (k < n)
	{
		if (arr[start] < arr[k])
		{
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		k++;
		start++;
	}


	return 0;


}

Measured memory_bytes: 5176
c = []
for i in range(3):
    c.append(list(map(int, input().split())))

if c[0][1] + c[1][0] - c[0][0] == c[1][1] \
    and c[0][2] + c[1][0] - c[0][0] == c[1][2] \
    and c[0][1] + c[2][0] - c[0][0] == c[2][1] \
    and c[0][2] + c[2][0] - c[0][0] == c[2][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N;
ll A[81];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];
    A[N]=0;
    
    ll inf=INF, sup=0;
    rep(i,N) inf=min(inf,A[i]);
    rep(i,N) sup=max(sup,A[i]);


    ll ans=1000;
    ll l=0;
    rep(i,N){
        if(A[i]>A[i+1]){
            ll cnt=ans/A[l];
            ans=ans%A[l]+cnt*A[i];
            l=i+1;
        }
    }

    cout<<ans<<endl;
} 

Measured memory_bytes: 3620
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
match = [0,2,5,5,4,5,6,3,7,6]
dp = [0]+[-1]*N

for i in A:
    for j in range(0,N+1):
        if j-match[i] >= 0:
            dp[j] = max(dp[j-match[i]]*10+i,dp[j])
print(dp[-1])


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

int main()
{
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int ans = 0;
	for (int i = 0; i <= a; i++)
	{
		for (int j = 0; j <= b; j++)
		{
			for (int k = 0; k <= c; k++)
			{
				if (500 * i + 100 * j + 50 * k == x)
				{
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int N;

bool is_prime(int n){
    for(int i = 2; i * i <= n; ++i){
        if(n % i == 0) return false;
    }
    return true;
}

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

    int n, ans = 0;
    for(int i = 0; i < N; ++i){
        cin >> n;
        if(is_prime(n)) ++ans;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
  int N;cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  sort(all(A), greater<int>());
  //DEBUG(A);
	queue<int> que;
  ll ans = 0;
  rep(i,N){
    if(i==0){
      que.push(A[i]);
      continue;
    }else{
      ans+= que.front();
      //DEBUG(que.front());
      que.pop();
      que.push(A[i]);
      que.push(A[i]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4764
import java.io.*;
import java.util.*;


public class Main {

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();

        int N = fs.nextInt();
        int M = fs.nextInt();
        int Q = fs.nextInt();

        int[][] queries = new int[Q][4];

        for (int i = 0; i < Q; ++i) {
            for (int j = 0; j < 4; ++j) {
                queries[i][j] = fs.nextInt();
            }
        }



        // generate all increasing sequences of length N where each element is <= M
        int start = 1;
        int length = 0;
        int[] max = new int[1];
        int[] seq = new int[N];
        int[] num = new int[1];
        dfs(seq, start, length, N, M, max, queries, num);


        System.out.println(max[0]);
    }

    private static void dfs(int[] seq, int start, int length, int N, int M, int[] max, int[][] queries, int[] num) {
        if (length == N) {
            num[0]++;
            max[0] = Math.max(max[0], compute(seq, queries));
            return;
        }
        else {
            for (int k = start; k <= M; ++k) {
                seq[length] = k;
                dfs(seq, k, length + 1, N, M, max, queries, num);
            }
        }
    }

    private static int compute(int[] seq, int[][] queries) {
        int sum = 0;
        for (int i = 0; i < queries.length; ++i) {
            if (seq[queries[i][1] - 1] - seq[queries[i][0] - 1] == queries[i][2]) {
                sum += queries[i][3];
            }
        }

        return sum;
    }
}


Measured memory_bytes: 33696
#include<iostream>
using namespace std;
int main(){
    int N,A,B;
    int i,j,k;
    cin>>N>>A>>B;
    int count=0;
    for(i=1;i<=N;i++ ){
    if(A<=i%10+(i/10)%10+(i/100)%10+(i/1000)%10+i/10000&&i%10+(i/10)%10+(i/100)%10+(i/1000)%10+i/10000<=B){
    count+=i;
    }
    }
    cout<<count<<endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 +9;
int n , a[N];
ll ans=0;
int mx;

int main(){

scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",a+i);
    if( a[i] > i ){
        printf("-1\n");
        return 0;
    }
}
mx=a[n-1];

for(int i=n-1;i>0;i--,mx--){
    if( (i!=(n-1)) && ((a[i]+1) == a[i+1]) )continue;
    else {
            ans += 1ll*a[i];

        if( a[i] >= mx )mx=a[i];
        else {
            printf("-1\n");
            return 0;
        }

    }

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

return 0;
}


Measured memory_bytes: 1024