akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    int N;
    cin >> N;
    stack<int> s;
    int64_t cnt = 1;
    if (N == 0){
        cout << 0;
    }
    while(N != 0){
        if (N == cnt){
            s.push(1);
            N -= cnt;
            break;
        }
        if (N % (cnt * 2) != 0){
            //cout << "cnt " << cnt << endl;
            s.push(1);
            N -= cnt;
        }
        else{
            s.push(0);
        }
        cnt *= -2;
        //cout << N << endl;
    }
    //cout << "OK" << endl;
    while(!s.empty()){
        int x = s.top();
        s.pop();
        cout << x;
    }
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int x;cin >> x;
    int i = 1;
    int p = 0;
    while(true){
        p += i;
        if(p>=x)break;
        i++;
    }
    cout << i <<"\n";

    return 0;
}

Measured memory_bytes: 256
//confirm 0LL and 1LL
//confirm cornercases such as 0
//confirm times of cin < 1^6
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(T n){cout << n << endl;}
template <typename T>
void cosp(T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	VecP p(n+1);
	repn(i, n){
		cin >> p[i].fs;
		p[i].sc = i;
	}
	sort(all(p));

	Vec noSwap1(n), noSwap2(n+1);
	repn(i, n) if(i != 1 && p[i].sc > p[i].sc) noSwap1[i] = noSwap1[i-1]+1;
	repnr(i, n) if(i != n && p[i].sc < p[i+1].sc) noSwap2[i] = noSwap2[i+1]+1;
	ll ans = 0;
	repn(i, n) chmax(ans, noSwap1[i]+noSwap2[i]);
	ans = n-1-ans;
	co(ans);

	return 0;
}


Measured memory_bytes: 6528
//contact me:subhajitmahata06@gmail.com 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h> 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;i<n;i++)
#define fr(i,k,n) for(ll i=k;i>n;i--)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define int ll
//===========================templates=========================
 int32_t main() {
    fast;
    ll n,k;
    cin>>n>>k;
    ll res=0;
    vl a(n,0); 
    fo(i,n) cin>>a[i];
    if(n>0)
    sortall(a);
    int r=n-k;
    if(r>0)
    {
        fo(i,r)
        res+=a[i];
    }
    cout<<res;
	return 0;
}


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

const int32_t MAX_N = 50;
const int32_t MOD = 1e9 + 7;

class Matrix {
public:	
	int32_t n, m;
	int32_t **vals;

	Matrix() : n(0), m(0), vals(nullptr) {}
	Matrix(int32_t pN, int32_t pM) : n(pN), m(pM) {
		vals = new int* [n];
		for(int32_t i = 0; i < n; i++) {
			vals[i] = new int [m];

			for(int32_t j = 0; j < m; j++) {
				vals[i][j] = 0;
			}
		}
	}

	Matrix operator* (const Matrix &o) const {
		Matrix ans = Matrix(n, o.m);

		for(int32_t i = 0; i < ans.n; i++) {
			for(int32_t j = 0; j < ans.m; j++) {
				for(int32_t p = 0; p < m; p++) {
					ans.vals[i][j] = ((int64_t) ans.vals[i][j] + (int64_t) vals[i][p] * o.vals[p][j]) % MOD;
				}
			}
		}

		return ans;
	}

	static Matrix RaiseToPower(const Matrix &mat, int64_t pw) {
		if(pw == 1) {
			return mat;
		}
		else if(pw % 2 == 0) {
			Matrix aux = RaiseToPower(mat, pw / 2);
			return aux * aux;
		}
		else {
			Matrix aux = RaiseToPower(mat, pw - 1);
			return aux * mat;
		}
	}
};

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

	int32_t n;
	int64_t k;
	std::cin >> n >> k;

	Matrix m = Matrix(n, n);

	for(int32_t i = 0; i < n; i++) {
		for(int32_t j = 0; j < n; j++) {
			std::cin >> m.vals[i][j];
		}
	}
	
	Matrix newM = Matrix::RaiseToPower(m, k);
 
	int32_t ans = 0;
	for(int32_t i = 0; i < n; i++) {
		for(int32_t j = 0; j < n; j++) {
			ans = ((int64_t) ans + newM.vals[i][j]) % MOD;
		}
	}

	std::cout << ans << '\n';
}



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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int partner[105];
int n;

