akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main(){
	string str;cin>>str;
	bool ap = false;
	for(int i=0;i<str.length();i++)
		if(str[i]=='C')ap=true;
		else if(str[i]=='F'&&ap){
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
s1 = [input() for i in range(N)]
c1 = Counter(s1)
M = int(input())
s2 = [input() for i in range(M)]
c2 = Counter(s2)

ans = 0
for k,v in c1.items():
    ans = max(ans, v - c2[k])
print(ans)

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(void){
	int m,n,flg[1001],i,j,cnt,h,list[1000],ff,mm,len,p;
	char s[10001][21],f[]="Fizz",b[]="Buzz",fb[]="FizzBuzz";
	while(1){
		cin>>m>>n;
		if(m==0) break;
		for(i=1;i<=m;i++) flg[i]=1;
		for(i=1;i<=n;i++) cin>>s[i];
		cnt=0; p=1;
		for(i=1;i<=n;i++){
			if(m-cnt==1){
//				cout<<i<<endl;
				break;
			}
			if(flg[p]==0){
				while(flg[p]!=1){
					p++;
					if(p>m) p=1;
				}
			}
			if(i%3==0&&i%5==0){
				if(strcmp(s[i],fb)!=0){
					flg[p]=0;
					cnt++;
				}
			}
			else if(i%3==0&&i%5!=0){
				if(strcmp(s[i],f)!=0){
					flg[p]=0;
					cnt++;
				}
			}
			else if(i%5==0&&i%3!=0){
				if(strcmp(s[i],b)!=0){
					flg[p]=0;
					cnt++;
				}
			}
			else{
				mm=atoi(s[i]);
				if(mm!=i){
					flg[p]=0;
					cnt++;
				}
			}
			p++;
		}
		cnt=0;
		for(i=1;i<=m;i++){
			if(flg[i]==1){
				list[cnt]=i;
				cnt++;
			}
		}
		cout<<list[0];
		for(i=1;i<cnt;i++) cout<<' '<<list[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll K) {
  int ans{1};
  for(auto i = 0; i != N; ++i) {
    ans = ans>K ? ans+K : ans*2;
  }
  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	map<int,int> mp1,mp2;
	rep(i,n){
		cin>>a[i];
		mp1[a[i]]++;
		mp2[a[i]%m]++;
	}
	vector<vector<int>> cnt(m);
	for(auto itr:mp1){
		cnt[itr.fi%m].push_back(itr.se);
	}
	rep(i,m){
		sort(begin(cnt[i]),end(cnt[i]),greater<int>());
	}
	int ans=0;
	vector<bool> used(m,false);
	for(auto &itr:mp2){
		int r=itr.fi,now=itr.se;
		if(used[r]) continue;
		used[r]=true;
		used[(m-r)%m]=true;
		if(r==(m-r)%m){
			ans+=mp2[r]/2;
			continue;
		}
		int tar=mp2[m-r];
		if(now>tar){
			mp2[m-r]=0;
			ans+=tar;
			mp2[r]-=tar;
		}else{
			ans+=mp2[r];
			mp2[m-r]-=mp2[r];
			mp2[r]=0;
		}
	}
	rep(i,m){
		if(i==(m-i)%m) continue;
		int ret=mp2[i];
		int now=0;
		for(auto x:cnt[i]){
			if(x>=ret){
				ans+=ret/2;
				break;
			}else{
				ans+=x/2;
				ret-=x/2*2;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15488
#include <iostream>
#include <map>
using namespace std;
int main (void) {
    int N;

    cin >> N;

    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        auto itr = mp.find(a);
        if( itr != mp.end() ) {
            mp[a]++;
        } else {
            mp[a] = 1;
        }
    }

    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->first < itr->second) {
            ans += itr->second - itr->first;
        } else if (itr->first > itr->second) {
            ans += itr->second;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };

int n, ans;
VI pm;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

int main() {
	pm.push_back( 2 );
	for ( int i = 3; i <= 123456 * 2; i += 2 ) {
		bool can_add = true;
		for ( int j = 0; j < pm.size() && pm[ j ] * pm[ j ] <= i; j++ ) {
			if ( !( i % pm[ j ] ) ) {
				can_add = false;
				break;
			}
		}
		if ( can_add ) {
			pm.push_back( i );
		}
	}
	while ( ~scanf("%d", &n) && n ) {
		ans = upper_bound( pm.begin(), pm.end(), 2 * n ) - upper_bound( pm.begin(), pm.end(), n );
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1336
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vint v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	int sum = 0;
	rep(i,n){
		int cnt = 0;
		int t = v[i];
		while(i<n&&t==v[i]){
			i++;
			cnt++;
		}
		i--;
		sum += cnt-1;
	}
	int ans;
	if(sum%2==0){
		ans = n - sum;
	}
	else{
		ans = n - sum - 1;
	}
	cout<<ans<<endl;
}


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

Measured memory_bytes: 768
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
	char c[4];
	cin>>c;
	int tbl[26];
	memset(tbl,0,sizeof(tbl));
	
	for(int i=0; i<strlen(c); i++)
		tbl[c[i]-'A']++;
	
	for(int i=0; i<26; i++)
		if(tbl[i]==1 || tbl[i]==4)
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
s = input()
l = len(s)
ans = 0
for i in range(2 ** (l-1)):
    tmp = ''
    sum = 0
    for j in range(l-1):
        tmp += s[j]
        if i >> j & 1:
            sum += int(tmp)
            tmp = ''
    sum += int(tmp + s[-1])

    ans += sum
print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	string s;
	cin >> s;
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
		PRIY;
	}
	else {
		PRIN;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){

  char	s[4] = {0};
  int	i;

  scanf("%s", s);
  
  if	 ( strcmp(s, "SUN")==0 ){ printf("7"); }
  else if( strcmp(s, "MON")==0 ){ printf("6"); }
  else if( strcmp(s, "TUE")==0 ){ printf("5"); }
  else if( strcmp(s, "WED")==0 ){ printf("4"); }
  else if( strcmp(s, "THU")==0 ){ printf("3"); }
  else if( strcmp(s, "FRI")==0 ){ printf("2"); }
  else if( strcmp(s, "SAT")==0 ){ printf("1"); }

  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args)
    {
        CP sc =new CP();
        int s = sc.nextInt();
        if (s < 3){
            System.out.println(0);
            return;
        }
        long[] ans = new long[s+1];
        for (int i = 3; i<=s; i++){
            ans[i]++;
            for (int j= 3; j<= i-3; j++){
                ans[i] += ans[j];
                ans[i] %= 1000000007;
            }
        }
        System.out.println(ans[s]);
    }
    /*****************************************************************************/
    static class CP
    {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;
        public CP() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }
        int nextInt() {
            return Integer.parseInt(NNNN());
        }
        long nextLong() {
            return Long.parseLong(NNNN());
        }
        double nextDouble() {
            return Double.parseDouble(NNNN());
        }
        String NNNN() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }
        String nextLine() {
            String spl = "";
            try {
                spl = bufferedReader.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return spl;
        }
    }
    /*****************************************************************************/
}

Measured memory_bytes: 32820
/**
 *   Author: Praveen Ojha
 *   Created: 24 March 2019
 *   Time: 21:58:40
**/
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

vector <int> adj[100005];
int dp[100005];
bool visited[100005];
int solve(int x){
	visited[x]=true;
	if(adj[x].size()==0)
		return 0;
	if(dp[x]!=-1)
		return dp[x];
	int maxi=0;
	for(int i=0;i<(int)adj[x].size();i++){
		maxi=max(maxi,solve(adj[x][i]));
	}
	return dp[x]=1+maxi;
}
int32_t main(){__
	int n,m,x,y;
	memset(dp,-1,sizeof dp);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		x--;
		y--;
		adj[x].push_back(y);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(!visited[i])
		ans=max(ans,solve(i));
	}
	cout<<ans<<"\n";
return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  string a,b,c; cin >> a >> b >> c;
  cout << (a.back() == b.front() && b.back() == c.front() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(x,y) 			fixed << setprecision(y) << x
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
#define pr(a) 				cout<<a<<endl;
#define pr2(a,b) 			cout<<a<<" "<<b<<"\n"
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    ll s=0;
    rep(i,1,n+1){
        if (i%3 != 0 and i%5 != 0) s+=i;
    }
    cout << s << endl;
}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#[allow(unused_imports)]
use proconio::{
    fastout, input,
};

#[fastout]
fn main() {
    input! {
        x: i32,
        n: usize,
        p: [i32; n],
    }
    let mut appears = vec![false; 102];
    for value in p {
        appears[value as usize] = true;
    }
    if let Some(ans) = (0 ..= 101).filter(|&k| !appears[k as usize]).min_by_key(|&k| ((k - x).abs(), k)) {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2172
#include <stdio.h>

int main(void) {
	int a, b, c, d, e, f;
	while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) == 6) {
		int det = a*e - b*d;
		int x = e*c - b*f;
		int y = -d*c + a*f;
		printf((x == 0 ? "0.000 " : "%.3f "), x/(double)det);
		printf((y == 0 ? "0.000\n" : "%.3f\n"), y/(double)det);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main (void){
	int x,y,z;
	scanf("%d",&x);//お金
	scanf("%d",&y);//1円の枚数
	z=x/500;
	x=x-500*z;
	if((y-x)>=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int high[10];
	int max, max_2, max_3, max_i, max2_i;
	int i;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &high[i]);
	}
	
	max = 0;
	max_2 = 0;
	max_3 = 0;
	for (i = 0; i < 10; i++){
		 if (high[i] > max){
		 	max = high[i];
			max_i = i;
		 }
	}
	for (i = 0; i < 10; i++){ 
		if (high[i] > max_2){
			if (max_i == i){
			}
			else{
				max_2 = high[i];
				max2_i = i;
			}
		}
	}
	for (i = 0; i < 10; i++){
		if (high[i] > max_3){
			if (max_i == i){
			}
			else if (max2_i == i){
			}
			else {
				max_3 = high[i];
			}
		}
	}
	
	printf("%d\n%d\n%d\n", max, max_2, max_3);
	
	return (0);
}

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

typedef long long ll;

int main(void) {
	ll N;
	cin >> N;
	
	ll ans = N - 1;
	for (ll a = 2; a * a <= N; ++a) {
		if (N % a == 0) {
			ll b = N / a;
			ll tmp = (a - 1) + (b - 1);
			ans = min(tmp, ans);
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
/* B - Distance */

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

int main(){
  int N, cnt = 0;
  long long D, X, Y;
  cin >> N >> D;
  for(int i = 0; i < N; i++){
    cin >> X >> Y;
    if(X * X + Y * Y <= D * D) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3608
A,B,C=[int(x) for x in input().split()]
if A==5 and B==5 and C==7:
    print("YES")
	
elif A==5 and B==7 and C==5:
	print ("YES")
	
elif A==7 and B==C==5:
    print ("YES")
	
else:
	print("NO")

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

using namespace std;

#define pb(x) push_back(x)
#define fr(i, n) for(int i=0; i<n; i++)
#define ll long long

int main() {
    string s, t;
    cin>>s>>t;
    int n = t.length();
    int ans = n;
    for(int i=0; i<=s.length()-n; i++)
    {
        string temp = s.substr(i, n);
        int cur = 0;
        for(int i=0; i<temp.length(); i++)
        {
            if(temp[i] != t[i])
                cur++;
        }
        ans = min(ans, cur);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3604
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int mx=f/(100*a);
    int my=f/(100*a);
    int ansu=0,anss=100*a;
    double ans=0.0;
    for(int x=0;x<=mx;x ++){
        for(int y=0;y<=my;y ++){
            if(x+y==0) continue;
            int xayb=x*a+y*b;
            int mz=(f-100*xayb)/c;
            if(100*xayb>=f) continue;
            for(int z=0;z<=mz;z++){
                if(c*z>xayb*e || 100*xayb+c*z>f) continue;
                int mw=(f-100*xayb-c*z)/d;
                for(int w=0;w<=mw;w++){
                    int czdw=c*z+d*w;
                    if(100*xayb+czdw>f) continue;
                    if(e*xayb<czdw) continue;
                    double ans2=(double)(czdw)/(100*xayb+czdw);
                    if(ans<ans2){
                        ansu=czdw;
                        anss=100*xayb+czdw;
                        ans=ans2;
                    }
                }
            }
        }
    }
    cout<<anss<<" "<<ansu<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 256
gets;s=gets.strip;t=gets.strip;n,m=s.size,t.size;(puts -1;exit)if s[0]!=t[0];e=n.lcm m;h={};n.times{|i|h[i*e/n]=s[i]};m.times{|i|w=h[i*e/m];(puts -1;exit)if w&&w!=t[i]};puts e

Measured memory_bytes: 11772
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 200005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

set<pair<lli,lli>> s;
void solve()
{
    
    lli h,w;
    cin>>h>>w;
    lli m;cin>>m;
    map<lli,lli> row,col;
    for(lli i=1;i<=m;i++)
    {
        lli x,y;
        cin>>x>>y;
        s.insert({x,y});

        row[x]++;
        col[y]++;
    }


    vector<pair<lli,lli> > r,c;

    for(auto i:row)
    {
        r.pb({i.se,i.fi});
    }
    for(auto i:col)
    {
        c.pb({i.se,i.fi});
    }

    sort(all(r),greater<pair<lli,lli>>() );
    sort(all(c),greater<pair<lli,lli>>() );



    // for(auto i:r)
    // {
    //     print2(i.fi,i.se);
    // }
    // er
    // for(auto i:c)
    // {
    //     print2(i.fi,i.se);
    // }

    lli ans=0;

    for(lli i=0;i<sz(c);i++)
    {
        lli ct=0;
        if(s.find({r[0].se,c[i].se})!=s.end())
            ct--;

        ct=ct+(r[0].fi+c[i].fi);

        ans=max(ans,ct);

    }
    for(lli i=0;i<sz(r);i++)
    {
        lli ct=0;
        if(s.find({r[i].se,c[0].se})!=s.end())
            ct--;

        ct=ct+(r[i].fi+c[0].fi);

        ans=max(ans,ct);

    }

    cout<<ans;






    
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 76512
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int x;
	cin >> x;
	if(x)
		cout << "0";
	else
		cout << "1";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h){
    cin >> a[i];
  }
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }
  rep(i,h){
    if(row[i]){
      rep(j,w){
        if(col[j]){
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
/*
Author: Snickeen 
Email : ff@snickeen.com
If you find any bug, please tell me.
*/

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

typedef long long LL;

const LL INF = 1e18+7;
const LL MOD = 1e9+7;
const LL MAXN = 1e6+7;

/////**********************************************/////



signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	LL i,j,k,n,ans=0;
	cin>>n>>k; 
	if(k!=0)for(i=k+1;i<=n;i++)
		ans+=n/i*(i-k)+max(0ll,n%i-k+1);
	else ans=n*n;
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    vector <pair<int,int> > price(n);
    REP(i,n){
        int a,b;
        cin >> a >> b;
        price[i]=make_pair(a,b);
    }

    sort(price.begin(),price.end());
    ll answer=0;
    int j=0;
    REP(i,m){
        if(price[j].second == 0)j++;
        price[j].second--;
        answer+=price[j].first;
    }
    /*REP(i,n){
        cout << price[i].first << " " << price[i].second << endl;
    }*/
    cout<<answer<<endl;
    return 0;
}

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

using namespace std;

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

    vector<int> p;
    for(int i=0;i<n;i++){
        int y;
        cin >> y;
        p.push_back(y);
    }

    if(n==0){
        cout << x << endl;
        return 0;
    }

    int x1 = x;
    int x2 = x;
    bool ok;
    while (1) {
        ok = true;
        for(auto i : p){
            if(x1 == i){
                ok = false;
            }
        }
        if(ok){
            cout << x1 << endl;
            return 0;
        }

        ok = true;
        for(auto i : p){
            if(x2 == i){
                ok = false;
            }
        }
        if(ok){
            cout << x2 << endl;
            return 0;
        }
        x1--;
        x2++;
    }
    return 0;
}


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

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    long n = in.nextLong();
    out.println(lcm(2,n));
  }

  long lcm(long a,long b){
    return a / gcd(a,b) * b;
  }

  private long gcd(long a,long b){
    return b == 0 ? a : gcd(b,a % b);
  }


  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try (
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {

    }
  }

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    int n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(all(a));

    int l=-(INF>>1),r=(INF>>1);

    while(r-l>1){
        int m=(l+r)/2;
        int s=0,t=0;
        rep(i,n){
            if(a[i]>0){
                int l2=-1,r2=n;
                while(r2-l2>1){
                    int m2=(l2+r2)/2;
                    if(a[i]*a[m2]<=m) l2=m2;
                    else r2=m2;
                }
                s+= r2;
            }else if(a[i]<0){
                int l2=-1,r2=n;
                while(r2-l2>1){
                    int m2=(l2+r2)/2;
                    if(a[i]*a[m2]<=m) r2=m2;
                    else l2=m2;
                }
                s+= n-r2;
            }else if(m>=0) s+=n;
            if(a[i]*a[i]<=m) t++;
        }
        //cout<<l<<' '<<r<<endl;
        int num=(s-t)/2;
        if(num>=k) r=m;
        else l=m;
    }

    cout<<r<<endl;


}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];
  
  int maxv = -2000000000;
  int minv = R[0];
  
  for ( int i = 1; i < n; i++ ) {
      maxv = max(maxv, R[i] - minv);
      minv = min(minv, R[i]);
  }

  cout << maxv << endl;
  
  return 0;
}




Measured memory_bytes: 3860
#include <iostream>
#include <cstdint>

using namespace std;
using ll = long long;

template <std::uint_fast64_t Mod>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 val;

  constexpr ModInt(const u64 x = 0) noexcept : val(x % Mod) {}
  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 {
    val += rhs.val;
    if (val >= Mod) {
      val -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (val < rhs.val) {
      val += Mod;
    }
    val -= rhs.val;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    val = val * rhs.val % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

const ll MOD = 1000000007;

using mint = ModInt<MOD>;

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

  mint ans{1};
  while(N) {
    ans *= N--;
  }

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


Measured memory_bytes: 256
function main(input) {
	var a = parseInt(input.split(" ")[0]);
	var b = parseInt(input.split(" ")[1]);
	var t = parseInt(input.split(" ")[2]) + 0.5;
	console.log(parseInt(t / a) * b);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

#[allow(dead_code)]
fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}

fn main() {
    let n = read::<usize>();
    let mut tseq = vec![0; n];
    let mut ans = 1;
    for i in 0..n {
        tseq[i] = read::<i64>();
        ans = lcm(ans, tseq[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
	int a,i,x;
	scanf("%d",&a);
	for(i=3;i<=a;i++){
		x = i;	
		if(x%3==0)
			printf(" %d",x);
		else{for( ; ;x/=10){
			if(x<1)
				break;
			if(x%10==3){
				printf(" %d",i);
				break;}
		}}
	}
	printf("\n");
	return 0;
}
			
		

Measured memory_bytes: 600
#include <vector>
#include <iostream>
#include <climits>


std::vector<std::vector<int>> Memo;

void show(int city, int day, int arrive, int tired){
  std::cout << "city = " << city << " day = " << day << " arrive = " << arrive << " tired = " << tired << std::endl;
}
int dp(const int &city, const int &day, std::vector<int> &distance, std::vector<int> &sky){
	if (city == 0){
		return 0;
	}else if (city <= day){
		if (Memo.at(city).at(day) != 0){
			return Memo.at(city).at(day);
		}else{
			auto min_sky = INT_MAX;
			auto day_of_min_sky = 0;
			auto min_tired = INT_MAX;
			auto day_of_arrive = 0;
			for(auto i = 1; (i <= day) and (day - i >= city - 1); ++i){
				if (min_sky > sky.at(day - i + 1)){
					min_sky = sky.at(day - i + 1);
					day_of_min_sky = day - i + 1;
				}
				if (min_tired > dp(city - 1, day - i, distance, sky) + min_sky * distance.at(city)){
					min_tired = dp(city - 1, day - i, distance, sky) + min_sky * distance.at(city);
					day_of_arrive = day_of_min_sky;
				}
			}
			for (auto i = day_of_arrive; i <= day; ++i){
				Memo.at(city).at(i) = min_tired;
			}
      //show(city, day, day_of_arrive, min_tired);
			return min_tired;
		}
	}else{
    return INT_MAX;
  }
}
int main(){
	int n, m;
	std::cin >> n >> m;
	std::vector<int> distance(1, 0);
  Memo.push_back(std::vector<int>(m + 1, 0));
	for (auto i = 0; i < n; ++i){
		int d;
		Memo.push_back(std::vector<int>(m + 1, 0));
		std::cin >> d;
		distance.push_back(d);
	}
	std::vector<int> sky(1, 0);
	for (auto i = 0; i < m; ++i){
		int s;
		std::cin >> s;
		sky.push_back(s);
	}
	std::cout << dp(n, m, distance, sky) << '\n';
	return 0;
}

Measured memory_bytes: 4428
li = []

def is_prime(n):
  for m in li:
    if m * m > n: 
      return True
    if n % m == 0:
      return False
  return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

while True:
  if is_prime(n):
    print(n)
    break
  n += 1

Measured memory_bytes: 3392
S = list(map(int, input()))

S_1 = [S[i] for i in range(len(S)) if S[i]==1]
S_0 = [S[i] for i in range(len(S)) if S[i]==0]

S_min = min(len(S_1), len(S_0))

print(2*S_min)

Measured memory_bytes: 4676
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  p=31,N=1000000 +10, M=(ll)1e9+1 ;
 const int mod =(ll)1e9+7  ;

vl left(ll sz,vl a){
    vl l(sz);
    l[0]=0;
    stack<ll> s;
    for(ll i=1;i<sz;i++){

        while(!s.empty()){
            ll x=s.top();
            if(a[x]>a[i])
                s.pop();
            else{
                l[i]=x;
                s.push(i);
                break;
            }
        }
        if(s.empty()){
            l[i]=0;
            s.push(i);
        }
    }
//    for(ll i=1;i<sz;i++)
//        cout << l[i] << " ";
//    cout << endl;
    return l;
}

vl right(ll sz,vl a){
    vl r(sz);
    stack<ll> s;
    for(ll i=sz-1;i>=1;i--){
        while(!s.empty()){
            ll x=s.top();
            if(a[x]>=a[i]){
                s.pop();
            }
            else{
                r[i]=x;
                s.push(i);
                break;
            }
        }
        if(s.empty()){
            r[i]=sz;
            s.push(i);
        }
    }
//    for(ll i=1;i<sz;i++)
//        cout << r[i] << " ";
//    cout << endl;
    return r;
}

ll comp(ll n,vl a){
     vl l=left(n+1,a),r=right(n+1,a);
     ll mi=0;
     for(ll i=1;i<=n;i++){
        mi+=a[i]*(i-l[i])*(r[i]-i);
     }
     return mi;
}
void work(){
  ll n;
  cin >> n;
  vl a(n+1);
  for(ll i=1;i<=n;i++){
    cin >> a[i];
  }
 ll mi=comp(n,a);
  cout << mi;

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


    ll t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 9700
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> ll2;
typedef pair <ld, ld> ldld;

const ll lim = 20000000000ll;
const int Maxn = 100005;

int n;
int A[Maxn], B[Maxn], C[Maxn];

bool Less(const ldld &a, const ldld &b)
{
	if (a.first != b.first) return a.first < b.first;
	return a.second > b.second;
}

ll getInvs(vector <ldld> &seq, int l, int r)
{
	if (l == r) return 0;
	else {
		ll res = 0;
		int m = l + r >> 1;
		vector <ldld> seq1, seq2;
		for (int i = l; i <= m; i++)
			seq1.push_back(seq[i]);
		for (int i = m + 1; i <= r; i++)
			seq2.push_back(seq[i]);
		res += getInvs(seq1, 0, int(seq1.size()) - 1) + getInvs(seq2, 0, int(seq2.size()) - 1);
		seq.clear();
		int i = 0, j = 0;
		while (i < seq1.size() || j < seq2.size())
			if (i < seq1.size() && (j >= seq2.size() || seq1[i].second > seq2[j].second)) seq.push_back(seq1[i++]);
			else { res += int(seq1.size()) - i; seq.push_back(seq2[j++]); }
		return res;
	}
}

ll Solve(vector <ldld> &seq)
{
	sort(seq.begin(), seq.end(), Less);
	return getInvs(seq, 0, int(seq.size()) - 1);
}

ll GetX(ld x)
{
	vector <ldld> seq;
	for (int i = 0; i < n; i++) {
		ld myC = C[i] - x * A[i];
		seq.push_back(ldld(ld(myC) / B[i], -ld(A[i]) / ld(B[i])));
	}
	/*if (x == 0) {
		for (int i = 0; i < seq.size(); i++)
			printf("seq[%d] = (%lld, %lld) %lf\n", i, seq[i].first.first, seq[i].first.second, double(seq[i].second));
		printf("r = %lld, s = %lld\n", res, Solve(seq));
	}*/
	return Solve(seq);
}

ll GetY(ld y)
{
	vector <ldld> seq;
	for (int i = 0; i < n; i++) {
		ld myC = C[i] - y * B[i];
		seq.push_back(ldld(ld(myC) / A[i], -ld(B[i]) / ld(A[i])));
	}
	return Solve(seq);
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d %d", &A[i], &B[i], &C[i]);
	ll nd = (ld(n) * (n - 1) / 2 - 1) / 2;
	ld lef = -lim, rig = lim;
	for (int i = 0; i < 80; i++) {
		ld mid = (lef + rig) / 2;
		if (GetX(mid) <= nd) lef = mid;
		else rig = mid; 
	}
	cout << fixed << setprecision(15) << lef << " ";
	lef = -lim, rig = lim;
	for (int i = 0; i < 80; i++) {
		ld mid = (lef + rig) / 2;
		if (GetY(mid) <= nd) lef = mid;
		else rig = mid;
	}
	cout << fixed << setprecision(15) << lef << endl;
	return 0;
}

Measured memory_bytes: 8212
n = int(input())
fib_memo = [0 for i in range(10000)]
fib_memo[0] = 1
fib_memo[1] = 1
for i in range(2, n+1):
    fib_memo[i] = fib_memo[i-1] + fib_memo[i-2]
print(fib_memo[n])


Measured memory_bytes: 5644
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
   int n;
   string s;
   cin >> n >> s;
   
   REP(i,s.size()){
      s[i] = (char) ((s[i]-'A'+n)%26 + 'A');
   }
   cout << s << endl;
   
   return 0;
}

Measured memory_bytes: 256
N = int(input())
input_array = list(map(int,input().split()))
input_array.insert(0,0)
input_array.append(0)
d1 = []
d2 = []

for i in range(N+1):
    d1.append(abs(input_array[i]-input_array[i+1]))

for i in range(N):
    d2.append(abs(input_array[i]-input_array[i+2]))

total= sum(d1)

for i in range(N):
    print(total-(d1[i]+d1[i+1])+d2[i])

Measured memory_bytes: 16144
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <climits>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i, 3*n) {
        cin >> a[i];
    }

    vector<ll> lsum(n+1);
    vector<ll> rsum(n+1);

    // まず左から
    priority_queue<ll, vector<ll>, greater<ll> > lp;
    ll now_lsum = 0;
    rep(i, n) {
        now_lsum += a[i];
        lp.push(a[i]);
    }
    rep(i, n+1) {
        lsum[i] = now_lsum;
        ll new_l = a[n+i];
        lp.push(new_l);

        ll pop_l = lp.top();
        lp.pop();
        now_lsum = now_lsum + new_l - pop_l;
    }
    //rep(i, n+1) cout << lsum[i] << endl;

    // 次は右
    priority_queue<ll> rp;
    ll now_rsum = 0;
    rep(i, n) {
        now_rsum += a[2*n+i];
        rp.push(a[2*n+i]);
    }
    for(int i = n; i>=0; --i) {
        rsum[i] = now_rsum;
        ll new_r = a[n+i-1];
        rp.push(new_r);

        ll pop_r = rp.top();
        rp.pop();
        now_rsum = now_rsum + new_r - pop_r;
    }
    
    //rep(i, n+1) cout << "right sum: " << rsum[i] << endl;
    ll ans = LLONG_MIN;
    rep(i, n+1) {
        ans = max(lsum[i]-rsum[i], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6516
(* O(n log n) *)
let kNMax = 200000 in
Scanf.scanf " %d %d" @@ fun n k ->
  let balls = Array.make (kNMax + 1) 0 in
  for i = 1 to n do
    let a = Scanf.scanf " %d" @@ (+) 0 in
    balls.(a) <- balls.(a) + 1
  done;
  Array.sort (fun x y -> y - x) balls;
  Array.sub balls k @@ kNMax + 1 - k |> Array.fold_left (+) 0 |> Printf.printf "%d\n"

Measured memory_bytes: 6400
n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
    print(-1)
else:
    P=(n-1)*(n-2)//2-k
    counter=0
    lists=[]
    for i in range(2,n+1):
        lists.append((1,i))

    for j in range(2,n+1):
        for K in range(j+1,n+1):
            lists.append((j,K))
    lists=lists[:n-1+P]
    print(len(lists))
    for some in lists:
        print(some[0],some[1])



Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	
	vector<int> people;
	int a = 1;
	char now;
	if(s[0]=='0'){	
		people.push_back(0);
		now = '0';
	}else{
		now = '1';
	}
	FOR(i,1,n){
		if(s[i]==now){
			a++;
		}else{
			people.push_back(a);
			a = 1;
			now = s[i];
		}
	}
	people.push_back(a);
	if(now=='0'){
		people.push_back(0);
	}
	
	
	vector<int> sum((int)people.size()+1);
	sum[0] = 0;
	REP(i,people.size()){
		sum[i+1] = sum[i]+people[i];
	}
	
	
	
	if(k >= (int)people.size()/2){
		cout << n << endl;
		return 0;
	}
	
	k = k*2+1;
	int ans=0;
	for(int i=0; i<(int)sum.size()-k; i+=2){
		chmax(ans, sum[i+k]-sum[i]);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4192
from scipy.sparse import*
f=csgraph.floyd_warshall
def main():
  n,m,l,*t=map(int,open(0).read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  d=d.astype('i').astype('U')
  print('\n'.join(d[i]for i in zip(*[iter(t[m*3+1:])]*2)))
main()

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

int main(){
    int n, i, R = 0, B = 0;;
    cin >> n;
    char s[n+1];
    for(i = 0; i < n; i++){
        cin >> s[i];
    }
    
    for(i = 0; i < n; i++){
        if(s[i] == 'R'){
            R++;
        }else{
            B++;
        }
    }

    if(R > B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256