akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    private static int n;
    private static int x;
    private static int y;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // ##### 初期読み込み #######################################################################
        // 1行 文字 複数 ----------------------------------------------------------------------------
        String[] stringArray = scanner.nextLine().split(" ");

        n = Integer.parseInt(stringArray[0]);
        x = Integer.parseInt(stringArray[1]);
        y = Integer.parseInt(stringArray[2]);

        // ##### メイン処理 #######################################################################

        int[] result = new int[n];

        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                // XYルート使わない場合のi,j間の距離
                int route1 = j - i;

                // XYルート使う場合のi,j間の距離
                int route2 = Math.abs(x - i) + 1 + Math.abs(y - j);

                result[Math.min(route1, route2)]++;
            }
        }

        for (int i = 1; i < n; i++) {
            System.out.println(result[i]);
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


//　一文字のとき
int main() {
  string s; ll k;
  cin >> s >> k;
  if(s.size() == 1){
    cout << k/2 << endl;
    return 0;
  }
  ll l = 1, r = 1;
  rep(i, 1, s.size()){
    if(s[i] == s[i-1]) l++;
    else break;
  }
  for(int i = s.size()-2; i >= 0; i--){
    if(s[i] == s[i+1]) r++;
    else break;
  }
  vector<bool> f(105, true);
  ll cnt = 0;
  rep(i, 0, s.size()){
    if(s[i] == s[i-1] && f[i-1]){
      cnt++;
      f[i] = false;
    }
  }

  ll ans = cnt * k;
  bool g = false;

  rep(i, 1, s.size()) if(s[i] != s[0]) g = true;
  if(!g && s.size()%2 != 0){ // 全部同じ文字　文字の長さが奇数
    cout << s.size()*(k/2)+(s.size()/2)*(k%2) << endl;
    return 0;
  }
  if(s[s.size()-1] == s[0] && (l+r)%2 == 0 && g) ans += k-1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S1 = input().strip()
S2 = input().strip()
mod = 10 ** 9 + 7

ans = 1
idx = 0
before_type = 0
if S1[0] == S2[0]:
    ans *= 3
    idx = 1
    before_type = 0
else:
    ans *= 6
    idx = 2
    before_type = 1

while idx < N:
    if S1[idx] == S2[idx]:
        if before_type == 0:
            ans *= 2
        idx += 1
        before_type = 0
    else:
        if before_type == 1:
            ans *= 3
        else:
            ans *= 2
        idx += 2
        before_type = 1
    ans %= mod
print(ans)

Measured memory_bytes: 3064
import Control.Monad
import Data.List
main = do
    n<-readLn::IO Int
    ws<-replicateM n getLine::IO [String]
    let ns = nub ws
    putStrLn $ chk ws ns
--
chk ws@(u:v) ns
    | length ws /= length ns = "No"
    | otherwise = chk2 u v
--
chk2 _ [] = "Yes"
chk2 u (v@(x:_):r)
    | last u /= x = "No"
    | otherwise = chk2 v r


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


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

    string s={"ACL"};

    int n;
    cin>>n;

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

    cout<<"\n";
    

    
    return 0;
}


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

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

    vector<int> nmb(N);
    int count = 0;
    
    for (int i = 0; i < N; i++) { 
        cin >> nmb.at(i);
    }

    for (int j = 0; j < 1000; j++) {
        for (int i = 0; i < N; i++) {
            if (i != N - 1 && nmb.at(i) % 2 == 0) {
                nmb.at(i) /= 2;
            }
            else if (i == N - 1 && nmb.at(i) % 2 == 0) {
                nmb.at(i) /= 2;
                count++;
            }
            else {
                break;
            }
        }
    }
    cout << count << endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int n, w;
    while (cin >> n >> w, n|w) {
        vi hist(11);
        int ma = 0, cnt = 0;
        REP(i, n) {
            int v;
            cin >> v;
            int idx = v/w;
            hist[idx]++;
            ma = max(ma, hist[idx]);
            cnt = max(cnt, idx);
        }
        double res = 0;
        REP(i, cnt) {
            res += (double)hist[i] / (double)ma * (double)(cnt-i) / (double)cnt;
        }
        cout << res + 0.01 << endl;
    }
}

Measured memory_bytes: 3184
#import<ios>
int D,d,c,a,X=448;char s[9];int main(){for(;c+21&&scanf("%s",s);a+=D/64)c=*s-69,d=511-D,D=c-9?c-14?c?c-18?c-13?c-7?a&&printf("%d\n",a),a=0,83:D&X|d*8&56|D/8&7:D&X|D*8&56|d/8&7:D*64&X|D&56|d/64:d*64&X|D&56|D/64:d*8&X|D/8&56|D&7:D*8&X|d/8&56|D&7;}

