akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long  a[52],b[52];
long long x,n;
long long ans=0;
void f(int d)
{
    if(x==a[d]){ans+=b[d];return ;}
    else if(x)
    {
        x--;
        if(x>a[d-1])
        {
            x-=a[d-1];
            ans+=b[d-1];
            x--,ans++;
            if(x)f(d-1);
        }
        else f(d-1);
    }
}
int main()
{
    scanf("%lld%lld",&n,&x);
    a[0]=1,b[0]=1;
    for(int i=1; i<=50; i++)
    {
        a[i]=a[i-1]*2+3;
        b[i]=b[i-1]*2+1;
    }
    f(n);
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<queue>
#include <algorithm>
#include<string>
#include <unordered_map>
using namespace std;

const int N=2e6+5;

int t,n,m;
int a[N];
int main(){
    scanf("%d%d",&n,&m);
    if(m>=n) puts("unsafe");
    else puts("safe");

}

Measured memory_bytes: 3168
n=int(input())
a={}
maxkey=0
maxindex=0
bkmaxkey=0
for i in range(n):
  key=int(input())
  if key in a:
    a[key]+=1
  else:
    a[key]=1
  if maxkey<key:
    if bkmaxkey!=0:
      bkmaxkey=maxkey
    maxkey=key
    maxindex=i
if a[maxkey]>1:
  for i in range(n):
    print(maxkey)
else:
  for i in range(n):
    if i==maxindex:
      a.pop(maxkey)
      print(max(a))
    else:
      print(maxkey)

Measured memory_bytes: 15060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, m, r;
    cin >> n >> m >> r;
    vector<int> goal(r);
    for(int i = 0; i < r; ++i){
        cin >> goal[i];
        --goal[i];
    }
    vector<vector<ll>> dist(n, vector<ll>(n, 1e+15));
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int i = 0; i < n; ++i)  dist[i][i] = 0;
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    ll ans = 1e+15;
    vector<int> order(r);
    for(int i = 0; i < r; ++i)  order[i] = i;
    do{
        vector<P> foo(r);
        for(int i = 0; i < r; ++i)  foo[i] = P(order[i], i);
        sort(foo.begin(), foo.end());
        ll sum = 0;
        for(int i = 0; i + 1 < r; ++i){
            int from = goal[foo[i].second];
            int to = goal[foo[i + 1].second];
            sum += dist[from][to];
        }
        chmin(ans, sum);
    }while(next_permutation(order.begin(), order.end()));
    cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC178
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NXT = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var N = long.Parse(Console.ReadLine());
            //var abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var L = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();

            var x = 1000000007L;
            var a = 1L;
            var b = 1L;
            var c = 1L;
            for (int i = 0; i < N; i++)
            {
                a = (a * 10) % x;
                b = (b * 9) % x;
                c = (c * 8) % x;

            }

            var ans = (a - ((2 * b) % x - c)) % x;
            if (ans < 0) Console.WriteLine(ans + x);
            else Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 27504
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 2e5+5;
int n, x, q, ans;
int p[N], vis[N];
int main()
{
    scanf("%d%d", &n, &x);
    if(x == 1||x == 2*n-1) return puts("No"), 0;
    puts("Yes"); 
    p[n] = x, p[n-1] = x == 2?x+1:x-1, p[n+1] = x == 2?x-1:x+1, p[n+2] = x == 2?x+2:x-2;
    vis[x] = vis[x+1] = vis[x-1] = vis[x == 2?x+2:x-2] = 1;
    for(int i = 1, j = 1; i <= 2*n-1; ++i)
    {
        if(p[i]) continue; while(vis[j]) ++j;
        p[i] = j, vis[j] = 1;
    }
    for(int i = 1; i <= 2*n-1; ++i) printf("%d ", p[i]);
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int BLACK=2;
static const int GRAY=1;
int n,M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    d[0]=0;
    color[0]=GRAY;
    while(1){
        minv=INFTY;
        int u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>d[u]+M[u][v]){
                    d[v]=d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<(d[i]==INFTY ? -1:d[i])<<endl;
    }
}


