akhauriyash/Code-Regression huggingface dataset:
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

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;  }
template<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int n; cin >> n;
    if(n % 10 == 3) {
        println("bon");
    } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
        println("pon");
    } else {
        println("hon");
    }

    return 0;
}


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

template<typename T>
T get_value(std::istream& is);

int main() {
  vector<int> v(get_value<size_t>(cin));
  for (auto& e: v)
    cin >> e;

  const auto ans {minmax_element(v.begin(), v.end())};
  cout << *ans.second - *ans.first << '\n';

  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a;
  vector<int> exi(n+1,1);
  for(int i = 0;i < m;i++){
    cin >> a;
    exi[a] = 0;
  } 
  vector<int> sum(n+1,0);
  sum[0] = 1;
  if(exi[1] == 1)sum[1] = 1;
  for(int i = 2;i <= n;i++){
    if(exi[i] == 0)sum[i] = 0;
    else{
      sum[i] = sum[i-1] + sum[i-2];
      sum[i] %= 1000000007;
    }
  }
  cout << sum[n] << endl;
}

Measured memory_bytes: 1024
line = gets.chomp.split('')
if line.length == 2
  if line[0] == line[1]
    puts '1 2'
  else
    puts '-1 -1'
  end
else
  (2...line.length).each do |i|
    if line[i - 2] == line[i - 1] || line[i - 2] == line[i] || line[i - 1] == line[i]
      puts "#{i - 1} #{i + 1}"
      exit(0)
    end
  end
  puts '-1 -1'
end

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int sn = 0, n_ = n;
    while (n_ != 0) {
        sn += n_ % 10;
        n_ /= 10;
    }

    Yes(n % sn == 0);
    return 0;
}



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

def matrixChainMultiplication(n):
    for l in range(2, n+1):
        for i in range(1, n-l+2):
            j = i + l - 1
            min_ = 2**21 # 十分大きい数
            for k in range(i, j):
                value = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]
                if min_ > value:
                    min_ = value
            m[i][j] = min_

m = [[0]*(101) for _ in range(101)]
p = [0] * 101
N = int(input())
l0 = list(map(int, input().split()))
p[0] = l0[0]
p[1] = l0[1]
for _ in range(1, N):
    li = list(map(int, input().split()))
    p[_+1] = li[1]
matrixChainMultiplication(N)
print(m[1][N])



Measured memory_bytes: 5688
#include<iostream>

using namespace std;

int ans=0;

void solve(int a){
    bool x =true;
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            x=false;
            break;
        }
    }
    if(x) ans++;
}