vector<pair<int, int> > v;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		partner[i] = n + (n % 2 == 0) - i;
	}
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			if(j != partner[i]){
				v.push_back({i, j});
			}
		}
	}
	
	int z = v.size();
	printf("%d\n", z);
	for(auto e: v){
		printf("%d %d\n", e.first, e.second);
	}
	return 0;
}


Measured memory_bytes: 384
n = int(input())
X = []
for i in range(n):
  x,l = map(int,input().split())
  ll = x-l
  rr = x+l
  X.append((x,l,ll,rr))

if n == 1:
  print(n)
else:
  XL = sorted(X, key=lambda x: x[3])

  # print(XL)

  ans = 0
  temp = -1 * (10**9)

  for i in range(n):
    if temp <= XL[i][2]:
      ans += 1
      temp = XL[i][3]

  print(ans)





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

ll N,X,Pat[51],Lay[51],L,ans;

ll count(ll X,ll L){
    if(X==0)return 0;
    if(X==Lay[L])return Pat[L];
    if(X>=(Lay[L]+1)/2) return (Pat[L]+1)/2 + count(X-(Lay[L]+1)/2,L-1);
    else return count(X-1,L-1);
}

int main(void){
    cin >> N >> X;
    Pat[0] = 1,Lay[0]=1;
    rep(i,N){
        Pat[i+1] = 2*Pat[i]+1;
        Lay[i+1] = 2*Lay[i]+3;
        //cout << Pat[i+1] << " " << Lay[i+1] << endl;
    }
    
    cout << count(X,N)<<endl;
    
}


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

int main() {
	double n;
	cin >> n;
	double ans =  2 * n * 3.141592;
	
	cout << ans << endl;
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	vector<vector<long>> B(4, vector<long> (3, 0));
	B.at(0).at(1)=1;
	B.at(1).at(1)=2;
	B.at(2).at(1)=4;
	B.at(3).at(1)=8;
	for (long i=0; i<4; i++) {
		cin >>B.at(i).at(2);
		B.at(i).at(0)=B.at(i).at(2)*8/B.at(i).at(1);
	}
	long N;
	cin >>N;
	N *=4;
	sort(B.begin(), B.end());
	long S=0;
	for(long i=0; i<4; i++) {
		long U=N/B.at(i).at(1);
		S +=U*B.at(i).at(2);
		N -=U*B.at(i).at(1);
	}
	cout <<S <<endl;
	return 0;
}



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

using namespace std;

vector<long long> primes;

void gen_primes(){
  primes.push_back(2);
  for(int long long i=3;i<=100;i+=2){
    bool is_ok=true;
    for(int j=0;j<primes.size();j++){
      if(i%primes[j]==0){
        is_ok=false;
        break;
      }
    }
    if(is_ok)primes.push_back(i);
  }
}

int main(){
  int n;
  cin >> n;
  gen_primes();
  map<int, int> mp;
  for(int i=2;i<=n;i++){
    int tmp=i;
    int j=0;
    while(tmp>1){
      while(tmp%primes[j]==0){
        mp[primes[j]]++;
        tmp/=primes[j];
      }
      j++;
    }
  }
  int cnt3=0, cnt5=0, cnt15=0, cnt25=0, cnt75=0;
  for(auto p: mp){
    if(p.second>=4)cnt5++;
    if(p.second>=2)cnt3++;
    if(p.second>=14)cnt15++;
    if(p.second>=24)cnt25++;
    if(p.second>=74)cnt75++;
  }
  if(cnt3>=3&&cnt5>=2){
    cout << cnt5*(cnt5-1)*(cnt3-2)/2+cnt15*(cnt5-1)+cnt25*(cnt3-1)+cnt75 << endl;
  }
  else{
    cout << 0 << endl;
  }
}



