akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0);
		char b = sc.next().charAt(1);
		char c = sc.next().charAt(2);
		System.out.println(a + "" + b + "" +c);
	}

}


Measured memory_bytes: 38876
#include<cstdio>
using namespace std;
int main(){
  int a,b,c,ans;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b)
    ans=c;
  else if(b==c)
    ans=a;
  else
    ans=b;
  printf("%d\n",ans);
}

Measured memory_bytes: 128
H,W = map(int,input().split())
List=[input() for i in range(H)]
A =[[] for i in range(H)]
B =[[] for i in range(W)]
for i in range(H):
    k = 0
    a = 0
    while k < W:
        if List[i][k]==".":
            a += 1
            k = k+1
        else:
            for j in range(a):
                A[i].append(a)
            A[i].append(0)
            a = 0
            k = k+1
    for j in range(a):
                A[i].append(a)
for i in range(W):
    k = 0
    a = 0
    while k < H:
        if List[k][i]==".":
            a += 1
            k = k+1
        else:
            for j in range(a):
                B[i].append(a)
            B[i].append(0)
            a = 0
            k = k+1
    for j in range(a):
                B[i].append(a)
max = 0
for i in range(H):
    for j in range(W):
        if max < A[i][j] + B[j][i]:
            max = A[i][j] + B[j][i]
print(max-1)
        


Measured memory_bytes: 125272
#include<bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define lli long long int
int main()
{
        lli number_of_times;
        cin>>number_of_times;
            if(number_of_times%2==0)
                {
                    cout<<(number_of_times/2)<<endl;
                }
            else
            {
                  cout<<((number_of_times/2)+1)<<endl;
            }
            
    return 0;
}

Measured memory_bytes: 256
class UnionFindTree
  def initialize(n)
    @parent = (0..n).to_a
    @rank = Array.new(n+1, 0)
  end
     
  def find(x)
    return x if @parent[x] == x
    return @parent[x] = find(@parent[x])
  end
     
  def unite(a, b)
    a = find(a)
    b = find(b)
    return if a == b
    if @rank[a] < @rank[b]
      @parent[a] = b
    else
      @parent[b] = a
      @rank[a] += 1 if @rank[a] == @rank[b]
    end
  end
  
  def same?(a, b)
    find(a) == find(b)
  end
end

N, M = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
b = Array.new(N+1)
a.each.with_index(1) do |x, i|
  b[x] = i
end

uf = UnionFindTree.new(N)
M.times do
  x, y = gets.split.map(&:to_i)
  uf.unite(x, y)
end

cnt = 0
(1..N).reverse_each do |i|
  if b[i] == i
    cnt += 1
    next
  end
  
  x = i;
  y = b[i];
  if uf.same?(x, y)
    cnt += 1
  end
end
puts cnt

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

using namespace std;

