akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <ostream>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

// 最大公約数を求める 条件
ll eculidean(ll a, ll b) {
  ll tmp;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

struct ListData {
  int id;
  string S;
  int P;
  ListData() {}
  ListData(const ListData &data) : id(data.id), S(data.S), P(data.P) {}
};

bool operator<(const ListData &a, const ListData &b) {
  if (a.S == b.S) {
    return a.P > b.P;
  }
  return a.S < b.S;
}

int main() {
  int N;
  cin >> N;
  list<ListData> data;

  REP(i, N) {
    ListData p;
    p.id = i + 1;
    cin >> p.S >> p.P;
    data.push_back(p);
  }

  data.sort();

  for (auto i = data.begin(); i != data.end(); i++) {
    cout << i->id << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<map>
#define ll long long
#define MM(arr,x) memset(arr,x,sizeof(arr))
#define INF 10000000
int a[200050];
using namespace std;
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
		else continue;
	}
	cout<<ans;
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  while(cin>>N,N){
	string S;
	cin >> S;

	int pile = 0, tn = 0;
	VI num(N);
	for(char c: S){
	  if(c == 'S'){
		pile += num[tn] + 1;
		num[tn] = 0;
	  }
	  else if(c == 'M'){
		num[tn]++;
	  }
	  else{
		num[tn] += 1 + pile;
		pile = 0;
	  }

	  ++tn %= N;
	}
	SORT(num);
	cout << num << " " << pile << endl;
  }

  return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n,k;cin>>n>>k;int h[n];
  for (int i=0;i<n;i++)cin>>h[i];int ans[n];ans[0]=0;ans[1]=abs(h[1]-h[0]);
  for (int i=2;i<n;i++)
  {
    ans[i]=ans[i-1]+abs(h[i]-h[i-1]);
    for (int j=i-2;j>=max(0,i-k);j--)
    {
      ans[i]=min(ans[i],ans[j]+abs(h[i]-h[j]));}
  }
  cout<<ans[n-1];return 0;}
  
  

Measured memory_bytes: 1024
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(5*(10**6)):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 78700
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> diff = new ArrayList<Integer>();
		
		int n = in.nextInt();
		int min = in.nextInt();
		for (int i = 1; i < n; i++) {
			int val = in.nextInt();
			diff.add(val-min);
			if (min > val) min=val;
		}
		Collections.sort(diff, Comparator.reverseOrder());
		System.out.println(diff.get(0));
	}
}



Measured memory_bytes: 107388
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let D = read!(usize);
    let mut s = "Christmas".to_owned();
    for i in 0..25 - D {
        s += " Eve";
    }
    println!("{}", s);
}


Measured memory_bytes: 4352
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{	
	int a,b,m;
	cin>>a>>b>>m;
	vi A(a),B(b);
	take(A,0,a);
	take(B,0,b);
	map<pii,int> M;
	int mip=MOD;
	for(int i=0;i<m;i++)
	{
		int x,y,c;
		cin>>x>>y>>c;
		mip=min(mip,A[x-1]+B[y-1]-c);
	}
	sort(all(A));
	sort(all(B));
	mip=min(mip,A[0]+B[0]);
	cout<<mip<<endl;
	
}		

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

int main(void)
{
    int N;
    std::cin >> N;
    std::string s;
    std::unordered_map<std::string, int> mp;
    for (int i = 0; i < N;i++){
        std::cin >> s;
        std::sort(s.begin(), s.end());
        mp[s]++;
    }

    long long ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ans += static_cast<long long>(itr->second) * (itr->second - 1) / 2;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    string s;
    cin >> s;
    int n = sz(s);
    if(s[n - 1] == 's'){
        s.pb('e');
    }
    s.pb('s');

    cout << s << endl;
}

signed main(){
    fastio;

    solve();

    return 0;
}


Measured memory_bytes: 3612
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 4000 + 10;
const ll MOD = 998244353;
const ll INF = 1000000000000000000;
const ll LOG = 25;

