akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int main(){
    int n;
    scanf("%d",&n);
    int ans[n]; memset(ans,0,sizeof(ans));
    int ct = 0;
    vector<int> adjlist[n+1];
    for (int i = 0; i < n-1; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        adjlist[a].push_back(i);
        adjlist[b].push_back(i);
    }
    for (int i = 1; i <= n; i++){
        unordered_set<int> s;
        ct = max(ct,(int)adjlist[i].size());
        for (int j = 1; j <= (int)adjlist[i].size(); j++){
            s.insert(j);
        }
       // printf("%d has %d in set\n",i,(int)s.size());
        for (auto x : adjlist[i]){
            if (ans[x] != 0){
               // printf("%d already done\n",x);
                if (s.find(ans[x]) != s.end()) s.erase(s.find(ans[x]));
            }
        }
        for (auto x : adjlist[i]){
            if (ans[x] == 0){
                //printf("fillling in %d %d\n",x,s.size());
                ans[x] = *s.begin(); s.erase(s.begin());
            }
        }
    }
    printf("%d\n",ct);
    for (int i = 0; i < n-1; i++){
        printf("%d\n",ans[i]);
    }

}


Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	string S, T;
	cin >> S >> T;
	int N = (int)S.size();
	int ok = 0;
	for(int i=0;i<N;i++){
		int check = 1;
		for(int j=0;j<N;j++){
			if(S[(i + j) % N] != T[j])check = 0;
		}
		if(check)ok = 1;
	}
	if(ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 cin >> a>> b;
 if(a>=13){
     cout << b << endl;
 }else if(a>5&&a<=12){
     cout << b/2 << endl;
 }else{
     cout << 0 << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#n, m = gets.chomp.split.map(&:to_i)
#ary = []; n.times { cakes << gets.chomp.split.map(&:to_i).to_a } 
#def cb(i);	i==1 ? 1 : -1;end
n = gets.chomp.to_i

puts n == 3 || n == 5 || n == 7 ? 'YES' : 'NO'


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <string>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long  ll;
const int max_n = 1e5 + 5;
bool was[200];

int main(){
    faster
    int n, k; cin >> n >> k;
    for(int i = 0;i < k;i++){
        int d; cin >> d;
        for(int j = 0;j < d;j++){
            int a; cin >> a;
            was[a - 1] = true;
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++)
        if(!was[i])
            ans++;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3592
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		fmt.Println("a > b")
	} else if a < b {
		fmt.Println("a < b")
	} else {
		fmt.Println("a == b")
	}
}



Measured memory_bytes: 1128
a,b,c=sorted(list(map(int,input().split())))
p,q=(c-a)//2,(c-b)//2
r=p+q
a,b=a+2*p,b+2*q
if a==c and b==c:
  print(r)
elif a==c or b==c:
  print(r+2)
else:
  print(r+1)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, x;
    cin >> n;
    int a[2][n];
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> x;
            a[i][j] = x;
            //cout << a[i][j] << " ";
        }
        //cout << endl;
    }
    
    int c[2][n];
    c[0][0] = a[0][0];
    c[1][0] = a[1][0];
    for (int i = 0; i < 2; i++) {
        for (int j = 1; j < n; j++) {
            c[i][j] = a[i][j] + c[i][j-1];
            //cout << c[i][j] << " ";
        }
        //cout << endl;
    }
    
    int sum = 0, max;
    max = c[1][n-1] + c[0][0];
    for (int i = 1; i < n - 1; i++) {
        sum = c[0][i] + (c[1][n-1] - c[1][i-1]);
        if (sum > max) {
            max = sum;
        }
    }
    cout << max << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp;
#define ll long long

long long knap(vector<ll> &weight, vector<ll> &val, ll max_weight, ll n , ll index)
{
    if(index == n || max_weight == 0)            return 0;
    if(dp[index][max_weight] != -1)
        return dp[index][max_weight];

    if(weight[index] > max_weight)
        dp[index][max_weight] =  knap(weight, val , max_weight , n, index+1);

    else
        dp[index][max_weight] = max(
                                    knap(weight , val , max_weight - weight[index] , n , index+1) + val[index],
                                    knap(weight , val , max_weight , n , index+1)
                                    );
    return dp[index][max_weight];
}