Measured memory_bytes: 0
num = gets.split(" ")
s = gets.chomp.split("")

x = 0
y = 0
z = 0
num[0] = num[0].to_i
num[1] = num[1].to_i
num[2] = num[2].to_i
repeat = num[0] - 1

for n in 0..repeat do
  if s[n] == "a"
    if num[1] + num[2] > z
      puts "Yes"
      x += 1
    else
      puts "No"
    end
  elsif s[n] == "b"
    if num[1] + num[2] > z && num[2] > y
      puts "Yes"
      y += 1
    else
      puts "No"
    end
  else
    puts "No"
  end 
  z = x + y
end


Measured memory_bytes: 9852
n,k = map(int,input().split())
a = list(map(int,input().split()))
imos = [0]*(2*10**5+1)
for j in range(min(k,50)):
    imos = [0]*(2*10**5+1)
    for i in range(n):
        imos[max(i-a[i],0)] += 1
        imos[min(i+a[i]+1,2*10**5)] -= 1
    for i in range(1,n):
        imos[i] += imos[i-1]
    a = imos
print(*imos[:n])


Measured memory_bytes: 171944
from itertools import chain

h, w = map(int, input().split())
s = [input() for _ in range(h)]
a = [[-1] * w for _ in range(h)]
for i in range(h):
    p = 0
    while p < w:
        j = p
        while j < w and s[i][j] == '.':
            j += 1
        for k in range(p, j):
            a[i][k] += j - p
        p = j + 1

for j in range(w):
    p = 0
    while p < h:
        i = p
        while i < h and s[i][j] == '.':
            i += 1
        for k in range(p, i):
            a[k][j] += i - p
        p = i + 1

print(max(chain.from_iterable(a)))


Measured memory_bytes: 99032
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if(op.equals("+")){
			System.out.println(a+b);
		}else{
			System.out.println(a-b);
		}
	}
}

Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e5+10;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
bool check(int x){

}
int binary(int x,int y){
    int s=x,e=y,mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[i]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}

int fun(int arr[],int s,int e){
    if(e-s==1){
        return 0;
    }
    int sz1=(s+e)/2;
    int sz2=e-(sz1+s);
    int ans=fun(arr,s,sz1)+fun(arr,sz1,e);
    int x=s;
    for(int i=sz1;i<e;i++){
        if(arr[i]>arr[x]){
            ans+=sz1-(x);
        }
        else{
            i--;
            x++;
        }
    }
    return ans;
}

in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        string s;
        cin>>s;
        cout<<(s[3]==s[2]&&s[4]==s[5]?"Yes\n":"No\n");
    }
    RETURN;
}


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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int    X,A,B;
	
	i_cin3(X, A, B);
	if (B <= A) { s_cout("delicious"); return 0; }
	if (B <= A + X) {s_cout("safe"); return 0;}
	s_cout("dangerous");
	return 0;

}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}




Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if (a+b==15){
			System.out.println("+");
		}else if (a*b==15){
			System.out.println("*");
		}else {
			System.out.println("x");
		}

	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x =scan.nextInt();
		int a =scan.nextInt();
		int b =scan.nextInt();

		int ans;

		ans = x - a;
		ans = ans % b;
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int ans = 0;
	if(s[0] == t[0]) ans++;
	if(s[1] == t[1]) ans++;
	if(s[2] == t[2]) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll n,A,B,K,f[600005],inv[600005];
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
ll C(int a,int b){
	return f[a]*inv[b]%mod*inv[a-b]%mod;
}
int main(){
	scanf("%lld%lld%lld%lld",&n,&A,&B,&K);
	ll ans=0;
	f[0]=inv[0]=1;
	for(int i=1;i<=600002;i++) f[i]=f[i-1]*i%mod,inv[i]=quick_pow(f[i],mod-2);
	for(ll i=0;i<=n&&A*i<=K;i++)if((K-A*i)%B==0&&(K-A*i)/B<=n)ans=(ans+C(n,i)*C(n,(K-A*i)/B))%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)

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

using namespace std;

signed main() {
	int N,x;
    string S;
	cin >> N >> S;
    x = N;
    rep(i, N-1) {
        if (S[i] == S[i + 1])
            x--;
    }
    cout << x;
}

Measured memory_bytes: 512
N=int(input())
D="MARCH"
cnt=[0]*5
for i in range(N):
  s=input()[0]
  if s in D:
    cnt[D.index(s)]+=1

pat=[None]*10
pati=0
for a in range(5):
  for b in range(a+1,5):
    for c in range(b+1,5):
      pat[pati]=[a,b,c]
      pati+=1

