akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		double a1 =0.08;
		double b1 =0.1;
		double s=0;
		int ans =-1;
		int s1 =0;
		double t =0;
		double t1 =0;
		for(int i=1; i<10000;i++) {
			s=i*0.08;
			s1 =(int)s;
			t=i*0.1;
			t1 =(int)t;
			if(s1==A &&t1==B) {
				ans = i;
				break;
			}
			
			
			
			
			
		}
		System.out.print(ans);

	}
}


Measured memory_bytes: 25172
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;
string str[10] = {
"",
".,!? ",
"abc",
"def",
"ghi",
"jkl",
"mno",
"pqrs",
"tuv",
"wxyz"
};

main(){
	string s;
	cin >> n;
	while(n--){
		cin >> s;
		string ans = "";
		for(int p=0;s[p];p++){
			if(s[p] == '0') continue;
			int t = -1;
			int c = s[p]-'0';
			for(;s[p]!='0';p++)t++;
			ans.push_back(str[c][t%str[c].size()]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  char c;
  cin>>c;
  switch(c)
    {
      case 'A': cout<<'T';break;
      case 'C': cout<<'G';break;
      case 'T': cout<<'A';break;
      default:  cout<<'C';break;
    }
  cout<<'\n';
  }

Measured memory_bytes: 256
main = do
  n <- readLn
  putStrLn (unwords $ map show $ solve n)

solve :: Int -> [Int]
solve n =
  take n $ filter ((==1).(`mod`10)) $ primes

primes :: [Int]
primes = 2:[i |i<-[3..], isPrime i ]

isPrime i =
  and[i`mod`p/=0 | p <- takeWhile (<=u) primes]
  where
    u = floor(sqrt(fromIntegral i))

Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
#define B

#ifdef B
#define _MAX 52
int main(void)
{
	int n;
	int dis;
	bool arr[_MAX] = {};
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		char m;
		int num;
		cin >> m >> num;
		switch (m)
		{
		default:
			break;
		case 'S':
			num += 0*13;
			break;
		case 'H':
			num += 1*13;
			break;
		case 'C':
			num += 2*13;
			break;
		case 'D':
			num += 3*13;
			break;
		}
		num--;
		arr[num] = true;

	}
	for (size_t i = 0; i < _MAX; i++)
	{
		if (!arr[i]) {
			switch (i / 13)
			{
			default:
				break;
			case 0:
				cout << "S ";
				break;
			case 1:
				cout << "H ";
				break;
			case 2:
				cout << "C ";
				break;
			case 3:
				cout << "D ";
				break;

			}
			cout << (i % 13) + 1 << endl;
		}
	}
	return 0;
}

#endif

Measured memory_bytes: 3096
#include <iostream>
typedef long long ll;
using namespace std;

ll euclid(ll a,ll b){
  if (a%b==0) return b;
  else return euclid(b,a%b);
}
ll cmulti(ll a,ll b){
  return a*b/euclid(a,b);
}

int main() {
  ll a,b,c,d;cin>>a>>b>>c>>d;
  --a;
  ll ans=b-a;
  if(c<d){
    ll x=c;
    c=d;
    d=x;
  }
  ll m = cmulti(c,d);
  ans += -(b/c +b/d -b/m);
  ans -= -(a/c +a/d -a/m);
  cout << ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

typedef pair < int, int > P;
vector < P > vec;

int main(){
	
	int n, k;
	cin >> n >> k;
	
	for(int i=0;i<n;i++){
		int a, b;
		cin >> a >> b;
		vec.push_back( P(a, b) );
	}

	long long int ans = 1LL<<62;
	
	for(int l=0;l<n;l++){
		for(int r=0;r<n;r++){
			for(int u=0;u<n;u++){
				for(int d=0;d<n;d++){
					
					int cnt = 0;
					int ll = vec[l].F, rr = vec[r].F, uu = vec[u].S, dd = vec[d].S;
					
					for(int i=0;i<n;i++){
						int x = vec[i].F, y = vec[i].S;
						if(ll <= x && rr >= x && uu >= y && dd <= y) cnt++;
					}
					
					if(cnt >= k) ans = min(ans, 1LL * (rr-ll)*(uu-dd));
					}
				}
			}
		}
	
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> vec;
vector<ll> check;
ll dfs1(ll from,ll to){
  check.at(from-1)=54;
  if(check.at(to-1)==54){return to;}
  dfs1(to,vec.at(to-1));
}
ll dfs2(ll from,ll to,ll count){//全体の個数
  count++;
  check.at(from-1)=69;
  if(check.at(to-1)==69){return count;}
  dfs2(to,vec.at(to-1),count);
}
ll dfs3(ll from,ll to,ll cc){//ループの個数
  cc++;
  check.at(from-1)=5;
  if(check.at(to-1)==5){return cc;}
  dfs3(to,vec.at(to-1),cc);
}
int main() {
  ll N,K,answer;
  cin>>N>>K;
  vec.resize(N);
  check.resize(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  dfs1(1,vec.at(0));
  dfs2(1,vec.at(0),0);
  ll a=dfs1(1,vec.at(0));
  ll b=dfs2(1,vec.at(0),0);
  ll c=dfs3(a,vec.at(a-1),0);
  K-=b-c;
  if(K==0){
    cout<<a<<endl;
    return 0;
  }
  if(K<0){
    K+=b-c;
    if(K==0){
      cout<<1<<endl;
      return 0;
    }
    answer=1;
    for(ll i=0;i<K;i++){
      answer=vec.at(answer-1);
    }
    cout<<answer<<endl;
    return 0;
  }
  ll ans=K%c;
  answer=a;
  if(ans==0){ans+=c;}
  for(ll i=0;i<ans;i++){
    answer=vec.at(answer-1);
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 9412
a,b,q = map(int,input().split())
s = []
t = []
for i in range(a):
    k = int(input())
    s.append(k)
for i in range(b):
    k = int(input())
    t.append(k)


import bisect
import itertools
#sは配列,xは知りたい値
inf = 10**15
s = [-inf]+s+[inf]
t = [-inf]+t+[inf]
#最初と最後にinfをつけておく。

for i in range(q):
    x = int(input())
    asa = bisect.bisect_left(s,x)-1
    bs = bisect.bisect_left(t,x)-1
    s1,s2 = s[asa],s[asa+1]
    t1,t2 = t[bs],t[bs+1]
    ans = min(x-min(s1,t1),max(s2,t2)-x,
    s2-t1+min(s2-x,x-t1),
    t2-s1+min(t2-x,x-s1))
    print(ans)


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

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

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

	c = b - a;

	c = (c * (c + 1)) / 2;

	printf("%d", c - b);

	return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("floor4.out", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    int n;
    cin >>n;
    vector<int> a(n);
    for(int& x : a)
        cin >> x;

    if (is_sorted(begin(a), end(a)))
        FINAL_OUT("YES");

    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            swap(a[i], a[j]);
            if (is_sorted(begin(a), end(a)))
                FINAL_OUT("YES");
            swap(a[i], a[j]);
        }
    FINAL_OUT("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

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

  int cnt = 0;
  for (int n=1;n<=N;n+=2){
    int d = 0;
    for (int i=1;i<=n;i++){
      if (n%i==0) d++;
    }
    if (d==8) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

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

    cout << (1000 - (n % 1000)) % 1000 << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define Fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int mo = 1e9 + 7;
int32_t main() {
    Fast_IO
#ifdef __WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m; cin >> n >> m;
    vector<string> mat(n);
    for (auto &itr : mat) {
        cin >> itr;
    }
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 and j == 1) {
                continue;
            }
            if (mat[i - 1][j - 1] == '#')
                continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mo;
        }
    }
    cout << dp[n][m];
}

Measured memory_bytes: 9216
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, x;
  cin >> N >> x;
  vector<long> a(N);
  rep (i, N) cin >> a[i];
  sort(a.begin(), a.end());
  long result = 0;
  rep (i, N) {
    if (x >= a[i]) {
      result++;
      x -= a[i];
    } else x = 0;
  }
  if (x > 0) result--;
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int s,m,temp[100001];

int main(){
    cin>>s;
    rep(i,100001){
        temp[i]=0;
    }
    temp[s]=1;
    repi(i,1,1000002){
        if(s%2==0){
            s/=2;
        }
        else{
            s=3*s+1;
        }
        if(temp[s]==0){
            temp[s]=1;
        }
        else{
            m=i+1;
            break;
        }
    }
    out(m);
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	long long int sum1=0,prev1=0;
	long long int sum2=0,prev2=0;
	long long int ans1=0, ans2=0;
	for(int i=0;i<n;i++){
		long long int a;
		cin >> a;
		sum1 += a;
		sum2 += a;
		if(i%2==0){
			if(sum1 >= 0){
				ans1 += abs(sum1)+1;
				sum1 = -1;
			}
			if(sum2 <= 0){
				ans2 += abs(sum2)+1;
				sum2 = 1;
			}
		} else {
			if(sum1 <= 0){
				ans1 += abs(sum1)+1;
				sum1 = 1;
			}
			if(sum2 >= 0){
				ans2 += abs(sum2)+1;
				sum2 = -1;
			}
		}
		prev1 = sum1;
		prev2 = sum2;
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %5f\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2088
#include <iostream>
using namespace std;
bool f(int x, int b){
    if(x-2 <= b && b <= x+1)return true;
    if(x == 2 && b == x+2) return true;
    return false;
}
int main() {
    int n, x, b = 1;
    cin >> n >> x;
    if(x == 1 || x == n*2-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    for(int i=1;i<=n*2-1;i++){
        int a;
        if(n-1 <= i && i <= n+2){
            if(i <= n+1){
                if(x == 2)a = x - i + n;
                else      a = x + i - n;
            }else{
                if(x == 2)a = x+2;
                else      a = x-2;
            }
        }else{
            while(f(x, b))b++;
            a = b++;
        }
        cout << a << endl;
    }
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(){

	int a,b,d,r;
	double f;

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

	d = a / b;
	r = a % b;
	f = (double)a / b;

	printf("%d %d %lf\n",d,r,f);

	return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int p[n];
    int v1 = 0, v2 = 0, v3 = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        if(p[i] <= a){
            v1++;
        } else if(a < p[i] && p[i] <= b){
            v2++;
        } else {
            v3++;
        }
    }
    int ans = min(v2, v3);
    ans = min(ans, v1);
    cout << ans << endl;
}


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

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b(n);

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

  
	for (int i = 0; i < n; i++) {
		if (i < n - 1) {
			cout << b[i] << " ";
		}
		else {
			cout << b[i];
		}
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 205;

ll a[sz], b[69];
char s[sz];

bool gauss(ll x)
{
   for(int i=0; i<61; i++) {
      if(x & 1LL << i) {
         if(b[i]) x ^= b[i];
         else {
            b[i] = x;
            return 0;
         }
      }
   }
   return 1;
}

void solve()
{
   int n;
   scanf("%d", &n);
   for(int i=0; i<n; i++) scanf("%lld", &a[i]);
   scanf("%s", s);

   int ans = 0;
   memset(b, 0, sizeof b);
   for(int i=n-1; i>=0 && !ans; i--) {
      if(!gauss(a[i]) && s[i] == '1') ans = 1;
   }
   printf("%d\n", ans);
}

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


Measured memory_bytes: 3796
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Console.ReadLine();
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var t = h[0];
		Console.WriteLine(1 + h.Skip(1).Count(x => { var b = x >= t; t = Math.Max(t, x); return b; }));
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    int mx = 0;
    for( int i = 0; i < s.size(); ++i ) {
        if( s[i] == 'I' ) ++cnt;
        else --cnt;
        mx = max( mx, cnt );
    }

    cout << mx << endl;
    return 0;
}



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

const long long x = 1000000000000000000;

int main(){
    int n;
    long long ans = 1;
    cin >> n;
    long long a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] == 0){
            ans = 0;
        }
    }

    if(ans != 0){
    for(int i = 0;i < n;i++){
        if(x/a[i] >= ans){
            ans *= a[i];
        }
        else
        {
            ans = -1;
            break;
        }
    }
    }

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

Measured memory_bytes: 4368
#include <cstdio>

char A[15], B[15];
int main(){
    scanf("%s", &A[0]);

    int cnt = 0;
    for (int i=0; A[i] != '\0'; ++i) {
        if (A[i] == '0' || A[i] == '1')
            B[cnt++] = A[i];
        else if (cnt > 0) {
            cnt--;
        }
    }

    for (int i=0; i<cnt; ++i)
        printf("%c", B[i]);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cctype>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

ll mul(ll a,ll b){
    return ((a%MD)*(b%MD)) % MD;
}

ll add(ll a,ll b){
    return (a+b)%MD;
}

int main(){
    ll n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;
    }else if(abs(n-m)==1){
        ll tmp=n-1;
        while(tmp>1){
            n=mul(n,tmp);
            tmp--;
        }
        tmp=m-1;
        while(tmp>1){
            m=mul(m,tmp);
            tmp--;
        }
        cout<<mul(n,m)<<endl;
    }else if(abs(n-m)==0){
        ll tmp=n-1;
        while(tmp>1){
            n=mul(n,tmp);
            tmp--;
        }
        tmp=m-1;
        while(tmp>1){
            m=mul(m,tmp);
            tmp--;
        }
        cout<<mul(2,mul(n,m))<<endl;
    }
    return 0;
}

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

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

using namespace std;

int main() {
  int n, m, c;
  std::cin >> n >> m >> c;
  std::vector<int> b(m);
  std::vector<int> code(n);
  rep(i, m) std::cin >> b[i];
  rep(i, n) {
    rep(j, m) {
      int x = 0;
      std::cin >> x;
      code[i] += x * b[j];
    }
    code[i] += c;
  }

  int ans = 0;
  rep(i, n) {
    if (code[i] > 0) {
      ans++;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    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 {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(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 {
        mint res(*this);
        return res /= a;
    }
};
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<int> cnt(60, 0);
    for (int i = 0; i < N; i++)
        for (int j = 0; a[i] > 0; a[i] >>= 1, j++)
            if(a[i] & 1) cnt[j]++;

    mint ans = 0;
    for (int i = 0; i < 60; i++) {
        mint p = 2;
        ans += p.pow(i) * (N - cnt[i]) * cnt[i];
    }
    cout << ans.x << '\n';
}


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

int main() {
    int K; string S;
    cin >> K; cin >> S;
    if(K>=S.size()) cout << S << endl;
    else{
        S=S.substr(0,K);
        S=S+"...";
        cout << S << endl;
    }
}


Measured memory_bytes: 3548
import sys
h, n = map(int, input().split())
waza = []
effic = []
for _ in range(n):
    a, b = map(int, sys.stdin.readline().split())
    waza.append([a, b])
dp = [10**10] * (h+1)
dp[0] = 0
for i in range(n):
    for j in range(h):
        if dp[j] != 10**10:
            target = j + waza[i][0]
            if target > h:
                target = h
            if dp[target] > dp[j] + waza[i][1]:
                dp[target] = dp[j] + waza[i][1]
print(dp[h])


Measured memory_bytes: 43096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  if(s[0]=='A'){
    bool ok = 0;
    int t = -1;
    for(int i = 2;i<s.size()-1;i++){
      if(s[i]=='C'){
        ok=1;
        t=i;
      }
    }
    if(t>0){
      bool c = 1;
      rep(i,s.size()){
        if(i==0||i==t)continue;
        if(s[i]>'z'||s[i]<'a')c=0;
      }
      if(ok&&c){
        cout << "AC" << endl;
        return 0;
      }
    }
  }
  cout << "WA" << endl;
}

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

using namespace std;
const int maxn = 4;
int main()
{
    double n;
    while (cin >> n) {
        for (double i = n; i >= 1; i = i - 1) {
            if (sqrt(i) == (int)sqrt(i)) {
                cout << (long long)i << endl;
                break;
            }
        }
    }
    return 0;
}


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

int main(){
  int a = (cin >> (a), a),
   b = (cin >> (b), b),
   c = (cin >> (c), c),
   d = (cin >> (d), d);

  if((a*b) >= (c*d))
 cout << a*b;
  else
   cout << c*d;

  //system("pause");
  return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        p = list(map(int, input().split()))
        if 100 in p:
            print("A")
        elif (p[0] + p[1]) // 2 >= 90:
            print("A")
        elif sum(p) // 3 >= 80:
            print("A")
        elif sum(p) // 3 >= 70:
            print("B")
        elif sum(p) // 3 >= 50 and (p[0] >= 80 or p[1] >= 80):
            print("B")
        else:
            print("C")

Measured memory_bytes: 7716
from math import sqrt
n, m = map(int, input().split())

ans = 1
for i in range(1, int(sqrt(m)) + 1):
    if m % i == 0:
        if m // i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
long double a[100001], b[100001], c[100001], d[100001], m, minx; int n;
long double solve2(long double W) {
	long double sum = 0;
	for (int i = 0; i < n; i++) { long double E = d[i] - W*a[i]; E /= c[i]; if (E < 0)E = 0; sum += E*b[i]; }
	minx = min(minx, W*m + sum); return W*m + sum;
}
long double solve() {
	long double L = 0, R = 1e12, a1, a2;
	for (int i = 0; i < 250; i++) {
		a1 = L + 1.0l*(R - L) / 3.0l; a2 = L + 2.0l*(R - L) / 3.0l;
		long double p1 = solve2(a1), p2 = solve2(a2);
		if (p1 < p2)R = a2; if (p1 > p2)L = a1;
	}
	return minx;
}
int main() {
	while (true) {
		cin >> n; minx = 1e18; if (n == 0)break; cin >> m;
		for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i] >> d[i];
		cout << fixed << setprecision(100) << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 7540
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string s[20];
	while(cin>>s[5]){
		s[5]="00000"+s[5];
		for(int i=6;i<13;i++){
			cin>>s[i];
			s[i]="00000"+s[i];
		}
		for(int i=5;i<13;i++){
			for(int j=5;	j<13;j++){
				if(s[i][j]=='1'){
					if(s[i+1][j+1]=='1'&&s[i+1][j]=='1'&&s[i][j+1]=='1'){cout<<'A'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+2][j]=='1'&&s[i+3][j]=='1'){cout<<'B'<<endl;goto L;}
					if(s[i][j+1]=='1'&&s[i][j+2]=='1'&&s[i][j+3]=='1'){cout<<'C'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+1][j-1]=='1'&&s[i+2][j-1]=='1'){cout<<'D'<<endl;goto L;}
					if(s[i+1][j+1]=='1'&&s[i][j+1]=='1'&&s[i+1][j+2]=='1'){cout<<'E'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+1][j+1]=='1'&&s[i+2][j+1]=='1'){cout<<'F'<<endl;goto L;}
					if(s[i+1][j]=='1'&&s[i+1][j-1]=='1'&&s[i][j+1]=='1'){cout<<'G'<<endl;goto L;}
				}
			}
		}L:;
	}
}

Measured memory_bytes: 3188
N = int(input())
*A, = map(int, input().split())
counter = {0: 0, 2: 0, 4: 0}
for a in A:
    _, r = divmod(a, 4)
    if r == 0: counter[4] += 1
    elif r == 2: counter[2] += 1
    else: counter[0] += 1
print('Yes' if counter[0] <= counter[4] or (counter[0] == counter[4] + 1 and counter[2] == 0) else 'No')

Measured memory_bytes: 14252
let walk path =
  let (y_max, x_max) = (Array.length path.(0) + 1, (Array.length path)/2 + 1) in
  let move (x,y) dir =
          if dir = "R" then (x,y+1)
          else if dir = "L" then (x,y-1)
          else if dir = "D" then (x+1,y)
          else (x-1, y)
  in
  let turn_right dir =
          if dir = "R" then "D"
          else if dir = "D" then "L"
          else if dir = "L" then "U"
          else "R"
  in
  let turn_left dir = turn_right dir |> turn_right |> turn_right
  in
  let right_is_clear (x,y) dir =
      if dir = "R" && (y = y_max || path.(x*2).(y-1) = 0) then true
      else if dir = "L" && (y = 0 || path.((x-1)*2).(y-1) = 0) then true
      else if dir = "D" && (x = x_max || path.(x*2-1).(y-1) = 0) then true
      else if dir = "U" && (x = 0 || path.(x*2-1).(y) = 0) then true
      else false
  in
  let front_is_clear (x,y) dir =
      right_is_clear (x,y) (turn_left dir)
  in
  let rec loop (x,y) dir turn =
    if (x,y) = (0,0) then ()
    else
      begin
        if (not turn) && right_is_clear (x,y) dir then
          begin
            let d = turn_right dir in
            loop (x,y) d true
          end
        else if front_is_clear (x,y) dir then
          begin
            if not turn then print_string dir;
            loop (move (x,y) dir) dir false
          end
        else begin
            print_string dir;
            let d = turn_left dir in
            loop (x,y) d  false end
        end
  in
  loop (move (0,0) "R") "R" false
;;

let to_array s =
  let n = String.length s in
  Array.init n (fun x -> String.make 1 s.[x] |> int_of_string)
;;

let () =
  let a = Array.init 9 (fun x -> read_line () |> to_array) in
  walk a;Printf.printf "\n"
;;

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

int main(){
    string str;
    int q;
    cin >> str >> q;

    for(int i=0; i<q; i++){
        string order;
        int a, b;
        cin >> order >> a >> b;

        if(order == "print"){
            cout << str.substr(a, b-a+1) << endl;
        }else if(order == "reverse"){
            string tmp = str.substr(a, b-a+1);
            int n = tmp.size();
            for(int i=0; i<n; i++){
                str[i+a] = tmp[n-i-1];
            }
        }else if(order == "replace"){
            string p;
            cin >> p;
            str = str.replace(a, b-a+1, p);
        }
        
    }

    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int a[21][21];
long long dp[1<<21+1];
long long mod=pow(10,9)+7;
int f(int n,long long mask)
{
    if(dp[mask]!=-1)return dp[mask];
    if(mask==(1<<n)-1){dp[mask]=1;return 1;}
    int men=__builtin_popcount(mask);

 long long ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[men][i]==1 && (mask&(1<<i))==0)
        {
            ans=(ans%mod+f(n,mask|(1<<i)%mod))%mod;
        }
    }
    dp[mask]=ans;
    return ans;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)cin>>a[i][j];

    long long mask=0;
    memset(dp,-1,sizeof(dp));
    // cout<< __builtin_popcount(3)<<endl;
    cout<<f(n,mask);
    
}

Measured memory_bytes: 33024
#include <iostream>
#include <string>
using namespace std;
int main() {
  int m[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string w[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
    "Saturday", "Sunday"};
  int x, y;
  while (cin >> x >> y) {
    if (x == 0) break;
    int d = 2;
    while (--x)
      d += m[x];
    d += y;
    cout << w[d % 7] << endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;	
	int res = 0;
	rep (i, N){
		int l, r; cin >> l >> r;
		res += (r - l) + 1;
	} // end rep

	cout << res << endl;

	return 0;
}

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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,r,x,y,m,n;
    	string s;
    	cin>>s;
    	for(i=0;i<s.size();i++)
    	{
    		if(s[i]=='?')s[i]='D';
    	}
    	cout<<s;
    }
    return 0;
}

Measured memory_bytes: 3772
<?php
    list($max, $sum) = explode(" ", trim(fgets(STDIN)));
    
    $count = 0;
    for($i=0;$i<=$max;$i++){
        for($j=0;$j<=$max;$j++){
            $m = $sum - $i - $j;
            if($m>=0&&$m<=$max){
//                echo $i," ",$j," ",$m,PHP_EOL;
                $count++;
            }
        }
    }

    echo $count;
 
?>  

Measured memory_bytes: 3452
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b)%mod;}
ll allmask  , n ;
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
vector<vector<ll>>dp(22 , vector<ll>(2097155,-1));
ll countWays(vector<vector<ll>>& arr , ll man , ll state){

	if(dp[man][state]!=-1)return 
		dp[man][state];

	if(state == allmask)return 1;
	if(man>n)return  0 ;


	ll ans = 0 ;

	for(ll i = 0; i< n; i++){

		if(arr[man][i]==0)continue ; 
		ll x = (1<<i);
		if(x&state)continue;

		ll newstate = x|state ; 

		add_self(ans ,countWays( arr , man + 1 , newstate));

	}

	// add_self(ans , man+1)

	return dp[man][state] = ans ;



}


signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>> n ;
vector<vector<ll>>arr(n,vector<ll>(n));
for(auto &i:arr)for(auto &j:i)cin>>j;

allmask =(1<<n)-1;

cout<<countWays(arr , 0 , 0 );


	
}

Measured memory_bytes: 377216
// E - Rem of Sum is Num

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];
ll cumA[200001];
ll M[200001];

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

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

	for (int i=1; i<=N; i++) {
		cumA[i] = cumA[i-1] + A[i-1];
		M[i] = (cumA[i] - i) % K;
	}

	ll ans = 0;

	// **** debug : この方法でカウントするとTLE ****
	/*
	for (int i=0; i<N; i++) {
		for (int j=i+1; j<=N; j++) {
			if ((j - i < K) && (M[i] % K == M[j] % K)) {
				ans++;
			}
		}
	}
	*/

	map<ll, ll> M_cnt; // 0 < j - i < K の範囲でのMの度数分布
	// i = 0
	for (int j=1; j<K && j<=N; j++) {
		M_cnt[M[j]]++;
	}

	for (int i=0; i<N; i++) {
		ans += M_cnt[M[i]];

		// 度数分布をスライド
		M_cnt[M[i+1]]--;
		if (i+K <= N) M_cnt[M[i+K]]++;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long ab, bc, ac;
  ab = a * b * ((c + 1) / 2) - a * b * (c / 2);
  bc = b * c * ((a + 1) / 2) - b * c * (a / 2);
  ac = a * c * ((b + 1) / 2) - a * c * (b / 2);
  cout << min(ab, min(bc, ac));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cake = 4;
		int donut = 7;
		for(int i=0;i<=(N/cake);i++) {
			for(int j=0;j<=((N-i*cake)/donut);j++) {
				if(cake*i+donut*j==N) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
const int N = 300050;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
int mod = 1000000007;
bool vis[N];
int sum[N>>1];
void get()
{
	memset(vis, 0, sizeof(vis));
	for (int i = 2; i < N; i++) if (!vis[i])
	{
		for (int j = i+i; j < N; j += i)
			vis[j] = true;
	}
}
int main()
{
	///freopen("in.txt", "r", stdin);
	get();
	int q;
	sum[0] = 0;
	vis[1] = 1;
	for (int i = 1; i <= 1e5; i += 2)
	{
		if (!vis[i] && !vis[(i+1)>>1])
			sum[i] = 1;
		
	}
	for (int i = 1; i <= 1e5; i++)
		sum[i] += sum[i-1];
	while (~scanf("%d", &q))
	{
		while (q--)
		{
			int l, r;
			scanf("%d%d", &l, &r);
			printf("%d\n", sum[r] - sum[l-1]);
		}
	}
   	return 0;
}

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

int main()

{
	int n,i,d=0;
	string s;
	cin>> n >>s;
	d=n;
	for(i=0;i<n-1;i++)	
	if(s[i]==s[i+1])
	d-=1;
	cout << d;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

# A - We Love Golf
k = int(input())
a, b = map(int, input().split())
i = 1

while True:
	ki = k * i
	
	if ki >= a and ki <= b:
		print('OK')
		sys.exit()
	elif ki > 1000:
		break
	
	i += 1

print('NG')

Measured memory_bytes: 9136
def resolve():
  c = []
  c.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
  c.append(list(map(int, input().split())))
  a01 = c[0][0] - c[0][1]
  a02 = c[0][0] - c[0][2]
  a12 = c[0][1] - c[0][2]
  b01 = c[0][0] - c[1][0]
  b02 = c[0][0] - c[2][0]
  b12 = c[1][0] - c[2][0]
  for i in range(3):
    if ((c[i][0] - c[i][1]) != a01) or (c[i][0] - c[i][2] != a02) or (c[i][1] - c[i][2] != a12):
      return False
    if ((c[0][i] - c[1][i]) != b01 or (c[0][i] - c[2][i]) != b02 or (c[1][i] - c[2][i]) != b12):
      return False

  return True

if __name__ == "__main__":
  if (resolve()):
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 3188
use std::collections::BTreeSet;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let b: Vec<usize> = sc.vec(m);

    let mut a_set = BTreeSet::new();
    for &a in a.iter() {
        a_set.insert(a);
    }

    let mut and_ans = vec![];
    for &b in b.iter() {
        if a_set.contains(&b) {
            and_ans.push(b);
        }
    }

    let mut or_set = BTreeSet::new();
    for &a in a.iter() {
        or_set.insert(a);
    }
    for &b in b.iter() {
        or_set.insert(b);
    }

    sc.write(format!("{} {}\n", and_ans.len(), or_set.len()));
    for and in and_ans.into_iter() {
        sc.write(format!("{}\n", and));
    }
    for or in or_set.into_iter() {
        sc.write(format!("{}\n", or));
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)


int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int A,B,C;
   ull ans=0;
   cin>>A>>B>>C;
   int MAX = max(A,max(B,C));
   int a=MAX-A;
   int b=MAX-B;
   int c=MAX-C;
   ans=a/2+b/2+c/2;
   if(a%2+b%2+c%2==2)ans+=1;
   else if(a%2+b%2+c%2==1)ans+=2;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
dice1 = Dice()
table1 = list(map(int,input().split()))
dice1.setNumber(table1[0], table1[1], table1[2], table1[3], table1[4], table1[5])
dice2 = Dice()
table2 = list(map(int,input().split()))
dice2.setNumber(table2[0], table2[1], table2[2], table2[3], table2[4], table2[5])
for loc in "NNNNWNNNWNNNENNNENNNWNNN":
  dice2.roll(loc)
  if dice2.number==dice1.number:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 5616
#include<stdio.h>

int main()
{
     int a,b,c;
     scanf("%d %d %d",&a,&b,&c);
     if(a < b){
          if(a < c){
               printf("%d ",a);
                    if(b < c){
                        printf("%d %d\n",b,c);
                    }else {
                        printf("%d %d\n",c,b);
                    }
          }else {
               printf("%d %d %d\n",c,a,b);
          }
     }else {
         if(b < c){
             printf("%d ",b);
                if(a < c){
                    printf("%d %d\n",a,c);
                }else {
                    printf("%d %d\n",c,a);
                }
         }else {
             printf("%d %d %d\n",c,b,a);
         }
     }
     return 0;
}


Measured memory_bytes: 2056
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,u,v = inputIL()
l = inputILL(N-1)

if u==v:
  print(0)
  exit()

dic = dict([(i,[]) for i in range(1,N+1)])
 
for i in l:
  dic[i[0]].append(i[1])
  dic[i[1]].append(i[0])

du = [INF for i in range(N+1)]
du[u] = 0
q = deque([u])

while q:
  x = q.popleft()
  nd = du[x]+1
  for nx in dic[x]:
    if nd < du[nx]:
      du[nx] = nd
      q.append(nx)
      
dv = [INF for i in range(N+1)]
dv[v] = 0
q = deque([v])

while q:
  x = q.popleft()
  nd = dv[x]+1
  for nx in dic[x]:
    if nd < dv[nx]:
      dv[nx] = nd
      q.append(nx)
  
best = 0
pos = None
for i in range(1,N+1):
  if du[i] < dv[i]:
    if best < dv[i]:
      best = dv[i]

print(best-1)

Measured memory_bytes: 120532
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll num = sqrt(n);
    vector<ll>vec;
    for(int i=num;i>0;i--)
    {
        if(n%i==0)
        {

            vec.push_back(i+(n/i)-2);
        }
    }
    sort(vec.begin(),vec.end());

    cout<<vec[0]<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,k,x;
string s;
int main(){
	n=read(),k=read(),cin >> s;
	for(int i=1;i<n;i++)
		if(s[i]==s[i-1])x++;
	printf("%d",x+min(n-x-1,2*k));
	return 0;
}

Measured memory_bytes: 512