akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  vector<vector<int>> G(N,vector<int> (M));
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      cin >> G[i][j];
      G[i][j]--;
    }
    reverse(G[i].begin(),G[i].end());
  }
  // i番目のスポーツに今何人集まってるか
  vector<int> cnt(M,0);
  for(int i=0; i<N; i++){
    cnt[G[i][M-1]]++;
  }
  // 最小値をmnにできるか判定
  for(int mn=1; mn<=N; mn++){
    vector<int> now = cnt;
    vector<vector<int>> rem = G;
    vector<bool> use(M,true);
    // 最小値超えるものがあればそのスポーツは選ばない
    bool can = true;
    while(1){
      // j番目のスポーツは選ばない
      int j = -1;
      for(int i=0; i<M; i++){
        if(!use[i]) continue;
        if(now[i] > mn) j = i;
      }
      if(j == -1) break;
      use[j] = false;
      for(int i=0; i<N; i++){
        while(1){
          if(use[rem[i].back()]) break;
          now[rem[i].back()]--;
          rem[i].pop_back();
          if(rem[i].size() == 0){
            can = false;
            break;
          }
          now[rem[i].back()]++;
        }
      }
      if(!can) break;
    }
    if(can){
      // for(int i=0; i<M; i++){
      //   cout << now[i] << " \n"[i+1==M];
      // }
      // for(int i=0; i<M; i++){
      //   cout << use[i] << " \n"[i+1==M];
      // }
      cout << mn << "\n";
      return 0;
    }
  }
  return 0;
}

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

