akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll dp[M][5];

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

	ll i,n,a,b,c;

	cin >> n;

	for(i=1;i<=n;++i)
	{
		cin >> a >> b >> c;
		dp[i][1] = max(dp[i-1][2],dp[i-1][3]) + a;
		dp[i][2] = max(dp[i-1][1],dp[i-1][3]) + b;
		dp[i][3] = max(dp[i-1][1],dp[i-1][2]) + c;
	}

	cout << max({dp[n][1],dp[n][2],dp[n][3]}) << endl;
	return 0;
}

	


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<deque>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<stack>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn =1000100;
typedef pair<ll,ll>p1;
typedef pair<pair<ll,ll>,ll>p2;
map<pair<pair<ll,ll>,ll>,ll>m1;
map<pair<ll,ll>,ll>m2;
const int MOD = 1e9;
const int N=351;
const int inf = 0x3f3f3f3f;
typedef pair<char, int> PAIR;
map<string,int>mm;
ll w[maxn],v[maxn],c[maxn];
ll dp[maxn];
int main()
{
    mem(dp,0);
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&w[i],&v[i]);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=k;j>=w[i];j--)
        {
            dp[j] = max(dp[j],1ll*dp[j-w[i]]+v[i]);
        }
    }
    cout<<dp[k]<<endl;
}

Measured memory_bytes: 11640
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define ft first
#define st second
#define mp make_pair
#define pb push_back
#define sz(n) int(n.size())
#define all(n) n.begin(), n.end()


using namespace std;

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

const int N = 1e5 + 123;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;

int a, b, c, ans, cnt[200];

int main ()
{      
	cin >> a >> b >> c;
	cnt[a] ++;
	cnt[b] ++;
	cnt[c] ++;
	for (int i = 1; i <= 100; i ++) ans += (cnt[i] != 0);

	cout << ans;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <queue>

using namespace std;

const char *X, *Y;
int X_length, Y_length;

int table_lcs[1001][1001];

int lcs(int x_begin, int y_begin) {
	int i, j, to;
	int max = 0;
	int v_lcs;
	bool alreadySeenTable[256];
	if (table_lcs[x_begin][y_begin] != -1) {
		return table_lcs[x_begin][y_begin];
	}
	
	for (i = 0; i < 256; i++) {
		alreadySeenTable[i] = false;
	}
	i = x_begin;
	to = Y_length-1;
	while(i <= X_length-1) {
		j = y_begin;
		if (alreadySeenTable[X[i]] == true) {
			i++;
			continue;
		}
		bool found = false;
		while (j <= to) {
			if (X[i] == Y[j]) {
				v_lcs = lcs(i + 1, j + 1) + 1;
				if (v_lcs > max) {
					max = v_lcs;
				}
				found = true;
				break;
			}
			else {
				j++;
			}
		}
		if (found == false) {
			alreadySeenTable[X[i]] = true;
			i++;
		}
		else {
			alreadySeenTable[X[i]] = true;
			i++;
			to = j - 1;
		}
	}
	return table_lcs[x_begin][y_begin] = max;
}

int main() {

	int N;
	cin >> N;
	string stringX, stringY;

	for (int i = 1; i <= N; i++) {
		for (int i = 0; i < 1001; i++) {
			for (int j = 0; j < 1001; j++) {
				table_lcs[i][j] = -1;
			}
		}
		cin >> stringX >> stringY;
		X = stringX.c_str();
		X_length = stringX.size();
		Y = stringY.c_str();
		Y_length = stringY.size();
		printf("%d\n", lcs(0, 0));
	}
	return 0;
}

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

#define CEK(x) cerr << "The value of " << #x << " is " << x << endl
#define endl '\n'
using graphInt = vector<vector< int> >;
using graphStr = map<string, vector<string> > ;

string s;
int n;
int main(){
		cin>>n;
	cin>>s;
	
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			
			if(left&&right)
				cnt++;
		}
		
		if(ans<cnt)
			ans=cnt;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int l[109];
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i>0&&s[i-1]==s[i]){
            cout<<i<<" "<<i+1<<endl;
            exit(0);
        }
        if(i>1&&s[i-2]==s[i]){
            cout<<i-1<<" "<<i+1<<endl;
            exit(0);
        }
    }
    cout<<"-1 -1"<<endl;
}





Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = sc.nextLong();
    long big = Math.max(x, y);
    long small = Math.min(x, y);
    String ans = "Brown";
    if(big > small + 1) ans = "Alice";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	vector<int> v;
	for(int i = 0; i < 5; i++){
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.rbegin(), v.rend());
	int cas = 1;
	for(auto i:v){
		if(cas > 1)cout << ' ';
		cas++;
		cout << i;
	}
	cout << '\n';
	return 0;
}
// Write Here



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1010],cnt=0;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]),cnt+=(a[i]&1);
	if(cnt>=3)return puts("Impossible"),0;	
	if(m==1)
	{
		if(a[1]==1)cout<<1<<endl<<1<<endl<<1;
		else cout<<a[1]<<endl<<2<<endl<<a[1]-1<<" "<<1<<endl;
	}
	else
	{
		bool flag=0;vector<int>ans;
		for(int i=1;i<=m;i++)
		{
			if(a[i]&1)
			{
				if(!flag)swap(a[i],a[1]),flag=1;
				else
				{
					swap(a[i],a[m]);
					break;
				}
			}
		}
		for(int i=1;i<=m;i++)cout<<a[i]<<" ";puts("");
		for(int i=1;i<=m;i++)
		{
			if(a[i]&1)
			{
				if(i==1)ans.push_back(a[i]+1);
				else if(i==m)if(a[i]>1)ans.push_back(a[i]-1);
			}
			else
			{
				if(i==1)ans.push_back(a[i]+1);
				else
				{
					if(i!=m)ans.push_back(a[i]);
					else 
					{
						if(a[i]>1)ans.push_back(a[i]-1);
					}
				}
			}
		}
		printf("%d\n",ans.size());
		for(int i=0;i<ans.size();i++)
			printf("%d\n",ans[i]);
	}
}

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

