akhauriyash/Code-Regression huggingface dataset:
n=int(input())
information=[]

one=[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
two=[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
three=[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
four=[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
kousya=[one,two,three,four]

for i in range(n):
    information=list(map(int,input().split()))
    b=information[0]-1
    f=information[1]-1
    r=information[2]-1
    v=information[3]
    kousya[b][f][r]=kousya[b][f][r]+v
    information=[]

for i in range(4):
    for j in range(3):
        for k in range(10):
            if k<9:
                print(" "+str(kousya[i][j][k]),end="")
            else:
                print(" "+str(kousya[i][j][k]))
    if i<3:
        print("####################")




Measured memory_bytes: 5636
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2*1e5+10;
const long long inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }
 
ll power(ll x, ll y){  
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  
bool ok;
ll n;
vector<char> ans;
vector<string> v;
void solve1(ll a, ll b, ll c, ll i){
	
	if (a<0 || b<0 || c<0){
		ok=false;
		return;
	}
	//d4(a,b,c,i);
	if (i==n){
	//	d3(a,b,c);
		if (a>=0 && b>=0 && c>=0) ok=true;
		else ok = false;
		
	}
	else{
		string s=v[i];
		if (s=="AB"){
			solve1(a-1, b+1, c, i+1);
			if (ok){
				ans.pb('B');
			}
			else{
				solve1(a+1, b-1, c, i+1);
				if (ok){
					ans.pb('A');
				}
				else{
					ok=false;
					return;
				}
			}
		}
		else if (s=="BC"){
			solve1(a, b+1, c-1, i+1);
			if (ok){
				ans.pb('B');
			}
			else{
				solve1(a, b-1, c+1, i+1);
				if (ok){
					ans.pb('C');
				}
				else{
					ok=false;
					return;
				}
			}
		}
		else{
			solve1(a+1, b, c-1, i+1);
			if (ok){
				ans.pb('A');
			}
			else{
				solve1(a-1, b, c+1, i+1);
				if (ok){
					ans.pb('C');
				}
				else{
					ok=false;
					return;
				}
			}
		}
	}
}

void solve(){
		
	string s1="ABC";
	string s2="ARC";
	string s;
	cin>>s;
	if (s==s1) cout<<s2<<endl;
	else cout<<s1<<endl;
	
	
	return;
}
 
int main(){ 
    
    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	return 0;
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    int N, K;

    cin >> N >> K;
    int temp;
    int d;
    vector<int> a(N, 0);
    for (int i = 0; i < K; ++i) {
        cin >> temp;
        for (int j = 0; j < temp; ++j) {
            cin >> d;
            a[d-1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (a.at(i) == 0) {
            ans++;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;


int main(){
    long long N,ans=0;
    cin >> N;
    long long A[N+10],B[N+10];
    for(int i=1; i<=N+1; i++){
        cin >> A[i];
    }for(int i=1; i<=N; i++){
        cin >> B[i];
    }
    for(int i=1; i<=N; i++){
        long long go=min(A[i],B[i]);
        ans+=go;
        B[i]-=go;
        if(B[i] !=0){
            go=min(A[i+1],B[i]);
            A[i+1]-=go;
            ans+=go;
        }
    }
    cout << ans << endl;
}

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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int n;
int a[3005];
int dp[3005][3005];

int f(int s,int e,bool t)
{
    if(s>e) return 0;
    int &ret=dp[s][e];
    if(ret!=-1)
        return ret;
    if(t)
        return ret=min(f(s+1,e,0)-a[s],f(s,e-1,0)-a[e]);
    return ret=max(f(s+1,e,1)+a[s],f(s,e-1,1)+a[e]);
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
        }
        memset(dp,-1,sizeof dp);
        cout<<f(0,n-1,0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 74340
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function write(x::Tuple{Int,Int})
	p = 0
	while 10^p<=x[1]
		p += 1
	end
	q = 0
	while 10^q<=x[2]
		q += 1
	end
	for i in 1:6-p
		print("0")
	end
	print(x[1])
	for i in 1:6-q
		print("0")
	end
	println(x[2])
end

function main()
	n,m = readline() |> split |> parseMap
	a = Tuple{Int,Int,Int}[]
	for i in 1:m
		p,y = readline() |> split |> parseMap
		push!(a,(i,p,y))
	end
	a = sort(a,by=x->(x[2],x[3]))
	g = Tuple{Int,Int}[(0,0) for i in 1:m]
	c = 1
	g[a[1][1]]=(a[1][2],c)
	for i in 2:m
		if a[i][2]!=a[i-1][2]
			c = 1
		else
			c += 1
		end
		g[a[i][1]]=(a[i][2],c)
	end
	map(write,g)
end

main()

Measured memory_bytes: 169852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int n = Integer.parseInt(str);
        int h, m, s;
        if(n>=0 && n<86400){
        	h = n/3600;
        	int rim = n % 3600;
        	m= rim/60;
        	s =rim%60;
        	System.out.println(h +":" + m + ":" + s);
        }
	}
}

Measured memory_bytes: 24452
num = 0
def marge_sort(array):
    global num
    if len(array) < 2: return array
    
    mid = len(array) // 2
    left = marge_sort(array[:mid])
    right = marge_sort(array[mid:])
    
    len_l, len_r = len(left), len(right)
    left += [float("inf")]
    right += [float("inf")]
    
    marray = [0] * (len_l + len_r)
    
    l, r = 0, 0
    for i in range(len_l + len_r):
        num += 1
        if left[l] <= right[r]:
            marray[i] = left[l]
            l += 1
        else:
            marray[i] = right[r]
            r += 1
        
    return marray

n = int(input())
a = list(map(int, input().split()))

print(" ".join(map(str, marge_sort(a))))
print(num)


Measured memory_bytes: 67136
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  for(int i=0;i<=27;i++){
    for(int j=0;j<=16;j++){
      if(4*i+7*j==n){
        P("Yes");
        return 0;
      }
    }
  }
  P("No");
  return 0;
}


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

class smart_sieve
{
    ll L, R, M;
    vector<int> small;
    vector<vector<ll>> large;
    vector<ll> aux;

public:
    smart_sieve(ll L, ll R): L(L), R(R), M(sqrt(R)+1)
    {
        small.resize(M);
        iota(small.begin(), small.end(), 0);
        large.resize(R-L);
        aux.assign(R-L, 1);

        for(ll i=2; i*i<R; i++)
        {
            if(small.at(i) < i) continue;
            small.at(i) = i;
            for(ll j=i*i; j<M; j+=i)
                if(small.at(j) == j) small.at(j) = i;
            
            for(ll j=(L+i-1)/i*i; j<R; j+=i)
            {
                ll k=j;
                do
                {
                    if(aux.at(j-L)*aux.at(j-L) > R) break;
                    large.at(j-L).push_back(i);
                    aux.at(j-L) *= i;
                    k /= i;
                } while (k%i == 0);
            }
        }
    }
    vector<ll> factor(ll n)
    {
        assert(L <= n && n < R);
        vector<ll> res = large.at(n-L);
        n /= aux.at(n-L);
        if(n >= M)
        {
            res.push_back(n);
            return res;
        }
        while(n > 1)
        {
            res.push_back(small.at(n));
            n /= small.at(n);
        }
        return res;
    }
};

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

    smart_sieve ss(1, N + 1);
    ll ans = 0;
    for(int i=1; i<N; i++) {
        auto vec = ss.factor(i);
        int c = 0;
        int pre = 0;
        int k = 1;
        for(auto n : vec) {
            if(pre != n) {
                k *= (c + 1);
                pre = n;
                c = 1;
            }
            else c++;
        }
        k *= (c + 1);
        ans += k;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 78180
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

    int n;
    string s;
    int ans = 0;
    cin >> n >> s;

    int r = 0, g = 0, b = 0;
    rep(i, n) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else b++;
    }
    ans = r * g * b;
    for (int i = 1; i <= n; i++) { //幅
        rep(j, n) { //してん
            if (j + i * 2 >= s.size()) break;
            int R = 0, G = 0, B = 0;
            rep(k, 3) {
                int now = j + k * i;
                if (s[now] == 'R') R++;
                else if (s[now] == 'G') G++;
                else B++;
            }
            if (R == 1 && G == 1 && B == 1) ans--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,N;
    int A[10000],B[10000];
    cin>>H>>N;
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
    }
    int dp[H+10];
    for(int i=0;i<=H;i++){
        dp[i]=pow(10,9);
    }
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=H;j++){
            if (j<A[i]){
                dp[j]=min(dp[j],dp[0]+B[i]);
            }else{
                dp[j]=min(dp[j],dp[j-A[i]]+B[i]);
            }
        }
    }
    cout<<dp[H]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;


int main(){
    int n;cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<vector<LL>> dp(n+1,vector<LL>(100000,0));
    vector<vector<LL>> dp2(n+1,vector<LL>(200000,0));
    dp[0][0] = 1;
    dp2[0][100000] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 90000; j++) {
            if(dp[i][j]==0) continue;
            dp[i+1][j+a[i]]=(dp[i+1][j+a[i]] + dp[i][j])%mod;
            dp[i+1][j]=(dp[i+1][j] + 2*dp[i][j])%mod;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = -90000; j <= 90000; j++) {
            if(dp2[i][j+100000]==0) continue;
            dp2[i+1][j+a[i]+100000]=(dp2[i+1][j+a[i]+100000] + dp2[i][j+100000])%mod;
            dp2[i+1][j-a[i]+100000]=(dp2[i+1][j-a[i]+100000] + dp2[i][j+100000])%mod;
        }
    }
    LL ans = 1;
    for (int i = 0; i < n; i++) {
        ans = ans * 3 %mod;
    }
    for (int i = (sum+1)/2; i <= sum; i++) {
        ans = (ans - dp[n][i]*3%mod + mod)%mod;
    }
    ans = (ans + dp2[n][100000]*3)%mod;
    cout << ans%mod << endl;
    return 0;
}



Measured memory_bytes: 708592
#C

import math

k = int(input())
cnt = 0

for i in range(1,k+1):
    for j in range(i,k+1):
        tmp = math.gcd(i,j)
        for l in range(1,k+1):
            if i != j:
                cnt += 2 * math.gcd(tmp,l)
            else:
                cnt += math.gcd(tmp,l)
            
print(cnt)

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

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

    int n; cin >> n;
    int a[n]; rep(i,n) cin >> a[i];
    int ans = 0;
    rep(i,n){
        if((i+1)%2 == 1 && a[i]%2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define I(x, a) for(auto x : (a))
#define ins insert
#define F(i, l, r) for(auto i = (l); i < (r); i++)
#define DF(i, l, r) for(auto i = (l); i >= (r); i--)
#define E(i, l, r) for(auto i = (l); i <= (r); i++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define ret return
#define brk break
#define cont continue
#define move fjgjgjgjghd

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair<int, int> pii;

const int N = (int)1e5 + 5;

int dp[N][3];
int n;
int a[N], b[N], c[N];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	F(i, 0, n)
		cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	F(i, 1, n + 1){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i - 1];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i - 1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i - 1];
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
	return 0;
}


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

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[k+1]={0};
  for(int i=1;i<=k;i++){
    for(int j=0;j<n;j++){
      if(a[j]<=i){
        if(dp[i-a[j]]==0)
          dp[i]=1;
      }
    }
  }
  if(dp[k]==1) cout<<"First";
  else cout<<"Second";
  return 0;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
int main(){
        int a, b, c; cin >> a >> b >> c;
        if ((a == b && a != c) || (b == c && b != a) || (c == a && c != b)) cout << "Yes";
        else cout << "No";
    return 0;
}



Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;
int N;
int H[2000001];

int left(int i){
    return i*2;
}
int right(int i){
    return i*2+1;
}
int parent(int i){
    return i/2;
}

void Maximize(int i){
    int l = left(i);
    int r = right(i);
    
    int largest = i;
    if (l <= N && H[l] > H[largest]) largest = l;
    if (r <= N && H[r] > H[largest]) largest = r;
    
    if (largest != i) {
        swap(H[largest],H[i]);
        Maximize(largest);
    }
}

void Minimize(int i){
    int p = parent(i);
    
    if (p > 0 && H[p] < H[i]){
        swap(H[p],H[i]);
        Minimize(p);
    }
}

void extract(){
    if (N == 0) return;
    
    cout << H[1] << endl;
    H[1] = H[N];
    N--;
    Maximize(1);
}

void insert(int x){
    N++;
    H[N] = x;
    Minimize(N);
}

int main(){
    int command;
    N = 0;
    
    while (true) {
        char com[16];
        scanf("%s",com);
        if (com[2] == 'd') break;
        
        if (com[0] == 'i'){
            int num;
            cin >> num;
            insert(num);
        }else{
            extract();
        }
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll n, i, j, k;
    cin >> n;
    cout << 3 * n * n << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

bool is_num(char c){return '0'<=c && c<='2';}

ll mns(ll a){
    if(a==1){return a;}
    return a^2;
}

ll OR(ll a,ll b){
    return min(a,b);
}

ll pls(ll a,ll b){
    return max(a,b);
}

ll Ans(const string &s){
    stack<char> S;
    for(int i=0;i<s.size();i++){
        if(is_num(s[i]) && !S.empty() && S.top()!='('){
            ll a=s[i]-'0';
            while(!S.empty() && S.top()!='('){
                char c=S.top(); S.pop();
                if(c=='-'){
                    a=mns(a);
                    continue;
                }
                ll b=S.top(); S.pop();
                b-='0';
                if(c=='*'){
                    a=OR(a,b);
                }
                else if(c=='+'){
                    a=pls(a,b);
                }
            }
            S.push(a+'0');
        }
        else if(s[i]==')'){
            ll a=S.top(); a-='0'; S.pop();
            S.pop();
            while(!S.empty() && S.top()!='('){
                char c=S.top(); S.pop();
                if(c=='-'){
                    a=mns(a);
                    continue;
                }
                ll b=S.top(); S.pop();
                b-='0';
                if(c=='*'){
                    a=OR(a,b);
                }
                else if(c=='+'){
                    a=pls(a,b);
                }
            }
            S.push(a+'0');
        }
        else{
            S.push(s[i]);
        }
    }
    return S.top()-'0';
}



int main(){
    string s;
    while(cin>>s){
        if(s=="."){break;}
    vector<vector<ll>> A(3);
    ll ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='P'){A[0].push_back(i);}
        if(s[i]=='Q'){A[1].push_back(i);}
        if(s[i]=='R'){A[2].push_back(i);}
    }
    for(int i=0;i<3;i++){
        for(auto &I:A[0]){s[I]=i+'0';}
        for(int t=0;t<3;t++){
            for(auto &I:A[1]){s[I]=t+'0';}
            for(int h=0;h<3;h++){
                for(auto &I:A[2]){s[I]=h+'0';}
                if(Ans(s)==2){ans++;}
            }
        }
    }
    cout<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3044
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int N = sc.nextInt();
        long[] a = IntStream.range(0, 3*N).mapToLong(i -> sc.nextLong()).sorted().toArray();
        long ans = 0;

        for (int i = 3*N-2; i >= N; i-=2) {
            ans += a[i];
        }

        out.println(ans);
        
        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main()
{
  int64_t a=1,b=1;
  int n;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
    int64_t x,y;
    cin>>x>>y;
    int64_t maga=a/x;
    int64_t magb=b/y;
    if(a%x!=0)maga++;
    if(b%y!=0)magb++;
    int64_t k=max(maga,magb);
    a=x*k;
    b=y*k;
  }
  cout<<a+b;
}

Measured memory_bytes: 256
# test!!!!!!!!!!!

from bisect import bisect_left, bisect_right

N = int(input())

S = list(input())

Q = int(input())

# {"a":[], "b":[], ..., "z":[]}
dict = {chr(ord('a') + i): [] for i in range(26)}


for i in range(N):
    dict[S[i]].append(i)

ans = []

for q in range(Q):
    query = list(input().split())
    if query[0] == '1':
        i, x = int(query[1])-1, query[2]
        now = S[i]
        if now == x:
            continue
        dict[now].remove(i)
        next_i = bisect_left(dict[x], i)
        dict[x].insert(next_i, i)
        S[i] = x
    else:
        start, end = int(query[1])-1, int(query[2])-1
        tmp_cout = 0
        for alf_array in dict.values():
            if len(alf_array) == 0:
                continue
            ss = bisect_left(alf_array, start)
            gg = bisect_right(alf_array, end)
            if gg- ss > 0:
                tmp_cout += 1
        ans.append(tmp_cout)

for i in ans:
    print(i)


Measured memory_bytes: 120264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double n; cin >> n;
    vector<double> x(n);
    vector<double> y(n);
    rep(i,n) {
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    rep(i,n-1) {
        for(int j = i+1; j < n; j++) {
            ans += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout << setprecision(12) << ans/n*2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int N;
    int B[99];
    int A[100];
    int i;
    int sum;
    
    scanf("%d", &N);
    if(N<=100)
    {
        for(i=0;i<N-1;i++)
        {
            scanf("%d",&B[i]);
        }
    }
    
    sum = B[0];
    for(i=0; i<N-2; i++)    
    {
        if(B[i]<=B[i+1])
        {
            sum = sum + B[i];
        }
        else
        {
            sum = sum + B[i+1];
        }
    }
    sum = sum + B[N-2];
    printf("%d",sum);
    return(0);
}


Measured memory_bytes: 128
#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while ( A[i] != key ) i++;
  return i != n;
}

int main() {
  int i, n, A[10000+1], q, key, sum =0;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


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

using namespace std;

typedef long long ll;
#define em emplace_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin >> x;
	if (x >= 30)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int d, e; cin >> d >> e;
    if (d == 0) break;
    double res = 1e10;
    for (int x = 0; x <= d; ++x) {
      int y = d - x;
      res = min(res, abs(hypot(x, y) - e));
    }
    cout << fixed << setprecision(15) << res << '\n';
  }
}


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

int main(){
 int n,x;
  cin>>n>>x;
  int A[1100];
  int sum=0,a=110000;
  
  for(int i=0;i<n;i++){
    cin>>A[i];
    a=min(a,A[i]);
    sum+=A[i];
  }
  
  cout<<(x-sum)/a+n<<endl;
  
}  
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef struct D{int h,p;long long s;}D;

#define ML 20005
char S[ML];
int i,A,nh=0,np,k,mh=0;
long long R[ML],r=0;
stack<D>ST;
int main()
{
	gets(S);
	for(i=np=0;S[i];i++)
	{
		if(S[i]=='\\')
		{
			D tmp={nh--,i,0};
			mh=max(mh,tmp.h);
			ST.push(tmp);
		}
		else if(S[i]=='/')
		{
			int ts=0;
			nh++;
			if(nh>mh)continue;
			for(;!ST.empty()&&ST.top().h<nh;)
			{
				ts+=ST.top().s;
				ST.pop();
			}
			if(!ST.empty()&&ST.top().h==nh)
			{
				D tmp=ST.top();ST.pop();
				tmp.s+=ts+i-tmp.p;
				ST.push(tmp);
			}
		}
	}
	for(i=ST.size(),k=0;i>0;i--)
	{
		if(ST.top().s)
		{
			r+=R[k++]=ST.top().s;
		}
		ST.pop();
	}
	printf("%lld\n",r);
	printf("%d%c",k,k?' ':'\n');
	for(i=0;i<k;i++)
		printf("%lld%c",R[k-i-1],i==k-1?'\n':' ');

}

Measured memory_bytes: 1464
N, X, Y = map(int, input().split())
D = [None] + [0] * (N - 1)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(abs(j - i),
                abs(X - i) + 1 + abs(j - Y),
                abs(Y - i) + 1 + abs(j - X))
        D[d] += 1

for d in D[1:]:
    print(d)


Measured memory_bytes: 3444
#if 0
????????£????????????25m
????????¨????§???????????????¨????????¨???????????¨???????§£?????????
?°???????????§£????????£???????????????????????????
#endif

#include <iostream>
using namespace std;

int main() {
	int N,W;
	cin>>N>>W;
	int v[N+10];
	int w[N+10];
	int V[N+10][W+10];

	for(int i=1;i<N+1;i++)
		cin>>v[i]>>w[i];
		
		for (int i=0;i<N+1;++i) { 
			for (int j=0;j<W+1;++j) { //j????????????????????¶?????¨?????£?????????
				if (i==0||j==0)
					V[i][j]=0; //??????????????????
				else if(j-w[i]<0) //????????¶???????¶??????????????????????????????°??????
					V[i][j]=V[i-1][j];  
				else
					V[i][j]=max(v[i]+V[i-1][j-w[i]],V[i-1][j]);
		}
	}
	cout<< V[N][W]<< endl;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const ll M = 1e9 + 7;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

ll n, k, ans;
VLL dp;

int main()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    cin>>n>>k;
    dp.resize(n+1);
    if (k >= n - 1)
        k = n - 1;
    ans = 1;
    FOR(i,1,k+1) {
        ans += comb(n, i) * comb(n-1, i);
        //debug(i); debug(comb(n - 1, i));
        ans %= MOD;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6528
word = list(input())
p = 0
pre = "あ"
for i in range(len(word)):
  if len(pre) == 2:
    pre = "あ"
  else:
    if word[i] == pre and i == len(word) - 1:
      pass
    elif word[i] == pre:
      pre = word[i] + word[i + 1]
      p += 1
    else:
      pre = word[i]
      p += 1
print(p)

Measured memory_bytes: 4840
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

bool isfinish(int d[]){
  int res = 0;
  REP(i,4){
    if(d[i] == 1) res++;
  }
  return res == 4;
}

int cnt(int d[]){
  int res = 0;
  REP(i,4) res += d[i];
  return res;
}

int main(){

  string s;
  cin >> s;

  int ans = 0;
  int d[4] = {}, dir = 0;
  bool is_start = true;
  REP(i,s.length()){
    if(s[i] == 'R'){
      int next_dir = (dir + 1) % 4;
      if(is_start){
        if(cnt(d) == 3 && next_dir == 0 && dir == 3){
          //goal
          ans++;
          REP(j,4){
            d[j] = 0;
          }
          is_start = true;
        }else if(next_dir == 0){
          //saisyo
          REP(j,4){
            d[j] = 0;
          }
          is_start = false;
        }else{
          d[next_dir] = 1;
        }
      }else{
        if(dir == 0){
          d[next_dir] = 1;
          is_start = true;
        }
      }
      dir = next_dir;
    }else{

      int next_dir = (dir + 4 - 1) % 4;
      if(is_start){
        if(next_dir == 0){
          REP(j,4){
            d[j] = 0;
          }
          is_start = false;
        }
      }
      dir = next_dir;
    }
  }

  printf("%d\n", ans);
  return 0;
}




Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int main(){
    ll h,w,n,m,ans;
    cin>>h>>w>>n>>m;
    int num[h][w];
    For(i,0,h){
        For(j,0,w){
            num[i][j]=0;
        }
    }
    For(i,0,m){
        For(j,0,n){
            num[i][j]=1;
        }
    }
     For(i,m,h){
        For(j,n,w){
            num[i][j]=1;
        }
    }   
    For(i,0,h){
        For(j,0,w){
            cout<<num[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<set>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
int n,m,i,j,a[100005],l[100005],r[100005],x,y;
vector<int> bi[100005];
void dfs(int x,int fa)
{
	if (r[x]==-1) r[x]=1<<28;
	ff(bi[x],it)
	{
		if (*it==fa) continue;
		dfs(*it,x);
		l[x]=max(l[x],l[*it]-1);
		r[x]=min(r[x],r[*it]+1);
	}
	if (l[x]>r[x])
	{
		puts("No");
		exit(0);
	}
}
void dfs2(int x,int fa)
{
	if (x==1&&a[x]==-1) a[x]=r[x];
	ff(bi[x],it)
	{
		if (*it==fa) continue;
		if (a[*it]==-1)
		{
			if (r[*it]>=a[x]+1) a[*it]=a[x]+1;
			else if (l[*it]<=a[x]-1) a[*it]=a[x]-1;
			else
			{
				puts("No");
				exit(0);
			}
		}
		dfs2(*it,x);
	}
}
int main()
{
	scanf("%d",&n);
	fz1(i,n-1)
	{
		scanf("%d%d",&x,&y);
		bi[x].push_back(y);
		bi[y].push_back(x);
	}
	memset(a,-1,sizeof(a));
	memset(r,-1,sizeof(r));
	scanf("%d",&m);
	while (m--)
	{
		scanf("%d%d",&x,&y);
		a[x]=l[x]=r[x]=y;
	}
	dfs(1,0);
	dfs2(1,0);
	fz1(i,n)
	{
		ff(bi[i],it)
		{
			if (abs(a[i]-a[*it])!=1)
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	fz1(i,n)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    Int n = s.size();
    if (s.front() == '0' or s.back() == '1') {
        dump(-1);
        return 0;
    }
    for (Int i = 0; i < n - 1; i++) {
        if (s[i] != s[n - 2 - i]) {
            dump(-1);
            return 0;
        }
    }
    cout << 1 << " " << 2 << endl;
    if (n == 2) return 0;
    cout << 2 << " " << 3 << endl;
    Int a, b;
    a = 2, b = 3;
    for (Int i = 1; i < n - 2; i++) {
        if (s[i] == '1') {
            cout << b << " " << i + 3 << endl;
            a = b;
            b = i + 3;
        } else {
            cout << a << " " << i + 3 << endl;
            b = i + 3;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false)cerr
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
#define minel(a) *min_element(all(a))
#define maxel(a) *max_element(all(a))
#define pq(t) priority_queue<t, vector <t>, greater <t>>
#define pqd(t) priority_queue<t>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))      // Used to iterate over the types

const ll mod = 1e9 + 7;
const ll mx = 1e18;
const ll inf = 1e7;

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// For printing variables and their respective values

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}

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

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

auto mods() { return 0; }

template<typename T, typename... Args>
auto mods(T a, Args... args) { return (a + mods(args...) + mod) % mod; }

auto modp() { return 1; }

template<typename T, typename... Args>
auto modp(T a, Args... args) { return ( a * modp(args...) )% mod; }
// ! inputs should be positive and less than `mod`.

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// !Taking `int` input

template<typename T>
T nxt(){
    T x;
    cin >> x;
    return x;
}

//  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

inline void solve()
{
   ll n = nxt<ll>(), d = nxt<ll>();
   d = d * d;
   vll arr(n);
   ll cnt = 0;
   rep(i, 0, n)
   {
       ll a, b;
       cin >> a >> b;
       if( a * a + b * b <= d)
            cnt++;
   }
   cout << cnt << endl;

}

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4780
from math import sqrt
n=int(input())
ans=[0]*n
for x in range(1,int(sqrt(n))+10):
    for y in range(1,int(sqrt(n))+10):
        for z in range(1,int(sqrt(n)+10)):
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if v<=n:
                ans[v-1]+=1
for a in ans:
    print(a)


Measured memory_bytes: 9256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int A, B, C; cin >> A >> B >> C;
    int X, Y; cin >> X >> Y;
    int ans = INF;
    for (int c = 0; c <= 200000; c += 2) {
        int a = 0;
        if (X >= c / 2) a = X - c / 2;
        int b = 0;
        if (Y >= c / 2) b = Y - c / 2;
        int sum = a * A + b * B + c * C;
        ans = min(ans, sum);
    }
    out(ans);


    return 0;
}










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

const int N=2e5+20;

int n,a[N];
long long ans;

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

	for(int i=1;i<n;i++)
	{
		if(a[i]>=a[i-1]) continue;
		ans+=a[i-1]-a[i];
		a[i]=a[i-1];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 4612
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 200000;
int n, k;
int las[maxn + 10];
int a[maxn + 10];
int temp[maxn + 10];
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for(int i = 1; i <= k; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			++temp[max(1, j - a[j])];
			--temp[min(n + 1, j + a[j] + 1)];
		}
		bool flag = 1;
		for(int j = 1; j <= n; ++j)
		{
			if(a[j] != n)
				flag = 0;
			temp[j] += temp[j - 1];
			a[j] = temp[j];
			temp[j - 1] = 0;
		}
		temp[n] = 0;
		if(flag)
			break;
	}
	for(int i = 1; i <= n; ++i)
		printf("%d ", a[i]);
	return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e3+5;


int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<pair<int,int>> p(n);
    fori(i,n) {
        cin >> p[i].fi;
        p[i].se = i;
    }

    sort(p.begin(), p.end());
    int mn = n;

    int ans = 0;
    fori(i,n) {
        int idx = p[i].se;
        if(idx < mn) ans++;
        mmin(mn,idx);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1792