akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,K,x;
    cin >> N >> K;
    int ans = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> x;
        if (abs(x-K) > x)
        {
            ans += 2*x;
        }
        else
        {
            ans += 2*abs(x-K);
        }
    };

    cout << ans << endl;
    
}


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

int ans;
bool b[5][5];
int p[4][2];

void rec(int n){
  if(n==8){ans++; return;}

  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(!b[i][j]){
	for(int k=0;k<4;k++){
	  int sx = j+p[k][0], sy = i+p[k][1];
	  if(sx<0 || sy<0 || 3<sx || 3<sy)continue;
	  if(b[sy][sx])continue;

	  b[i][j] = b[sy][sx] = true;
	  rec(n+1);
	  b[i][j] = b[sy][sx] = false;
	}
	return;
      }
    }
  }
}

int main(){
  for(;;){
    cin >> p[0][0];
    if(p[0][0]>4)break;

    cin >> p[0][1];
    for(int i=1;i<4;i++)cin >> p[i][0] >> p[i][1];

    for(int i=0;i<4;i++)
      if(p[i][0]<0 && p[i][1]<0){p[i][0]*=-1; p[i][1]*=-1;}

    ans = 0;
    for(int i=0;i<4;i++)
      for(int j=0;j<4;j++)b[i][j] = false;
    rec(0);

    cout << ans << endl;
  }
}

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


#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const int MOD = 1e9 + 7;
 
int K;
string N;
ll dp[10005][2][5];
 
int main() {
    cin >> N >> K;
    int n = N.size();
 
    dp[0][0][0] = 1;
 
    REP(i, n) {
        REP(k, K + 1) {
            // i桁目まででNより小さいならi+1桁目は何でも良い
            dp[i + 1][1][k + 1] += dp[i][1][k] * 9;  // i+1桁目が0以外
            dp[i + 1][1][k] += dp[i][1][k];          // i+1桁目が0
 
            int ni = (N[i] - '0');
 
            // i桁目までNと同じで、i+1桁目はNより小さい数の時
            if (ni > 0) {
                dp[i + 1][1][k + 1] += dp[i][0][k] * (ni - 1);  // i+1桁目が0以外
                dp[i + 1][1][k] += dp[i][0][k];                 // i+1桁目が0
            }
 
            //  i桁目までNと同じで、i+1桁目もNと同じ数の時
            if (ni > 0) {
                dp[i + 1][0][k + 1] = dp[i][0][k];  // i+1桁目が0以外
            } else {
                dp[i + 1][0][k] = dp[i][0][k];  // i+1桁目が0
            }
        }
    }
 
    cout << dp[n][0][K] + dp[n][1][K] << endl;
 
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    replicateM_ n $ do
        [a,b,c,d] <- map read.words <$> getLine :: IO [Integer]
        putStrLn.bool"No""Yes"$solve a b c d

solve x0 cost c gain
    | x0 < cost = False
    | gain < cost = False
    | cost <= th = True
    | x1 >= th = False
    | otherwise = ((cost - x1 + g - 1) `div` g - 1) * g + x1 < th
  where
    th = c + 1
    g = gcd cost gain
    x1 = mod x0 cost


Measured memory_bytes: 1020
def main():
    n = int(input())
    x = list(map(int, input().split()))
    l = int(input())
    q = int(input())
    ab = [list(map(lambda x:int(x)-1, input().split())) for _ in [0]*q]
    doubling = [[] for _ in [0]*n]
    j = 0
    for i in range(n):
        while j < n:
            if x[j]-x[i] > l:
                doubling[i].append(j-1)
                break
            else:
                j += 1
    for i in range(n-1, -1, -1):
        if not doubling[i]:
            doubling[i].append(n-1)
        else:
            break
    for _ in range(16):
        for i in range(n):
            doubling[i].append(doubling[doubling[i][-1]][-1])
    for a, b in ab:
        if a > b:
            a, b = b, a
        ans = 0
        j = 16
        while j >= 0:
            if doubling[a][j] >= b:
                j -= 1
            else:
                a = doubling[a][j]
                ans += 2**j
        if a == b:
            print(ans)
        else:
            print(ans+1)


main()


Measured memory_bytes: 63480
#include <iostream>
#include <vector>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


Int gcd(Int a, Int b){
    Int p, q, r, s;
    p = a > b ? a : b;
    q = a > b ? b : a;
    while(true){
        //cout << p << " " << q << " " << s << " " << r << endl;
        s = p/q;
        r = p%q;
        if(r==0){
            break;
        }else{
            p = q;
            q = r;
        }
    }
    return q;
}

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

    Int n, tmpi;
    vector<Int> a;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmpi;
        a.push_back(tmpi);
    }

    Int l[100001], r[100001];
    l[0] = a[0];
    r[n-1] = a[n-1];

    for(int i=1; i<n-1; i++){
        l[i] = gcd(l[i-1], a[i]);
    }
    for(Int i=n-2; i>=1; i--){
        r[i] = gcd(r[i+1], a[i]);
    }
    Int max = 0;
    for(int i=0; i<n; i++){
        Int m = 0;
        if(i==0){
            m = r[1];
        }else if(i==n-1){
            m = l[n-2];
        }else{
            m = gcd(l[i-1], r[i+1]);
        }
        max = m > max ? m : max;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 2676
#include<stdio.h>

void set_data(int data[], int n){
    for(int i = 0; i < n; i++){
        scanf("%d", &data[i]);
    }
}

void set_data2(int data[][3], int n){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &data[i][j]);
        }
    }
}