int main()
{
    ll n,  max_weight;
    cin>>n>>max_weight;
    dp = vector<vector<ll>>(n+1 , vector<ll>(max_weight+1,-1));

    vector<ll> val(n) , weight(n);
    for(ll i=0 ; i<n ; i++)
        cin>>weight[i] >> val[i];

    ll ans = knap(weight , val , max_weight , n , 0);
    cout<<endl<<ans;
}


Measured memory_bytes: 80256
import sys
sys.setrecursionlimit(1000000000)

N = int(input())
G = [[] for _ in range(N)]
for i in range(N - 1):
    a, b, c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    G[a].append((b, c))
    G[b].append((a, c))
    
Q, K = list(map(int,input().split()))

D = [0] * N
def dfs(pos, pre, dis):
    D[pos] = dis
    for (to, cost) in G[pos]:
        if to == pre:
            continue
        dfs(to, pos, dis + cost)


dfs(K - 1, -1, 0)

while Q:
    Q = Q - 1
    x, y = list(map(lambda a:int(a) - 1, input().split()))
    ans = D[x] + D[y]
    print (ans)


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a  > 9 || b > 9){
        cout << -1 << endl;
        return 0;
    }
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdint.h>
#include <string.h>

int main() {
    int32_t a, b, c;
    
    scanf("%ld %ld %ld", &a, &b, &c);
    
    if (a > c) {
        printf("1\n");
        return 0;
    }
    
    int32_t i = 0;
    while (c > 0) {
        c -= a;

        if (i % 7 == 6) {
            c -= b;
        } 

        ++i;
    }

    printf("%ld\n", i);

    return 0;
}



Measured memory_bytes: 2128
z[4000],*a=z,*b=z+2000,m,i,j;main(n){for(;!scanf("%d",&n)||n;m=!printf("%d\n",m))for(i=++n;i--;j=a,a=b,b=j)for(j=n;j--;)m=fmax(m,b[j]=n+~i&&getchar()>45?1+fmin(fmin(b[j+1],a[j+1]),a[j]):0);}

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

bitset<4040404> dp;

int main(){
  int N; cin>>N;
  int A[N]; rep(i,N) cin>>A[i];
  dp[0]=1;
  int sum=0;
  rep(i,N){
    sum+=A[i];
    dp|=(dp<<A[i]);
  }
  for(int i=(sum+1)/2;i<=sum;i++) if(dp[i]){
    cout<<i<<endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void) {
	int a, b;
	int i = 0 , buf;
	
	while (scanf("%d %d", &a, &b) != EOF){
		i = 0;
		buf = a + b;
		while (1){
			i++;
			buf = buf / 10;
			if (buf == 0) break;
		}
		printf("%d\n", i);
	}
	

	return 0;
}

Measured memory_bytes: 600
N,M = map(int,input().split())
minimum = 1
maximum = N 
for i in range(M):
    L,R = map(int,input().split())
    minimum = max(minimum,L)
    maximum = min(maximum,R)
    if minimum > maximum:
        print(0)
        exit(0)

print(maximum - minimum + 1)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;
 
typedef long long LL;
typedef pair < int, int > pa;
 
const int MAXN = 100010;
 
int n, x[MAXN], a[MAXN], w[MAXN], L, T;
LL cur;
 
int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d%d", &n, &L, &T );
	for( int i = 0 ; i < n ; i++ )
	{
		scanf( "%d%d", &a[ i ], &w[ i ] );
		if( w[ i ] == 1 )
		{
			x[ i ] = ( a[ i ] + T ) % L;
			cur += ( a[ i ] + T ) / L;
		}
		else
		{
			x[ i ] = ( a[ i ] - T ) % L;
			cur += ( a[ i ] - T ) / L;
			if( x[ i ] < 0 ) x[ i ] += L, cur--;
		}
	}
	cur = ( cur % n + n ) % n;
	sort( x, x + n );
	for( int i = cur ; i < n ; i++ ) printf( "%d\n", x[ i ] );
	for( int i = 0 ; i < cur ; i++ ) printf( "%d\n", x[ i ] );
}



Measured memory_bytes: 2304
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.count = [1] * (n + 1)

    # find
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # union
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
                self.count[y] += self.count[x]
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
                self.count[x] += self.count[y]

    # size
    def size(self, x):
        return self.count[self.par[x]]

    # same
    def issame(self, x, y):
        return self.find(x) == self.find(y)