string s;
int n, dp[N][N], num[N][2];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(num, -1, sizeof num);
	cin >> s;
	n = s.size();
	int cnt0 = 0, cnt1 = 0;
	for (int i = 1; i <= n; i++){
		if (s[i - 1] == '0') cnt0++, num[cnt0][0] = i, cnt0++, num[cnt0][0] = i;
		else if(s[i - 1] == '1') cnt0++, cnt1++, num[cnt0][0] = i, num[cnt1][1] = i;
		else cnt1++, num[cnt1][1] = i, cnt1++, num[cnt1][1] = i;
	}
	int c = 1;
	dp[0][c] = 1;
	for (int i = 1; i <= 2 * n; i++){
		for (int j = 0; j <= min(i, cnt0); j++){
			int koj = num[j][0];
			if (koj <= i){
			//	cout << "YES " << i << ' ' << j << '\n';
              dp[i][j + c] += dp[i - 1][j - 1 + c]; 
			}
			koj = num[i - j][1];
			if (koj <= i) dp[i][j + c] += dp[i - 1][j + c];
			dp[i][j + c] %= MOD;
			//cout << i << ' ' << j << ' ' << num[j][0] << ' ' << dp[i][j + c] << '\n';
		}
	}
	cout << dp[2 * n][cnt0 + c];










	return 0;
}


Measured memory_bytes: 61568
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	string c;
	int n,r=0,w=0,i,ans;
	cin>>n>>c;
	for(i=0;i<n;i++)
	{
		if(c[i]=='R')r++;
	}
	if(r==0||r==n)cout<<0;
	else
	{
		for(i=0;i<r;i++)
		{
			if(c[i]=='W')w++;
		}
		cout<<w;
	}
} 

Measured memory_bytes: 3756
use std::collections::BinaryHeap;
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut lrc: Vec<(usize, usize, i64)> = (0..m)
        .map(|_| {
            let l: usize = sc.read();
            let r: usize = sc.read();
            let c: i64 = sc.read();
            (l - 1, r - 1, c)
        })
        .collect();
    lrc.sort();
    let mut heap = BinaryHeap::new();
    heap.push((0, 0, 0));
    let mut max_id = 0;
    let mut results = vec![None; n + 1];
    while let Some(res) = heap.pop() {
        let cost = -res.0;
        let pos = res.1;
        let idx = res.2;
        if results[pos].is_some() {
            continue;
        }
        results[pos] = Some(cost);
        max_id = std::cmp::max(max_id, idx);
        for i in max_id..m {
            let (l, r, c) = lrc[i];
            if l <= pos && pos < r {
                heap.push((-(cost + c), r, i + 1));
            } else if pos < l {
                max_id = std::cmp::max(max_id, i);
                break;
            }
        }
    }
    let result = if results[n - 1].is_some() {
        results[n - 1].unwrap()
    } else {
        -1
    };
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 16764
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  int n, k, s;
  cin >> n >> k >> s;

  vi ans(n);
  for (int i = 0; i < k; i++)
    ans[i] = s;
  for (int i = k; i < n; i++)
    ans[i] = s==1e9?1:1e9;;

  for (int x : ans)
    cout << x << " ";

}

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

  ll t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }
}



Measured memory_bytes: 3704
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define IO cin.tie(0),cout.tie(0)
#define ISWS ios::sync_with_stdio(0)
typedef long long Long;
void FastIO(){ISWS;IO;}

const int N = 1e5;