int main(void) {
  int N, M;
  cin >> N >> M;
  // prefecture, year, index
  vector<tuple<int, int, int>> v(M);
  for (int i = 0; i < M; i++) {
    int p, y;
    cin >> p >> y;
    v[i] = make_tuple(p, y, i);
  }
  sort(v.begin(), v.end());

  vector<string> ans(M);
  int before = -1, cnt = 0;
  for (int i = 0; i < M; i++) {
    stringstream ss;
    int p, y, ind;
    tie(p, y, ind) = v[i];
    cnt = p == before ? cnt + 1 : 1;
    before = p;
    ss << setfill('0') << setw(6) << p;
    ss << setfill('0') << setw(6) << cnt;
    ans[ind] = ss.str();
  }

  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n, m;
	int a, LCM = 1, t = -1;

	cin >> n >> m;
	rep(i, n) {
		cin >> a;
		int now = a, cnt = 0;
		while(now % 2 == 0) {
			now /= 2;
			cnt++;
		}
		if(t == -1) t = cnt;
		else if(t != cnt) {
			cout << 0 << endl;
			return 0;
		}
		LCM = lcm(a, LCM);
	}

	if(LCM % 2 == 1) {
		cout << 0 << endl;
	} else {
		int ans = (m - LCM / 2 + LCM) / LCM;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(args: Array<String>) {
    var (a, b, c) = readInts()
    val k = readInt()
    var flag = true
    var itr = 0
    while (flag) {
        if (b <= a) {
            b = b * 2
            itr++
        } else
            break
    }
    while (flag) {
        if (c <= b) {
            c = c * 2
            itr++
        } else
            break
    }
    if (itr > k)
        println("No")
    else
        println("Yes")
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    string s;
    cin >> s;
    rep(i,3){
        if(s[i]=='1') cout << 9;
        else if(s[i]=='9') cout << 1;
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	cout<<0<<endl;
	string zero;
	cin >> zero;
	int l = 0,r=n;
	string uke;
	string de;
	while(1)
	{
		int m = (l+r)/2;
		cout<<m<<endl;
		cin >> uke;
		if(r-l<2)
		{
			break;
		}
		if(uke=="Vacant")return 0;
		else if((m%2==0)?(zero!=uke):(zero==uke))
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	int odd = N - (N / 2);
	cout << (double)odd / N << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = 0;
        int x = 0;
        int y = 0;
        for (int i = 0; i < n; i++) {
            int tNext = sc.nextInt();
            int xNext = sc.nextInt();
            int yNext = sc.nextInt();
            int time = tNext - t;
            int length = Math.abs(xNext - x) + Math.abs(yNext - y);
            if (time < length || (time - length) % 2 == 1) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


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

int main(){
  int N;
  cin >> N;
  char s[400000];
  int W = 0;
  int E = 0;
  
  for(int i = 0;i < N;i++){
    cin >> s[i];
    if(s[i] == 'E' && i != 0){
      W++;
    }
  }
  
  vector<int> a(N);
  a.at(0) = W;
  
  for(int i = 1;i < N;i++){
    if(s[i] == 'E'){
      W--;
    }
    
    if(s[i-1] == 'W'){
      E++;
    }
    
    a.at(i) = W + E;
  }
  sort(a.begin(),a.end());
  cout << a.at(0) << endl;
}

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


#define rep(i, a, b) for(long long i = a; i < (b); ++i)
#define repdown(i, a, b) for(long long i = a; i >= b; --i)
#define all(x) x.begin(), x.end()
#define bfs(a) while(a.size())

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vector<ll>> vvi;
typedef vector<vector<double>> vvd;
typedef vector<ll> vi;
typedef vector<pii> vpii;
typedef vector<pdd> vpdd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;


int main() {    
	cin.sync_with_stdio(0); cin.tie(0);    cin.exceptions(cin.failbit);//OUTPUT MANAGEMENT
	string in;
	cin>>in;
	ll n = in.size()+1;
	vi num;
	ll cc = 1;
	rep(i , 1, n-1){
		if(in[i] == in[i-1]){
			cc++;
		}else{

			if(in[i-1] == '<' ){
				num.push_back(cc);
			}else{
				num.push_back(cc*-1);
			}

			cc = 1;
		}
	}
	if(in[in.size()-1] == '<' ){
		num.push_back(cc);
	}else{
		num.push_back(cc*-1);
	}
	//rep(i ,0, num.size())cout<<num[i]<<endl;
	vi ans(num.size()+1, min(ll(0), num[0])*-1);
	rep(i ,0, num.size()){
		if(num[i]<0){
			ans[i+1] = 0;
		}else{
			if(i == n-1){
				ans[i+1] = max(ll(0), num[i]);
			}else
			ans[i+1] = max(num[i], num[i+1]*-1);
		}
	}
	ll tot = ans[0];
	rep(i, 1, ans.size()){
		ll diff = abs(num[i-1]);
		tot+=ans[i];
		rep(i , 1, diff){
			tot+=i;
		}
	}
	cout<<tot<<endl;
}

Measured memory_bytes: 5140
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,c,b;
    cin >> c >> a >> b;
    int ans = a*c/2;
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.swift
//  atCoderTest
//
//  Created by jun on 2020/05/23.
//  Copyright © 2020 jun. All rights reserved.
//

import Foundation

func solution() -> String {
   let AV = readLine()!.components(separatedBy: " ").map { Int($0)! }
   let BW = readLine()!.components(separatedBy: " ").map { Int($0)! }
   let A = AV.first!
   let V = AV.last!
   let B = BW.first!
   let W = BW.last!
   let T = Int(readLine()!)!
   
   let BetweenAtoB = abs(A - B)
   let speedAtoB = V - W
   
   //if A == B { return "YES" }
   
   if BetweenAtoB <= speedAtoB * T {
      return "YES"
   }


 
   return "NO"
}

print(solution())





Measured memory_bytes: 14084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			x += d/a;
			if(d%a!=0) x++;
		}
		sc.close();
		System.out.println(x);
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d", &a,&b,&c);
   if(a>b&&b>c){
        printf("%d %d %d\n", c,b,a);
   }else if(b>c&&c>a){
        printf("%d %d %d\n", a,c,b);
   }else if(c>a&&a>b){
        printf("%d %d %d\n", b,a,c);
   }else if(c>b&&b>a){
        printf("%d %d %d\n", a,b,c);
   }else if(b>a&&a>c){
        printf("%d %d %d\n", c,a,b);
   }else if(b>c&&c>a){
        printf("%d %d %d\n", b,c,a);
   }else if(a>c&&c>b){
        printf("%d %d %d\n", b,c,a);   
   }else if(b>c&&c==a){
        printf("%d %d %d\n", a,c,b);
   }else if(a>c&&c==b){
        printf("%d %d %d\n", b,c,a);
   }else if(b>a&&a==b){
        printf("%d %d %d\n", c,a,b);
   }
return 0;
}

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

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 200005;
const int LG = 18;

int a[N];
int b[LG][N];
int lg[N];

ll go(int l, int r) {
  if (r < l) return 0;
  if (r == l) return a[l];
  int t = lg[r - l + 1];
  int m = b[t][l];
  if (a[b[t][r+1-(1<<t)]] < a[m]) m = b[t][r+1-(1<<t)];
  return go(l, m - 1) + go(m + 1, r) + (m - l+1) * 1LL * (r - m+1)*1LL*a[m];
}

int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  rep(i, 1, n) {
    cin >> a[i];
    b[0][i] = i;
  }
  rep(i, 1, LG - 1) {
    rep(j, 1, n) {
      b[i][j] = b[i - 1][j];
      if (j + (1 << (i - 1)) <= n && a[b[i - 1][j + (1 << (i - 1))]] < a[b[i][j]]) b[i][j] = b[i - 1][j + (1 << (i - 1))];
    }
  }
  rep(i, 2, N - 1) {
    lg[i] = lg[i / 2] + 1;
  }
  cout << go(1, n) << endl;
  return 0;
}

Measured memory_bytes: 25216
# abc104_b.py
# https://atcoder.jp/contests/abc104/tasks/abc104_b

# ★ WA:2
# b12
# b13

# B - AcCepted /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 文字列 Sが与えられます。S のそれぞれの文字は英大文字または英小文字です。 Sが次の条件すべてを満たすか判定してください。
#     Sの先頭の文字は大文字の A である。
#     Sの先頭から 3 文字目と末尾から 2 文字目の間（両端含む）に大文字の C がちょうど 1個含まれる。
#     以上の A, C を除く Sのすべての文字は小文字である。

# 制約
#     4≤|S|≤10（|S| は文字列 Sの長さ）
#     Sのそれぞれの文字は英大文字または英小文字である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# Sが問題文中の条件すべてを満たすなら AC、そうでなければ WA と出力せよ。

# 入力例 1
# AtCoder

# 出力例 1
# AC

# 1文字目が A、3文字目が C でそれ以外の文字はすべて小文字であり、すべての条件を満たします。

# 入力例 2
# ACoder

# 出力例 2
# WA

# 2文字目が C であってはいけません。

# 入力例 3
# AcycliC

# 出力例 3
# WA

# 最後の文字が C であってもいけません。

# 入力例 4
# AtCoCo

# 出力例 4
# WA

# C を 2個以上含んではいけません。

# 入力例 5
# Atcoder

# 出力例 5
# WA

# C を 1個も含まないのもいけません。


def calculation(lines):
    S = lines[0]
    n_c = 0
    n_l = 0
    for i in range(len(S)):
        if S[i] == 'C':
            n_c += 1
        if S[i] < 'a':
            n_l += 1
    if S[0] != 'A':
        ret = 'WA'
    elif S[1] == 'C':
        ret = 'WA'
    elif S[-1] == 'C':
        ret = 'WA'
    elif n_c != 1:
        ret = 'WA'
    elif n_l != 2:
        # print(n_l)
        ret = 'WA'
    else:
        ret = 'AC'
    return [ret]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['AtCoder']
        lines_export = ['AC']
    if pattern == 2:
        lines_input = ['ACoder']
        lines_export = ['WA']
    if pattern == 3:
        lines_input = ['AcycliC']
        lines_export = ['WA']
    if pattern == 4:
        lines_input = ['AtCoCo']
        lines_export = ['WA']
    if pattern == 5:
        lines_input = ['Atcoder']
        lines_export = ['WA']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}




const ll N=1e5+5;

ll sp[N];

void sieve(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      if(sp[i]==i){
        for(int j=i*i;j<N;j+=i){
          if(sp[j]==j)sp[j]=i;
        }
      }
    }
}

  

int main()
{ 

IOS;

ll a,b,c;
cin>>a>>b>>c;
ll cnt=0;
ll k;
cin>>k;

while(b<=a){
  b*=2;
  cnt++;
}
while(c<=b){
  c*=2;
  cnt++;
}

if(cnt<=k)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

//end_routine();

return 0;
 
}


Measured memory_bytes: 3648
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int start = 0;
		int goal = 0;

		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'A') {
				start = i;
				break;
			}
		}
		for(int j = s.length() - 1; j > 0; j--) {
			if (s.charAt(j) == 'Z') {
				goal = j;
				break;
			}
		}
		System.out.println(goal - start + 1);
	}

}