n,m=map(int,input().split())
a=[tuple(map(int,input().split())) for i in range(m)]
U=UnionFind(n)
dis=[0]
cn=0
for i,j in reversed(a):
    if U.issame(i,j)==True:
        dis.append(cn)
    else:
        cn+=U.size(i)*U.size(j)
        dis.append(cn)
    U.union(i, j)
M=int(n*(n-1)/2)
for x in reversed(dis[:-1]):
    print(M-x)


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

int main() {
  long long int N, R=0, W=0 , count=0;
  cin >> N;
  vector <char> c(N);
  queue <long long int> r,w;

  for (long long int i=0;i<N; i++){
    cin >> c.at(i);
    if(c.at(i)=='R'){
      R++;
      r.push(i);
    }
    else{
      W++;
      w.push(i);
    }
    if(i==0) continue;
    if(c.at(i-1)=='W'&&c.at(i)=='R'){
      count ++;
    }

  }
  //cout << "complete0" << endl;
  if(count ==0){
    cout <<0 <<endl;
  }
  else if(w.empty()||r.empty()){
    cout <<0 <<endl;
  }
  else{
    vector<long long int>tmp(R);
    for(long long int i=R-1;i>-1;i--){
      tmp.at(i)=r.front();
      r.pop();
    }
    for(long long int i=0; i<R; i++){
      r.push(tmp.at(i));
    }

    //cout << "complete1" << endl;

    long long int w_min,r_max;
    w_min=w.front();
    r_max=r.front();
    count = 0;
    while(true){
      if(w_min<r_max){
        count++;

        w.pop();
        if(!w.empty()){
          w_min = min(w.front(),r_max);
        }
        else break;

        r.pop();
        if(!r.empty()){
          r_max = max(r.front(),w_min);
        }
        else break;

      }
      else{
        break;
      }
    }
    cout << count << endl;
  }


}


Measured memory_bytes: 6404
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];

    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];        
    }
    int mean = sum/n;

    int res = 0;
    int res1 = 0;
    int res2 = 0;
    for (int i = 0; i < n; i++) {
        res += (mean - a[i]) * (mean - a[i]);
        res1+= (mean+1 - a[i]) * (mean+1 - a[i]);
        res2 += (mean-1 - a[i]) * (mean-1 - a[i]);
    }

    cout << min(res, min(res1, res2)) << endl;
    return 0;
}



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

int zero[4] = {1, 2, 4, 3};
int one[4] = {0, 3, 5, 2};
int two[4] = {0, 1, 5, 4};

// getNeighbors gets the correct array of zero, one, and two given a number 0, 1, 2, 3, 4, or 5.
int *getNeighbors(int index)
{
  if (index > 2)
     index = 5 - index;
  switch (index)
    {
    case 0:
      return zero;
    case 1:
      return one;
    case 2:
      return two;
    }
}

// chooseIndex chooses to search zero, one, or two for the purposes of getIndex2(int,int).
int chooseIndex(int index0, int index1)
{
  int i;
  int indices[3] = {};
  indices[index0 < 3 ? index0 : 5 - index0] = 1;
  indices[index1 < 3 ? index1 : 5 - index1] = 1;
  for (i = 0; i < 3; i++)
    if (!indices[i])
      return i;
}

// getIndex2 determines the 3rd index in the counter-clockwise rotation of index0 -> index1 -> index2.
int getIndex2(int index0, int index1)
{
  int *toSearch, i;
  int index = chooseIndex(index0, index1);
  toSearch = getNeighbors(index);
  for (i = 0; i < 4; i++)
    {
      if (toSearch[i] == index0)
	if (toSearch[(i + 1) % 4] == index1)
	  return index;
	else
	  return 5 - index;
    }
}