Measured memory_bytes: 3604
def main():
    a, b, c = map(int, input().split())
    k = int(input())

    op = 0
    while not (a < b and b < c):
        if not a < b:
            b *= 2
            op += 1
        elif not b < c:
            c *= 2
            op += 1

    if op <= k:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int x = a + b;
			int d = 0;
			
			while(x != 0){
				x /= 10;
				d++;
			}
			
			System.out.println(d);
		}
		
		sc.close();
	}

}

Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    ll n = b - a + 1;
    if (a % 2)
    {
        ans = a;
        n--;
    }
    if (n % 2 == 0)
    {
        if ((n / 2) % 2 == 0)
        {
            ans = ans ^ 0;
        }
        else
        {
            ans = ans ^ 1;
        }
    }
    else
    {
        n--;
        if ((n / 2) % 2 == 0)
        {
            ans = ans ^ 0;
            ans = ans ^ b;
        }
        else
        {
            ans = ans ^ 1;
            ans = ans ^ b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int num(int n, int p[]) {
	int count = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i; j < n; j++)
			if (p[i] > p[j])
				count++;
		count *= n - i - 1;
	}
	return count;
}
 
int main(void) {
	int n;
	int p[8], q[8];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &p[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &q[i]);
	printf("%d\n", abs(num(n, p) - num(n, q)));
	return 0;
}