int main(){
    int i,j,N;
    cin >> N;
    vector<int> p;
    vector<int> is_prime(55556, 0);
    int n = 2;
    while(n <= 55555){
        bool is_calc = true;
        if (is_prime[n] == -1){
            is_calc = false;
        }else{
            is_prime[n] = 1;
        }
        int r = n;
        while(r <= 55555 && is_calc){
            if (r+n > 55555){
                break;
            }
            r += n;
            is_prime[r] = -1;
        }
        n += 1;
    }
    int count = 0;
    for(i = 2; i <= 55555; i++){
        if (is_prime[i] == 1 && i % 10 == 1){
            if (count < N){
                cout << i << " ";
            }
            count += 1;
        }

    }
    cout << endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;


ll dp[100010][13];
int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);


    int r; cin>>r;
    cout << 3*r*r << endl;
    return 0;
}

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

int main()
{
	int i,j,a,b,ans=-7;
	char c[10];
	char d[1000]={'h'};
	while(scanf("%s",&c) !=EOF){
		/*for(i=1; i<9; i++){
			scanf("%s", &c[i]);
		}*/
		for(i=0; i<9; i++){
			//cout << c[i] <<endl;
			if(i%3==0 || i==0){
				if(c[0+i]=='o' &&c[1+i]=='o'&&c[2+i]=='o'){
					ans=1;
				}
				if(c[0+i]=='x' &&c[1+i]=='x'&&c[2+i]=='x'){
					ans=0;
					//cout << 1 <<endl;
				}
			}
			if(i <=2){
				if(c[0+i]=='o' &&c[3+i]=='o'&&c[6+i]=='o'){
					ans=1;
				}
				if(c[0+i]=='x' &&c[3+i]=='x'&&c[6+i]=='x'){
					ans=0;
					//cout << 10 <<endl;
				}
			}
		}
		if(c[0]=='o' &&c[4]=='o'&&c[8]=='o')	ans=1;
		if(c[0]=='x' &&c[4]=='x'&&c[8]=='x')	ans=0;
		if(c[2]=='o' &&c[4]=='o'&&c[6]=='o')	ans=1;
		if(c[2]=='x' &&c[4]=='x'&&c[6]=='x')	ans=0;

		if(ans==1)		/*d[a]='o';*/	cout<<'o'<<endl;
		else if(ans==0)	/*d[a]='x';*/	cout<<'x'<<endl;
		else			/*d[a]='d';*/	cout<<'d'<<endl;
		//strcpy(c, "aaaaaaaaa");
		ans=-7;
	}

}