// same determines if die0 and die1 are the same, it returns 1 if the are0 if not.
int same(int die0[], int die1[])
{
  int i, index0, index1;
  // set index0
  for (index0 = 0; index0 < 6; index0++)
    {
      if (die0[0] != die1[index0])
	continue;
      // set index1
      int *neighbors = getNeighbors(index0);
      for (i = 0; i < 4; i++)
	{
	  index1 = neighbors[i];
	  if (die0[1] != die1[index1])
	    continue;
	  // find the 3rd counter-clockwise index of die1
	  int index2 = getIndex2(index0, index1);
	  if (die0[2] != die1[index2])
	    continue;
	  // check the last three faces are equivalent
	  if (die0[3] != die1[5 - index2])
	    continue;
	  if (die0[4] != die1[5 - index1])
	    continue;
	  if (die0[5] != die1[5 - index0])
	    continue;
	  return 1;
	}
    }
  return 0;
}

int main(void)
{
  int *dice, n, i, j;
  scanf(" %d", &n);
  dice = malloc(sizeof(int[6]) * n);
  for (i = 0; i < n * 6; i++)
    scanf(" %d", dice + i);
  // perform pairwise comparisons
  for (i = 0; i < n; i++)
    {
      for (j = i + 1; j < n; j++)
	{
	  if (same(&dice[i * 6], &dice[j * 6]))
	    {
	      printf("No\n");
	      return 0;
	    }
	}
    }
  printf("Yes\n");
  return 0;
}



Measured memory_bytes: 2080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

#define INF 9999999999;
#define D(x) cout << x << endl;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;

int main() {
  
  int a, b;
  
  cin >> a >> b;

  if (a == 1) {
    a = 14;
  }

  if (b == 1) {
    b = 14;
  }

  if (a == b) {
    cout << "Draw" << endl;
  } else { 
    cout << (a > b ? "Alice" : "Bob") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<int> A(x);
    vector<int> B(y);
    vector<int> C(z);
    rep(i,x)cin >> A[i];
    rep(i,y)cin >> B[i];
    rep(i,z)cin >> C[i];

    SORT(A);
    SORT(B);
    SORT(C);

    vector<int> ans;
    rep(a,x){
        rep(b,y){
            rep(c,z){
                if((a+1)*(b+1)*(c+1) > k)break;
                ans.pb(A[x-1-a]+B[y-1-b]+C[z-1-c]);
            }
            if((a+1)*(b+1) > k)break;
        }
        if((a+1) > k)break;
    }
    
    SORT(ans);

    rep(i,k){
        cout << ans[ans.size()-1-i] << endl;
    }

    

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc123.contest.atcoder.jp/tasks/abc123_d

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll A;
	double B; cin >> A >> B;
	ll BB = (B+1e-6)*100;
	cout << (A*BB)/100 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b){
            System.out.println("a < b");
        }else if(a == b){
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26156
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
int c[10005];
int a[2000005],b[2000005],n;
void CountingSort()
{
	mem(c,0);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		c[a[i]]++;
	}
	for(int i=1;i<=10005;i++)
	{
		c[i] = c[i]+c[i-1];
	}
	for(int i=n;i>0;i--)
	{
		b[c[a[i]]] = a[i];
		c[a[i]]--;
	}
}
int main()
{
	cin>>n;
	CountingSort();
	for(int i =1;i<=n;i++)
	{
		if(i>1)
		cout<<' ';
		cout<<b[i];
	}
	cout<<endl;
	return 0;
	
	
}








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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cout << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}

void test() {
    cout << "TEST: " << endl;


    exit(0);
}


void smain() {

    ll k, a, b;
    cin >> k >> a >> b;
    if (b > a + 1) {
        ll steps = a - 1;
        ll rest = k - steps;
        if (rest < 0) {
            cout << k + 1;
            return;
        }
        ll ans = a + (rest >> 1) * (b - a) + ((rest & 1) ? 1 : 0);
        inmax(ans, k + 1);
        cout << ans;
    } else {
        cout << k + 1;
    }
}


Measured memory_bytes: 256
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int val = 0;
    for (int i = 0; i < n; ++i) {
        val = v[i] ^ val;
    }
    for (int i = 0; i < n; ++i) {
        int x = v[i] ^ val;
        cout << x << " ";
    }
    return 0;
}

Measured memory_bytes: 4780
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-07 18:55:24
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

class UnionFind {
 public:
  UnionFind(int n) : n_(n) { initialize(); }

  int root(int x) {
    assert(0 <= x && x < n_);
    if (parent_[x] == -1)
      return x;
    else
      return parent_[x] = root(parent_[x]);
  }