int main(int argc, char const *argv[])
{
	int x, y, a, b, c; 
    cin >> x >> y;
    a=x+y;
    b=x-y;
    c=x*y;
    if (a>b) {
        if (a>c)
        {
            cout << a << endl;
        } else {
            cout << c << endl;
        }
    } else {
        if (b>c)
        {
            cout << b << endl;
        } else {
            cout << c << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i

t = Rational(4, N)

(1..3500).each do |h|
  (1..3500).each do |n|
    a = N * h * n
    b = 4 * h * n - N * n - N * h

    next if b <= 0
    next if a < b
    next if a % b != 0

    w = a / b

    puts [h, n, w.to_i].join(' ')
    exit
  end
end


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		short temp[] = new short[3];
		for (int i = 0; i < 10; i++) {
			short num  = scan.nextShort();
			if (temp[0] < num) {
				temp[2] = temp[1];
				temp[1] = temp[0];
				temp[0] = num;
				continue;
			}
			if (temp[1] < num) {
				temp[2] = temp[1];
				temp[1] = num;
				continue;
			}
			if (temp[2] < num) {
				temp[2] = num;
				continue;
			}
		}
		for (short i = 0; i < 3; i++) {
			System.out.println(temp[i]);
		}
		scan.close();
	}
}

Measured memory_bytes: 17328
#include<cstdio>
typedef long long ll;
int K,N,ans[300010],len;
ll siz[300010];
void dfs(int i,ll k){
	if(!k){len=i;return;}
	int s=siz[N-i-1],t=ans[i]=(k+s-1)/s;
	dfs(i+1,k-(t-1ll)*s-1);
}
int main(){
	scanf("%d%d",&K,&N);
	if(K%2){
		int m=siz[0]=1;
		while((siz[m]=siz[m-1]*K+1)<=N)m++; 
		for(int i=0;i<N;i++,len++){
			if(N-i>m)ans[i]=K/2+1;
			else{dfs(i,siz[N-i-1]*K-i+1>>1);break;}
		}
	}
	else for(int i=len=N;i--;)ans[i]=i?K:K/2;
	for(int i=0;i<len;i++)printf("%d%c",ans[i]," \n"[i==N-1]);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int x;
    cin >> x;
    vector<bool> ret(1010, false);
    for(int i = 1; i*i <= 1000; i++){
        if(i == 1)ret[1] = true;
        else{
            int j = i * i;
            while(j <= 1000){
                ret[j] = true;
                j *= i;
            }
        }
    }
    for(int i = x; i > 0; i--){
        if(ret[i]){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N,V; cin>>N>>V;
    vector<int> a(N),b(N),c(N),d(N);
    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<N;i++) cin>>b[i];
    for(int i=0;i<N;i++) cin>>c[i];
    for(int i=0;i<N;i++) cin>>d[i];

    vector<int> x,y;
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) x.push_back(a[i]+b[j]);
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) y.push_back(c[i]+d[j]);
    sort(y.begin(),y.end());

    int ans=0;
    for(int i:x){
        auto p=equal_range(y.begin(),y.end(),V-i);
        ans+=p.second-p.first;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 23136
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int a[N];
int main() {
	int n;
	cin >> n;
	int s = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		s ^= a[i];
	}
	for(int i = 1; i <= n; i++) printf("%d%c", a[i] ^ s, i == n ? '\n' : ' ');
}






Measured memory_bytes: 4476
#include <stdio.h>
int main(){
	int n,a;
	scanf("%d",&n);
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)printf("hon\n");
	else if(a==0||a==1||a==6||a==8)printf("pon\n");
	else if(a==3)printf("bon\n");
	return 0;
}

Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+2;
struct train{
	int l,r;
}t[N];
bool cmp(train a,train b){
	if(a.l!=b.l) return a.l<b.l; return a.r<b.r;
}
int sum[502][502];
int main(){
	int n,m,q;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&t[i].l,&t[i].r);
	}
	sort(t+1,t+m+1,cmp);
	int tot=1;
	for(int i=1;i<=n;i++){
		if(t[tot].l>i) continue;
		//printf("%d %d %d\n",i,t[tot].l,t[tot].r);
		for(int j=i;j<=n;j++){
			//if(i==4) printf("%d\n",j);
			sum[i][j]+=sum[i][j-1];
			if(t[tot].l==i){
				if(t[tot].r==j){
					int l=t[tot].l,r=t[tot].r;
					//printf("%d %d\n",t[tot].l,t[tot].r);
					while(t[tot].l==l&&t[tot].r==r){tot++; sum[i][j]++;}
					//printf("%d %d\n",t[tot].l,t[tot].r);
				}
			}
		}
	}
	while(q--){
		int l,r; scanf("%d%d",&l,&r);
		int ans=0;
		for(int i=l;i<=r;i++) ans+=sum[i][r];
		printf("%d\n",ans);
	}
return 0;
}

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

int main(){
    int a[6],l = 1,n = 1;
    string m;
    while(1){
    a[0]=1;a[1]=3;a[2]=6;a[3]=4;a[4]=2;a[5]=5;
    cin>>n;
    if(n == 0)break;
	l = a[0];
    for(int i = 0 ; i < n ; i++){
        cin>>m;
        if(m == "North"){
            a[6]=a[0];a[0]=a[4];a[4]=a[2];a[2]=a[5];a[5]=a[6];
        }if(m == "East"){
            a[6]=a[0];a[0]=a[3];a[3]=a[2];a[2]=a[1];a[1]=a[6];
        }if(m == "West"){
            a[6]=a[0];a[0]=a[1];a[1]=a[2];a[2]=a[3];a[3]=a[6];
        }if(m == "South"){
            a[6]=a[0];a[0]=a[5];a[5]=a[2];a[2]=a[4];a[4]=a[6];
        }if(m == "Right"){
            a[6]=a[4];a[4]=a[1];a[1]=a[5];a[5]=a[3];a[3]=a[6];
        }if(m == "Left"){
            a[6]=a[4];a[4]=a[3];a[3]=a[5];a[5]=a[1];a[1]=a[6];
        }
        l = l +a[0];
    }
    cout<<l<<endl;
    }

    return 0;
}


