akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  int n, m;
  cin >> n >> m;
  if(m > n) swap(n,m);


  vector<mint> f(100005);
  f[0] = 1;
  f[1] = 1;
  f[2] = 2;
  REP2(i,2,n+1){
    f[i] = (mint)i*f[i-1];
    f[i] = f[i];
  }

  mint ans = 0;

  if(n == m){
    ans = f[n] * f[n]*2; 
  }
  else if (n == m+1){
    ans = f[n] * f[n-1];
  }
  else {
    ans = 0;
  }

  cout << ans << endl;
  //m = n: m! * n! *2
  //m != n m! * n!;

  return 0;
}

Measured memory_bytes: 4052
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  ll h1, m1, h2, m2;
  cin >> h1 >> m1 >> h2 >> m2;
  ll a = h1 * 60 + m1;
  ll b = h2 * 60 + m2;
  ll t = b - a;
  ll k;
  cin >> k;
  cout << t - k << "\n";
}

int main()
{
  init_main();

  solve();

  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
LL Sun[2000000];
int main(){
    CIN(N);LL K;cin >> K;
    REP(a,N){
        CIN(A);CIN(B);
        Sun[A]+=B;
    }
    for(int a = 0;a < 1000000;a++){
        if(Sun[a]>=K){
            COUT(a);
            break;
        }
        K-=Sun[a];
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

#define MAX 1000
#define VMAX 10000

int n , A[MAX] , s;
int B[MAX] , T[VMAX+1];

void bubblesort( int a[]  ){
	
	int temp , flag = 1;
	int j;
	
	while( flag == 1 ){
		
		flag = 0;
		
		for( j = n - 1; j >= 1; j-- ){
			
			if( a[j] < a[ j - 1 ] ){
				temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				flag = 1;
			}
		}
	}
	
}

int min( int a , int b ){
	
	if( a < b ){ return a; }
	else{ return b; }
	
}

int solve(){
	
	int ans = 0;
	
	int V[MAX];
	
	for( int i = 0; i < n; i++ ){
		B[i] = A[i];
		V[i] = 0;
	}
	
	bubblesort( B );
	
	for( int i = 0; i < n; i++ ) T[B[i]] = i;
	for( int i = 0; i < n; i++ ){
		if( V[i] ) continue;
		
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		
		while(1){
			V[cur] = 1;
			an++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
			if( V[cur] ){ break; }
		}
		ans += min( S+(an-2) * m , m + S + (an + 1 ) * s );
		
	}
	
	return ans;
	
}

int main( void ){
	
	int ans;
	
	scanf( "%d" , &n );
	
	s = VMAX;
	
	for( int i = 0; i < n; i++ ){
		scanf( "%d" , &A[i] );
		s = min(s,A[i]);
	}
	
	ans = solve();
	
	printf( "%d\n" , ans );
	
	return 0;
}


Measured memory_bytes: 2108
n=int(input())
l=list(map(int,input().split()))
print(" ".join(list(map(str,l))))
for i in range(1,n):
    x=l[i]
    for j in range(0,i)[::-1]:
        if(l[j] <= x):
            j+=1
            break
    del l[i]
    l.insert(j,x)
    print(" ".join(list(map(str,l))))


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int N,K; cin >>N >>K;
	vector <int> P(N);
	for (int i=0;i<N;i++) {
		cin >>P[i];
		P[i]--;
	}
	vector <int> C(N);
	for (int i=0;i<N;i++) {
		cin >>C[i];
	}
	if (K<=N) {
		ll ans=-INF;
		for (int i=0;i<N;i++) {
			ll p=i,s=0;
			for (int j=0;j<K;j++) {
				p=P[p];
				s+=C[p];
				ans=max(ans,s);
			}
		}
		cout <<ans;
	}
	else {
		vector<vector<int> > next(31,vector<int>(N));
		for (int i=0;i<N;i++) {
			next[0][i]=P[i];
		}
		for (int i=1;i<31;i++) {
			for (int j=0;j<N;j++) {
				next[i][j]=next[i-1][next[i-1][j]];
			}
		}
		vector<vector<long long> > sum(31,vector<long long>(N));
		for (int i=0;i<N;i++) {
			sum[0][i]=C[P[i]];
		}
		for (int i=1;i<31;i++) {
			for (int j=0;j<N;j++) {
				sum[i][j]=sum[i-1][j]+sum[i-1][next[i-1][j]];
			}
		}
		long long ans=0;
		for (int i=0;i<N;i++) {
			long long p=i;
			long long s=0;
			for (int j=0;j<N;j++) {
				p=P[p];
				s+=C[p];
				ans=max(ans,s);
			}
			p=i;
			s=0;
			for (int j=0;j<31;j++) {
				if ((K-N>>j)&1) {
					s+=sum[j][p];
					p=next[j][p];
				}
			}
			ans=max(ans,s);
			for (int j=0;j<N;j++) {
				p=P[p];
				s+=C[p];
				ans=max(ans,s);
			}
		}
		cout <<ans;
	}
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 5068
/*
AizuOnline A0022
Delivery Fee
*/
#include <stdio.h>
#define SIZ 6
struct {int xyz;int wt;int fee;} fee_table[SIZ]=
  {{60,2,600},{80,5,800},{100,10,1000},{120,15,1200},
   {140,20,1400},{160,25,1600}};

main()
{
  long int n;
  int x,y,z,w;
  int i,j;
  long int total_fee;

  while(scanf("%ld",&n),n)
    {
      total_fee=0;
      for(i=0;i<n;i++)
	{
	  scanf(" %d %d %d %d",&x,&y,&z,&w);
#ifdef DEBUG
	  printf("xyz=%d w=%d\n",x+y+z,w);

#endif
	  for(j=0;j<SIZ;j++)
	    if((fee_table[j].xyz >= x+y+z) && (fee_table[j].wt >=w) )
	      {
		total_fee += fee_table[j].fee;
		break;
	      }
	}
      printf("%ld\n",total_fee);
    }
return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int sum = 0;
    if(a+1+b<c){
        sum += a + 1 + b;
    }
    if(a+1+b>=c){
        sum += c;
    }
    cout << sum + b << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = mutableListOf<Pair<Int, Int>>()
    for (i in 1..n)
        for (j in (i + 1)..n)
            list.add(Pair(i, j))
    for (i in 1..(n / 2)) list.remove(Pair(i, n - i + (n + 1) % 2))
    println(list.size)
    list.forEach { println("${it.first} ${it.second}") }
}


Measured memory_bytes: 32060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    string a,b,c;

    cin >> a >> b >> c;

    cout << a[0] << b[0] << c[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
str = input()
a = str[-1:]
if a == "3":
	result = "bon"
elif (a == "0") or (a == "1") or (a == "6") or (a == "8"):
  	result = "pon"
elif (a == "2") or (a == "4") or (a == "5") or (a == "7") or (a == "9"):
  	result = "hon"
else:
  	result = "ng"
    
print(result)

Measured memory_bytes: 9044
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int p[5005],c[5005],n,k,num[5005],used[5005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	FOR(i,1,n)cin>>p[i];
	FOR(i,1,n)cin>>c[i];
	int maxi=-1e9;
	FOR(i,1,n){
		int t=i;
		do{
			num[i]+=c[p[t]];
			t=p[t];used[i]++;
		}while(t!=i);
	}
	FOR(i,1,n){
		int t=k%used[i];
		int ti=k/used[i];
		int ans=0;
		if(num[i]<=0){
			t=min(k,used[i]);
			int now=i,mm=-1e9;
			FOR(j,1,t){
				ans+=c[p[now]];gmax(mm,ans);
				now=p[now];
			}
			gmax(maxi,mm);
		}else {
			if(ti>0){
				int mm=-1e9;
				ans=(ti-1)*num[i];
				int now=i;
				FOR(j,1,used[i]){
					ans+=c[p[now]];gmax(mm,ans);
					now=p[now];
				}
				gmax(maxi,mm);
			}
			int mm=-1e9;
			ans=ti*num[i];
			int now=i;
			FOR(j,1,t){
				ans+=c[p[now]];gmax(mm,ans);
				now=p[now];
			}
			gmax(maxi,mm);
		}
	}
	cout<<maxi;
	RE 0;
}


Measured memory_bytes: 3840
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static InputReader in = new InputReader(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	
	
	
	
	
	
	
	
	int n, a, b;
	long[] v = new long[100];
	HashMap<Long, Integer> m  = new HashMap<>();
	
	BigInteger fac(int x){
		BigInteger c = new BigInteger("1");
		for(int i=1; i<=x; i++) {
			c = c.multiply(new BigInteger(""+i));
		}
		return c;
	}
	BigInteger ncr(int n, int k){
		if( k > n) return new BigInteger("0");
		return fac(n).divide(fac(k)).divide(fac(n-k));
	}

	void solve(){
		n = in.nextInt();
		a = in.nextInt();
		b = in.nextInt();
		for(int i=1; i<=n; i++){ v[i] = in.nextLong();
			m.put(v[i], m.getOrDefault(v[i], 0) + 1);
		}
		
		Arrays.sort(v, 1, n+1);
		long maxsum = 0;
	
	for(int j=1, i = n; j <= a; j++,i--){
		maxsum += v[i];
	}
	if(a == n){
		out.printf("%.10f\n%d\n", (double)maxsum/(double)n, 1);
	}
	else{
		
		double ans = (double)maxsum/a;
		BigInteger ways = null;
		if(v[n-a] < v[n-a+1]) ways = new BigInteger("1");
		else{
			int k = n-a+1;
			while(k+1 <= n && v[k+1] == v[k]) k++;
			int occ = k - (n-a+1) + 1;
			if(occ < a){
			// compute X choose occ
			ways = ncr(m.get(v[n-a+1]), occ);
			}
			else{
				BigInteger sum = new BigInteger("0");
				for(int x =a; x <= b; x++){
					sum = sum.add(
					ncr(
					m.get(v[n-a+1]), x));
				}
				ways = sum;
			}
		}
		out.printf("%.10f\n%s\n", ans, ways);
	}
		
	}
	
	
		
	
	
	
	
	
	
	
	
	public static void main(String[] args){
		Main m = new Main();
		m.solve();
		out.flush();
		out.close();
	}
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream instream){
			reader = new BufferedReader(new InputStreamReader(instream), 1<<15);
			tokenizer = null;
		}
		public String next(){
			while(tokenizer == null || !tokenizer.hasMoreTokens()){
				try{
					tokenizer = new StringTokenizer(reader.readLine());
				}catch(Exception e){
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();	
		}
		public String nextLine(){
			try{
			return reader.readLine();
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}


	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
	cin >> n;
	vector<int> w(n);
	for(int i=0;i<n;i++){
		cin >> w[i];
	}

	int ans;
	for(int i=1;i<n;i++){
		int s1=0,s2=0;
		for(int j=0;j<i;j++){
			s1+=w[j];
		}
		for(int j=i;j<n;j++){
			s2+=w[j];
		}
		if(ans>abs(s1-s2) || i==1) ans=abs(s1-s2);
	}

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


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

class Dice
{
private:
  int d[6];
public:
  Dice();
  void CreateDice(int n1, int n2, int n3, int n4, int n5, int n6);
  void disp();
  void Roll_The_Dice(int top, int front);
};

Dice::Dice(){
  for(int i = 0; i < 6; i++){
    d[i] = 0;
  }
}

void Dice::CreateDice(int n1, int n2, int n3, int n4, int n5, int n6){
  d[0] = n1;
  d[1] = n2;
  d[2] = n3;
  d[3] = n4;
  d[4] = n5;
  d[5] = n6;
}

void Dice::disp(){
  cout << d[2] << endl;
}

void Dice::Roll_The_Dice(int top, int front){
  int tmp;
  int i = 0;
  while(true){
    for(i = 0; i < 4; i++){
      if(d[0] == top){
        break;
      }
      tmp  = d[0];
      d[0] = d[4];
      d[4] = d[5];
      d[5] = d[1];
      d[1] = tmp;
    }
    if(d[1] == front && d[0] == top){
      break;
    }
    tmp  = d[3];
    d[3] = d[1];
    d[1] = d[2];
    d[2] = d[4];
    d[4] = tmp;
    i = 0;
  }
}

int main(){
  int n[6] ,num;
  int top,front;
  string order;
  for(int i = 0; i < 6; i++){
    cin >> n[i];
  }
  Dice dice1;
  dice1.CreateDice(n[0],n[1],n[2],n[3],n[4],n[5]);
  cin >> num;
  for(int j = 0; j < num; j++){
    cin >> top >> front;
    dice1.Roll_The_Dice(top,front);
    dice1.disp();
  }
}



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

bool isPrime(ll num)
{
	if (num < 2) return false;
	for (ll i = 2; i*i <= num; ++i)
	{
		if (num % i == 0)
			return false;
	}
	return true;
}

int main(int argc, char **argv)
{
	int x; cin >> x;
	while (!isPrime(x)){++x;}
	std::cout << x << std::endl;
}



Measured memory_bytes: 256
def check(arr, x):
    pos = set([0])
    for dx in arr:
        npos = set()
        for p in pos:
            npos.add(p+dx)
            npos.add(p-dx)
        pos = npos
    return x in pos


s = input().split('T')
x, y = map(int, input().split())
d = [len(ss) for ss in s]
dx = d[2::2]
dy = d[1::2]
x -= d[0]
if check(dx, x) and check(dy, y):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3700
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	dm := make(map[int]bool)
	var d int
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		dm[d] = true
	}
	gs := make([]int, 0)
	for i := 0; i <= 9; i++ {
		if !dm[i] {
			gs = append(gs, i)
		}
	}

	u := 0
	nums := make([]int, 0)
	s := strconv.Itoa(n)
	for i := len(s) - 1; i >= 0; i-- {
		ok := false
		c := int(s[i]-'0') + u
		uu := 0
		if c >= 10 {
			c = 0
			uu = 1
		}
		for _, d := range gs {
			if c <= d {
				nums = append(nums, d)
				ok = true
				u = 0 + uu
				if c < d {
					nums = update(nums, gs)
				}

				break
			}
		}
		if !ok {
			nums = append(nums, gs[0])
			u = 1
			nums = update(nums, gs)
		}
	}

	if u > 0 {
		for _, g := range gs {
			if g > 0 {
				nums = append(nums, g)
				break
			}
		}
		nums = update(nums, gs)
	}

	for i := len(nums) - 1; i >= 0; i-- {
		fmt.Print(nums[i])
	}
	fmt.Println()
}

func update(nums, gs []int) []int {
	for j := 0; j < len(nums)-1; j++ {
		nums[j] = gs[0]
	}
	return nums
}


Measured memory_bytes: 512
s=input()
ans=0
li=[0 for i in range(len(s))]
for index,i in enumerate(s):
    if i in ["A","C","G","T"]:
        li[index]=1
tmp=0
for i in li:
    if i==1:
        tmp+=1
        ans=max(ans,tmp)
    else:
        tmp=0
print(ans)

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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n, k; cin >> n >> k;
	if (n % k == 0) cout << 0;
	else cout << min(n % k, abs((n % k) - k));
}


Measured memory_bytes: 256
// Palace
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100010

int main() {
    int n, t, a, mi, mi_idx;
    cin >> n >> t >> a;
    for (int i = 0; i < n; ++i) {
        int x, diff, temp;
        cin >> x;
        temp = 1000 * t - 6 * x;
        diff = abs(a * 1000 - temp);
        if (i == 0) {
            mi = diff;
            mi_idx=1;
        }
        if (mi > diff) {
            mi = diff;
            mi_idx = i + 1;
        }
    }
    cout << mi_idx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k[1005];
cin>>n;
for(int i=0;i<n;++i){cin>>k[i];}
for(int i=0;i<n;++i){
  for(int j=i+1;j<n;++j){
  if(abs(k[i]-k[j])%(n-1)==0){
   cout<<k[i]<<" "<<k[j]<<endl;
return 0;
}
}
}
}


Measured memory_bytes: 3124
from collections import deque
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
moves = ((1, 0), (-1, 0), (0, 1), (0, -1))
cnt = [[float('inf') for _ in range(w)] for _ in range(h)]
ans = 0
searched = [[0 for _ in range(w)] for _ in range(h)]
q = deque([])

def bfs():
  while q:
    y, x = q.popleft()
    for dy, dx in moves:
      next_y = y + dy
      next_x = x + dx 
      if 0 <= next_y < h and 0 <= next_x < w and searched[next_y][next_x] == 0 and a[next_y][next_x] == '.' and cnt[next_y][next_x] > cnt[y][x]+1:
        searched[next_y][next_x] = 1
        q.append([next_y, next_x])
        cnt[next_y][next_x] = cnt[y][x]+1

for i in range(h):
  for j in range(w):
    if a[i][j] == '#':
      cnt[i][j] = 0
      searched[i][j] = 1
      q.append([i, j])

bfs()
for i in range(h):
  for j in range(w):
    ans = max(ans, cnt[i][j])

print(ans)

Measured memory_bytes: 171656
n = int(input())
mojiretues = []
for _ in range(n):
	s = list(input())
	s.sort()
	mojiretues.append("".join(s))
mojiretues.sort()

prestr = mojiretues[0]
cnt = 1
ans = 0
for s in mojiretues[1:]:
	if prestr == s:
		ans += cnt
		cnt += 1
	else:
		prestr = s
		cnt = 1

print(ans)


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

/* MIGHT BE OF USE


#define si(x)	scanf("%d",&x)
#define pi(x)	printf("%d\n",x)

typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
*/


#define fo(i,a,b) for(i=a;i<b;i++)
#define ll long long
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define sl(x)	scanf("%lld",&x)
#define pl(x)	printf("%lld\n",x)
#define ss(s)	cin>>s
#define ps(s)	cout<<s
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back

typedef pair<ll, ll>	pl;
typedef vector<ll>		vl;
typedef vector<pl>		vpl;
typedef vector<string>	vs;

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





void solve()
{
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ll i, j, n, m;
    sl(n);
    while(n--)
    cout<<"ACL";

}



int main()
{

    ll t = 1;
    //sl(t);
    while(t--)
    {
        solve();
    }

    return 0;
}






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

int main() {
	int a, b;

	while (cin >> a >> b) {
		int sum, i;
		sum = a + b;
		for (i = 0; sum > 9;i++){
			sum /= 10;
		}
		cout << i+1 << endl;
	}

	return  0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define forsn(i,s,n) for(int i=(s); i<(int)(n); i++)
#define forn(i,n) forsn(i,0,n)

typedef long long int tint;

tint suma(vector<int> &v){
  tint res = 0;
  for(auto e : v){
    res += e;
  }
  return res;
}

int main(){
  int N; cin >> N;
  vector<int> v(N);
  forn(i,N){
    cin >> v[i];
  }
  tint cantOper = 0;
  forn(i,N){
    int x;
    cin >> x;
    v[i] -= x;
    if(v[i] < 0){
      cantOper += v[i]/2;
    } else {
      cantOper += v[i];
    }
  }
  cout << (cantOper > 0 ? "No\n" : "Yes\n");
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String x = sc.next();

		if (x.equals("SSS")) {
			System.out.println(0);
			return;
		}

		if (x.equals("RSS")) {
			System.out.println(1);
			return;
		}

		if (x.equals("SRS")) {
			System.out.println(1);
			return;
		}

		if (x.equals("SSR")) {
			System.out.println(1);
			return;
		}

		if (x.equals("RRS")) {
			System.out.println(2);
			return;
		}

		if (x.equals("SRR")) {
			System.out.println(2);
			return;
		}

		if (x.equals("RSR")) {
			System.out.println(1);
			return;
		}

		if (x.equals("RRR")) {
			System.out.println(3);
			return;
		}

	}
}

Measured memory_bytes: 35596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
    cin >> s;
    int l, r;
    l = s/100;
    r = s%100;
    if( 1<=l && l<=12 ){
        if( 1<=r && r<=12 ){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if( 1<=r && r<=12 ){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn=200000;
ll w[maxn][3];
ll f[maxn]; //f[i]表示 使用重量为 i的最大价值 
int main()
{
	int N,W;
	cin>>N>>W;
	for (int i=1;i<=N;i++)
		for (int j=1;j<=2;j++)
			scanf("%d",&w[i][j]);
	for (int i=1;i<=N;i++)
		for (int j=W;j-w[i][1]>=0;j--)
		f[j]=max(f[j],f[j-w[i][1]]+w[i][2]);
	cout<<f[W];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int x;

void solve()
{
    cin >> x;
    nout(x==1?0:1);
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
INF = 999999999
n, k = gets.strip.split.map(&:to_i)
hs = n.times.map { gets.strip.to_i }.sort

ref = k - 1
last_pos = n - 1
result = INF
n.times do |i|
  j = i + ref
  result = [hs[j] - hs[i], result].min
  break if j >= last_pos
end 

puts result

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

int main(){
  int K,S;
  cin >>K >>S;
  int a=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j>=0&&S-i-j<=K)
        a++;
    }
  }
  cout <<a <<endl;
}

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

int main()
{
	std::string S = "";
	std::cin >> S;

	int N = S.size();

	std::string S1 = "";
	for (int i = 0, n = (N - 1) / 2; i < n; ++i)
	{
		S1 += S.at(i);
	}

	std::string S2 = "";
	for (int i = (N + 3) / 2 - 1; i < N; ++i)
	{
		S2 += S.at(i);
	}

	if (S1 == S2)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}

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

long long dp[100001][13];

void rep(int x, int u, long long mul){
  if ( u == 1){
    dp[1][x] = 1;
    return;
  }
  for (int j = 0; j < 13; j++ ){
    dp[u][(x*mul+j)%13] += dp[u-1][j];
    dp[u][(x*mul+j)%13] %= M;
  }
}

int main(){
  string s;
  cin >> s;
  int c, n = s.length();

  for ( int i = 0; i<=100001; i++){
    for ( int j = 0; j < 13; j++){
      dp[i][j] = 0;
    }
  }

  long long mul = 1;
  for ( int i = n-1; i >= 0; i--){
    if ( s[i] == '?') c = -1;
    else c = s[i] - '0';

    for ( int j = 0; j <= 9; j++){
      if ( c != -1 && c != j )continue;
      rep(j, n-i, mul);
    }
    mul *= 10;
    mul %= 13;
  }

  cout << dp[s.length()][5] << endl;

  return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;

    int res = 0;
    for (int i = 1; i < static_cast<int>(s.size()); i++) {
        if (s[i - 1] != s[i]) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = n * (n - 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
 
count = 0
 
for i in range(n):
    if a[i] != b[i] and b[i] == c[i]:
        count += 1
    elif a[i] != b[i] and a[i] != c[i]:
        count += 2
    elif a[i] != b[i] or a[i] != c[i]:
        count += 1
        
print(count)

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

int main(){
  int n;
  cin >> n;
  int hig=0, ans=0;
  for(int i=0; i<n; ++i){
    int x;
    cin >> x;
    if(x>hig) ans += x-hig;
    hig = x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] l = new int[n];
    int sum = 0;

    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }

    Arrays.sort(l);

    for (int i = n-1; i > n-1-k; i--) {
      sum += l[i];
    }

    System.out.println(sum);

  }

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int W, H, x, y;

int main(void) {

	cin >> W >> H >> x >> y;

	cout << setprecision(12) << fixed << (W*H)*0.5L<<" ";

	if (x * 2 == W && y * 2 == H) { cout << 1 << endl; }
	else { cout << 0 << endl; }

	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int,input().split()))
    i = 0
    j = 1
    money = 1000
    num_of_stock = 0

    while (i<N-1):
        #print(i)
        if A[i] < A[i+1]:
            num_of_stock += money // A[i]
            money = money % A[i]
        elif A[i] > A[i+1]:
            money += A[i]*num_of_stock
            num_of_stock = 0
        else:
            i += 1
            continue
        i += 1

    money += A[N-1]*num_of_stock

    return money

print(main())


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

std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
int main(void) {
    int N;
    int cnt =0;    
    cin >> N;    

    // 多分55555までは求める必要無いはず
    vector<int> prime = Eratosthenes(2000);
//sort(prime.begin(), prime.end());
//for(int i=0;i<55;i++) {
//    cout << prime[i] << endl;
//}

    // 前からmodを取っていってうまく合うものだけ出す？？
    
    // 試しに素数だけ出すと？-> NG
    for(int i=0;i<prime.size();i++) {
        if(prime[i] % 5 == 1) {
            cout << prime[i] << " ";
            cnt++;
            if(cnt == N) break;
        }
    }
    cout << endl;
//printf("cnt:%d\n",cnt);

    return 0;
}


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

typedef long long ll;

ll N,K;
vector<ll> b1(42,0);
vector<ll> b0(42,0);
vector<bool> Kb(42,0);

ll countfree(int n){
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=max(b1[i],b0[i]);
	}
	return ans;
}

int main(){
	cin>>N>>K;
	for(ll i=0;i<N;i++){
		ll A;
		cin>>A;
		for(int i=0;i<42;i++){
			int m=A&1;
			if(m==0){
				b1[i]+=(ll)1<<i;
			}else{
				b0[i]+=(ll)1<<i;
			}
			A=A>>1;
		}
	}
	for(ll i=0;i<42;i++){
		Kb[i]=K&1;
		K=K>>1;
	}
	int i=0;
	ll ans=0;
	while(1){
		i=0;
		ll t;
		while(Kb[i]!=0){
			Kb[i]=0;
			i++;
		}
		t=countfree(i);
		while(i<42){
			if(Kb[i]==0){
				t+=b0[i];
			}else{
				t+=b1[i];
			}
			i++;
		}
		ans=max(ans,t);
		i=0;
		while(Kb[i]!=1&&i<42){
			Kb[i]=1;
			i++;
		}
		if(i>=41)break;
		Kb[i]=0;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    vector<int> ans(0);
    for (int i=1; i<=min(a,b); i++){
        if (a%i==0 && b%i==0){
            ans.push_back(i);
        }
    }
	cout << ans[ans.size()-k] << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a >= -1000 && a <= 1000 && b >= -1000 && b <= 1000){
        if (a < b) 
            cout << "a < b" << endl;
        else if (a > b)
            cout << "a > b" << endl;
        else
            cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3080
S = input()
listA = []
listB = []
ans1 = 0
ans2 = 0

for i in range(len(S)//2):
    listA.append(1)
    listA.append(0)
    listB.append(0)
    listB.append(1)

if len(S)%2 != 0:
    listA.append(1)
    listB.append(0)


for i in range(len(S)):
    if int(S[i]) != listA[i]:
        ans1 += 1
    if int(S[i]) != listB[i]:
        ans2 += 1

print(min(ans1,ans2))

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a;
  cin>>a;
  int b=a%1000;
  if(b==0){
    cout<<0;
  }
  else{
    cout<<1000-b;
  }
}   


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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    string s;
    string t;
    cin >> s >> t;

    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
int main() {
	long K;
	cin >> K;
	vector<vector<long>> countl(1000);
	vector<long> sum = {0,1,2,3,4,5,6,7,8,9};
	countl[1] = { 1,1,1,1,1,1,1,1,1,1 };
	long countall = 9,digit;
	for (int i = 2;; i++)
	{
		if (countall >= K) {
			digit = i-1;
			break;
		}
		countl[i] = vector<long>(10);
		countl[i][0] = countl[i - 1][0] + countl[i - 1][1];
		//countall += countl[i][0];
		sum[0] = 0;

		for (int k = 1; k < 9; k++)
		{
			countl[i][k] = countl[i - 1][k - 1] + countl[i - 1][k] + countl[i - 1][k + 1];
			countall += countl[i][k];
			sum[k] = countall;
		}
		countl[i][9] = countl[i - 1][8] + countl[i - 1][9];
		countall += countl[i][9];
		sum[9] = countall;
		if (countall >= K) {
			digit = i;
			break;
		}
	}
	int top=9, bottom=0;
	string ans = "";
	for (int i = digit; i >= 1; i--)
	{
		vector<long> ss(10);
		int sss = 0;
		for (int k = bottom; k <=top; k++)
		{

			if (!(i == digit ))
				sss += countl[i][k];
			else
				sss = sum[k];
			ss[k] = sss;
			//long s = (i==digit)?sum[k]:ss[k];
			if (K<=ss[k])
			{
				top = min(9, k+1);
				bottom = max(0, k-1);
				//countall = countl[digit][k];
				if (i == 1) {
					ans += k  + '0';
				}
				else {
					ans += k + '0' ;
				}
				K = K - (sss-countl[i][k]);
				break;
			}
		}
	}
	
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n,k;
	cin>>n>>k;
	vector<int>h(n);
	for(int i=0;i<n;i++)
	cin>>h[i];
	ll dp[n];
	for(int i=0;i<n;i++)
	dp[i] = INT_MAX;
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
		for(int j=1;j<=min(i,k);j++){
			dp[i] = min(dp[i],(dp[i-j]+abs(h[i-j]-h[i])));
		}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int a, b;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >>a >> b;
    if (b % a == 0) cout << a+b;
    else cout << b-a;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

    vector<ll> H(N, 0);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
        if(i == 0) continue;
        if(H[i] > H[i-1]) H[i] -= 1;
        if(H[i] < H[i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    


}

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

int f(int a) {
  if (a == 0) return 0;
  return f(a % __builtin_popcount(a)) + 1;
}

int main() {
  int n;
  string x_;
  cin >> n >> x_;
  vector<int> x(n);
  int pc_ = 0;
  rep(i, n) {
    x[i] = x_[i] - '0';
    pc_ += x[i];
  }
  vector<int> ans(n);
  rep(j, 2) {
    int pc = pc_ + (j == 0 ? 1 : -1);
    if (pc == 0) continue;
    int xmod = 0;
    rep(i, n) xmod = (xmod * 2 + x[i]) % pc;
    int powmod = 1;
    for (int i = n - 1; i >= 0; i--) {
      if (x[i] == j) {
        ans[i] = f((xmod + (j == 0 ? powmod : -powmod) + pc) % pc) + 1;
      }
      powmod = (powmod * 2) % pc;
    }
  }
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<int> a(n), ind(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i]; a[i]--; ind[a[i]] = i;
    }

    int cnt = 1;
    for(int i = 1; i < n; i++) {
        int j = i;
        while(j < n && ind[j] > ind[j - 1]){
            j++;
        }
        cnt = max(j - i + 1, cnt);
        i = j;
    }
    cout << n - cnt << endl;
}

Measured memory_bytes: 1792
//2:14 start
//2:37 writing done
//2:44 passed test case


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//#define DEBUG
#define MAX_LEN 32
#define MAX_N_WORDS 1000

void word_lower(char* word)
{
    int i,len;
    len=strlen(word);
    for(i=0;i<len;i++){
        word[i]=tolower(word[i]);
    }
}

typedef struct{
    char word[MAX_LEN+1];
    int len;
    int cnt;
}word_t,*p_word_t;

word_t words[MAX_N_WORDS];
int n_words=0;

void add(char* w)
{
    int i;
    for(i=0;i<n_words;i++){
        if(strcmp(w,words[i].word)==0){
            words[i].cnt++;
            return;
        }
    }


    strcpy(words[n_words].word,w);
#ifdef DEBUG
    printf("adding...%s\n",words[n_words].word);
#endif
    words[n_words].len=strlen(w);
    words[n_words].cnt=1;
    n_words++;
}

int main(void)
{
    FILE* fp;
#ifdef DEBUG
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif

    int c;
    n_words=0;
    while(feof(fp)==0 && c!='\n'){
        char w[MAX_LEN+1];
        fscanf(fp,"%s ",w); 
        word_lower(w);
        add(w);
    }

    //get word that appears most
    int i;
    int max_cnt=0; char *max_cnt_word=NULL;
    int max_len=0; char *max_len_word=NULL;
    for(i=0;i<n_words;i++){
        if(max_cnt<words[i].cnt){
            max_cnt=words[i].cnt;
            max_cnt_word=words[i].word;
        }
        if(max_len<words[i].len){
            max_len=words[i].len;
            max_len_word=words[i].word;
        }
    }
#ifdef DEBUG
    printf("result...%d %d\n",max_cnt,max_len);
#endif
    printf("%s %s\n",max_cnt_word,max_len_word);

    return 0;
}

Measured memory_bytes: 0
my @ABC = glob<>;
my $result = (($ABC[0] eq $ABC[1] && $ABC[1] eq $ABC[2] && $ABC[0] eq $ABC[2])|| ($ABC[0] ne $ABC[1] && $ABC[1] ne $ABC[2] && $ABC[0] ne $ABC[2])) ? "No" : "Yes";
print $result;


Measured memory_bytes: 768
#include <iostream>
#include <vector>

int main(){
    using namespace std;
    int n,m;
    cin >> n >> m;
    int ans[n+1];
    for(int i=0; i < n+1; i++){
        ans[i] = 1;
    }
    for(int i=0; i < m; i++){
        int t;
        cin >> t;
        ans[t] = 0;
    }
    for(int i=2; i < n+1; i++){
        if(ans[i] != 0){
            ans[i] = (ans[i-2] + ans[i-1]) % 1000000007;
        }
    }
    cout << ans[n] << endl;
    return 0;
}


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

s = input()
q = int(input())
flag = True
p = ''
m = ''
for i in range(q):
    qfc = input()
    if qfc[0] == '1':
        if flag:
            flag = False
        else:
            flag = True
    else:
        if qfc[2] == '1':
            if flag:
                p += qfc[4]
            else:
                m += qfc[4]
        else:
            if flag:
                m += qfc[4]
            else:
                p += qfc[4]
if flag:
    print(p[::-1] + s + m)
else:
    print(m[::-1] + s[::-1] + p)


Measured memory_bytes: 4388
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,ini,n) for(int i=ini;i<n;i++)
using namespace std;
typedef long long ll;

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

    string S;
    long long int res = 0;
    vector <int> a(10);
    cin >> S;
    int n = S.size();
    rep(i,0,n){
        a.at(i) = S.at(i) - '0';
    }
    rep(S, 0, 1<<n-1){ // +の位置を決める
        long long int now = a.at(0);
        long long int sum = 0;
        rep(i, 0, n-1){ // 各+の位置のもとで計算
            if(S >> i&1){ // もし次の値がSに含まれている（数値）なら10倍にした値と次の値の和を足す
                now *= 10LL;
                now += a.at(i+1);
            }else{ // もし次の値が+なら現在の位置の値を足す
                sum += now;
                now = a.at(i+1);
            }
        }
        sum += now;
        res += sum;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<vector<int>>adj;
int ls[200005];
int val[200005];
int t[800005];
multiset<int>s[200005];
int maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)) , maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}


void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}
void dfs(int v, int p){
	int value=val[v];
	int val2=1+maxi(1, 0, 200001, 0, value-1);
	ls[v]=max(val2, ls[p]);
	update(1, 0, 200001, value, val2);
	s[value].insert(val2);
	for(auto u:adj[v]){
		if(u==p){
			continue;
		}
		dfs(u, v);
	}
	auto it=s[value].end();
	it--;
	s[value].erase(it);
	if(s[value].size()==0){
		update(1, 0, 200001, value, 0);
	}
	else{
		auto it=s[value].end();
		it--;
		int vals=(*it);
		update(1, 0, 200001, value, vals);
	}
}

int main() {
	int n;
	cin>>n;
	adj.resize(n+1);
	set<int>s;
	for(int i=1; i<=n; i++){
		cin>>val[i];
		s.insert(val[i]);
	}
	map<int, int>m;
	int pt=1;
	
	for(auto it=s.begin(); it!=s.end(); it++){
		m[(*it)]=pt;
		pt++;
	}
	for(int i=1; i<=n; i++){
		val[i]=m[val[i]];
	}
	
	for(int i=0; i<n-1; i++){
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ls[1]=1;
	dfs(1, 0);
	for(int i=1; i<=n; i++){
		cout<<ls[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 65092
// atcoder/abc136/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  string s;
  while (cin >> s) {
    const int N = 1e5;
    int cnt[N];
    fill(cnt, cnt + N, 0);

    s += 'R';

    int j = 0;
    int r = 0;
    int l = 0;
    for (int i = 0; i + 1 < s.size(); ++i) {
      r += (s[i] == 'R');
      l += (s[i] == 'L');
      if (s[i] == 'R' && s[i + 1] == 'L') j = i;
      if (s[i] == 'L' && s[i + 1] == 'R') {
        // cout << i << endl;
        cnt[j] = ((r + 1) / 2) + (l / 2);
        cnt[j+1] = (r / 2) + ((l + 1) / 2);
        r = l = 0;
      }
    }

    for (int i = 0; i + 1 < s.size(); ++i) {
      if (i) cout << ' ';
      cout << cnt[i];
    }
    // cout << endl;
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1104
#include <stdio.h>

int main(){
	long x,y,i;
	int length=0;
	scanf("%ld",&x);
	scanf("%ld",&y);
	
	for(i=x;i<=y;){
		i=i*2;
		length++;
	}
	printf("%d",length);
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Atcoder.Abc
{
    //https://atcoder.jp/contests/abc176/tasks/abc176_a
    public class Abc176_A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var intN= Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            var N = intN[0];
            var X = intN[1];
            var T = intN[2];

            for (int i = 1; i <= 1000; i++)
            {
                if ( X * i >= N)
                {
                    WriteLine(T * i);
                    break;
                }
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17680