int main()
{
  FastIO();
  int tc, ca = 0;
  int n, d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0;i < n;i++){
    double a, b;
    cin >> a >> b;
    if (sqrt((a*a)+(b*b)) <= d)ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3796
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

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

    while (true) {
        if (isPrime(n)) {
            cout << n << endl;
            return 0;
        }
        ++n;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll a, b, h, m;
	cin >> a >> b >> h >> m;
	long double rad = pi * (60 * h - 11 * m) / 360.0;
	rad = abs(rad);
	if (rad > pi) rad = 2 * pi - rad;
	long double ans = a * a + b * b - 2 * a * b * cos(rad);
	cout << fsp(10) << sqrt(ans) << endl;
}


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

using namespace std;
int k;
  string s;

void pre(){
  
    if (s.size() <= k) 
    {
      
    cout << s << '\n';
      
  } 
  else
  {
    for (int i = 0; i < k; ++i) {
      cout << s[i];
    }
    cout << "..." << '\n';
  }

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
 
  cin >> k >> s;
  pre();
 

  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main (void)
{
    int a, b, c, x, y;
    int ac, bc, p = 0;

    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

    if ((2 * c) < (a + b)) {
        if (x < y) {
            p = 2 * c * x;
            y -= x;
            x = 0;
            if ((2 * c) < b) {
                p += 2 * c * y;
            } else {
                p += b * y;
            }
        } else {
            p = 2 * c * y;
            x -= y;
            y = 0;
            if ((2 * c) < a) {
                p += 2 * c * x;
            } else {
                p += a * x;
            }
        }
    } else {
        p = a * x + b * y;
    }

    printf("%d\n", p);
}


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



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

    vector<long> A(N,0);
    for(long i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    
    //for(long idx=N-1; idx>=0; idx--){
    //    cout << idx << ':' << A[idx] << endl;
    //}

    queue<long> Q;
    Q.push(A[N-1]);
    long kokochi=Q.front(); Q.pop();
    Q.push(A[N-2]);
    Q.push(A[N-2]);

    for(long idx=N-3;idx>=0;idx--){
        kokochi += Q.front(); Q.pop();
        Q.push(A[idx]);
        Q.push(A[idx]);
    }

    cout << kokochi << endl;

    return 0;
}


Measured memory_bytes: 6420
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,z,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a<0){
		a=a*-1;
		x=c*a;
		x=x+d;
		x=x+(b*e);
		printf("%d\n",x);
	}
	else{
		y=b-a;
		y=y*e;
		printf("%d\n",y);
	}	
	return 0;
}

Measured memory_bytes: 2704
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	string S_, T;
	cin >> S_;
	cin >> T;
	vector<string> ans;
	int lenS = S_.size();
	int lenT = T.size();
	if(lenS<lenT){
		cout << "UNRESTORABLE" << "\n";
		return 0;
	}
	bool flag=true;
	for(int i=0; i<lenS-lenT+1; i++){
		flag = true;
		for(int k=0; k<lenT; k++){
			if(not (S_[i+k] == T[k] || S_[i+k] == '?')){
				flag = false;
				break;
			}
		}
		if(not flag)continue;
		string tmp = S_;
		tmp.replace(i, lenT, T);
		replace(ALL(tmp), '?', 'a');
		ans.PB(tmp);
	}
	if(not (ans.size() == 0)){
		sort(ALL(ans));
		cout << ans[0] << "\n";
	}else{
		cout << "UNRESTORABLE" << "\n";
	}
	return 0;
}


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

#define forn(i,n) for(int i = 0;i<int(n);i++)
#define ll long long

using namespace std;

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int N,K;
    cin>>N>>K;
    int *n = new int [N];
    forn(i,N)
        n[i] = 0;
    forn(i,K){
        int d;
        cin>>d;
        forn(j,d){
            int tmp;
            cin>>tmp;
            n[tmp-1]++;
        }
    }
    int ans = 0;
    forn(i,N){
        if(n[i] == 0)
            ++ans;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  ll a,b;
  cin>>a>>b;
  if(a<0 && b>0) cout<<"Zero"<<endl;
  else{
    if(((a-b)%2==0 && a<0 && b<0) || ((a-b)%2==1 && a>0 && b>0)) cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
  }
}

Measured memory_bytes: 256
N = int(input())

ans = 0
ans += 10**N % (10**9 + 7)
ans += 8**N % (10**9 + 7)
ans %= 10**9 + 7
ans -= (2 * 9**N) % (10**9 + 7)
ans %= 10**9 + 7

print(ans)