Measured memory_bytes: 40332
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {

			String str = kb.readLine();
			String[] tmpArray = str.split( " " );
			int r=Integer.parseInt( tmpArray[0] );
			int c=Integer.parseInt( tmpArray[1] );
			
			int[][] spredsheet = new int[r+1][c+1];
			for( int i=0; i<r; i++ ) {
				spredsheet[i][c]=0;
				str = kb.readLine();
				tmpArray = str.split( " " );
				for( int j=0; j<c; j++ ) {
					if( 0 == i ) { spredsheet[r][j]=0; }
					spredsheet[i][j]=Integer.parseInt( tmpArray[j] );
					spredsheet[i][c]+=spredsheet[i][j];
					spredsheet[r][j]+=spredsheet[i][j];
					System.out.print( tmpArray[j]+" " );	
				}
				System.out.println( spredsheet[i][c] );
			}
			spredsheet[r][c]=0;
			for( int j=0; j<c; j++ ) {
				spredsheet[r][c]+=spredsheet[r][j];
				System.out.print( spredsheet[r][j]+" " );	
			}
			System.out.println( spredsheet[r][c] );
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 24676
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  long long A,B,K;
  cin>>A>>B>>K;
  
  
  set<int> S;
  for(int i=0;i<K;i++){
    if(A<=B-i){
      S.insert(B-i);
    }
    if(A+i<=B){
      S.insert(A+i);
    }
  }
  
  while(!(S.empty())){
    cout<<*begin(S)<<endl;
    S.erase(*begin(S));
  }
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(std::string s){
    i64 ans = 0, cnt = 0;
    i64 n = s.length();
    rep(i, n){
        if(i + 1 < n && s[i] == 'B' && s[i + 1] == 'C'){
            ans += cnt;
            i += 1;
        }
        else if(s[i] == 'A') ++cnt;
        else{
            cnt = 0;
        }
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 772
#include<stdio.h>

#define max 2147483647

void merge(int *a,int left,int mid,int right){
        int n1 = mid - left;
        int n2 = right - mid;
        int L[n1+1],R[n2+1];
        int i;
        for(i=0;i<n1;i++){
            L[i] = a[left + i];
        }
        for(i=0;i<n2;i++){
            R[i] = a[mid + i];
        }
        L[n1]=max;
        R[n2]=max;
        int j=0,k=0;
        for(i=left;i<right;i++){
            if(L[j]<R[k]){
                a[i] = L[j];
                j++;
            }
            else{
                a[i] = R[k];
                k++;
            }
        }

}


void merge_sort(int *a,int left,int right){
    int middle;
    if(left + 1 < right){
        middle = (left + right)/2;
        merge_sort(a,left,middle);
        merge_sort(a,middle,right);
        merge(a,left,middle,right);
    }
}


int main(void){
    int N;
    scanf("%d",&N);
    int i,a[N];
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    merge_sort(a,0,N);
    printf("%d\n",a[N-1]-a[0]);
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    ball: [(i64, i64); n],
  }
  let mut ball = ball;
  ball.sort();
  use std::collections::BTreeMap;
  let mut map = BTreeMap::new();
  for i in 0 .. n {
    for j in i + 1 .. n {
      let dx = ball[j].0 - ball[i].0;
      let dy = ball[j].1 - ball[i].1;
      if let Some(current) = map.get_mut(&(dx, dy)) {
        *current += 1;
        continue;
      }
      map.insert((dx, dy), 1);
    }
  }
  let mut m = 0;
  for &v in map.values() {
    m = cmp::max(m, v);
  }

  println!("{}", n - m);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main(){
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll r1=a*c;
ll r2=a*d;
ll r3=b*c;
ll r4=b*d;
 ll m1=max(r1,r2);
 ll m2=max(m1,r3);
 ll m3=max(m2,r4);
 cout<<m3<<endl;

}

Measured memory_bytes: 3632
/******* VIVEK PAl *******/
/*************************/
#include <bits/stdc++.h>
#define prime 1000000007
#define mod 100008
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
/****** END OF HEADER ******/
/***************************/
void fastIO(void);

bool cmp(pair<int,int>a, pair<int,int>b){
  if(a.first == b.first) return (a.second < b.second);
  return (a.first < b.first);
}
void solve()
{
  ll N, K; cin>>N>>K;
  int cnt=0;
  while(N>0){
    N/=K;
    cnt+=1;
  }
  printf("%d\n", cnt);
}
int main()
{
  fastIO();
  int T=1, t;
  //cin>>T;
  t = T;
  while(T--)
    {
        //printf("Case #%d: ", t-T);
        solve();
    }
}


void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<int,int> a;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    a[x]++;
  }
  int c=0;
  for(auto x:a)
    c+=(x.first<=x.second?x.second-x.first:x.second);
  cout<<c<<endl;
}

Measured memory_bytes: 4736
def main():
    N, M, C = map(int, input().split(" "))
    B = list(map(int, input().split(" ")))
    result = 0
    for _ in range(N):
        A = list(map(int, input().split(" ")))
        tmp = C
        for i in range(M):
            tmp += A[i] * B[i]
        if tmp > 0:
            result += 1
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<string>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int a,b;
	int flaga = 0,flagb = 0;
	cin >> a >> b;
	if(a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12)
		flaga = 1;
	else if(a == 4 || a == 6 || a == 9 || a == 11)
		flaga = 2;
	else if(a == 2)
		flaga == 3;
	if(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)
		flagb = 1;
	else if(b == 4 || b == 6 || b == 9 || b == 11)
		flagb = 2;
	else if(b == 2)
		flagb == 3;
	if(flaga == flagb)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

ll f2n(ll n)
{
  if(n == 0) return 1;
  if(n == 1) return 2;
  ll ans = f2n(n / 2);
  ans = (ans * ans) % MOD;
  ans = (ans * ((n % 2) + 1)) % MOD;
  return ans;
}
  

ll ncr(ll n, ll r)
{
  ll a = 1, b = 1;
  rep1(i, r) {
    a = (a * (n - i + 1)) % MOD;
    b = (b * i) % MOD;
  }
  ll br = modinv(b, MOD);
  return (a * br) % MOD;
}


void solve()
{
  ll n, a, b; cin >> n >> a >> b;

  ll ttl = f2n(n) - 1;
  
  ll ans = 0;

  ans = (ttl - ncr(n, a)) % MOD;
  if(ans < 0) ans += MOD;
  ans = (ans - ncr(n, b)) % MOD;
  if(ans < 0) ans += MOD;
  
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

using namespace std;

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

void dfs(int x, int y, vector<vector<bool> >& Cango){
  
  Cango[x][y] = false;
  

  for(int i = 0; i < 8; i++){
    int nextx = x + dx[i];
    int nexty = y + dy[i];
    
    if(Cango[nextx][nexty]) dfs(nextx, nexty, Cango);

  }
}

int main(void)
{
  
  int w, h;
  int si, sj;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    vector<vector<bool> > Cango(h + 2, vector<bool>(w + 2, false));
    for(int i = 1 ; i <= h; i++){
      for(int j = 1; j <= w; j++){
	int input; cin >> input;
       Cango[i][j] = input;
      }
    }
    
    int counter = 0;

    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        if(Cango[i][j] == true){
          counter++;
           dfs(i, j, Cango);
         }
       }
     }
    cout << counter << endl;
  }

  return 0;
    
}

