akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
map<char, int> mc;
inline void bubbleSort(vs& a, int n) {
	rep(i, 0, n) {
		rrep(j, n - 1, i) {
			if(a[j][1] < a[j - 1][1]) {
				swap(a[j], a[j - 1]);
			}
		}
	}
}
inline void selectionSort(vs& a, int n) {
	rep(i, 0, n - 1) {
		int minj = i;
		rep(j, i, n) {
			if(a[j][1] < a[minj][1]) minj = j;
		}
		if(i != minj) {
			swap(a[i], a[minj]);
		}
	}
}
int main() {
	rep(i, 0, 4) mc["SHCD"[i]] = i;
	int n; cin >> n;
	vs v1(n); rep(i, 0, n) cin >> v1[i];
	vs v2(v1);
	bubbleSort(v1, n);
	rep(i, 0, n) cout << v1[i] << (i + 1 == n ? "\n" : " ");
	P("Stable");
	selectionSort(v2, n);
	rep(i, 0, n) cout << v2[i] << (i + 1 == n ? "\n" : " ");
	P(v1 == v2 ? "Stable" : "Not stable");
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
#define MOD 1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

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

    int ans = 0;
    int cnt = 0;
    for (int i = 1; cnt < x; i++)
    {
        cnt += i;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0); 
	int n , k;
	cin>>n>>k ;
	string s ;
	cin>>s ;
	char prv = s[0] ;
	bool t = false ;
	for(int i = 1 ; i < n ; ++i)
	{
		if(s[i] != prv)
		{
			if(t == true)
				t = false ;
		}
		if(s[i] == prv && t)
		{
			if(prv == 'L')
				s[i] = 'R' ;
			else
				s[i] = 'L' ;
		}
		if(s[i] != s[i-1])
		{
			if(k > 0)
			{
				prv = s[i] ;
				s[i] = s[i-1] ;
				--k ;
				t = true ;
			}
		}
	}
	if(n > 1 && k > 0 && s[0] != s[1])
	{
		s[0] = s[1] ;
		--k ;
	}
	int ans = 0 ;
	for(int i = 0 ; i <n-1 ; ++i)
	{
		if(s[i] == s[i+1])
			ans++ ;
	}
	return cout<<ans<<"\n" , 0 ;
}

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