int main(){
    int n;
    cin>>n;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        solve(a);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>

int main(int argc, char const* argv[])
{
	int input;
	int flag = 1;
	int i = 1;

	while (flag)
	{
		std::cin >> input;
		if (input != 0)
		{
			std::cout << "Case " << i << ": " << input << std::endl;
			i++;
		}
		else
			flag = 0;

	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int N;
    int A1[101] = {};
    int A2[101] = {};

    cin >> N;
    for (int i = 1; i <= N; ++i)
    {
        int a;
        cin >> a;
        A1[i] = A1[i-1] + a;
    }
    for (int i = 1; i <= N; ++i)
    {
        int a;
        cin >> a;
        A2[i] = A2[i-1] + a;
    }

    int ans = 0;
    for (int i = 1; i <= N; ++i)
    {
        int cnum = A1[i] + (A2[N] - A2[i-1]);
        ans = max(ans, cnum);
    }

    cout << ans << endl;

    return 0;
}


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

for a in range(N+1):
    for b in range(N+1):
        if a + b <= N:
            c = N - a - b
            total = 10000*a + 5000*b + 1000*c
            if total == Y:
                print(a, b, c)
                exit()

print('-1 -1 -1')


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  int x=d[N/2-1],y=d[N/2];
  cout << y-x << endl;
}

Measured memory_bytes: 640
def main():
    S = input()
    mod = 10 ** 9 + 7
    A = AB = ABC = 0
    n = 1
    for i in S:
        if i == '?':
            ABC = ABC * 3 + AB
            AB = AB * 3 + A
            A = A * 3 + n
            n = n * 3 % mod
        if i == 'C':
            ABC = ABC + AB
        if i == 'B':
            AB = AB + A
        if i == 'A':
            A += n
    print(ABC % mod)

main()


Measured memory_bytes: 61276
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

/*

vecveci seen(10,veci(10));
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int H,W;
bool ok = true;

void dfs(vector<string> &G, int y, int x) {
    seen[y][x] = 1;
    bool go = false;
    REP(dir,4) {
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
        if(seen[ny][nx] || G[ny][nx] == '.') continue;
        if(dir == 0 || dir == 1) ok = false;
        go = true;
        //cout << y << "->" << ny << " " << x << "->" << nx << endl;
        dfs(G,ny,nx);
    }
    //cout << y << " " << x << " " << go << endl;
    if(!go) {
        if(y < H-1 || x < W-1) ok = false;
    }
}

int main() {
    cin >> H >> W;
    vector<string> G(H);
    REP(i,H) cin >> G[i];
    dfs(G,0,0);
    cout << (ok ? "Possible" : "Impossible") << endl; 
}

*/

int main() {
    int H,W; cin >> H >> W;
    vector<string> G(H);
    REP(i,H) cin >> G[i];
    int cnt = 0;
    REP(i,H) REP(j,W) if(G[i][j] == '#') cnt++;
    cout << (cnt == H+W-1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 3560
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int pas=0;
  cin >> pas;
  cout << pow(pas,3) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n , i , debt = 100000;
	scanf("%d" , &n);
	for(i=1;i<=n;i++){
		debt *= 1.05;
		if(debt%1000>0){
			debt = debt - (debt%1000) + 1000;
		}
	}
	printf("%d\n" , debt);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

vector<bool> isPrime;

void sieve(long max){
    if(max+1 > isPrime.size()){ 
        isPrime.resize(max+1, true);
    } 
    isPrime[0] = false;
    isPrime[1] = false;

    for(long i=2; i*i<=max; ++i) 
        if(isPrime[i]) 
            for(long j=2; i*j<=max; ++j) 
                isPrime[i*j] = false;  
}

int primeCnt[100005];

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

  int q;
  cin >> q;

  sieve(100005);

  primeCnt[0] = 0;
  primeCnt[1] = 0;

  for(int i = 2; i < 100005; i++) {
    primeCnt[i] = primeCnt[i-1] + ((isPrime[i]&&isPrime[(i+1)/2])?1:0);
  }

  rep(i, q) {
    int l, r;
    cin >> l >> r;
    cout << primeCnt[r] - primeCnt[l-1] << endl;
  }

}


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

typedef long long ll;

const int MN = 500012;
const ll mod = 1e9 + 7;

ll f[MN], fi[MN];
ll n, m;

ll modpow (ll a, ll b, ll m = mod) {
  ll res = 1;
  while (b) {
    if (b&1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}

void init () {
  f[0] = fi[0] = 1;
  for (ll i = 1; i < MN; i++) {
    f[i] = f[i - 1] * i % mod;
    fi[i] = modpow(f[i], mod - 2, mod);
  }
}

ll ncr (ll n, ll r) { return f[n] * fi[n-r] % mod * fi[r] % mod; }
ll npr (ll n, ll r) { return f[n] * fi[n-r] % mod; }

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  init();
  cin >> n >> m;
  ll ans = 0;
  for (ll i = 0; i <= n; i++) {
    ll cur = ncr(n, i) * npr(m, i) % mod * modpow(npr(m - i, n - i), 2, mod) % mod;
    if (i & 1) ans = (ans + mod - cur) % mod;
    else ans = (ans + cur) % mod;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 11452
#include <iostream>
#include<algorithm>
#include<cmath>
#include <string>

 int main (){

	 int a, b;

	 std::cin >> a >> b;

	 if (a % 2 == 0) {
		 std::cout << "Even" << std::endl;
		 return 0;
	 }
	 if (b % 2 == 0) {
		 std::cout << "Even" << std::endl;
		 return 0;
	 }

	 std::cout << "Odd" << std::endl;

	 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    if (a < b)
        cout << "<";
    else if (b < a)
        cout << ">";
    else
        cout << "=";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		String T = scan.nextLine();
		int flag = 0;

		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == T.charAt(i)) {
				continue;
			}else {
				flag = 1;
				break;
			}
		}

		if(flag == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		scan.close();
	}
}


Measured memory_bytes: 35700
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int L,A[200005],dp[200005][5];

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    cin>>L;
    for(int i=1;i<=L;i++){
        cin>>A[i];
    }
    for(int i=1;i<=L;i++){
        for(int j=0;j<=4;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    dp[0][3]=0;
    dp[0][4]=0;
    A[L+1]=0;
    for(int i=1;i<=L+1;i++){
        dp[i][4]=dp[i-1][4]+A[i];
        if(A[i]==0){
            dp[i][3]=min(dp[i-1][4]+2,dp[i-1][3]+2);
        }else{
            dp[i][3]=min(dp[i-1][4]+A[i]%2,dp[i-1][3]+A[i]%2);
        }
        
        dp[i][2]=min(dp[i-1][4]+(A[i]+1)%2,min(dp[i-1][3]+(A[i]+1)%2,dp[i-1][2]+(A[i]+1)%2));
        
        long long int tmp=min(dp[i-1][4],dp[i-1][3]);
        tmp=min(tmp,dp[i-1][2]);
        tmp=min(tmp,dp[i-1][1]);
        if(A[i]==0){
            dp[i][1]=tmp+2;
        }else{
            dp[i][1]=tmp+A[i]%2;
        }
        tmp=min(tmp,dp[i-1][0]);
        dp[i][0]=tmp+A[i];
        //cout<<dp[i][4]<<" "<<dp[i][3]<<" "<<dp[i][2]<<" "<<dp[i][1]<<" "<<dp[i][0]<<endl;
    }
    cout<<dp[L+1][0];
} 


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

int main(){
    int n,l;
    cin >> n >> l;
    if(l>=0)cout << (2*l+n-1)*n/2-l << endl;
    else if(n+l>0){
        cout << (2*l+n-1)*n/2 << endl;
    }
    else {
        cout << (2*l+n-1)*n/2-(l+n-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#pragma region templates 


//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<math.h>
#include<string>
#define all(v) v.begin(),v.end()
#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))
#define REV(x) reverse(x.begin(),x.end())
#define pi pair<int,int>
#define SORT(v) sort(all(v))
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

using namespace std;

ll gcd(ll a, ll b) { if (a == 0)return(b); else return(gcd(b % a, a)); }
int modularexpo(ll a, ll b, ll c)
{
	if (a == 0)
	{
		return 0;
	}
	if (b == 0)
	{
		return 1;
	}
	else {
		if (b % 2 == 0)
		{
			long smallans = modularexpo(a, b / 2, c);
			int ans = ((smallans % c) * (smallans % c)) % c;
			return (ans + c) % c;
		}
		else {
			long smallans = modularexpo(a, b - 1, c);
			long ans = a % c;
			ans = ((ans % c) * (smallans % c)) % c;
			return (ans + c) % c;
		}
	}
}
long combination(int n, int r)
{
	long long ans = 1;
	r = r > n - r ? n - r : r;
	int j = 1;
	for (; j <= r; j++, n--)
	{
		if (n % j == 0)
		{
			ans *= n / j;
		}
		else
			if (ans % j == 0)
			{
				ans = ans / j * n;
			}
			else
			{
				ans = (ans * n) / j;
			}
	}
	return ans;
}
int binary(int* arr, int l, int r, int x)
{
	while (l <= r)
	{
		int mid = (l + r) / 2;
		if (arr[mid] == x)
		{
			return mid;
		}
		else if (arr[mid] < x)
		{
			l = mid + 1;
		}
		else
		{
			r = mid - 1;
		}
	}
	return -1;
}
#pragma endregion

int main()
{
	
		int n, k;
		std::cin >> n >> k;
		int* arr = new int[n];
		for (int i = 0; i < n; i++)
		{
			std::cin >> arr[i];
		}
		int* dp = new int[k + 1];
		dp[0] = 2;
		sort(arr, arr + n);
	    for (int i = 1; i < k+1; i++)
		{
			int flag = 2;
			for (int j = 0; j < n; j++)
			{
				if (i < arr[j])
				{
					break;
				}
				else {
					if (dp[i - arr[j]] == 2)
					{
						flag = 1;
						break;
					}
				
				}
			}
			dp[i] = flag;
		}
		if (dp[k] == 1)
		{
			std::cout << "First";
		}
		else
		{
			std::cout << "Second";
		}
	

	return 0;
}


Measured memory_bytes: 3984
#include <cstdio>
#include <stack>
#include <algorithm>

using namespace std;

int H,W;
char S[2500][2500];
int c[5000][5000];
int h[5000][5000];
int l[5000];
int r[5000];
long long answer;
int main() {
  scanf("%d%d", &H, &W);
  answer = max(W,H);
  for(int i=0;i<H;++i) {
    scanf("%s", S[i]);
  }
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if (S[i][j]=='.') {
        S[i][j] = 0;
      } else {
        S[i][j] = 1;
      }
    }
  }
  for(int i=0;i<H-1;++i) {
    for(int j=0;j<W-1;++j) {
      int sum = S[i][j] + S[i+1][j] + S[i][j+1] + S[i+1][j+1];
      c[i*2+1][j*2+1] = sum % 2;
    }
  }
  W=W*2-1;
  H=H*2-1;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if (c[i][j] == 1) {
        h[i][j] = 0;
      } else if (i==0 || c[i-1][j] == 1) {
        h[i][j] = 1;
      } else {
        h[i][j] = h[i-1][j] + 1;
      }
    }
  }
  for(int i=0;i<H;++i) {
    stack<int> S;
    for(int j=0;j<W;++j) {
      while(!S.empty() && h[i][S.top()] >= h[i][j]) S.pop();
      if (S.empty()) {
        l[j] = 0;
      } else {
        l[j] = S.top() + 1;
      }
      S.push(j);
    }
    S=stack<int>();
    for(int j=W-1;j>=0;--j) {
      while(!S.empty() && h[i][S.top()] >= h[i][j]) S.pop();
      if (S.empty()) {
        r[j] = W-1;
      } else {
        r[j] = S.top() - 1;
      }
      S.push(j);
    }

    for(int j=0;j<W;++j) {
      int w = r[j]-l[j] + 1;
      answer = max(answer, 1ll * (h[i][j] - h[i][j]/2) * (w - w/2));
    }
  }

  printf("%lld\n", answer);
  return 0;
}


Measured memory_bytes: 166144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

char arr[200020];
int main() {
	scanf("%s",arr);
	int l = strlen(arr), sum = 0;
	for(int i=0; i<l; i++) {
		sum+=arr[i]-'0';
	}
	if(sum%9)
		printf("No");
	else {
		printf("Yes");
	}
}	



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

typedef long long ll;

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



















Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PIB pair<int,bool>
#define PIL pair<int,long long>
#define MP make_pair
#define X first
#define Y second
using namespace std;
const int maxn=44;
long long e[maxn]; int v[maxn],n,m;
void init(){
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;++i) scanf("%d",v+i);
    for (int i=1,a,b;i<=m;++i) scanf("%d%d",&a,&b),--a,--b,e[a]+=1LL<<b,e[b]+=1LL<<a;
}
void print(long long x){
	if (!x) return; print(x/2); putchar((x&1)+'0');
}
map<PIL,PIB>mp;
void spfa(){
	int ans=~0u>>1;
	static const int maxN=10000011;
    static PIL q[maxN]; int t=0,w=1; q[1]=MP(0,1); mp[q[1]]=MP(v[1],1);
    while (t!=w){
        if (++t==maxN) t=1; mp[q[t]].Y=0;
        if (q[t].X==n-1){
            long long s=q[t].Y|e[n-1]; int V=0;
            for (int i=0;i<n;++i) if ((s>>i)&1) V+=v[i];
            if (V<ans) ans=V;
        }else{
			for (int i=0;i<n;++i) if (!((q[t].Y>>i)&1) && ((e[q[t].X]>>i)&1)){
				PIL nw=MP(i,q[t].Y|e[q[t].X]); int V=0;
				for (int j=0;j<n;++j) if ((nw.Y>>j)&1) V+=v[j];
				map<PIL,PIB>::iterator son=mp.find(nw);
				if (son==mp.end()) mp[nw]=MP(V,0),son=mp.find(nw);
				else if (son->Y.X>V) son->Y.X=V; else continue;
				if (!son->Y.Y){
					son->Y.Y=1; if (++w==maxN) w=1; q[w]=nw; //cout<<nw.X<<' '; print(nw.Y); putchar('\n');
				}
			}
		}
    }
	printf("%d\n",ans);
}
void work(){
    spfa();
}
int main(){
    init();
    work();
    return 0;
}

Measured memory_bytes: 158888
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    cout << 24+24-n << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char a[3];
  scanf("%s",a);
  for(int i=0;i<3;i++){
  if(a[i]=='1')a[i]='9';
    else if(a[i]=='9')a[i]='1';
  }
  printf("%s",a);
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  LL ans = 0;
  LL next = 0;
  int N; cin >> N;
  vector<LL> A; A.reserve(N+1); 
  REP0(i, N+1) cin >> A[i];
  
  vector<LL> B; B.reserve(N);
  REP0(i, N) { 
      cin >> B[i];
      if (A[i] < B[i]) {
          ans += A[i];
          next = min(A[i+1], B[i] - A[i]);
          A[i+1] -= next;
          ans += next;
      } else {
          ans += B[i];
          next = 0;
      }
  }
  cout << ans << endl;  
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  int r,g,b,n; cin >> r >> g >> b >> n;

  int ans = 0;
  for(int ri = 0; ri * r <= n; ++ri) {
    int rem = n - (ri * r);
    for(int gi = 0; gi * g <= rem; ++gi) {
      int remB = rem - (gi * g);
      if(remB % b == 0) ++ans;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

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

    int ret = 0;
    ret += 1 * min(a, k), k -= min(a, k);
    ret += 0 * min(b, k), k -= min(b, k);
    ret += -1 * min(c, k), k -= min(c, k);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n ,k =0,k1 = 0 ;
	cin>>n;
	for(int i = 0 ; i < n ;i ++)
	{
		int l ;
		cin>>l;
		if(l % 2 == 0)
		{
		    k++;	
		}else
		{
			k1++;
		}
	}
	if(k1 == 1 && k ==0)
	{
		cout<<"YES";
		return 0;
	}
	if(k1 % 2 != 0 )
	{
		cout<<"NO";
	}else
	{
		cout<<"YES";
	}
}

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

# 0初期化ではダメ。組合せ不可を表し、演算しても問題ない状態にしておく
dp=[-float("inf")] * (N+1)
dp[0]=0

cost =[0, 2,5,5,4,5,6,3,7,6]
for i in range(N+1):
    for a in A:
      # -inf初期化なので、不可能なものの演算結果も同じ
       new_i = i + cost[a]
       if new_i <= N:
        dp[new_i] = max([dp[new_i],  dp[i]+1])

sa = sorted(A, reverse=True)
n = N
ans = 0
while n > 0:
  for a in sa:
    nn = n-cost[a]
    if nn >= 0 and dp[n] == dp[nn] +1:
      ans = ans * 10 + a
      n -= cost[a]
      break

print(ans)

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

int main() {
    int H, W;
    cin >> H >> W;
    string C[H];
    for(int i = 0; i < H; i++) {
        cin >> C[i];
    }
    for(int i = 0; i < H; i++) {
        cout << C[i] << endl;
        cout << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
time=map(int,open(0).read().split())

arr=[]
for t in time:
  amari=t % 10
  if amari == 0:
    d=amari
  else:
    d=10-amari
  arr.append([d, t])

arr.sort(key=lambda x: x[0])

total=0
for x in arr[:-1]:
  total+=sum(x)
print(total+arr[-1][1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int INF = 1e8;
const int N = 2e5 + 10;
int work[N][2];
VI ans[N];
bool reach[N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
  s = "#" + s;

  for (int i = 1; i <= n; i++) {
    work[i][0] = max(work[i - 1][0], work[i - 1][1]);
    work[i][1] = -INF;
    if (s[i] == 'o') {
      work[i][1] = 1;
      if (i - c - 1 >= 0) {
        work[i][1] += max(work[i - c - 1][0], work[i - c - 1][1]);
      }
    }
//    cerr << work[i][1] << endl;
  }
  if (max(work[n][0], work[n][1]) > k) {
    return 0;
  }

  int prv = k + 1;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'o') {
      if (prv <= work[i][1] + 1) {
        ans[work[i][1]].push_back(i);
        reach[i] = true;
      }
    }
    if (i + c <= n && (reach[i + c] || work[i + c][1] == k)) {
      prv = min(prv, work[i + c][1]);
    }
  }
  for (int d = 1; d <= k; d++) {
    if (ans[d].size() == 1) {
      cout << ans[d][0] << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 14416
#include<bits/stdc++.h>
using namespace std;
long long fact(long long n){
    long long cnt=(n*(n-1))/2;
    return cnt;
}
int main()
{
  map<int,int>mp;
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
  map<int,int>::iterator it;
  long long sum=0;
  for(it=mp.begin();it!=mp.end();it++){
   // cout<<it->first<<" "<<it->second<<endl;
    sum+=fact(it->second);

  }
  //cout<<sum<<endl;
  for(int i=0;i<n;i++){
    if(mp[a[i]]<2){
        cout<<sum<<endl;
    }
    else{
        long long sum1=sum;
        sum1=sum1-fact(mp[a[i]]);
        sum1+=fact(mp[a[i]]-1);
        cout<<sum1<<endl;
    }
  }
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define MOD 1000000007

using namespace std;

long long fastpow(long long a, int b)
{
    if(b == 0) return 1;
    if(b % 2) return (a * fastpow(a, b-1))%MOD;
    long long c = fastpow(a, b/2);
    return (c * c)%MOD;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string tc, pt;
    cin>>tc;
    cin>>pt;
    
    long long n = tc.size();
    long long m = pt.size();
    long long m2 = m;
    long long h = fastpow(62,m2-1);

    long long patternheight = 0, tcheight = 0;
    for(long long i = 0; i < m2; i++){
        patternheight = (62 * patternheight + pt[i]) % MOD;
        tcheight = (62 * tcheight + tc[i]) % MOD;
    }

    for(long long i = 0; i <= n-m; i++){
        if(patternheight == tcheight){
           /* bool isMatched = true;
            for(long long j = 0; j < m && isMatched; j++)
            {
                if(p[j] != t[j+i]) isMatched = false;

            }
            if(isMatched) */cout<<i<<endl;

        }
        
        if(i < n-m) {
		tcheight = (62*(tcheight - (h*tc[i])) + tc[i+m2]) % MOD;
			}
		
        if(tcheight < 0){
		tcheight += MOD;
			}
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    vector<ll> M(2019, 0);
    ll res = 0;
    for(auto c: s) {
        int x = c - '0';
        vector<ll> N(2019, 0);
        for(int i = 0; i < 2019; i++) {
            N[(10 * i + x) % 2019] += M[i];
        }
        N[x] += 1;
        M = N;
        res += M[0];
    }

    cout << res << endl;
}

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

const int N = 10005;
int a[N], b[N];
int n;
long long ans;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	for (int i = 1; i <= n; ++i) {
		int c = b[i] - a[i];
		if (c < 0) ans += c;
		else ans += c / 2;
	}
	if (ans < 0) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 384
#include <cstdio>

int main(void){
	int n, a, b;
	scanf("%d", &n);
		
	if(n == 1){
		printf("Hello World\n");
	}else if(n == 2){
		scanf("%d", &a);	
		scanf("%d", &b);
		printf("%d\n", a + b);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int A[50];
int main(){
  int n;
  cin>>n;
  for(int i = 0;i < n; i ++)cin>>A[i];
  int ans = 0;
  for(int i = 0 ; i < n ; i ++){
  	for(int j = i+1 ; j < n ; j ++){
    	ans += A[i]*A[j];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
my $fac = 998244353;
my $N = <STDIN>;
chomp($N);
my $T;
my $i = 0;
foreach my $d (map {$_ + 0} split(/ /o, <STDIN>)){
    $T->{$d} = 0 unless (defined($T->{$d}));
    $T->{$d}++;
    if ($i == 0 and $d != 0) {
      print 0;
      exit 0;
    }
    $i++;
}
if ( !defined($T->{0}) or $T->{0} != 1) {
    print 0;
    exit 0;
}
$i = 0;
my $ans = 1;
my $last = 1;
foreach my $j (sort {$a <=> $b} keys %{$T}) {
    my $val = $T->{$j};
    if ( $i != $j ) {
        print 0;
        exit 0;
    }
    if ( $i == 0 ) {
    } else {
        my $v = &modpower($last, $val);
        $ans = ($ans * $v) % $fac;
    }
    $last = $val;
    $i++;
}
print $ans;
sub modpower($$) {
    my ($a, $n) = @_;
    my $res = 1;
    while ($n > 0) {
        $res = $res * $a % $fac if ($n & 1);
        $a = $a * $a % $fac;
        $n >>= 1;
    }
    return $res;
}

Measured memory_bytes: 34508
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    long long A, B, C, K; cin >> A >> B >> C >> K;
    long long D = max(max(A, B), C);
    D *= pow(2, K);
    cout << A + B +C+D-max(max(A,B),C) << endl;
}

Measured memory_bytes: 3824
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
typedef struct{
    ll a; ll cnt;
}array;

int cmp(const void *a, const void *b){
    ll A=((array *)a)->a, B=((array *)b)->a;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート1,2,....9
}

int main(void){
    ll N, K;
    array X[100100];
    scanf("%lld %lld", &N, &K);
    rep(i, N) scanf("%lld %lld", &X[i].a, &X[i].cnt);
    qsort(X, N, sizeof(array), cmp);
    ll sum=0, ans;
    rep(i, N) {
        sum += X[i].cnt;
        if(sum>=K) {
            ans = X[i].a;
            break;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

using P = pair<int, char>;

int main() {
    int n;
    cin >> n;
    while(n--) {
        vector<P> v(9);
        for(int i=0; i<9; ++i) {
            cin >> v[i].first;
        }
        for(int i=0; i<9; ++i) {
            cin >> v[i].second;
        }
        sort(v.begin(), v.end());
        bool ok = false;
        do {
            bool f = true;
            for(int i=0; i<3; ++i) {
                if(v[3*i].second != v[3*i+1].second || v[3*i].second != v[3*i+2].second || v[3*i+1].second != v[3*i+2].second) {
                    f = false;
                }
                int t1 = v[3*i+1].first - v[3*i].first;
                int t2 = v[3*i+2].first - v[3*i+1].first;
                if((t1 != 0 || t2 != 0) && (t2 != 1 || t1 != 1)) {
                    f = false;
                }
            }
            ok |= f;
        } while(next_permutation(v.begin(), v.end()));
        cout << ok << endl;
    }
}


Measured memory_bytes: 3000
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

typedef pair<int, P> T;
struct edge {
	P to;
	int cost;
};
map<P, vector<edge>> G;
map<P, int> d;
void dijkstra(P s) {
	priority_queue<T, vector<T>, greater<T>> que;
	d[s] = 0;
	que.push(T(0, s));
	while (!que.empty()) {
		T p = que.top(); que.pop();
		P v = p.second;
		//cout << v.first << ' ' << v.second << endl;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d.count(e.to) == 0 || d[v] + e.cost < d[e.to]) {
				d[e.to] = d[v] + e.cost;
				que.push(T(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int p, q, c;
		cin >> p >> q >> c;
		p--;
		q--;
		if (G.count(P(p, c)) == 0) {
			G[P(p, c)] = { (edge) { P(p, 0), 1 } };
			G[P(p, c)].push_back((edge) { P(q, c), 0 });
		}
		else {
			G[P(p, c)].push_back((edge) { P(p, 0), 1 });
			G[P(p, c)].push_back((edge) { P(q, c), 0 });
		}
		if (G.count(P(p, 0)) == 0) {
			G[P(p, 0)] = { (edge) { P(p, c), 0 } };
		}
		else {
			G[P(p, 0)].push_back((edge) { P(p, c), 0 });
		}
		if (G.count(P(q, c)) == 0) {
			G[P(q, c)] = { (edge) { P(q, 0), 1 } };
			G[P(q, c)].push_back((edge) { P(p, c), 0 });
		}
		else {
			G[P(q, c)].push_back((edge) { P(q, 0), 1 });
			G[P(q, c)].push_back((edge) { P(p, c), 0 });
		}
		if (G.count(P(q, 0)) == 0) {
			G[P(q, 0)] = { (edge) { P(q, c), 0 } };
		}
		else {
			G[P(q, 0)].push_back((edge) { P(q, c), 0 });
		}
	}
	dijkstra(P(0, 0));
	//cout << d[P(0, 0)] << endl;
	if (d.count(P(N - 1, 0)) == 0) printf("-1");
	else printf("%d", d[P(N - 1, 0)]);
}

Measured memory_bytes: 111024
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(H: int, W: int, A: int, B: int):

    F = [0] * (H + W + 1)
    F[0] = 1
    for i in range(1, H + W + 1):
        F[i] = (F[i-1] * i) % MOD
    F2 = [0] * (H + W + 1)
    F2[0] = 1
    for i in range(1, H+W+1):
        F2[i] = (F2[i-1] * pow(i, MOD-2, MOD)) % MOD
    def nck(a, b):
        if a == 0 and b == 0:
            return 1
        return (F2[a-b] * F2[b] % MOD) * F[a] % MOD
    total = nck(H+W-2, H-1)
    removed = 0
    for k in range(A):
        removed += nck(H-k-1+B-1, H-k-1) * nck(k+W-B-1, k)
        removed %= MOD
    res = (total - removed) % MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(H, W, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18880
H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for i in range(H)]
C=[[0] for i in range(H)]
for i in range(H):
  for j in range(W):
    C[i].append(C[i][j]+S[i][j])
def f(b,l,r):
  R=[0]
  for i in range(H):
    R[-1]+=C[i][r+1]-C[i][l]
    if i!=H-1:
      if b&(1<<i):
        R.append(0)
  return max(R)

INF=10**12
P=INF
Q=0
L=0
for x in range(1<<(H-1)):
  Q=bin(x).count('1')
  L=0
  for i in range(W):
    if f(x,L,i)>K:
      Q+=1
      L=i
      if f(x,L,i)>K:
        Q=INF
        break
  P=min(P,Q)
print(P)

Measured memory_bytes: 75096
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    string S; cin >> S;
    string s = '0' + S;
    int N = S.length();
    
    int flag = 1;
    for (int i = 1; i <= N; i++) {
        if (s[i] != s[N-i+1]) {
            flag = 0;
        }
    }
    for (int i = 1; i <= (N-1)/2; i++) {
        if (s[i] != s[(N-1)/2 - i+1]) {
            flag = 0;
        }
    }
    for (int i = (N+3)/2; i <= N; i++) {
        if (s[i] != s[N-(i-(N+3)/2)]) {
            flag = 0;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
	int a, b;
	cin >> a >> b;
	int x = 1;
	bool exist = false;

	for (x = 1; x < 1010; x += 1)
	{
		int vat_8 = floor(0.08 * (double)x);
		int vat_10 = floor(0.1 * (double)x);

		if (a == vat_8 && b == vat_10)
		{
			exist = true;
			break;
		}
	}

	if (exist)
	{
		cout << x << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
          if ( (a < b) && (b < c) ){
            System.out.println("Yes");
          }
          else {
            System.out.println("No");
          }
        }
      }


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

using ll = long long;
const int mxN = 2e3, mod = 2019;

string s;

int mul (int a) {
	while (a >= mod) {
		a -= mod;
	}
	return a;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n, dp[2][mod] = {0}, ans = 0;
	cin >> s; n = s.size(); s = '#' + s;
	dp[0][0] = 1;
	for (int i=1; i<=n; i++) {
		int bit1 = (i&1)^1, bit2 = i&1;
		dp[bit2][0] = 1;
		for (int j=0; j<mod; j++) {
			dp[bit2][mul(j*10+int(s[i]-'0'))] += dp[bit1][j];
			dp[bit1][j] = 0;
		}
		ans += dp[bit2][0]-1;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 3816
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long Gcd(long long a, long long b)
{
  long long tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  long long r;
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }  
  return b;
}
int main(){
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  long long numa=0;
  long long numb=0;
  long long numc=0;
  long long gcd = Gcd(C,D);
  long long CD=C*D/gcd;
  numa=(long long)(B/C) - (long long)((A-1)/C);
  numb=(long long)(B/D)-(long long)((A-1)/D);
  numc=(long long)(B/(CD))-(long long)((A-1)/(CD));
  cout<<B-A+1-numa-numb+numc<<endl;

  return 0;
}



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

int main(){
  int N;
  string S;

  cin>>N>>S;


  ll r=0,g=0,b=0;
  rep(i,N){
    if(S[i] == 'R'){
      r++;
    }else if(S[i] == 'G'){
      g++;
    }
    else if(S[i] == 'B'){
      b++;
    }
  }

ll ans = r*g*b;

for(int width = 1; width<N;width++){
  for(int l=0; l+2*width<N; l++){
    if(S[l] != S[l+width] && S[l+width] != S[l+2*width] && S[l] != S[l+2*width]){
      ans--;
    }
  }
}
cout<<ans;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double calcDistance(int x[], int y[], int n, int p){
	double result = 0;
	if(p > 0){
		for(int i = 0; i < n; i++){
			result += pow(abs(x[i] - y[i]),p);
		}
		result = pow(result,(double)1.0/(double)p);
	}else if(p == -1){
		double tmp = 0;
		for(int i = 0; i < n; i++){
			tmp = abs(x[i] - y[i]);
			result = max(result, tmp);
		}
	}
	return result;
}

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

	int x[100];
	int y[100];
	
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> y[i];
	}

	cout << fixed << setprecision(10);

	cout << calcDistance(x, y, n, 1) << endl;
	cout << calcDistance(x, y, n, 2) << endl;
	cout << calcDistance(x, y, n, 3) << endl;
	cout << calcDistance(x, y, n, -1) << endl;

	return 0;
}


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

int c[501]; //cost from i to i+1
int s[501]; //start time i th station
int f[501]; // frequency time to i th station
int n;

int calc(int pos) {
    int time = 0;
    while (pos != n) {
        int depart_time = max ( (time+f[pos]-1)/f[pos] * f[pos], s[pos]);
        time = depart_time + c[pos];
        pos++;
    }
    
    return time;
}
int main() {
    
    cin >> n;
    for (int i=1; i < n; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i=1; i <= n; i++) {
        cout << calc(i) << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
def ten_count(n):
    cnt=0
    while True:
        n=n/10
        cnt+=1
        if n < 1:
            break
    return cnt

N=int(input())
  
ans_list=[]
for i in range(1,int(N**0.5)+2):
    if N%i==0:
        A=int(i)
        B=int(N/i)
        
        a=ten_count(A)
        b=ten_count(B)
        
        ans_list.append(max(a,b))
        
print(min(ans_list))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define debug(x) cout<<#x<<": "<<x<<endl
typedef long long ll;

/* 2017/01/18 問題 -----  abc052 c /Link ----- */
/* -----解説等-----
問題:

1000!がでかすぎる。

*/
 
ll N;

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

    cin >> N;

    //prime
    vector<int>primes;
    primes.push_back(2);
    for (int i = 3; i < 1001; i += 2) {
        int flag = 0;
        FOR(j, 2, i) {
            if (i%j==0) {
                flag = 1;
                break;
            }
        }
        if (flag == 0) {
            primes.push_back(i);
        }
    }


    ll ans = 1;

    FOR(i, 0, primes.size()) {
        int p = primes[i];
        int cnt = 0;
        while (p <= N) {
            cnt += N / p; //2,4,8,16,....
            p = p*primes[i];
        }
        ans = (ans*(cnt + 1)) % MOD;
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))

l.sort()

icnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[j]!=l[k]:
                if l[k]<l[i]+l[j]:
                    icnt+=1
                    
print(icnt)


Measured memory_bytes: 9184
from  collections import deque

S = str(input())
Q = int(input())

#Que = [list(map(str, input().split())) for _ in range(Q)]

deque_S = deque(S)
re_flag = 1
for i in range(Q):
    que = str(input())

    if len(que) == 1:
        #S = S[::-1]
        re_flag *= -1

    else:
        if que[2] == '1':
            if re_flag == 1:
                #S = que[4:] + S
                deque_S.appendleft(que[4:])
            else:
                #S =  S + que[-1:3:-1]
                deque_S.append(que[-1:3:-1])
        if que[2] == '2':
            if re_flag == 1:
                #S = S + que[4:]
                deque_S.append(que[4:])
            else:
                #S = que[-1:3:-1] + S
                deque_S.appendleft(que[-1:3:-1])

ans = ''
if re_flag == 1:
    ans = ''.join(deque_S)
else:
    ans = ''.join(deque_S)[::-1]
#print(deque_S)

print(ans)

Measured memory_bytes: 13288