akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  // string S{}; std::cin >> S;
  ui N{}, i{}; std::cin >> N >> i;

  auto ans = N + 1 - i;
  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384
from collections import deque

def read():
    N, u, v = list(map(int, input().strip().split()))
    G = [list() for i in range(N+1)]
    for i in range(N-1):
        a, b = list(map(int, input().strip().split()))
        G[a].append(b)
        G[b].append(a)
    return N, u, v, G

def bfs(N, G, start):
    depth = [-1 for i in range(N+1)]
    depth[start] = 0
    q = deque()
    q.append(start)
    while(len(q) > 0):
        s = q.popleft()
        for t in G[s]:
            if depth[t] == -1:
                depth[t] = depth[s] + 1
                q.append(t)
    return depth

def solve(N, u, v, G):
    depth_u = bfs(N, G, u)
    depth_v = bfs(N, G, v)
    most_deepest_node = u
    for i in range(1, N+1):
        if depth_u[i] < depth_v[i]:
            if depth_v[i] > depth_v[most_deepest_node]:
                most_deepest_node = i
    neighbor_node = G[most_deepest_node][0]
    step_u = depth_u[neighbor_node]
    step_v = depth_v[neighbor_node]
    return step_v

if __name__ == '__main__':
    inputs = read()
    print('%d' % solve(*inputs))


Measured memory_bytes: 67616
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;
vector<pair<ll,ll>>ans;
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll k, x, y; cin >> k >> x >> y;
	ll kof_x = (x == 0 ? 1 : abs(x) / x);
	ll kof_y = (y == 0 ? 1 : abs(y) / y);
	x = abs(x), y = abs(y);
	if (k % 2 == 0 && (x + y) % 2 == 1) {
		cout << -1;
		return 0;
	}
	ll n = (x + y + k - 1) / k;
	if (n == 1 && ((x) + (y)) != k) n++;
	while ((n * k - (x) - (y)) % 2 != 0) n++;
	
	ll a = (n * k + x + y) / 2;
	ll b = (n * k - x - y) / 2;
	
	ll curx = 0, cury = 0;
	while (b >= k) {
		if (x < y) {
			curx -= k;
			b -= k;
		}
		else {
			cury -= k;
			b -= k;
		}
		ans.push_back({ curx,cury });
	}
	if (b > 0) {
		ll bb = k - b;
		if (x - curx >= bb) {
			curx += bb;
			cury -= b;
		}
		else {
			cury += bb;
			curx -= b;
		}
		a -= bb;
		b -= b;
		ans.push_back({ curx,cury });
	}
	while ((x - curx) >= k || (y - cury) >= k) {
		if (x - curx >= k) {
			curx += k;
		}
		else if (y - cury >= k) {
			cury += k;
		}
		a -= k;
		ans.push_back({ curx, cury });
	}
	if (a > 0) {
		ll bb = k - (x - curx);
		a -= (x - curx);
		curx = x;
		cury += bb;
		a -= bb;
		ans.push_back({ curx,cury });
	}
	if (a > 0) {
		ans.push_back({ x,y });
		a = 0;
	}

	for (auto& p : ans) {
		p.X *= kof_x;
		p.Y *= kof_y;
	}
	cout << ans.size() << endl;
	for (auto p : ans) {
		cout << p.X << " " << p.Y << '\n';
	}
	return 0;
}
/*

*/

Measured memory_bytes: 5616
N=int(input())
def next_357(num_arr,i=-1):
    if len(num_arr) < -i:
        num_arr.insert(0,3)
        return num_arr
    if num_arr[i] == 3:
        num_arr[i] = 5
        return num_arr
    elif num_arr[i] == 5:
        num_arr[i] = 7
        return num_arr
    elif num_arr[i] == 7:
        num_arr[i] = 3
        i -= 1
        return next_357(num_arr,i)
ans = 1
a357 = [3,5,7]
while True:
    if N < 357:
        ans = 0
        break
    elif N == 357:
        break
    else:
        a357 = next_357(a357)
        if int("".join(map(str, a357))) <= N:
            if a357.count(3) >= 1 and a357.count(5) >= 1 and a357.count(7) >= 1:
                ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 52060
import numpy as np
a,b,c,d = map(int,input().split())
X1 = np.array([a,b])
X2 = np.array([c,d])
x = (X2-X1)
x[0],x[1] = -x[1],x[0]
print((X2+x)[0],(X2+x)[1],(X1+x)[0],(X1+x)[1])