using namespace std;

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

    stack<int> st1;
    stack<pair<int, int> > st2;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '\\') st1.push(i);//'\'をスタックに積む
        else if (s[i] == '/' && !st1.empty()) {//'/'にあたったら'\'を取り出す
            int j = st1.top();
            st1.pop();
            int a = i - j;// '\'と'/'とその間の'_'でできる図形の面積
            while (!st2.empty() && st2.top().first > j) {
                a += st2.top().second;
                st2.pop();
            }
            st2.push(make_pair(j, a));//起点になる'\'と対応する面積を記録
        }
    }

    vector<int> ans;
    while (!st2.empty()) {
        ans.emplace_back(st2.top().second);
        st2.pop();
    }
    reverse(ans.begin(), ans.end());

    cout << accumulate(ans.begin(), ans.end(), 0) << endl;
    cout << ans.size();

    for (auto x:ans) {
        cout << " " << x;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3304
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    char hoge;
    int a,b;
    vector<pii>v;
    while(cin>>a>>hoge>>b, a+b)
        v.push_back(pii(b,a));
    sort(all(v),greater<pii>());
    int rank[10000];
    int maxi=v[0].first;
    rank[0]=1;
    int now=1;
    for(int i=1; i<v.size(); i++){
        if(v[i].first==maxi){
            rank[i]=now;
        }else{
            maxi=v[i].first;
            now++;
            rank[i]=now;
        }
    }
    int n;
    while(cin>>n){
        for(int i=0; i<v.size();i++){
            if(n==v[i].second){
                cout<<rank[i]<<endl;
            }
        }
    }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    string S;cin>>S;
    if(S[0]==S[N-1]){
        cout<<N<<endl;
    }else if(S[0]=='>'&&S[N-1]=='<'){
        cout<<N<<endl;
    }else{
        int cnt=0,cnt2=0;
        for(int i=0;i<N;i++){
            if(S[i]=='<') cnt++;
            else break;
        }
        reverse(all(S));
        for(int i=0;i<N;i++){
            if(S[i]=='>') cnt2++;
            else break;
        }
        
        cout<<N-min(cnt,cnt2)<<endl;
    }
}




Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,i,ans = 0,j,x,y,k;
    cin>>n;
    ll a[n+5];
	for(i=1;i<=n;i++) cin>>a[i];
	ll check = 1;
    for(i=1;i<=n;i++){
    	if(a[i] != check) ans++;
    	else{
    		check++;
		}
	}
	if(ans == n) cout<<-1;
	else cout<<ans;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, m, c, ans = 0, next = 0, bulb = 0;
    string t;
    cin >> n >> m;
    vector<int> ks(m);
    vector<vector<int>> as(m);
    vector<int> ps(m);
    for (int i = 0; i < m; i++) {
        cin >> ks[i];
        for (int j = 0; j < ks[i]; j++) {
            cin >> c;
            c = c - 1;
            as[i].push_back(c);
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> ps[i];
    }
    // cout << "hoge" << endl;
    for (int b = 0; b < (1 << n); b++) {
        set<int> subset;
        next = 0;
        bulb = 0;
        map<int, int> cnt;
        for (int i = 0; i < n; i++) {
            if (b & (1 << i)) subset.insert(i);
        }
        for (int i = 0; i < m; i++) {
            next = 0;
            for (int j = 0; j < ks[i]; j++) {
                // cout << "hoge" << i << endl;
                next += subset.count(as[i][j]);
            }
            if (next % 2 == ps[i]) {
                bulb++;
            }
            // cout << "hoge" << " " << next << endl;
        }
        // cout << b << " " << bulb << endl;
        if (bulb == m) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
s_map = [[] for _ in range(26)]
import bisect
for i in range(len(s)):
    s_map[ord(s[i])-97].append(i)
for i in range(len(s)):
    s_map[ord(s[i])-97].append(len(s)+i)
cur = 0
count = 0
f = True
for c in t:
    if s_map[ord(c)-97] == []:
        f = False
        break
    np = bisect.bisect_left(s_map[ord(c)-97],cur)
    cur = s_map[ord(c)-97][np]+1
    
    if cur >= len(s):
        count += 1
        cur -= len(s)
print(count * len(s) + cur if f else -1)

Measured memory_bytes: 48928
a,b,c,d,e,f=map(int,input().split())

a *=100
b *=100
DP=[[0,0] for _ in range(f+3000)]
DP[a][0]=a
DP[b][0]=b

for i in range(f+1):
    if DP[i][0]==0:continue
    for j in a,b:
        if i+j<=f:
            if DP[i][1]*100/(i+j)>=DP[i+j][1]*100/(i+j):
                DP[i+j]=[i+j,DP[i][1]]
    for j in c,d:
        if i+j<=f:
            if 100*(DP[i][1]+j)/(i+j)<=100*e/(100+e):
                if 100*(DP[i][1]+j)/(i+j)>=100*(DP[i+j][1])/(i+j):
                    DP[i+j]=[i+j,DP[i][1]+j]

ans,water=0,[a,0]
for x,y in DP:
    if x==0:continue
    if 100*y/x>ans:
        ans=100*y/x
        water=[x,y]
print(*water)

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

struct Light {
    int k;
    std::vector<int> s;
};

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

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

    std::vector<Light> lights;
    for (int i = 0; i < M; i += 1) {
        int k;
        std::cin >> k;

        std::vector<int> s;
        for (int j = 0; j < k; j += 1) {
            int si;
            std::cin >> si;

            s.push_back(si - 1);
        }

        lights.push_back({k, s});
    }

    std::vector<int> p;
    for (int i = 0; i < M; i += 1) {
        int pi;
        std::cin >> pi;

        p.push_back(pi);
    }

    int count = 0;
    for (int i = 0; i < (1 << N); i += 1) {
        bool ok = true;
        for (int j = 0; j < M; j += 1) {
            int mask = 0;
            for (int k = 0; k < lights[j].k; k += 1) {
                mask += (1 << lights[j].s[k]);
            }
            if (bitCount(i & mask) % 2 != p[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            count += 1;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#define int long long
using namespace std;

int n, a[200002], pos[200001];
set<int> pastPos;

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	pastPos.insert(0);
	pastPos.insert(n + 1);
	
	int ans = 0;
	for (i = 1; i <= n; i++) {
		set<int>::iterator it = pastPos.upper_bound(pos[i]);
		int r = *it;
		int l = *(--it);
		ans += i * (pos[i] - l) * (r - pos[i]);
		pastPos.insert(pos[i]);
	}
	cout << ans << endl;
	return 0;
}

//minの値はN種類しかないので、min = iとなる区間がいくつあるかに注目する。
//a[0]=a[N+1]=-INFとおくと, [i未満]…i…[i未満] (…はi以上)となる[]の位置が分かれば, 求められることが分かる.
//たとえば、i=10について求める際には1,2,…,9の位置をset<int>かなにかに入れておき、10の位置も前処理で求めておけば、O(logN)で[]の位置が分かる.
//よって、i=1,2,…の順で求めていけば、O(NlogN)でこの問題は解ける。
//別解：
//lを固定したとき最小値がa[l]になるようなrは、a[R] < a[l]なる最小のR(R > l)をとったとき、R - l個あることが分かる。
//Rは区間最小を求める＋2分探索, またはRMQをするセグメントツリー上で2分探索することで、O(Nlog^2N)またはO(NlogN)でこの問題は解ける。
//(別解の方は、a_i = a_j (i≠j)があってもOK)

Measured memory_bytes: 12800
N = int(input())
A = list(map(int, input().split()))

L = [None] * N
R = [None] * N
for i in range(N):
    L[i] = i + 1 + A[i]
    R[i] = i + 1 - A[i]

dl = dict()
dr = dict()
for l in L:
    dl[l] = dl.get(l, 0) + 1
for r in R:
    dr[r] = dr.get(r, 0) + 1

cnt = 0
for k in dl.keys():
    cnt += dl.get(k, 0) * dr.get(k, 0)

print(cnt)

Measured memory_bytes: 62924
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
typedef long long ll;
int main() {
	int n = 0, x = 0;
	int nece = 0,nokori = 0;
	int count = 0;
	int func = 0,funct = 0;
	int max = 0;
	int mate[10000] = {};
	std::cin >> n >> x;
	for (int i = 0; i < n; i++) {
		std::cin >> mate[i];
		nece += mate[i];
		count++;
	}
	nokori = x - nece;
	func = nokori / mate[0];
	for (int i = 1; i < n; i++) {
		funct = nokori / mate[i];
		func = std::max(func, funct);
	}
	std::cout << count + func << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

int b[1000000];

void solve()
{
    IN(n);
    string s; cin >> s;
    ll a = 0;
    bool is = true;
    rep(i, n-1)
    {
        b[i] = abs(s[i+1] - s[i]);
        is = is && (b[i] != 1);
    }
    if (is)
    {
        rep(i, n-1) b[i] = b[i] == 2;
        rep(i, n-1)
        {
            if (((n-2)&i) == i) a ^= b[i];
        }
        cout << (a ? 2 : 0) << endl;
        return;
    }
    rep(i, n)
    {
        if (((n-1)&i) == i) a ^= (s[i] - '0') % 2;
    }
    cout << a << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 5276
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int diff = b - a;
    if (diff & 1)
        cout << "IMPOSSIBLE\n";
    else
       cout << a + diff / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main(){
    
    cout << fixed << setprecision(6);
    int n ;
    cin >> n;
    double ans ;
    if(n % 2 == 0){
        ans = 0.5;
    }
    else {
        int a = n / 2;
        ans = (double)(a + 1)/ n; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys


def bfs(xs, ys):
    queue = deque([[xs, ys]])
    M[xs][ys] = 0
    while queue:
        # queueには訪れた地点が入っている。そこから、4方向に移動できるか考え、queueから消す。
        x1, y1 = queue.popleft()  # queueに入っていたものを消す。
        if [x1, y1] == [xg, yg]:  # もしゴールについていたならば、そのときの手数を出す。
            return M[x1][y1]

        for dx, dy in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            for k in range(1, K + 1):
                new_x = x1 + dx * k
                new_y = y1 + dy * k

                if (0 <= new_x < H) and (0 <= new_y < W):
                    if m[new_x][new_y] == "@":
                        break
                    elif M[new_x][new_y] == -1:  # まだ来たことない点だったという条件
                        M[new_x][new_y] = M[x1][y1] + 1
                        queue.append([new_x, new_y])  # 新しい点を足す。
                    elif M[new_x][new_y] < M[x1][y1] + 1:
                        break
                else:
                    break


H, W, K = map(int, input().split())
# K = min(K, max(H, W))
xs, ys, xg, yg = map(int, input().split())
xs, ys, xg, yg = xs - 1, ys - 1, xg - 1, yg - 1

m = []
for i in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))

M = [[-1] * W for i in range(H)]

bfs(xs, ys)

print(M[xg][yg])


Measured memory_bytes: 45192
nN = int(input())
 
nList = []
 
nTmp = int(input())
nList.append(nTmp)
nAns = 1
 
if (nN > 1):  
  for i in range(nN - 1):
    nTmp = int(input())
      
    if nTmp not in nList:
      nList.append(nTmp)
      nAns += 1
    
print(nAns)


Measured memory_bytes: 2940
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
    
ans = float("inf")
li = make_divisors(n)
if li[-1]**2 == n:
    li.append(li[-1])

for i in range(len(li))[::2]:
    ans = min(ans, max(len(str(li[i])), len(str(li[i+1]))))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char s[100];
	bool ans=false;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='Y'){ans=true; break;}
	}
	if(ans==true){puts("Four");}
	else{puts("Three");}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <ios>
#include <iomanip>
#include <limits>
#include <algorithm>
#include <sstream>
#include <bitset>
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, s, n) for(int i=s; i<n; i++)

using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int W[N] = {};
    int E[N] = {};

    if (S[0] == 'W') W[0] = 1;
    else E[0] = 1;

    FOR(i, 1, N){
        if (S[i] == 'W'){
            W[i] = W[i-1] + 1;
            E[i] = E[i-1];
        }
        else{
            W[i] = W[i-1];
            E[i] = E[i-1] + 1;
        }
    }

    int minans = E[N-1];

    REP(i, N){
        minans = min(minans, W[i] + E[N-1] - E[i]);
    }

    cout << minans << endl;
}


Measured memory_bytes: 3076
function main()
  
  A = split(chomp(readline()),"")
  B = split(chomp(readline()),"")
  C = split(chomp(readline()),"")
  
  A = push!(A,"0")
  B = push!(B,"0")
  C = push!(C,"0")
  
  check = A[1]
  shift!(A)
  
  while !(A == [] || B == [] || C == [])

    if check == "a"
      
      check = A[1]
      if check == "0"
        println("A")
        break
      end
      shift!(A)

    elseif check == "b"
      
      check = B[1]
      if check == "0"
        println("B")
        break
      end
      shift!(B)

    elseif check == "c"
      
      check = C[1]
      if check == "0"
        println("C")
        break
      end
      shift!(C)

    end

  end
 
end

main()

Measured memory_bytes: 114316
Number =int (input())

a=int( Number%10)
num_1=int(Number/10)
b= int(num_1%10)
num_2=int(num_1/10)
c= int(num_2%10)
num_3=int(num_2/10)
d= int(num_3%10)

if(a==b or b==c or c==d ):
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 3064
N=int(input())
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

ans=digitSum(N)
print('Yes' if ans%9==0 else 'No')

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    double L;
    cin >> L;

    double ans = L / 3.0 * L / 3.0 * L / 3.0;
    cout << setprecision(18) << ans << endl;

    return 0;
}

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

int main()
{
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;

  if(S.at(K-1)=='A')
  {
    S.at(K-1)='a';
    cout << S << endl;
  }
  if(S.at(K-1)=='B')
  {
    S.at(K-1)='b';
    cout << S << endl;
  }
  if(S.at(K-1)=='C')
  {
    S.at(K-1)='c';
    cout << S << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
    long long int N;
    cin>>N;
    int K;
    cin>>K;
    int i=0;
    while(pow(K,i)<=N){
        i++;
    }
    cout<<i<<endl;
}


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

using namespace std;
typedef long long ll;
#define int 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))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 3010

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() {}
    CumulativeSum(int sz) : m_Data(sz, T(0)) {};

    void Init(int sz) { m_Data.assign(sz, T(0)); }

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(static_cast<int>(m_Data.size()) >= k);
        if(static_cast<int>(m_Data.size()) <= k) { m_Data.push_back(x); }
        else { m_Data[k] = (m_Data[k] + x); }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < static_cast<int>(m_Data.size()); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1]);
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1));
    }