ans=0
for p in pat:
  ans+=cnt[p[0]]*cnt[p[1]]*cnt[p[2]]
  
print(ans)


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double L; cin >> L;
  cout << fixed << setprecision(10) << L * L * L / 27 << endl;
}

Measured memory_bytes: 256
#include <iostream>
int H,W;
char field[51][51];
int num[51][51];
int dx[8]={-1,-1,-1,0,0,1,1,1}, dy[8]={-1,0,1,-1,1,-1,0,1};

int main(){
  std::cin>>H>>W;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      std::cin>>field[i][j];
      if(field[i][j]=='#'){
        for(int k=0;k<8;++k){
          int x=i+dx[k],y=j+dy[k];
          if(x>=0 && x<H && y>=0 && y<W)num[x][y]++;
        }
      }
    }
  }
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      if(field[i][j]=='.')std::cout<<num[i][j];
      else std::cout<<field[i][j];
    }
    std::cout<<std::endl;
  }
  return 0;
}



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

int main()
	{
	long long x ,y ,ans ,tmp ,tmpx ,tmpy ;
	long long n ,d ;
	scanf("%lld%lld" ,&n ,&d) ;
	d*=d ;
	ans=0 ;
	while(n--)
		{
		scanf("%lld%lld" ,&x ,&y) ;
		tmpx=x*x ;
		tmpy=y*y ;
		tmp=tmpx+tmpy ; 
		if(tmp<=d)
			ans++ ;
		} 
	printf("%lld\n" ,ans) ;
	}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int a,b,c,d,s1 = 0,s2 = 0;
  cin >> a >> b >> c >> d;
  while(a > 0)
  {
      a -= d;
      s1++;
  }
  while(c > 0)
  {
      c -=b;
      s2++;
  }
  if(s1 >= s2) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 3636
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	rep(i,3){
		string s;
		cin>>s;
		cout<<char(toupper(s[0]));
	}
	cout<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int S = sc.nextInt();
		final int W = sc.nextInt();
		sc.close();
		if(S>W){
			System.out.println("safe");
		}else{
			System.out.println("unsafe");
		}
	}
}


Measured memory_bytes: 35648
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;


int main() {
	while(1){
		int x,y,s,ma=0;
		cin >> x >> y >> s;
		if(x==0 && y==0 && x==0) return 0;
		for(int i=1; i<s; i++){
			for(int j=1; j<s; j++){
				if(i*(100+x)/100+j*(100+x)/100==s){
					ma=max(ma,i*(100+y)/100+j*(100+y)/100);
				}
			}
		}
		cout << ma << endl;
	}
}