Measured memory_bytes: 12508
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

long long process(long long v)
{
	return v * v * v * v * v;
}

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

	long long X;
	cin >> X;

	for (long long i = -200; i <= 200; i++)
	{
		for (long long j = -200; j <= 200; j++)
		{
			if (process(i) - process(j) == X)
			{
				cout << i << " " << j;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
ll const N=1e6+5;
struct node{
	ll x,h;
};
bool comp(node a,node b){
	return a.x<b.x;
}
ll getSum(ll BITree[], ll index) 
{ 
    ll sum = 0; // Iniialize result 
  
    // index in BITree[] is 1 more than the index in arr[] 
    index = index + 1; 
  
    // Traverse ancestors of BITree[index] 
    while (index>0) 
    { 
        // Add current element of BITree to sum 
        sum += BITree[index]; 
  
        // Move index to parent node in getSum View 
        index -= index & (-index); 
    } 
    return sum; 
} 
void updateBIT(ll BITree[], ll n, ll index, ll val) 
{ 
    index = index + 1; 
  
    // Traverse all ancestors and add 'val' 
    while (index <= n) 
    { 
    // Add 'val' to current node of BI Tree 
    BITree[index] += val; 
  
    // Update index to that of parent in update View 
    index += index & (-index); 
    } 
} 
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;T=1;
    // cin>>T;
    while(T--){
   		ll ans=0;
   		int h,n;cin>>h>>n;
   		int a[n],b[n];
   		rep(i,n){
   			cin>>a[i]>>b[i];
   		}
   		int dp[h+1]={0};
   		rep(i,h+1)dp[i]=INT_MAX;
   		dp[0]=0;
   		repA(i,1,h){
   			for(int j=0;j<n;j++){
   				int t=max(0,i-a[j]);
   				dp[i]=min(b[j]+dp[t],dp[i]);
   			}
   		}
   		cout<<dp[h]<<endl;
    }
    return 0;   
}
 


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
    string str;
    cin >> str;
    reverse(str.begin(), str.end());
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#define N 100
#define NO 0
#define DISCOVERY 1
#define FINISHING 2

int n,ans[N][N];
int check[N],discover[N],finish[N],cnt;

void dfs(int u){
  int v;
  check[u]=DISCOVERY;
  discover[u]=++cnt;
  for(v=0;v<n;v++){
    if(ans[u][v]==0)continue;
    if(check[v]==NO)dfs(v);
  }
  check[u]=FINISHING;
  finish[u]=++cnt;
}
void fdfs(){
  int u;
  for(u=0;u<n;u++)check[u]=NO;
  cnt=0;
  for(u=0;u<n;u++)if(check[u]==NO)dfs(u);
  for(u=0;u<n;u++)printf("%d %d %d\n",u+1,discover[u],finish[u]);
}

int main() {
  int u,v,k;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      ans[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      ans[u][v]=1;
    }
  }
  fdfs();
  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
int main(void){
    int N;
    
    scanf("%d",&N);
    
    N=N%10;
    
    if(N==3){
        printf("bon\n");
    }else if(N==0 || N==1 || N==6 || N==8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    
    return 0;
}

Measured memory_bytes: 2064
def main():
    X, N = map(int, input().split())
    P = set(map(int, input().split()))

    ans = min(
        (i for i in range(0, 102) if i not in P),
        key=lambda x: abs(X - x)
    )
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n;
	cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];

	ll res = 0;
	for (int d = 0; d < 60; d++) {	//桁ごとに見る
		ll n0 = 0, n1 = 0;
		for (int i = 0; i < n; i++) {
			if ((a[i] >> d) & 1) ++n1;
			else ++n0;
		}
		ll tmp = (1LL << d) % mod;	//2^d
		ll n = n0 * n1 % mod;		//1になるのは(0,1)のとき
		tmp = tmp * n % mod;		//2^d * (n0 * n1)
		res = (res + tmp) % mod;
	}

	out(res);

	return 0;
}

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

using namespace std;

long long a, b, x;

long long f(long long n){
	if(n == -1) return 0;
	return n / x + 1;
}

int main(){
	cin >> a >> b >> x;
	cout << f(b) - f(a-1) << endl;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int N,M,S,T;
int u[200010],v[200010],a[200010],b[200010];
struct edge{
    int to,cost;
    edge(int to,int cost):to(to),cost(cost){}
};
vpint x[200010];
vpint y[200010];
int dist1[200010],dist2[200010];
priority_queue<pint,vpint,greater<pint>> que;
int p[200010];


signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N>>M>>S>>T;
	rep(i,0,M){
		cin>>u[i]>>v[i]>>a[i]>>b[i];
		x[u[i]].pb(pint(v[i],a[i]));
		x[v[i]].pb(pint(u[i],a[i]));
		y[u[i]].pb(pint(v[i],b[i]));
		y[v[i]].pb(pint(u[i],b[i]));
	}
	rep(i,0,N+1)dist1[i]=dist2[i]=INF;
    
	dist1[S]=0;que.push(pint(0,S));
	
	while(!que.empty()){
		int pos=que.top().se;que.pop();
		rep(i,0,x[pos].size()){
			int to=x[pos][i].fi,cost=x[pos][i].se;
			if(dist1[to]>dist1[pos]+cost){
				dist1[to]=dist1[pos]+cost;
				que.push(pint(dist1[to],to));
			}
		}
	}
    
    dist2[T]=0;que.push(pint(0,T));
	
	while(!que.empty()){
		int pos=que.top().se;que.pop();
		rep(i,0,y[pos].size()){
			int to=y[pos][i].fi,cost=y[pos][i].se;
			if(dist2[to]>dist2[pos]+cost){
				dist2[to]=dist2[pos]+cost;
				que.push(pint(dist2[to],to));
			}
		}
	}
    
	rep(i,1,N+1){
		p[i]=dist1[i]+dist2[i];
	}
    rrep(i,0,N){
		p[i]=min(p[i],p[i+1]);
	}
    rep(i,1,N+1){
		cout<<1000000000000000LL-p[i]<<endl;
	}
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 31096
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			for(int k=j+1;k<=n;k++)
				if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])
					ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>
