akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 1000000000
typedef long long ll;

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

    int a[n+1]={};

    int d;

    for (int i = 0;i<k;i++){
        cin >> d;
        for (int j= 0;j<d;j++){
            int ind;
            cin >> ind;
            a[ind]++;
        }
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if(a[i]==0){
            sum++;
        }
    }

    cout << sum << endl;
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<ll MOD=ll(1e9+7)>
ll mod_pow(ll n,ll p){
  ll ans=1LL;
  while(p){
    if(p&1)ans*=n;
    n*=n;
    p>>=1;
    ans%=MOD;
    n%=MOD;
  }
  return ans;
}


signed main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  vector<bitset<64>> bit(n);
  rep(i,n){
    bit[i]=bitset<64>(a[i]);
  }
  vector<vector<ll>>cnt(n,vector<ll>(64));
  for(int i=n-1;i>=0;--i){
    if(i+1<n)cnt[i]=cnt[i+1];
    rep(j,64)if(bit[i][j])cnt[i][j]++;
  }

  ll ans = 0;
  rep(i,n-1){
    ll num=n-i-1;
    ll tmp=0;
    rep(j,64){
      if(bit[i][j]){
        tmp += (num-cnt[i+1][j])*((1LL<<j)%MOD);
        tmp%=MOD;
      }
      else if(cnt[i+1][j]){
        tmp += cnt[i+1][j]*((1LL<<j)%MOD);
        tmp %= MOD;
      }
    }
    ans += tmp;
    ans %= MOD;
  }
  cout<<(ans)<<endl;


}

Measured memory_bytes: 166656
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define invrepr(i, a, b) for (int i = b - 1; i >= a; i--)
#define invrep(i, n) invrepr(i, 0, n)
const int MOD = 1e9 + 7;


int main() {
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(),a.end());
    int ans=0;
    rep(i,2) ans+=a[i+1]-a[i];
    cout << ans << endl;
}

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

int main(void) {
  int n;
  cin >> n;
  int d = n % 10;
  if (d == 3) {
    cout << "bon" << endl;
  } else if (d == 0 || d == 1 || d == 6 || d == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }

  return 0;
}

Measured memory_bytes: 3540
from collections import deque
n,k=map(int,input().split())
v=[int(_) for _ in input().split()]
num=min(n,k)
fans=0
for lll in range(num+1):
  for rrr in range(num-lll+1):
    rest=k-lll-rrr
    if rrr!=0:
      pick=v[:lll]+v[-rrr:]
    else:
      pick=v[:lll]
    ans=sum(pick)
    pick=sorted(pick)
    for iii in range(min(rest,len(pick))):
      if pick[iii]<0:
        ans-=pick[iii]
    fans=max(ans,fans)
print(fans)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int number = Integer.parseInt(br.readLine());
        long n = (long)number;
        BigInteger b = BigInteger.valueOf(n);
        BigInteger sum = BigInteger.ZERO;

        for(int i = 1; i <= number; i++){
            if(i%3 != 0 && i%5 != 0){
                sum = sum.add(BigInteger.valueOf((long)i));
            }
        }
        System.out.println(sum);

    }
}



Measured memory_bytes: 50972
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int A = S.indexOf('A');
    int Z = S.lastIndexOf('Z');
    System.out.println(Z - A + 1);
  }
}


Measured memory_bytes: 25428
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;


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

    lint A[100010];
    REP(i,N) cin >> A[i];

    lint x1=A[0];
    REP(i,N-1){
    	if(i%2==0){
    		x1-=A[i+1];
    	}else{
    		x1+=A[i+1];
    	}
    }

    cout << x1 << " ";

    x1 = x1/2;

    lint tmp=x1;
    REP(i,N-1){
    	tmp = A[i]-tmp;
    	cout << tmp*2 << " ";

    }






}


Measured memory_bytes: 2048
#include <stdio.h>

#define true  (1)
#define false  (0)

static int n;
static int A[2000];

int
search(int m, int i)
{
        if (m == 0)
                return true;
        if (i >= n)
                return false;

        if (search(m, i + 1) == true || search(m - A[i], i + 1) == true)
                return true;
        else
                return false;
}