Measured memory_bytes: 10628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string a;
  cin >> a;
  if(a=="ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}

Measured memory_bytes: 3596
import collections

N = int(input())
s_list = [input() for _ in range(N)]
M = int(input())
t_list = [input() for _ in range(M)]

s_copy = s_list[:]
t_copy = t_list[:]
for i, s in enumerate(s_list):
  if s in t_copy:
    t_copy.remove(s)
    s_copy.remove(s)

if s_copy:
  c = collections.Counter(s_copy)
  print(c.most_common(1)[0][1])
else:
  print(0)

Measured memory_bytes: 3316
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

good = [0 for i in range(0, N)]

for i in AB:
    if H[i[0]-1] > H[i[1]-1]:
        good[i[1]-1] += 1
    elif H[i[1]-1] > H[i[0]-1]:
        good[i[0]-1] += 1
    else:
        good[i[0]-1] += 1
        good[i[1]-1] += 1

ct = 0
for j in good:
    if j == 0:
        ct+=1

print(ct)

# N, M = [int(_) for _ in input().split()]
# H = [int(_) for _ in input().split()]
# AB = [[int(_) for _ in input().split()] for i in range(M)]

# root = {i:[i] for i in range(1, N+1)}

# for i in AB:
#     root[i[0]].append(i[1])
#     root[i[1]].append(i[0])

# ct = 0
# for j in range(0, N):
#     b = [H[i-1] for i in root[j+1]]
    
#     if len(b) == 1:
#         ct += 1
#         continue
    
#     if max(b) == b[0] and len(list(set(b))) != 1:
#         ct+=1

# print(ct)

Measured memory_bytes: 31668
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int p, q, r;

    cin >> p >> q >> r;

    if(p+q<=q+r && p+q<=r+p){
        cout << p+q << endl;
    }

    else if(q+r<=p+q && q+r<=r+p){
        cout << q+r << endl;
    }

    else{
        cout << r+p << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
    long A, B, C, K;
    
    std::cin >> A >> B >> C >> K;
    
    if(K <= A) {
        std::cout << K << std::endl;
    } else if(K <= A + B) {
        std::cout << A << std::endl;
    } else {
        // A - (K - A - B)
        std::cout << 2 * A + B - K << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3588
while (num = gets.chomp.to_i) != 0
  hash = Hash.new
  num.times do
    line = gets.split.map(&:to_i)
    if hash[line[0]] == nil
      hash[line[0]] = (line[1] * line[2])
    else
      hash[line[0]] += (line[1] * line[2])
    end
  end
  hash.delete_if {|k, v| v < 1000000}
  puts hash == {} ? "NA" : hash.keys
end

Measured memory_bytes: 8724
import math
import re
import copy

s = input()
if s == 'SUN':
    print('7')
if s == 'MON':
    print('6')
if s == 'TUE':
    print('5')
if s == 'WED':
    print('4')
if s == 'THU':
    print('3')
if s == 'FRI':
    print(2)
if s == 'SAT':
    print(1)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
char s[3005], t[3005];
int dp[3005][3005];
int main() {
    scanf("%s %s", s+1, t+1);
    int n = strlen(s+1);
    int m = strlen(t+1);
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            if (s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    vector <char> v;
    int tar = dp[n][m];
    int x = n, y = m;
    while (tar) {
        bool ok = false;
        for (int i=x; i>=1; i--) {
            for (int j=y; j>=1; j--) {
                if (dp[i][j] == tar && s[i] == t[j]) {
                    v.push_back(s[i]);
                    x = i - 1;
                    y = j - 1;
                    ok = true;
                    break;
                }
            }
            if (ok) break;
        }
        tar--;
    }
    reverse(v.begin(), v.end());
    for (int i=0; i<v.size(); i++) printf("%c", v[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

class FermatCombination{
public:
  vector<ll> factrial; // 階乗
  vector<ll> inverse; // 逆元
  FermatCombination(int size){
    factrial.resize(size+1);
    inverse.resize(size+1);
    factrial[0] = 1;
    inverse[0] = 1;
    for(int i = 1; i < size+1; i++){
      factrial[i] = factrial[i-1] * i % DIV;
      inverse[i] = pow(factrial[i],DIV-2,DIV);
    }
  }
  ll combination(int n, int k){
    if(n < k) return 0; 
    return factrial[n]* inverse[k] % DIV * inverse[n - k] % DIV;
  }
  ll permutation(int n, int k){
    if(n < k) return 0; 
    return factrial[n] * inverse[n-k] % DIV;
  }
  ll multi_choose(int n, int k){
    if(n == 0 && k == 0) return 1;
    else return combination(n+k-1,k);
  }
};

int main(){
  ll h,w,a,b; cin >> h >> w >> a >> b;
  FermatCombination fc(200005);
  ll ans = 0;
  for(int i = b+1; i <= w; i++){
    //SHOW(ans,ans);
    ans += (fc.combination(i-1+h-a-1,i-1)*fc.combination(w-i+a-1,w-i))%DIV;
    ans %=DIV; 
  }
  cout << ans%DIV << endl;
}

Measured memory_bytes: 3328
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max(a * b, c * d);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	string s; CI s;
	s[3] = '8';
	CO s EN;
}

Measured memory_bytes: 256
from collections import deque

h, w = [int(item) for item in input().split()]
s = [input() for _ in range(h)]
dist = [[-1] * w for _ in range(h)]

black = 0
for line in s:
  black += line.count("#")

que = deque()
que.append([0,0])
dist[0][0] = 1
while que:
  x, y = que.popleft()
  for i, j in [(1,0), (-1,0), (0,1), (0,-1)]:
    nx = x + i
    ny = y + j
    if nx < 0 or nx >= h or ny < 0 or ny >= w:
      continue
    if s[nx][ny] == "#":
      continue
    if dist[nx][ny] == -1:
      dist[nx][ny] = dist[x][y] + 1
      que.append([nx, ny])

if dist[h-1][w-1] == -1:
  print(-1)
else:
  print(h*w - dist[h-1][w-1] - black)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);

  int count = 0;
  int cur_min = 200000;
  rep(i, n) {
      cin >> p.at(i);
       if (min(cur_min, p.at(i)) == p.at(i))
       {
           /* code */
           cur_min = p.at(i);
           count++;
       }
  }
  cout << count << endl;
}

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

int main ()
{

    string s,k;
    cin>>s;

    k = "keyence";

    long long i,j,c=0;
    if(s.size()<k.size()) cout<<"NO"<<endl;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=k[i]) break;
        c++;
    }
    i--;

    long long p = k.size()-1;
    for(long long j=s.size()-1;j>i,p>=0;j--,p--)
    {
        if(s[j]!=k[p]) break;
        c++;
    }

    if(c>=k.size()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

const int N = 110;
int q[N], n, m;

int main()
{
	scanf("%d%d", &n, &m);
	
	int sum = 0;
	for(int i = 1; i <= n; i++) scanf("%d", &q[i]), sum += q[i];
	sort(q + 1, q + 1 + n);
	reverse(q + 1, q + 1 + n);
	
	if(q[m] * 4 * m >= sum) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int modinv(Int a, Int m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

Int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int root_sum(int target, vi &parents, vi &nodes_value, vi &memo, int sum){
    if(memo[target] != -1){
        sum += memo[target];
        return sum;
    }
    if (parents[target] == target){
        sum+=nodes_value[target];
        return sum;
    }else{
        sum+=nodes_value[target];
        return root_sum(parents[target],parents, nodes_value, memo, sum);
    }
}


int main() {
    Int N,M;
    cin >> N >> M;

    priority_queue<Int> A;

    Int ans =0;

    rep(i,N){
        int tmp;
        cin >> tmp;
        A.push(tmp);
    }

    rep(i,M){
        Int highest = A.top();
        A.pop();
        A.push(highest/2);
    }

    rep(i,N){
        int tmp = A.top();
        A.pop();
        ans += tmp;
    }


    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1400
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;
using Graph = vector<vector<int>>;

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

#define P (1'000'000'007)

signed main() {
    string s, t;
    cin >> s >> t;

    int ans = INT_MAX;

    for (int i = 0; i <= s.size() - t.size(); ++i) {
        auto sub = s.substr(i, t.size());
        int res = t.size();
        for (int j = 0; j < sub.size(); ++j) {
            if (sub[j] == t[j]) --res;
        }

        chmin(ans, res);
    }

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sort(v) sort(v.begin(),v.end()) 
#define pb push_back
/*
ll ar[1000000+9]={0}; 
void seiv() { 
ll n=1000000,i,j; 
ar[1]=1; 
for(i=4;i<=n;i+=2)ar[i]=1; 
for(i=3;i<=n;i+=2) 
{ if(ar[i]==0) 
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
 } 
}*/
int main()
{
      string s,t;
     ll a,b,c,d,i,j,k,l;
     cin>>s>>t;l=11000000000;d=0;
   for(i=0;i<=s.size()-t.size();i++)
   {d=0;
   for(j=0,k=i;j<t.size();j++,k++)
   {
   if(s[k]!=t[j])d++;
   
   }
     // cout<<k<<endl;
    l=min(l,d);
   }cout<<l<<endl;
}

Measured memory_bytes: 3628
s = input()
last = s[-1]
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
n = len(ascii_lowercase)

for moji in ascii_lowercase:
    if moji not in s:
        s += moji
        print(s)
        exit()

sl = list(s)
for i in range(len(s)-1, -1,-1):
    idx = ascii_lowercase.index(s[i])
    for j in range(idx,n):
        if ascii_lowercase[j] not in sl:
            sl[i] = ascii_lowercase[j]
            print(''.join(sl))
            exit()
    sl.pop()

if not sl:
    print(-1)

Measured memory_bytes: 9144
//BISMILLAH
#include <stdio.h>
#include <string.h>
#define n 300000

int main(void){
    int len, i, count=0;
    char a[n], b[n];

    scanf("%s %s", a, b);
    len = strlen(a);

    for(i=0; i<len; i++){
        if(a[i]==b[i])
            continue;
        else
            count++;
    }

    printf("%d\n", count);

    return 0;
}


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

int main(){
    ll a[3],k;cin >> a[0] >> a[1] >> a[2] >> k;
    rep(i,k){
        sort(a,a+3);
        a[2]*=2;
    }
    cout << a[0]+a[1]+a[2] << endl;
}

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

int main(){
  int R, G, B, K;
  int count=0;
  cin >> R >> G >> B >> K;
  
  for (int i=0;i< K;i++){
    if ( G <= R )
      G *= 2;
    else if ( B <= G )
      B *= 2;
    
    if ( B > G && G > R )
      break;
  }
  
  if ( B > G && G > R )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
	int n, q;
	int a, b, c;
	cin >> n >> q;
	queue<int> arr[n];
	while(q--) {
		cin >> a;
		if(a == 0) {
			cin >> b >> c;
			arr[b].push(c);
		}
		else if(a == 1) {
			cin >> b;
			if(arr[b].size() == 0) {
				
			}
			else cout << arr[b].front() << endl;
		}
		else {
			cin >> b;
			if(arr[b].size() == 0) {
				
			}
			else arr[b].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 4280
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int F[26];
char A;
string S;

int main(void){
	//IO("test.in", "test.out");
	A = -1;
	cin >> S;
	for(int i = 0; i < S.length(); i++) F[S[i] - 'a'] = 1;
	for(int i = 0; i < 26; i++)
		if(F[i] == 0){
			A = i + 'a';
			break;
		}
	if(A == -1) printf("None\n");
	else printf("%c\n", A);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,ba,h[11],i;
	char a;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
	ba=0;
	fill(h,h+n+1,0);
	for(i=1;i<=101;i++){
		scanf("%c",&a);
		if(a=='S'){
			if(i%n!=0) ba+=h[i%n],h[i%n]=0;
			else ba+=h[n],h[n]=0;
			ba++;
		}	
		if(a=='M'){
			if(i%n!=0) h[i%n]++;
			else h[n]++;
		}	
		if(a=='L'){
			if(i%n!=0) h[i%n]+=ba+1;
			else h[n]+=ba+1;
			ba=0;
		}	
	}
	sort(h+1,h+n+1);
	printf("%d",h[1]);
	for(i=2;i<=n;i++) printf(" %d",h[i]);
	printf(" %d\n",ba);
	}
}	


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int64_t mod(int64_t x, int64_t md) {
  x %= md;
  if (x < 0) {
    x += md;
  }
  return x;
}

int main() {
  int64_t N, L, T;
  std::cin >> N >> L >> T;
  std::vector<int64_t> X(N), D(N);
  std::vector<std::pair<int64_t, int>> after(N);
  for (int i: range(0, N)) {
    std::cin >> X[i] >> D[i];
    D[i] = (D[i] == 1 ? 1 : -1);
    after[i] = { mod(X[i] + D[i] * T, L), i };
  }
  std::sort(after.begin(), after.end());
  int64_t count = 0;
  if (D[0] == 1) {
    for (int i: range(1, N)) {
      if (D[i] == -1) {
        int64_t val = 2 * T - (X[i] - X[0]);
        if (val > 0) {
          count += (val - 1) / L + 1;
        }
      }
    }
  }
  else {
    for (int i: range(1, N)) {
      if (D[i] == 1) {
        int64_t val = 2 * T - (L - X[i] + X[0]);
        if (val >= 0) {
          count -= val / L + 1;
        }
      }
    }
  }
  count = mod(count, N);
  int pos = -1;
  for (int i: range(0, N)) {
    if (after[i].second == 0) {
      pos = i;
      break;
    }
  }
  std::vector<int64_t> ans(N);
  for (int i: range(0, N)) {
    ans[mod(count + i, N)] = after[mod(pos + i, N)].first;
  }
  for (int64_t x: ans) {
    std::cout << x << '\n';
  }
  return 0;
}


Measured memory_bytes: 5120
N, A, B, C = list(map(int, input().split()))
s = [input() for _ in range(N)]

DP = [[0] * 3 for _ in range(N + 1)]
DP[0] = [A, B, C]

L = [""] * N
R = {}
R[0] = "A"
R[1] = "B"
R[2] = "C"
A = []
B = []
for i in range(N):
  t = s[i]
  if t == "AB":
    x = 0
    y = 1
  if t == "BC":
    x = 1
    y = 2
  if t == "AC":
    x = 0
    y = 2
  if DP[i][y] != 0:
    DP[i + 1] = DP[i]
    DP[i + 1][x] += 1
    DP[i + 1][y] -= 1
    L[i] = R[x]
    if x == 0:
      A.append([i, y])
    else:
      B.append([i, y])
  elif DP[i][x] != 0:
    DP[i + 1] = DP[i]
    DP[i + 1][x] -= 1
    DP[i + 1][y] += 1
    L[i] = R[y]
  else:
    if x == 0:
      if len(B) == 0:
        print("No")
        exit()
      z = 1
      k, n = B.pop()
    if x == 1:
      if len(A) == 0:
        print("No")
        exit()
      z = 0
      k, n = A.pop()
    DP[i + 1] = DP[i]
    DP[i + 1][z] -= 2
    DP[i + 1][n] += 2
    if n == x:
      x, y = y, x
    DP[i + 1][x] += 1
    DP[i + 1][y] -= 1
    if DP[i + 1][z] < 0:
      print("No")
      exit()
    L[i] = R[x]
    L[k] = R[y]

print("Yes")
for i in L:
  print(i)



Measured memory_bytes: 107500
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l,r;
        int maxL = 0;
        int minR = Integer.MAX_VALUE;
        for (int i = 0; i< m;i++) {
            l = sc.nextInt();
            r = sc.nextInt();
            maxL = Math.max(maxL, l);
            minR = Math.min(minR, r);
        }
        
        if (minR < maxL) {
            System.out.println(0);
        } else {
            System.out.println(minR - maxL + 1);
        }
    }
}

Measured memory_bytes: 63908
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		Map<String, String> map = new HashMap<>();

		map.put("a", a);
		map.put("b", b);
		map.put("c", c);

		String key = "a";
		while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		}

	}

}

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

int main() {
  LL sum = (LL)0;
  LL n = (LL)0;
  for (int ci = cin.get(); isdigit(ci); ci = cin.get()) {
    LL digit = ci - '0';
    sum += digit;
    n = n * (LL)10 + digit;
  }
  if (n % sum == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }   
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3832
n,k = map(int, input().split())
list_ab = []
for i in range(n):
    list_ab.append(list(map(int, input().split())))
list_ab.sort()
count = 0
i = 0
while k > count:
    count += list_ab[i][1]
    i += 1
print(list_ab[i-1][0])


Measured memory_bytes: 27872
def abc068_c():
    from collections import Counter
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(m)]
    candidates = []

    for i in range(m):
        if ab[i][0] == 1:
            candidates.append(ab[i][1])
        elif ab[i][1] == n:
            candidates.append(ab[i][0])

    if max(Counter(candidates).values()) >= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


abc068_c()

Measured memory_bytes: 69016
N, M = map(int, input().split())
H = list(map(int, input().split()))
Q = [list(map(int, input().split())) for _ in range(M)]

tmp = [0 for _ in range(N)]
for i in range(M):
  if H[Q[i][0]-1] >= H[Q[i][1]-1]:
    tmp[Q[i][1]-1] = -1
  if H[Q[i][0]-1]<= H[Q[i][1]-1]:
    tmp[Q[i][0]-1] = -1

print(N + sum(tmp))

Measured memory_bytes: 32016