Measured memory_bytes: 3148
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
xli = na()
li = []
ans = 1000000000
for i in range(n - k + 1):
    l = xli[i]
    r = xli[i + k - 1]
    ans = min(ans, abs(l) + abs(r-l), abs(r) + abs(r - l))
print(ans)


Measured memory_bytes: 58608
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  if(s.size()>=4&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>PA;
#define to first
#define cost second
int main(){
  
  int a,b,c,d,e,f;
  vector<PA> vec[100001];
  queue<int> que;
  int min_cost[100001];
  fill(min_cost,min_cost+100001,INT_MAX);
  cin >> a >> b >> c;
  que.push(c);
  min_cost[c] = 0;
  
  for(int i=0;i<b;i++){
    cin >> d >> e >> f;
    vec[d].push_back(PA(e,f));
  }
  
  while(!que.empty()){
    int g = que.front();
    que.pop();
    for(int i=0;i<vec[g].size();i++){
      if(min_cost[vec[g][i].to] > min_cost[g]+vec[g][i].cost){
	min_cost[vec[g][i].to] = min_cost[g]+vec[g][i].cost;
	que.push(vec[g][i].to);
      }
    }
  }

  for(int i=0;i<a;i++){
    if(min_cost[i] != INT_MAX) cout << min_cost[i] << endl;
    else cout << "INF" << endl;
  }
  return (0);
}

Measured memory_bytes: 12456
#include <iostream>

using namespace std;

int main ()

{
 int a,b,c ;

 cin >> a >> b >> c ;

 if(a<=b && b<=c)
 cout << a <<" "<< b <<" "<< c << endl;
 else if(a<=c && c<=b)
 cout << a <<" "<< c <<" "<< b << endl;
 else if(b<=a && a<=c)
 cout << b <<" "<< a <<" "<< c << endl;
 else if(b<=c && c<=a)
 cout << b <<" "<< c <<" "<< a << endl;
 else if(c<=a && a<=b)
 cout << c <<" "<< a <<" "<< b << endl;
 else
 cout << c <<" "<< b <<" "<< a << endl;

return 0;
}







Measured memory_bytes: 3088
#include <stdio.h>

#define INF 1e18

long long min(long long a, long long b){ return a < b ? a : b; }

int main(){
    long long n, s;
    long long ans = INF;
    scanf("%lld%lld", &n, &s);
    for(int i=2; i<=10000005; i++){
        //printf("n base %d: ", i);
        long long temp = n;
        long long res=0;
        while(temp){
            //printf("%lld ", temp%i);
            res += temp%i;
            temp /= i;
        }
        if(res == s) ans = min(i, ans);
    }
    for(long long x = 1; x <= min(s, 10000005); x++){
        long long y = s-x;
        long long b = (n-y)/x;
        if(b*x != n-y) continue;
        if(y >= b || x >= b || b == 1) continue;
        ans = min(b, ans);
    }
    if(ans == INF){
        if(n == s) printf("%lld", n+1);
        else printf("-1");
    } else printf("%lld", ans);
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int num0,num1,num2;
    int ans=0;
    cin>>num0>>num1>>num2;
    if((num1-num0)*(num1-num2)<0)ans++;
    num0=num1;
    num1=num2;
    for (int i = 0; i < n-3; ++i){
        cin>>num2;
        if((num1-num0)*(num1-num2)<0)ans++;
        num0=num1;
        num1=num2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;
        //cin>>t;
        while(t--)
        {
            ll n;
            cin>>n;
            string s;
            cin>>s;
            stack<ll> r;
            queue<ll> w;
            for(ll i=0;i<n;i++)
            {
                if(s[i]=='R')r.push(i);
                if(s[i]=='W')w.push(i);
            }

            ll ans = 0;
            while(true)
            {
                if(r.empty())break;
                if(w.empty())break;
                if(w.front()>r.top())break;

                ans++;
                r.pop();
                w.pop();
            }
            cout<<ans<<endl;
        }
    }

Measured memory_bytes: 5276
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

LL MAX_N = 5*100000;
LL p = 1E9 + 7;
vector<LL> factorials(MAX_N+1,0);
vector<LL> ifactorials(MAX_N+1,0);


LL getPow(LL val, LL n){
    // バイナリ法
    LL ans = 1;
    while(n > 0){
        ans = ans % p;
        if((n & 1) == 1){
            ans = (ans * (val%p)) % p;
        }
        val = ((val%p) * (val%p))%p;
        n = n >> 1;
    }
    return ans%p;
}

LL combination(LL n, LL k){
    if(k==0){return 1;}
    LL val1 = factorials[n];
    LL val2 = ifactorials[k]; //getPow(factorials[k], p-2);
    LL val3 = ifactorials[n-k]; //getPow(factorials[n-k], p-2);
    
    return ((val1 * val2)%p * val3)%p;
}

LL permutation(LL n, LL k){
    if(k==0){return 1;}
    LL val1 = factorials[n];
    // LL val2 = getPow(factorials(k), p-2);
    LL val3 = ifactorials[n-k]; //getPow(factorials[n-k], p-2);

    return ((val1 * val3)%p);
}

int main(){
    int N, M;
    cin >> N >> M;

    if(M<N){
        cout << 0 << endl;
        return 0;
    }

    REP(i, MAX_N+1){
        if(i==0){
            factorials[i] = 1;
            ifactorials[i] = 1;
        }else{
            factorials[i] = (factorials[i-1]*i)%p;
            ifactorials[i] = (ifactorials[i-1] * getPow(i, p-2))%p;
        }
    }

    LL ans_p = 0;
    LL ans_n = 0;
    for(int k=0; k<=N; k++){
        // LL sign = (k%2==0)? 1:-1;
        LL val1 = combination(N, k);
        LL val2 = permutation(M, k);
        LL val3 = getPow(permutation(M-k, N-k), 2);

        LL tmp = ((val1 * val2)%p * val3)%p;
        if(k%2==0){
            ans_p = (ans_p + tmp)%p;
        }else{
            ans_n = (ans_n + tmp)%p;
        }
    }

    if(ans_p < ans_n){
        cout << p + (ans_p - ans_n)%p << endl;
    }else{
        cout << (ans_p - ans_n)%p << endl;
    }
    return 0;
}

Measured memory_bytes: 10992
N,M=map(int,input().split())
a=[0]*N#正解した問題一覧
b=[0]*N
for i in range(M):
    s=list(map(str,input().split()))
    if s[1]=="AC" and a[int(s[0])-1]==0:
        a[int(s[0])-1]+=1
    elif s[1]=="AC" and a[int(s[0])-1]==1:
        pass
    elif s[1]=="WA" and a[int(s[0])-1]==0:
        b[int(s[0])-1]+=1
for i in range(N):
    if b[i]>=1 and a[i]==0:
        b[i]=0
    
print(sum(a),sum(b))

Measured memory_bytes: 4724
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cmath>
#include <stack>
typedef long long ll;
#define INF 0x3f3f3f3f

using namespace std;
int str_s1[4000 + 10][30];
int str_s2[4000 + 10][30];

char str1[4000 + 10];
char str2[4000 + 10];

unsigned long long lists[16 * 1000000 + 10];

void solve() {
	scanf("%s", str1 + 1);
	scanf("%s", str2 + 1);
	
	int len_1 = strlen(str1 + 1);
	int len_2 = strlen(str2 + 1);
	memset(str_s1, 0, sizeof(str_s1));
	memset(str_s2, 0, sizeof(str_s2));
	
	int maxLen = min(len_1, len_2);
	
	for(int i = 1; i <= len_1; i++) {
		str_s1[i][str1[i] - 'a'] = 1;
		for(int j = 0; j < 26; j++) {
			str_s1[i][j] += str_s1[i - 1][j];
		}
	}
	
	
	for(int i = 1; i <= len_2; i++) {
		str_s2[i][str2[i] - 'a'] = 1;
		for(int j = 0; j < 26; j++) {
			str_s2[i][j] += str_s2[i - 1][j];
		}
	}
	int index = 0;
	for(int l = 1; l <= len_1; l++) {
		for(int r = l; r <= len_1; r++) {
			unsigned long long num = 7;
			for(int j = 0; j < 26; j++) {
				num += (num  << 11) + str_s1[r][j] - str_s1[l - 1][j];
			}
			//cerr << num << endl;
			lists[index++] = num;
		}
	}
	
	sort(lists, lists + index);
	
	int ans = 0;
	int flag = 0;
	for(int l = maxLen; l && !flag; l--) {
		for(int i = 1; i + l - 1 <= len_2 && !flag; i++) {
			unsigned long long num = 7;
			for(int j = 0; j < 26 && !flag; j++) {
				num += (num << 11) + str_s2[i + l - 1][j] - str_s2[i - 1][j];
			}
			unsigned long long * it = lower_bound(lists, lists + index, num);
			if(*it == num) {
				ans = l;
				flag = 1;
			}
				
		}
	}
	printf("%d\n", ans);
	
	
}
int main(int argc, char *argv[]) {
	//freopen("data.txt", "r", stdin);
	solve();
}

Measured memory_bytes: 66668
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, k, a[N], dp[N];

void solve()
{
    fill(dp, dp+N, MOD);
    cin >> n >> k; for (int i=1; i<=n; i++) cin >> a[i];
    dp[1]=0;
    for (int i=2; i<=n; i++) {
        for (int j=i-1; j>=max(1, i-k); j--) {
            dp[i] = min(dp[i], dp[j] + abs(a[i]-a[j]));
        }
    }nout(dp[n]);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4396
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
v = 0
for num in a:
    v ^= num
if v==0:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Measured memory_bytes: 86516
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	char s[3][4];
	for(int i=0;i<3;i++){
		scanf("%s", s[i]);
	}
	for(int i=0;i<3;i++){
		printf("%c", s[i][i]);
	}
	printf("\n");
	return 0;
}


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

class Main {
    public static void main(String[] args) throws  IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
      	int x = Integer.parseInt(br.readLine());
      	
      	for (int i = 3; i <= x; i++) {
        	if(i % 3 == 0) {
              sb.append(" " + i);
            } else {
                for (int j = i; j > 0; j /= 10) {
                    if (j % 10 == 3) {
                        sb.append(" " + i);
                        break;
                    }
                }
            }
      	}
      	System.out.print(sb + "\n");
    }
}


Measured memory_bytes: 26464
#include <stdio.h>

int main(void){

 int N, A[1000], i, v, j;

 scanf("%d", &N);

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

 for(i = 0; i < N; i++){
  v = A[i];
  j = i -1;
  while(j >= 0 && A[j] > v){
   A[j+1] = A[j];
   j--;
  }
  A[j+1] = v;
  for(j = 0; j<N-1; j++)
   printf("%d ", A[j]);
  printf("%d\n", A[N-1]);
 }

 return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 084_abc_d / Link: https://abc084.contest.atcoder.jp/tasks/abc084_d?lang=en  ----- */
/* ------問題------

「N も (N+1)÷2 も素数」を満たす奇数 N を 2017に似た数 とします。
Q 個のクエリが与えられます。
クエリ i(1≦i≦Q) では奇数 li,ri が与えられるので、li≦x≦ri かつ 2017に似た数 となる奇数 x の個数を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;
#define primeN 100000
bool prime[primeN + 1];// 外部だとハッシュ表みたいになる
void make_prime() {
	FOR(i, 0, primeN + 1) {
		prime[i] = 1;
	}prime[0] = prime[1] = 0;

	for (int i = 2; i <= primeN; i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= primeN; j += i)
				prime[j] = 0;
		}
	}
}
#undef primeN 

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

	make_prime();

	VI like2017(100001, 0);
	FOR(i, 1, 100001) {
		if (i % 2 == 1 && prime[i] && prime[(i + 1) / 2]) {
			like2017[i] = 1;
		}
	}
	VI sum(100002, 0);
	FOR(i, 0, 100001) {
		sum[i + 1] += sum[i]+ like2017[i];
	}

	cin >> N;
	FOR(i, 0, N) {
		int L, R;
		cin >> L >> R;
		cout << sum[R+1] - sum[L] << endl;
	}

	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	string S;
	cin >> S;
	int ans = S.length();
	for(int i = 0; i < 26; i++) {
		int last = -1, cur = 0;
		for(int j = 0; j < (int)S.length(); j++) if(S[j] == 'a'+i) {
			cur = max(cur, j-last-1);
			last = j;
		}
		cur = max(cur, (int)S.length()-last-1);
		ans = min(ans, cur);
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN],dp[MAXN][2];
vector<int> G[MAXN];
void add(int &a,int b){a+=b; if(a>=MOD) a-=MOD;}
void add_edge(int u,int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}
void dfs(int v,int p)
{
    dp[v][0]=dp[v][1]=1;
    for(auto to:G[v])
    {
        if(to==p) continue;
        dfs(to,v);
        dp[v][0]=1LL*dp[v][0]*dp[to][1]%MOD;
        dp[v][1]=1LL*dp[v][1]*(dp[to][0]+dp[to][1])%MOD;
    }
}
int main()
{
    scanf("%d",&n);
    if(n==1) {puts("2"); return 0;}
    for(int i=0;i<n-1;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        add_edge(u,v);
    }
    dfs(1,0);printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
    return 0;
}



Measured memory_bytes: 9472
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
#define long long ll

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      a/=2;b+=a;
    }
    if(i%2!=0){
      b/=2;a+=b;
    }
  } 
  cout<<a<<" "<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = X/500*1000;
        X-=X/500*500;
        ans += X/5*5;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844