private:
    vector< T > m_Data;
};

ll N;
vector<ll> A;
CumulativeSum<ll> cs;
ll dp[MAX_N][MAX_N][2];

enum Player { Taro = 0, Jiro = 1 };

// 左側は l 右側は r を見ていて、プレイヤーが player のときの
// 最大の X か Y の値
ll dfs(ll l, ll r, ll player) {
    if(l > r) { return 0; }
    ll next_player = (player == Taro) ? Jiro : Taro;

    ll& ret = dp[l][r][player];
    if(ret != LLINF) { return ret; }

    // 左側を取った場合
    ll next_player_point_1 = dfs(l+1, r, next_player);
    ll player_point_1 = cs.Query(l, r) - next_player_point_1;
    // 右側を取った場合
    ll next_player_point_2 = dfs(l, r-1, next_player);
    ll player_point_2 = cs.Query(l, r) - next_player_point_2;

    ret = max(player_point_1, player_point_2);

    return ret;
}

signed main()
{
    cin >> N;
    A.assign(N, 0);
    cs.Init(N);
    REP(i, N) {
        cin >> A[i];
        cs.Add(i, A[i]);
    }
    cs.Build();
    REP(i, N) { REP(j, N) { REP(k, 2) { dp[i][j][k] = LLINF; } } }
    ll X = dfs(0, N-1, Taro);
    ll Y = cs.Query(0, N-1) - X;
    printf("%lld\n", X - Y);
    return 0;
}


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