Measured memory_bytes: 3064
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            for (int i = 1; i <= num; i++)
            {
                if (i % 3 == 0)
                {
                    Console.Write(" " + i);
                }
                else if (i % 10 == 3)
                {
                    Console.Write(" " + i);
                }
                else
                {
                    int j = i;
                    while (true)
                    {
                        j /= 10;
                        if (j < 3)
                        {
                            break;
                        }
                        if (j % 10 == 3)
                        {
                            Console.Write(" " + i);
                            break;
                        }
                    }
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9248
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, X = map(int, readline().split())

    @lru_cache(maxsize=None)
    def rec1(i):
        if i == 0:
            return 1
        else:
            return 2 * rec1(i - 1) + 1

    @lru_cache(maxsize=None)
    def rec2(i):
        if i == 0:
            return 1
        else:
            return 2 * rec2(i - 1) + 3

    def rec(i, x):
        if x <= 0:
            return 0
        if i == 0:
            return 1

        x -= 1
        ans = 0
        if x > rec2(i - 1):
            x -= rec2(i - 1)
            ans += rec1(i - 1)
        else:
            ans += rec(i - 1, x)
            return ans

        if x > 0:
            x -= 1
            ans += 1
        else:
            return ans

        if x > rec2(i - 1):
            x -= rec2(i - 1)
            ans += rec1(i - 1)
        else:
            ans += rec(i - 1, x)

        return ans

    print(rec(N, X))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9664
#include<iostream>

using namespace std;
int main()
{
	int a, b;
	cin>>a>>b;
	if (a < b) 
		cout<<"a < b"<<endl;
	else if (a > b) 
		cout<<"a > b"<<endl;
	else 
		cout<<"a == b"<<endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

struct block{
    int w, s;
    lint v;
    
    bool operator <(const block another) const{
        return w + s < another.w + another.s;
    }
};

int N;
vector<block> blocks;

lint dp[1145][14810];

lint tower(int now, int sum){
    if(now == N || sum > 10000){
        return 0;
    }else if(dp[now][sum] != -1){
        return dp[now][sum];
    }
    lint ans = tower(now + 1, sum);
    if(sum <= blocks[now].s){
        ans = max(ans, tower(now + 1, sum + blocks[now].w) + blocks[now].v);
    }
    return dp[now][sum] = ans;
}

int main(){
    cin >> N;
    blocks.resize(N);
    for(int i = 0; i < N; i++){
        cin >> blocks[i].w >> blocks[i].s >> blocks[i].v;
    }
    sort(all(blocks));
    memset(dp, -1, sizeof(dp));
    cout << tower(0, 0) << endl;
}


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

int main(){
  int n;
  cin >> n;
  map<string, int> a;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    a[s]++;
  }
  int mx = 0;
  for(auto p : a){
    mx = max(mx, p.second);
  }
  for(auto p : a){
    if(p.second != mx){
      continue;
    }
    cout << p.first << endl;
  }
}


Measured memory_bytes: 25600
from itertools import groupby


def all_equal(iterable):
    g = groupby(iterable)
    return next(g, True) and not next(g, False)


N, A, B = map(int, input().split())
if all_equal(map(lambda x: x % 2, (A, B))):
    print((B - A) // 2)
else:
    print(min((A - 1, N - B)) + 1 + (B - A - 1) // 2)


Measured memory_bytes: 3188
N, Q = map(int,input().split())
S = input()
AC = [0,0]
for i in range(1,len(S)):
    if S[i-1] == "A" and S[i] == "C":
        AC.append(AC[-1]+1)
    else:
        AC.append(AC[-1])
for i in range(Q):
    l, r = map(int,input().split())
    print(AC[r]-AC[l])

Measured memory_bytes: 53044
require 'set'
N, M = gets.split.map(&:to_i)
E = $<.map{|ab| ab.split.map(&:to_i) }

Tr = Hash.new{|h,k| h[k]=[] }
E.each{|a,b|
	Tr[a] << b
	Tr[b] << a
}

Cycle = (CycleDetector = lambda{|vs|
	ret = []
	Tr[vs[-1]].each{|b|
		pb = vs.index(b)
		if pb.nil?
			vs << b
			ret.concat CycleDetector[vs]
			vs.pop
		elsif vs.length - pb <= 2
		else
			ret << Set[*vs[pb,vs.length-pb]]
		end
	}
	return ret
}).call [1]

V = Cycle + (1..N).map{|v| Set[v] }
i = -1
until (i+=1) == V.length
	j = V.length
	until (j-=1) == i
		V[i].merge(V.delete_at(j)) if V[i].intersect?(V[j])
	end
end
br, nbr = E.partition{|ab|
	i, j = ab.map{|c| V.index{|v| v.include? c } }.sort
	V[i].merge V.delete_at j if i != j
	next i != j
}
p br.size


Measured memory_bytes: 43900
n,m,l = gets.split.map(&:to_i)
a = []
b = []

for i in 1..n
 a << gets.split.map(&:to_i)
end

for j in 1..m
 b << gets.split.map(&:to_i)
end

for i in 1..n
 for j in 1..l
 if j != 1
 print " "
end
 mul = 0
for k in 1..m
 mul += a[i-1][k-1] * b[k-1][j-1]
end
print mul 
end
puts "\n"

end


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

int main() {
  string S;
  int Q;
  cin >> S >> Q;
  int flag = 0;
  int t, f;
  string c, pre;
  for (int i = 0; i < Q; i++){
    cin >> t;
    if (t == 1){
      flag++;
    }
    else{
      cin >> f >> c;
      if ((f == 1 && flag % 2 == 0) || (f == 2 && flag % 2 == 1)){
        pre += c;
      }
      else{
        S += c;
      }
    }
  }
  reverse(pre.begin(), pre.end());
  pre += S;
  if (flag % 2 == 1){
    reverse(pre.begin(), pre.end());
  }
  cout << pre << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    string s;
    cin >> s;
    ll ans = 100100100, tmp = 0;
    // 0101...
    rep(i, s.size()) {
        // 0
        if((i%2)==0) {
            if(s[i] == '1') tmp++;
        }
        // 1
        else {
            if(s[i] == '0') tmp++;
        }
    }
    if(ans > tmp) ans = tmp;

    tmp = 0;
    // 1010..
    rep(i, s.size()) {
        // 1
        if((i%2)==0) {
            if(s[i] == '0') tmp++;
        }
        // 0
        else {
            if(s[i] == '1') tmp++;
        }
    }
    if(ans > tmp) ans = tmp;
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



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

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c;
    d = c - a - b;
    if (d > 0 && 4 * a * b < d * d) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
typedef long long ll;
using namespace std;
struct hhh
{
    double x,y;
} h[105];
ll a[100];
double fun(double x1,double y1,double x2,double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
    ll i,j,n,flag=1,as=0;
    double ans=0;
    scanf("%lld",&n);

    for(i=1; i<=n; i++)
    {
        scanf("%lf %lf",&h[i].x,&h[i].y);
        a[i]=i;
    }
    do
    {
        for(i=1; i<n; i++)
        {
            //printf("**%lld %lld\n",a[i],a[i+1]);
            ans+=fun(h[a[i]].x,h[a[i]].y,h[a[i+1]].x,h[a[i+1]].y);
           // printf("%lf\n",fun(h[a[i]].x,h[a[i]].y,h[a[i+1]].x,h[a[i+1]].y));
        }
as++;
    }
    while(next_permutation(a+1,a+1+n));
    printf("%.10f",ans/as);


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define in(x); { for (auto &qwertyhgfdsa : x) cin >> qwertyhgfdsa; }
#define out(x); { for (auto qwertyhgfdsa : x) cout << qwertyhgfdsa << ' '; cout << endl; }
#define int long long

typedef long long ll;

using namespace std;

const int INF = 1e9;
const long long INFll = 2e18;
const long long base1 = 239;
const long long base2 = 653;
const long long mod = 1e9 + 7;
const double eps = 1e-6;
const int len = 140;

char s[100]; int N;
void go(int n, int k) {
    if (n == N) {
        for (int i = 0; i < n; i++)
            cout << s[i];
        cout << '\n';
        return;
    }
    for (int i = 0; i < k; i++) {
        s[n] = 'a' + i;
        go(n + 1, k);
    }
    s[n] = 'a' + k;
    go(n + 1, k + 1);
}

void solve() {
    go(0, 0);
}

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

    cin >> N;
    solve();
}


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

int main() {
	int N,sum;
	cin >>N;
	vector<int>an(N);
	vector<int>bn(N);
	vector<int>cn(N-1);
	
	for(int i=0;i<N;i++){
		cin >> an.at(i);
	}
	for(int i=0;i<N;i++){
		cin >> bn.at(i);
	}
	for(int i=0;i<N-1;i++){
		cin >> cn.at(i);
	}
	
	sum=0;
	int a1,a2;
	a1=an.at(0)-1;
	a2=a1;
	
	for(int i=0;i<N;i++){
		sum =sum+bn.at(an.at(i)-1);
		a2 = an.at(i)-1;
		
		if(a2-a1 == 1 ){
			sum =sum +cn.at(an.at(i)-2);
		}
		a1 = a2;
		
	}
	cout << sum<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;


int main(void) {
	int n, k;
	string s;
	cin >> n >> s >> k;
	char sk = s[k - 1];
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != sk) {
			s[i] = '*';
		}
	}
	cout << s << endl;
	return 0;
}

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

int main(){
  int N,M,a,b;
  vector<pair<int,int>>vec;
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>a>>b;
    vec.emplace_back(b,a);
  }
  int temp=-1;
  int cnt=0;
  sort(vec.begin(),vec.end());
  for(auto itr=vec.begin();itr !=vec.end();itr++){
    //cout<<itr->second<<" "<<itr->first<<"temp"<<temp<<endl;
    if((itr->second)<=temp && temp<(itr->first)) continue;
    //cout<<itr->second<<"*"<<itr->first<<endl;
    //cout<<(itr->first)-1<<endl;
    cnt++;
    temp=(itr->first)-1;
  }

  cout<<cnt<<endl;
 
  return 0;
}
 



Measured memory_bytes: 4316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define MOD 1000000007
using namespace std;
inline int read(){
    int re=0,flag=1;char ch=getchar();
    while(ch>'9'||ch<'0'){
        if(ch=='-') flag=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
    return re*flag;
}
const int dx[3]={0,0,1},dy[3]={0,1,0};
int dp[4020][4020];int N=2005;bool vis[4020][4020];
int n,xx[200010],yy[200010],qx[200010],qy[200010],head=0,tail=1,maxq=200000;
ll inv[8010],finv[8010],f[8010];
void init(){
    int i;inv[1]=finv[1]=1;
    for(i=2;i<=8000;i++){
        inv[i]=((MOD-MOD/i)*inv[MOD%i])%MOD;
    }
    f[1]=1;
    for(i=2;i<=8000;i++){
        f[i]=(f[i-1]*i)%MOD;
        finv[i]=(finv[i-1]*inv[i])%MOD;
    }
}
int main(){
    init();
    int i,maxx=0,maxy=0,x,y,tx,ty;ll X=0;
    n=read();
    for(i=1;i<=n;i++){
        xx[i]=read();yy[i]=read();
        dp[N-xx[i]][N-yy[i]]+=1;
        maxx=max(maxx,xx[i]);maxy=max(maxy,yy[i]);
    }
    qx[0]=N-maxx,qy[0]=N-maxy;vis[N-maxx][N-maxy]=1;
    while(head!=tail){
        x=qx[head];y=qy[head];head=(head+1)%maxq;
//        cout<<"dp "<<x<<ends<<y<<ends<<dp[x][y]<<endl;;
        for(i=1;i<=2;i++){
            tx=x+dx[i];ty=y+dy[i];
            if(tx>N+maxx||ty>N+maxy) continue;
            dp[tx][ty]=(dp[tx][ty]+dp[x][y])%MOD;
//            cout<<"    to "<<tx<<ends<<ty<<ends<<dp[tx][ty]<<endl;
            if(!vis[tx][ty]){
                vis[tx][ty]=1;
                qx[tail]=tx;qy[tail]=ty;tail=(tail+1)%maxq;
            }
        }
    }
    for(i=1;i<=n;i++){
        X=X+dp[N+xx[i]][N+yy[i]];X%=MOD;
        X=X-((f[xx[i]*2+yy[i]*2]*finv[xx[i]*2])%MOD*finv[yy[i]*2])%MOD+MOD;
        X%=MOD;
    }
    printf("%lld\n",(X*inv[2])%MOD);
}

Measured memory_bytes: 82304
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double ans = 0;
    int a, b;
    for (int Ac = 0; Ac <= 30; Ac++) {
        for (int Bc = 0; Bc <= 30; Bc++) {
            for (int Cc = 0; Cc <= 60; Cc++) {
                for (int Dc = 0; Dc <= 60; Dc++) {
                    if (100 * A * Ac + 100 * B * Bc + C * Cc + D * Dc <= F && C * Cc + D * Dc <= E * (A * Ac + B * Bc)) {
                        int ta = 100 * (A * Ac + B * Bc), tb = C * Cc + D * Dc;
                        double tt = 100.0 * tb / (ta + tb);
                        if (tt >= ans) {
                            ans = tt;
                            a = ta;
                            b = tb;
                        }
                    }
                }
            }
        }
    }
    cout << a + b << ' ' << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
 
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<ll> vi;

int main(){
    int n;
    while(cin>>n){
        n--;
        vi v(n);
        rep(i,n){
            cin>>v[i];
        }
        int x; cin>>x;
        // rep(i,n){
        //     cout<<v[i]<<" ";
        // }
        // cout<<endl;
        vi dp(21);
        dp[v[0]]=1;
        loop(i,1,n){
            vi dp2(21);
            rep(j,21){
                if(0<=j+v[i]&&j+v[i]<=20)dp2[j+v[i]]+=dp[j];
                if(0<=j-v[i]&&j-v[i]<=20)dp2[j-v[i]]+=dp[j];
            }
            // rep(i,dp2.size()){
            //     cout<<dp[i]<<" ";
            // }
            // cout<<endl;
            swap(dp2,dp);
        }
    
        cout<<dp[x]<<endl;
    }
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
const int N = 2e5 + 1;
int d[N],n,m;
bool avail[N];
vector <int> adj[N];
queue <int> Q;

void bfs(int x){
    avail[N] = true;
    Q.push(x);
    d[x] = 0;
    while (!Q.empty()){
        int u = Q.front(); Q.pop();
        for (auto v : adj[u])
            if (!avail[v]){
                avail[v] = true;
                d[v] = u;
                Q.push(v);
            }
    }
}
int main(){
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u , v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    bfs(1);
    bool check = true;
    for (int i = 2; i <= n; i++)
        if (d[i] == 0) check = false;
    if (check == false) cout << "No";
    else{
        cout << "Yes\n";
        for (int i = 2; i <= n; i++) cout << d[i] << "\n";
    }
    return 0;
}

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

// variable -------------------------------------------

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

vector<ll> a;

// structure ------------------------------------------

// function -------------------------------------------
ll nankai(ll len, ll nagasa){
	return (len - 1) / nagasa;
}

bool dekiruka(ll n, ll k, ll mid){
	ll cnt = 0;
	REP(i, n){
		cnt += nankai(a[i], mid);
	}
	if(cnt <= k){
		return true;
	}else{
		return false;
	}
}

ll nibutan(ll n, ll k, ll min, ll max){
	if(abs(max - min) <= 1){
		if(min > max){
			swap(min, max);
		}
		if(dekiruka(n, k, min) == true){
			return min;
		}else{
			return max;
		}
	}

	ll mid = (min + max) / 2;
	if(dekiruka(n, k, mid) == true){
		max = mid;
	}else{
		min = mid;
	}
	return nibutan(n, k, min, max);
}

// main -----------------------------------------------

int main() {
	ll n, k;
	cin >> n >> k;
	a = vector<ll>(n);
	ll saidai = 0;
	REP(i, n){
		cin >> a[i];
		chmax(saidai, a[i]);
	}

	ll ans = nibutan(n, k, 1, saidai);

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 4752
#include"bits/stdc++.h"

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int p[] = { 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 };
	int K;
	cin >> K;
	for (int i = 0; i < 32; i++){
		if (K - 1 == i) {
			cout << p[i] << endl;
			return 0;
		}
	}

	return 0;
}

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

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

    for(int i=n;i>0;--i){
        int sum=0;
        for(int j=2;i*j<=n;++j) sum+=b[i*j];
        if(sum%2!=a[i]) b[i]=1;
    }

    int m=accumulate(b.begin(),b.end(),0);
    cout<<m<<endl;
    for(int i=0;i<n;++i){
        if(b[i+1]) cout<<i+1<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 4716
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    string s;
    cin >> s;
    int K;
    cin >> K;
    int i;
    for(i=0;i<N;i++)
    {
        if(s[i] != s[K-1])
        {
            s[i] = '*';
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
struct L {
  int a, b, c;
  L(int a=0, int b=0, int c=0): a(a), b(b), c(c) {}
};
 
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
int main() {
  int n, m;
  cin >> n >> m;
  map<int,int> mpX, mpY;
  mpX[0] = 0;
  mpY[0] = 0;
 
  vector<L> lh, lv;
  rep(i,n) {
    int a, b, c;
    cin >> a >> b >> c;
    mpX[a] = 0;
    mpX[b] = 0;
    mpY[c] = 0;
    lh.emplace_back(a,b,c);
  }
  rep(i,m) {
    int a, b, c;
    cin >> c >> a >> b;
    mpY[a] = 0;
    mpY[b] = 0;
    mpX[c] = 0;
    lv.emplace_back(a,b,c);
  }
 
  vector<int> xs, ys;
  for (auto& p : mpX) {
    p.second = xs.size();
    xs.push_back(p.first);
  }
  for (auto& p : mpY) {
    p.second = ys.size();
    ys.push_back(p.first);
  }
 
  int h = xs.size()*2;
  int w = ys.size()*2;
 
  vector<vector<int>> d(h, vector<int>(w));
  rep(i,n) {
    int a = mpX[lh[i].a]*2;
    int b = mpX[lh[i].b]*2;
    int c = mpY[lh[i].c]*2;
    for (int x = a; x <= b; ++x) d[x][c] = -1;
  }
  rep(i,m) {
    int a = mpY[lv[i].a]*2;
    int b = mpY[lv[i].b]*2;
    int c = mpX[lv[i].c]*2;
    for (int y = a; y <= b; ++y) d[c][y] = -1;
  }
 
  queue<P> q;
  int sx = mpX[0]*2, sy = mpY[0]*2;
  d[sx][sy] = 1;
  q.emplace(sx,sy);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    rep(v,4) {
      int nx = x+dx[v], ny = y+dy[v];
      if (nx < 0 || nx >= h) continue;
      if (ny < 0 || ny >= w) continue;
      if (d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx,ny);
    }
  }
 
  ll ans = 0;
  rep(x,h)rep(y,w) {
    if (d[x][y] != 1) continue;
    if (x == 0 || x == h-1 || y == 0 || y == w-1) {
      cout << "INF" << endl;
      return 0;
    }
    if (x%2 == 0 || y%2 == 0) continue;
    ll ex = xs[x/2+1]-xs[x/2];
    ll ey = ys[y/2+1]-ys[y/2];
    ans += ex*ey;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144404
import scala.util.control.Breaks._

object Main extends App {
  var x = scala.io.StdIn.readLong()
  var time = x / 11

  breakable {
    if (x <= 6) {
      println(1)
      break()
    }
    if (x <= 11) {
      println(2)
      break()
    }

    if (x % 11 == 0){
      println(time * 2)
    } else if (x % 11 <= 6) {
      println(time * 2 + 1)
    } else {
      println(time * 2 + 2)
    }


  }
}


Measured memory_bytes: 25536
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

#define repd(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

template <typename T>
void output(T,int);
int gcd(int a,int b);

struct SegmentTree{
	vector<int> v;
	int n;
	void init(int n_){
		n=1;
		while(n<n_){
			n<<=1;
		}
		v.assign((n<<1)+1,0);
	}

	int solve(int index){
		index+=n;
		int ans=0;
		int ans_brother;
		if(index%2==0){
			ans_brother=v[index+1];
		}else{
			ans_brother=v[index];
		}

		while(index!=1){
			if(index%2==0){
				ans_brother=v[index+1];
			}else{
				ans_brother=v[index-1];
			}
			ans=gcd(ans,ans_brother);
			index/=2;
		}

		return ans;
	}
};

int main(){
	//source
	int n;
	cin >> n;
	int a[n];
	rep(i,n){
		cin >> a[i];
	}

	SegmentTree seg;
	seg.init(n);
	rep(i,n){
		seg.v[seg.n+i]=a[i];
	}
	for(int i=seg.n-1;i;i--){
		seg.v[i]=gcd(seg.v[i*2],seg.v[i*2+1]);
	}

	int ans=0;
	rep(i,n){
		ans=max(ans,seg.solve(i));
	}

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

template<typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

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


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
string a, b;

int main(){
	IOS
	bool cacat=false;
	cin >> a >> b;
	int c=a.length();
	for(int i=0;i<c;i++){
		if(a[i]!=b[i]){
			cacat=true;
			break;
		}
	}
	if(!cacat){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h.at(i);
    sort(h.rbegin(), h.rend());
    ll ans = 0;
    for(ll i = k; i < n; i++) {
        ans += h.at(i);
    }
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s,t;
    cin >> s >> t;
    ll n=t.size();
    ll x=s.size();
    if(x<n){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<ll>check(51,MOD);
    for(ll i=x-n;i>=0;i--){
        bool judge=true;
        for(ll j=0;j<n;j++){
            if(s[i+j]!='?'&&s[i+j]!=t[j]){
                judge=false;
            }
        }
        if(judge){
            check[i]=i;
        }
    }
    sort(check.begin(),check.end());
    ll cnt=0;
    for(ll i=0;i<51;i++){
        if(check[i]==MOD) break;
        cnt++;
    }
    if(cnt==0){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string>S(cnt,"");
    for(ll k=0;k<cnt;k++){
        string sumple="";
        for(ll i=0;i<x;i++){
            if(check[k]==i){
                for(ll j=0;j<n;j++){
                    sumple.push_back(t[j]);
                }
                i+=n-1;
              	continue;
            }

            if(s[i]=='?'){
                sumple.push_back('a');
            }
            else {
                sumple.push_back(s[i]);
            }
        }
        S[k]=sumple;
    }
    sort(S.begin(),S.end());
    cout << S[0] << endl;
}


Measured memory_bytes: 3604
H, W = gets.chomp.split.map(&:to_i)
S = (0..H+1).inject([]){|a, i|
    case i
    when 0, H+1 then
        a << ("." * (W+2)).chars
    else
        a << ("."+ gets.chomp + ".").chars
    end
}

Bool = (1..H).inject(true){|bool, i|
    (1..W).each{|j|
        if S[i][j] == "#" then
            jugde = [S[i-1][j], S[i][j-1], S[i][j+1], S[i+1][j]].any?{|s| s == "#"}
            bool = jugde ? bool : false
        end
    }
    
    bool
}

puts Bool ? :Yes : :No

Measured memory_bytes: 2172
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K;
	string S;
	vint retu;
	scan(N>>K);
	scan(S);
	int ans=0;
	int flag=1,num=0,iniflag=0;
	if(N<=2){
		prin(N);
		return 0;
	}
	rep(i,N){
		if(S[i]=='1'){
			iniflag=1;
			if(flag==0){
				flag=1;
				ans=max(ans,num);
				retu.push_back(num);
				num=0;
			}
			num++;
		}
		else if(iniflag){
			if(flag==1){
				flag=0;
				retu.push_back(num);
				num=0;
			}
			num++;
		}
		if(i==N-1){
			if(flag==1) retu.push_back(num);
		}
	}
	int bubunwa[100001]={};
	rep(i,retu.size()){
		bubunwa[i+1]=bubunwa[i]+retu[i];
	}
	for(int i=0;i<max(1,(int)retu.size()-2*K);i+=2){
		ans=max(ans,bubunwa[min(i+2*K+1,(int)retu.size())]-bubunwa[i]);
	}
	if(S[0]=='0'){
		int zerocount=1;
		for(int i=1;i<N&&S[i]=='0';i++,zerocount++){

		}
		ans=max(ans,bubunwa[min(2*K-1,(int)retu.size())]+zerocount);
	}
	if(S.back()=='0'){
		int zerocount=1;
		for(int i=N-2;i>=0&&S[i]=='0';i--,zerocount++){

		}
		ans=max(ans,bubunwa[(int)retu.size()]-bubunwa[max(0,(int)retu.size()-2*K+1)]+zerocount);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1272
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanInit()

	s := nextStr()
	ans := 0
	for i := 0; i < 4; i++ {
		if strings.Index(s, strings.Repeat("R", i)) != -1 {
			ans = i
		}
	}
	fmt.Println(ans)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780