Measured memory_bytes: 1148
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int maxNumber = sc.nextInt();
		int sum = sc.nextInt();

		for (int i = 0; i <= maxNumber; i++) {
            int j = 0;
            while (j + i <= maxNumber) {
                int ant = 0;
                ant += 10000 * i;
                ant += 5000 * j;
                ant += 1000 * (maxNumber - (i + j));

                if (ant == sum) {
                    System.out.println(i + " " + j + " " + (maxNumber - (i + j)));
                    return;
                }
                j++;
            }
        }
        
        System.out.println("-1 -1 -1");
	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int H, W; cin >> H >> W;
  vector<vector<int>> a(H, vector<int>(W));
  vector<int> row(H, 0);
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      cin >> a[r][c];
      row[r] += a[r][c];
    }
  }

  vector<string> ss;
  for (int r = 0; r < H; ++r) {
    int r2 = r + 1;
    for (int c = 0; c < W; ++c) {
      int c2 = c + 1;
      if (row[r] == 0) break;
      if (a[r][c] % 2 == 0) continue;
      if (r < H - 1 && row[r] % 2 != 0) {
        ss.push_back(to_string(r2) + " " + to_string(c2) + " " + to_string(r2 + 1) + " " + to_string(c2));
        --row[r];
        --a[r][c];
        ++row[r+1];
        ++a[r+1][c];
      } else if (c < W - 1) {
        ss.push_back(to_string(r2) + " " + to_string(c2) + " " + to_string(r2) + " " + to_string(c2 + 1));
        --a[r][c];
        ++a[r][c + 1];
      }
    }
  }

  cout << ss.size() << endl;
  for (string s : ss) cout << s << endl;
}


Measured memory_bytes: 8532
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

int main()
{
  flash
  ll n;
  cin>>n;
  ll sum=0;

  for(int i=1;i<=n;i++)
  {

    if(i%5 == 0 || i%3 ==0)
      continue;

    else
      sum+=i;

  }

  cout<<sum<<"\n";

}


Measured memory_bytes: 3664
using System;
using System.Text;
using System.Collections.Generic;

