akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#define For(i,j,k)  for(int i=j;i<=k;++i)
#define Dow(i,j,k)  for(int i=k;i>=j;--i)
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double db;
const int INF = 0x7fffffff;
const int maxn = 5e4 + 10;
const int MAXN = 200050, SIZE = 26;  
struct SAM {  
    int len[MAXN], link[MAXN], next[MAXN][SIZE];  
    int total, last;  
    inline int newNode(int L) {  
        len[++total] = L; link[total] = 0;  
        for(int i = 0; i < SIZE; ++i) next[total][i] = 0;  
        return total;  
    }  
    inline void Add(int c) {  
        int i, p = last, cur = newNode(len[last] + 1);  
        for(; p && !next[p][c]; p = link[p]) next[p][c] = cur;  
        if(!p) link[cur] = 1;//令其指向初始状态  
        else {  
            int q = next[p][c];  
            if(len[q] == len[p] + 1) link[cur] = q;  
            else {//>  
                int clone = newNode(len[p] + 1);  
                for(i = 0; i < SIZE; ++i) next[clone][i] = next[q][i];  
                link[clone] = link[q];  
                link[q] = link[cur] = clone;  
                for(; p && next[p][c] == q; p = link[p]) next[p][c] = clone;  
            }  
        }  
        last = cur;  
    }  
    void Init () {//根节点是1  
        total = 0;  
        last = newNode(0);  
    }  
}sam;  
char str[MAXN];  
int num[MAXN],idx[MAXN];  
int dp[MAXN];  
void solve(int k){  
    int now=1,L=0;  
    while(k){  
        for(int j=0;j<SIZE;j++){  
            if(sam.next[now][j]==0)  
                continue;  
            int x=sam.next[now][j];  
            if(k>dp[x])  
                k-=dp[x];  
            else{  
                str[L++]='a'+j;  
                now=x;  
                k--;  
                break;  
            }  
        }  
    }  
    str[L]='\0';  
    puts(str);  
}  
int main(){  
  
    int Q,k;  
    scanf("%s",str);  
        sam.Init();  
        for(int i=0;str[i]!='\0';i++)  
            sam.Add(str[i]-'a');  
        for(int i=1;i<=sam.total;i++)  
            num[i]=0;  
        for(int i=1;i<=sam.total;i++)  
            num[sam.len[i]]++;  
        for(int i=1;i<=sam.total;i++)  
            num[i]+=num[i-1];  
        for(int i=1;i<=sam.total;i++)  
            idx[num[sam.len[i]]--]=i;  
  
        for(int i=sam.total;i>=1;i--){  
            int now=idx[i];  
            dp[now]=1;  
            for(int j=0;j<SIZE;j++)  
                dp[now]+=dp[sam.next[now][j]];  
        }  
            scanf("%d",&k);  
            solve(k);   
    return 0;  
}  

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int c[5][5];
  vector<int> A(4, INF);
  reps(i, 1, 3) {
    reps(j, 1, 3) {
      cin >> c[i][j];
      chmin(A[i], c[i][j]);
    }
  }

  vector<int> B(4);
  reps(i, 1, 3) {
    reps(j, 1, 3) {
      if (i == 1) B[j] = c[i][j] - A[i];
      else {
        if (c[i][j] - A[i] != B[j]) {
          cout << "No" << "\n";
          return 0;
        }
      }
    }
  }

  cout << "Yes" << "\n";

  return 0;
}

Measured memory_bytes: 256
import Foundation

let input = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let N = input[0]
let K = input[1]

let price = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let lowToExpensive = price.sorted()

var totalPrice = 0

for i in 0...K - 1 {
    totalPrice += lowToExpensive[i]
}

print(totalPrice)

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