using namespace std;

int main(void){
  int n,t_limit;

  cin >> n >> t_limit;

  vector<int> c(n);
  vector<int> t(n);
  int min = 1001;

  for(int i=0; i<n; i++){
    cin >> c[i] >> t[i]; 
    if(t[i] > t_limit){
       c[i] = 1001;
    }
  }

  for(int i=0; i<n; i++) {
    if(min > c[i]){
      min = c[i];
    }
  }
  
  if(min <= 1000) {
    cout << min << endl;
  } else {
    cout << "TLE" << endl;
  }
}
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();

		int[] cntZero = new int[N+2];
		int[] cntOne = new int[N];
		boolean flg = false;
		int numZ = 0;
		int numO = 0;
		if(S.charAt(0)=='0') {
			flg=true;
			cntOne[numO++]=0;
		}
		for(int i =0;i < N;i++) {
			if(!flg && S.charAt(i)=='1') {
				cntOne[numO++] = i;
				flg = true;
			}else if(flg && S.charAt(i)=='0'){
				cntZero[numZ++] = i;
				flg = false;
			}
		}
		cntZero[numZ++] = N;
		int max = 0;
		if(numZ -1 < K) {
			max = N;
		}else{
			for(int i = K;i < numZ;i++) {
				if(cntZero[i] - cntOne[i-K] > max) {
					max = cntZero[i] - cntOne[i-K];
				}
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 26552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int X,t;cin >> X >> t;
  cout << max(0,X-t) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

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

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

using namespace std;
/*******************************************
****************** BY **********************
******* FUTURE GOOGLE EMPLOYEE *************
****** KARTHICK KUPPURAJ M *****************
********************************************/
#define ms(s, n) memset(s, n, sizeof(s))
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define prec(n) fixed<<setprecision(n)
#define sll(x) scanf("%lld",&x);
#define pll(x) printf("%lld",x);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c",c);
typedef long long int ll;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
bitset<1000002> state, finder[64];
int N, K;
string S[2020];
string Sc;
int idx[2020];
char in[1010101];
bool dp[2020][10101];

char smallest() {
    int pos = 1;
    while (pos < 32)
    {
        if ((state & finder[pos * 2]).none()) pos = pos * 2 + 1;
        else pos *= 2;
    }
    return (pos - 32) + 'a';
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; ++i)
    {
        scanf("%s", in);
        S[i] = in;
    }

    dp[N][0] = true;
    for (int i = N - 1; i >= 0; --i)
    {
        for (int j = 0; j <= K; ++j)
        {
            if (dp[i + 1][j])
            {
                dp[i][j] = true;
                if (j + S[i].size() <= K) dp[i][j + S[i].size()] = true;
            }
        }
    }
    for (int i = 0; i < N; ++i)
    {
        idx[i] = Sc.size();
        for (char c : S[i])
        { Sc.push_back(c); }
    }
    idx[N] = Sc.size();

    for (int i = 0; i < 64; ++i)
    { finder[i].reset(); }
    for (int i = 0; i < Sc.size(); ++i)
    {
        finder[Sc[i] - 'a' + 32].set(i);
    }
    for (int i = 31; i >= 1; --i)
    { finder[i] = finder[i * 2] | finder[i * 2 + 1]; }

    state.reset();
    state.set(0, true);

    string ret;

    for (int i = 0; i < K; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (state[idx[j]]) state.set(idx[j + 1]);
        }
        for (int j = 0; j < N; ++j)
        {
            if (K - i - (int) S[j].size() < 0 || !dp[j + 1][K - i - S[j].size()]) state.reset(idx[j]);
        }

        char nxt = smallest();
        ret.push_back(nxt);
        state &= finder[(nxt - 'a') + 32];
        state <<= 1;
    }

    puts(ret.c_str());

    return 0;
}