  bool same(int x, int y) {
    assert(0 <= x && x < n_ && 0 <= y && y < n_);
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    assert(0 <= x && x < n_ && 0 <= y && y < n_);
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (rank_[x] < rank_[y]) std::swap(x, y);
    if (rank_[x] == rank_[y]) ++rank_[x];
    parent_[y] = x;
    return;
  }

 private:
  const int n_;
  std::vector<int> parent_;
  std::vector<int> rank_;

  void initialize() {
    parent_.assign(n_, -1);
    rank_.assign(n_, 0);
  }
};

void DSL_1_A() {
  int n, q; cin >> n >> q;
  UnionFind uf(n);
  for (int i = 0; i < q; ++i) {
    int com, x, y; cin >> com >> x >> y;
    if (com == 0) {
      uf.unite(x, y);
    } else {
      cout << uf.same(x, y) << '\n';
    }
  }
}

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

  DSL_1_A();

  return 0;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
const int INF=0x3f;
int m,n,k,p,cnt;
int dis[N],head[N];
struct edge
{
    int nx,to,dist;
} e[N*40];
void add_edge(int a,int b,int dist)
{
    cnt++;e[cnt].nx=head[a];e[cnt].to=b;e[cnt].dist=dist;head[a]=cnt;
}
struct node
{
    int pos,dist;
    bool operator<(const node &x) const
    {
        return x.dist<dist;
    }
};
priority_queue<node> que;
bool vis[N];
void dijkstra(int pos)
{
    for (int i=1;i<=N;i++) dis[i]=INF;
    que.push((node){pos,0});dis[pos]=0;
    while (!que.empty())
    {
        node tmp=que.top();que.pop();
        int x=tmp.pos;
        if (vis[x]) continue;
        vis[x]=true;
        for (int i=head[x];i;i=e[i].nx)
        {
            int y=e[i].to;
            if (dis[y]>dis[x]+e[i].dist)
            {
                dis[y]=dis[x]+e[i].dist;
                if  (!vis[y]) que.push((node) {y,dis[y]});
            }
        }
    }
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=9;j++)
		add_edge(i,((i-1)*10+j)%n+1,j);
	}
	for (int j=1;j<=9;j++) add_edge(0,j+1,j);
	dijkstra(0);
	printf("%d\n",dis[1]);
	return 0;
}

Measured memory_bytes: 17396
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void)

{
    long long int A, B, K;
    cin>>A>>B>>K;//cout<<A<<B<<K<<endl;
    if(K > A){
        K = K-A;
        B = B-K;
        //cout<<K<<B<<endl;
        if(B < 0)
            B = 0;
        A = 0;
    }
    else if(K == A){
        A = 0;
    }
    else{
        A -= K;
    }
    printf("%lld %lld\n", A, B);
    return 0;
}


