akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
const int N = 305;
const int M = 305;

int main (void)
{
	int a , b ;
	int i , n ;
	while(scanf("%d %d" , &a , &b))
	{
		if(a == 0 && b == 0)
		{
			return 0;
		}
		for(i = 0 ; i < a ; i++)
		{
			for(n = 0 ; n < b ; n++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d=0,e=1,i,j,k,l;
 cin>>a;
  map<ll,ll>m;
  m[a]=1;
  while(1)
  {
  if(a%2==0){a=a/2;}
  else  a=a*3+1;
  if(m[a]==0)m[a]=1;
  else break;   
    e++;
 

  }
cout<<e+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define endl '\n'
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, sum = 0;
    cin >> n >> m;
    int a[m];
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    cout << ((sum <= n) ? n - sum : -1) << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;cin>>A>>B;
  int x=0;
  for(int i=A; i<=B; i++){
    string a=to_string(i);
    if(a[0]==a[4]&&a[1]==a[3])x++;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	string str;
	int n;

	cin >> str >> n;

	for (int i = 0; i < n; i++)
	{
		string command;
		cin >> command;

		if (command == "replace")
		{
			int f, t;
			string newStr;
			cin >> f >> t >> newStr;
			str.replace(f, t - f + 1, newStr.c_str());
		}
		else if (command == "reverse")
		{
			int f, t;
			cin >> f >> t;
			reverse(str.begin() + f, str.begin() + t + 1);
		}
		else if (command == "print")
		{
			int f, t;
			cin >> f >> t;
			for (int j = f; j <= t; j++)
			{
				printf("%c", str[j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3216
#include<stdio.h>
int main(){
	int n,a[105],b[105],f=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n-2;i++) if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]) f=1;
	if(f) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M; cin >> N >> M;
  int tot = 0, A;
  for(int i = 0; i < M; i++){
    cin >> A;
    tot += A;
  }
  cout << max(-1, N - tot) << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int h,w;
    cin >> w >> h;
    int ww,hh,x,y;
    cin >> ww >> hh >> x >> y;
    double lx = max(-w/2.0, x-ww/2.0);
    double rx = min(w/2.0, x+ww/2.0);
    double ly = max(-h/2.0, y-hh/2.0);
    double ry = min(h/2.0, y+hh/2.0);
    //cout << shosu(10) << lx << " " << rx << " " << ly << " " << ry << endl;
    double dx = (lx + rx)/2;
    double dy = (ly + ry)/2;
    //cout << dx << " "<< dy << endl;
    cout << shosu(10) << dy/dx << endl;
}



Measured memory_bytes: 3284
#include <iostream>

using namespace std;

int main() {
    int h, n, ai, s;
    s = 0;
    cin >> h >> n;
    for (int i=0; i<n; i++){
        cin >> ai;
        s += ai;
    }
    if (s < h) {
        cout << "No";
    } else {
        cout << "Yes";
    }
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c;
    cin >> a >> b >> c;
    cout << ((a + b >= c) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
### constant

INF = 1 << 30

### main

loop do
  n = gets.to_i
  break if n == 0

  blns = n.times.map{gets.split.map(&:to_i)}
  #p blns

  dp = (n + 1).times.map{4.times.map{INF}}
  dp[0][0] = 0

  prvp = 0
  prvt = 0
  ng = nil
  
  for i in (0...n)
    pi, ti = blns[i]
    catch = false
    
    for j in (0..3)
      dij = dp[i][j]
      next if dij >= INF

      # return to home
      dt = prvp * (j + 1) + pi
      if prvt + dt <= ti
        d = dij + prvp + pi
        if dp[i + 1][1] > d
          dp[i + 1][1] = d
          catch = true
        end
      end

      # catch directly
      if j < 3
        dd = (pi - prvp).abs
        dt = dd * (j + 1)
        if prvt + dt <= ti
          d = dij + dd
          if dp[i + 1][j + 1] > d
            dp[i + 1][j + 1] = d
            catch = true
          end
        end
      end
    end
    
    if ! catch
      ng = i + 1
      break
    end
    
    prvp = pi
    prvt = ti
  end

  if ng
    puts "NG #{ng}"
  else
    min_d = dp[n].min + prvp
    puts "OK #{min_d}"
  end
end

Measured memory_bytes: 6152
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn score(c: &[i64], s: &[Vec<i64>], t: &[usize]) -> i64 {
    let d = t.len();
    let mut last = vec![0; 26];
    let mut sc = 0;
    for i in 0..d {
        last[t[i]] = i as i64 + 1;
        sc += s[i][t[i]];
        for j in 0..26 {
            sc -= (i as i64 - last[j] + 1) * c[j];
        }
    }
    sc
}

fn rnd_nxt(rnd: &mut u64) -> u32 {
    *rnd = rnd.wrapping_mul(0xdeadc0de01111011).wrapping_add(0x13331);
    (*rnd >> 32) as u32
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    }
    let mut rnd = 1000;
    let mut t = vec![0; d];
    for i in 0..d {
        t[i] = rnd_nxt(&mut rnd) as usize % 26;
    }
    for i in 0..d {
        puts!("{}\n", t[i] + 1);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2348
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int H, W;
	cin >> H >> W;
	
	for_(y,0,H) for_(x,0,W) {
		string S;
		cin >> S;
		if (S == "snuke") cout << char('A' + x) << 1+y << endl;
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//


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

namespace ABC_158c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int num = -1;

            for (int i = 1; i < 8000; i++)
            {
                if (Math.Floor(i * 0.08) == input[0] && Math.Floor(i * 0.1) == input[1])
                {
                    num = i;

                    break;
                }
            }
            Console.WriteLine(num);

            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
def b_search(A, a, left=None, right=None):
    if left is None:
        left = 0
    if right is None:
        right = len(A)
    if left == right:
        return False
    mid = (left + right) // 2
    if a == A[mid]:
        return True
    elif a > A[mid]:
        return b_search(A, a, mid + 1, right)
    else:
        return b_search(A, a, left, mid)


N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))
ans = 0
for t in T:
    ans += b_search(S, t)
print(ans)



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

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

  if (abs(a - b) <= d && abs(b - c) <= d)
    cout << "Yes" << endl;
  else if (abs(a - c) <= d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, z, w;
    cin >> n >> z >> w;
    int a[n];
    rep(i, n) cin >> a[i];
    if (n > 1) cout << max(abs(w - a[n - 1]), abs(a[n - 2] - a[n - 1])) << endl;
    else cout << abs(w - a[n - 1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
const ll inf = 1000000000000000;
ll in = 1000000000000000000;
using namespace std;
int main()
{
	FastIO;
	ll t, a, i, j, k, n, q;
	cin >> k >> n;
	if (2 * k >= n)
	{
		i = 0;
	}
	else
	{
		i = n - 2 * k;
	}
	ll sum = 0;
	for (;i<= min(k,n) ;i++)
	{
		a = n - i;
		if (a >= k)
		{
			sum += 2 * k - a + 1;
		}
		else
		{
			sum += a + 1;
		}
	}
	cout << sum << endl;

	return 0;
}


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

int main()
{
  
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int s=0;
  int ma=0;
  for(int i=1;i<n;i++)
  {
    
    if(a[i]>a[i-1])
    {
      int x=i-1-s;
      if(x>ma)
        ma=x;
      s=i;
    }
    else
      if(i==n-1)
    {
      int x=i-s;
      if(x>ma)
        ma=x;
      s=i;

    }
    else
      continue;
  }
  cout<<ma;
 
  
  return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int xmax=x,ymin=y;
	for(int i=0;i<n;i++){
		cin>>x;
		xmax=max(x,xmax);
	}
	while(cin>>y)
		ymin=min(y,ymin);
	cout<<(xmax<ymin?"No War":"War")<<endl;
}


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

int main() {
  int total_money;
  int one_yen;
    
  cin >> total_money >> one_yen;
  
  total_money = total_money - (total_money / 500) * 500;
  
  if(total_money <= one_yen){
   cout << "Yes" << endl;
  }else{
   cout << "No" << endl;
  }
   

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
struct pp
{
    string s;
    int n;
}a[100];
int main()
{
    cin>>a[0].s>>a[1].s;
    cin>>a[0].n>>a[1].n;
    string s2;
    cin>>s2;
    if(s2==a[0].s)
        a[0].n--;
    else a[1].n--;
    cout<<a[0].n<<" "<<a[1].n;
    return 0;
}


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

int main(){
  int n;
  (cin >> n).ignore();
  while(n--){
    string str;
    getline(cin,str);
    bool flg = false;
    for(int i=0;i<26;i++){
      for(int j=0;j<26;j++){
	string tmp = str;
	for(int k=0;k<tmp.size();k++){
	  if(tmp[k] != ' ') tmp[k] = 'a'+(((tmp[k]-'a')*i+j) % 26);
	}
	if(tmp.find("this")!=string::npos || tmp.find("that")!=string::npos){
	  cout << tmp << endl;
	  flg = true;
	  break;
	}
      }
      if(flg) break;
    }
  }
}

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

int main() {
  int n,c,k;
  cin >> n >> c >> k;
  int A[100000];
  for(int i=0;i<n;++i) {
    cin >> A[i];
  }

  sort(A, A+n, less<int>());

  int limitT = 0;
  int goesCnt = 0;
  int busCnt = 0;

  for(int i = 0; i < n; i++) {
    if(goesCnt == 0) {
      goesCnt++;
      limitT = A[i] + k;
      continue;
    }

    goesCnt++;

    if(A[i] > limitT || goesCnt > c) {
      busCnt++;
      goesCnt = 1;
      limitT = A[i] + k;
      continue;
    }
  }

  cout << busCnt + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : stdin.readline().split()
sys.setrecursionlimit(10 ** 7)

def main():
    n = ni()
    s, t = na()

    tmp = ""
    for i, ss in enumerate(s):
        tmp += ss + t[i]
    print(tmp)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];
 
ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
//-------------------関数----------------------//
 
ll ketawa(ll b, ll nn) {
	if (nn < b) {
		return nn;
	}
	return ketawa(b, nn / b) + nn%b;
}
int main() {

ll n;cin>>n;
if(n%10==9){cout<<"Yes"<<endl;return 0;}
if(n/10==9){{cout<<"Yes"<<endl;return 0;}}
cout<<"No"<<endl;
	return 0;
}

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

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

long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;

int main(){
  int K;
  ll A,B;
  cin >> A >> B >> K;
  map<ll,int> ans;
  ll max_val = B;
  ll min_val = A;
  
  for(int i = 0; i < K; i++){
    ans[A]++;
    A++;
    if(A > max_val) break;
  }
  for(int i = 0; i < K; i++){
    ans[B]++;
    B--;
    if(B < min_val) break;
  }
  for(auto x: ans){
    cout << x.first << endl;
    
  }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}

	}
}

Measured memory_bytes: 21588
r, c = map(int, input().split())

m = [list(map(int, input().split())) for i in range(r)]

for i in range(r):
    sum = 0
    for j in range(c):
        sum += m[i][j]
    m[i].append(sum)

l = []
for i in range(c+1):
    sum = 0
    for j in range(r):
        sum += m[j][i]
    l.append(sum)

m = m+[l]


for i in range(r+1):
    for j in range(c + 1):
        if j == c:
            print(f"{m[i][j]}", end="")
        else:
            print(f"{m[i][j]} ", end="")
    print()



Measured memory_bytes: 6248
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================




	int K;
	cin >> K;
	vint A = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << A[K - 1];








}



Measured memory_bytes: 256
#include<cstdio>
#define LL long long
using namespace std;
const LL N=2e5+1;
LL i,n,m,ans;
LL a[N];
int main()
{
	scanf("%lld%lld",&n,&m);
	for (i=1;i<=n;++i)
		++a[i%m];
	ans=a[0]*a[0]*a[0];
	if (!(m%2))
		ans+=a[m>>1]*a[m>>1]*a[m>>1];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 896
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
index=1
nonflag=0
N.times do |i|
  index+=1 if a[i]==index
  nonflag=1 if a[i]==1
end

if nonflag==0
  puts -1
else
puts N-(index-1)
end

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

int main() {
  int w, h;
  char c;
  cin >> w >> h >> c;
  int i, j;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (i == 0 || i == h - 1) {
        if (j == 0 || j == w - 1) {
          cout << '+';
        } else {
          cout << '-';
        }
      } else {
        if (j == 0 || j == w - 1) {
          cout << '|';
        } else if (i == h / 2 && j == w / 2) {
          cout << c;
        } else {
          cout << '.';
        }
      }
    }
    cout << endl;
  }
  return 0;
}



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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


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

    int n;
    cin >> n;
    int a[n][3];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    int dp[n][3] = {0};
    for (int j = 0; j < 3; ++j) {
        dp[0][j] = a[0][j];
    }
    for (int i = 0; i < n-1; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j != k) {
                    dp[i+1][k] = max(dp[i][j]+a[i+1][k], dp[i+1][k]);
                }
            }
        }
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;

    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    deque<char> que;
    FORE(c, S) {
        que.EB(c);
    }
    bool flag = true;
    while (Q--) {
        int go;
        cin >> go;
        if (go == 1) {
            flag = !flag;
            continue;
        }

        int f;
        string c;
        cin >> f >> c;
        if (f == 1 && flag) {
            que.emplace_front(c[0]);
        } else if (f == 1 && !flag) {
            que.EB(c[0]);
        } else if (f == 2 && flag) {
            que.EB(c[0]);
        } else {
            que.emplace_front(c[0]);
        }
    }

    string ans = "";
    while (!que.empty()) {
        if (flag) {
            ans += que.front();
            que.pop_front();
        } else {
            ans += que.back();
            que.pop_back();
        }
    }

    cout << ans << endl;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
    ll k;
    cin >> k;
    
    queue<ll> q;
    ll num = 0;
    rep(i,9){
        q.push(i+1);
        num++;
        if(num==k){
            cout << num << endl;
            return 0;
        }
    }

    while(num < k){
        ll tmp = q.front();
        q.pop();
        ll mod10 = tmp%10;

        if(mod10!=0){
            num++;
            if(num==k){
                cout << tmp*10+mod10-1 << endl;
                return 0;
            }
            q.push(tmp*10+mod10-1);
        }
        
        num++;
        if(num==k){
            cout << tmp*10+mod10 << endl;
            return 0;
        }
        q.push(tmp*10+mod10);

        if(mod10!=9){
            num++;
            if(num==k){
                cout << tmp*10 + mod10 + 1 << endl;
                return 0;
            }
            q.push(tmp*10 + mod10 + 1);
        }
    }
    return 0;
}  


Measured memory_bytes: 768
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  n <- readInt
  arr <- sort <$> readIntList
  putStrLn $ if judge arr then "YES" else "NO"

judge (x:y:rest) = (x /= y) && judge (y:rest)
judge _ = True


Measured memory_bytes: 31100
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
ll N,C;
ll X[100001],V[100001];
ll v[100001];
ll rv[100001];
ll n[100001];
int main(){
	cin>>N>>C;
	X[0]=0;V[0]=0;
	FOR(i,1,N+1){
		cin>>X[i]>>V[i];
	}
	v[0]=0;
	FOR(i,1,N+1){
		v[i]=v[i-1]+V[i];
	}
	FOR(i,1,N+1){
		v[i]-=X[i]*2;
	}
	int now=0;
	n[0]=0;
	FOR(i,1,N+1){
		if(v[now]<v[i]){
			now=i;
		}
		n[i]=now;
	}
	//
	reverse(X+1,X+N+1);
	reverse(V+1,V+N+1);
	rv[0]=0;
	FOR(i,1,N+1){
		rv[i]=rv[i-1]+V[i];
	}
	FOR(i,1,N+1){
		rv[i]-=C-X[i];
	}
	//
	ll ans=0;
	reverse(X+1,X+N+1);
	reverse(V+1,V+N+1);
	FOR(i,1,N+1){
		ans=max(ans,rv[i]+v[n[N-i]]);
	}
	//
	FOR(i,1,N+1){
		v[i]+=X[i];
	}
	ll ma=0;
	FOR(i,0,N+1){
		ma=max(ma,v[i]);
	}
	ans=max(ans,ma);
	//
	fill(v,v+N+1,0);
	fill(rv,rv+N+1,0);
	fill(n,n+N+1,0);
	//
	reverse(X+1,X+N+1);
	reverse(V+1,V+N+1);
	FOR(i,1,N+1){
		X[i]=C-X[i];
	}
	//
	v[0]=0;
	FOR(i,1,N+1){
		v[i]=v[i-1]+V[i];
	}
	FOR(i,1,N+1){
		v[i]-=X[i]*2;
	}
	now=0;
	n[0]=0;
	FOR(i,1,N+1){
		if(v[now]<v[i]){
			now=i;
		}
		n[i]=now;
	}
	//
	reverse(X+1,X+N+1);
	reverse(V+1,V+N+1);
	rv[0]=0;
	FOR(i,1,N+1){
		rv[i]=rv[i-1]+V[i];
	}
	FOR(i,1,N+1){
		rv[i]-=C-X[i];
	}
	reverse(X+1,X+N+1);
	reverse(V+1,V+N+1);
	FOR(i,1,N+1){
		ans=max(ans,rv[i]+v[n[N-i]]);
	}
	FOR(i,1,N+1){
		v[i]+=X[i];
	}
	ma=0;
	FOR(i,0,N+1){
		ma=max(ma,v[i]);
	}
	ans=max(ans,ma);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    map<char,int>m;
    for(int i=0;i<s.length();i++){
        if(m[s[i]]==0)
            m[s[i]]++;
        else{
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct Stat{
	int x,y,d; // d : Ì½ßÔ
	bool operator<(const Stat &S)const{ return d>S.d; }
};

int main(){
	for(int h,w,n;scanf("%d%d%d",&h,&w,&n),h;){
		char cmd[1000001]; scanf("%s",cmd);
		int sx,sy,gx,gy;
		static char B[1000][1001];
		rep(i,h){
			scanf("%s",B[i]);
			rep(j,w){
				if(B[i][j]=='S') sx=j, sy=i;
				if(B[i][j]=='G') gx=j, gy=i;
			}
		}

		// precalc
		int len=strlen(cmd);
		// dir[i] := ÉÀs·é½ßª i Å éÆ«Éü¢Ä¢éûü
		static int dir[1000001];
		dir[0]=1;
		rep(i,len) dir[i+1]=(dir[i]+(cmd[i]=='L'?1:3))%4;

		// next[i][k] := ÉÀs·é½ßª i Å éÆ«AÉßÄûü k ðü­æ¤È½ßÔ(+1)
		static int next[1000001][4];
		rep(k,4) next[len][k]=(k==dir[len]?len:INF);
		for(int i=len;i>0;i--) rep(k,4) {
			if(k==dir[i-1]) next[i-1][k]=i-1;
			else            next[i-1][k]=next[i][k];
		}

		// Dijkstra
		static int d[1000][1000][4];
		rep(i,h) rep(j,w) rep(k,4) d[i][j][k]=INF;
		d[sy][sx][1]=0;

		bool ok=false;
		priority_queue<Stat> pq; pq.push((Stat){sx,sy,0});
		while(!pq.empty()){
			Stat S=pq.top(); pq.pop();

			if(d[S.y][S.x][dir[S.d]]<S.d) continue;
			if(S.x==gx && S.y==gy){ ok=true; break; }

			rep(k,4){
				int xx=S.x+dx[k],yy=S.y+dy[k];
				if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]!='#'){
					if(next[S.d][k]<d[yy][xx][k]){
						d[yy][xx][k]=next[S.d][k];
						pq.push((Stat){xx,yy,next[S.d][k]});
					}
				}
			}
		}

		puts(ok?"Yes":"No");
	}

	return 0;
}

Measured memory_bytes: 18000
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;



int main() {
    ll n; cin>>n;
    ll s=0;
    for(int i=1; i<=n; ++i) {
        if(i%3&&i%5) s+=i;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3636
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=-1000000000;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans=max(abs(a[i]-a[j]),ans);
		}
	}
	cout<<ans;
    return 0;
} 

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

int main() {
  int X, Y;
  cin >> X >> Y;
  int legs = X * 2;
  while (legs <= 4 * X) {
    if (legs == Y) {
      cout << "Yes" << endl;
      return 0;
    }
    legs += 2;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n; scanf("%d", &n);
    while((n & (n - 1)) != 0) n = n & (n - 1);
    printf("%d\n", n);
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<string> V;
int n,lat[51][301],mini[301];
string a;

int main()
{
  // printf("%c %c",97,98);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        cin>>a;
        V.push_back(a);
    }
    memset(mini,51,sizeof mini);
    for(int i=0;i<V.size();i++){
        int j=0;
        while(V[i][j]!=0){
            lat[i][V[i][j]]++;
            j++;
        }
        for(int j=97;j<=122;j++){
            mini[j]=min(mini[j],lat[i][j]);
        }
    }
    for(int i=97;i<=122;i++){
        for(int k=1;k<=mini[i];k++)
            printf("%c",i);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e6 + 5) 
#define mod (long long int) (1e9 + 7)
 
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

lli dp[2001];
int s;

lli fa(int ps)
{
	// cout << in << " " << ps << "\n";
	if (ps == 0)
	{
		return 1;
	}

	if (ps < 3)
	{
		// dp[ps] = 0;
		return 0;
	}

	if (dp[ps] != -1)
	{
		return dp[ps];
	}

	dp[ps] = 0;

	for (int i = 3; i <= ps; ++i)
	{
		dp[ps] += fa(ps-i);
		dp[ps] %= mod;
	}

	return dp[ps];
}

int main()
{
	// ios_base::sync_with_stdio(false);cin.tie(NULL);   
   	cin >> s;

   	if(s < 3)
   	{
   		cout << 0;
   		return 0;
   	}
   	
   	for (int i = 0; i <= s; ++i)
   	{
   		dp[i] = -1;
   	}

   	fa(s);

   	cout << dp[s];
    return 0;
}




Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    string s;
    cin >> s;
    ll l = 0;
    rep(i, s.size()) if(s[i] == 'A') { l = i; break;}
    ll r = 0;
    for(ll j = l; j < s.size(); j++) if(s[j] == 'Z') r = j;
    cout << r-l+1;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 720
from collections import deque

def main():
    h, w = map(int, input().split())
    G = [["#"]*(w+2)]+[["#"]+list(input())+["#"] for i in range(h)]+[["#"]*(w+2)]
    dy, dx = [-1, 1, 0, 0], [0, 0, -1, 1]
    dist = [[-1 for j in range(w+2)] for i in range(h+2)]
    que = deque()
    
    for i in range(1, h+1):
        for j in range(1, w+1):
            if G[i][j] == "#":
                dist[i][j] = 0
                que.append((i, j))
    
    while (len(que) != 0):
        y, x = que[0][0], que[0][1]
        que.popleft()

        for i in range(4):
            ny, nx = y+dy[i], x+dx[i]
            if G[ny][nx] == "#":
                continue
            if dist[ny][nx] == -1:
                dist[ny][nx] = dist[y][x] + 1
                que.append((ny, nx))
    
    ans = 0
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            ans = max(ans, dist[i][j])
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 123996
line = gets.chomp.to_i
ac = 0
wa = 0
tle = 0
re = 0
line.times do
  r = gets.chomp
  case r
  when "AC"
    ac += 1
  when "WA"
    wa += 1
  when "TLE"
    tle += 1
  when "RE"
    re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
print "RE x #{re}"


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

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

    int count = 0;

    if (S.at(0) == '1') count++;
    if (S.at(1) == '1') count++;
    if (S.at(2) == '1') count++;

    cout << count << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> m(h);
    for(int i = 0;i < h;++i) {
        cin>>m[i];
    }
    int ans=0;
    for(int hit = 0;hit < 1<<h;++hit) {
        for(int wit = 0;wit < 1<<w;++wit) {
            int cnt=0;
            for(int i = 0;i < h;++i) {
                if((hit&(1<<i))!=0)continue;
                for(int j = 0;j < w;++j) {
                    if((wit&(1<<j))!=0)continue;
                    if(m[i][j]=='#')++cnt;
                }
            }
            if(cnt==k)++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    a = LI()
    s = [0]
    for i in a:
        s.append((s[-1]+i-1)%k)
    ans = 0
    d = defaultdict(lambda : 0)
    for i in range(n+1):
        ans += d[s[i]]
        d[s[i]] += 1
        j = i-k+1
        if j >= 0:
            d[s[j]] -= 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 107780
#include<bits/stdc++.h>
using namespace std;
char a[10011001];
char b[10011001];
char c[10011001];

int main()
{
	scanf("%s %s %s",a,b,c);
	printf("%c%c%c\n",a[0],b[0],c[0]);
	return 0;
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n, k;
    cin >> n >> k;
    map<char, int> p;
    cin >> p['r'] >> p['s'] >> p['p'];
    string s;
    cin >> s;
    string t;
    map<char, char> m;
    m['r'] = 'p';
    m['p'] = 's';
    m['s'] = 'r';
    int ans = 0;
    for (int i = 0; i < k; i++) {
        t += m[s[i]];
        ans += p[t[i]];
    }
    for (int i = k; i < n; i++) {
        if (m[s[i]] == t[i-k]) {
            t += '?';
        }
        else {
            t += m[s[i]];
            ans += p[t[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
program main
   implicit none
   integer::n,i,counter=0,j,acounter=0,bcounter=0,abcounter=0
   character(10) s(10000)
   read(*,*)n
   do i=1,n
      read(*,*)s(i)
   enddo
   do i=1,n
      if(s(i)(1:1)=="B")bcounter=bcounter+1
      do j=2,len_trim(s(i))
         if(s(i)(j-1:j-1)=="A".and.s(i)(j:j)=="B")counter=counter+1
      enddo
      if(s(i)(len_trim(s(i)):len_trim(s(i)))=="A")acounter=acounter+1
      if(s(i)(len_trim(s(i)):len_trim(s(i)))=="A".and.s(i)(1:1)=="B")abcounter=abcounter+1
   enddo
   counter=counter+min(acounter,bcounter)
  if(abcounter==acounter.and.abcounter==bcounter)counter=counter-min(1,abcounter)
   write(*,*)counter
end program main


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>

int main() {
    int X, Y, Z;
    std::cin >> X >> Y >> Z;
    
    int ans = 0;
    
    while (X >= (Y+2*Z)) {
        ans++;
        X -= (Y + Z);
    }
    
    std::cout << ans << std::endl;
}

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

#define MAX_N 100000

int N;
int l[MAX_N], r[MAX_N];

int main() {
    cin >> N;
    rep(i, N) {
        cin >> l[i] >> r[i];
    }

    int ans = 0;
    rep(i, N) {
        ans += r[i] - l[i] + 1;
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
	int K, T, a[100] = {};
	cin >> K >> T;
	for (int i = 0; i < T; i++)
		cin >> a[i];
	sort(a, a + 100);
	while (a[98] != 0) {
		a[99] -= a[98];
		a[98] = 0;
		sort(a, a + 100);
	}
	if (a[99]) cout << a[99] - 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
import sys, collections, bisect, math, itertools
from fractions import gcd 
input = sys.stdin.readline #文字列入力のときは注意

n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

maxspeed = [0]*(n+1)
for i in range(n-1,0,-1):
    maxspeed[i] = min(v[i], v[i-1], t[i] + maxspeed[i+1])

#print(t)
#print(v)
#print(maxspeed)

def dist(first,i): # distance,lastspeed
    ti = t[i]
    vi = v[i]
    mi1= maxspeed[i+1]
    ta = vi - first
    tb = vi - mi1
    if ta + tb <= ti:
        c = (first+vi)*ta/2 + vi*(ti-ta-tb) + (mi1+vi)*tb/2
        lastspeed = mi1
    elif mi1 - first > ti:
        c = (first + first + ti)*ti/2
        lastspeed = first + ti
    else:
        a = (mi1+ti-first)/2
        c = (first+first+a)*a/2 + (first+a+mi1)*(ti-a)/2
#        print(a,'a',c,first,(first+first+a)*a/2, (first+a+mi1)*(ti-a)/2)
        lastspeed = mi1
#    print(c)

    return c, lastspeed


ans = 0
firstspeed = 0
for i in range(n):
    d,firstspeed = dist(firstspeed,i)
#    print(d,firstspeed)
    ans += d

print(ans)    
    









Measured memory_bytes: 5368
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int main(){
    int a , b;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << -1 << endl;
        return 0;
    }
    cout << a*b << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = input()
if N[0]==N[1]==N[2]:
    print(N)
else:
    if int(N) <int(N[0]*3):
        print(int(N[0]*3))
    else:
        print(str((int(N[0])+1))*3)
        

Measured memory_bytes: 2940