#include<string.h>
int main(void){
char S[101];
int n, sum=0;
scanf("%s", S);
n=strlen(S);
for(int i=0;i<n;i++){
 if( S[i]!=S[n-(i+1)] ){
  sum+=1;
 }
}
printf("%d", sum/2);
return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
    String str=sc.next();
    if(str.replaceAll("eraser","").replaceAll("erase","").replaceAll("dreamer","").replaceAll("dream","").equals("")){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

	}
}

Measured memory_bytes: 30224
def is_even_str(s):
    mid = len(s) // 2
    for i in range(mid):
        if s[i] != s[mid + i]:
            return False
    return True


S = input()

if len(S) % 2 == 0:
    S = S[:-2]
else:
    S = S[:-1]

for stop in range(len(S), 1, -2):
    if is_even_str(S[:stop]):
        print(stop)
        break


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

int main() {
	string word;
	string sentence;
	int count=0,i;
	getline(cin,word);
	while(1) {
		cin >> sentence;
		if(sentence=="END_OF_TEXT") break;
		if(sentence[(int)sentence.length()-1]=='.') {
			sentence.pop_back();
		}
		if(sentence.length()==word.length()) {
			for(i=0;i<(int)sentence.length();++i) {
				if(sentence[i]!=word[i]&&sentence[i]+'a'-'A'!=word[i]&&sentence[i]-'a'+'A'!=word[i]) break;
			}
			if(i==(int)sentence.length()) ++count;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3160
if __name__ == '__main__':
  str = input()
  l = list(str)
  counter = 0
  max = 0
  for s in l:
    if s == 'A' or s == 'G' or s == 'C' or s == 'T':
      counter += 1
      if max <= counter:
        max = counter
    else:
      counter = 0
  print(max)

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, a;
  cin >> n;
  bool flag = true;
  rep(i, n) {
    cin >> a;
    if (a % 2 == 0) flag &= (a % 3 == 0 || a % 5 == 0);
  }
  cout << (flag ? "APPROVED" : "DENIED") << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> pii;

int H,W;
char A[101][101];
int B[101][101];
int L[10],R[10],U[10],D[10];
int C[101][101];
void solve(){
	cin>>H>>W;
	set<char>st;
	REP(i,H){
		REP(j,W){
			cin>>A[i][j];
			if(A[i][j]!='.')st.insert(A[i][j]);
		}
	}
	map<char,int>mp;
	int id=0;
	for(auto c:st){
		mp[c]=id;
		id++;
	}
	REP(i,10){
		L[i]=1e9,R[i]=-1,U[i]=1e9,D[i]=-1;
	}
	REP(i,H){
		REP(j,W){
			if(A[i][j]=='.')B[i][j]=-1;
			else {
				B[i][j]=mp[A[i][j]];
				int id = mp[A[i][j]];
				L[id]=min(L[id],j);
				R[id]=max(R[id],j);
				U[id]=min(U[id],i);
				D[id]=max(D[id],i);
			}
		}
	}
	int perm[10];
	int M=st.size();
	REP(i,M)perm[i]=i;
	bool safe = false;
	do{
		REP(i,H){
			REP(j,W){
				C[i][j]=B[i][j];
			}
		}
		bool ok = true;
		REP(i,M){
			int id = perm[i];
			FOR(i,U[id],D[id]+1){
				FOR(j,L[id],R[id]+1){
					if(C[i][j]!=id&&C[i][j]!=-2){
						ok=false;
						//goto END;
					}
				}
			}
			FOR(i,U[id],D[id]+1){
				FOR(j,L[id],R[id]+1){
					C[i][j]=-2;
				}
			}
		}
		END:;
		if(ok){
			safe=true;
		}
	}while(next_permutation(perm,perm+M));
	if(safe)cout<<"SAFE"<<endl;
	else cout<<"SUSPICIOUS"<<endl;
}

signed main() {
	int q;cin>>q;
	while (q--) {
		solve();
	}
}


Measured memory_bytes: 3148
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

X = s()

C = 'CODEFESTIVAL2016'

c = 0
for i, x in enumerate(X):
    if x != C[i]:
        c += 1

print c



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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e5 + 2, inf = 1e18;
const int mod = 1e9 + 7;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    int n;
    cin >> n;
    int cnt1[66] = {};
    int cnt0[66] = {};
    int twos[66] = {};
    twos[0] = 1;
    for(int i = 1; i < 62; i++)
        twos[i] = (twos[i - 1] * 2) % mod;

    int ans = 0;

    FOR(i,1,n) {
        int u;
        cin >> u;

        int add = 0;

        for(int bit = 0; bit < 62; bit++) {
            if(u >> bit & 1LL)
            {
                add = (add + cnt0[bit] * twos[bit]) % mod;
            }
            else 
            {
                add = (add + cnt1[bit] * twos[bit]) % mod;
            }
        }

        ans = (ans + add) % mod;

        for(int bit = 0; bit < 62; bit++) 
            cnt1[bit] += (u >> bit & 1LL) == 1,
            cnt0[bit] += (u >> bit & 1LL) == 0;
    }

    cout << ans;
}


Measured memory_bytes: 3672
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC144C
{
    class Program
    {
        static void Main(string[] args)
        {
            //var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var inputLong = long.Parse(Console.ReadLine());

            long ans = inputLong - 1;
            //string ans = "";

            for(long a = 1; a * a <= inputLong; a++)
            {
                if (inputLong % a == 0)
                {
                    long b = inputLong / a;
                    ans = Math.Min(a + b - 2, ans);
                }
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
 
typedef long long ll;
const int N = 200005;

int cnt[N];
bool vstd[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	int cor = 0,pen = 0;
	
	for(int i=0;i<m;i++){
		int x;
		string c;
		cin>>x>>c;
		if(vstd[x])continue;
		else{
			if(c == "AC"){
				cor++;
				vstd[x] = true;
				pen += cnt[x];
			}
			else{
				cnt[x]++;
			}
		}
	}
	cout<<cor<<" "<<pen;
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 1005


int main(){

    ll n,k;
    cin >> n >> k;
    vector<ll> a(ARRAY_MAX,0);
    vector<ll> beautiful;
    vector<ll> w;
    REP(i,n){
        cin >> a[i+1];
    }
    //累積和をとる
    REP(i,n){
        a[i+1] += a[i];
    }

    for(int i = 1;i <= n;i++){//左端
        for(int j = i;j <= n;j++){//右端
            beautiful.push_back(a[j]-a[i-1]);
        }
    }

    ll ans = 0;

    for(ll bit = 42;bit >= 0;bit--){
        //iビット目を見る
        ll cnt = 0;
        vector<ll> tmp;//iビット目がk個以上たっている数字を格納する

        REP(j,beautiful.size()){

            if((beautiful[j] >> bit)&1LL){
                cnt++;
                tmp.push_back(beautiful[j]);
            }
        }
        if(cnt >= k){
            //k個以上あったらこれらの数字のみ使う
            ans += (1LL << bit);
            beautiful = tmp;
        }
        tmp.shrink_to_fit();
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  vector<int> d(109);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() - 1 << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=1e6+10;

int a[maxn*3][3],d[maxn*3],id[maxn*3],ans[maxn];
int n,p[15];
string s;

void build(int c,int x,int pos){
	if(c==n){
	//	cout<<x<<" "<<pos<<endl;
		id[x]=pos;
		return;
	}
	for(int i=0;i<3;i++){
		a[x][i]=x*3+i;
		build(c+1,x*3+i,pos+i*p[c]);
	}
}

void apply(int x){
	d[x]=!d[x];
	swap(a[x][1],a[x][2]);
//	cout<<a[x][1]<<" "<<a[x][2]<<endl;
}

void update(int x){
	if(d[x]==false) return;
	d[x]=false;
	for(int i=0;i<3;i++) apply(a[x][i]);
}

void add(int c,int x){
	if(c==n){
		return;
	} 
	else{
		update(x);
		swap(a[x][1],a[x][2]);
		swap(a[x][0],a[x][1]);
		add(c+1,a[x][0]);
	}
}

void dfs(int c,int x,int pos) {
	if(c==n){
		ans[id[x]]=pos;
	} 
	else{
		update(x);
		for(int i=0;i<3;i++){
			dfs(c+1,a[x][i],pos+i*p[c]);
		}
	}
}

int main(){
	p[0]=1;
	for(int i=1;i<15;i++) p[i]=p[i-1]*3;
	cin>>n>>s;
	int n2=n;
	build(0,1,0);
	for(int i=0;i<s.size();i++){
		if(s[i]=='S'){
			apply(1);
		//	cout<<i<<endl;
		}
		else{
			add(0,1);
		}
	//	dfs(0,1,0);
	//	for(int i=0;i<3;i++) cout<<ans[i]<<" "; cout<<endl;
	}
	dfs(0,1,0);
	n=1;
	for(int i=0;i<n2;i++) n=n*3;
	for(int i=0;i<n;i++) cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 21024
#!/usr/bin/env python
# coding: utf-8

# In[16]:


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


# In[18]:


ans = 0
plug = 1
while 1:
    if plug >= B:
        break
    else:
        ans += 1
        plug = plug - 1 + A
#         print(plug)
print(ans)


# In[ ]:






Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; };
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; };

int dx[8] = { 1,1,1,0,0,-1,-1,-1 };
int dy[8] = { 1,0,-1,1,-1,1,0,-1 };
string board[60];

int main() {
	int X, Y;
	cin >> X >> Y;
	for(int i = 0;i < X;++i) {
		cin >> board[i];
	}
    for(int i = 0;i < X;++i) {
		for (int j = 0;j < Y;++j) {
			if (board[i][j] == '.') {
				int cnt = 0;
				for (int k = 0;k < 8;++k) {
					int x = i + dx[k];
					int y = j + dy[k];
					if (x >= 0 && x < X && y >= 0 && y < Y && board[x][y] == '#')cnt++;

				}
				board[i][j] = '0' + cnt;
			}
		}
	}
	for (int i = 0;i < X;++i)cout << board[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>                                             
#include <vector>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  int n, m;                                                     
  while (true) {                                                
    cin >> n;                                                   
    if (n==0) {                                                 
      break;                                                    
    }                                                           
    vector<char> from(n);                                       
    vector<char> to(n);                                         
    for (int i=0; i<n; i++) {                                   
      cin >> from[i] >> to[i];                                  
    }                                                           
    cin >> m;                                                   
    vector<char> v(m);                                          
    for (int i=0; i<m; i++) {                                   
      cin >> v[i];                                              
      for (int j=0; j<n; j++) {                                 
        if (v[i]==from[j]) {                                    
          v[i] = to[j];                                         
          break;                                                
        }                                                       
      }                                                         
    }                                                           
    for (int i=0; i<m; i++) {                                   
      cout << v[i];                                             
    }                                                           
    cout << endl;                                               
  }                                                             
  return 0;                                                     
}                                    

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    fast;
    string str;
    cin >> str;
    if(str[0] == str[1] && str[1] == str[2] && str[2] == str[0]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }


    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const int inf = 1 << 28;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int w, h;

inline bool inrect(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

int solve(vector<string>& c){
    vector<int> xs, ys;
    rep(i, h)rep(j, w){
        if(c[i][j] == 'o')xs.insert(xs.begin(), i), ys.insert(ys.begin(), j);
        if(c[i][j] == '*')xs.push_back(i), ys.push_back(j);
    }
    int n = (int)xs.size();
    vector<vector<int> > costs(n, vector<int>(n, inf));
    rep(i, n){
        vector<vector<int> > mem(h, vector<int>(w, inf)); mem[xs[i]][ys[i]] = 0;
        typedef tuple<int, int, int> State;
        priority_queue<State> q;
        for(q.emplace(0, xs[i], ys[i]); !q.empty();){
            int cost, x, y;
            tie(cost, x, y) = q.top(); q.pop();
            if(mem[x][y] != -cost)continue;
            rep(k, 4){
                int nx = x + dx[k], ny = y + dy[k];
                if(!inrect(nx, ny) || c[nx][ny] == 'x' || mem[nx][ny] <= 1 - cost)continue;
                mem[nx][ny] = 1 - cost;
                q.emplace(-mem[nx][ny], nx, ny);
            }
        }
        rep(j, n)costs[i][j] = mem[xs[j]][ys[j]];
    }
    if(find(all(costs[0]), inf) != costs[0].end())return -1;
    vector<vector<int> > mem(1 << n, vector<int>(n, inf)); mem[1 << 0][0] = 0;
    typedef tuple<int, int, int> State;
    priority_queue<State> q;
    for(q.emplace(0, 1 << 0, 0); !q.empty();){
        int cost, vis, v;
        tie(cost, vis, v) = q.top(); q.pop();
        if(mem[vis][v] != -cost)continue;
        rep(i, n){
            if(vis >> i & 1 || mem[vis | 1 << i][i] <= costs[v][i] - cost)continue;
            mem[vis | 1 << i][i] = costs[v][i] - cost;
            q.emplace(-mem[vis | 1 << i][i], vis | 1<< i, i);
        }
    }
    return *min_element(all(mem[(1 << n) - 1]));
}

int main(){
    while(cin >> w >> h, w|h){
        vector<string> c(h);
        rep(i, h)cin >> c[i];
        cout << solve(c) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,T,A,t,a;
	cin>>n;
	t=a=1;
	for(long long i=0;i<=n;i++)
	{
		cin>>T>>A;
		long long k=max((t+T-1)/T,(a+A-1)/A);
		t=k*T;
		a=k*A;
		//cout<<t<<" "<<a<<endl;
	}
	cout<<t+a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> ko(n);
  for(int i=0;i<n;i++){
    cin >> ko.at(i);
  }
  int m=0;
  for(int i=0;i<n;i++){
    m+=ko.at(i);
  }
  cout << m-n;
}

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

int main(){
    int N;
    string S;
    map<string,int> m;

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

    int max=0;
    for(const auto& x:m){
        if(x.second>max){     
            max=x.second;
        }
    }

    for(const auto& x:m){
        if(x.second==max){
            cout<<x.first<<'\n';
        }
    }

}


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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

char s[100005];
int len, ans;

int main(){
	scanf("%s", s);
	len = strlen(s);
	int l = 0, r = len - 1;
	while(l < r){
		if(s[l] == s[r]){
			l++, r--;
		}
		else if(s[l] == 'x'){
			ans++;
			l++;
		}
		else if(s[r] == 'x'){
			ans++;
			r--;
		}
		else{
			printf("-1\n");
			return 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int N, K;
int ub, lb;
int ans[1008];
vector<vector<int>> v(1001);

bool check()
{

    for (int i = 0; i < K; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < N / 2; ++j)
        {
            cnt += ans[v[i][j]];
        }
        if (cnt < lb || cnt > ub)
            return false;
    }
    return true;
}

void solve()
{
    for (int i = 0; i < N / 2; ++i)
        ans[i] = 1;
    while (1)
    {
        std::random_device seed_gen;
        std::mt19937 engine(seed_gen());
        shuffle(ans, ans + N, engine);
        if (check())
            break;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int h1, h2, m1, m2, s1, s2;
    for (int i = 0; i < 3; ++i)
    {
        cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;

        int t1 = 3600 * h1 + 60 * m1 + s1;
        int t2 = 3600 * h2 + 60 * m2 + s2;

        int sa = t2 - t1;
        cout << sa / 3600 << " " << (sa % 3600) / 60 << " " << (sa % 3600) % 60 << endl;
    }
    return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int kai_1 = C / B;
  int kai_2 = A / D;
  int a = C % B;
  int b = A % D;
  
  if(a){
    kai_1++;
  }
  if(b){
    kai_2++;
  }
  
  if(kai_1 <= kai_2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3620
from sys import stdin
N = int(stdin.readline().rstrip())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*n*h == N*(n+h):
            continue
        w = N*h*n/(4*n*h-N*(n+h))
        if w.is_integer() == True and w>0:
            print(n,h,int(w))
            exit()

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  int b[n];
  if(n%2==0){
    rep(i,0,n/2){
      b[n/2+i]=a[2*i];
    }
    rep(i,0,n/2){
      b[n/2-1-i]=a[2*i+1];
    }
  }
  else{
    rep(i,0,n/2+1){
      b[n/2-i]=a[2*i];
    }
    rep(i,0,n/2){
      b[n/2+1+i]=a[2*i+1];
    }
  }
  rep(i,0,n) cout<<b[i]<<endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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 ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, w;
  cin >> n >> w;
  vector<vector<ll>> wv(n, vector<ll>(2));
  rep(i, n) cin >> wv[i][0] >> wv[i][1];

  vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));

  rep(i, n) {
    reps1(j, w+1) {
      if (j-wv[i][0] >= 0)
        chmax(dp[i+1][j], dp[i][j-wv[i][0]] + wv[i][1]);

      chmax(dp[i+1][j], dp[i][j]);
    }
  }

  cout << dp[n][w] << endl;
  
  return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    string x;
    cin>>x;
    int n = x.size();
    int a[n + 1];
    memset(a  , 0 , sizeof(a));
    for(int i = 0 ; i< n -1 ; i++){
        if(x[i] == '>' && x[i+1] == '<'){
            a[i + 1] = 0;
        }
    }
    for(int i = 0 ; i < n ; i++){
        if((i == n-1 && x[i] == '<' ) ||(x[i] == '<' && x[i+1] == '<') ){
            a[i + 1] = a[i] + 1;
        }
    }
    for(int i = n - 1 ; i >= 0 ; i--){
        if((i == 0 && x[i] == '>') || (x[i] == '>' && x[i-1] == '>')){
            a[i] = a[i+1] + 1;
        }
    }
    for(int i = 0 ; i < n -1 ; i++){
        if(x[i] == '<' && x[i+1] == '>'){
            a[i+1] = max(a[i] , a[i+2]) + 1;
        }
    }
    int sum = 0;
    for(int i = 0 ; i< n + 1 ; i++){
        sum += a[i];
    }
    cout<<sum<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4764
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int N, A, B;
	int num1 = 0, num2 = 0, num3 = 0;
	cin >> N >> A >> B;
	for(int i = 0; i < N; i ++){
		int p;
		cin >> p;
		if(p <= A)num1 ++;
		else if(A + 1 <= p && p <= B)num2 ++;
		else num3 ++;
	}
	cout << min(num1, min(num2, num3)) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void debug() { std::cerr << '\n'; }
template <class H, class... T> void debug(H &&head, T &&... args) {
    std::cerr << head;
    sizeof...(args) == 0 ? std::cerr << "" : std::cerr << ' ';
    debug(std::forward<T>(args)...);
}
template <class T> void debug(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cerr << v[i];
        i == v.size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
    }
}
template <class T> void debug(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cerr << v[i][j];
            j == v[i].size() - 1 ? std::cerr << '\n' : std::cerr << ' ';
        }
    }
}
vector<int> run_length(const string &v) {
    vector<int> ans(1, 1);
    if (v.size() == 1)
        return ans;
    for (int i = 1; i < v.size(); i++) {
        if (v[i - 1] == v[i]) {
            ans[ans.size() - 1]++;
        } else {
            ans.emplace_back(1);
        }
    }
    return ans;
}

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

    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    auto cnt = run_length(s);

    if (cnt.size() == 2) {
        print(N - 1);
        return 0;
    }
    if (cnt.size() == 1) {
        print(N - 1);
        return 0;
    }
    int ans = 0;
    for (auto &&i : cnt) {
        ans += i - 1;
    }
    ans = min(N - 1, ans + 2 * K);
    print(ans);

    return 0;
}

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

int main(){
	int k;
	while(cin >> k,k){
		int c;
		int ans=0;
		for(int i = 0; i < k*(k-1)/2; i++){
			cin >> c;
			ans += c;
		}
		cout << ans/(k-1) << endl;
	}
}

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

int main(void) {
	int i, n, a, b, as = 0, bs = 0;
	for(cin >> n ; n != 0 ; as = bs = 0, cin >> n) {
		for(i=0 ; i<n ; i++) {
			cin >> a >> b;
			if(a > b)		{ as += a+b; }
			else if(a < b)	{ bs += a+b; }
			else 			{ as += a; bs += b; }
		}
		cout << as << " " << bs << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
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; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;
  string s;cin>>s;

  rep(i,0,s.size()){
    char ans;
    if(char(s[i]+n)>'Z')ans=char('A'-1+char(s[i]+n)-'Z');
    else ans=char(s[i]+n);
    cout<<ans;
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
tmp = 1
 
for i in range(1,10**6+1):
  if n%i == 0:
    if i <= n//i:
      tmp  = i
    else:
      break
  elif tmp == 1 and i >= n/i:
    break
      
print(tmp + (n//tmp) -2)

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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0;i < N;i++){
    char S;
    cin >> S;
    if(S == 'Y'){
      cout << "Four";
      break;
    }
    if(S != 'Y' && i == N - 1){
       cout << "Three";
    }
  }
}


Measured memory_bytes: 256
a=list(map(int,input().split()))
b=list(map(int,input().split()))
N=a[0]
M=a[1]
sum_day = 0
for i in range(M):
    sum_day += b[i]
ans = N - sum_day
if ans < 0:
    print(-1)
else:
    print(ans)



Measured memory_bytes: 9884
import math

n,k = map(int,input().split())

sum = 0

for i in range(1,n+1):
    if i < k :
        x = -(-math.log2(k/i)//1)
        sum += (1/n) * pow(0.5,x)
    else:
        sum += (1/n)

print(sum)



Measured memory_bytes: 3060
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>

#include <queue>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int freq[200004];

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

   int N, K;
   cin >> N >> K;
   REP(i, N) {
      int x;
      cin >> x;
      ++freq[x];
   }

   priority_queue< int, vector<int>, greater<int> > pq;
   FOR(x, 1, N) {
      if (freq[x])
         pq.push(freq[x]);
   }

   int res = 0;
   while (SZ(pq) > K) {
      int f = pq.top();
      pq.pop();
      res += f;
   }
   cout << res << endl;

   return 0;
}


Measured memory_bytes: 2168
#include <iostream>

using namespace std;

int main(){
  while(true){
    int r0, w0, c, r;
    cin >> r0 >> w0 >> c >> r;
    if(r0+w0+c+r == 0) break;

    if(r0/w0 > c){
      cout << 0 << endl;
    }else{
      //(r0+x*r)/w0 > c
      //x*r > c*w0-r0
      cout << ((r-1)+c*w0-r0)/r << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3040
# 幅優先探索（行きがけ）
import collections
import sys


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    X, Y = LI()
    ans = "No"
    for i in range(X+1):
        for j in range(X+1):
            if i+j > X:
                break
            if 2*i+4*j == Y and i+j == X:
                ans = "Yes"
                print(ans)
                return

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9464
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,h,ans=0,i=0; cin>>n>>h;
    vector<int> a(n,0),b(n,0);
    rep(i,n) cin>>a[i]>>b[i];
    sort(al(a)); reverse(al(a));
    sort(al(b)); reverse(al(b));
    for(int i=0;i<n;i++){
        if(b[i]>a[0]){
            h-=b[i]; ans++;
            if(h<=0) break;
        }
        if(b[i]<=a[0] || i==n-1){
            ans+=(h+a[0]-1)/a[0];
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
int N;
cin >> N;
vector<int> A(N);
vector<int> B(N);
A.at(0)=0;
for(int i=1;i<N;i++){
  cin >> A.at(i);
}
for(int i=1;i<N;i++){
  B.at(A.at(i)-1)++;
}
for(int i=0;i<N;i++){
  cout << B.at(i) <<endl;
}
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    
    ll ans = 0;
    rep(i, n) {
        ll bigger = c.end() -  upper_bound(c.begin(), c.end(), b[i]);
        ll smaller = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ans += bigger * smaller;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 1408