int min(int data[], int n){
    int min = data[0];
    for(int i = 0; i < n; i++){
        if(min > data[i]){
            min = data[i];
        }
    }
    return min;
}

int main(void){
    int a, b, m;
    scanf("%d""%d""%d", &a, &b, &m);
    int data_a[a], data_b[b], data[m][3];
    set_data(data_a, a);
    set_data(data_b, b);
    set_data2(data, m);

    int min1 = data_a[data[0][0] - 1] + data_b[data[0][1] - 1] - data[0][2];
    int min2 = min(data_a, a) + min(data_b, b), ans;
    for(int i = 0; i < m; i++){
        if(min1> data_a[data[i][0] - 1] + data_b[data[i][1] - 1] - data[i][2]){
            min1 = data_a[data[i][0] - 1] + data_b[data[i][1] - 1] - data[i][2];
        }
    }
    if(min1 > min2){
        ans = min2;
    }else{
        ans = min1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.buffer.readline

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [AB[i][0] for i in range(N)]
B = [AB[i][1] for i in range(N)]

ans = 0
for i in reversed(range(N)):
    ans += (-(-(A[i]+ans)//B[i]) * B[i]) - (A[i] + ans)

print(ans)

Measured memory_bytes: 29112
M,K= map(int,input().split())

if K >= 2**M:
    print(-1)
    exit()

if M == 0:
    print("0 0")
    exit()

if M == 1:
    if K == 0:
        print("0 0 1 1")
    if K == 1:
        print(-1)
    exit()

left = [i for i in range(2**M) if not i == K]

ans = left + [K] + left[::-1] + [K]

print(*ans)




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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    
    vector<int> ans(n + 1);
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (i <= x && j <= y){
                ans[min(j - i, x - i + 1 + y - j)] += 1;
            }
            else if (i <= x && j > y){
                ans[x - i + j - y + 1] += 1;
            }
            else if (i >= x && j <= y){
                ans[min(j - i, i - x + y - j + 1)] += 1;
            }
            else if (i >= x && j > y){
                ans[min(j - i, i - x + j - y + 1)] += 1;
            }
        }
    }

    for (int i = 1; i < n; i++)
        cout << ans[i] << '\n';

    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int H[105];
ll mo=1000000007;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

pair<ll,ll> hoge(int L,int R,int v) {
	ll dp1=1,dp2=1;
	int i;
	
	if(L>R) return {-1,1};
	
	int mi=1<<30;
	for(i=L;i<=R;i++) mi=min(mi,H[i]);
	int W=R-L+1;
	for(i=L;i<=R;i++) if(mi!=H[i]) W--;
	
	int pre=L-1;
	for(i=L;i<=R;i++) {
		if(mi==H[i]) {
			auto r=hoge(pre+1,i-1,mi);
			if(r.first>=0) {
				(dp1*=r.first)%=mo;
				(dp2*=r.first+r.second)%=mo;
			}
			
			pre=i;
		}
	}
	auto r=hoge(pre+1,R,mi);
	if(r.first>=0) {
		(dp1*=r.first)%=mo;
		(dp2*=r.first+r.second)%=mo;
	}
	
	(dp2=dp2*modpow(2,W)+(modpow(2,mi-v)+mo-2)*dp1)%=mo;
	(dp1*=modpow(2,mi-v))%=mo;
	
	return {dp1,dp2};
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(i=1;i<=N;i++) cin>>H[i];
	cout<<hoge(1,N,0).second<<endl;
	return;
	
	ll ret=1;
	FOR(j,1001) {
		FOR(i,N+1) if(H[i]==1) (ret*=2)%=mo, H[i]=0;
		for(i=1;i<N+1;i++) {
			if(H[i]>max(H[i-1],H[i+1])) {
				(ret*=modpow(2,H[i]-max(H[i-1],H[i+1])))%=mo;
				H[i]=max(H[i-1],H[i+1]);
			}
		}
	}	
	
	for(i=1;i<=N;i++) if(H[i]) {
		j=i;
		while(H[j]) j++;
		(ret*=hoge(i,j-1,0).second)%=mo;
		i=j;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int dp[105][105];
    for(int i = 0; i < 105; i++)for(int j = 0; j < 105; j++) dp[i][j] = 1e9;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        for(int j = a-1; j <= b; j++)dp[a-1][j] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 0; i+j <= n; j++){
            for(int k = j; k <= j+i; k++){
                dp[j][j+i] = min(dp[j][j+i], dp[j][k] + dp[k][j+i]);
            }
        }
    }
    if(dp[0][n] == 1e9) cout << "Impossible" << endl;
    else cout << dp[0][n] << endl;
}



Measured memory_bytes: 3128
#include<stdio.h>
int main()
{
  int N,i,s,num,sum;
  scanf("%d",&N);
  sum=0;
  s=0;
  for(i=1;i<=N;i++){
    scanf("%d ",&num);
    s=s+sum*num;
    sum+=num;
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if (h - r < y){
    cout << "No\n";
    return 0;
  }
  if (w - r < x){
    cout << "No\n";
    return 0;
  }
  if (y < r){
    cout << "No\n";
    return 0;
  }
  if (x < r){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 3088
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
set_s = set(s)
lists = []
lists.append(int(c["AC"]))
lists.append(int(c["WA"]))
lists.append(int(c["TLE"]))
lists.append(int(c["RE"]))
print("AC x " + str(lists[0]))
print("WA x " + str(lists[1]))
print("TLE x " + str(lists[2]))
print("RE x " + str(lists[3]))

Measured memory_bytes: 16612
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main(){
  int a,b,c,d;
  cin >> a >>b >>c >>d;
  if(a+b<c+d){cout << "Right" << endl;}else if(a+b==c+d){cout << "Balanced" << endl;}else{cout << "Left" << endl;}
}

Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    card = [input() for _ in range(3)]
    idx = [0] * 3
    now = 0
    ans = None
    while True:
        if idx[now] >= len(card[now]):
            ans = chr(now + 65)
            break
        idx[now] += 1
        now = ord(card[now][idx[now] - 1]) - ord('a')
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint X,Y;
	cin >> X >> Y;
	if (X * 2 <= Y && Y <= X * 4 && Y % 2 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

const int N = 4000, mod = 998244353;
long long dp[N][N], p[N];

long long C(int n, int m) {
  if (n < m) return 0;
  return dp[n][m];
}

long long H(int n, int m) {
  if (m < 0) return 0;
  return C(n + m - 1, m);
}

int main() {
  int k, n;
  cin >> k >> n;
  p[0] = 1;
  for (int i = 1; i < N; i++) {
    p[i] = p[i - 1] * 2 % mod;
  }
  for (int i = 0; i < N; i++) {
    dp[i][0] = dp[i][i] = 1;
    for (int j = 1; j < i; j++) {
      dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
    }
  }

  for (int sum = 2; sum <= 2 * k; sum++) {
    int num = 0;
    for (int i = 1, j = sum - 1; i < j; i++, j--) {
      if (j <= k) num++;
    }

    long long res = 0;
    if (sum & 1) {
      for (int i = 0; i <= num; i++) { // choose i in num
        res += C(num, i) * p[i] % mod * H(k + i - 2 * num, n - i);
        res %= mod;
      }
    }
    else {
      // choose zero of sum / 2
      for (int i = 0; i <= num; i++) {
        res += C(num, i) * p[i] % mod * H(k - 2 * num - 1 + i, n - i);
        res %= mod;
      }
      // choose one of sum / 2
      for (int i = 0; i <= num; i++) {
        res += C(num, i) * p[i] % mod * H(k - 2 * num - 1 + i, n - i - 1);
        res %= mod;
      }
    }
    cout << (res + mod) % mod << "\n";
  }

  return 0;
}

Measured memory_bytes: 123520
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# s = input()

a, b = list(map(int, input().split()))

# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

ans = lcm(a, b)
print(ans)


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

int main(){
  
  int N, M;
  cin >> N >> M;
  
  vector<int> L(M);
  vector<int> R(M);
  
  for (int i=0;i<M;i++){
    int l,r;
    cin >> l >> r;
    L[i] = l;
    R[i] = r;
  }
  
  int Lmax = 0;
  for (int i=0;i<M;i++){
    Lmax = max(Lmax,L[i]);
  }
  
  int Rmin = N;
  for (int i=0;i<M;i++){
    Rmin = min(Rmin,R[i]);
  }
  
  cout << max(Rmin - Lmax + 1,0) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e5 + 5;
const int mod = 1e9 + 7;
int n, a[M], b[M], pw[M], ze;

pair <int, int> reduce(int x, int y)
{
	int g = __gcd(x, y);
	x /= g, y /= g;
	if(y < 0)
		x *= -1, y *= -1;
	if(x == 0)
		return {0, 1};
	if(y == 0)
		return {1, 0};
	return {x, y};
}

pair <int, int> opp(pair <int, int> p)
{
	return reduce(-p.second, p.first);
}
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	pw[0] = 1;
	for(int i = 1; i < M; i++)
		pw[i] = (2LL * pw[i - 1]) % mod;
	cin >> n;
	map <pair <int, int>, int> mp, vis;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
		if(a[i] == 0 && b[i] == 0)	ze++;
		else				mp[reduce(a[i], b[i])]++; 
	}
	int ans = 1;
	for(auto &i : mp)
	{
		if(vis.find(i.first) != vis.end())	continue;
		vis[i.first] = 1;
		pair <int, int> p = opp(i.first);
		vis[p] = 1;
		int cur = pw[i.second] + pw[mp[p]] - 1;
		ans = (ans * cur + mod) % mod;
	}
	ans = (ans + ze + mod - 1) % mod;
	cout << ans;
    	return 0;
}

Measured memory_bytes: 58324
#include <set>
#include <string>
#include <iostream>
using namespace std;
int val[14][8222], cal[22], ev[22], dp[10][109], mod = 998244353;
int solve(string s, int d) {
	if (s.size() <= 12) {
		int bit = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '1') bit |= 1 << i;
		}
		return val[s.size()][bit];
	}
	int m = s.size();
	// depth will be at most 3, so it will pass :)
	dp[d][0] = 1;
	for (int i = 1; i <= m; i++) {
		dp[d][i] = dp[d][i - 1] * (s[i - 1] == '1' ? 2 : 1);
		if (dp[d][i] >= mod) dp[d][i] -= mod;
		for (int j = 0; j < i; j++) {
			string t = s.substr(j, i - j);
			for (int k = 2; k <= i - j; k++) {
				if ((i - j) % k != 0) continue;
				int iv = (i - j) / k;
				string u = string(iv, '1');
				for (int l = 0; l < i - j; l++) {
					if (s[l + j] == '0') u[l % iv] = '0';
				}
				dp[d][i] = (dp[d][i] + 1LL * dp[d][j] * solve(u, d + 1)) % mod;
			}
		}
	}
	return dp[d][m];
}
int main() {
	for (int i = 0; i <= 12; i++) {
		for (int j = 0; j < 1 << i; j++) {
			cal[0] = 1;
			for (int k = 1; k <= i; k++) {
				cal[k] = cal[k - 1];
				for (int l = 0; l < k; l++) {
					int sub = (j >> l) & ((1 << (k - l)) - 1);
					for (int m = 2; m <= k - l; m++) {
						if ((k - l) % m != 0) continue;
						int iv = (k - l) / m;
						for (int z = 0; z < k - l; z += iv) {
							ev[z / iv] = (sub >> z) & ((1 << iv) - 1);
						}
						bool f = true;
						for (int z = 1; z < m; z++) {
							if (ev[z] != ev[z - 1]) f = false;
						}
						if (f) {
							cal[k] = (cal[k] + 1LL * cal[l] * val[iv][ev[0]]) % mod;
						}
					}
				}
			}
			val[i][j] = cal[i];
		}
	}
	for (int i = 0; i <= 12; i++) {
		for (int j = 0; j < i; j++) {
			for (int k = 0; k < 1 << i; k++) {
				if ((k >> j) & 1) {
					val[i][k] += val[i][k - (1 << j)];
					if (val[i][k] >= mod) val[i][k] -= mod;
				}
			}
		}
	}
	string s; cin >> s;
	int ret = solve(s, 0);
	cout << ret << endl;
	return 0;
}

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

int dp[200010];
int last[200010], CCC[200010];
int nxt[26];

int main () {
	string s; cin >> s;
	int n = s.size();
	for (int i = 0; i < 26; i++) {
		nxt[i] = n;
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[n] = 1, dp[n + 1] = 0;
	for (int i = n - 1; i >= 0; i--) {
		nxt[s[i] - 'a'] = i;
		for (int j = 0; j < 26; j++) {
			if (dp[i] > dp[nxt[j] + 1] + 1) {
				dp[i] = dp[nxt[j] + 1] + 1;
				last[i] = nxt[j] + 1, CCC[i] = j;
			}
		}
	}
	int now = 0;
	while (now < n) {
		printf("%c", char(CCC[now] + 'a'));
		now = last[now];
	}
	printf("\n");
	return 0;
}


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

int n,m,arr[55];

int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    arr[a]++;
    arr[b]++;
  }
  for(int i=1;i<=n;i++){
    printf("%d\n",arr[i]);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,a=0,b=0,ans=1,aa=0,bb=0;
bool acan[100010],bcan[100010];

signed main(){
   cin>>n;
   vint amax(n),bmax(n),c(n);
   rep(i,0,n){
       cin>>a;
       amax[i]=a;
       aa=max(a,aa);
   }
   rep(i,0,n){
       cin>>b;
       bmax[i]=b;
       bb=max(b,bb);
   }
   sort(bmax.begin(),bmax.end());
   //rep(i,0,n)cout<<bmax[i]<<endl;
   if(aa!=bb){
       puts("0");
       return 0;
   }
   
   rep(i,0,n)c[i]=-1;
   c[0]=amax[0];c[n-1]=bmax[0];
   rep(i,1,n){
       if(amax[i]>amax[i-1]){
           if(c[i]>=0&&c[i]!=amax[i]){
               puts("0");
               return 0;
           }
           c[i]=amax[i];
       }
   }
   rep(i,1,n){
       if(bmax[i]>bmax[i-1]){
           //cout<<c[i]<<" "<<bmax[i]<<endl;
           if(c[n-1-i]>=0&&c[n-1-i]!=bmax[i]){
               puts("0");
               return 0;
           }
           c[n-1-i]=bmax[i];
       }
   }
   int MAX=1;
   rep(i,0,n){
       if(i==0){
           acan[i]=bcan[i]=true;
           MAX=amax[0];
       }
       else{
           if(amax[i]>amax[i-1]){
               acan[i]=true;
               MAX=amax[i];
           }
           if(bmax[i]>bmax[i-1]){
               bcan[i]=true;
               MAX=bmax[i];
           }
       }
   }
   //rep(i,0,n)cout<<c[i]<<endl;
   rep(i,0,n){
       //cout<<amax[i]<<" "<<bmax[n-1-i]<<endl;
       if(c[i]==-1){
           ans*=min(amax[i],bmax[n-1-i]);
           ans%=MOD;
       }else if(c[i]>min(amax[i],bmax[n-1-i])){
           puts("0");
           return 0;
       }
   }
   cout<<ans<<endl;
   return 0;
}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int n;
    cin >> n;
    vi a(n);
    int x = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for(int i=0; i<n; i++) {
        cout << (x^a[i]) << " ";
    }
    cout << "\n";
    return 0;
}



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

using namespace std;
int n;
vector<int> graph[20001];
vector<int> vis(20001,0);
vector<int> dis(20001,0);
vector<int> ans(2001);
void bfs(int node){
queue<int> q;
q.push(node);
vis[node]=1;
while(!q.empty()){
    int node1 =q.front();
    q.pop();
    for(int child:graph[node1]){
        if(vis[child]==0){
        q.push(child);
        vis[child]=1;
        dis[child]=dis[node1]+1;
        ans[dis[child]]++;
        }
    }
}
}

int main(){    
  int x,y;
  cin >> n >> x >> y;
  for(int i=1;i<n;i++){
      graph[i].push_back(i+1);
      graph[i+1].push_back(i);
  }
  graph[x].push_back(y);
  graph[y].push_back(x);
  for(int i=1;i<=n;i++){
    for(int j=0;j<20001;j++)vis[j]=0,dis[i]=0;
    bfs(i);
  }
  for(int i=1;i<n;i++)
  cout << ans[i]/2 <<'\n';
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
  class Problem0036
  {
    public static void Main(string[] args)
    {
      foreach (var field in Read())
      {
        int origX = 0, origY = 0;
        var origFound = false;
        foreach (var row in Enumerable.Range(0, 8))
        {
          foreach (var col in Enumerable.Range(0, 8))
          {
            if (field[row][col])
            {
              origX = col;
              origY = row;
              origFound = true;
              break;
            }
          }
          if (origFound)
            break;
        }

        var predicates = new List<Func<bool[][], int, int, bool>> {
          (f, x, y) => y <= 6 && x <= 6 && f[y][x + 1] && f[y + 1][x] && f[y + 1][x + 1],
          (f, x, y) => y <= 4 && f[y + 1][x] && f[y + 2][x] && f[y + 3][x],
          (f, x, y) => x <= 4 && f[y][x + 1] && f[y][x + 2] && f[y][x + 3],
          (f, x, y) => 0 < x && y <= 5 && f[y + 1][x - 1] && f[y + 1][x] && f[y + 2][x - 1],
          (f, x, y) => x <= 5 && y <= 6 && f[y][x + 1] && f[y + 1][x + 1] && f[y + 1][x + 2],
          (f, x, y) => x <= 6 && y <= 5 && f[y + 1][x] && f[y + 1][x + 1] && f[y + 2][x + 1],
          (f, x, y) => 0 < x && x < 7 && y <= 6 && f[y][x + 1] && f[y + 1][x] && f[y + 1][x - 1]
        };
        foreach (var vi in predicates.Select((p, i) => new {Predicate = p, Index = i}))
        {
          if (vi.Predicate(field, origX, origY))
          {
            Console.WriteLine(((char)('A' + vi.Index)).ToString());
            break;
          }
        }
      }
    }

    public static IEnumerable<bool[][]> Read()
    {
      foreach (var t in ReadLine().Slice(8))
        yield return t;
    }

    public static IEnumerable<bool[]> ReadLine()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
      {
        if (line == "")
          continue;
        yield return line.Select(c => c == '0' ? false : true).ToArray();
      }
    }
  }

  static class EnumerableEx
  {
    public static IEnumerable<T[]> Slice<T>(this IEnumerable<T> source, int count)
    {
      return Slice<T, T[]>(source, count, x => x.ToArray());
    }

    public static IEnumerable<TResult> Slice<TSource, TResult>(this IEnumerable<TSource> source, int count, Func<IEnumerable<TSource>, TResult> selector)
    {
      var result = new List<TSource>(count);
      foreach (var v in source)
      {
        result.Add(v);
        if (result.Count == count)
        {
          yield return selector(result);
          result.Clear();
        }
      }
      if (result.Any())
        yield return selector(result);
    }
  }
}

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

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    char a;
    cin >> a;
    if(a >= 'A' and a <= 'Z') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3660
n = int(input())

n_list = [0]*50000
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            if x+y+z >= 150:
                break
            index = x*x + y*y + z*z + x*y + y*z + z*x
            n_list[index] = n_list[index]+1

for i in range(1,n+1):
    print(n_list[i])

Measured memory_bytes: 69360
#include <stdio.h>

int main(void)
{
    int n;
    

    scanf("%d", &n);

    int a[n];

    for (int i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    
    int max=0;
    int dif=0;
    for (int i=0; i<n-1; i++)
    {
        for (int j=i+1; j<n; j++)
        {
            dif = (a[i] > a[j]) ? a[i] - a[j] : a[j] - a[i];
            max = (dif > max) ? dif : max;
        }
    }

    printf("%d\n", max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<char>> fi(H, vector<char>(W));
    vector<vector<bool>> used(H, vector<bool>(W));

    int ans = H * W;
    REP(i,H) REP(j,W){
        cin >> fi[i][j];
        if(fi[i][j] == '#') ans--;
    }
    
    queue<tuple<int, int,int>> q;
    q.emplace(1, 0, 0);
    while(!q.empty()){
        int h, w, dist;
        tie(dist, h, w) = q.front();
        q.pop();
        if(h == H-1 && w == W-1){
            cout << ans - dist << endl;
            return 0;
        }
        if(used[h][w]) continue;
        used[h][w] = true;
        REP(i,4){
            int nh = h + dx[i], nw = w + dy[i];
            if(nh < 0 || nh >= H || nw < 0 || nw >= W || used[nh][nw] || fi[nh][nw] == '#') continue;
            q.emplace(dist + 1, nh, nw);
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll a[n],b[n],c[n];
    f(i,0,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    f(i,1,n){
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(a[i-1],c[i-1]);
        c[i]+=max(a[i-1],b[i-1]);
    }
    cout<<max({a[n-1],b[n-1],c[n-1]});
    return 0;
}   


Measured memory_bytes: 2560
class Tree:
    def __init__(self, *args):
        self.value, self.left, self.right = args

    def postorder(self):
        left = [] if self.left is None else self.left.postorder()
        right = [] if self.right is None else self.right.postorder()
        return left + right + [self.value]


def recover(pre, ino):
    preord = dict(map(lambda t: (t[1], t[0]), enumerate(pre)))

    def make_tree(tree):
        if len(tree) == 0:
            return None
        root_idx, root_value = min(enumerate(tree), key=lambda t: preord[t[1]])
        return Tree(
            root_value,
            make_tree(tree[:root_idx]),
            make_tree(tree[root_idx + 1:])
        )

    return make_tree(ino).postorder()


if __name__ == '__main__':
    _ = input()
    pre = list(map(int, input().split()))
    ino = list(map(int, input().split()))
    print(' '.join([str(t) for t in recover(pre, ino)]))


Measured memory_bytes: 5616
// A - Two Abbreviations
#include <stdio.h>
#include <string.h>
#define MAXSIZE 100000
typedef long long int ll;

ll get_gcd(ll a, ll b);

int main(void){
    char s[MAXSIZE+1], t[MAXSIZE+1];
    ll n, m;
    scanf("%d %d %s %s", &n, &m, s, t);

    ll lcm_length = n * m / get_gcd(n, m);
    //printf("lcm_length = %lld\n", lcm_length);
    int success_flag = 9;
    if(n == m){
        //printf("gcd_length = 1\n");
        success_flag = (strcmp(s, t) == 0);
    }else{
        if(n > m){
            char tmp_s[MAXSIZE + 1];
            strcpy(tmp_s, s);
            strcpy(s, t);
            strcpy(t, tmp_s);

            n = strlen(s);
            m = strlen(t);
        }

        //printf("s: %s, t: %s\n", s, t);
        if(lcm_length == n * m){
            //printf("TAGAINISO\n");
            success_flag = (s[0] == t[0]);
        }else{
            //printf("GCD = %lld > 1\n", get_gcd(n, m));
            ll delta_m = lcm_length / m;
            ll delta_n = lcm_length / n;
            ll index_m = 0, index_n = 0;
            while(index_n < lcm_length){
                //printf("index_n = %lld, index_m = %lld\n", index_n, index_m);
                //printf("index_n / delta_n = %lld index_m / delta_m = %lld\n", index_n / delta_n, index_m / delta_m);
                if(index_m == index_n){
                    if(t[index_m / delta_m] != s[index_n / delta_n]){
                        success_flag = 0;
                        break;
                    }
                }

                if(index_n == index_m){
                    index_n += delta_n;
                }else if(index_n > index_m){
                    index_m += delta_m;
                }else{
                    index_n += delta_n;
                }
            }
            
            success_flag = (success_flag == 9);
        }
    }
    printf("%lld\n", (success_flag)? lcm_length : -1);
    return 0;
}

ll get_gcd(ll a, ll b){
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }

    if(a % b == 0) return b;
    return get_gcd(b, a % b);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Hoge {
	int mode;
	bool maxfunc;
	Hoge* left;
	Hoge* right;
	string num;
	Hoge() : mode(0) {}
	bool read(char c) {
		switch (mode) {
			case 0:
				if (c == '^') {
					mode = 100;
					maxfunc = true;
					left = new Hoge;
					right = new Hoge;
				} else if (c == '_') {
					mode = 100;
					maxfunc = false;
					left = new Hoge;
					right = new Hoge;
				} else {
					mode = 1;
					num += c;
					if (c == '0') mode = 2;
				}
				return true;
			case 1:
				if (c == '?') {
					mode = 2;
					return true;
				}
				if ('0' <= c && c <= '9') {
					num += c;
					mode = 2;
					return true;
				} else {
					mode = 2;
				}
				return false;
			case 2:
				return false;
			case 100:
				if (c != '(') throw 1;
				mode = 101;
				return true;
			case 101:
				if (left->read(c)) return true;
				if (c == ',') { mode = 102; return true; }
				throw 1;
			case 102:
				if (right->read(c)) return true;
				if (c == ')') { mode = 103; return true; }
				throw 1;
			case 103:
				return false;
		}
	}
	int ma() {
		switch (mode) {
			case 0: return 99;
			case 1: return (num[0]-'0') * 10 + 9;
			case 2:
				if (num.length() == 1) return num[0]-'0';
				else return (num[0]-'0') * 10 + (num[1]-'0');
			case 100: return 99;
			case 101:
			case 102:
			case 103:
				if (maxfunc) return max(left->ma(), right->ma());
				else return min(left->ma(), right->ma());
		}
		throw 1;
	}
	int mi() {
		switch (mode) {
			case 0: return 0;
			case 1: return num[0]-'0';
			case 2:
				if (num.length() == 1) return num[0]-'0';
				else return (num[0]-'0') * 10 + (num[1]-'0');
			case 100: return 0;
			case 101:
			case 102:
			case 103:
				if (maxfunc) return max(left->mi(), right->mi());
				else return min(left->mi(), right->mi());
		}
		throw 1;
	}
};
int main() {
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++ i) {
		Hoge hoge;
		string s;
		cin >> s;
		for (int i = 0; i < s.length(); ++ i) {
			hoge.read(s[i]);
			int ma = hoge.ma(), mi = hoge.mi();
			//cout << i+1 << " " << mi << " " << ma << endl;
			if (ma == mi) {
				cout << ma << " " << i+1 << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 4992
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
s = 0
for i in range(len(a) - 1):
  s += abs(a[i+1] - a[i])

for i in range(1, len(a) - 1):
  print(s + abs(a[i-1] - a[i+1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])))

Measured memory_bytes: 14048
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws  Exception{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (isBlandrome(i))
                count++;
        }
        System.out.println(count);
    }

    public static boolean isBlandrome(int n){
        int copy = n;

        int newN = 0;

        while (n > 9){
            newN = newN * 10 + (n % 10);
            n /= 10;
        }

        if (n > 0){
            newN = newN * 10 + (n % 10);
        }

        return  newN == copy;
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 60
#define MAX_V MAX_N

struct edge{ int to, cost; };
typedef pair<int, int> P;   // first は最短距離、 second は頂点の番号

int V;
vector<edge> G[MAX_V];      // ノード i からのびている edge の vector 。ダイクストラ前に自分で入力する
int d[MAX_V];
int prev_p[MAX_V];  // 経路も求める場合は必要

pair<int, int> neg;

// 始点 s から各頂点への最短距離を求める
void dijkstra(int s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    //fill(prev_p, prev_p + V, -1); // 経路を求めるなら有効
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first){ continue; }
        REP(i, G[v].size()) {
            edge e = G[v][i];
            if( (v == neg.first && e.to == neg.second) ||
                (e.to == neg.first && v == neg.second) ) { continue; }
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                prev_p[e.to] = v;   // 経路も求めるなら有効
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int N, M;
vector< pair<int, int> > AB;

int main()
{
    cin >> N >> M;
    V = N;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge e;
        e.to = b;
        e.cost = 1;
        G[a].push_back(e);
        e.to = a;
        G[b].push_back(e);

        AB.push_back(make_pair(a, b));
    }
    int ans = 0;
    for(auto p : AB) {
        neg = p;
        dijkstra(0);
        bool isINF = false;
        REP(i, N) {
            if(d[i] >= INF) {
                isINF = true;
                break;
            }
        }
        if(isINF) { ans++; }
    }
    printf("%d\n", ans);
    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>;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int t =0,k=0;
  while(c>0){
    c -=b;
    t++;
  }
  while(a>0){
    a -= d;
    k++;
  }
  if(t<=k)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n;

int main() {

	FAST;

	cin >> n;
	string s;
	cin >> s;
	s = " " + s;
	int cntR = 0;
	for (int i = 1; i <= n; i ++) {
		if (s[i] == 'R') cntR ++;
	}
	int ans = 0;
	for (int i = 1; i <= cntR; i ++) {
		if (s[i] == 'W') ans ++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
vector<int>G[500];
signed main() {
	int n; cin >> n;
	for (int i = 1; i <= 449; i++) {
		int x = i*(i + 1) / 2;
		int cnt = 1;
		if (n == x) {
			cout << "Yes" << endl;
			rep(j, i+1) {
				for (int k = j + 1; k < i+1; k++) {
					G[j].push_back(cnt);
					G[k].push_back(cnt);
					cnt++;
				}
			}

			cout << i + 1 << endl;
			rep(j, i + 1) {
				cout << G[j].size();
				rep(k, G[j].size()) {
					cout << ' ' << G[j][k];
				}
				cout << endl;
			}
			return 0;
		}
	}
	cout << "No" << endl;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int A,B,C,D,N;

int main(){
	cin>>A>>B>>C>>D>>N;
	B=min(B,A<<1);
	C=min(C,B<<1);
	D=min(D,C<<1);
	ll ans=1LL*(N/2)*D;N&=1;
	ans+=N*C;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=2e6+9;
const ll mod = 1e9+7;
map<ll,ll>m;
void slv()
{
}
ll pre[N];
int main()
{
    string s,t;
    cin >> s >> t;
    int ans=0;
    int n1=s.size();
    int n2=t.size();
    for(int i=0;i<=(n1-n2);i++) {
        int cnt=0;
        for(int j=i,k=0;k<n2;j++,k++) {
            if(t[k] == s[j]) cnt ++;
        }
        ans=max(ans,cnt);
    }
    cout<<n2-ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main() {
  
  	ll X;
  	cin >> X;
  	ll money=100;
  	for(ll i=1; i<= pow(10, 18); i++){
    	money*=1.01;
      	if(money >= X){
          	cout << i << endl;
          	break;
        }
    }
	
}

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


def solve(K: int):
    arr = [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]
    print(arr[K-1])
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060