int
main(void)
{
        int q;
        int m;
        int i, j;

        scanf("%d", &n);

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

        for (j = 0; j < q; j++) {
                scanf("%d", &m);
                if (search(m, 0) == true)
                        printf("yes\n");
                else
                        printf("no\n");
        }
        return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
using i128 = __int128_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    i64 a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i < 100000; i++) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 100
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
ll n,m,q,aa[maxn],b[maxn],c[maxn],d[maxn],a[maxn];
ll ans;
void sousuo(ll x,ll y) {
    if(x-1==n){
    	ll tmp=0;
    	for(int i=1;i<=q;i++){
    		if(a[b[i]]-a[aa[i]]==c[i])tmp+=d[i];
		}
		ans=max(ans,tmp);
        return;
    }
    for(int i=y;i<=m;i++){
    	a[x]=i;
    	sousuo(x+1,i);
	}
}

main(){
	IO;
	cin>>n>>m>>q;	
	for(int i=1;i<=q;i++){
		cin>>aa[i]>>b[i]>>c[i]>>d[i];
	}
    sousuo(1,1);
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
    int n=0;
    int s[14];
    int h[14];
    int c[14];
    int d[14];
    char suit;
    char trash;
    int rank;
    int i;

    for(i=0;i<=14;i++){ //配列の中身を初期化
        s[i]=0;
        h[i]=0;
        c[i]=0;
        d[i]=0;
    }
    
    scanf("%d",&n);
    scanf("%c",&trash);

    for(i=0;i<n;i++){ //存在するカードをスキャン
        scanf("%c",&suit);
        scanf("%c",&trash);
        scanf("%d",&rank);
        scanf("%c",&trash);
        if(suit=='S'){
            s[rank]=1;
        }else if(suit=='H'){
            h[rank]=1;
        }else if(suit=='C'){
            c[rank]=1;
        }else{
            d[rank]=1;
        }
    }

    for(i=1;i<14;i++){
        if(s[i]==0){
            printf("S %d\n",i);
        }
    }
    for(i=1;i<14;i++){
        if(h[i]==0){
            printf("H %d\n",i);
        }
    }
    for(i=1;i<14;i++){
        if(c[i]==0){
            printf("C %d\n",i);
        }
    }
    for(i=1;i<14;i++){
        if(d[i]==0){
            printf("D %d\n",i);
        }
    }


    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int n, k, ans;
const int N = 200000;
queue <int> Q;
int ai[N], cc[N], ext[N];
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++ i) cin >> ai[i];
    if (ai[1] != 1) ai[1] = 1, ans ++;
    for (int i = 1; i <= n; ++ i) cc[ai[i]] ++, ext[i] = k;
    for (int i = 1; i <= n; ++ i)
        if (!cc[i]) Q.push(i);
    while (!Q.empty())
    {
        int i = Q.front(); Q.pop();
        if (ai[i] != 1? ext[i] <= 1: ext[i] <= 0) ext[i] = k + 1, ans ++;
        cc[ai[i]] --, ext[ai[i]] = min(ext[i] - 1, ext[ai[i]]);
        if (cc[ai[i]] == 0) Q.push(ai[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N,A,B=map(int,input().split())
    if (A-B)%2==0:
        print(abs(A-B)//2)
    else:
        print(min(A-1+1+((B-1)-(A-1))//2,\
                N-B+1+(N-(A+N-B+1))//2))


resolve()

Measured memory_bytes: 38484
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

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

int M, T, P, R;
int m[2003], t[2003], p[2003], j[2003];
int correct[51], penalty[51][11], times[51][11];
void solve() {
    memset(correct, 0, sizeof(correct));
    memset(penalty, 0, sizeof(penalty));
    memset(times, 0, sizeof(times));
    rep(i, R) {
        if (j[i] == 0) {
            correct[t[i]]++;
            times[t[i]][p[i]] += m[i];
            times[t[i]][p[i]] += penalty[t[i]][p[i]] * 20;
        } else {
            penalty[t[i]][p[i]]++;
        }
    }
    vector<tuple<int, int, int>> vec;
    rep(i, T) {
        int sum = 0;
        rep(k, P + 1) sum += times[i][k];
        vec.emplace_back(-correct[i], sum, -i);
    }
    sort(all(vec));
    tuple<int, int, int> pre{-1, -1, -1};
    rep(i, vec.size()) {
        auto x = vec[i];
        if (get<0>(x) == get<0>(pre) and get<1>(x) == get<1>(pre)) {
            cout << "=";
        } else {
            if (i) cout << ",";
        }
        cout << -get<2>(x) + 1;

        pre = x;
    }
    cout << endl;
}
int main() {
    while (cin >> M >> T >> P >> R, M) {
        rep(i, R) cin >> m[i] >> t[i] >> p[i] >> j[i];
        rep(i, R) t[i]--;
        solve();
    }
    return 0;
}

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

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

    int maxv = -1;
    int ans = 0;
    
    for(int i = n; i > 0; i--){
        int j = i;
        int cnt = 0;
        while(1){
            if(j%2==0){
                cnt++;
                j/=2;
            }
            else break;
        }
        if(cnt>=maxv) {
            maxv = cnt;
            ans = i;
        }
    }
    
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			int a=sc.nextInt(),b=sc.nextInt();
			int s=a+b;
			int d=s!=0?0:1;
			while(s>0){
				d++;
				s/=10;
			}
			ln(d);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
 
int main(){
  int n,x,t;
  cin >>n >> x >> t;
  int time =0;
  
  time = n/x;
  if(n%x>0){
    cout<<time*t+t;
  }else{
    cout<<time*t;
  }
  
  return 0;
}

Measured memory_bytes: 3636
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n;
set<string> s;
string ss;

int main() {
  init_ios();
  cin >> n;
  while (n--) {
    cin >> ss;
    s.insert(ss);
  }
  cout<<s.size()<<"\n";
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

int a[100];
int dp[51][51][103];
int n;

int fun(int lo , int hi , int k){

    if(k==0 || lo>hi)return 0;

    int &ret = dp[lo][hi][k];

    if(ret != -1)return ret;

    ret = 0;

    if(a[lo]>=0){
        ret = a[lo] + fun(lo+1,hi,k-1);
    }
    else{
        if(k>=2) ret = max(fun(lo+1,hi,k-2) , a[lo] + fun(lo+1,hi,k-1));
        else ret = a[lo] + fun(lo+1,hi,k-1);
    }

    if(a[hi]>=0){
        ret = max(ret , a[hi] + fun(lo,hi-1,k-1));
    }
    else{
        if(k>=2) ret = max3(ret , fun(lo,hi-1,k-2) , a[hi] + fun(lo,hi-1,k-1));
        else ret = max(ret , a[hi] + fun(lo,hi-1,k-1));
    }
    ret = max(0,ret);
    return  ret;
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    int k;
    scn2(n,k);

    for(int i=1; i<=n; i++)scn(a[i]);

    Fill(dp,-1);

    cout<<fun(1,n,k);

    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 1280
K=int(input())
a=list(range(1,10))
if K<=9:
  print(a[K-1])
  quit()
count=9
i=0
while count<K:
  b=a[i]%10
  if b!=0:
    a.append(a[i]*10+b-1)
    count+=1
  a.append(a[i]*10+b)
  count+=1
  if b!=9:
    a.append(a[i]*10+b+1)
    count+=1
  i+=1
print(a[K-1])

Measured memory_bytes: 7140
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct node{
    int to;
    int far;
};
vector<node> v[100000];
int x[100000];
bool done[100000];
bool dfs(int i,int now){
    done[i]=1;
    x[i]=now;
    for(auto itr:v[i]){
        if(!done[itr.to]){
            if(!dfs(itr.to,now+itr.far))return false;
        }else if(x[itr.to]!=x[i]+itr.far)return false;
    }
    return true;
};

int main(void){
    int n,m;
    bool a=true;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        v[l-1].push_back({r-1,d});
        v[r-1].push_back({l-1,-d});
    }
    for(int i=0;i<n;i++)if(!done[i])if(!dfs(i,0))a=0;
    string ans=(a)?"Yes":"No";
    cout<<ans<<endl;
}


Measured memory_bytes: 12032
N = int(input())
A = list(map(int, input().split()))

Sum = 0
minus_Sum = 0
min = 10**9

for i in range(N):
    Sum += abs(A[i])
    if min > abs(A[i]):
        min = abs(A[i])
    
    if A[i] < 0:
        minus_Sum += 1
        
if minus_Sum % 2 == 0:
    print(Sum)
else:
    print(Sum - 2*min)

Measured memory_bytes: 64752
Scanf.scanf "%d %d %d" (fun h w d ->
    let pos = Array.make (h * w + 1) (0, 0) in
    for y = 1 to h do
        for x = 1 to w do
            Scanf.scanf " %d" (fun a -> pos.(a) <- (y, x))
        done
    done;
    let asm = Array.make (h * w + 1) 0 in
    for i = 1 to d do
        let rec loop cur acc =
            let next = cur + d in
            if next <= h * w then (
                let (y0, x0) = pos.(cur) in
                let (y1, x1) = pos.(next) in
                let acc = acc + abs (y1 - y0) + abs (x1 - x0) in
                asm.(next) <- acc;
                loop next acc
            )
        in
        loop i 0
    done;
    Scanf.scanf " %d" (fun q ->
        for i = 1 to q do
            Scanf.scanf " %d %d" (fun l r -> Printf.printf "%d\n" (asm.(r) - asm.(l)))
        done
    )
)

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

typedef long long ll;
#define SZ(a) (int)a.size()
#define PB push_back
//#define cerr if(false)cerr
#define print(x) cerr<<"\n" << (#x) << " is " << (x) << endl;



int32_t main(){
	int n;
	cin >> n;
	string s;
	map<string, int> m;
	vector<string> v(n);
	int mx = -1;
	for(auto &i: v){
		cin >> i;
		m[i]++;
		mx = max(m[i], mx);
	}
	for(auto x: m){
		if(x.second == mx){
			cout << x.first << endl;
		}
	}
}


Measured memory_bytes: 26752
#include <iostream>
#include <cstdlib>
#define llint long long

using namespace std;


llint N, D, Q;
llint d[500005];
llint q[500005];
llint rem[500005], can[500005];
bool ans[500005];

int main(void)
{
	cin >> N >> D;
	for(int i = 1; i <= N; i++) cin >> d[i];
	cin >> Q;
	for(int i = 1; i <= Q; i++) cin >> q[i];
	
	llint dist = D;
	for(int i = 1; i <= N; i++){
		rem[i] = dist;
		dist = min(dist, abs(d[i] - dist));
	}
	llint k = 0;
	for(int i = N; i >= 1; i--){
		if(k == 0 && d[i] == 1) k += d[i];
		else if(k > 0 && d[i]/2 <= k) k += d[i];
		can[i] = k;
	}
	for(int i = 1; i <= N; i++){
		ans[i] = (rem[i] > can[i+1]);
	}
	
	//for(int i = 1; i <= N; i++) cout << rem[i] << " "; cout << endl;
	//for(int i = 1; i <= N; i++) cout << can[i] << " "; cout << endl;
	
	for(int i = 1; i <= Q; i++){
		if(ans[q[i]]) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 18048
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int S = sc.nextInt();
int h =  S / 3600;
int m =  (S - h * 3600)/60;
int s = S - h * 3600 - m * 60;
System.out.println(h+":"+m+":"+s); 
}
}


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

using namespace std;

#define ll long long
#define ull unsigned long long

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int &x : p) cin >> x;
    for (int &x : q) cin >> x;
    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    vector<vector<int> > v;
    do {
        v.push_back(a);
    } while (next_permutation(a.begin(), a.end()));
    int p1 = -1, p2 = -1;
    for (int i = 0; i < (int) v.size(); i++) {
        if (v[i] == p) p1 = i;
        if (v[i] == q) p2 = i;
        if (p1 != -1 && p2 != -1) break;
    }
    cout << abs(p2 - p1) << '\n';
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int sol(ll x)
{
    int ans = 0;
    while(x>0)
    {
        x/=10;
        ans++;
    }
    return ans;
}
int main()
{
    string s;
    cin>>s;
    int ans = 0;
    string t[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    int id = 0;
    for(int i=0;i<7;i++)
    {
        if(s == t[i])
            id = i;
    }
    for(int i=0;i<7;i++)
    {
        id++;
        id %= 7 ;
        ans++;
        if(t[id] == "SUN")
        {
            cout<<ans<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
tmp = input()
lis = list(tmp)
length = len(lis)
judge = 0
for i in range(0, length, 2):
    if lis[i] == 'L':
        judge = 1
for j in range(1, length, 2):
    if lis[j] == 'R':
        judge = 1

if judge == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >>N;
    vector<int> a(N);
    vector<int> b(N);
    rep(i,N){
        cin>>b[i];
        b[i]--;
        a[i]=i;
        if(a[i]<b[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int ans[N];
    int cou=0;
    int n=N;
    while(N>0){
        for(int i=N-1;i>=0;i--){
            if(b[i]==a[i]){
                ans[cou]=a[i]+1;
                cou++;
                b.erase(b.begin()+i);
                N--;
                break;
            }
        }
    }
    for(int i=n-1;i>=0;i--){
        cout << ans[i] << endl;
    }


}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
h = [int(item) for item in input().split()]
ans = [True] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    if h[a] >= h[b]:
        ans[b] = False
    if h[b] >= h[a]:
        ans[a] = False

print(sum(ans))

Measured memory_bytes: 20332
n,c = map(int,input().split())
program = [list(map(int,input().split())) for i in range(n)]
time = [0 for i in range(10**5+1)]

program.sort()
program.sort(key = lambda x: x[2])
 
for i in range(1,n):
    if program[i][2]==program[i-1][2] and program[i][0]==program[i-1][1]:
        program[i][0] = program[i-1][0]
        program[i-1][0] = None
#print(program)
 
for i in range(n):
    if program[i][0] == None:
        continue
    time[program[i][0]-1] += 1
    time[program[i][1]] -= 1
 
count = 0
max_count = 0
 
for i in range(10**5+1):
    count += time[i]
    max_count = max(max_count,count)
 
print(max_count)

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

void solve() {
  int N;
  cin >> N;
  rep(i, 1, N) {
    if (int(i * 1.08) == N) {
      cout << i << endl;
      return;
    };
  }
  cout << ":(" << endl;
}

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

Measured memory_bytes: 3640
#include <iostream>
#define llint long long
#define mod 998244353

using namespace std;

llint fact[200005], fact_i[200005];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 200005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 200005; i++){
		fact_i[i] = pow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_i[k], ret %= mod;
	ret *= fact_i[n-k], ret %= mod;
	return ret;
}

llint N;
llint x[205], y[205];

bool onLine(llint x1, llint y1, llint x2, llint y2, llint x3, llint y3)
{
	if(x1 == x2) return x1 == x3;
	if((y2-y1)*(x3-x1) % (x2-x1)) return false;
	return (y2-y1)*(x3-x1)/(x2-x1)+y1 == y3;
}

int main(void)
{
	make_fact();
	
	cin >> N;
	for(int i = 0; i < N; i++) cin >> x[i] >> y[i];
	
	if(N <= 2){
		cout << 0 << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 3; i <= N; i++){
		ans += comb(N, i);
		ans %= mod;
	}
	
	int cnt;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i >= j) continue;
			cnt = 2;
			for(int k = 0; k < N; k++){
				if(k == i || k == j) continue;
				if(!onLine(x[i], y[i], x[j], y[j], x[k], y[k])) continue;
				if(k < j) break;
				cnt++;
			}
			if(cnt >= 3){
				for(int k = 3; k <= cnt; k++){
					ans -= comb(cnt, k);
					if(ans < 0) ans += mod;
					ans %= mod;
				}
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
N = int(input())
candyList = []
for i in range(2):
    candyList.append(list(map(int,(input()).split())))

maxi = -1
for i in range(N):
    tmp = 0
    for j in range(N):
        if j < i:
            tmp += candyList[0][j]
        elif j == i:
            tmp += candyList[0][j] + candyList[1][j]
        else:
            tmp += candyList[1][j]
    maxi = max(maxi,tmp)

print(maxi)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    string s; cin >> s;

    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes" << endl;
    }else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B>>S;
	int aa=0,bb=0;
	
	FORR(c,S) {
		if(c=='a') {
			if(aa+bb<A+B) {
				aa++;
				_P("Yes\n");
				continue;
			}
		}
		if(c=='b') {
			if(aa+bb<A+B && bb<B) {
				bb++;
				_P("Yes\n");
				continue;
			}
			
		}
		_P("No\n");
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 848
#include<stdio.h>

int main(){
  int tmp,i,minj,j,n,cnt=0;

  scanf("%d",&n);

  int A[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
    tmp=A[i];
    A[i]=A[minj];
    A[minj]=tmp;
    cnt++;
    }
  }

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



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

class Main{
  public static void main(String[] args) {
  Scanner scan = new Scanner(System.in);

while(true) {
    int a = scan.nextInt();
    char op = scan.next().charAt(0);
    int b = scan.nextInt();

    if (op == '?'){
      break;
    } else if (op == '+'){
      System.out.println(a + b);
    } else  if (op == '-'){
      System.out.println(a - b);
    } else  if (op == '*'){
      System.out.println(a * b);
    } else  if (op == '/'){
      System.out.println(a / b);
    }
    }
  }
}

Measured memory_bytes: 26296
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    x <- readLn :: IO Int
    let a1 = zip [1.. ] (scanl1 (+) [1..])
    let a2 = dropWhile ((< x) . snd) a1
    let ans = fst $ head a2
    print ans

Measured memory_bytes: 1148
n = int(input())
a = [[0 for i in range(10)] for j in range(n)]

for i in range(n):
    a[i] = list(map(int, input().split()))
    
for i in range(n):
    l = 0
    r = 0
    f = 1
    for j in range(10):
        if l>=r and l<a[i][j]:
            l = a[i][j]
        elif r<a[i][j]:
            r = a[i][j]
        else:
            f = 0
            break
    if f == 1:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5600
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
  int a[123];
  int n;
  int i;
  int co[9]={};
  int sum=0;

  cin>>n;

  for(i=0;i<n;i++)
    {
      cin>>a[i];
      co[a[i]>3200?8:a[i]/400]++;
    }

  for(i=0;i<8;i++)
    {
      if(co[i]!=0)
        sum++;
    }
if(sum==0)
sum=1,co[8]--;
  cout<<sum<<" "<<sum+co[8]<<endl;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll ans;

    ll x = min(n, b - 1);
    cout << a*x/b - a*(x/b) << endl;
/*
    if(b > n){
        ans = a*n/b;
    }else{
        ans = a - a/b;
    }

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

int main(){
  #define int long long
  string s;
  cin >> s;
  int tempi = 0;
  int tempj = 0;
  int rcount = 0;
  int lcount = 0;
  vint ans(s.size());
  rep(i,s.size()){
    if(i != s.size()-1){
      if(s[i] == 'R'){
        rcount++;
        if(s[i+1] == 'L'){
          tempi = i;
          tempj = i+1;
        }
      }
      else{
        lcount++;
        if(s[i+1] == 'R'){
          if(rcount % 2 == 0 && lcount % 2 == 0){
            ans[tempi] = rcount/2 + lcount/2;
            ans[tempj] = rcount/2 + lcount/2;
          }
          else if(rcount % 2 == 1 && lcount % 2 == 0){
            ans[tempi] = rcount/2 + lcount/2 + 1;
            ans[tempj] = rcount/2 + lcount/2;
          }
          else if(rcount % 2 == 0 && lcount % 2 == 1){
            ans[tempi] = rcount/2 + lcount/2;
            ans[tempj] = rcount/2 + lcount/2 + 1;
          }
          else{
            ans[tempi] = rcount/2 + lcount/2 + 1;
            ans[tempj] = rcount/2 + lcount/2 + 1;
          }
          lcount = 0;
          rcount = 0;
        }
      }
    }
    else{
      lcount++;
      if(rcount % 2 == 0 && lcount % 2 == 0){
        ans[tempi] = rcount/2 + lcount/2;
        ans[tempj] = rcount/2 + lcount/2;
      }
      else if(rcount % 2 == 1 && lcount % 2 == 0){
        ans[tempi] = rcount/2 + lcount/2 + 1;
        ans[tempj] = rcount/2 + lcount/2;
      }
      else if(rcount % 2 == 0 && lcount % 2 == 1){
        ans[tempi] = rcount/2 + lcount/2;
        ans[tempj] = rcount/2 + lcount/2 + 1;
      }
      else{
        ans[tempi] = rcount/2 + lcount/2 + 1;
        ans[tempj] = rcount/2 + lcount/2 + 1;
      }
    }
  }
  rep(i,ans.size()){
    cout << ans[i] << " ";
  }
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
  while(1){
      int n,ans=0;
      bool pos=false;
      cin>>n;
      if(n==0)break;
      
      int k[n];
      for(int i=0;i<n;i++){
          cin>>k[i];
      }
      for(int i=0;i<n;i++){
          if(k[i]){
              ans++;
            
          }
          if(k[i]>1)pos=true;
      }
      if(pos)cout<<ans+1<<endl;
      else cout<<"NA"<<endl;
  }
}

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

int main(void)
{
    string S;
    cin >> S;
    for (int i = 0; i < 3; i++) {
        if (S[i] == S[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

vector<vector<Weight>> shortest_distance(Graph g) {
    /* Johnson */
    size_t V=g.size();
    vector<Weight> h(V);
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (h[e.dst] > h[e.src] + e.weight) {
                    h[e.dst] = h[e.src] + e.weight;
                    if (k == V-1)
                        return vector<vector<Weight>>();
                }

    for (size_t i=0; i<V; ++i)
        for (Edge &e: g[i])
            e.weight += h[e.src] - h[e.dst];

    vector<vector<Weight>> d(V, vector<Weight>(V, INF<<1));
    vector<vector<size_t>> prev(V, vector<size_t>(V, -1));
    for (size_t s=0; s<V; ++s) {
        gp_queue<Edge> q; q.push(Edge(s, s, 0));
        d[s][s] = 0;
        while (!q.empty()) {
            Edge e=q.top(); q.pop();
            if (~prev[s][e.dst]) continue;

            prev[s][e.dst] = e.src;
            for (const Edge &f: g[e.dst]) {
                if (d[s][f.dst] > e.weight + f.weight) {
                    d[s][f.dst] = e.weight + f.weight;
                    q.push(Edge(f.src, f.dst, e.weight+f.weight));
                }
            }
        }
        for (size_t u=0; u<V; ++u)
            d[s][u] += h[u] - h[s];
    }

    return d;
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<vector<Weight>> d=shortest_distance(g);
    if (d.empty())
        return !printf("NEGATIVE CYCLE\n");

    for (vector<Weight> w: d)
        for (size_t i=0; i<V; ++i)
            if (w[i] < INF) {
                printf("%lld%c", w[i], i<V-1? ' ':'\n');
            } else {
                printf("INF%c", i<V-1? ' ':'\n');
            }

    return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, count = 0;
  cin >> n;
  string s;
  cin >> s;
  char current;
  for (int i = 0; i < n; i ++) {
    if (s[i] == current) {
      continue;
    } else {
      count += 1;
      current = s[i];
    }
  }
  cout << count << endl;
}

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

using namespace std;

const int N = 4040, mod = 998244353;

int dp[N][N], C[N][N];
char s[N];

void add(int & var, int x) {
  var += x;
  if (var >= mod)
    var -= mod;
}

int main() {
  for (int i = 0; i < N; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j)
      C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
  }
  dp[0][0] = 1;
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; ++i)
    s[i] -= '0';
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (dp[i][j] == 0) continue;
      int b = j + s[i], r = 2 * i - j + (2 - s[i]);
      if (b)
        add(dp[i+1][b-1], dp[i][j]);
      if (r)
        add(dp[i+1][b], dp[i][j]); 
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans = (ans + 1LL * C[n][i] * dp[n][i]) % mod;
  }
  if (ans < 0) ans += mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 94976
import sys
from collections import deque
 
read = sys.stdin.buffer.read
 
N, *A = map(int, read().split())
A.sort(reverse=True)
 
deq = deque([A[0]])
ans = 0
 
for x in A[1:]:
    ans += deq.popleft()
    deq.append(x)
    deq.append(x)

print(ans)

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

X = int(input())

for i in range(0, 1000):
    for j in range(0, 1000):
        if i**5 - j**5 == X:
            print(i, j)
            exit()
        if i**5 + j**5 == X:
            print(i, -j)
            exit()
        if -i**5 - j**5 == X:
            print(-i, j)
            exit()
        if -i**5 + j**5 == X:
            print(-i, -j)
            exit()

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


def make_result(n, a, b):
    result = []
    tail = []
    if n < a * b:
        if a <= b:
            k = (a * b - n + b - 2)//(b - 1) - 1
            tail = [n - i for i in range(k - 1, -1, -1)]
            n -= k
            a -= k
            k = n - (a - 1) * b
            tail = [n - i for i in range(k)] + tail
            n -= k
            a -= 1
        else:
            k = (a * b - n + a - 2)//(a - 1) - 1
            result = [n - i for i in range(k)]
            n -= k
            b -= k
            k = n - a * (b - 1)
            result += [n - i for i in range(k - 1, -1, -1)]
            n -= k
            b -= 1

    for i in range(b):
        for j in range(a):
            result.append(n - a * (i + 1) + j + 1)

    return result + tail


def solve(n, a, b):
    if n < a + b - 1:
        return '-1'
    if a * b < n:
        return '-1'

    return ' '.join(map(str, make_result(n, a, b)))


def main():
    n, a, b = input().split()
    n = int(n)
    a = int(a)
    b = int(b)

    print(solve(n, a, b))


if __name__ == '__main__':
    main()



Measured memory_bytes: 35568
#include <bits/stdc++.h>
using namespace std; 
int main() {
  int x, a, b;   cin  >> x >> a >> b;
  if (abs(x-a)<abs(x-b)) {
    cout << "A" << endl;
  }
  else{
    cout << "B" << endl;
  }
  return 0;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n), d(n+1, 0);
  for(int i = 0; i < n; i++) {
    cin >> l.at(i);
  }
  for(int i = 1; i < n+1; i++) {
    d.at(i) = d.at(i-1) + l.at(i-1);
  }
  for(int i = 1; i < n+1; i++) {
    if(d.at(i) > x) {
      cout << i;
      exit(0);
    }
  }
  cout << n+1;
}
   

Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

int partition(int A[], int p, int r){
    int x = A[r];
    int i = p - 1;
    for (int j = p; j != r; ++j){
        if (A[j] <= x) swap(A[++i], A[j]);
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}


int main()
{
    int n = 0;
    cin >> n;
    int A[100000] = {0};
    for (int i = 0; i != n; ++i) cin >> A[i];
    int pivot = partition(A, 0, n - 1);
    for (int i = 0; i != n; ++i){
        if (i == pivot){
            cout << '[' << A[i] << ']';
        }else{
            cout << A[i];
        }
        if (i == n - 1){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define N 2100
#define MAX 1000000000001
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define MOD 1000000007

int main()
{
    fastio;

    clock_t tStart = clock();

    ll n;
    cin >> n;
    double S = (double)n;
    cout << fixed << setprecision(10);
    cout << S*S*S / 27.00 << endl;

    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

map<ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
int main(){
  ll A, B; cin >> A >> B;
  auto a = prime_factor(A);
  auto b = prime_factor(B);
  ll ans = 1;
  for (auto p : a){
    if (b[p.first]>0) ans++; 
  }
  cout << ans << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3656
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

// 素因数分解
void prime_factor(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

ll n;

void solve() {
    repone(i, n) {
        prime_factor(i);
    }
    ll ans = 1;
    each(m, mp) {
        ans *= (1 + m.second);
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        cin >> n;

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int a,b,c,licznik=0,mx;

void solve(int &y,int &x)
{
	y+=1;
	x+=1;
	licznik++;
}

int main() 
{

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>a>>b>>c;
	while(a%2!=b%2||b%2!=c%2)
	{
		if(a%2==b%2)solve(a,b);
		else if(a%2==c%2)solve(a,c);
		else if(b%2==c%2)solve(b,c);
	}
	while(a!=b||a!=c||b!=c)
	{
		mx=max(a,b);
		mx=max(mx,c);
		licznik+=(mx-a)/2;
		a=mx;
		licznik+=(mx-b)/2;
		b=mx;
		licznik+=(mx-c)/2;
		c=mx;
	}
	cout<<licznik;
	return 0;
}

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

  moves = []

  for i in range(N):
    moves.append([int(j) for j in input().split()])

  # 移動前
  pre_t = 0
  pre_x = 0
  pre_y = 0

  for move in moves:
    new_t, new_x, new_y = move[0], move[1], move[2]

    # 時刻の差分
    delta_t = new_t - pre_t

    # 位置の差分
    delta_x = abs(new_x - pre_x)
    delta_y = abs(new_y - pre_y)
    delta_sum = delta_x + delta_y

    remain_time = delta_t - delta_sum

    # 移動量と時間が一致
    if remain_time == 0:
      pre_t, pre_x, pre_y = new_t, new_x, new_y

    # 移動量の方が少ない
    elif remain_time > 0:
      # 残り時間が偶数なら行ったり来たりでOK
      if remain_time % 2 == 0:
        pre_t, pre_x, pre_y = new_t, new_x, new_y
      else:
        print("No")
        return

    # 時間が足りない
    else:
      print("No")
      return

  print("Yes")
  return

main()


Measured memory_bytes: 21156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
価値の低い２つからつなげていく。
*/

ll n,ans=0;
priority_queue<double,vector<double>,greater<double>> Q;

void init(){
	cin>>n;
	rep(i,n){
		double a;
		cin>>a;
		Q.push(a);
	}
}

int main(void){
	init();
	while(Q.size()>=2){
		double p1=Q.top();Q.pop();
		double p2=Q.top();Q.pop();
		Q.push((p1+p2)/2);
	}
	cout<<Q.top()<<endl;
	return 0;
}

Measured memory_bytes: 256