int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=INFTY;
        }
    }
    int k,c,u,v;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            M[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair

string s;

int main(){
cin >> s;
int x = s.size();
if(s[0]==s[x-1]){
    if((x-2)%2==0)cout << "First";
    else cout << "Second";
}
else {
    if((x-2)%2==0)cout << "Second";
    else cout << "First";
}


return 0;}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  const in inf=1e18;
  in n,s;
  in bst=inf;
  cin>>n>>s;
  if(n==s)
    bst=n+1;
  for(in b=2;b*b<=n;++b){
    in tp=n;
    in sm=0;
    while(tp){
      sm+=tp%b;
      tp/=b;
    }
    if(sm==s)
      bst=min(bst,b);
  }
  for(in rt=1;rt*rt<=n;++rt){
    in mxb=n/rt;
    in mnb=max(n/(rt+1)+1,rt+1);
    in gl=rt+n-s;
    if(gl%rt==0){
      in b=gl/rt;
      if(b>=mnb && b<=mxb)
	bst=min(bst,b);
    }
  }
  if(bst==inf)
    cout<<-1<<endl;
  else
    cout<<bst<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	ll a[n+1];
	rep(i, 1, n){
		cin >> a[i];
	}
	ll before = 0;
	ll ans = 0;
	rrep(i, n, 1){
		if(a[i] < before-1 || a[i] > i-1){
			ans = -1;
			break;
		}
		if(a[i] != before-1){
			ans += a[i];
		}
		before = a[i];
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
// 多倍長整数型
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    ll res = 0;
    REP(i, 1, n){
      if(i % 2 == 0)continue;
      int tmp = i;
      int cnt = 0;
      for(int j = 1; j * j <= tmp; j++){
        if(tmp % j == 0){
          cnt++;
          if(j != tmp / j)cnt++;
        }
      }
      if(cnt == 8)res++;
      //cout << i << " " << cnt << endl;
    }
    cout << res << endl;
}





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

vector<int> dev2(vector<int> &A) {
    for (int i = 0; i < A.size(); i++) {
        A.at(i)= A.at(i) / 2;
    }
    return A;
}

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    int count = 0;
    vector<bool> B(N, false);
    do{
        B.at(0) = (A.at(0) % 2 <= 0 ? true : false);
        for (int i = 1; i < N; i++) {
            bool tmpB = false;
            if (A.at(i) % 2 == 0){
                tmpB = true;
            }
            B.at(i) = tmpB && B.at(i-1);
        }
        if (B.at(N-1)) {
            count++;
            dev2(A);
        }
    } while (B.at(N-1));

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[510][510];
int n,m;
int ans;
struct data{
	int i,j;
	int x,y;
}tot[1000010];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	    scanf("%d",&a[i][j]);
	for(int i=1;i<n;i++)
	  for(int j=1;j<=m;j++)
	  	if(a[i][j]&1) 
			a[i+1][j]++,tot[++ans].i=i,tot[ans].j=j,tot[ans].x=i+1,tot[ans].y=j;
	for(int j=1;j<m;j++) if(a[n][j]&1) a[n][j+1]++,tot[++ans].i=n,tot[ans].j=j,tot[ans].x=n,tot[ans].y=j+1;
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++) printf("%d %d %d %d\n",tot[i].i,tot[i].j,tot[i].x,tot[i].y); 	
	return 0;
}


Measured memory_bytes: 6400
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
a = [int(i) for i in input().split()]

count = 0
total = sum(a)
for i in a:
    if i >= (total / (4 * m)):
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")


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

double ans,now,x;
string s;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x>>s;
        if(s=="JPY")    ans+=x;
        else ans+=x*380000.0;
    }
    printf("%.10lf",ans);
    return 0;
}

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

using namespace std;

