akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){

    string S;
    cin >> S;

    vector<int> alphabet(27, 0);
    for(int i = 0; i < S.length(); i++) alphabet[S[i] - 'a']++;

    for(int i = 0; i < alphabet.size(); i++){
        if(i == 26) cout << "None" << endl;
        else if(alphabet[i] == 0){
            char ans = 'a' + i;
            cout << ans << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	READARR(h, n);
	sort(h+1, h+n+1, greater<int>());
	
	int sum = 0;
	FOR (i, k+1, n) sum += h[i];
	cout << sum;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int col[3][n + 1];
  memset(col, 0, sizeof(col));
  rep(i, n) {
    int addNum[3] = {0};
    switch(s[i]) {
    case 'R':
      addNum[0] = 1;
      break;
    case 'G':
      addNum[1] = 1;
      break;
    case 'B':
      addNum[2] = 1;
      break;
    }
    rep(c, 3) {
      if(i == 0)
        col[c][i] = addNum[c];
      else
        col[c][i] = col[c][i - 1] + addNum[c];
    }
  }

  map<char, int> mp;
  mp['R'] = 0;
  mp['G'] = 1;
  mp['B'] = 2;
  ll ans = 0;
  FOR(mid, 1, n - 1) {
    int num = mp[s[mid]];

    rep(i, mid) {
      int left = mp[s[i]];
      if(left == num)
        continue;
      int right = 3 - left - num;
      ans += col[right][n - 1] - col[right][mid];
      ll diff = mid - i;
      if(mid + diff < n && mp[s[mid + diff]] == right) {
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template <uint32_t mod>
class Modular {
private:
  uint32_t n;

public:
  Modular(int64_t _n = 0) : n((_n >= 0 ? _n : mod - (-_n) % mod) % mod) {}

  uint32_t get() const {
    return n;
  }

  bool operator ==(const Modular& o) const {
    return n == o.n;
  }

  bool operator !=(const Modular& o) const {
    return n != o.n;
  }

  Modular& operator +=(const Modular& o) {
    n += o.n;
    n = (n < mod ? n : n - mod);
    return *this; 
  }

  Modular& operator -=(const Modular& o) {
    n += mod - o.n;
    n = (n < mod ? n : n - mod);
    return *this;
  }

  Modular& operator *=(const Modular& o) {
    n = uint64_t(n) * o.n % mod;
    return *this;
  }

  Modular& operator /=(const Modular& o) {
    return (*this) *= o.inv();
  }

  Modular operator +(const Modular& o) const {
    return Modular(*this) += o;
  }

  Modular operator -(const Modular& o) const {
    return Modular(*this) -= o;
  }

  Modular operator *(const Modular& o) const {
    return Modular(*this) *= o;
  }

  Modular operator /(const Modular& o) const {
    return Modular(*this) /= o;
  }

  Modular pow(uint64_t b) const {
    Modular ans(1), m = Modular(*this);
    while (b) {
      if (b & 1) {
        ans *= m;
      }
      m *= m;
      b >>= 1;
    }
    return ans;
  }

  Modular inv() const {
    int32_t a = n, b = mod, u = 0, v = 1;
    while (a) {
      int32_t t = b / a;
      b -= t * a;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    assert(b == 1);
    return Modular(u);
  }
};

using Mint = Modular<int(1e9 + 7)>;

void test_case() {
  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  Mint res;
  vector<int> nxt;
  for (int i = n - 1; i >= 0; --i) {
    int ind = lower_bound(nxt.begin(), nxt.end(), A[i]) - nxt.begin();
    res += Mint(k) * Mint(ind);
    nxt.emplace_back(A[i]);
    sort(nxt.begin(), nxt.end());
  }
  for (int i = 0; i < n; ++i) {
    int ind = lower_bound(nxt.begin(), nxt.end(), A[i]) - nxt.begin();
    res += Mint((1LL * (k - 1) * k) / 2) * Mint(ind);
  }
  cout << res.get() << "\n";
}

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


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

int N,M;

class List{
public:
	int t;
	int s,d;
	bool operator< (const List &opp) const {
		return t<opp.t;
	}
};

main(){
	int i,j;
	while(cin >> N >> M, N){
		int Infected[20002];
		vector<List> list(M);
		for(i=1;i<=N;i++) Infected[i] = 0;
		for(i=0;i<M;i++) cin >> list[i].t >> list[i].s >> list[i].d;
		sort(list.begin(), list.end());
		Infected[1] = 1;
		int ans = 1;
		for(i=0;i<M;i++){
			if(Infected[list[i].s] && !Infected[list[i].d]){
				Infected[list[i].d] = 1;
				ans ++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1524
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

ll dp[100007];
ll h[100007];
ll n;

ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

ll fun(ll x)
{
	if(dp[x]!=-1)
		return dp[x];
	if(x==n)
		dp[x]=0;
	else if(x==n-1)
		dp[x] = abs(h[x]-h[x+1]);
	else
		dp[x] =  min(fun(x+1)+abs(h[x+1]-h[x]) ,fun(x+2) + abs(h[x+2]-h[x]) );
//	deb2(x,dp[x]);
	return dp[x];
}
int main()
{
	fastio
	
	cin >> n;
	
	h[n+1]=0;
	h[n+2]=0;
	for(ll i=1;i<=n;i++)
		cin >> h[i];
	for(ll i=1;i<=n;i++)
		dp[i]=-1;

	cout << fun(1) << endl;
	return 0;	
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int count_substr(const string& word,const string& q) {
	int count = 0;
	for (string::size_type pos = 0; (pos = word.find(q, pos)) != string::npos; pos += q.size()) {
		++count;
	}
	return count;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int SX=in(),SY=in(),TX=in(),TY=in();
	int X=0,Y=0;
	vector<char> H;
	// phase1: 1st s->t
	if(SY<TY){
		for(int i=0;i<TY-SY;i++) H.push_back('U');
	}
	else{
		for(int i=0;i<SY-TY;i++) H.push_back('D');
	}
	if(SX<TX){
		for(int i=0;i<TX-SX;i++) H.push_back('R');
	}
	else{
		for(int i=0;i<SX-TX;i++) H.push_back('L');
	}
	// phase2: 1st t->s
	if(SY<TY){
		for(int i=0;i<TY-SY;i++) H.push_back('D');
	}
	else{
		for(int i=0;i<SY-TY;i++) H.push_back('U');
	}
	if(SX<TX){
		for(int i=0;i<TX-SX+1;i++) H.push_back('L');
	}
	else{
		for(int i=0;i<SX-TX+1;i++) H.push_back('R');
	}
	// phase3: 2nd s->t
	if(SY<TY){
		for(int i=0;i<TY-SY+1;i++) H.push_back('U');
	}
	else{
		for(int i=0;i<SY-TY+1;i++) H.push_back('D');
	}
	if(SX<TX){
		for(int i=0;i<TX-SX+1;i++) H.push_back('R');
	}
	else{
		for(int i=0;i<SX-TX+1;i++) H.push_back('L');
	}

	if(SY<TY) H.push_back('D');
	else H.push_back('U');

	if(SX<TX) H.push_back('R');
	else H.push_back('L');

	// phase4: 2nd t->s
	if(SY<TY){
		for(int i=0;i<TY-SY+1;i++) H.push_back('D');
	}
	else{
		for(int i=0;i<SY-TY+1;i++) H.push_back('U');
	}
	if(SX<TX){
		for(int i=0;i<TX-SX+1;i++) H.push_back('L');
	}
	else{
		for(int i=0;i<SX-TX+1;i++) H.push_back('R');
	}

	if(SY<TY) H.push_back('U');
	else H.push_back('D');

	for(auto& x:H) cout << x;
	out();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a, b, i;
	cin >> a >> b;
	for (int i = b - a + 1; i < b + a - 1; i++)
	{
		cout << i << " ";
	}
	cout << b + a - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque 
import math
n, d, a = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key = lambda x:x[0])
cnt = 0
queue = deque()
sum_bomb = 0
for i in range(n):
    while len(queue) != 0 and queue[0][0]<l[i][0]:
        sum_bomb -= queue[0][1] * a
        queue.popleft()
    l[i][1] -= sum_bomb
    if l[i][1] <= 0 :
        continue
    num = math.ceil(l[i][1]/a)
    right = l[i][0] + 2 * d
    queue.append([right, num])
    cnt += num
    sum_bomb += num * a
print(cnt)


Measured memory_bytes: 62008
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool dp[100001];
int main()
{
   int n,k;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0]=false;
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i>=a[j]&&dp[i-a[j]]==false)
                dp[i]=true;
        }
    }
    string s="";
    s=dp[k]==true?"First":"Second";
    cout<<s<<endl;
    return 0;
}

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

typedef long long ll;

int main()
{
    ll i,j,k;
    ll n;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll t1 = 1;
    ll bit;
    int q;
    cin >> q;
    unordered_set<ll> set;
    for(bit = 0;bit < (t1 << n);++bit){
        ll tmp = 0;
        for(i = 0;i < n;++i){
            if(bit & (t1<<i)){
                tmp += a.at(i);
            }
        }
        if(tmp <= 2000){
            set.emplace(tmp);
        }
    }
    for(j = 0;j < q;++j){
        ll moku;
        cin >> moku;
        auto it = set.find(moku);
        if(it == set.end()){
            cout << "no" << endl;
        }else{
            cout << "yes" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>
#include <math.h>
//#include <stdlib.h>
//#include<string.h>
using namespace std;
int main()
{
    int N;
    int q[101];
    int total=0;
    float avg=0;
    scanf("%d", &N);
    
    for(int i=0; i<N; i++){
        scanf("%d", &q[i]);
        avg+=q[i];
    }
    avg/=N;
    avg = round(avg);
    
    for(int i=0; i<N; i++){
        total = total + (q[i]-avg)*(q[i]-avg);
    }
 
    printf("%d", total);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  vector<int> d(n,1e9);
  d[0]=0;
  d[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i-j>=0){
        d[i]=min(d[i],d[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout << d[n-1] << endl;
}

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

const int N = 200005;
typedef pair<int,int> ii;

int n, w, h;
vector<int> z;
int tout[N];

struct Point {
    int x; int y; int id; char dir;
    bool operator < (const Point &other) const {
        return x > other.x || (x == other.x && dir < other.dir);
    }
} a[N];
vector<Point> vec[N][2];

void solve(vector<Point> &v) {
    int sz = v.size();
    sort(v.begin(), v.end());
    vector< pair< ii, int > > fallout;

    for (int i = 0; i < sz; ++i) {
        if (v[i].dir == 'S') {
            fallout.push_back( make_pair( ii(1, -v[i].x), h - v[i].y ) );
        }
        else {
            fallout.push_back( make_pair( ii(0, v[i].y), w - v[i].x ) );
        }
    }

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

    for (int i = 0; i < sz; ++i) {
        tout[v[i].id] = fallout[i].second;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> w >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].x >> a[i].y >> a[i].dir;
        a[i].id = i;
        z.push_back(a[i].x + a[i].y);
    }
    sort(z.begin(), z.end());
    z.erase(unique(z.begin(), z.end()), z.end());

    for (int i = 0; i < n; ++i) {
        int sum = lower_bound(z.begin(), z.end(), a[i].x + a[i].y) - z.begin() + 1;
        if (a[i].dir == 'S') vec[sum][a[i].x % 2].push_back(a[i]);
        else vec[sum][a[i].y % 2].push_back(a[i]);
    }

    for (int i = 1; i <= z.size(); ++i) {
        for (int j = 0; j < 2; ++j) if (vec[i][j].size()) {
            solve(vec[i][j]);
        }
    }


    vector< pair<int,int> > vres;
    for (int i = 0; i < n; ++i) {
        vres.push_back(make_pair(tout[i], i));
    }

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

    for (int i = 0; i < vres.size(); ++i) {
        printf("%d\n", vres[i].second + 1);
    }
}


Measured memory_bytes: 25444
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>

using namespace std;



int main(int argc, char *argv[])
{
	int H, W;
	int h, w;
	int ans = 0;

	//input
	cin >> H >> W;
	cin >> h >> w;


	//calc
	ans = (H - h) * (W - w);

	//ans
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;

fn main() {
    let n = read::<usize>();
    let mut v: Vec<Vec<usize>> = vec![vec![usize::max_value(); n+1]; n+1];
    for i in 0..n {
        let a = read::<usize>();
        for _ in 0..a {
            let xy = read_vec::<usize>();
            v[i+1][xy[0]] = xy[1];
        }
    }

    let mut ma = 0;
    for bit in 0..1<<n {
        let mut hset: HashSet<usize> = HashSet::new();
        let mut nset: HashSet<usize> = HashSet::new();
        for i in 0..n {
            if bit & 1<<i != 0 {
                hset.insert(i+1);
            } else {
                nset.insert(i+1);
            }
        }

        let mut cnt = hset.len();
        for i in hset.iter() {
            let g = &v[*i];
            for j in 0..n {
                if g[j+1] == usize::max_value() { continue; }

                if g[j+1] == 1 {
                    if nset.contains(&(j+1)) {
                        cnt = 0;
                        break;
                    }
                } else {
                    if hset.contains(&(j+1)) {
                        cnt = 0;
                        break;
                    }
                }
            }
        }

        if ma < cnt {
            ma = cnt;
        }
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

int main() {
    int N;
    int d[110];

    cin >> N;
    for (int i=0; i<N; ++i) cin >> d[i];

    set<int> values;
    for (int i=0; i<N; ++i){
        values.insert(d[i]);
    }

    cout << values.size() << endl;
}


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

int N;
vector<int> v[10000];
int c[10000];

int main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    rep(i,N) cin>>c[i];

    sort(c,c+N,greater<>());

    int ans=0;
    repn(i,N-1) ans+=c[i];
    cout<<ans<<endl;

    vector<int> ans1(N);
    queue<int> q;
    q.push(0);
    int idx=0;
    while(!q.empty()){
        int p=q.front(); q.pop();
        if(ans1[p]==0){
            ans1[p]=c[idx++];
            rep(i,v[p].size()){
                q.push(v[p][i]);
            }
        }
    }

    rep(i,N) cout<<ans1[i]<<' '; cout<<endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

const ll MAX = 1e18;

int main(void){
    std::ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    ll ans = 1;
    bool ng = false;
    FOR(i, n){
    	ll tmp;
    	cin >> tmp;

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

    	if(ng || MAX/ans < tmp){
    		ng = true;
    	}

    	ans *= tmp;    	
    }

    if(ng) 
    	cout << -1 << endl;
	else
    	cout << ans;

    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>

int main(void)
{
	const double INTEREST = 1.05;
	int week;
	int i;
	int debt = 100000;

	scanf("%d", &week);

	for(i = 0; i < week; ++i)
	{
		debt *= INTEREST;
		if(debt % 1000 != 0)
		{
			debt += (1000 - (debt % 1000));
		}
	}

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

	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int ans = 1e9;
	for (int n = 0;n<S.size()-2;++n) {
		int num = (S[n] - '0') * 100 + (S[n+1] - '0') * 10 + (S[n+2] - '0');
		ans = min(ans, abs(753-num));
	}
	cout << ans <<endl;
}

Measured memory_bytes: 3572
#<B>
S = input()
S1 = S[0::2]
S2 = S[1::2]
ans1 = S1.count("R") + S1.count("U") + S1.count("D")
ans2 = S2.count("L") + S2.count("U") + S2.count("D")
if ans1 == len(S1) and ans2 == len(S2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9076
#include <iostream>
using namespace std;
int main() {
    int D, T, S;
    cin >> D >> T >> S;
    double time = (double)D / S;
    if (T >= time) 
    {
        cout << "Yes" << endl;
    }
    else 
    {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;


int main() {
	//code
	int t=1;
	// cin>>t;
	while(t--)
	{
	    int n;
        cin>>n;
        double p;
        p = (double)2 * 3.141592653589793238 * n;
        cout << fixed << setprecision(20) <<p<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 3768
from collections import Counter

s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
  if x not in dict_st:
    dict_st[x] = y
  else:
    if dict_st[x] != y:
      print("No")
      break
  if y not in dict_ts:
    dict_ts[y] = x
  else:
    if dict_ts[y] != x:
      print("No")
      break
else:
  print("Yes")
      

Measured memory_bytes: 4136
use std::io;

fn main(){
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.trim().split_whitespace();
    
    let a: f64 = iter.next().unwrap().parse().unwrap();
    let b: f64 = iter.next().unwrap().parse().unwrap();
    let c: f64 = iter.next().unwrap().parse().unwrap();

    let h = b * c.to_radians().sin();
    let s = a * h / 2.;
    let l = a + b + (a.powi(2) + b.powi(2) - 2. * a * b * c.to_radians().cos()).sqrt();

    println!("{}\n{}\n{}", s, l, h);
}


Measured memory_bytes: 5184
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**(1/2)) + 1):
        if n%i == 0:
            return False
    return True

def factors(N): #約数を全て求める。ただし、順不同
    from collections import deque
    ret = 0
    middle = int( N**(1/2))
    for i in range(1, middle):
        if N%i == 0:
            if is_prime(i):
                ret += 1
            if is_prime(N//i):
                ret += 1
            
    if N%middle == 0:
        if is_prime(middle):
            ret += 1
        if middle != N//middle:
            if is_prime(N//middle):
                ret += 1
    return ret

    
def main():
    a, b = map( int, input().split())
    d = gcd(a,b)
#    print(2, is_prime(2))
    if d == 1:
        print(1)
        return
    if is_prime(d):
        print(2)
        return

    print(factors(d)+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
n,m,l = gets.split(" ").map(&:to_i)
a = []
b = []
c = Array.new(n).map{Array.new(l,0)}
n.times do
  a<<gets.split(" ").map(&:to_i)
end
m.times do
  b<<gets.split(" ").map(&:to_i)
end
bt = b.transpose
n.times do |i|
  l.times do |j|
    c[i][j] = [a[i],bt[j]].transpose.map{|t| t.inject(:*)}.inject(:+)
  end
  puts c[i].join(" ")
end

Measured memory_bytes: 9132
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
  ll H,W; cin >> H >> W;
  ll ans = LINF;
  rep(i,2){
    if(i == 0){
      repr(j,1,H){
        rep(k,2){
          ll sM = 0;
          ll sm = 0;
          if(k == 0){
            sM = max(W*j,max(W*((H-j)/2),W*((H-j)-(H-j)/2)));
            sm = min(W*j,min(W*((H-j)/2),W*((H-j)-(H-j)/2)));
          }
          if(k == 1){
            sM = max(W*j,max((H-j)*(W/2),(H-j)*(W-W/2)));
            sm = min(W*j,min((H-j)*(W/2),(H-j)*(W-W/2)));
          }
          ans = min(ans,sM - sm);
        }
      }
    }
    if(i == 1){
      repr(j,1,W){
        rep(k,2){
          ll sM = 0;
          ll sm = 0;
          if(k == 0){
            sM = max(H*j,max(H*((W-j)/2),H*((W-j)-(W-j)/2)));
            sm = min(H*j,min(H*((W-j)/2),H*((W-j)-(W-j)/2)));
          }
          if(k == 1){
            sM = max(H*j,max((W-j)*(H/2),(W-j)*(H-H/2)));
            sm = min(H*j,min((W-j)*(H/2),(W-j)*(H-H/2)));
          }
          ans = min(ans,sM - sm);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// finish date: 2018/01/15
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    ll N;
    cin >> N;
    int s = (int) sqrt(N);
    int ma_ab=1; //代入する値は適当
    for (int i = s; i >= 1; i--) {
        if (N % i == 0) {
            ma_ab = (i > N / i) ? i : (int)(N / i);
            break;
        }
    }
    cout << (int) log10(ma_ab) + 1 << endl;


    return 0;
}


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

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;




int main(){
    int list[100003] = {0};
    long long int Rsum[100003] = {0};

    int N;

    cin >>N;

    for(int i = 0;i<N;i++){
        int a,b;

        cin >>a>>b;

        list[a] += 1;
        list[b+1] += -1;
    }

    for(int i = 1;i <= 100003;i++){
        Rsum[i] = Rsum[i-1] + list[i];
    }

    long long int ans = -1;

    for(int i = 0;i <= N+1;i++){
       if(Rsum[i]+1 >= i){
           ans = i;
       }
    }

    cout <<ans-1<<endl;



  return 0;
}


Measured memory_bytes: 4268
package main

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

/*-----------Main-----------*/

func main() {
	n := readI()
	p := make(map[int][]int)

	for i := 1; i <= n; i++ {
		a := readI()
		if _, ok := p[a+i]; !ok {
			p[a+i] = make([]int, 1)
		}
		p[a+i] = []int{p[a+i][0] + 1, 0}

		if _, ok := p[i-a]; ok {
			p[i-a][1]++
		}
	}

	ans := 0
	for _, v := range p {
		ans += v[0] * v[1]
	}
	fmt.Println(ans)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

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

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


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

int main() {
	// your code goes here
	string S;
	int n;
	cin>>S;
	S.pop_back();
	n=S.size();
	for(int i=n;i;i--){
		if(n%2==0){
			if(S.substr(0,i/2)==S.substr(i/2,i/2)){
				cout<< S.size() <<endl;
				break;
			}
		}
		S.pop_back();
		n=S.size();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int ans = 1;
    while (n / 2)
    {
        ans *= 2;
        n /= 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

use std::cmp;

fn main() {
    let (n, k): (usize, usize);
    input!(n);
    input!(k);
    let mut ans = 1;
    for _ in 0..n {
        ans += cmp::min(ans, k);
    }
    p(ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll n;
    cin >> n;
    ll x[n], y[n], h[n];
    tuple<ll,ll,ll> ini;
    ll ansx, ansy, ansh;
    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]!=0) ini = make_tuple(x[i], y[i], h[i]);
    }
    for(int cx = 0; cx <= 100; cx++){
        for(int cy = 0; cy <= 100; cy++){
            bool flag = true;
            ll nowh = get<2>(ini)+abs(get<0>(ini)-cx)+abs(get<1>(ini)-cy);
            for(int i = 0; i < n; i++){
                ll tmph = max(nowh-abs(x[i]-cx)-abs(y[i]-cy),0LL);
                if(tmph!=h[i]){
                    flag = false;
                }
            }
            if(flag){
                ansx = cx;
                ansy = cy;
                ansh = nowh;
            }
        }
    }
    cout << ansx << " " << ansy << " " << ansh << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    tree = [[] for _ in range(N)]
    
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    
    ans = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    visited = [False] * N
    visited[0] = True
    Q = deque([0])

    while Q:
        p = Q.popleft()

        for q in tree[p]:
            if visited[q]:
                continue
            visited[q] = True
            ans[q] += ans[p]
            Q.append(q)

    print(*ans)
main()

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

int kind(string s){
	int ans = 0;
	rep(i,s.size()){
		ans = max(ans, s[i] - 'a' + 1);
	}
	return ans;
}

void Main(){
	int n;
	cin >> n;
	vector<string> temp = {"a"};
	vector<string> ans = {"a"};
  
	// cout << kind("abc") << endl;
	// cout << kind("aaa") << endl;

	rep(i, n-1){
		ans.clear();
		for(auto s : temp){
			rep(j, kind(s)+1){
				char next = 'a' + j;
				string ok = s + next;
				ans.pb(ok);
			}          
		}
		temp = ans;
	}

	for(auto s : ans){
		cout << s << endl;
	}
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 10060
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::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 n;
	cin>>n;
	vi h(n);
	rep(i,n){
		cin>>h[i];
	}		
	vi cost(n);
	cost[0] = 0;
	cost[1] = abs(h[0]-h[1]);
	repa(i,2,n){
		cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<cost[n-1]<<" ";
	return 0;
}

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

int main() {
  int H,W,h,w;
  int count = 0;
  cin >> H >> W >> h >> w;
  vector<vector<int>> matrix(H, vector<int>(W));
  //h個の行のの塗りつぶし
  for (int i = 0; i < W; i++){
    for(int j = 0; j < h; j++)
    matrix.at(j).at(i) = 1;
  }
  //w列目の塗りつぶし
  for(int i = 0; i < H; i++){
    for(int j = 0; j < w; j++)
    //塗りつぶし
    matrix.at(i).at(j) = 1;
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
 
      // 上からi番目、左からj番目の画素が0かを判定
      if (matrix.at(i).at(j) != 1) {
        count++;
      }
    }
  }
  cout << count << endl;
}


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

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

  int ans = 0;
  if(N % 2 == 0){
    ans = N;
  }
  else{
    ans = N * 2;
  }
  
  cout << ans;
  return 0;
}

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

int bubbleSort(int [],int);

int main(){
  int n,cnt;
  int *A;
  int i;
  
  scanf("%d",&n);

  A = (int *)malloc(n*sizeof(int));

  for(i=0; i<n; i++)
    scanf("%d",&A[i]);

  cnt = bubbleSort(A,n);

  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i<n-1)
      printf(" ");
  }
  printf("\n");

  printf("%d\n",cnt);
  
  free(A);
  return 0;
}

int bubbleSort(int A[],int n){
  int flag = 1;
  int tmp, cnt=0;
  int i;
  
  while(flag){
    flag = 0;

    for(i=n-1; i>=1; i--){
      if(A[i] < A[i-1]){
	tmp = A[i];
	A[i] = A[i-1];
	A[i-1] = tmp;
	
	cnt++;
	flag = 1;
      }
    }
  }

  return cnt;
}



Measured memory_bytes: 2140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    int mi = *min_element(all(v));
    int mx = *max_element(all(v));

    vector<pii> ans;
    if(abs(mi)>abs(mx)){
        int p = min_element(all(v)) - v.begin();
        rep(i,n){
            if(i!=p)ans.pb(pii(i,p));
        }
        for(int i=n-2;i>=0;i--){
            ans.pb(pii(i,i+1));
        }
    }else{
        int p = max_element(all(v)) - v.begin();
        rep(i,n){
            if(i!=p)ans.pb(pii(i,p));
        }
        for(int i=1;i<n;i++){
            ans.pb(pii(i,i-1));
        }
    }
    
    cout<<ans.size()<<endl;
    rep(i,ans.size()){
        cout<<ans[i].second+1<<" "<<ans[i].first+1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if (A + B - 1 <= N and N <= A * B and A <= N and B <= N) {
        vector<int> a(N);
        for (int i = 0; i < N; i++) a[i] = N - i;
        reverse(a.begin(), a.begin() + A);
        if (B > 1) {
            int rest = N - A;
            int pos = A;
            for (int i = B - 1; i >= 1; i--) {
                const int num = rest / i;
                reverse(a.begin() + pos, a.begin() + pos + num);
                pos += num;
                rest -= num;
            }
        }
        for (int i = 0; i < N; i++) {
            cout << a[i] << " ";
        }
        cout << endl;
    } else {
        cout << "-1\n";
    }
    return 0;
}


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

int bubblesort(int A[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; i < N; i++) {
		flag = 0;
		for (int j = N - 1; j > i; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int A[100], N, sw;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sw = bubblesort(A, N);
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(){

	int a,b,c;

	cin>>a>>b>>c;

	int now=0;
	int goal = c;

	while(1){
		if(now<=goal && goal<=now+a){
			cout<<goal<<endl;
			break;
		}
		now+= (a+b);

		if(goal<now){
			goal+=60;
			if(60%(a+b)==0){
				cout<<-1<<endl;
				return 0;
			}
		}
		if(now%60==0){
			cout<<-1<<endl;
			return 0;
		}
	}

	return 0;

}

Measured memory_bytes: 3092
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    bool f; char ch; f=0; x=0; ch=getchar();
    while(ch<'0' || ch>'9') {if(ch=='-') f=1; ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    if(f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi=(double) acos(-1.0);
const int MOD=(int) 1e9+7;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int SINF=(uint) ~0>>1;
const LL  SLINF=(ULL) (-1)>>1;
const double DINF=(double) 1e50;
const double eps=(double) 1e-8;
const int maxn=(int) 1e5+20;
const int maxm=(int) 1e5+20;
const int maxk=(int) 5e2+20;

inline int sig(double x) {return x<-eps?-1:x>eps;}

//--------------start------------------

int n;
int dis[maxn];

deque<int> Q;
bool inq[maxn];

void spfa()
{
    for(int i=0;i<n;i++) dis[i]=INF, inq[i]=0;
    dis[1]=1;
    inq[1]=1;
    Q.push_front(1);
    while(!Q.empty())
    {
        int u=Q.front(), v; Q.pop_front(); inq[u]=0;
        v=(u+1)%n;
        if(dis[v]>dis[u]+1)
        {
            dis[v]=dis[u]+1;
            if(!inq[v]) inq[v]=1, Q.push_back(v);
        }
        v=u*10%n;
        if(dis[v]>dis[u])
        {
            dis[v]=dis[u];
            if(!inq[v]) inq[v]=1, Q.push_front(v);
        }
    }
}

void work()
{
    read(n);

    spfa();

    printf("%d\n",dis[0]);
}

//--------------end--------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 896
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

typedef long long LL;

vector<LL> getSum(const vector<LL> &v) {
	vector<LL> sum(1, 0);
	for (LL i = 0; i != v.size(); ++i) {
		sum.push_back(sum[i] + v[i]);
	}
	return sum;
}

int main(int argc, char *argv[]) {
	LL n;
	cin >> n;
	vector<LL> v(n);
	for (LL i = 0; i < n; ++i) {
		cin >> v[i];
	}
	auto getBalancedPositions = [&](const vector<LL> &v, const vector<LL> &sum) {
		vector<LL> pos(n + 1);
		LL left = 1;
		for (LL i = 2; i <= n; ++i) {
			while (left < i - 1) {
				LL a = sum[left], b = sum[i] - sum[left];
				LL na = sum[left + 1], nb = sum[i] - sum[left + 1];
				if (abs(na - nb) >= abs(a - b)) {
					break;
				}
				++left;
			}
			pos[i] = left;
		}
		return pos;
	};
	vector<LL> sum = getSum(v);
	vector<LL> l = getBalancedPositions(v, sum);
	reverse(v.begin(), v.end());
	vector<LL> rsum = getSum(v);
	vector<LL> r = getBalancedPositions(v, rsum);

	LL ans = 1LL << 60;
	for (LL i = 2; i <= n - 2; ++i) {
		LL a = sum[l[i]], b = sum[i] - a;
		LL c = rsum[r[n - i]], d = rsum[n - i] - c;
		LL t = max({ a, b, c, d }) - min({ a, b, c, d });
		ans = min(ans, t);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8688
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>

using namespace std;

using ll = long long;
//constexpr ll N = 2e5;
//ll a[N];


int main()
{
	ll A,B,a, b;
	cin >> A >> B;

	if (A > B) {
		a = A;
		b = B;
	}
	else {
		a = B;
		b = A;
	}

	
	int r;
	while (true)
	{
		r = a % b;
		if (r == 0)
			break;
		a = b;
		b = r;
	}
	
	
	cout << A / b * B;
	


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 10;




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int n, m; cin >> n >> m;
	// sの数の2倍がcの数より少ない場合
	// ⇔cが多い
	if (n * 2 <= m) {
		cout << n + ((m - (2 * n))) / 4 << endl;
	}
	else {
		cout << m / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
words = []
for i in range(N):
  wi = input()
  if wi in words:
    print("No")
    exit()
  if i==0:
    words.append(wi)
  else:
    if words[-1][-1] != wi[0]:
      print("No")
      exit()
    words.append(wi)
print("Yes")

Measured memory_bytes: 3064