akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9;
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= n; ++j){
       for(int k = 1; k <=n; ++k) {
         sum+= __gcd(i, __gcd(j, k));
       }
    }
  }
  cout << sum << endl;
  return 0;
}

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

long long H;
int N;

int main() {
  cin >> H >> N;
  int a;
  for (int i=0; i<N; i++) {
    cin >> a;
    H -= a;
  }
  if (H <= 0) cout << "Yes";
  else cout << "No";
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

inline void print(ll n){
	if(!n) return ;
	ll p = n%26;
	
	if(p) print(n/26);
	else print((n-26)/26),p += 26;
	
	printf("%c",(p-1)+'a');
	return ;
}

int main()
{	
	ll n;
	scanf("%lld",&n);
	print(n);
	return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());
 
    int ans = 0;
 
    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            for (int k = j+1; k < N; ++k) {
                if (vec[k] != vec[j] && vec[i] != vec[j] &&
                    vec[i] + vec[j] > vec[k]) {
                    ans++;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int beki_10(int n){
  int sum=1;
  for(int i=1;i<=n;i++){
    sum*=10;
  }
  return sum;
}
int main(){
  int flag ,cnt=0,x,stgsan[3];
  string s;
  cin >> x;
  for(int i=357;i<=x;i++){
    stgsan[0]=stgsan[1]=stgsan[2]=0;
    flag=0;
    s=to_string(i);
    for(int j=0;j<s.length();j++){
      if(s[j]=='7')stgsan[0]=1;
      else if(s[j]=='5')stgsan[1]=1;
      else if(s[j]=='3')stgsan[2]=1;
      else {
        for(int k=j;k<s.length();k++){
          i-=beki_10(s.length()-k-1)*(s[k]-'0');
        }
        i+=beki_10(s.length()-j-1)*(s[j]-'0'+1);
        i--;
        flag=1;
        break;
      }
    }
    if(stgsan[0]==1&&stgsan[1]==1&&stgsan[2]==1&&flag==0){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
/* C Priority Queue */
#include<stdio.h>

int S[2000001];
int heap_size=0;

int parent(int i);
int left(int i);
int right(int i);

void maxHeapInsert(int A[],int key);
void heapIncreaseKey(int A[], int i, int key);
int heapExtractMax(int A[]);
void maxHeapify(int A[],int i);

int main(){
  char com[7];
  int k;
  int i;

  while(1){
    scanf("%s",com);
    if(com[2]=='s'){       /*insert*/
      scanf("%d",&k);
      maxHeapInsert(S,k);
    }else if(com[2]=='t'){ /*extract*/
      printf("%d\n",heapExtractMax(S));
    }else{                 /*end*/
      break;
    }
  }
  return 0;
}

void maxHeapInsert(int A[],int key){
  int temp;
  heap_size=heap_size+1;
  A[heap_size]=-1; /*0<=key<=2,000,000,000*/
  heapIncreaseKey(A, heap_size, key);
}
void heapIncreaseKey(int A[], int i, int key){
  int temp;
  if(key<A[i]){
    fprintf(stderr,"new key is smaller than current key\n"); 
  }
  A[i]=key;
  while(i>1&&A[parent(i)]<A[i]){
    temp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=temp;
    i=parent(i);
  }
}

int heapExtractMax(int A[]){
  int max;
  if(heap_size<1){
    fprintf(stderr,"heap underflow\n");
  }
  max=A[1];
  A[1]=A[heap_size];
  heap_size=heap_size-1;
  maxHeapify(A,1);
  return max;
}

void maxHeapify(int A[],int i){
  int temp;
  int l,r,largest;
  l=left(i);
  r=right(i);

  if(l<=heap_size&&A[l]>A[i]){
    largest=l;
  }else{
    largest=i;
  }
  if(r<=heap_size&&A[r]>A[largest]){
    largest=r;
  }
  if(largest!=i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(A, largest);
  }
}

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

Measured memory_bytes: 4332
def main():
    S = input()  # 2<= |S| <= 200, あらっぽい事ができる

    while True:
        S = S[:-1]
        if len(S) % 2 == 0:
            center = int(len(S)/2)
            if S[center:] == S[:center]:
                break

    print(len(S))


if __name__ == "__main__":
    main()


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

int main(){
    string str;

    cin >> str;

    if (str == "Sunny"){
        cout << "Cloudy";
    }
    else if (str == "Cloudy"){
        cout << "Rainy";
    }
    else if (str == "Rainy"){
        cout << "Sunny";
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

struct Card {
  char mark;
  int number;
};

void swap(Card& a, Card& b) {
  Card tmp = a;
  a = b;
  b = tmp;
}

int partition(vector<Card>& cards, int first_index, int last_index) {
  Card pivot = cards[last_index];

  int less_or_equal_tail = first_index;
  for(int i = first_index; i < last_index; i++) {
    if(cards[i].number <= pivot.number) {
      swap(cards[less_or_equal_tail++], cards[i]);
    }
  }

  swap(cards[less_or_equal_tail], cards[last_index]);

  return less_or_equal_tail;
}

void quick_sort(vector<Card>& cards, int first_index, int last_index) {
  // 配列の長さが1はソートする必要がない。
  if(!(first_index < last_index)) {
    return;
  }

  int partition_index = partition(cards, first_index, last_index);

  quick_sort(cards, first_index, partition_index - 1);
  quick_sort(cards, partition_index + 1, last_index);
}

int main() {
  int card_num;
  vector<Card> cards;
  map<int, vector<char>> orders;

  cin >> card_num;
  cards.resize(card_num);

  for(int i = 0; i < card_num; i++) {
    Card card;
    cin >> card.mark >> card.number;

    cards[i] = card;
    orders[card.number].push_back(card.mark);
  }

  quick_sort(cards, 0, cards.size() - 1);

  // init count number
  map<int, int> count_number;
  for(int i = 0; i < card_num; i++) {
    count_number[cards[i].number] = 0;
  }

  bool is_stable = true;
  for(int i = 0; i < card_num; i++) {
    Card current_card = cards[i];
    if(current_card.mark != orders[current_card.number][count_number[current_card.number]]) {
      is_stable = false;
      break;
    }

     count_number[cards[i].number]++;
  }

  if (is_stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  for(int i = 0; i < card_num ; i++) {
    cout << cards[i].mark << ' ' << cards[i].number << endl;
  }
}



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

long long N, L, T;
long long X[100000], W[100000];
pair<long long, int> X_after[100000];

int main(){
    cin >> N >> L >> T;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> W[i];
        int j;
        if(W[0] == 1){
            j = i;
        }else{
            j = -i;
        }
        if(W[i] == 1){
            X_after[i] = make_pair((X[i] + T) % L, j);
        }else{
            X_after[i] = make_pair((X[i] + (L - 1) * T) % L, j);
        }
    }
    sort(X_after, X_after + N);
    long long meet_count = 0;
    for(int i = 1; i < N; i++){
        long long dist = 0;
        if(W[0] == 1){
            dist = ((X[i] + L) - X[0]) % L;
        }else{
            dist = ((X[0] + L) - X[i]) % L;
        }
        if(W[0] != W[i]){
            // 2*T > (n - 1)*L + dist
            long long n = 0;
            if(2*T > dist){
                n = (2*T - dist - 1) / L + 1;
            }
            meet_count += n;
        }
    }
    meet_count %= N;
    int start;
    for(int i = 0; i < N; i++){
        if(X_after[i].second == 0){
            if(W[0] == 1){
                start = (i + N - meet_count) % N;
            }else{
                start = (i + meet_count) % N;
            }
        }
    }
    for(int i = 0; i < N; i++){
        cout << X_after[(start + i) % N].first << endl;
    }
}


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

int main(){
  long a, b;
  long l, m, n;
  while (scanf("%ld %ld", &a, &b) != EOF){
    m = a;
    n = b;

    while (1){
      if (m <= n){
        int t = m;
        m = n;
        n = t;
      }

      if (n == 0){
        cout << m << " " << a * b / m << "\n";
        break;
      }

      l = m % n;
      m = n;
      n = l;

    }

    if (a <= 0 || b <= 0){
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1204
N=int(input())
A=list(map(int,input().split()))
if A.count(0)==N:
    print("Yes")
elif N%3!=0:
    print("No")
elif len(set(A))==2:
    if 0 in set(A):
        if A.count(0)==N/3:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif len(set(A))==3:
    xor=0
    for a in set(A):
        if A.count(a)==N/3:
            xor^=a
        else:
            print("No")
            exit()
    if xor==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 20424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		
		System.out.println((n-1) * (m-1));

	}

}


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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == 'o') ++counter;
    if (s[1] == 'o') ++counter;
    if (s[2] == 'o') ++counter;
    cout << counter*100 + 700 << endl;
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if(s.size()%2 == 1){
      cout << "No" << endl;
      return 0;
  }
  for(int i = 0; i < s.size()-1; i+=2){
    if(s.at(i) != 'h' || s.at(i+1) != 'i'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int n, w, d;

int main() {
	while (cin >> n >> w >> d, n || w || d) {
		vector<pair<int, int>> cakes = {{
			{w, d}
		}};
		for (int i = 0; i < n; i++) {
			int p, s;
			cin >> p >> s;
			auto it = cakes.begin() + p - 1;
			auto c = *it;
			cakes.erase(it);

			int cw = c.first;
			int ch = c.second;
//			cout << cw << ',' << ch << endl;
			if (s % (cw + ch) < cw) {
				int nw = s % (cw + ch);
				int nh = ch;
//				cout << 'w' << nw << ',' << nh << endl;
				cakes.emplace_back(min(nw, cw - nw), nh);
				cakes.emplace_back(max(nw, cw - nw), nh);
			}
			else {
				int nw = cw;
				int nh = s % (cw + ch) - cw;
//				cout << 'h' << nw << ',' << nh << endl;
				cakes.emplace_back(nw, min(nh, ch - nh));
				cakes.emplace_back(nw, max(nh, ch - nh));
			}
		}
		vector<int> areas(n + 1);
		for (int i = 0; i <= n; i++) {
			areas[i] = cakes[i].first * cakes[i].second;
		}
		sort(areas.begin(), areas.end());
		cout << areas[0];
		for (int i = 1; i <= n; i++) {
			cout << ' ' << areas[i];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i + 1 < n; ++i) {
        if (a[i] == i + 1) {
            swap(a[i], a[i + 1]);
            ++ans;
        }
    }
    if (a[n - 1] == n) {
        ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int t = i;
        int sum = 0;
        while (t > 0) {
            sum += t % 10;
            t /= 10;
        }
        if (sum >= a && sum <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=sorted(list(map(int,input().split())))

b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#print(a)
#print(b)
#print(c)
c_count=[]#cから行けるところの回数
b_count=[]#bから行けるところの回数

j=0
count=0
for i in range(n):#cから行けるところの回数
    for j in range(count,n):
        
        if b[j]<c[i]:
 #           print("dfghj")
            count+=1
        else:
  #          print("GHJK")
            break
    c_count.append(count)

count=0

for i in range(n):#bから行けるところの回数
    for j in range(count,n):
        if a[j]<b[i]:
            count+=1
        else:
            break
    b_count.append(count)

ans=0
#print(b_count)
#print(c_count)
for i in range(1,n):
    b_count[i]+=b_count[i-1]
#print(b_count)

for i in range(n):
    if 0<=c_count[i]-1:
        ans+=b_count[c_count[i]-1]

print(ans)

#print(b_count)
#print(c_count)


Measured memory_bytes: 24096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(b==1){
    cout<<0<<endl;
    return 0;
  }
  int hole=a;
  int count=1;
  while(1){
    if(hole<b){
      hole+=a-1;
      count++;
    }else{
      break;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int n,m,size,ans;
int  t[100000];
int dp[100000][2];
bool flg;

void init(){
  dp[0][0]=1;
  dp[0][1]=2;
  size=0;
  flg=false;
  ans=0;
}

int main(){

  while(cin>>n>>m&&n&&m){
    init();
    for(int i=0;i<m;i++){
      scanf("%d",&t[size]);
      if(t[size]==0)flg=true;
      else size++;
    }
    sort(t,t+m);
    for(int i=1;i<size;i++){
      if(t[i]-1==t[i-1]){
	dp[i][0]=dp[i-1][0]+1;
	dp[i][1]=dp[i-1][1]+1;
      }else if(t[i]-2==t[i-1]){
	dp[i][1]=dp[i-1][0]+2;
	dp[i][0]=1;
      }else{
	dp[i][0]=1;
	dp[i][1]=2;
      }
      ans=max(ans,dp[i][0]);
      if(flg)ans=max(ans,dp[i][1]);
    }
    if(ans>n)ans--;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2208
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int MAXN = 50 + 5;
const int MAXM = 1e2 + 5;
const int MAXS = 5e3 + 5;
const int infs = 5e3;
const ll linf = 0x3f3f3f3f3f3f3f3f;

inline void chk_min(ll &a,ll b){ if(a>b) a=b;}

struct Edge
{
	int next,to,cost,w;
}e[MAXM<<1];
int head[MAXN],etot=0;
inline void add(int u,int v,int cost,int w)
{
	e[++etot]=(Edge){ head[u],v,cost,w};
	head[u]=etot;
}

int s;
int c[MAXN],d[MAXN];

struct Node
{
	int u,x;
	ll dis;
};
inline bool operator < (const Node &p,const Node &q){ return p.dis>q.dis;}
priority_queue<Node> q;
ll dis[MAXN][MAXS];
bool vis[MAXN][MAXS];

int main(void)
{
	int n,m;
	scanf("%d%d%d",&n,&m,&s);
	if(s>infs) s=infs;
	for(int i=1; i<=m; ++i)
	{
		int u,v,cost,w;
		scanf("%d%d%d%d",&u,&v,&cost,&w);
		add(u,v,cost,w); add(v,u,cost,w);
	}
	for(int i=1; i<=n; ++i)
	{
		scanf("%d%d",&c[i],&d[i]);
		if(c[i]>infs) c[i] = infs;
	}
	
	memset(dis,0x3f,sizeof(dis));
	dis[1][s] = 0;
	q.push((Node){1,s,0});
	while(!q.empty())
	{
		Node cur = q.top(); q.pop();
		int u=cur.u, x=cur.x;
		if(vis[u][x]) continue;
		vis[u][x] = 1;
		
		if(x+c[u] <= infs && dis[u][x+c[u]] > dis[u][x] + d[u])
		{
			dis[u][x+c[u]] = dis[u][x] + d[u];
			q.push((Node){u, x+c[u], dis[u][x+c[u]]});
		}
		
		for(int i=head[u]; i; i=e[i].next)
		{
			int v=e[i].to, y=x-e[i].cost, w=e[i].w;
			if(y<0) continue;
			if(dis[v][y] > dis[u][x] + w)
			{
				dis[v][y] = dis[u][x] + w;
				q.push((Node){v,y,dis[v][y]});
			}
		}
	}
	
	for(int i=2; i<=n; ++i)
	{
		ll res=linf;
		for(int j=0; j<=infs; ++j)
			chk_min(res, dis[i][j]);
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 9224
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    vector<tuple<int,int,int>>vt;
    for(int i=0,x,y,z;i<n;++i){
        cin>>x>>y>>z;
        vt.emplace_back(make_tuple(x,y,z));
    }
    for(int i=0;i<=100;++i){
        for(int j=0;j<=100;++j){
            int h=-1;
            for(auto x:vt){
                int val=abs(get<0>(x)-i)+abs(get<1>(x)-j);
                if(get<2>(x)>0){
                    if(h==-1)
                    h=get<2>(x)+val;
                    else if(h!=get<2>(x)+val)
                        goto label;
                }
            }
            for(auto x:vt){
                int val=abs(get<0>(x)-i)+abs(get<1>(x)-j);
                if(get<2>(x)==0){
                    if(h>val)goto label;
                }
            }
            cout<<i<<" "<<j<<" "<<h;return 0;
            label:;
        }
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string K;cin >> K;
    LL D;cin >> D;
    LL dp[10010][110][2] = {0};
    LL N = K.size();

    dp[0][0][0] = 1;

    rep(i,N) rep(j,D) rep(k,2) rep(l,(k ? 9 : K[i] - '0') + 1){
        LL c = K[i] - '0';
        dp[i+1][(j+l)%D][k || l != c] = (dp[i+1][(j+l)%D][k || l != c] + dp[i][j][k]) % MOD;
    }


    cout << (dp[N][0][0] + dp[N][0][1] +  MOD  -1 ) % MOD  << endl;
}


Measured memory_bytes: 17536
#include<iostream>
#include<vector>
#include<stack>

using namespace std;


static const int MAX = 100'000;
static const int nil = -1;

int n;
vector<int> grp[MAX];
int color[MAX];



void dfs(int r, int c) {
	stack<int> stk;
	stk.push(r);
	color[r] = c;

	while (!stk.empty())
	{
		int u = stk.top();stk.pop();

;		for (int i = 0; i < grp[u].size(); i++)
		{
			int v = grp[u][i];
			if (color[v] == nil) {
				color[v] = c;
				stk.push(v);
			}
		}
	}
}

void assignColor() {
	int id = 1;
	for (int i = 0; i < n; i++) color[i] = nil;
	for (int u = 0; u < n; u++)
	{
		if (color[u] == nil) dfs(u, id++);
	}
}

int main() {



	int s, t, m, q;

	cin >> n >> m;

	for (int i = 0;i < m;i++) {
		cin >> s >> t;
		grp[s].push_back(t);
		grp[t].push_back(s);
	}

	assignColor();

	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> s >> t;
		if (color[s] == color[t]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}


	return 0;
}






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

using namespace std;

typedef long long ll;
typedef long double ld;

template <typename T>
ostream &operator<<(ostream &out, vector<vector<T>> &data) {
    for (int i = 0; i < data.size(); ++i) {
        for (int j = 0; j < data[i].size(); ++j) {
            out << data[i][j];
        }
        out << '\n';
    }
    return out;
}

int main() {
    vector<vector<char>> three = {{'a', 'a', '.'},
                                  {'.', '.', 'a'},
                                  {'.', '.', 'a'}};
    vector<vector<char>> four = {{'a', 'a', 'b', 'c'},
                                 {'c', 'c', 'b', 'c'},
                                 {'a', 'b', 'd', 'd'},
                                 {'a', 'b', 'a', 'a'}};
    vector<vector<char>> five = {{'a', 'a', '.', 'b', 'c'},
                                 {'.', '.', 'a', 'b', 'c'},
                                 {'c', 'c', 'a', 'd', 'd'},
                                 {'a', 'b', 'b', '.', 'a'},
                                 {'a', '.', 'c', 'c', 'a'}};
    vector<vector<char>> six = {{'a', 'a', 'c', 'a', '.', '.'},
                                {'b', 'b', 'c', 'a', '.', '.'},
                                {'c', 'c', 'a', 'b', '.', '.'},
                                {'.', '.', 'a', 'b', 'c', 'c'},
                                {'.', '.', 'b', 'c', 'b', 'b'},
                                {'.', '.', 'b', 'c', 'a', 'a'}};
    vector<vector<char>> seven = {
        {'a', 'a', 'b', 'b', 'c', 'c', '.'},
        {'d', 'd', '.', 'd', 'd', '.', 'a'},
        {'.', '.', 'd', '.', '.', 'd', 'a'},
        {'.', '.', 'd', '.', '.', 'd', 'b'},
        {'d', 'd', '.', 'd', 'd', '.', 'b'},
        {'.', '.', 'd', '.', '.', 'd', 'c'},
        {'.', '.', 'd', '.', '.', 'd', 'c'}
    };
    int n;
    cin >> n;
    if (n == 2 || n == 1) {
        cout << -1;
    } else if (n == 3) {
        cout << three;
    } else {
        vector<vector<char>> ans(n, vector<char>(n, '.'));
        for (int i = 0; i < (n - 4) / 4; ++i) {
            for (int j = 4 * i; j < 4 * (i + 1); ++j) {
                for (int k = 4 * i; k < 4 * (i + 1); ++k) {
                    ans[j][k] = four[j % 4][k % 4];
                }
            }
        }
        for (int i = 4 * ((n - 4) / 4); i < n; ++i) {
            for (int j = 4 * ((n - 4) / 4); j < n; ++j) {
                switch (n - 4 * ((n - 4) / 4)) {
                    case 4:
                        ans[i][j] = four[i - 4 * ((n - 4) / 4)][j - 4 * ((n - 4) / 4)];
                        break;
                    case 5:
                        ans[i][j] = five[i - 4 * ((n - 4) / 4)][j - 4 * ((n - 4) / 4)];
                        break;
                    case 6:
                        ans[i][j] = six[i - 4 * ((n - 4) / 4)][j - 4 * ((n - 4) / 4)];
                        break;
                    case 7:
                        ans[i][j] = seven[i - 4 * ((n - 4) / 4)][j - 4 * ((n - 4) / 4)];
                        break;
                }
            }
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cmath>

int crab(int E)
{
    int ans {E};
    for (int z {}; z * z * z <= E; ++z)
        for (int y {}; y * y + z * z * z <= E; ++y)
            if (E - y * y - z * z * z >= 0)
                ans = std::min(ans, E - y * y - z * z * z + y + z);
    
    return ans;
}

int main() 
{
    int E {};
    while (std::cin >> E && E > 0)
        std::cout << crab(E) << std::endl;
}


Measured memory_bytes: 2952
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;

using Graph = vector<vector<int>>;
vector<bool> seen;
vector<ll> answer;
void dfs(Graph &G, int v){
  
  seen[v] = true;

  for(auto next_v : G[v]){
    if(seen[next_v]) continue;
    else{
      answer[next_v] += answer[v];
      dfs(G, next_v);
    }
  }

}

int main() {
  int N,q;
  cin >> N >> q;
  Graph G(N+1);

  for (int i = 1; i <= N-1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  answer.resize(N+1,0);
  seen.resize(N+1,false);

  for(int i=1; i<=q; i++){
    int c,d;
    cin >> c >> d;
    answer[c]+=d;
  }

  dfs(G, 1);

  for(int i=1; i<=N; i++){
    if(i!=N) cout << answer[i] << " ";
    else  cout << answer[i] << endl;
  }
    
}

Measured memory_bytes: 24320
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int N = 1e5 + 137;

int n, head[N], top = 0;

struct Node
{
	int y, nxt, w;
} e[N << 1];

inline void Adde( int x, int y, int w )
{
	e[++top].y = y, e[top].nxt = head[x], head[x] = top, e[top].w = w;
	e[++top].y = x, e[top].nxt = head[y], head[y] = top, e[top].w = w;
}

int que[N << 3], h, t;
long long dis[N];

void Bfs( int st )
{
	int u, v;
	memset(dis, -1, sizeof(dis));
	h = t = 0;
	que[++t] = st;
	dis[st] = 0;
	while(h < t)
	{
		u = que[++h];
		for(int i = head[u]; i; i = e[i].nxt)
		{
			v = e[i].y;
			if(dis[v] != -1) continue;
			dis[v] = dis[u] + e[i].w;
			que[++t] = v;
		}
	}
}

int main()
{
	int u, v, w;
	scanf( "%d", &n );
	for(int i = 1; i < n; i++)
		scanf( "%d%d%d", &u, &v, &w ), Adde(u, v, w);
	int m, k;
	scanf( "%d%d", &m, &k );
	Bfs(k);
	while(m--)
	{
		scanf( "%d%d", &u, &v );
		cout << dis[u] + dis[v] << endl;
	}
	return 0;
}

Measured memory_bytes: 7552
n = int(input())
arr = list(map(int, input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(arr[1] - arr[0])
for i in range(2, n):
    dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1], abs(arr[i]-arr[i-2])+dp[i-2])
print(dp[-1])


Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k){
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<k;i++){
        cout<<s[i];
    }
    cout<<"..."<<endl;

    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());

            var graph = new List<int>[n].Select(x => new List<int>()).ToArray();
            for (var i = 0; i < graph.Length; i++)
            {
                var s = Console.ReadLine().Trim();
                for (var j = i + 1; j < s.Length; j++)
                {
                    if (s[j] == '1')
                    {
                        graph[i].Add(j);
                        graph[j].Add(i);
                    }
                }
            }

            var answer = 0;
            for (var i = 0; i < graph.Length; i++)
            {
                var queue = new Queue<int>();
                queue.Enqueue(i);
                var depths = Enumerable.Repeat(-1, graph.Length).ToArray();
                depths[i] = 0;
                while (queue.Any())
                {
                    var current = queue.Dequeue();
                    foreach (var next in graph[current])
                    {
                        if (depths[next] != -1)
                        {
                            if (depths[current] % 2 != depths[next] % 2) continue;
                            Console.WriteLine(-1);
                            return;
                        }
                        depths[next] = depths[current] + 1;
                        queue.Enqueue(next);
                    }
                }
                answer = Math.Max(answer, depths.Max() + 1);
                if (answer == graph.Length) break;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 15956
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,H,N;
  cin>>W>>H>>N;
  int a=W*H;
  int X[N],Y[N],A[N];
  int P[W][H]={0};
  for(int i=0;i<N;i++) cin>>X[i]>>Y[i]>>A[i];
  for(int i=0;i<N;i++){
    switch(A[i]){
      case 1:
        for(int x=0;x<X[i];x++){
          for(int y=0;y<H;y++) P[x][y]=1;
        }
        break;
      case 2:
        for(int x=X[i];x<W;x++){
          for(int y=0;y<H;y++) P[x][y]=1;
        }
        break;
      case 3:
        for(int y=0;y<Y[i];y++){
          for(int x=0;x<W;x++) P[x][y]=1;
        }
        break;
      case 4:
        for(int y=Y[i];y<H;y++){
          for(int x=0;x<W;x++) P[x][y]=1;
        }
        break;
    }
  }
  for(int x=0;x<W;x++){
    for(int y=0;y<H;y++){
      a-=P[x][y];
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, i;
      cin >> n;
      string s;
      map <string, lld> vote;
      map <string, lld> :: iterator itr;
      foi(i, n)
      {
      	cin >> s;
      	if (!vote.count(s))
      	{
      		vote.insert(pair<string,lld>(s,1));
      	}
      	else
      	{
      		itr = vote.find(s);
      		lld c =itr->second;
      		c++;
      		vote.erase(s);
      		vote.insert(pair<string,lld>(s,c));
      	}
      }
      lld max = 0;
      for(itr = vote.begin(); itr!=vote.end();itr++)
      {
      	if ((itr->second) > max)
      	{
      		max = itr->second;
      	}
      }
      string Array[n];
      lld j = 0;
      for(itr = vote.begin(); itr!=vote.end();itr++)
      {
      	if ((itr->second) ==max)
      	{
      		Array[j] = itr->first;
      		j++;
      	}
      }
      sort(Array, Array + j);
      foi(i, j)
      {
      	cout << Array[i] << "\n";
      }
      return 0;
}

Measured memory_bytes: 25472
#include<stdio.h>

int main(void){
    
 int x,y,z,i;
 int n =0;
 scanf("%d %d %d",&x,&y,&z);
    
    
for( i=x; i<=y; i++ ){ 


    if( z%i == 0 ) 

    n++;
  } 

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

return 0;
   
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

char N[5];
int main(){
    scanf("%s",&N);
    if(N[0]==N[1]&&N[1]==N[2]){
        cout << "Yes" << endl;
    }else if(N[1]==N[2]&&N[2]==N[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(){
    int p,q,r;
    cin >> p>>q>>r;
    int ans = p+q+r-max(max(p,q),max(q,r));
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int h,n,a[1005],b[1005];
int dp[1][30005];

int main(){
	cin>>h>>n;
	rep(i,n) cin>>a[i]>>b[i];
	rep(a,1)rep(b,30005)dp[a][b]=INF;
	dp[0][0] = 0;
	rep(i,n){
		rep(x,30005){
			if(dp[0][x] == INF) continue;
			if(x+a[i] < 30005) dp[0][x+a[i]] = min(dp[0][x+a[i]],dp[0][x]+b[i]);
		}
	}
	int ans = INF;
	for(int x=h;x<30005;x++) ans = min(ans,dp[0][x]);
	if(ans == INF) puts("-1"); else cout<<ans<<endl;
}

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

int main(){
  string S;cin>>S;
  int mod=2019;
  vector<int> T(S.size()+1);
  vector<int> C(2019,0);
  T[S.size()]=0;
  vector<int> ruimod(200001,0);
  ruimod[0]=1;
  for(int i=1;i<200001;i++){
    ruimod[i]=(ruimod[i-1]*10)%mod;
  }
  for(int i=S.size()-1;i>=0;i--){
    T[i]=(T[i+1]+(S[i]-'0')*ruimod[S.size()-i-1])%mod;
  }
  int a=S.size();
  for(int i=0;i<=a;i++){
    C[T[i]]++;
  }
  int cnt=0;
  for(int i=0;i<2019;i++){
    if(C[i]>=2)cnt+=(C[i]*(C[i]-1))/2;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 5176
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int N,K;
int main(int argc, char const *argv[])
{
    cin >> N>>K;
    if(N%2==1){
        if((N+1)/2<K){
            cout<<"NO"<<endl;
        }else{
            cout<<"YES"<<endl;
        }
    }else{
        if(N/2<K){
            cout<<"NO"<<endl;
        }else{
            cout<<"YES"<<endl;
        }
    }

    return 0;
}


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

int n, W; 
int v[100], w[100]; 
int dp[101][10000]; 
int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++) cin >> v[i] >> w[i];
    for (int i =n-1; i >= 0; i--) { 
        for (int j = 0; j <= W; j++) { 
            if (j < w[i]) {
                dp[i][j] = dp[i+1][j];
            }
            else {
                dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
            }
        }
    }

    cout << dp[0][W] << endl;
} 


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

void print(vector<int> v){
    for(auto el : v){
        cout << el << " ";
    }
    cout << endl;
}

int main(){
    int N; cin >> N;
    vector<int> vec(N), p(N), q(N);
    rep(i,N) vec[i] = i+1;
    rep(i,N) cin >> p[i];
    rep(i,N) cin >> q[i];

    int a,b;
    a=b=-1;
    int i=1;
    do{
        if(vec == p) a = i;
        if(vec == q) b = i;
        i++;
    }while(next_permutation(vec.begin(), vec.end()));
    cout << fabs(a-b) << endl;
}

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

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

#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

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

    constexpr ll X_MAX = 10000000000ll;
    constexpr ll INF = 2 * X_MAX;
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    REP(i, A) cin >> s[i];
    REP(i, B) cin >> t[i];
    REP(_, Q) {
        ll x;
        cin >> x;

        auto s_ub = upper_bound(all(s), x);
        auto t_ub = upper_bound(all(t), x);
        ll s_right, t_right, s_left, t_left;
        if (s_ub != s.end()) {
            s_right = *s_ub;
        } else {
            s_right = INF;
        }
        if (t_ub != t.end()) {
            t_right = *t_ub;
        } else {
            t_right = INF;
        }
        if (s_ub != s.begin()) {
            s_left = *(s_ub - 1);
        } else {
            s_left = -INF;
        }
        if (t_ub != t.begin()) {
            t_left = *(t_ub - 1);
        } else {
            t_left = -INF;
        }

        ll d_sl = x - s_left;
        ll d_tl = x - t_left;
        ll d_sr = s_right - x;
        ll d_tr = t_right - x;
        ll cost_l = max(d_sl, d_tl);
        ll cost_r = max(d_sr, d_tr);
        ll cost_lr = min(2 * d_sl + d_tr, 2 * d_tl + d_sr);
        ll cost_rl = min(2 * d_sr + d_tl, 2 * d_tr + d_sl);
        ll cost_min = min(min(cost_l, cost_r), min(cost_lr, cost_rl));
        cout << cost_min << "\n";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
# TODO B - Five Dishes
# https://atcoder.jp/contests/abc123/tasks/abc123_b

NUM_DISHES = 5
intervals = list()

total_time = 0
for i in range(NUM_DISHES):
    serve_time = int(input())
    total_time += serve_time

    if serve_time % 10 == 0:
        intervals.append(0)
    else:
        intervals.append(10 - serve_time % 10)

intervals.sort()

for interval in range(len(intervals) - 1):
    total_time += intervals[interval]

print "{:d}".format(total_time)


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

#define int long long
int dp[200005];
int INF = 1000000005;
double PI = 3.14159265358979323846;
int getLIS(vector<int> &a){
	
	int P = a.size();
	fill(dp, dp + P, INF);
	for (int i = 0; i<P; ++i) {
		*lower_bound(dp, dp + P, a[i]) = a[i];
	}
	return lower_bound(dp, dp + P, INF) - dp;
}
signed main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int N;
	cin >> N;
	vector<pair<int,int> > X(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i].first >> X[i].second;
	}
	
	vector<int>k;
	bool f = false;
	double res;
	if (x1 == x2) {
		if (y2 < y1) swap(y1, y2);
		for (int i = 0; i < N; i++) {
			if (X[i].first==x1 && (X[i].second>y1) && X[i].second<y2) {
				f = true;
			}
		}
		res = (y2 - y1) * 100;
		if (f) {
			res += (10 * PI - 20);
		}
	}
	else if (y1 == y2) {
		if (x2 < x1) swap(x1, x2);
		for (int i = 0; i < N; i++) {
			if (X[i].second == y1 && (X[i].first>x1) && X[i].first<x2) {
				f = true;
			}
		}
		res = (x2 - x1) * 100;
		if (f) {
			res += (10 * PI - 20);
		}
	}
	else {
		if ((x2 - x1 > 0) && (y2 - y1) > 0) {

		}
		else if ((x2 - x1 < 0) && (y2 - y1) < 0) {
			swap(x1, x2);
			swap(y1, y2);
		}
		else if ((x2 - x1 > 0) && (y2 - y1) < 0) {
			y2 = -y2;
			y1 = -y1;
			for (int i = 0; i < N; i++) {
				X[i].second = -X[i].second;
			}
		}
		else {
			x2 = -x2;
			x1 = -x1;
			for (int i = 0; i < N; i++) {
				X[i].first = -X[i].first;
			}
		}
		sort(X.begin(), X.end());
		for (int i = 0; i < N; i++) {
			if (x1<=X[i].first && x2>=X[i].first && y1<=X[i].second && y2>=X[i].second) {
				k.push_back(X[i].second);
			}
		}
		int l = getLIS(k);
		res = 100 * (abs(x1 - x2) + abs(y1 - y2));
		if (min(x2 - x1, y2 - y1) == l - 1){
			res += (l-1)*(5 * PI - 20);
			res += (10 * PI - 20);
		}
		else {
			res += l*(5 * PI - 20);
		}
		
	}
	
	cout << setprecision(20) << res << endl;
	return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::cout << n * 800 - (n / 15) * 200 << std::endl;
  return 0;
}


Measured memory_bytes: 256
s = list(str(input()))

g = 0
p = 0
res = 0
for i in range(len(s)):
	if s[i] == 'p':
		if p + 1 <= g:
			p += 1
		else:
			g += 1
			res -= 1
	else: # if s[i] == 'g':
		if p + 1 <= g:
			p += 1
			res += 1
		else:
			g+=1

print(res)

Measured memory_bytes: 3956
#include <stdio.h>
int main(){
    int max=0,n,i,j,count=1;
    scanf("%d\n", &n);
    int arr[n];

    for(j=0;j<n;j++){
        scanf("%d", &arr[j]);
    }

    max=arr[0];

    for(i=1;i<n;i++){
        if(arr[i]>=max){
            count++;
            max = arr[i];
        }
    }

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

Measured memory_bytes: 1736
S = input()
N = len(S)
S1 = S[:int((N-1)/2)]
S2 = S[int((N+1)/2) : N]
l = [S, S1, S2]
ans = 'Yes'

for s in l:
  for i in range(len(s)):
    a = s[i]
    b = s[-(i+1)]
    if a != b:
      ans = 'No'

print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second
#define pb push_back 
#define pf push_front 
#define ppb pop_back 
#define ppf pop_front 

using namespace std ;
 
int z , o , ans ;
 
int main(){
 

	int x ;
	cin >> x ;

	int k = x / 500 ;

	x %= 500 ;

	cout << ( (x / 5) * 5 ) + ( k * 1000 ) ;	

 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;


int main() {
	ll n, a, b; cin >> n >> a >> b;
	if (a + b > n + 1 || a*b < n) {
		cout << -1 << endl;
		return 0;
	}
	if (b == 1) {
		if (a == n) for (ll i = 1; i <= n; i++) cout << i << (i < n ? " " : "\n");
		else cout << -1 << endl;
		return 0;
	}

	vector<ll> ans;
	for (ll i = n - a + 1; i <= n; i++) ans.push_back(i);
	ll pos = n - a;
	ll bl = (n - a) / (b - 1);
	ll res = (n - a) % (b - 1);
	for (ll i = 1; i <= b - 1; i++) {
		for (ll j = pos - bl - (i <= res) + 1; j <= pos; j++) ans.push_back(j);
		pos = pos - bl - (i <= res);
	}
	for (ll i = 0; i < n; i++) cout << ans[i] << (i < n - 1 ? " " : "\n");
	return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll x,r,D;

int main(){
  cin >> r >> D >> x;
  for(int i=0;i<10;++i){
    x=r*x-D;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
Cards = [
    "S 1", "S 2", "S 3", "S 4", "S 5", "S 6", "S 7", "S 8", "S 9", "S 10", "S 11", "S 12", "S 13",
    "H 1", "H 2", "H 3", "H 4", "H 5", "H 6", "H 7", "H 8", "H 9", "H 10", "H 11", "H 12", "H 13",
    "C 1", "C 2", "C 3", "C 4", "C 5", "C 6", "C 7", "C 8", "C 9", "C 10", "C 11", "C 12", "C 13",
    "D 1", "D 2", "D 3", "D 4", "D 5", "D 6", "D 7", "D 8", "D 9", "D 10", "D 11", "D 12", "D 13",
]

n = input()

for i in range(int(n)):
    rm = input()
    Cards.remove(rm)

for i in range(52 - int(n)):
    print(Cards.pop(0))


Measured memory_bytes: 5596
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int n = sc.nextInt();
            int m = sc.nextInt();

            ArrayList[] l = new ArrayList[m];
            for (int i = 0; i < m; i++) {
                int cnt = sc.nextInt();
                l[i] = new ArrayList();
                for (int j = 0; j < cnt; j++) l[i].add(sc.nextInt() - 1);
            }

            int[] p = new int[m];
            for (int i = 0; i < p.length; i++) p[i] = sc.nextInt();

            int ret = 0;
            for (int st = 0; st < 1 << n; st++) {
                int lighted = 0;
                for (int i = 0; i < l.length; i++) {
                    ArrayList<Integer> wiring = l[i];

                    int acc = 0;
                    for (Integer w : wiring) {
                        acc = (acc + (st >>> w & 1)) % 2;
                    }

                    if (acc == p[i]) lighted++;
                }

                if (lighted == m) ret++;
            }

            out.println(ret);
        }
    }
    
}


Measured memory_bytes: 22100
/* ALDS1_11_C: Breadth First Search */

#include <iostream>
#include <vector>
#include <queue>
using std::vector;
using std::queue;

// 頂点0から各頂点への最短距離を paths に格納する。
void minimum_paths(int n_v, vector<int> graph[], int paths[]) {
    queue<int> visits;
    int found[n_v];
    std::fill_n(found, n_v, 0);
    found[0] = 1;

    visits.push(0);
    while(! visits.empty()) {
        int id = visits.front();
        visits.pop();
        vector<int> adjs = graph[id];
        for (int i = 0; i < adjs.size(); i++) {
            int adj = adjs[i];
            if (! found[adj]) {
                found[adj] = 1;
                paths[adj] = paths[id] + 1;
                visits.push(adj);
            }
        }
    }

    // 辿りつけなかった頂点までの距離は -1 とする。
    for (int i = 1; i < n_v; i++) {
        if (paths[i] == 0) {
            paths[i] = -1;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    int n_v;
    std::cin >> n_v;

    int id, adj, n_adjs;
    vector<int> *graph = new vector<int>[n_v];
    for (int i = 0; i < n_v; i++) {
        std::cin >> id >> n_adjs;
        for (int j = 0; j < n_adjs; j++) {
            std::cin >> adj;
            graph[id - 1].push_back(adj - 1);
        }
    }

    int paths[n_v];
    std::fill_n(paths, n_v, 0);
    minimum_paths(n_v, graph, paths);

    for (int i = 0; i < n_v; i++) {
        std::cout << i + 1 << " " << paths[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1228
use std::io::Read;

fn calc_sum(n : i64, m : i64) -> i64 {
    let mut res = 0;
    let mut val = n;
    while val >= m {
        res += val / m;
        val /= m;
    }
    res
}

fn solve(n : i64) -> i64 {
    if n%2 == 0 {
        std::cmp::min(calc_sum(n, 2), calc_sum(n/2, 5))
    } else {
        0
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let n = buf.trim_right().parse::<i64>().unwrap();
    println!("{}", solve(n));
}


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

int main()
{
    string s;
    int money = 700;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i] == 'o'){
            money += 100;
        }
    }
    cout << money << endl;
    return 0;
}


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

using namespace std;

#define FOR(i,n)	for(int i=0;i<(int)n;i++)
#define FOB(i,n)	for(int i=n;i>=1;i--)
#define MP(x,y)	make_pair((x),(y))
#define ii pair<int, int>
#define lli long long int
#define ulli unsigned long long int
#define lili pair<lli, lli>
#ifdef EBUG
#define DBG	if(1)
#else
#define DBG	if(0)
#endif
#define SIZE(x) int(x.size())
const int infinity = 2000000999 / 2;
const long long int inff = 4000000000000000999;

typedef complex<long double> point;

template<class T>
T get() {
    T a;
    cin >> a;
    return a;
}

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont){
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T,U> &cont){
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}"; return out;
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  FOR(i, v.size()){
    if(i) out << " ";
    out << v[i];
  }
  out << endl;
  return out;
}

bool ccw(point p, point a, point b){
  if((conj(a - p) * (b - p)).imag() <= 0) return(0);
  else return(1);
}

int main(){
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    
    int n = get<int>();
    vector<int> pfs(1, 0), sfs(n + 1, 0), A, B;
    FOR(i, n){
        A.push_back(get<int>());
        pfs.push_back(pfs[i] + A[i]);
    }
    FOR(i, n) B.push_back(get<int>());
    
    for(int i = n - 1; i >= 0; i --) sfs[i] = sfs[i + 1] + B[i];
    int maxi = 0;
    FOR(i, n){
        DBG cout << i << " : " << pfs[i + 1] << " + " << sfs[i] << endl;
        maxi = max(pfs[i + 1] + sfs[i], maxi);
    }
    cout << maxi << endl;
    
}


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

using ll=long long;
const ll MOD=1e9+7;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(n+1,vector<ll>(n+1,0)));
    dp[0][0][1]=1;
    for(int i=0;i<m;i++){
        for(int j=0;j<=n;j++) fill(dp[(i+1)&1][j].begin(),dp[(i+1)&1][j].end(),0LL);
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                //dp[i&1][j][k]
                if(j+1<=n) (dp[(i+1)&1][j+1][k]+=dp[i&1][j][k]*max((n-j-k),0))%=MOD;
                (dp[(i+1)&1][j][k]+=dp[i&1][j][k]*j)%=MOD;
                if(j+k<=n) (dp[(i+1)&1][0][j+k]+=dp[i&1][j][k]*k)%=MOD;
            }
        }
    }
    cout<<dp[m&1][0][n]<<endl;
    return 0;
}

Measured memory_bytes: 2432