int main(){
	int n;
	int val=0;
	int ans=0;
	int count=0;
	vector<int> a; 

	cin>>n;

	for(int i=0; i<n; i++){
		int tmp;
		cin>>tmp;

		a.push_back(tmp);
	}

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

	for(int i=0; i<n; i++){
		if(val!= a[i]){
			if(val<count){
				ans+= count-val;
			}

			if(count<val){
				ans+= count;
			}
			val= a[i];
			count= 1;
		}else{
			count++;
		}

		if(i==n-1){
			if(val<count){
				ans+= count-val;
			}

			if(count<val){
				ans+= count;
			}						
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL  solve(LL i,LL N,LL K) {
	LL sum = 0;
	if ((N / i)*(i - K) > 0) 
	{
		sum += (N / i)*(i - K);
	}

	if (K == 0) {
		sum += N % i;
	}
	else {
		if (N%i - (K - 1) > 0)
		{
			sum += N % i - (K - 1);
		}
	}
	return sum;
}

int main() {
	LL N, K;
	cin >> N >> K;

	LL sum = 0;
	FOR(i, 1, N + 1) {
		sum += solve(i, N,K);
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
  string line;

  while (1) {
    getline(cin, line);
    if (line == "END OF INPUT") return 0;
    string word;
    stringstream ss(line);
    char delim = ' ';
    while (getline(ss, word, delim)) {
      cout << word.length();
    }
    cout << endl;
  }
}



Measured memory_bytes: 3012
def gcd(a, b):
  if a < b:
    tmp = b
    b = a
    a = tmp
  while b != 0:
    tmp = a % b
    a = b
    b = tmp
  return a

n, m = [int(x) for x in input().split()]
s, t = [input() for _ in range(2)]

d = gcd(n, m)

nd = n // d
md = m // d

if all(s[nd*i] == t[md*i] for i in range(d)):
  print(n*m//d)
else:
  print(-1)


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

int n, m, a[202000], ans=2.001e9;

void fuck(int *a,int n,int &mn,int &mx,int &res){
    mn=2.001e9, mx=-1;
    for (int i=1;i<=n;++i){
        int t=a[i]+a[n*2-i+1];
        mn=min(mn,t);
        mx=max(mx,t);
        res=max(res,t%m);
    }
}

int gao(int k){
    int l1, r1, l2, r2, res=-1;
    fuck(a,k,l1,r1,res);
    fuck(a+k*2,n-k,l2,r2,res);
    ans=min(ans,res);
    //if (r1>=m) return 1;
    if (l2<m) return 0;
    return 1;
}

int main(){
    cin>>n>>m;
    for (int i=1;i<=n*2;++i) scanf("%d",&a[i]);
    sort(a+1,a+n*2+1);
    int l=0, r=n;
    while (l<=r){
        int mid=l+r>>1;
        if (gao(mid)) r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
using namespace std;

int main()
{
	int N, count[100000], an = 0;
	long long int a[100000];
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		count[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
		if (a[i] > 100000) {
			an++;
		}
		else {
			count[a[i]]++;
		}
	}
	for (int i = 0; i < 100000; i++) {
		if (count[i] != i) {
			if (count[i] > i) {
				an += count[i] - i;
			}
			else {
				an += count[i];
			}
		}
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 1280
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
n=[]
for i in range(1,N+1):
  n.append(i)
import itertools
n=list(itertools.permutations(n))
a=0
b=0
for i in n:
  if i==tuple(P):
    a+=1
    break
  else:
    a+=1
for i in n:
  if i==tuple(Q):
    b+=1
    break
  else:
    b+=1
print(abs(a-b))

Measured memory_bytes: 13836
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  itertools import permutations

def sieve(n):
    prime = []
    limit = n ** 0.5
    data = [i + 1 for i in range(1,n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e%p != 0]

def Factor(n,primes):
    factor = {}
    for p in primes:
        while n%p == 0:
            n //= p
            if p in factor:
                factor[p] += 1
            else:
                factor[p] = 1
    
    if n != 1:
        factor[n] = 1
    
    return factor

MAXN = 110000
factorial = [1]
for i in range(1, MAXN + 1):
    factorial.append(factorial[-1] * i % MOD)

inv_factorial = [-1] * (MAXN + 1)
inv_factorial[-1] = pow(factorial[-1], MOD-2, MOD)
for i in reversed(range(MAXN)):
    inv_factorial[i] = inv_factorial[i + 1] * (i + 1) % MOD

def fact(n):
    return factorial[n]

def nck(n, k):
    if k>n or k<0:
        return 0
    else:
        return factorial[n] * inv_factorial[n-k] * inv_factorial[k]

def main():
    n,m = map(int,input().split())
    primes = sieve(100000)
    factor = Factor(m,primes)

    ans = 1
    for v in factor.values():
        ans *= nck(v + n - 1,v)
        ans %= MOD
    
    print(ans)

if __name__ =='__main__':
    main()  

Measured memory_bytes: 16176
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val a = readLine.trim.split(' ').map(_.toInt)
  val g = gcd(n, m)
  println(
    (0 until n / g).map{start ⇒ (0 until m).map(diff ⇒ a((start * g + diff) % n)).let{it ⇒ it.max - it.min}}.sum
  )

  def gcd(a: Int, b: Int): Int = {
    b match {
      case 0 ⇒ a
      case _ ⇒ gcd(b, a % b)
    }
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 63344
#define N 100001
long p[N],r[N],n,m,i,b[N],a[N][2];int f(int x){if(p[x]==x)return x;return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);if(r[x]<r[y])p[x]=y;else p[y]=x;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",a[i],&a[i][1]);b[m]=n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){if(f(a[i][0])==f(a[i][1]))b[i]=b[i+1];else{b[i]=b[i+1]-r[f(a[i][0])]*r[f(a[i][1])];u(a[i][0],a[i][1]);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);return 0;}

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

#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) (1ll << (t))
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define SIZE(v) ll(v.size())
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
typedef long long ll;

ll const MAX = 100;

int main(){
    ll n;
    cin >> n;
    ll mx = MAX;
    ll t = 0;
    while(BIT(t+1) - 1 <= n){
        t++;
    }
    vll seq;
    REP(i,1,mx){   
        seq.push_back(i);
    }
    ll rem = n - (BIT(t)-1);
    REP(i,0,t-1){
        if(BIT(i)&rem){
            seq.push_back(mx);
            mx--;
            rem-=BIT(i);
        }
        seq.push_back(i+1);
    }
    cout << seq.size() << endl;
    REP(i,0,seq.size()-1){
        cout << seq[i];
        if(i < seq.size()-1){
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int n,a[100005];
map<int,int>mp;
signed main() {
	cin>>n;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	int ans=0;
	for(auto p:mp){
		ans++;
	}
	if(ans%2)cout<<ans<<endl;
	else cout<<ans-1<<endl;
}


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

using namespace std;

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

const int inf = 1LL << 55;

int W, N;
int x[50010], sum[50010];

bool dp[50010]; // dp[i+1] = xi?????§?????????sp??\?????§????????????????????????

// ?????????
bool isIn(int l, int r)
{
  return sum[r] - sum[l] + r - l - 1 <= W;
}

// ??¢??????
bool isOver(int l, int r, int sp)
{
  return sum[r] - sum[l] + (r - l - 1) * sp >= W;
}

bool check(int sp)
{
  if(isIn(0, N)) return true;
  memset(dp, false, sizeof(dp)); dp[0] = true;
  // [l,i]??§??????1??\?????§1????????§????????????????????????word?????\??????
  // [r,i]??§??????sp??\?????§1????????§?????????????°???????word?????\??????
  int l = 0, r = 0, cnt = 0; // [l,r)????????????????????????i??????  
  // ??????????????????????????????????????????????????§?°?????????£????????§?????????
  for(int i = 1; i <= N; i++) {
    while(l <= i && !isIn(l, i)) cnt -= dp[l], l++; 
    while(r <= i && isOver(r, i, sp)) cnt += dp[r], r++;
    dp[i] = cnt > 0;
    if(dp[i] && isIn(i, N)) return true;
  }
  return false;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  while(cin >> W >> N, W) {
    sum[0] = 0;
    rep(i, N) cin >> x[i], sum[i+1] = sum[i] + x[i]; // ??¨?????????????´???????
    // ?????§???????°??????????????????¶????????£??????
    int l = 0, r = W;
    while(l + 1 < r) {
      int m = (l + r) / 2;
      if(check(m)) r = m;
      else l = m;
    }
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 4008
#include <stdio.h>

int main() {
	int a, b, ans=0;

	scanf("%d %d", &a, &b);

	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}

	if (a > b) {
		ans += a;
		a--;
	}
	else {
		ans += b;
		b--;
	}

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

	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = list(input())

count_end = 0
count = 0
for s in S:
    if s == ')':
        if count > 0:
            count -= 1
        else:
            count_end += 1
    else:
        count += 1

count_begin = 0
count = 0
S.reverse()
for s in S:
    if s == '(':
        if count > 0:
            count -= 1
        else:
            count_begin += 1
    else:
        count += 1
S.reverse()
print (("("*count_end) + "".join(S) +  (")"*count_begin))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=1,f=0;
  string s;
  cin >>s;
  for(int n=0;n<19;n++){
    if(n==5||n==13) cout <<' ';
    else cout <<s[n];
  }
  cout <<'\n';
  return (0);
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int M; cin >> M;
  REP(t,M){
	string str; cin >> str;
	int sz = SZ(str);
	set<string> s;
	for(int i=1;i<sz;++i){
	  string a = str.substr(0, i);
	  string b = str.substr(i, sz-i);
	  string ra = a, rb = b;
	  reverse(ALL(ra)); reverse(ALL(rb));
	  s.insert(a+b);
	  s.insert(ra+b);
	  s.insert(a+rb);
	  s.insert(ra+rb);
	  s.insert(b+a);
	  s.insert(rb+a);
	  s.insert(b+ra);
	  s.insert(rb+ra);
	}
	cout << SZ(s) << endl;
  }
	
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,n,x;
  cin>>h>>n;
  for (int i=1;i<=n;i++){
    cin>>x;
    h-=x;
  }
  if (h<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main (){
    int a,b;
    cin>>a>>b;
    if(a<=5){
        cout<<0<<endl;
    }
    if(a>=6&&a<=12){
        cout<<b/2<<endl;
    }
    if(a>12){
        cout<<b<<endl;
    }
      return 0;
}


Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    REP(i, x) cin >> a[i];
    REP(i, y) cin >> b[i];
    REP(i, z) cin >> c[i];
    
    vector<ll> q; q.reserve(x * y);
    REP(i, x) REP(j, y) {
        q.push_back(a[i] + b[j]);
    }
    sort(ALL_OF(q), greater<ll>());
    
    vector<ll> cand; cand.reserve(k * k);
    sort(ALL_OF(c), greater<ll>());
    REP(i, min(k, z)) {
        REP(j, min(k, x * y)) {
            cand.push_back(q[j] + c[i]);
        }
    }
    sort(ALL_OF(cand), greater<ll>());
    REP(i, min((ll)cand.size(), k)) {
        cout << cand[i] << "\n";
    }
    
}

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

using namespace std;

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

    long long a[n];
    long long s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(a,a+n);

    long long s1 = a[n/2];
    long long ss=0;
    for(int i=0;i<n;i++)
    {
        ss+=abs(a[i] - s1);
    }

    cout<<ss;
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    string K;
    int D;
    cin >> K >> D;
    int N = K.size();

    vector<vector<vector<mint>>> cnt(
        N + 1, vector<vector<mint>>(2, vector<mint>(D, 0)));
    cnt[0][0][0] = 1;

    rep(i, N) rep(le, 2) rep(mo, D) {
        int a = int(K[i] - '0');
        for (int x = 0; x < (le ? 10 : a + 1); x++) {
            cnt[i + 1][le || (x < a)][(mo + x) % D] += cnt[i][le][mo];
        }
    }

    cout << (cnt[N][0][0] + cnt[N][1][0] - 1).x << endl;
    return 0;
}

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

const int M=605;
const double INF=1e20;
const double EPS=1e-8;

int n,m;
//int s[M],t[M];
vector<int> g[M];

double dp[M],dpall[M];

int s,t;
double dfs(int u)
{
	if(u==n) return 0.0;
	if(dp[u]>-0.5) return dp[u];
	int cnt=0;
	double &ans=dp[u];
	ans=0.0;
	for(int v:g[u])
	{
		if(u==s&&v==t) continue;
		cnt++;
		ans+=dfs(v);
	}
	ans=ans/(double)cnt+1.0;
	return ans;
}
double cal()
{
	for(int i=1;i<=n;i++)
		dp[i]=-1.0;
	return dfs(1);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&s,&t);
		g[s].push_back(t);
	}
	s=t=-1;
	double ans=cal();
	for(int i=1;i<=n;i++)
		dpall[i]=dp[i];
	for(int i=1;i<n;i++)
	{
		s=i;
		if(g[i].size()<=1) continue;
		int mxj;
		double mx=0;
		for(int j:g[i])
		{
			if(dpall[j]>mx)
			{
				mx=dpall[j];
				mxj=j;
			}
		}
		t=mxj;
		ans=min(ans,cal());
	}
	printf("%.15f\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <initializer_list>
#include <string>
#include <thread>
#include <unistd.h>
#include <chrono>
#include <algorithm>
#include <vector>
#include <mutex>
#include <queue>
#include <numeric>
#include <iterator>
#include <fstream>
#include <map>
using namespace std;

class Obj1 {
public:
    Obj1() {
      cout << "Obj1()" << endl;
    }
    Obj1(const Obj1&) {
      cout << "Obj1(const Obj1&)" << endl;
    }
    Obj1(Obj1&&) {
      cout << "Obj1(Obj1&&)" << endl;
    }
};


/*
template<typename Iterator,typename T>
struct accumulate_block
{
    void operator()(Iterator first,Iterator last,T& result)
    {
      result=std::accumulate(first,last,result);
    }
};

template<typename Iterator,typename T>
T parallel_accumulate(Iterator first,Iterator last,T init) {
  unsigned long const length=std::distance(first,last);
  if(!length) // 1
    return init;

  unsigned long const min_per_thread=25;
  unsigned long const max_threads=
          (length+min_per_thread-1)/min_per_thread; // 2

  unsigned long const hardware_threads=
          std::thread::hardware_concurrency();

  unsigned long const num_threads=  // 3
          std::min(hardware_threads != 0 ? hardware_threads : 2, max_threads);

  unsigned long const block_size=length/num_threads; // 4

  std::vector<T> results(num_threads);
  std::vector<std::thread> threads(num_threads-1);  // 5

  Iterator block_start=first;
  for(unsigned long i=0; i < (num_threads-1); ++i) {
    Iterator block_end=block_start;
    std::advance(block_end,block_size);  // 6
    threads[i]=std::thread(     // 7
            accumulate_block<Iterator,T>(),
            block_start,block_end,std::ref(results[i]));
    block_start=block_end;  // 8
  }
  accumulate_block<Iterator,T>()(
          block_start,last,results[num_threads-1]); // 9
  std::for_each(threads.begin(),threads.end(),
                std::mem_fn(&std::thread::join));  // 10

  return std::accumulate(results.begin(),results.end(),init); // 11
}

class Sta {
public:
      static Sta& get_instance() {
        static Sta sta;
        return sta;
      }
      Sta() {
        cout << "hello world" << endl;
      }
};

int main() {
  std::mutex()
  cout << "666" << endl;
  auto sta = Sta::get_instance();
  return 0;
}

*/

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  printf("%s\n", a[0] != a[2] && (a[0] == a[1] || a[1] == a[2]) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int N,K;
    scanf("%d %d", &N, &K);
    int s[N];
    for(int i=0;i<N;i++) scanf("%d", &s[i]);
    for(int i=0;i<N-K;i++){
        if(s[i]<s[i+K]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2432
def solve(A,L):
    N = len(A)
    for i in range(N-1):
        if A[i]+A[i+1] >= L:
            pro = i
            break
    else:
        return None

    res = list(range(i))+list(reversed(range(i+1,N-1)))+[i]
    return res


if __name__ == '__main__':
    N,L = map(int,input().split())

    A = list(map(int,input().split()))

    res = solve(A,L)
    if res is None:
        print('Impossible')
    else:
        print('Possible')
        print(*(v+1 for v in res), sep='\n')

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

int main(){

  int n, m, s[101], t[101];

  while(cin >> n >> m && n && m){
    int x, y, sum1 = 0, sum2 = 0, sum = 200;
    bool flag = true;
    for(int i=0; i<n; i++){
      cin >> s[i];
      sum1 += s[i];
    }

    for(int i=0; i<m; i++){
      cin >> t[i];
      sum2 += t[i];
    }

    int nsum = sum1, msum = sum2;
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
        sum1 = sum1 - s[i] + t[j];
        sum2 = sum2 - t[j] + s[i];
        if(sum1==sum2 && sum>s[i]+t[j]){
          sum = s[i] + t[j];
          x = s[i];
          y = t[j];
          flag = false;
        }
        sum1 = nsum, sum2 = msum;
      }
    }

    if(flag){
      cout << -1 << endl;
    } else {
      cout << x << " " << y << endl;
    }

    sum1=0, sum2=0, sum=200;
  }
  return 0;
}

Measured memory_bytes: 2984
### subroutines

def rotate_l(chs)
  chs.rotate
end

def rotate_r(chs)
  chs.rotate(-1)
end

def swap_h(chs)
  len = chs.length
  hlen = len / 2
  
  if len.even?
    chs[hlen, hlen] + chs[0, hlen]
  else
    chs[hlen + 1, hlen] + chs[hlen, 1] + chs[0, hlen]
  end
end

def reverse(chs)
  chs.reverse
end

def inc_num(chs)
  chs0 = []
  for ch in chs
    if ch >= '0' && ch <= '9'
      chs0 << ((ch.to_i + 1) % 10).to_s
    else
      chs0 << ch
    end
  end
  chs0
end

def dec_num(chs)
  chs0 = []
  for ch in chs
    if ch >= '0' && ch <= '9'
      chs0 << ((ch.to_i + 9) % 10).to_s
    else
      chs0 << ch
    end
  end
  chs0
end

### main

n = gets.to_i

n.times do
  cmds = gets.strip.split('')
  chs = gets.strip.split('')
  #p [cmds, chs]

  for cmd in cmds.reverse
    case cmd
    when 'J'
      chs = rotate_r(chs)
    when 'C'
      chs = rotate_l(chs)
    when 'E'
      chs = swap_h(chs)
    when 'A'
      chs = reverse(chs)
    when 'P'
      chs = dec_num(chs)
    when 'M'
      chs = inc_num(chs)
    end
  end

  puts chs.join('')
end

Measured memory_bytes: 6128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 1e6+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int isprime[maxn];

vector<int> primes;

void sieve()
{
	for(int i = 2; i<= 1e6; i++) isprime[i] = 1;
	for(int i = 2; i<= 1e6; i++)
	{
		if(!isprime[i]) continue;
		for(int j = i; j<= 1e6; j += i) isprime[i] = 0;
		primes.pb(i);
	}
}

int main()
{
	sieve();
	vector<bool> bist((int) primes.size(), false);

	vector<int> foo;
	int n;
	scanf("%d", &n);
	for(int i = 0; i< n; i++)
	{
		int x; scanf("%d", &x);
		foo.pb(x);
	} 
	int all = foo[0];
	for(int i = 1; i< n; i++)
	{
		all = __gcd(all, foo[i]);
	}

	bool bad = false;
	for(int i = 0; i< n; i++)
	{
		vector<int> divs;
		int bar = foo[i];
		int ptr = 0;
		while(ptr< (int) primes.size() && 1LL*primes[ptr]*primes[ptr]<= 1LL*bar)
		{
			if(bar%primes[ptr] == 0)
			{
				divs.pb(ptr);
			}
			while(bar%primes[ptr] == 0) bar /= primes[ptr];
			ptr++;
		}

		if(bar != 1)
		{
			int pos = lower_bound(primes.begin(), primes.end(), bar)-primes.begin();

			if(primes[pos] == bar) divs.pb(pos);
		}
		for(int x : divs) if(bist[x]) bad = true;

		for(int x : divs) bist[x] = true; 
	}

	if(!bad) printf("pairwise coprime\n");
	else if(all == 1) printf("setwise coprime\n");
	else printf("not coprime\n");
}

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

int main()
{
    string s1;
    cin >> s1;
    vector<ll> k(s1.size()), ans(s1.size());
    ll j = 1, n;
    k[0] = 0;
    for (ll i = 1; i < s1.size(); i++)
    {
        if (s1[i - 1] == 'L' && s1[i] == 'R')
        {
            k[j] = i;
            j++;
        }
    }
    k[j] = s1.size();
    j = 0;
    for (ll i = 1; i < s1.size(); i++)
    {
        if (s1[i - 1] == 'R' && s1[i] == 'L')
        {
            ans[i - 1]++;
            ans[i]++;
            for (n = k[j]; n < i - 1; n++)
            {
                if ((i - n) % 2 == 0)
                {
                    ans[i]++;
                }
                else
                {
                    ans[i - 1]++;
                }
            }

            for (n = i + 1; n < k[j + 1]; n++)
            {
                if ((n - i) % 2 == 0)
                {
                    ans[i]++;
                }
                else
                {
                    ans[i - 1]++;
                }
            }

            j++;
        }
    }
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back

//PBDS: policy-based data structures. 包含 associative containers 和优先队列两类。
// Associative containers are typically parameterized by various policies.
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

using order_statistic_tree = __gnu_pbds::tree<
        long long,
        __gnu_pbds::null_type,
        less_equal<long long>,
        __gnu_pbds::rb_tree_tag,
        __gnu_pbds::tree_order_statistics_node_update>;



using ll = long long;
using ull = unsigned long long;
using ul = unsigned long;


template<typename T>
void print(const T &t, const char &eol = '\n') {
    cout << t << eol;
}

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
    cout << t << ' ';
    print(rest...);
}


using PII=pair<int,int>;
const int N = 105;

int a[N], b[N], c[N], d[N];

namespace hungary {
    const int N = 105;
    bool vis[N];
    int match[N];
    int n;
    bool e[N][N];
    bool dfs(int u) {
        for (int v = 1; v <= n; v++) {
            if(!e[u][v]) continue;
            if (vis[v]) continue;
            vis[v] = true;
            if (!match[v] || dfs(match[v])) {
                match[v] = u;
                return true;
            }
        }
        return false;
    }

    int hungary(int n) {
        memset(match, 0, sizeof(match));
        int res = 0;
        for (int i = 1; i <= n; i++) {
            memset(vis, 0, sizeof(vis));
            res += dfs(i);
        }
        return res;
    }
}

int main(){
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////
    int n;
    cin >> n;
    hungary::n = n;
    for(int i=1; i<=n; i++)
        cin >> a[i] >> b[i];
    for(int i=1; i<=n; i++)
        cin >> c[i] >> d[i];

    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++){
            hungary::e[i][j] = a[i] < c[j] && b[i] < d[j];
        }
    print(hungary::hungary(n));

    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-01
**/

#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second

vector<int> link, len;

int find(int node) {
    if (node == link[node]) {
        return node;
    }
    link[node] = find(link[node]);
	return link[node];
}

bool same(int node1, int node2) {
    return find(node1) == find(node2);
}

void unite(int node1, int node2) {
    node1 = find(node1);
    node2 = find(node2);
    if (len[node1] < len[node2]) {
        swap(node1, node2);
    }
    len[node1] += len[node2];
    link[node2] = node1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<pair<int,int>> x(n), y(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        x[i] = {a, i};
        y[i] = {b, i};
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    
    vector<pair<int, pair<int,int>>> edges(2 * (n - 1));
    for (int i = 0; i < n - 1; i++) {
        edges[i] = {x[i+1].f - x[i].f, {x[i].s, x[i+1].s}};
    }
    for (int i = 0; i < n - 1; i++) {
        edges[i + n - 1] = {y[i+1].f - y[i].f, {y[i].s, y[i+1].s}};
    }
    sort(edges.begin(), edges.end());
    
    long long ans = 0, cnt = 0;
    link.resize(n);
    len.resize(n);
    for (int i = 0; i < n; i++) {
        link[i] = i;
    }
    for (int i = 0; i < edges.size(); i++) {
        if (cnt >= n - 1) break;
        if (!same(edges[i].s.f, edges[i].s.s)) {
            unite(edges[i].s.f, edges[i].s.s);
            ans += edges[i].f;
            cnt++;
        }
    }
    
    cout << ans << '\n';
    
    return 0;
}

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

main(){
  int N, x=0, m, n=0;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> m;
    if(i==0){
      for(; m%2==0; m/=2){
        n++;
      }
      x=n;
      n=0;
      continue;
    }
    for(; m%2==0; m/=2){
      n++;
    }
    if(x>n)
      x=n;
    n=0;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, M; cin >> N >> M;
    vector<set<int>> G(N);
    int A, B;
    rep(i, M) {
        cin >> A >> B;
        A--; B--;
        G[A].insert(B); G[B].insert(A);
    }
    vector<int> g(N, -1);
    int cnt = 0;
    rep(i, N) {
        if (g[i] >= 0) continue;
        queue<int> q;
        q.push(i);
        g[i] = cnt;
        while(!q.empty()) {
            int tmp = q.front();
            q.pop();
            vector<int> Gtmp(ALL(G[tmp]));
            rep(j, Gtmp.size()) {
                if (g[Gtmp[j]] >= 0) continue;
                g[Gtmp[j]] = cnt;
                q.push(Gtmp[j]);
            }
        }
        cnt++;
    }
    int ans = 0;
    cnt = 1;
    sort(ALL(g));
    rep(i, N-1) {
        if (g[i] == g[i+1]) cnt++;
        else {
            chmax(ans, cnt);
            cnt = 1;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 32332
ss = [input() for _ in range(3)]

i = 0
while ss[i % 3] != "":
    card = ss[i % 3][0]
    ss[i % 3] = ss[i % 3][1:]
    if card == "a":
        i = 0
    elif card == "b":
        i = 1
    else:
        i = 2

if i == 0:
    print("A")
elif i == 1:
    print("B")
else:
    print("C")


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
 
long a[1000005],b[1000005],c[1000005];
 
int main()
{
	int i,n,k;
	while(~scanf("%d",&n)){
		long t = 0,sum = 0,qs = 0;
		for(i = 1; i <= n; i++) {
			scanf("%ld",&a[i]);
			sum += a[i];
		}
		for(i = n; i > 1; i--){
			sum -= a[i];
			qs += a[i];
			b[++t] = abs(sum-qs);
		}
		sort(b+1,b+1+t);
		printf("%ld\n",b[1]);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

int main(){

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

    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        a[i] -=(i+1);
        sum += a[i];
    }

    sort(ALL(a));

    ll min = (1LL << 60);

    ll left = 0;

    REP(i,n){
        chmin(min,(ll)(i+1)*(a[i])-(left+a[i]) + (sum-left-a[i]) + (ll)(-a[i])*(n-i-1));
        left += a[i];
    }

    cout << min <<endl;

    return 0;
}


Measured memory_bytes: 3996