Measured memory_bytes: 31492
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
string s;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    if(s == "Sunny") cout << "Cloudy";
    if(s == "Cloudy") cout << "Rainy";
    if(s == "Rainy") cout << "Sunny";
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    var list = List[Int]()

    for(in <- StdIn.readLine.split(" ").map(_.toInt)){
      list = in :: list
    }

    boc(list.reverse)
  }

  def boc(a: List[Int])={
    if(a(0) < a(1) && a(1) < a(2)) println("Yes")
    else println("No")
  }
}

Measured memory_bytes: 43904
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

const int MAX=510000;
long long fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
long long COM(int n,int k){
    if(n<k) return 0;
    if(n<0 or k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
} 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
//O(r)
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
ll inv_mod(ll n){
    return pow_mod(n,mod-2);
}

int n;
vector<vector<int>> g;
vector<vector<ll>> v;
vector<ll> sz;

ll dfs(int pre,int now){
    ll ret=1;
    for(auto to:g[now])if(to!=pre){
        ll t=dfs(now,to);
        v[now].push_back(t);
        ret+=t;
    }
    if(n-ret!=0) v[now].push_back(n-ret);
    return sz[now]=ret;
}

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

    cin>>n;
    g.resize(n);sz.resize(n);v.resize(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(-1,0);
    ll p2=pow_mod(2,n),p22=pow_mod(2,n-1);
    ll ans=0;
    rep(i,n){
        if(v[i].size()==1) continue;
        
        ll k=p22;
        ll mi=1;
        for(auto t:v[i]){
            mi+=mod-1+pow_mod(2,t);
            mi%=mod;
        }
        k+=mod-mi;
        k%=mod;
        // cout<<i<<" ans : "<<k<<endl;
        ans=(ans+k)%mod;
    }
    ans=ans*inv_mod(p2)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 37376
import java.util.*;
public class Main {



	    public static void main(String[] args) throws java.io.IOException{
	        Scanner scan = new Scanner(System.in);

	        while(true){
	        	int a=scan.nextInt();
	        	int d =scan.nextInt();
	        	int n =scan.nextInt();
	        	if((a|d|n)==0)break;
	        	int count=0;
	        	for(int i=0;;i++){
	        		if(prime(a+i*d))count++;
	        		if(count==n){
	        			System.out.println(a+i*d);
	        			break;
	        		}
	        	}

	        }
	    }
	    public static boolean prime (int n){
	    	if(n==1)return false;
	    	for(int i=2;i<=Math.sqrt(n);i++)
	    		if(n%i==0)return false;
	    	return true;
	    }
	}

Measured memory_bytes: 12000
from collections import defaultdict


def resolve():
    n, m = map(int, input().split())
    xys = list(list(map(int, input().split())) for _ in range(m))
    num = [1] * n
    red = [False] * n
    red[0] = True
    for x, y in xys:
        if red[x - 1]:
            red[y - 1] = True
        num[x - 1] -= 1
        num[y - 1] += 1
        if num[x - 1] == 0:
            red[x - 1] = False
    print(red.count(True))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 29172
import sys
sys.setrecursionlimit(10**6)


def main():
    input = sys.stdin.readline
    n, q = map(int, input().split())
    e = [list(map(int, input().split())) for _ in range(n-1)]
    p = [list(map(int, input().split())) for _ in range(q)]

    e2 = [[] for _ in range(n)]
    for ee in e:
        a, b = ee
        e2[a-1].append(b-1)
        e2[b-1].append(a-1)

    counters = [0 for _ in range(n)]
    for pp in p:
        counters[pp[0]-1] += pp[1]

    used = [0] * n

    def dfs(x, p_sum):
        counters[x] += p_sum
        used[x] = 1
        for y in e2[x]:
            if used[y] == 1:
                continue
            dfs(y, counters[x])

    dfs(0, 0)
    print(*counters)


main()


Measured memory_bytes: 351868
K, A, B = map( int, input().split())
ans = 0
if A+1 <= K:
    t = (K+1)//(A+2)
    ans = t*B + (K - ((A+2)*t-1))

twoans = A
now = A-1
if A*2 < B:
    while now < K:
        if now + twoans//A*2 <= K:
            now += twoans//A*2
            twoans = twoans - (twoans//A*A) + (twoans//A*B)
        else:
            break
if (K - now)%2 == 0:
    twoans = twoans + (K-now)//2*(B-A)
else:
    twoans = twoans + (K-now)//2*(B-A)+1
print( max(twoans,  ans, K+1))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(){
    int W,H;
    int x,y,r;
    
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    W -=r,H -=r;
    if(r<=x&&x<=W&&r<=y&&y<=H){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
    
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const ll M = 1000000007;

int a[N],k[4];

int main()
{
	int x,n;
	scanf("%d",&n);
	memset(k,0,sizeof(k));
	
	ll ans = 1;
	for(int i = 1;i <= n;++i) scanf("%d",&a[i]);
	for(int i = 1;i <= n;++i){
		int sum = 0;
		for(int j = 1;j <= 3;++j){
			if(k[j] == a[i]) sum++;
		}
		ans = (ans*sum)%M;
		for(int j = 1;j <= 3;++j){
			if(k[j] == a[i]){
				k[j]++;
				break;
			}
		}
	} 
	
	printf("%lld\n",(ans+M)%M);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x=0,xx=0;
  cin>>x;
  int tx=x;
  while(tx>0)
  {
    xx+=tx%10;
    tx/=10;
  }
  if(x%xx==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		char[] s = scan.nextLine().toCharArray();
		for(int i = 0; i < s.length - 4; i++){
			if(s[i] == 'a' && 
					s[i+1] == 'p' && 
					s[i+2] == 'p' && 
					s[i+3] == 'l' && 
					s[i+4]=='e'){
				s[i] = 'p';
				s[i+1] = 'e';
				s[i+2] = 'a';
				s[i+3] = 'c';
				s[i+4] = 'h';
			}
			else if( s[i] == 'p' && 
					s[i+1] == 'e' && 
					s[i+2] == 'a' && 
					s[i+3] == 'c' &&
					s[i+4] == 'h'){
				s[i] = 'a';
				s[i+1] = 'p';
				s[i+2] = 'p';
				s[i+3] = 'l';
				s[i+4] = 'e';
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 25892
package main

import (
	"fmt"
)

func main() {
	var n, tmp int
    var a []int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
      	a = append(a, tmp)
	}
  	memo := 0
  	sum := 0
	for i := 0; i < n; i++ {
      sum = sum + (memo * a[i]) % 1000000007
      memo = (memo + a[i])% 1000000007
    }
	
  	ans := sum % 1000000007
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 9944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    int cnt=0;
    for(int i=1; i<=9; i++){
        for(int j=0; j<=9; j++){
        for(int k=0; k<=9; k++){
            int x = 10001*i + 1010*j + 100*k;
            if(x >= a && x <= b) cnt++;
        }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=[0]*(l[-1]-l[0]+3)
b=l[0]
for i in range(n):
  l[i]-=b
for i in range(n):
  a[l[i]]+=1
  a[l[i]+1]+=1
  a[l[i]+2]+=1
print(max(a))


Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

ll dp[3000][3000];
ll sum[3000][3000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<ll> s(n+1),t(m+1);
    FOR(i,1,n+1) cin>>s[i];
    FOR(i,1,m+1) cin>>t[i];
    dp[0][0]=1;
    rep(i,n+1) sum[i][0]=1;
    rep(j,m+1) sum[0][j]=1;
    ll ans=1;
    FOR(i,1,n+1)FOR(j,1,m+1){
      if(s[i]==t[j]){
        dp[i][j]=sum[i-1][j-1];
        sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j]+mod)%mod;
        ans+=dp[i][j];
        ans%=mod;
      }else sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j]+mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 96256
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
using large = long long;
int main() {
    int n;
    cin >> n;
    auto a = vector<large>(n);
    for (auto &a_i : a)
        cin >> a_i;
    auto x = vector<large>(n);

    // a[i] = x[i] + x[i+1]
    // a[i+1] = x[i+1] + x[i+2]
    //
    // x[i] = a[i] - x[i+1]
    // x[i+1] = a[i+1] - x[i+2]
    //
    // x[i] = a[i] - [ a[i+1] - x[i+2] ]
    //      = a[i] - a[i+1] + x[i+2]

    auto sum_a = 0LL;
    for (int i = 0; i < n; i++) {
        sum_a += (i % 2 == 0 ? a[i] : -a[i]);
    }
    x[0] = sum_a / 2;
    for (int i = 1; i < n; i++) {
        // a[i-1] = x[i-1] + x[i]
        x[i] = a[i - 1] - x[i - 1];
    }
    for (int i = 0; i < n; i++) {
        printf("%d%c", 2 * x[i], (i == n - 1 ? '\n' : ' '));
    }

    return 0;
}


Measured memory_bytes: 2816
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

int sx, sy;

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

  int w, h;

  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    char tile[22][22];
    queue<pair<int, int>> que;
    rep(y, h) {
      rep(x, w) {
        cin >> tile[y][x];
        if (tile[y][x] == '@') {
          que.push(make_pair(x, y));
        }
      }
    }

    int ans = 0;

    while (!que.empty()) {
      pair<int, int> p = que.front();
      que.pop();

      rep(i, 4) {
        int nx = p.first + dx[i];
        int ny = p.second + dy[i];
        if (0 <= nx && nx < w && 0 <= ny && ny < h && tile[ny][nx] == '.') {
          ans++;
          tile[ny][nx] = '#';
          que.push(make_pair(nx, ny));
        }
      }
    }

    cout << ans + 1 << "\n";
  }

  return 0;
}


Measured memory_bytes: 3092
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

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

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef LOCALCODE
signed solve()
#else
signed main()
#endif
{
	auto N = IN();
	auto X = IN();
	vector<i64> m(N);
	for (auto& v : m)
	{
		cin >> v;
	}
	i64 sum = accumulate(m.begin(), m.end(), 0);
	i64 x = X - sum;

	sort(m.begin(), m.end());

	i64 ans = N;
	ans += x / m[0];
	print(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 10000000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};


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

	ll n,ans=1;cin>>n;
	vector<ll> t(n),a(n),res(n,-1);

	cin>>t[0];
	res[0]=t[0];

	for(int i=1;i < n;i++)
	{
		cin>>t[i];
		if(t[i]>t[i-1]){
			res[i]=t[i];
		}
	}

	rep(i,n)cin>>a[i];

	if((res[n-1]==-1 && a[n-1]<=t[n-1])|| (res[n-1]!=-1 && res[n-1]==a[n-1])){//
		res[n-1]=a[n-1];
	}else{
		cout<<0<<endl;
		return 0;
	}
	
	for(int i=n-2;0<=i;i--)
	{
		if(a[i]>a[i+1]){
			if((res[i]==-1 && a[i]<=t[i])|| (res[i]!=-1 && res[i]==a[i]))res[i]=a[i];//
			else {
				cout<<0<<endl;
				return 0;
			}
		}
	}
	//rep(i,n)cout<<res[i]<<endl;

	rep(i,n){
		if(res[i]==-1){
			ans*=min(a[i],t[i]);
			ans%=mod;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

























int main(){
    ll k, s;
    cin >> k >> s;
    ll ans = 0;
    REP(x, k + 1){
        REP(y, k + 1){
            ll z = s - x - y;
            if(0 <= z && z <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	
	cin>>a>>b;
	
	if(a>b)
		cout<<"a > b\n";
	else if(a<b)
		cout<<"a < b\n";
	else if(a==b)
		cout<<"a == b\n";
}
	

Measured memory_bytes: 1124