Measured memory_bytes: 3180
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)

b = [0] * (n+1)
b[0] = 3

ans = 1
for ai in a:
    ans *= b[ai]
    ans %= 1000000007
    b[ai] -= 1
    b[ai+1] += 1

print(ans)


Measured memory_bytes: 53300
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

Graph g;
vector<int> col;

bool dfs(int v, int c){
  col[v] = c;

  REP(i, g[v].size()){
    if(col[g[v][i]] == 0){
      if(!dfs(g[v][i], -c)) return false;
    }
    else if(col[g[v][i]] == c){
      return false;
    }
  }

  return true;
}

int main(){
  ll n, m; cin >> n >> m;
  g.resize(n); col.resize(n, 0);
  REP(i, m){
    int x, y; cin >> x >> y;
    x--; y--;

    g[x].push_back(y);
    g[y].push_back(x);
  }
  
  if(dfs(1, 1)){
    ll b = 0, w = 0;
    REP(i, n){
      if(col[i] == 1) b++;
      else if(col[i] == -1) w++;
    }

    cout << b * w - m << endl;
  }
  else{
    cout << n*(n-1)/2 - m << endl;
  }

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string s;
	cin >> s;

	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	if (s == "Rainy") {
		cout << "Sunny" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int p2[55],res=1;
	p2[0]=1;p2[1]=x%inf;
	for(int i=2;i<=50;i++){
		p2[i]=p2[i-1]*p2[i-1];
		p2[i] %= inf;
	}
	for(int i=1;i<=50;i++){
		if(k%2==1){
			res *= p2[i];
			res %= inf;
		}
		k /= 2;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	setkaijo(11450);
	setinv(11450);
	if( b % 2 != 0 ){
		cout<<0<<endl;
		return 0;
	}
	int w = b / 2;
	int m = min(a,c);
	int ans = 0;
	for(int y = 0; y <= m; y++ ){
		int x = a - y;
		int zma = ( c - y ) / 3;
		for(int z = 0; z <= zma; z ++ ){
			int amari = c - y - 3 * z;
			int tmp = ka[ x + y + z + w ];
			tmp *= inv[x];
			tmp %= inf;
			tmp *= inv[y];
			tmp %= inf;
			tmp *= inv[z];
			tmp %= inf;
			tmp *= inv[w];
			tmp %= inf;
			if( w > 0 ){
				tmp *= comb( amari+w-1, w-1 );
				tmp %= inf;
			}
			else{
				if( amari != 0 ){
					tmp *= 0;
				}
				else{
					tmp *= 1;
				}
			}
			ans += tmp;
			ans %= inf;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
D = []
A = []
for i in range(K):
    d = INT()
    D.append(d)
    a = LIST()
    A.append(a)

B = []
for i in A:
    for j in i:
        B.append(j)

ans = 0
for i in range(N):
    if i+1 not in B:
        ans += 1
print(ans)


Measured memory_bytes: 10696
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		
		if(a>=b) {
			for(int i=0;i<a;i++)
				System.out.print(b+"");
		}
		
		else {
			for(int i=0;i<b;i++)
				System.out.print(a+"");
		}

	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<utility>
#include<map>
#include<vector>
#include<string>
using namespace std;


int main() {
	int n, ans=0;
	vector<int>l;
	map<int, int>rl;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int L;
		cin >> L;
		l.push_back(L);
	}
	sort(l.begin(), l.end());
	for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
		auto itr = lower_bound(l.begin(), l.end(), l[i] + l[j]);
		ans += max((int)(itr - l.begin() - j - 1), 0);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=5e4+5,maxm=4e5+5;
const ll inf=1e18;
inline int fa(int u){ return u/2; }
inline int ls(int u){ return u*2; }
inline int rs(int u){ return u*2+1; }
struct heap{
	int hea[maxn],pos[maxn],siz;
	ll *dis;
	heap(ll a[],int n){
		dis=a; siz=n;
		int i;
		for (i=1;i<=n;i++){
			dis[i]=inf; hea[i]=i; pos[i]=i;
		}
	}
	void hswap(int u,int v){
		swap(hea[u],hea[v]);
		pos[hea[u]]=u; pos[hea[v]]=v;
	}
	void update(int u){
		if (u==1) return;
		if (dis[hea[fa(u)]]<=dis[hea[u]]) return;
		hswap(u,fa(u));
		update(fa(u));
	}
	void pushdown(int u){
		int v=u;
		if (ls(u)<=siz&&dis[hea[ls(u)]]<dis[hea[v]]) v=ls(u);
		if (rs(u)<=siz&&dis[hea[rs(u)]]<dis[hea[v]]) v=rs(u);
		if (u==v) return;
		hswap(u,v);
		pushdown(v);
	}
	void change(int u,ll val){
		dis[u]=val;
		update(pos[u]);
		pushdown(pos[u]);
	}
	int pop(){
		hswap(1,siz);
		siz--;
		pushdown(1);
		return hea[siz+1];
	}
};
struct gragh{
	int head[maxn],next[maxm],to[maxm],tot;
	ll wei[maxm],cost[maxn];
	gragh(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void clear(){
		memset(head,-1,sizeof(head));
		tot=0;
	}
	void add(int u,int v,ll w,ll c){
		next[tot]=head[u];
		head[u]=tot;
		to[tot]=v;
		wei[tot]=w;
		cost[tot]=c;
		tot++;
	}
	void dijkstra(ll dis[],ll val[],int st,int n){
		heap hp(dis,n);
		hp.change(st,0);
		int i,u,v,ed;
		for (i=1;i<=n;i++) val[i]=inf;
		val[st]=0;
		while (hp.siz){
			u=hp.pop();
			for (ed=head[u];ed!=-1;ed=next[ed])
				if (dis[v=to[ed]]>dis[u]+wei[ed])
					hp.change(v,dis[u]+wei[ed]);
		}
		for (u=1;u<=n;u++) for (ed=head[u];ed!=-1;ed=next[ed])
			if (dis[v=to[ed]]==dis[u]+wei[ed])
			val[v]=min(val[v],cost[ed]);
	}
};
gragh g;
ll dis[maxn],val[maxn];
int main(){
	int n,m,i,u,v;
	ll w,c,ans;
	while (scanf("%d%d",&n,&m)&&(n||m)){
		g.clear();
		for (i=0;i<m;i++){
			scanf("%d%d%lld%lld",&u,&v,&w,&c);
			g.add(u,v,w,c);
			g.add(v,u,w,c);
		}
		g.dijkstra(dis,val,1,n);
		ans=0;
		for (i=1;i<=n;i++) ans+=val[i];
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 4504
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

long long GetDigit(long long num) { return std::to_string(num).length(); }
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M);
    vector<char> c(M);
    rep(i, 0, M) {
        cin >> s[i];
        cin >> c[i];
    }
    bool kekka = false;
    rep(i, 0, 1000) {
        string tmp = to_string(i);
        bool k = true;
        if(tmp.length() != N) {
            continue;
        }
        rep(j, 0, M) {
            if(s[j] > N || tmp[s[j] - 1] != c[j]) {

                k = false;
            }
        }
        if(k) {
            kekka = true;
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

using namespace std;

uint16_t
bubblesort(vector<uint16_t>& A) {
    bool flag = true;
    uint16_t times = 0;
    while(flag) {
        flag = false;
        for(size_t j = A.size() - 1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                uint16_t tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                ++times;
                flag = true;
            }
        }
    }
    return times;
}

void
out(const vector<uint16_t>& A) {
    for (int i = 0; i < A.size() - 1; i++) {
        cout << A[i] << " ";
    }
    cout << A[A.size() - 1] << endl;
}

int
main(int argc, char** argv) {
    uint16_t n; cin >> n;
    vector<uint16_t> A(n);
    for (auto& a : A) {
        cin >> a;                                                                                                                 }
    auto times = bubblesort(A);
    out(A);                                                                                                                       cout << times << endl;

}


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

string str[3];
int cnt[3];
int main(){
	for(int i = 0;i < 3;i++)cin >> str[i];
	for(int i = 0;i < 3;i++)cnt[i] = str[i].size();
	if(str[0][cnt[0]-1] == str[1][0] && str[1][cnt[1]-1] == str[2][0])
	cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

int main(void){

//     string s,t;
// int n;
// cin>>n;
//     cin>>s>>t;
//     for(int i=0;i<s.size();i++){
//         cout<<s[i]<<t[i];
//     }
//     cout<<endl;

    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    if(a==1&&b==2)fin(3);
    else if(a==1&&b==3)fin(2);
    else if(a==2&&b==3)fin(1);
}


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

def assignColor(G):
    n = len(G)
    C = [-1 for i in range(n)]
    for i in range(n):
        if C[i] == -1:
            C = BFS(G, i, C)
    return C

#@profile
def BFS(G, start, C):
    n = len(G)
    Q = [start]
    C[start] = start

    while len(Q) != 0:
        u = Q.pop(0)
        v = [i for i in G[u] if C[i] == -1] # v := ??£??\???????????????????????¢?´¢??????????????????
        
        for i in v:
            Q.append(i)
            C[i] = C[start]
    
    return C

def main():
    
    n, m = list(map(int, input().split()))
    G = [[] for i in range(n)]

    for i in range(m):
        s, t = list(map(int, input().split()))
        G[s].append(t)
        G[t].append(s)

    C = assignColor(G)
        
    q = int(input())
    
    for i in range(q):
        s, t = list(map(int, input().split()))
        if C[s] == C[t]:
            print("yes")
        else:
            print("no")
            
if __name__ == "__main__":
    main()    

Measured memory_bytes: 32680
S = input()

if len(S)%2 == 0:
    itr = int(len(S)/2)
else:
    itr = int((len(S)+1)/2)

counter = 0
i = 0
while i != itr :
    i = i+1
    if S[i-1] != S[-i] :
        counter = counter + 1

print(counter)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s= sc.next().toCharArray();
		for (int i=1;i<4;i++) {
			if (s[i]==s[i-1]) {
				System.out.println("Bad");
				return ;
			}
		}

		System.out.println("Good");

	}

}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	/*
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 文字列の入力
		String s = sc.next();
		// 出力
		System.out.println((a+b+c) + " " + s);

	}
	*/
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		
		int bigger = H >= W ? H : W;
		
		int ans = N / bigger;
		if( N % bigger != 0){
			ans++;
		}
		
		System.out.println(ans);
	}	
}

Measured memory_bytes: 21844
N = list(map(int, input().split()))
d = {0:0}

pos=[]
for x in range(N[0]):
    a = list(map(int, input().split()))
    for y in pos:
        key = (a[0]-y[0])*(10**11)+(a[1]-y[1])
        if key<0:
            key=-key
        if key not in d.keys():
            d[key] = 0
        d[key] += 1
    pos.append(a)
    
print(N[0]-max(d.values()))

Measured memory_bytes: 3064
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n; 

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n;
    
    string x;
    cin >> x;

    int ans = 0;

    int idx = 0, jdx = n - 1;

    while(idx < jdx) {

        for(int i = idx; i < n; i++) {
            if(x[i] == 'W') {
                idx = i;
                break;
            }
        }

        for(int j = jdx; j >= 0; j--) {
            if(x[j] == 'R'){
                jdx = j;
                break;
            }
        }  

        if(x[idx] != 'W' || x[jdx] != 'R') break;

        if(idx >= jdx) break;
        
        swap(x[idx], x[jdx]);
        ans ++;
        idx++;
        jdx--;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3744
n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = b[0]
count = 1
ans = 0
for i in range(1,n+1):
    if b[i] == check:
        count += 1
    else:
        ans += count * (count - 1) // 2
        check = b[i]
        count = 1
ans += count * (count - 1) // 2            
print(ans)
    



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

long long n, a, tot, ans, mod = 1e9+7;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        ans += tot*a;
        ans %= mod;
        tot += a;
        tot %= mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3628
#include <stdio.h>

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


    scanf("%d %d %d",&a,&b,&c);
    count = 0;
    for (i = a;  i<=b; i++){
      if (c%i==0){
      count = count+1;
    }


   }

  printf("%d\n",count);

return(0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
long long n, m, s, a[100000];
int main() {
	int i;
	scanf("%lld", &n);
	for(i=0; i<n; i++) scanf("%lld", &a[i]);

	sort(a, a+n);

	for(i=n-1; i; i--) {
		if(a[i]==a[i-1]) {
			if(m==0) m = a[i];
			else {s = m*a[i]; break;}
			i--;
		}
	}

	printf("%lld", s);

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>

char s[100001];

bool solve(int i);

int main(void){
    scanf("%s", s);

    printf("%s\n", solve(0) ? "YES" : "NO");

    return 0;
}

bool solve(int i){
    bool result = false;
    if(s[i] == '\0'){
        return true;
    }

    //printf("i:%d s:%s\n", i, s + i);

    int len = strlen(s + i);

    if(strncmp(s + i, "dream", 5) == 0){
        result |= solve(i + 5);
    }

    if(strncmp(s + i, "erase", 5) == 0){
        result |= solve(i + 5);
    }

    if(strncmp(s + i, "eraser", 6) == 0){
        result |= solve(i + 6);
    }

    if(strncmp(s + i, "dreamer", 7) == 0){
        result |= solve(i + 7);
    }

    return result;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
using namespace std;

int cnt[2][4005][4005];
int psum[2][4005][4005];
int find(int b,int si,int sj,int ei,int ej){
	return psum[b][ei][ej]-psum[b][ei][sj]-psum[b][si][ej]+psum[b][si][sj];
}
int main(){
	int N, K; scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		int x,y; char c;
		scanf("%d %d %c",&x,&y,&c);
		cnt[c=='W'][x%(2*K)+1][y%(2*K)+1]++;
		cnt[c=='W'][x%(2*K)+2*K+1][y%(2*K)+1]++;
		cnt[c=='W'][x%(2*K)+1][y%(2*K)+2*K+1]++;
		cnt[c=='W'][x%(2*K)+2*K+1][y%(2*K)+2*K+1]++;
	}
	for(int k=0;k<2;k++){
		for(int i=1;i<=4*K;i++){
			for(int j=1;j<=4*K;j++){
				psum[k][i][j]=cnt[k][i][j]+psum[k][i-1][j]+psum[k][i][j-1]-psum[k][i-1][j-1];
			}
		}
	}
	int ans=0;
	for(int i=0;i<2*K;i++){
		for(int j=0;j<2*K;j++){
			ans=max(ans, find(0,i,j,i+K,j+K) + find(1,i+K,j,i+2*K,j+K) + find(1,i,j+K,i+K,j+2*K) + find(0,i+K,j+K,i+2*K,j+2*K));
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 250752
#include <iostream>

int main(int argc, char *argv[]){
    int N, X;
    std::cin >> N >> X;
    int L[N];
    for(auto &l : L){
        std::cin >> l;
    }

    int D = 0;
    int nBound = 1;
    for(int i=0; i<N; ++i){
        if((D+=L[i])<=X){
            ++nBound;
        }
    }
    std::cout << nBound << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int n, ans = 0;cin>>n;
  rep(i,n){
    int a;cin>>a;
    int cnt = 0;
    while(a % 2 == 0){
      a /= 2;cnt++;
    }
    ans += cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int h,w;
LL tmp=1e9+7;
unordered_map <LL,int> Map;
int Min[N];
int main(){
	Map.clear();
	h=read(),w=read();
	int n=read();
	for (int i=1;i<=h;i++){
		Min[i]=w+1;
		Map[tmp*i+w+1]=1;
	}
	while (n--){
		int x=read(),y=read();
		Map[tmp*x+y]=1;
		Min[x]=min(Min[x],y);
	}
	int x=1,y=1;
	while (1){
		x++;
		if (!Map[tmp*x+y+1])
			y++;
		if (Min[x]<=y){
			printf("%d\n",x-1);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 29684
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=1e3+1,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    ll d,s,t;
    cin>>d>>t>>s;
    if(s*t>=d){
        cout<<"Yes"<<endl;
    } else cout<<"No"<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int R,G,B,N;
    int Ans=0;
    cin >>R>>G>>B>>N;
    for(int i=0;i<=(N/R);i++){
        for(int j=0;j<=((N-R*i)/G);j++){
            if(((N-R*i-G*j)%B)==0){
                Ans++;
            }
        }
    }
    cout <<Ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
//#include <unordered_map>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

#define fopen freopen("substrcmp.in", "r", stdin); freopen("substrcmp.out","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define IOSFAST ios::sync_with_stdio(false); cin.tie(0)

const ll MOD = 1000LL * 1000 * 1000 + 7;
const int INF = 1e9;
const ll base = 1e18;
const int MAX = 1000;
const double EPS = 1e-9;
const double PI = acos(-1.);

int n;
pair<int,int> a[200000];
int main()
{
	IOSFAST;
	cin >> n;
	FOR(i,0,n)
	{
		cin >> a[i].f;
		a[i].s = i;
	}
	sort(a,a+n);
	int res = 0;
	FOR(i,0,n)
	{
		if (abs(a[i].s-i)%2)
		{
			res++;
		}
	}
	cout << res/2;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int k, count=0;
	scanf(" %d", &k);
	for (int i=0;i<=k;i++) {
		for (int j=i+1;j<k;j++) {
			if ((i%2==0&&j%2==1)||(i%2==1&&j%2==0)) {
				count++;
			}
		}
	}
	printf("%d\n", count);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		System.out.println((a >= 13) ? b : (a <= 5) ? 0 : b/2);

		sc.close();
	}
}

Measured memory_bytes: 21844
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def ggg(a,b):
	while b>0:
		nb=a%b
		na=b
		a,b=na,nb
	return a
		

def main():
	n, x = IN()
	al = list(IN())
	al.append(x)
	al.sort()
	bl=[b-a for a,b in zip(al,al[1:])]
	ret=bl[0]
	for diff in bl:
		ret = ggg(ret, diff)
	return ret
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 64024
import collections
n=int(input())
a=list(input() for i in range(n))

a = collections.Counter(a)
a= a.most_common()
b=[]
b.append(a[0][0])
for i in range(len(a)-1):
    if a[i][1]==a[i+1][1]:
        b.append(a[i+1][0])
    else:
        break

b.sort()
for i in range(len(b)):
    print(b[i])

Measured memory_bytes: 43612
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int T=sc.nextInt();
        int[] t=new int[n];
        int[] c=new int[n];
        for (int i = 0; i < n; i++) {
            c[i]=sc.nextInt();
            t[i]=sc.nextInt();
        }
        int ans=114514;
        for (int i = 0; i < n; i++) {
            if(t[i]<=T)ans=min(ans,c[i]);
        }
        if(ans==114514){
            out.println("TLE");
        }else{
            out.println(ans);
        }
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const ll mod = 1000000007;
using namespace std;

int N,K;
int cnt[maxn];
ll f[111][maxn],pre[maxn];

ll solve(){
    for(int i = 0;i<=K;i++) f[1][i] = (i<=cnt[1])? 1:0;
    for(int i = 2;i<=N;i++){ // child
        memset(pre,0,sizeof pre);
        pre[0] = f[i-1][0];
        for(int j = 1;j<=K;j++) pre[j] = (f[i-1][j] + pre[j-1]);
        for(int j = K;j>=0;j--){ //want to use
            if(j-cnt[i]-1 >= 0) f[i][j] = pre[j] - pre[j-cnt[i]-1];
            else f[i][j]  =  pre[j];
            f[i][j] %= mod;
        }
    }
    return f[N][K];
}

int main(){
    // debug;
    ios;

    cin>>N>>K;
    for(int i = 1;i<=N;i++) cin>>cnt[i];
    cout<<solve()<<'\n';

    
    return 0;
}


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

  string S ;
  cin >> S ;
  int count = 0 ;
  int A ;
  int B ;
  int N = S.size() ;
  int ans = 0 ;
  for(int i = 0 ; i < N ; i++){
    if (S.at(i) == 'A'){
      A = i ;
      break ;
    }
  }
  for(int i = N-1 ; i >= 0 ; i-- ){
     if (S.at(i) == 'Z'){
      B = i ;
      break ;
     }
  }
 cout << B - A + 1 << endl;
}

Measured memory_bytes: 644
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

bool palindrome(string s){
	string s1 = s;
	reverse(all(s1));
	return (s == s1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int n = s.size();
	if(palindrome(s) && palindrome(s.substr(0, n / 2)) && palindrome(s.substr(((n + 3) / 2) - 1, n / 2))) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
import types
N=int(input())

#print(26*26,26**3,26**4)

a=[]
a.append(0)
         
for i in range(12):
  t = 26**i + a[i]
  if N >= t:
    x = i+1 #文字数
  a.append(t)

#print("x",x)
#print("a[x]",a[x])

b=N-a[x] #差分
#print("b",b)
c=[]


for i in range(x):
  tmp=0
  d=0
  if len(c) == 0:
    d=b // 26**(x-i-1)
  else:
    for j in range(len(c)):
      tmp += 26**(x-j-1)*c[j]
    #print("i",i,"tmp",tmp)
    d=(b-tmp) // 26**(x-i-1)
  #print("d",d)
  c.append(d)

#print(c)

x=ord("a")
for i in range(len(c)):
  print(chr(x+c[i]), end="")


Measured memory_bytes: 9224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    switch(N % 10){
        case 0:
        case 1:
        case 6:
        case 8:
        cout << "pon" << endl;
        break;
        
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon" << endl;
        break;
        
        default:
        cout << "bon" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int A, B, T, res;

int main() {
	cin >> A >> B >> T;
	for (int i = A; i <= T; i += A) {
		res += B;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int a,b,c;cin>>a>>b>>c;
  int res=-a+b+c;
  if(res>=0){
    cout<<res<<endl;
  }else{
    cout<<0<<endl;
  }
}

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

using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (A + B - 1 > N || A * B < N) {
        cout << -1 << endl;
        return 0;
    }
    if (A == 1) {
        rep(i, B) {
            cout << N - i << " ";
        }
        cout << endl;
        return 0;
    }
    int Q = (N - B) / (A - 1), R = (N - B) % (A - 1);
    //cout << "Q=" << Q << ", R=" << R << endl;
    rep(i, Q) {
        rep(j, A) {
            cout << N - A - i * A + j + 1 << " ";
        }
    }
    if (R == 0) {
        rep(i, B - Q) {
            cout << B - Q - i << " ";
        }
        cout << endl;
        return 0;
    }
    rep(i, R + 1) {
        cout << N - Q * A - R + i << " ";
    }
    rep(i, B - Q - 1) {
        cout << B - Q - 1 - i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
    ll H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    
    for (ll i=0; i<H; i++){
      for (ll j=0; j<W; j++){
        char tmp;
        cin >> tmp;
        if(tmp == '.') tmp ='0';
        s[i][j] = tmp;
      }
    }

    vector<ll> dx = {-1, 0, +1, -1, 1, -1, 0, 1};
    vector<ll> dy = {-1, -1, -1, 0, 0, 1, 1, 1};

    //間の処理
    for (ll i=0; i<H; i++){
      for (ll j=0; j<W; j++){
          if (s[i][j] == '#'){
            for (ll d=0; d<8; d++){
              const ll x = i + dx[d]; 
              const ll y = j + dy[d];
           
              if (x < 0) continue;
              if (x >= H) continue;
              if (y < 0) continue;
              if (y >= W) continue;

              if(s[x][y] == '#') continue;
              s[x][y] = char(int(s[x][y])+1);
                            
              
            }    
              
          }
      }
    }


    
    for (ll i=0; i<H; i++){
      for (ll j=0; j<W; j++){
        cout << s[i][j];
      }
      cout << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

typedef long long ll;

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    ll ans;
    if(m==1){
        ans=1;
        for(int i=0;i<n;i++){
            ans=(ans*2) %1000000;
        }
    }
    if(m==2){
        int dp[150][4];
        dp[0][2]=4;
        dp[0][1]=3;
        dp[0][0]=3;
        dp[0][3]=3;
        for(int i=0;i<n-1;i++){
            dp[i+1][2]=dp[i][2];
            for(int j=0;j<=i;j++){
                dp[i+1][2]+=dp[j][0];
            }
            dp[i+1][2]+=2+dp[i][1];
            
            dp[i+1][1]=dp[i][1];
            for(int j=0;j<=i;j++){
                dp[i+1][1]+=dp[j][1];
            }
            dp[i+1][1]+=1+dp[i][3];
            
            dp[i+1][0]=dp[i][0];
            for(int j=0;j<=i;j++){
                dp[i+1][0]+=dp[j][2];
            }
            dp[i+1][0]+=1+dp[i][1];
            
            dp[i+1][3]=dp[i][3]+2*dp[i][1];
            
            dp[i+1][2]=dp[i+1][2]%1000000;
            dp[i+1][1]=dp[i+1][1]%1000000;
            dp[i+1][0]=dp[i+1][0]%1000000;
        }
        ans=dp[n-1][2];
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3100
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : yash1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
using namespace std;
# define ll  long long int 
# define TEST int t ; cin>>t; while(t--)
# define line cout<<endl;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define loop(i,a,b) for(long long int i=a;i<b;i++)
# define loopIn(i,a,b) for(long long int i=a;i<=b;i++)
# define Vi vector<int>
#define MAX_SIZE 1000000000
using namespace std ;
int main(){
	fast
	string s ;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

    return 0;
}
	

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

int main() {

    string s;
    int k;
    cin>>k;
    cin>>s;
    int p=s.size();
    if(p>k) {
        for(int i=0; i<k; i++) {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    } else {
        cout<<s<<endl;
    }





    return 0;
}


Measured memory_bytes: 3588