Measured memory_bytes: 128
// Amsal Shoma Ro Gaedan Ye Amal Pasandidas !

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str s;
	cin >> s;
	cout << s.substr(0, 3) << '\n';
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main() {
	int l, r, d;
	
	scanf("%d%d%d", &l, &r, &d);
	
	int count = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  ll n;
  cin>>n;
  for(int i=1;i<10;++i){
    for(int j=1;j<10;++j){
      if(i*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
using namespace std;

int main(){
    int n,m;
    int k;
    int a;
    int cnt;
    cin >> n >> m;
    vector<int> v(m,0);
    for (int i = 0;i < n ; i++){
        cin >> k;
        for (int j = 0 ; j < k ; j++){
            cin >> a;
            v.at(a-1) += 1;
        }
    }
    for(int i = 0 ; i < v.size() ; i++){
        if (v.at(i) == n){
            cnt +=1 ;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

vector<vector<ll>> graph(100007, vector<ll>(0));  // DAG
vector<ll> order(0);  // トポロジカルソートされた頂点を格納
vector<bool> used(100007,0);  // 訪問済みフラグ

// 辿れるところまで辿る深さ優先探索
void dfs(ll u){
    if(used[u]) return;
    used[u] = true;
    for(ll v : graph[u]) dfs(v);
    order.emplace_back(u);     // 帰りがけ順で頂点を入れていく
}

// トポロジカルソート
//Nは頂点数
void tsort(ll N){
    for(ll v = 1; v <= N; v++) dfs(v);
    reverse(order.begin(), order.end());
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> x(M,0);
    vector<ll> y(M,0);
    for(ll i=0;i<M;++i){
        cin>>x[i]>>y[i];//x[i]--;y[i]--;
        graph[x[i]].emplace_back(y[i]);
    }
    tsort(N);
    vector<ll> longest(N+1,0);
    for(ll i=N-1;i>=0;--i){
        for(auto p: graph[order[i]]){
            chmax(longest[order[i]],longest[p]+1);
        }
    }
    ll ans=0;
    for(auto p: longest)chmax(ans,p);
    prt(ans)
    //for(ll i=0;i<N;++i)cout<<order[i]<<" ";cout<<endl;
    return 0;
}


Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];
    vector<ll> sum;
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    rep(i, X)
    {

        rep(j, Y)
        {

            rep(k, Z)
            {
                if (i * j * k > K)
                    continue;
                sum.push_back(A[i] + B[j] + C[k]);
            }
        }
    }
    sort(sum.begin(), sum.end(), greater<ll>());
    rep(i, K) cout << sum[i] << endl;
    return 0;
}


Measured memory_bytes: 35176
#include <stdio.h>
#define EPS (0.0001)

int main(void)
{
	double a, b, c, d, e, f;
	
	while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF){
		printf("%.3f %.3f\n",(c * e - f * b) / (a * e - d * b) + EPS, (a * f - d * c) / (a * e - d * b) + EPS);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    string s;cin>>s;
    int L=0,R=0;
    int N=s.size();
    vector<int> ans(N,1);
    REP(i,s.size()-1){
        if(s[i]=='R'&&s[i+1]=='R'){
            ans[i+2]+=ans[i];
            ans[i]=0;
        }
    }
    REP(i,N-1){
        if(s[N-i-1]=='L'&&s[N-i-2]=='L'){
            ans[N-i-3]+=ans[N-i-1];
            ans[N-i-1]=0;
        }
    }
    REP(i,s.size()) cout<<ans[i]<<" \n"[i==s.size()-1];
}

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

int N, M;

int main(){
    cin >> N >> M;
    int gMAX = M / N;
    int ans;
    for(int i = gMAX; i >= 1; i--){
        if(M % i == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


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

int main(){
	string A,S,T;
	int P=0;
	int n;
	cin>>A;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>S;
		T=S+S;
		for(int j=0;j<10;j++){
			if(T.substr(j,A.length())==A){
				P++;
				break;
			}
		}
	}
	cout<<P<<endl;
	return 0;
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int k, a, b;
  cin >> k >> a >> b;
  int t = min(k, a - 1);
  k -= t;
  int ans = 1 + t;
  if (b >= a + 2) ans += (b - a) * (k / 2) + k % 2;
  else ans += k;
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3600
from collections import deque

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

tree=[[] for i in range(n)]
for i in range(n-1):
 i,j=map(int,input().split())
 tree[i-1].append(j-1)
 tree[j-1].append(i-1)

t_cnt=[0 for i in range(n)]
for i in range(q):
 p,x=map(int,input().split())
 t_cnt[p-1]+=x

cnt=[-1]*n
cnt[0]=t_cnt[0]

seen=set([0])

dq=deque()
dq.append(0)

while dq:
 x=dq.popleft()
 for i in tree[x]:
#  if cnt[i]==-1:
   if i in seen:
    continue
   else:
    seen.add(i)
    dq.append(i)
    cnt[i]=cnt[x]+t_cnt[i]

print(*cnt)

Measured memory_bytes: 70248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main implements Runnable {

    private int[] s;
    
    public static void main(String[] args) {
	Main m = new Main();
	m.run();
    }

    private void set() {
	try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
	    s = Arrays.stream(br.readLine().split("")).mapToInt(this::convert).toArray();
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }

    @Override
    public void run() {
	set();
	long n = 0;
	long m = 0;
	for (int i=0;i<s.length;i++) {
	    if (s[i] == 0) {
		m++;
	    } else {
		n += m;
	    }
	}
	System.out.println(n);
    }

    private int convert(String t) {
	if (t.equals("B")) return 0;
	if (t.equals("W")) return 1;
	return -1;
    }
}

Measured memory_bytes: 51752
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readLine().toInt
    val arr = io.StdIn.readLine().split(' ').map(x => {
      val a = x toInt;
      if (1 <= a && a < 400) 0;
      else if (400 <= a && a < 800) 1;
      else if (800 <= a && a < 1200) 2;
      else if (1200 <= a && a < 1600) 3;
      else if (1600 <= a && a < 2000) 4;
      else if (2000 <= a && a < 2400) 5;
      else if (2400 <= a && a < 2800) 6;
      else if (2800 <= a && a < 3200) 7;
      else 8
    })

    val (fixs, anys) = arr.partition(_ < 8)
    val anyNum = anys.length
    val colors = fixs.distinct
    val (min, max) = if (anyNum == 0) (colors.length, colors.length)
    else {
      if (colors.length == 0) {
        (1, anyNum)
      } else {
        (colors.length, colors.length + anyNum)
      }
    }

    println(min.toString + ' ' + max.toString
    )
  }
}

Measured memory_bytes: 25540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace cShaprTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            int Q = input[1];
            var S = Console.ReadLine();
            var l = new int[Q];
            var r = new int[Q];

            for (var i = 0; i < Q; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                l[i] = input[0];
                r[i] = input[1];
            }

            var map = new Dictionary<int, int>();
            var sums = new int[S.Length + 1];
            for (var s = 1; s < S.Length; s++)
            {
                if (S[s] == 'C' && S[s - 1] == 'A')
                {
                    sums[s] = sums[s - 1] + 1;
                }
                else
                {
                    sums[s] = sums[s - 1];
                }
            }


            for (var i = 0; i < Q; i++)
            {
                var start = l[i] - 1;
                var end = r[i] - 1;

                Console.WriteLine(sums[end] - sums[start]);
            }
        }
    }
}

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

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

    int ans = n * 2;
    int same = 0;
    rep(i, n) {
        int now = 0;
        for (int j = 0; j < n; j++) {
            if (s[j + i] == t[j])
                now++;
            else
                break;
        }
        same = max(same, now);
    }

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


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

using namespace std;

int main() {
    int N;
    stack<char> stk;
    string s;
    string l = "", r = "";

    cin >> N;
    cin >> s;
    string ans = s;

    int size = s.size();
    for (int i = 0; i < s.size() - 1; ++i) {
        if (s[i] == '(' && s[i + 1] == ')') {
            s.erase(s.begin() + i, s.begin() + i + 2);
            i -= 2;
            size -= 2;
            continue;
        }
    }
    for (char c : s) {
        if (c == '(')
            r += ")";
        else if (c == ')')
            l += "(";
    }
    cout << l + ans + r << endl;
    return 0;
}

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

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

	vector<vector<int>> dp(a.size(),vector<int>(b.size()));
	// dp[i][j] will store the length of the longest subsequence till i-th indx in string-a and j-th indx in string-b
	for(int i=0;i<a.size();i++){
		for(int j=0;j<b.size();j++){
			if(a[i]==b[j])
				dp[i][j] = 1 + ((i-1>=0 and j-1>=0) ? dp[i-1][j-1] : 0);
			else{
				dp[i][j] = max(j-1<0?0:dp[i][j-1],i-1<0?0:dp[i-1][j]);
			}
		}
	}

	int i=a.size()-1,j=b.size()-1;
	// cout<<dp[i][j]<<endl;
	string ans="";
	while(i>=0 and j>=0){
		if(a[i]==b[j]){
			ans=a[i]+ans;
			i--;
			j--;
		}
		else{
			if(i==0)
				j--;
			else if(j==0)
				i--;
			else if(dp[i][j-1]>=dp[i-1][j])
				j--;
			else
				i--;
		}
	}
	cout<<ans<<endl;
	/*
	vector<vector<string>> dp((int)a.size(),vector<string>((int)b.size(),""));
	// dp[i][j] will store the longest subsequence till i-th indx in string-a and j-th indx in string-b
	for(int i=0;i<a.size();i++){
		for(int j=0;j<b.size();j++){
			if(a[i]==b[j])
				dp[i][j]=((i-1>=0 and j-1>=0) ? dp[i-1][j-1] : "") + a[i];
			else{
				string p = (i-1>=0 ? dp[i-1][j] : "");
				string q = (j-1>=0 ? dp[i][j-1] : "");
				dp[i][j] = ((int)p.size()>(int)q.size()?p:q);
			}
		}
	}
	cout<<dp[a.size()-1][b.size()-1]<<endl;
	return 0;
	*/
}

Measured memory_bytes: 35584
N,M=map(int,input().split())
def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            siz[a]+=siz[b]
        else:
            par[a]=b
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1
            

def size(a):
    return siz[find(a)]

def same(a,b):
    return find(a)==find(b)

ab=[]
for i in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    ab.append([A,B])
res=0

for i in range(M):
    par=[j for j in range(N)]
    siz=[1 for _ in range(N)]
    rank=[0 for _ in range(N)]
    for j in range(M):
        if(i==j):
            continue
        union(ab[j][0],ab[j][1])
    for i in range(1,N):
        if(not same(0,i)):
            res+=1
            break
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<bool> x(n);
	int ans = 0;
	for(int i=0;i<n;i++){
		x.at(i) = false;
	}
	for(int i=0;i<k;i++){
		int d;
		cin >> d;
		for(int j=0;j<d;j++){
			int a;
			cin >> a;
			x.at(a-1) = true;
		}
	}
	for(int i=0;i<n;i++){
		if(!x.at(i)){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int n, m;

		n = scan.nextInt();
		m = scan.nextInt();

		if (m == 4 || m == 5) {
			System.out.println(-1);
			return;
		}

		int s[] = new int[m];
		int c[] = new int[m];

		//一度書き込みした桁数を保存する
		Map<Integer, Integer> map = new HashMap<>();

		for (int i = 0; i < m; i++) {
			boolean update_flg = false;
			int s_tmp;
			int c_tmp;

			s_tmp = scan.nextInt();
			c_tmp = scan.nextInt();

			if (map.containsKey(s_tmp)) {
				update_flg = true;

			}

			if (update_flg) {
				if (map.get(s_tmp) != c_tmp) {
					System.out.println(-1);
					return;
				}
			}
			s[i] = s_tmp;
			c[i] = c_tmp;

			map.put(s_tmp, c_tmp);
		}

		//ans は1桁から持つ
		int ans[] = new int[n + 1];

		for (int k = 0; k < m; k++) {
			//1桁目が0だったらエラー
			if (n != 1) {
				if (s[k] == 1) {
					if (c[k] == 0) {
						System.out.println(-1);
						return;
					}
				}
			}

			ans[s[k]] = c[k];

		}

		if (n != 1) {
			if (ans[1] == 0) {
				ans[1] = 1;
			}
		}

		//文字列として結合
		String ansString = "";

		for (int j = 1; j <= n; j++) {
			ansString += ans[j];
		}

		System.out.println(ansString);

	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			a = myMod(a, primeNumMod);

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


Measured memory_bytes: 22868
hasA = false
hasB = false
hasC = false
gets.each_char do |c|
  #puts c
  if c == 'a'
    hasA = true
  elsif c == 'b'
    hasB = true
  elsif c == 'c'
    hasC = true
  end
end

if hasA && hasB && hasC
  puts "Yes"
else
  puts "No"
end


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

N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for i in range(101):
    for j in range(101):
        for x, y, h in xyh:
            if h != 0:
                H = h + abs(i - x) + abs(j - y)
                for x, y, h in xyh:
                    if h != max(H - abs(i - x) - abs(j - y), 0):
                        break
                else:
                    print(i, j, H)
                    exit()

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

const int N = 100005;
vector<pair<int, ll> > g[N];
ll dist[N];
 
void dfs(int v, int p){
	for(auto x : g[v]){
		if(x.first == p)continue;
		dist[x.first] = dist[v] + x.second;
		dfs(x.first, v);
	}
}
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);
 
	int n; cin>>n;
	for(int i = 1; i < n; i++){
		int u, v, w;
		cin>>u>>v>>w;
        //相手と距離
		g[u].push_back({v, w%2});
		g[v].push_back({u, w%2});
	}
    //根は1
	dist[1] = 0; dfs(1, -1);
	for(int i = 1; i <= n; i++){
        //dist[i]&1でビットごとのAND、すなわち奇数のとき1、偶数のとき0で塗分け可能。
		cout<<(dist[i]&1)<<'\n';
	}
 
 
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string.h>

using namespace std;

const int mod=1e9+7, Log=30, maxn=1e5+5;
typedef long long ll;

inline int sum(int a, int b){
	if(a+b>=mod){
		return a+b-mod;
	}
	else if(a+b<0){
		return a+b+mod;
	}
	return a+b;
}

inline int mul(int a, int b){
	return (ll)a*b%mod;
}

inline int pot(int a, int b){
	int sol=1;
	for(int i=0; i<Log; i++){
		if(b&(1<<i)){
			sol=mul(sol, a);
		}
		a=mul(a, a);
	}
	return sol;
}

int komb[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int br;
	int uk;
	int sol=0;
	for(int i=k; i>0; i--){
		br=1;
		uk=0;
		for(int j=i*2; j<=k; j+=i){
			uk=sum(uk, komb[j]);
			br++;
		}
//		cout << i << " " << br << '\n';
		komb[i]=sum(pot(br, n), -uk);
		sol=sum(sol, mul(komb[i], i));
	}
	cout << sol << '\n';
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n;
    cin>>n;
    long long dp[n+10][3];
    int a[n];
    int b[n];
    int c[n];
    rep(i,n){
        cin>>a[i+1]>>b[i+1]>>c[i+1];
    }
    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for (int i=2;i<n+1;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));


    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      
      int number = 0;
      while(scan.hasNext()) {
         if(scan.hasNextInt()) {
            number = scan.nextInt();
            System.out.println(number * number * number);
         }
      }
   }
}


Measured memory_bytes: 26108
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
	  fac[i] = fac[i-1] * i % MOD;
	  inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
	  finv[i] = finv[i-1] * inv[i] % MOD;
	}
}
//組み合わせ
long long COM (int n, int k) {
	if(n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
void solve() {
	int n; cin >> n;
	vector<vector<int>> to(n);
	vector<vector<int>> cost(n);
	rep (i, n - 1) {
		int a, b, w; cin >> a >> b >> w;
		--a; --b;
		to[a].push_back(b); cost[a].push_back(w);
		to[b].push_back(a); cost[b].push_back(w);
	}
	queue<int> q;
	vector<int> ans(n, -1);
	//bfs
	q.push(0);
	while(!q.empty()) {
		int v = q.front(); q.pop();
		rep (i, to[v].size()) {
			int u = to[v][i];
			int w = cost[v][i];
			if (ans[u] != -1) continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}
	rep (i, n) {
		cout << ans[i] << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 11904
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("Impossible"),0;
#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,l,a[N],z[N],tot,p;
signed main(){
	n=read();l=read();
	F(i,1,n) a[i]=read();int p=0;
	F(i,2,n) if (a[i]+a[i-1]>=l) p=i;
	if (!p) ret;
	p--;z[++tot]=p;D(i,p-1,1) z[++tot]=i;
	F(i,p+1,n-1) z[++tot]=i;
	puts("Possible");
	D(i,tot,1) wrn(z[i]);
	return 0;
}

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

int main() {
    ll a,b,c;
    std::cin >> a>>b>>c;
    ll k;
    std::cin >> k;
    for (int i = 0; i < pow(3,k); i++) {
        ll ta,tb,tc;
        ta = a;
        tb = b;
        tc = c;
        ll now = i;

        for (int j = 0; j < k; j++) {
            if((i/(ll)pow(3,j))%3==0){
                ta *= 2;
            }else if((i/(ll)pow(3,j))%3==1){
                tb *= 2;
            }else{
                tc *= 2;
            }
        }
        if(ta<tb&&tb<tc){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 4096
INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i + arr[j]] = max(dp[i + arr[j]], dp[i] + 1)
ans = ''
while(N>0):
    for i in src[::-1]:
        if N - arr[i] >= 0 and dp[N-arr[i]] == dp[N] - 1:
            ans += str(i)
            N -= arr[i]
            break
print(ans if ans else 0)

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

int main() {
    int n, l, r;
    ll ans=0;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int r;
    while(cin>>r)
    {
        cout<<r*r<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
suma = sum(a)

for i in range(n):
    c = min(a[i], b[i])
    a[i] -= c
    a[i + 1] -= min(a[i + 1], b[i] - c)

print(suma - sum(a))

Measured memory_bytes: 19116
"""Counting Sort."""

def countingSort(A, n):
    """Sort the elements of list A with Counting Sort algorithm.

    n is the length of A.
    The elements of A are intergers between 0 and k, inclusive.
    B is the output list where the sorted elements will be arranged.
    
    Print the elements of B in a line separated by a space character.
    """

    k = max(A)
    
    C = [0 for i in range(k + 1)]

    for i in A:
        C[i] += 1

    for i in range(1, k + 1):
        C[i] = C[i] + C[i - 1]

    B = [0 for i in range(n + 1)]
    
    for i in A[::-1]:
        B[C[i]] = i
        C[i] -= 1

    print(*B[1:])


n = int(input())

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

countingSort(A, n)

Measured memory_bytes: 231232
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  vector<int> kind(110,0);
  int p[3];
  for (int i=0; i<3; i++) cin >> p[i];
  for (int i=0; i<3; i++) {
    kind[p[i]]++;
  }
  int cnt = 0;
  for (int i=0; i<110; i++) {
    if (kind[i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            string ans = "";
            foreach (string line in lines)
            {
                ans += ((char)(line[0] + ('A' - 'a'))).ToString();
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
using namespace std;

void Time() {
	int S;
	cin >> S;

	cout << S / 3600 << ":" << S % 3600 / 60 << ":" << S % 60 << endl;
}
int main() {
	Time();
}



Measured memory_bytes: 3092
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;



long long int N,M,res=0;

long long int a,b,c,D;

char ch[140];
int main()
{
    cout << fixed << setprecision(18);
   cin>>D>>N;
   if(N==100){N++;}
   while(D!=0){
       N*=100;
       D--;
   }
   cout<<N<<endl;
}


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

int main () {
  int n;
  cin >> n;
  string h;
  cin >> h;
  string hh;
  cin >> hh;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (h[j] != hh[j - i]) {
        break;    
      }    
      if (j == n - 1) {
        ans = n - i;
        break;  
      }
    }  
    if (ans != 0) {
      break;  
    }
  }
  cout << (h + hh.substr(ans, n - ans)).size() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[3];
int main()
{
    cin>>a[0]>>a[1]>>a[3];
	if(a[0]-a[1]==a[1]-a[3])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	B := ReadInts(N)

	cnt := make(map[int]int)
	for i := 0; i < N; i++ {
		cnt[A[i]]++
		cnt[B[i]]++
	}
	for _, c := range cnt {
		if c > N {
			fmt.Println("No")
			return
		}
	}

	type Val struct {
		Num, Type int
	}
	c := make([]*Val, 0)
	for i := 0; i < N; i++ {
		c = append(c, &Val{Num: A[i], Type: 0})
		c = append(c, &Val{Num: B[i], Type: 1})
	}
	sort.Slice(c, func(i, j int) bool {
		return c[i].Num < c[j].Num
	})

	type Pair struct {
		X, Y *Val
	}
	pairs := make([]*Pair, N)
	for i := 0; i < N; i++ {
		pairs[i] = &Pair{
			X: c[i],
			Y: c[i+N],
		}
	}

	type0Indices := make([]int, 0)
	type1Indices := make([]int, 0)
	for i := 0; i < N; i++ {
		if pairs[i].X.Type != pairs[i].Y.Type {
			continue
		}
		if pairs[i].X.Type == 0 {
			type0Indices = append(type0Indices, i)
		} else {
			type1Indices = append(type1Indices, i)
		}
	}
	for i := 0; i < len(type0Indices); i++ {
		j := type0Indices[i]
		k := type1Indices[i]
		if pairs[j].X.Num == pairs[k].Y.Num {
			pairs[j].Y, pairs[k].X = pairs[k].X, pairs[j].Y
		} else {
			pairs[j].Y, pairs[k].Y = pairs[k].Y, pairs[j].Y
		}
	}

	for i := 0; i < N; i++ {
		if pairs[i].X.Type == 1 {
			pairs[i].X, pairs[i].Y = pairs[i].Y, pairs[i].X
		}
	}
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].X.Num < pairs[j].X.Num
	})
	fmt.Println("Yes")
	for i := 0; i < N; i++ {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%d", pairs[i].Y.Num)
	}
	fmt.Println()

	// for i := 0; i < N; i++ {
	// 	if c[i].Type == 1 {
	// 		c[i], c[i+N] = c[i+N], c[i]
	// 	}
	// }
	// indices := make([]int, N) // indices of c
	// for i := 0; i < N; i++ {
	// 	indices[i] = i
	// }
	// sort.Slice(indices, func(i, j int) bool {
	// 	return c[indices[i]].Num < c[indices[j]].Num
	// })
	// fmt.Println("Yes")
	// for i := 0; i < N; i++ {
	// 	if i > 0 {
	// 		fmt.Printf(" ")
	// 	}
	// 	fmt.Printf("%d", c[indices[i]+N].Num)
	// }
	// fmt.Println()
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 30032
/**
 *    author:  tourist
 *    created: 27.01.2020 05:43:19       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long i, o, t, j, l, s, z;
  cin >> i >> o >> t >> j >> l >> s >> z;
  long long ans = o;
  if (i > 0 && j > 0 && l > 0 && i % 2 + j % 2 + l % 2 >= 2) {
    ans += 3;
    --i; --j; --l;
  }
  ans += 2 * (i / 2);
  ans += 2 * (j / 2);
  ans += 2 * (l / 2);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256