Measured memory_bytes: 256
(setq h(read))(setq w(read))
(setq a(loop for i from 1 to h collect(read-line)))
(setq p(loop for i from 1 to h collect(if(find #\#(nth (1- i) a))t nil)))
(setq q(loop for i from 1 to w collect(if(>(loop for j from 1 to h count(char=(char(nth (1- j) a)(1- i))#\#))0)t nil)))
(loop for i from 1 to h do(loop for j from 1 to w do(if(and(nth (1- i)p)(nth (1- j)q))(format t"~A"(char(nth (1- i) a)(1- j)))))(if(nth(1- i)p)(format t"~%")))


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

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

Measured memory_bytes: 3584
def comb(n,k):
  if k==0:
    return 1
  if k==1:
    return n
  if k==2:
    return n*(n-1)//2
  if k==3:
    return n*(n-1)*(n-2)//6
  return None
def cnt(n,k):
  if k==0:
    return 1
  if k>len(n):
    return 0
  return (comb(len(n)-1,k)*9**k
          +(int(n[0])-1)*comb(len(n)-1,k-1)*9**(k-1)
          +cnt(n[1:].lstrip('0'),k-1))
def main():
  n=input()
  k=int(input())
  print(cnt(n,k))
main()

Measured memory_bytes: 3064
(defun create-data ()
  (let* ((n (read))
         (a (make-array n)))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (values n a)))


(defun shift-only (n a)
  (let ((res 0)
        (exist-odd nil))
    (loop
      (dotimes (i n)
        (if (/= 0 (rem (aref a i) 2))
            (setf exist-odd t))
        (setf (aref a i) (floor (aref a i) 2)))
      (if (eq exist-odd t) (return))
      (incf res))
    res))

(multiple-value-bind (n a) (create-data)
  (format t "~d~%" (shift-only n a)))

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

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

using namespace std;
using ll = long long;

int main(void) {
  int n, x;
  cin >> n >> x;
  int t = 0;
  int tmp;
  int ans = 1;
  rep(i, n) {
    cin >> tmp;
    t += tmp;
    if (t > x) {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}



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

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

const int MAX = 1e6 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, M;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll f(int cnt){
    return COM(N - 1 + cnt, cnt);
}

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

    map<int, int> m;
    int x = 2;
    while(M >= x * x){
        if(M % x){
            x++;
        } else {
            m[x]++;
            M /= x;
        }
    }
    if(M != 1) m[M]++;

    COMinit();

    ll ans = 1;
    for(auto i : m){
        int cnt = i.second;
        ans = ans * f(cnt);
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

class DayDream
{
public:
	string s;
	vector<string> checkString;
	DayDream();
	~DayDream();
	int dfs(int k);
	void exec();
};


DayDream::DayDream(){
	cin >> s;
	checkString.push_back("dream");
	checkString.push_back("dreamer");
	checkString.push_back("erase");
	checkString.push_back("eraser");
}

DayDream::~DayDream(){}

int DayDream::dfs(int k){
	if(k == s.size()) return s.size();
	int maxV = 0;
	for (int i = 0; i < 4; ++i)
	{
		bool flag = false;
		for (int j = 0; j < checkString[i].size(); ++j)
		{
			if(s.size() >= k+j && s[k+j] == checkString[i][j]){
				flag = true;
			}else{
				flag = false;
				break;
			}
		}
		if(flag){
			maxV = max(maxV, dfs(k+checkString[i].size()) );
		}
	}
	return maxV;
}

void DayDream::exec(){
	if(dfs(0) == s.size()){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}

int main(){
	DayDream dd = DayDream();
	dd.exec();
}

Measured memory_bytes: 1792
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;

}













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

int main()
{
	long long a,b,c,x,y;
	while(cin>>a>>b>>c>>x>>y){
		if(c*2>=a+b)
			cout<<a*x+b*y<<endl;
		else{
			long long m=min(x,y);
			x-=m; y-=m;
			cout<<m*c*2 + min(c*2*max(x,y) , a*x+b*y)<<endl;
		}
	}
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define MAX_N 3010

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    ll N;
    cin >> N;

    vector<double> p(N);
    rep (i, N) {
        cin >> p[i];
    }

    // dp table
    // init dp table
    vector<vector<double>> dp(MAX_N, vector<double>(MAX_N, 0));

    // init condition
    dp[0][0] = 1;

    // loop
    rep (i, N) {
        rep (j, i+1) {
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }

    double ans = 0;
    for (ll i = (N+1)/2; i <= N; i++) {
        ans += dp[N][i];
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[111];

inline bool ok() {
    rin{
        if (a[i] > n - 1)return false;
    }
    return true;
}

inline void process(li x, li times) {
    rin{
        if (i == x) {
            a[i] -= n * times;
        } else{
            a[i] += times;
        }
    }
}

int main() {
    cin >> n;
    rin{cin >> a[i];}
    li cnt = 0;
    while (!ok()) {
        rin{
            if (a[i] > n - 1) {
                cnt += a[i] / n;
                process(i, a[i] / n);
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

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

using namespace std;

int n;
string s, c;

int main()
{
    cin >> n;
    cout << 0 << '\n';
    cout.flush();
    cin >> s;
    if (s == "Vacant")
    {
        cout << 0 << '\n'; cout.flush();
    }
    else
    {
        int l = 1, r = n - 1;
        while (l < r)
        {
            int mid = l + r >> 1;
            cout << mid << '\n'; cout.flush();

            cin >> c;
            if (c == "Vacant")
            {
                cout << mid << '\n'; cout.flush();
                return 0;
            }
            string rem;
            if (mid % 2 == 0)
                rem = s;
            else
            {
                if (s == "Male")
                    rem = "Female";
                else
                    rem = "Male";
            }
            if (c == rem)
                l = mid + 1;
            else
                r = mid;
        }
        cout << l << '\n';
        cout.flush();
    }

    return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll n;
    cin >> n;
    ll a[n];
    vector<ll> cnt(100009, 0);
    for(ll i = 0; i < n; i++) cin >> a[i];

    for(ll i = 0; i < n; i++){
        cnt[a[i]]++;
        cnt[a[i] + 1]++;
        if(a[i] == 0) continue;
        cnt[a[i] - 1]++;
    }

    ll ans = 0;
    for(ll i = 0; i < 100001; i++) ans = max(ans, cnt[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int H,W;
	cin>>H>>W;
	int sp=0;
	rep(i,H*W){
		char x;
		cin>>x;
		if(x=='#')sp++;
	}
	if(sp==H+W-1)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

int main() {
    ll n; cin >> n;
    V<P<ll, ll> > v1(100010), v2(100010);
    for(int i = 0; i < n; i++){
        ll v; cin >> v;
        if(i % 2 == 0){
            v1[v].first++;
            v1[v].second = v;
        }else{
            v2[v].first++;
            v2[v].second = v;
        }
    }

    sort(all(v1), greater<P<ll, ll>>());
    sort(all(v2), greater<P<ll, ll>>());

    ll tmp = 0;
    if(v1[0].second == v2[0].second){
        tmp = max(v1[0].first + v2[1].first, v1[1].first + v2[0].first);
    }else{
        tmp = v1[0].first + v2[0].first;
    }

    cout << n - tmp << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && b >= c ? "Yes" : "No") << endl;
  return 0;
}

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

char mp[30][30];
int dx[]{ -1,1,0,0 }, dy[]{ 0,0,-1,1 };
char cc[]{ 'U','D','L','R' }, ccc[]{ '^','v','<','>' };
int main() {
	int t; scanf("%d", &t);
	rep(k, t) {
		int h, w; scanf("%d%d", &h, &w);
		int px, py, dir;
		rep(i, h) {
			scanf("%s", mp[i]);
			rep(j, w) {
				int d = find(ccc, ccc + 4, mp[i][j]) - ccc;
				if (d < 4)px = i, py = j, dir = d, mp[i][j] = '.';
			}
		}
		int n; string s; cin >> n >> s;
		for (char c : s) {
			if (c != 'S') {
				dir = find(cc, cc + 4, c) - cc;
				int nx = px + dx[dir], ny = py + dy[dir];
				if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&mp[nx][ny] == '.')px = nx, py = ny;
				continue;
			}
			for (int nx = px, ny = py; 0 <= nx&&nx < h && 0 <= ny&&ny < w; nx += dx[dir], ny += dy[dir]) {
				if (mp[nx][ny] == '*') {
					mp[nx][ny] = '.';
					break;
				}
				if (mp[nx][ny] == '#')break;
			}
		}
		mp[px][py] = ccc[dir];
		rep(i, h)printf("%s\n", mp[i]);
		if (k != t - 1)printf("\n");
	}
}

Measured memory_bytes: 3200
package main

import (
	"fmt"
)

const mod = 1000000007
func main() {
	var n int64
	fmt.Scan(&n)

	ans := (powmod(10, n)-2*powmod(9, n)%mod+powmod(8, n)+mod) % mod
	fmt.Println(ans)

}

func powmod(x int64, y int64) int64{
	res := int64(1)
	for i := int64(0); i < y; i++{
		res *= x
		res %= mod
	}
	return res
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=998244353;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

const ll nmax=1000000;


ll fac[nmax],finv[nmax],inv[nmax];

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(ll i=2;i<nmax;i++){
  fac[i]=fac[i-1]*i%mod;
  inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  finv[i]=finv[i-1]*inv[i]%mod;
}
}

ll com(ll n, ll k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}


void solve(){
  ll ans=0;
  ll n,a,b,k;
  cin>>n>>a>>b>>k;
  
  rep(x,0,k/a+1){
   if((k-x*a)%b) continue; 
    ll y=(k-x*a)/b;
    ans+=(com(n,x)*com(n,y))%mod;
    ans%=mod;
  }
  
  cout << ans << endl;
}

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

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

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

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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

    cout << n*n*n << endl;

}



Measured memory_bytes: 256