int main(){ 
    int A, B, C;
    cin >> A >> B >> C;
    
    int ans = 0;
    while(C>0){
        for(int i=0;i<7;i++){
            C -= A;
            ans++;
            if(C <= 0) goto end;
        }
        C -= B;
    }
    end: cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3096
// olaf_surgut
//        _        __                             _   
//   ___ | | __ _ / _|  ___ _   _ _ __ __ _ _   _| |_ 
//  / _ \| |/ _` | |_  / __| | | | '__/ _` | | | | __|
// | (_) | | (_| |  _| \__ \ |_| | | | (_| | |_| | |_ 
//  \___/|_|\__,_|_|___|___/\__,_|_|  \__, |\__,_|\__|
//                |_____|             |___/           
//
#pragma optimize ("Ofast")
#include <bits/stdc++.h>
#define st  first
#define nd  second
#define ll  long long
#define INF 1000000005LL
using namespace std;

void solve(){
  ll n;
  cin >> n;
  vector<pair<ll,int>> p;
  for(ll i = 2; i * i <= n; i++){
    int cnt = 0;
    while(n % i == 0){
      cnt++;
      n /= i;
    }
    if(cnt) p.push_back({i, cnt});
  }  
  if(n > 1) p.push_back({n, 1});

  // for(const pair<int,int> & x : p)  cout << x.st << ' ' << x.nd << '\n';

  int ans = 0;
 
  for(int i = 0; i < (int)p.size(); i++){
    for(int j = 1; j <= (int)p[i].nd; j++){
      ans ++;
      p[i].nd -= j;
    }   

  }

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

int main(){
#ifndef LOCAL
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  int _ = 1;
  // cin >> _;
  while(_--)solve();
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(abs(c-a) <= d){
    // direct
    cout << "Yes" << endl;
  }else{
    if((abs(b-a)<=d) && (abs(b-c)<=d) && (abs(c-a)<=2*d)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }

  return 0;
}


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

[N, M] = map(int, input().split())

ans = 0
# Cが余る場合
if N * 2 <= M:
    # Sを全部使ってからCを使う
    print(N + (M-2*N) // 4)
# Sが余るとき
else:
    # ccの個数だけ作れる
    print(M // 2)


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	if A-K >= 0 {
		fmt.Printf("%d %d", A-K, B)
	} else {
		n := K - A
		if n <= B {
			fmt.Printf("%d %d", 0, B-n)
		} else {
			fmt.Printf("%d %d", 0, 0)
		}
	}

}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    if(a == b && b == c && a == c){
        cout << 1 << endl;    
    }
    else if(((a == b) && (b != c)) || ((a == c) && (c != b)) || ((b == c) && (c != a)) ){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(K)]

mod = 998244353

dp = [0]*(N+1)
tmp = 1

for i in range(N-1):
    tmp = (tmp + dp[i]) % mod
    # dp[i] = tmp
    for l, r in LR:
        dp[min(i+l, N)] = (dp[min(i+l, N)] + tmp) % mod
        dp[min(i+r+1, N)] = (dp[min(i+r+1, N)] - tmp) % mod
print(dp[N-1])

Measured memory_bytes: 81072
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++ ) {
    if ( ch == '\\') S1.push(i);
    else if ( ch == '/' && S1.size() > 0 ) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while ( S2.size() > 0 && S2.top().first > j ) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while ( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3196
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 3 "../../library/popcount.hpp"

int popcount(int n) {
  return __builtin_popcount(n);
}

ll popcount(ll n) {
  return __builtin_popcountll(n);
}
#line 3 "e.cpp"

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) {
    cin >> s[i];
  }

  ll ans = 1LL<<60;

  rep(bit, 1LL<<(h-1)) {
    ll sum = popcount(bit);
    ll tmp = sum+1;


    bool f = true;

    vl cnt(tmp);
    rep(i, w) {
      vl cnt2(tmp);
      ll ind = 0;
      rep(j, h) {
        if (s[j][i] == '1') cnt2[ind]++;
        if ((bit>>j) & 1) {
          ind++;
        }
      }

      bool is_over = true;
      rep(j, tmp) {
        if (cnt[j] + cnt2[j] > k) {
          is_over = false;
          break;
        }
      }

      rep(j, tmp) {
        if (cnt2[j] > k) {
          f = false;
          break;
        }
      }

      if (is_over) {
        rep(j, tmp) {
          cnt[j] += cnt2[j];
        }
      } else {
        sum++;
        rep(j, tmp) {
          cnt[j] = cnt2[j];
        }
      }
    }

    if (f) cmin(ans, sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [i32; n],
    };
    let mut a = a.clone();
    a.sort_by(|a, b| b.cmp(a));
    let sum: i32 = a.iter().sum();
    if sum - 4 * a[m - 1] * (m as i32) > 0 {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
template<typename T>
void read(T &x)
{
    char ch=getchar();
    int f=1;
    for (x=0;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
    if (ch=='-') f=-1,ch=getchar();
    for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
    x*=f;
}
typedef long long ll; 
#define MAXN 100010
struct edge{
	int s,t,next;
}e[MAXN<<1];
int head[MAXN],cnt;
void addedge(int s,int t)
{
	e[cnt].s=s;e[cnt].t=t;e[cnt].next=head[s];head[s]=cnt++;
	e[cnt].s=t;e[cnt].t=s;e[cnt].next=head[t];head[t]=cnt++;
}
int n,u,v;
ll sg[MAXN];
void dfs(int node,int lastfa)
{
	sg[node]=0;
	for (int i=head[node];i!=-1;i=e[i].next)
		if (e[i].t!=lastfa)
		{
			dfs(e[i].t,node);
			sg[node]^=(sg[e[i].t]+1);
		}
}
int main()
{
	read(n);
	memset(head,0xff,sizeof(head));
	cnt=0;
	for (int i=1;i<n;i++)
	{
		read(u),read(v);
		addedge(u,v);
	}
	dfs(1,1);
	puts(sg[1]==0 ? "Bob" : "Alice");
	return 0;
}

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

const int MaxN = 1e5 + 6.66;
long long arr[MaxN];
map<long long, int> cnt;

long long mul(long long a, long long b) {
  if(a > 1e15l / b) return 1e15l;
  return a * b;
}

int main() {
  int N; scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%lld", arr + i);
  for(int i = 0; i < N; i++) {
    long long aa = arr[i];
    for(long long c = 2; c * c * c <= aa; c++) {
      if(arr[i] % c) continue;
      long long x = c * c * c;
      while(arr[i] % x == 0) arr[i] /= x;
    }
    cnt[arr[i]]++;
  }
  int ans = 0;
  for(auto x : cnt) {
    if(!x.second) continue;
    long long a = x.first;
    long long tmp = a;
    long long b = 1;
    for(long long x = 2; x * x * x <= 1e10l; x++) {
      if(tmp % x) continue;
      if(tmp % (x * x)) b = mul(b, x * x), tmp /= x;
      else b = mul(b, x), tmp /= x * x;
    }
    if(tmp > 1) b = mul(b, tmp * tmp);
    if(b > 1e10l) ans += x.second;
    else if(a == b) ans ++;
    else {
      ans += max(x.second, cnt[b]);
      cnt[b] = 0;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

int main()
{
  int N, A[202020];
  cin >> N;
  for(int i = 1; i < 2 * N; i++) {
    cin >> A[i];
  }

  auto check = [&](int v)
  {
    vector< int > binary(2 * N);
    for(int i = 1; i < 2 * N; i++) binary[i] = A[i] >= v;
    int a = N, b = N;
    while(a > 1 && binary[a - 1] != binary[a]) --a;
    while(b + 1 < 2 * N && binary[b + 1] != binary[b]) ++b;
    return ((a + b) >= 2 * N ? binary[a] : binary[b]);
  };
  int ok = 1, ng = 2 * N - 1;
  while(ng - ok > 1) {
    int mid = (ok + ng) / 2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}



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

using namespace std ;

int main ()
{
    string s ;
    long long g = 0 ;
    cin >> s ;
    int x = s . size ()  - 1 ;
    for ( int i = 0 ; i < ( 1 << x ) ; ++ i ){
        long long sum = s [ 0 ] - '0' ;
        for ( int j = 0 ; j < x ; ++ j ){
            if ( i & ( 1 << j ) ){
                g += sum ;
                sum = 0 ;
            }
            sum = sum * 10 + ( s [ j + 1 ] - '0' ) ;
        }
        g += sum ;
    }
    cout << g ;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

//----------1000000007----------
const int O = 1000000007;
int add(int a, int b)
{
	return (a + b) % O;
}
int sub(int a, int b)
{
	return (a + O - b) % O;
}
int mul(int a, int b)
{
	return (a * b) % O;
}

int kai(int n)
{
	return ((n + 1) * n) / 2;

}

int N, K;
int A[2000];

signed main()
{
	cin >> N >> K;
	REP(i, N) cin >> A[i];

	int cnt1[2000] = {};
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (A[i] > A[j]) cnt1[i]++;
		}
	}

	int cnt2[2000] = {};
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (A[i] > A[j]) cnt2[i]++;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int k = kai(K - 1);
		k = k % O;
		int a = mul(cnt1[i], K);
		int b = mul(cnt2[i], k);
		a = a % O;
		b = b % O;
		ans = add(ans, a);
		ans = add(ans, b);
	}

	cout << ans << endl;
}




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

int max(int a,int b){if(a>b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int main(){
  int n,p,b[64],w,i;
  while(scanf("%d%d",&n,&p),p!=0){
    w=p;
    for(i=0;i<n;i++){b[i]=0;}
    i=0;
    while(1){
      if(w!=0){
        b[i]++;
        w--;
        if(b[i]==p){printf("%d\n",i);break;}
      }
      else{w=b[i];b[i]=0;}
      i++;i%=n;
    }
  }
  return 0;
}



Measured memory_bytes: 1972
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
 
int main(){

	long long int n;


	while(cin>>n){
		vector<long long int> v;
		if(n==0)break;
		long long int ans=10000001;

		for(int i=0;i<n;i++){
			long long int a;
			cin>>a;
			v.push_back(a); 
		}

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

		for(int i=0;i<n-1;i++){
			ans=min(ans,v[i+1]-v[i]);
		}

		cout<<ans<<endl;


	}
}

Measured memory_bytes: 3140
/*
  AOJ 0135
  Title:Clock Short Hand and Long Hand
  @kankichi573
*/
#include <stdio.h>
#include <float.h>

int n,h,m;
int long_h,long_l,short_h,short_l;
char output[3][10]={"alert","warning","safe"};

int my_abs(int x)
{
  return (x>=0)?x:(-x);
}
int  hantei(int short_h,int short_l,int long_h,int long_l) 
{
  int deg=abs((short_h-long_h)*60+(short_l-long_l));
  if(deg>360)
    deg=720-deg;

  //printf("deg=%d\n",deg);

  if(deg<60)
    return(1);
  else if((60 <= deg) && (deg < 180))
    return(2);
  else
    return(3);
}


main ()
{
  int i,ret;
  scanf("%d",&n);
  {
    for(i=0;i<n;i++)
      {
	scanf("%d:%d",&h,&m);
	short_h=h;  // 30deg    tanni
	short_l=m;  // 30deg/60 tanni

	long_h = m / 5;
	long_l = (m % 5)*12;
	ret=hantei(short_h,short_l,long_h,long_l);
	printf("%s\n",output[ret-1]);
      }
  }
  return(0);
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n,a,b;
vector<ll> res;

int main(){
  cin>>n>>a>>b;
  bool swapped=false;
  if(a<b){
    swap(a,b);
    swapped=true;
  }
  if(a<(b+n-1)/b||a>n-b+1){
    cout<<-1<<endl;
    return 0;
  }

  ll rest=n;
  rep(i,n){
    if(a>(b+rest-1)/b){
      res.push_back(i+1);
      a--;
      rest--;
    }else{
      for(ll j=min(n-1,i+b-1);j>=i;j--){
        res.push_back(j+1);
      }
      a--;
      i+=b-1;
    }
  }

  if(swapped){
    rep(i,n){
      res[i]=n+1-res[i];
    }
  }
  rep(i,n)cout<<res[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 6128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from copy import deepcopy


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


n = int(readline())
ans = len(make_divisors(n - 1))
for check in make_divisors(n):
    if check == 1:
        continue
    nn = deepcopy(n)
    while nn % check == 0:
        nn //= check
    if nn % check == 1:
        ans += 1
print(ans - 1)


Measured memory_bytes: 3728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll x,abc=0,m,n,k,cnt=0;
	cin>>n;
	ll a[n+1];
	vector<ll> v;
	v.push_back(0);
	REP(i,1,n)
	{
		cin>>x;
		a[x]=i;
	}
	REP(i,1,n)
		cout<<a[i]<<" ";
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define S(v) sort(v.begin(), v.end())
#define print(v) for(auto i:v)cout<<i<<" "
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	ll t= 1;
	// cin>>t;
	while(t--)
	{
		ll n, k;
		cin>>n>>k;
		vector<ll> v(n);
		loop(i,0,n)cin>>v[i];
		ll dp[n];
		dp[0] = 0;
		dp[1] = abs(v[1] - v[0]);
		loop(i, 1, n){
			dp[i] = LONG_LONG_MAX;
			loop(j, max((ll)0, i - k), i){
				dp[i] = min(dp[i], abs(v[i] - v[j]) + dp[j]);
			}

		}
		cout<<dp[n-1]<<endl;

		
	}
} 

Measured memory_bytes: 4780
//Only the Creator has given me strength!

#include<cstdio>

#include<sstream>

#include<cstdlib>

#include<cctype>

#include<cmath>

#include<algorithm>

#include<set>

#include<queue>

#include<stack>

#include<list>

#include<iostream>

#include<fstream>

#include<numeric>

#include<string>

#include<vector>

#include<cstring>

#include<map>

#include<iterator>

#include<bitset>

typedef long long ll;

#define pi 3.1415926535897931159979635

#define pb push_back

#define vctr vector < int >

#define vvtr vector < vctr >

using namespace std;

ll mod=1e7+7;

void fastio() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int main() {

    fastio();

    string a;

    cin>>a;

    int s=a.size();

    if(a[s-1]=='s') cout<<a<<"es\n";

    else cout<<a<<"s\n";

    return 0;

}

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

int b,r;
int g,c,s;
int t;

int main()
{
	while( cin >> b >> r >> g >> c >> s >> t )
	{
		if( b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0 )
			break;

		//メダルの増減
		int diff = 0;
		t -= s;				//スター回ノーカウント
		diff += 12*b;
		diff += 13*5*b;
		diff += 12*r;
		diff += 13*3*r;
		t = t - 6*b - 4*r;
		//残りですね
		diff -= t*3;
		diff += g*7 + c*2;
		//答え
		cout << 100 + diff << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n=int(input())
A=[]
for i in range(n):
    A.append(int(input()))

B=sorted(A[::2])
C=sorted(A)
dic={}
for i in range(n):
    dic[C[i]]=i

ans=0
for i in range(len(B)):
    if dic[B[i]]%2==1:
        ans+=1
print(ans)

Measured memory_bytes: 24828
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define endl '\n'
#define pi 3.1415926536
#define inf 1e15
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,m;
    cin>>n>>m;
    map<int,int>mpp;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        if(mpp.find(-x)!=mpp.end())mpp[-x]=max(-y,mpp[-x]);
        else mpp[-x]=-y;
    }
    int cur=n,cnt=0;
    
    for(auto a:mpp){
       // cout<<cur<<" "<<abs(a.second)<<" "<<abs(a.first)<<endl;
        if(cur>=abs(a.second)){
            cur=abs(a.first);
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int A,B,C;
	cin>>A>>B>>C;
	string ans = "No";
	if(A<C&&C<B)ans ="Yes";
	if(A>C&&C>B)ans = "Yes";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

#define NUM 3 
#define MAX_B 100

int A[NUM][NUM];
bool A_[NUM][NUM];

bool is_ok(){
    for(int i = 0; i < NUM; i++){
        if(A_[i][0] && A_[i][1] && A_[i][2]){
            return true;
        }
    }
    for(int i = 0; i < NUM; i++){
        if(A_[0][i] && A_[1][i] && A_[2][i]){
            return true;
        }
    }
    if(A_[0][0] && A_[1][1] && A_[2][2]){
        return true;
    }
    if(A_[0][2] && A_[1][1] && A_[2][0]){
        return true;
    }

    return false;
}

int main(void){
    int N;
    int b;

    for(int i = 0; i < NUM; i++){
        for(int j = 0; j < NUM; j++){
            scanf("%d", &A[i][j]);
            A_[i][j] = false;
        }
    }

    scanf("%d", &N);

    for(int i = 0; i < N; i++){
        scanf("%d", &b);
        for(int i = 0; i < NUM; i++){
            for(int j = 0; j < NUM; j++){
                if(A[i][j] == b){
                    A_[i][j] = true;
                }
            }
        }
    }

    if(is_ok()){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


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

#define ll long long
#define mod 1000000007
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define dbg(x) cout<<#x<<" "<<x
#define sci(x) scanf("%d",&x)
#define scd(x) scanf("%lf",&x)
#define scl(x) scanf("%lld",&x)
#define pfi(x) printf("%d",x)
#define pfd(x) printf("%lf",x)
#define pfl(x) printf("%lld",x)


auto fatafat=[](){std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); return 0;}();

ll maxSum(int n,ll maxWt,vector<ll> vl,vector<ll>wt,vector<vector<ll>> &dp)
{
//     if(n==0)
//         return 0;
//     if(dp[n][maxWt]!=-1)
//         return dp[n][maxWt];
    
    
//     if(wt[n-1]<=maxWt)
//         dp[n][maxWt]= max(vl[n-1]+maxSum(n-1,maxWt-wt[n-1],vl,wt,dp) , maxSum(n-1,maxWt,vl,wt,dp));
//     else 
//         dp[n][maxWt]= maxSum(n-1,maxWt,vl,wt,dp);
    
    
        for(int i=0;i<=maxWt;i++)
        {
            dp[0][i]=0;
        }
        
        for(int i=0;i<=n;i++)
        {
            dp[i][0]=0;
        }
    
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=maxWt;j++)
            {
                if(wt[i-1]<=j)
                    dp[i][j]=max(vl[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j] );
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
    
    return dp[n][maxWt];
    
    
}


int main()
{
   
    int n;
    ll w;
    cin>>n>>w;
    vector<ll> wt(n);
    vector<ll> vl(n);
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>vl[i];
    }
    
    vector<vector<ll>> dp(n+1);
    for(int i=0;i<=n;i++)
    {
        dp[i].resize(w+1,-1);
    }
    
    
    
    cout<<maxSum(n,w,vl,wt,dp);
    
   
    
    
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    int count=0;
	cin >> a >> b >>c;
    for(int i=b;i>0;i=i-a){
      if(i<a || i<=0)break;
      if(c==count)break;
      count++;
    }
    cout << count <<endl;
    return 0;
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/(b))
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    LL N;
    cin >> N;
    vector<LL> A (N);
    LL sum = 0;
    for(LL i = 0;i < N;i++){
        cin >> A[i];
        sum += A[i];
    }
    LL ans = 0;
    for(LL i = 0;i < N;i++){
        sum -= A[i];
        ans += A[i] * (sum%MOD);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    cin>>str ;
    n = str.size() ;
    c = 0 ;
    a = 0 ;
    b = 0 ;
    for(i=0 ; i<n ; i=i+1)
    {
        if(i<n-1 && str[i]=='0' && str[i+1]=='1')
        {
            c++ ;
            i++ ;
        }
        else if(str[i]=='0')
        {
            if(b>0)
            {
            	b-- ;
            	c++ ;
			}
			else
			{
				a++ ;
			}
        }
        else
        {
            if(a>0)
            {
            	c++ ;
            	a-- ;
			}
			else
			{
				b++ ;
			}
        }
    }
    cout<<c*2 ;
}

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

const int inf = 1e9;
int n;
int dp[1 << 18][55];
int A[55][2];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> A[i][0];
    for (int i = 1; i <= n; i++) cin >> A[i][1];
    for (int i = 1; i < (1 << n); i++) {
        int x = __builtin_popcount(i);
        for (int j = 1; j <= 50; j++) {
            dp[i][j] = inf;
        }
        for (int j = 1; j <= n; j++) {
            if (i & (1 << j - 1)) {
                int v = A[j][x - j & 1];
                dp[i][v] = min(dp[i][v], dp[i ^ (1 << j - 1)][v] + __builtin_popcount(i ^ (i & (1 << j) - 1)));
            }
        }
        for (int j = 2; j <= 50; j++) {
            dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        }
    }
    cout << (dp[(1 << n) - 1][50] < inf ? dp[(1 << n) - 1][50] : -1);
}

Measured memory_bytes: 56576
// https://atcoder.jp/contests/abc042/tasks/abc042_b
// B - 文字列大好きいろはちゃんイージー
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

// 文字列の比較
int comp_s(char a[], char b[], int n) {
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            return a[i] - b[i];
        }
    }
    return 0;
}

// 文字列ソート
void sort_s(char a[][101], int num) {
    int i, j;
    char t[101];

    for (i = 0; i < num-1; i++) {
        for (j = 0; j < num-i-1; j++) {
            if (comp_s(a[j], a[j+1], 100) > 0) {
                strcpy(t, a[j]);
                strcpy(a[j], a[j+1]);
                strcpy(a[j+1], t);
            }
        }
    }
}
int main(void) {
    int l, n, i;
    char s[100][101];
    n = get_num();
    l = get_num();
    for (i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }

    sort_s(s, n);
    
    for (i = 0; i < n; i++) {
        printf("%s", s[i]);
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std ;
typedef long long int ll ;


int main(){
	ios;
	string s;
	cin>>s;
	if(s=="Sunny")cout<<"Cloudy\n";
	else if(s=="Cloudy") cout<<"Rainy\n";
	else cout<<"Sunny\n";

	return 0;
}



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

class Main
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        Map<String,Integer> map = new HashMap<>();
        for(int i=0;i<a;i++)
        {
            map.putIfAbsent(sc.next(),1);

        }
        System.out.print(map.size());


    }
}

Measured memory_bytes: 77032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N, D;
        List<int[]> points = new ArrayList<>();

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            D = in.nextInt();
            for (int i = 0; i < N; ++i) {
                int[] p = new int[D];
                for (int j = 0; j < D; ++j) {
                    p[j] = in.nextInt();
                }
                points.add(p);
            }

            int ans = 0;
            int len = points.size();
            for (int i = 0; i < len; ++i) {
                for (int j = i + 1; j < len; ++j) {
                    int[] p1 = points.get(i);
                    int[] p2 = points.get(j);
                    double d = 0;
                    for (int k = 0; k < D; ++k) {
                        d += Math.pow(p1[k] - p2[k], 2);
                    }
                    d = Math.sqrt(d);
                    if (d == Math.ceil(d)) ans++;
                }
            }

            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 21588
#include<iostream>
using namespace std;
int main()
{
    int m,d;
    int count = 0;
    cin >> m >> d;
    for(int i = 22;i<=d;i++){
        if(((i/10)*(i%10))<=m&&(i%10)>1){
            count++;
        }
    }
    cout << count;

}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    long long A, B, V, W, T;
    scanf("%lld %lld %lld %lld %lld", &A, &V, &B, &W, &T);

    long long dist = B - A, v = V - W;
    if(A == B) printf("YES");
    else if(v < 0) printf("NO");
    else {
        dist = dist < 0 ? -dist : dist;
        printf(T * v >= dist ? "YES" : "NO");
    }
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll x, a, b;

	cin >> x >> a >> b;

	if (abs(x - a) <= abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char *p;
    p = new char[n];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int l = 0, r = n - 1;
    int ans = 0;
    while (l <= r)
    {
        if (p[l] == 'W' && p[r] == 'R')
        {
            ans++;
            l++;
            r--;
            continue;
        }
        else if (p[l] == 'W' && p[r] == 'W')
        {
            r--;
            continue;
        }
        else if (p[l] == 'R')
        {
            l++;
            continue;
        }
    }
    delete[] p;
    cout << ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	ll S;
	cin >> S;

	ll s = (ll) sqrt(S);
	if(s * s != S) s++;
	ll t = s * s - S;

	cout << "0 0 1 " << s << " " << s << " " << t << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int int64_t

signed main(){
	int n,m;cin>>n>>m;
	vector<pair<int,int>> v(n);
	rep(i,n){
		int a,b;cin>>a>>b;
		v[i]=make_pair(a,b);
	}
	sort(all(v));
	int d=0,ans=0;
	rep(i,n){
		int e=0;
		while(d<m){
			if(e==v[i].second)break;
			e++;d++;
			ans+=v[i].first;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = list(it)

    ans = 0
    x = A[0]

    for i in range(1, N):
        ai = A[i]
        diff = x - ai
        if diff >= 0:
            ans += diff
        else:
            x = ai

    print(ans)

if __name__ == "__main__":
    resolve()


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

void Main() {
  std::string wether;

  std::cin >> wether;
  if (wether == "Sunny") {
    std::cout << "Cloudy" << std::endl;
  } else if (wether == "Cloudy") {
    std::cout << "Rainy" << std::endl;
  } else if (wether == "Rainy") {
    std::cout << "Sunny" << std::endl;
  }
}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Answer {
    private static readonly string TextOK = "Yay!";
    private static readonly string TextNG = ":(";
  
    private static void Main(string[] args) {
        var numberOfLines = 5;
        var inputs = new List<string>();
        
        for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) {
            inputs.Add(Console.ReadLine().Trim());
        }

        var inputLastLine = Console.ReadLine().Trim();
        
        Console.WriteLine(GetAnswer(inputs, inputLastLine));
    }
  
	private static string GetAnswer(List<string> inputs, string inputLastLine) {
        var distance = CalculateDistance(int.Parse(inputs[0]), int.Parse(inputs[inputs.Count - 1]));

        if (!IsDistanceOK(distance, int.Parse(inputLastLine))) {
            return TextNG;
        }

        return TextOK;
    }

    private static int CalculateDistance(int a, int b) => Math.Abs(a - b);
    private static bool IsDistanceOK(int distance, int standard) => distance <= standard;
}

Measured memory_bytes: 11348
#include<stdio.h>

int fibo(int n){
    int f,i;
    int fib[50];
    for(i=0; i<=n; i++){
        if(i==0 || i==1)fib[i] = 1;
        else fib[i] = fib[i-2] + fib[i-1];
    }
    if(n==0 || n==1) return fib[n];
    else {
        f = fib[n-1]+fib[n-2];
        return f;
    }
}
int main(){
    int n;
    scanf("%d", &n);
    printf("%d\n",fibo(n));
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, r, g, b, ans;
string s;

main () {
	cin >> n >> s;
	for (auto c : s)
		if (c == 'R')
			++r;
		else if (c == 'G')
			++g;
		else
			++b;

	ans = r * g * b;	

	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			if (s[i] != s[j]) {
				int dist = j - i;
				if (j + dist < n && s[j + dist] != s[i] && s[j + dist] != s[j]) 
					--ans;  				
			}

	cout << ans << endl;

}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	char ch;
	cin>>ch;
	if(ch>='a'&&ch<='z') cout<<"a\n";
	else cout<<"A\n";
	return 0;
}

Measured memory_bytes: 3648
import sys
import collections
import bisect


def main():
    n = int(input())
    AList = list(map(int, input().split()))
    ASum = sum(AList)
    c = 0
    for i in range(n):
        c += AList[i]
        if c >= ASum / 2:
            k = i
            break
    ans = min(2 * c - ASum, ASum - 2 * c + 2 * AList[k])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33136
#include <iostream>

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    for (int x = 0; x < B; ++x) {
        if ((x * A) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var array [7]string = [7]string{"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}
	var S string
	var ans int
	if scanner.Scan() {
		S = scanner.Text()
	}
	if S == "SUN" {
		ans = 7
	} else {
		var at = 0
		for true {
			if array[at] == S {
				break
			}
			at++
		}
		ans = 6 - at
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n;
	cin >> n;
	n--;
	
	cout << n * (n + 1) / 2ll << endl;

	return 0;
}


Measured memory_bytes: 256