namespace cskyopro {
    class Solver : Reader {
        public void Solve() {
            string S = Next();
            if (S[2] == S[3] && S[4] == S[5]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }

    class Mint {
        const long MOD = 1000000007;
        private long n;

        public Mint(long n) {
            this.n = n;
        }

        public static Mint operator +(Mint a, Mint b) => new Mint((a.n + b.n) % 5);
        public static Mint operator -(Mint a, Mint b) => new Mint((a.n + 5 - b.n) % 5L);
        public static Mint operator *(Mint a, Mint b) => new Mint((a.n * b.n) % 5);
        public static implicit operator Mint(int n) => new Mint(n);

        public override string ToString() => n.ToString();
    }

    class Reader {
        public string Next() {
            StringBuilder sb = new StringBuilder();
            while (true) {
                int x = Console.Read();
                if (x == -1 || x == ' ' || x == '\n') break;
                sb.Append((char)x);
            }
            return sb.ToString();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
    }

    class Program {
        static void Main(string[] args) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
cnt=[0]*60
for elem in a:
    for i in range(60):
        cnt[i]+=(elem>>i)%2
ans=0
for i in range(60):
    ans+=((cnt[i]*(n-cnt[i]))<<i)%mod
print(ans%mod)

Measured memory_bytes: 118064
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n, cntMin = 100000000, cnt = 0;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			a[i] = a[i] / 2;
			cnt++;
		}
		cntMin = min(cntMin, cnt);
		cnt = 0;//cntをリセットする
	}
	cout << cntMin << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    puts(a == vector<int>{5,5,7} ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll bpow(ll a,ll b){
	ll res=1;
	while(b!=0){
		if(b%2) res= (res*a)%mod;
		a= (a*a)%mod;
		b/=2;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	vi v(k+1);
	for(ll i=1;i<=k;i++){
		v[i] = bpow(k/i,n);
	}
	for(ll i=k;i>=1;i--){
		for(ll j=2*i;j<=k;j+=i){
			v[i] -= v[j];  
		}
	}
	for(ll i=1;i<=k;i++){
		ans = (ans+ (i*v[i])%mod)%mod; 
	}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 3956
K = int(input())
A = [int(x) for x in input().split()]
C = [[0, 0] for _ in range(K + 1)]
C[K] = [2, 2]
for i in range(K - 1, -1, -1):
  C[i][0] = A[i] * -(-C[i + 1][0] // A[i])
  C[i][1] = A[i] * (C[i + 1][1] // A[i]) + (A[i] - 1)
  if C[i][0] > C[i + 1][1]:
    print(-1)
    break
else:
  print(C[0][0], C[0][1])

Measured memory_bytes: 24424
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

ll n, m, q;
vector<ll> a, b, c, d;
ll ans = 0;

ll calc(vector<ll> v, ll len){
    ll res = 0;
    REP(i, q){
        if(v[b[i]] - v[a[i]] == c[i]){
            res += d[i];
        }
    }
    return res;
}

void dfs(vector<ll> v, ll len){
    if(len == n){
        chmax(ans, calc(v, len));
        return;
    }
    for(ll i = v[len-1]; i <= m; i ++){
        vector<ll> next = v;
        next.push_back(i);
        dfs(next, len + 1);
    }
    return;
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<ll>(q);
    REP(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    dfs(vector<ll>(1, 1), 1);

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;
 
//素因数分解
vector<long long> PrimeFactorize(long long n){
  vector<bool> prime(round(sqrt(n))+1,1);
  vector<long long> ans;
  for(long long i = 2;i*i <= n;i++){
    if(prime[i]){
      for(long long j = 2*i;j*j <= n;j += i){
        prime[j] = 0;
      }
      while(n%i == 0){
        ans.push_back(i);
        n /= i;
      }
    }
  }
  if(n != 1)ans.push_back(n);
  return ans;
}
 
signed main(){
  ll n;
  cin >> n;
  vector<ll> ans = PrimeFactorize(n);
  cout << n << ':';
  for(auto x:ans)cout << ' ' << x;
  cout << endl;
}


Measured memory_bytes: 3264
S = input()
N = len(S)

ans0 = ''
ans1 = ''

for i in range(N):
	if i%2 == 0:
		ans0 += '0'
		ans1 += '1'
	else:
		ans0 += '1'
		ans1 += '0'

leven0 = 0
leven1 = 0

for i in range(N):
	if S[i]!=ans0[i]:
		leven0 += 1
	if S[i]!=ans1[i]:
		leven1 += 1


if leven0>leven1:
	print(leven1)
else:
	print(leven0)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int n, m, a[31];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int k, x;
		cin >> k;
		for (int i = 0; i < k; i++) {
			cin >> x;
			a[x]++;
		}
	}
	int t = 0;
	for (int i = 1; i <= m; i++) {
		if (a[i] == n) t++;
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;

int main() {
    while (cin >> N ) {
        set<int> se;
        for (int i = 0; i < N; ++i) {
            int a;
            cin >> a;
            se.insert(a);
        }
        cout << se.size() << endl;
    }
}


















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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
//#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const string YES = "Yes";
const string NO = "No";
template<class T> void YesNo(T a) {cout<<(a?YES:NO)<<endl;}

void solve(std::string S){
    if(S[2]==S[3] && S[4]==S[5]) cout<<YES<<endl;
    else cout<<NO<<endl;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    
    ios_base::sync_with_stdio(0);
    int a,b;
    cin>>a>>b;
    while(1){
        if(a==0 && b==0)    break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(i%2==0){
                    if(j%2==0)  cout<<"#";
                    else        cout<<".";
                }
                else{
                    if(j%2==0)  cout<<".";
                    else cout<<"#";
                }
                
                }
            cout<<"\n";
        }
        cout<<"\n";
        cin>>a>>b;
    }
    return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string n,s;
	cin>>n>>s;
	n+=n;
	//cout<<n<<endl;
	int i,j;
	int flg=0;
	for(i=0;i<n.size();i++){
		for(j=0;j<s.size();j++){
			if(n[i+j]!=s[j]){
				break;
			}
		}
		//cout<<j<<endl;
		if(j==s.size()) flg=1;
	}
	cout<<((flg)?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 3224
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int num =0;
        if(S.equals(T)){
            num=1;
            System.out.println("Yes");
        }
        else{
            for(int i=1;i<S.length();i++){
                String Index = S.substring(0,i);
                String last = S.substring(i);
                String con = last + Index;
                if(con.equals(T)){
                    System.out.println("Yes");
                    num=1;
                    break;
                }
            }
        }
        if(num==0) System.out.println("No");
    }
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

vector<int> cost[100001]; //ノードiへの到達コストの情報
vector<int> nodes[100001]; //辺の情報

void init(){
    rep(i, 100001) cost[i].resize(3, mod);
}

//dfsだと更新が頻発し得るのでTLE
/*
void dfs(int s, int c){
    rep(i, nodes[s].size()){
        //コストc+1が行き先にとって有用ならdfs
        int to = nodes[s][i];
        if(cost[to][(c+1)%3] > c+1){
            cost[to][(c+1)%3] = c+1;
            dfs(to, c+1);
        }
    }
}
*/

int main(void){
    init();
    int N, M; cin >> N >> M;
    rep(i, M){
        int u, v;
        cin >> u >> v;
        nodes[u].push_back(v);
    }
    int S, T; cin >> S >> T;
    cost[S][0] = 0;
    
    //幅優先でやる. 各ノードは3回以上訪れない
    int c = 0;
    queue<int> que;
    que.push(S);
    while(!que.empty()){
        c++; //このループで展開するノードはコストcで到達
        queue<int> work;
        while(!que.empty()){
            int temp = que.front();
            que.pop();
            work.push(temp);
        }
        while(!work.empty()){
            int op = work.front();
            work.pop();
            rep(i, nodes[op].size()){
                int to = nodes[op][i];
                if(cost[to][c%3] > c){
                    cost[to][c%3] = c;
                    que.push(to);
                }
            }
        }
    }
    if(cost[T][0] != mod){
        cout << cost[T][0] / 3 << endl;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int N;
int a[100002];
int ans;
int main(){
  a[0]=0;
  cin >> N;
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    a[l]++;
    a[r+1]--;
  }
  for(int i=1;i<=100000;i++)a[i]+=a[i-1];
  for(int i=1;i<=100000;i++){
    if(a[i]>0)ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
K,N = map(int,input().split())
A = list(map(int,input().split()))
dmax = K - A[-1] + A[0]
for i in range(N - 1):
  if A[i + 1] - A[i] > dmax:
    dmax = A[i + 1] - A[i]
print(K - dmax)

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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int r = Integer.parseInt(br.readLine());
    System.out.println(3 * r * r);
  }
}


Measured memory_bytes: 21332
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

void prec(){

}

const int MAXN = 3e3 + 20;


ll mod = 998244353;
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

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

ll bin_p(ll b, ll p) {
    if (p == 0)
        return 1;
    if (p % 2 == 1) {
        return ml(b, bin_p(b, p - 1));
    }

    ll v = bin_p(b, p >> 1);
    return ml(v, v);
}

ll dp[MAXN][MAXN];

ll pows[MAXN];

void solve() {

    int n, s;
    cin >> n >> s;

    vector<int> v;

    for (int i = 0; i < n; ++i) {
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

    pows[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        pows[i] = ml(pows[i - 1], 2);
    }

    dp[0][0] = pows[n];

    ll back_2 = bin_p(2, mod - 2);

    for (int i = 1; i <= n; ++i) {

        for (int j = 0; j <= s; ++j) {
            dp[i][j] = add(dp[i][j], dp[i - 1][j]);
            if (v[i - 1] <= j) {
                dp[i][j] = add(dp[i][j], ml(dp[i - 1][j - v[i - 1]], back_2));
            }
        }
    }

    ll answr = dp[n][s];

    cout << answr;
}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 74456
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;

    int match_location = -1;

    for(int i = 0; i + T.size() - 1 < S.size(); i++)
    {
        int match_made = true;
        for(int j = 0; j < T.size(); j++)
        {
            if(S[i + j] != T[j] && S[i + j] != '?')
            {
                match_made = false;
            }
        }

        if(match_made)
            match_location = i;
    }

    for(int i = 0; i < S.size(); i++)
        if(S[i] == '?')
            S[i] = 'a';

    for(int i = 0; i < T.size(); i++)
        S[match_location + i] = T[i];

    if(match_location == -1)
        cout << "UNRESTORABLE\n";
    else
        cout << S;
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

graph = [[False] * N for _ in range(N)]
queries = []


for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    queries.append((a, b))
    graph[a][b] = True
    graph[b][a] = True


def dfs(node, visited):
    global graph
    for i, next in enumerate(graph[node]):
        if next and i not in visited:
            visited.append(i)
            dfs(i, visited)
    return visited


cnt = 0
for q in queries:
    graph[q[0]][q[1]] = False
    graph[q[1]][q[0]] = False
    visited = dfs(0, [])
    if len(visited) != N:
        cnt += 1
    graph[q[0]][q[1]] = True
    graph[q[1]][q[0]] = True

print(cnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin>>s;
    int a=s%10;
    if(a==2||a==4||a==5||a==7||a==9)
        cout<<"hon"<<endl;
    else if(a==0||a==1||a==6||a==8)
        cout<<"pon"<<endl;
    else if(a==3)
        cout<<"bon"<<endl;
}


Measured memory_bytes: 3636
def LucasNumber(N):
    if N==0:
        return 2
    elif N==1:
        return 1
    else:
        Li2 = 2
        Li1 = 1
        for T in range(2,N+1):
            Li0 = Li1+Li2
            Li2 = Li1
            Li1 = Li0
        return Li0
      
print(LucasNumber(int(input())))

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n; cin>>n; int h[n+1]; for(int i=1;i<=n;i++) cin>>h[i];
        long long cnt=0;
        unordered_map<long long,int> mp;
        for(int i=1;i<=n;i++){
                int val=i-h[i];
                cnt+=mp[val];
                mp[i+h[i]]++;
        }
        cout<<cnt<<endl;
}



Measured memory_bytes: 19184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using State = tuple<int, int, int>;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if(A < B) {
		swap(A, B);
	}
	if(A < C) {
		swap(A, C);
	}

	int ans = 0;
	if (((A - C) + (A - B)) % 2 != 0) {
		A++;
		B++;
		ans++;
	}
	ans += ((A - C) + (A - B)) / 2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  long n, k;
  scanf("%ld%ld", &n, &k);
  long r = n%k;
  long ans = (2*r < k) ? r : k-r;
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main(void) {
	long N = 0;
	std::string S;
	std::string T;
	std::cin >> N;
	std::cin >> S >> T;
	for (int i = 0; i < N; i++) {
		std::cout << S[i] << T[i];
 	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(ix,v.size())cout<<" "<<v[ix];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))

const int INF = 2125252830;
const int MAX = 100000;

int r,c,n;
int xy[2*MAX];
int val[MAX];

int xmin[MAX];
vector<pii> ys[MAX];
vector<pii> g[MAX];
ll dist[MAX];
bool used[MAX];

bool po[MAX];
int a;
int node[MAX];
int vere[MAX];

bool check(){
  REP(i,a)vere[node[i]] = i;
  REP(i,a)dist[i] = 0;
  REP(i,a)used[i] = false;
  dist[0] = 0;
  used[0] = true;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    int id = node[p];
    ll d = dist[p];
    REP(i,g[id].size()){
      int to = vere[g[id][i].first];
      ll cost = (ll)g[id][i].second;
      ll nd = d+cost;
      if(used[to]){
        if(dist[to]!=nd)return false;
      }else{
        dist[to] = nd;
        used[to] = true;
        Q.push(to);
      }
    }
  }
  // negative check
  ll sm = *min_element(dist,dist+a);
  REP(i,a){
    if(sm + (ll)xmin[node[i]] < 0){
      return false;
    }
    if(i==a-1)break;
    sm -= dist[i+1]-dist[i];
  }
  return true;
}
 
bool valid(int n){
  REP(i,n)po[i]=false;
  REP(i,n){
    if(po[i])continue;
    a = 0;
    po[i] = true;
    node[a++] = i;
    queue<int> Q;
    Q.push(i);
    while(!Q.empty()){
      int p = Q.front(); Q.pop();
      REP(j,g[p].size()){
        int to = g[p][j].first;
        if(po[to])continue;
        po[to] = true;
        node[a++] = to;
        Q.push(to);
      }
    }
    sort(node,node+a);
    if(!check())return false;
  }
  return true;
}

int Sx[MAX],Sy[MAX];
int Mx[MAX],My[MAX];
 
int main(){
  scanf("%d%d%d",&r,&c,&n);
  REP(i,n){
    scanf("%d%d%d",xy+2*i,xy+2*i+1,val+i);
    Sx[i] = xy[2*i];
    Sy[i] = xy[2*i+1];
  }
  sort(Sx,Sx+n);
  sort(Sy,Sy+n);
  r = unique(Sx,Sx+n)-Sx;
  c = unique(Sy,Sy+n)-Sy;
  REP(i,r)Mx[Sx[i]]=i;
  REP(i,c)My[Sy[i]]=i;

  REP(i,c)xmin[i] = INF;
  REP(i,n){
    int x,y;
    x=Mx[xy[2*i]];
    y=My[xy[2*i+1]];
    CHMIN(xmin[y],val[i]);
    ys[x].emplace_back(y,val[i]);
  }
  // graph
  REP(i,r){
    sort(ALL(ys[i]));
    vector<pii> &vec = ys[i];
    REP(j,vec.size()-1){
      int s,t;
      s = vec[j].first;
      t = vec[j+1].first;
      int sa = vec[j+1].second - vec[j].second;
      g[s].emplace_back(t,sa);
      g[t].emplace_back(s,-sa);
    }
  }
  if(!valid(r)){
    puts("No");
    return 0;
  }
  // ok
  puts("Yes");
  return 0;
}


Measured memory_bytes: 12416
import numpy as np

n = int(input())
P = list(map(float, input().split()))
dp = np.zeros((n+1, n+1))
dp[0, 0] = 1
for i in range(n):
  dp[i+1, 0] = dp[i, 0] * (1-P[i])
  dp[i+1, 1:] = dp[i, :-1]*P[i] + dp[i, 1:]*(1-P[i])
print(dp[n, 1+n//2:].sum())

Measured memory_bytes: 84788
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main() {
	int n,a[M],b[M],c[M];
	ll lsum={},rsum={};
	cin>>n;
	priority_queue<int,vi,greater<int>> l;
	priority_queue<int> r;
	rep(i,0,n)cin>>a[i],lsum+=a[i],l.push(a[i]);
	rep(i,0,n)cin>>b[i];
	rep(i,0,n)cin>>c[i],rsum+=c[i],r.push(c[i]);
	ll ans=lsum-rsum;
	ll lans[M],rans[M];
	rep(i,0,n){
		lans[i]=lsum;
		lsum=lsum+b[i]-l.top();
		l.pop();
		l.push(b[i]);
		lans[i+1]=lsum;
	}
	reverse(b,b+n);
	rep(i,0,n){
		rans[i]=rsum;
		rsum=rsum+b[i]-r.top();
		r.pop();
		r.push(b[i]);
		rans[i+1]=rsum;
	}
	rep(i,0,n+1)ans=max(ans,lans[i]-rans[n-i]);
	print(ans);
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  string s;
  cin >> s;
  int pointA, ans;
  for(int i = 0; ; i++) {
    if(s[i] == 'A') {
      pointA = i;
      break;
    }
  }
  for(int i = s.size()-1; ; i--) {
    if(s[i] == 'Z') {
      ans = s.size() - (s.size() - i) - pointA + 1;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	long long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,a;
  cin >> n >> a;
  vector<int> x(n);
  rep(i,n) {
    cin >> x[i];
    x[i] -= a;
  }
  auto ind = [](int i) {
    assert(-2500 <= i);
    assert(i <= 2500);
    return i + 2500;
  };
  ll dp[55][5010] = {0};
  dp[0][ind(0)] = 1;
  for (int i = 0; i < n; ++i) { //dp(i,k) 0...iで総和がkとなる選び方の個数
    for (int k = -2500; k <= 2500; ++k) {
      dp[i+1][ind(k)] += dp[i][ind(k)];
      if (dp[i][ind(k)] > 0) {
        if (k+x[i] <= 2500 && k+x[i] >= -2500) {
          dp[i+1][ind(k+x[i])] += dp[i][ind(k)];
        }
      }
    }
  }
  cout << dp[n][ind(0)] - 1 << endl; //全て選ばないを除く
  return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_M 7
#define MAX_N 1000

int m;
int a[MAX_M];
int b[MAX_M];

int
solve(int n)
{
	int dp[MAX_M + 1][MAX_N + 1];

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

	for (int i = 0; i < m; ++i)
	{
		dp[i][0] = 1;
		for (int j = 0; j <= n; ++j)
		{
			if (dp[i][j] != 0)
			{
				int s = j;
				for (int k = b[i]; k >= 0 && s <= n; --k, s += a[i])
					dp[i + 1][s] += dp[i][j];
			}
		}
	}

	return dp[m][n];
}

int
main(int argc, char **argv)
{
	while (true)
	{
		scanf("%d", &m);
		if (m == 0)
			break;

		for (int i = 0; i < m; ++i)
			scanf("%d%d", &a[i], &b[i]);

		int g;
		int n;
		scanf("%d", &g);
		for (int i = 0; i < g; ++i)
		{
			scanf("%d", &n);
			printf("%d\n", solve(n));
		}
	}

	return 0;
}


Measured memory_bytes: 1712
# DP(配るDP)
INF = float('inf')

N = int(input())

c = [1]
t = 6
while t <= N:
    c.append(t)
    t *= 6
t = 9
while t <= N:
    c.append(t)
    t *= 9

dp = [INF] * (N + 1)
dp[0] = 0
for i in range(N):
    t0 = dp[i]
    for j in c:
        t1 = i + j
        if t1 <= N and dp[t1] > t0 + 1:
            dp[t1] = t0 + 1
        if t1 == N:
            break
print(dp[N])


Measured memory_bytes: 3828
def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    floor = 1
    ceil = 10
    for x in range(floor, ceil):
        if n % x == 0:
            if n // x in range(floor, ceil):
                return 'Yes'
    return 'No'


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
using namespace std;

int main()
{
	int n;
	char blood[5];
	int a,b,ab,o;
	
	a = b = ab = o = 0;
	while(scanf("%d,%s", &n, blood) != EOF){
		string str = blood;
		
		if(str == "A") a++;
		else if(str == "B") b++;
		else if(str == "AB") ab++;
		else if(str == "O") o++;
		
	}
	
	printf("%d\n%d\n%d\n%d\n", a, b, ab, o);
	
	return(0);
}

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

int main() {
 int n;
 cin >> n;
    
 vector<int> a(n);
 rep(i,n) {
 cin >> a.at(i);
 }
  
    long long maxdist = 10000000;
        
    for(int i = 1; i <= 100; i++){
      long long dist = 0;
        rep(j,n) {
     dist += abs(i - a.at(j)) * abs(i - a.at(j));
        }
      maxdist = min(dist, maxdist);
    }
    
    cout << maxdist;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		sc.close();
		
		int r = 1;
		while(L/(int)Math.pow(2,(r+1)) > 0) r++;
		
		int N = r + 1;
		StringBuilder sb = new StringBuilder();
		int cnt = 0;
		for(int i=0;i<r;i++) {
			sb.append((i+1) + " " + (i+2) + " " + 0 + "\n");
			sb.append((i+1) + " " + (i+2) + " " + (int)Math.pow(2, i) + "\n");
			cnt += 2;
		}
		
		int tmpMax = (int)Math.pow(2,r)-1;
		int rem = (L-1) - tmpMax;
		
		for(int i=25;i>=0;i--) {
			if(((rem>>i)&1)==1) {
				sb.append((i+1) + " " + N + " "  + (tmpMax+1) + "\n");
				tmpMax += (1<<i);
				cnt ++;
			}
		}
		
		System.out.println(N + " " + cnt);
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 22740
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
using namespace std;
template <typename lx> inline void read(lx &x){
	x = 0;int f = 1;char c = getchar();
	for(;c < '0' || '9' < c; c = getchar()) if(c == '-') f = -1;
	for(;'0' <= c && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;return;
}
template <typename lx> inline void print(lx x){
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
	return;
}
#define rg register
#define ll long long
#define r_2(a,b) read(a),read(b)
#define r_3(a,b,c) read(a),read(b),read(c)
#define print_n(a) print(a),puts("")
#define print_(a) print(a),putchar(' ')
const int inf = 2147483647;
int n,d;
int main()
{
	r_2(n,d);
	d = d * 2 + 1;
	print_n((n + d - 1) / d);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}

signed  main(){
	int t=1;
	//cin>>t;
	while(t--) {
		float n;
		cin>>n;
		int x=n+1;
		x/=2;
		cout<<(float)((x)/(n)) <<endl;
	}
	return 0;
}

Measured memory_bytes: 3776