akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;
 
    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }
 
    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
 
    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
 
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
 
int main(){
    int N,M;cin>>N>>M;
    UnionFind<int> uf(N);
    for(int i = 0; i < M ;i++){
        int l,r,d;cin >> l >> r >> d;
        l--,r--;
        if(uf.issame(l,r)){
            int diff = uf.diff(l,r);
            if(diff != d){
                cout << "No" << endl;
                return 0;
            }
        }
        else uf.merge(l,r,d);
    }
 
    cout << "Yes" << endl;
 
    return 0;
}

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

int main(){
  int N ;
  cin >> N ;
  
  vector<int> vec(N + 1);
  rep(i, N){
    cin >> vec.at(i);
  }
  
  vector<int> ans(N);
  
  rep(i, N){
    int x;
    x = vec.at(i);
    ans.at(x - 1) = i + 1;
  }
  
  rep(i, N){
    cout << ans.at(i) << " "; 
  }
  cout << endl;
  
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    ll answer = K;
    for(int i=0;i<N-1;i++)
    {
        answer *= (K-1);
    }

    cout << answer << endl;

    return 0;
}

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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scaner sc = new Scaner();
        write wr = new write();
        //ここから

        int[] x=sc.IntArr;
        int a=x[0];
        int b=x[1];

        wr.wri(Math.Max(Math.Max(a+b,a-b),a*b));
        

        //ここまで
    }
    
        


    static int factmod(int X){
        int ret=1;
        for(int i=1;i<=X;++i){
            ret*=i;
            ret%=MOD;
        }
        return ret;
    }
}





class Scaner
{
    public string Str => Console.ReadLine();

    public string[] StrArr => Str.Split(' ');

    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public char[] CharArr => Str.ToArray();
    public long Long1 => LongArr[0];
    public int Int1 => IntArr[0];
    
}



class write
{
    public  void wri<T>(T x)
    {
        Console.WriteLine(x);
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int H,W,N;
int ix,iy;
string S,T;

bool solve(){
    int left=0,right=W;
    if(S[N-1]=='L')++left;
    if(S[N-1]=='R')--right;
    for(int i=N-2;i>=0;i--){
        if(T[i]=='L') right=min(right+1,W);
        else if(T[i]=='R') left=max(0,left-1);
        if(S[i]=='L') left=left+1;
        else if(S[i]=='R')right=right-1;
        if(left>=right) return false;
    }
    if(iy<left||iy>=right) return false;

    left=0,right=H;
    if(S[N-1]=='U')++left;
    if(S[N-1]=='D')--right;
    for(int i=N-2;i>=0;i--){
        if(T[i]=='U') right=min(right+1,H);
        else if(T[i]=='D') left=max(0,left-1);
        if(S[i]=='U') left=left+1;
        else if(S[i]=='D')right=right-1;
        if(left>=right) return false;
    }
    if(ix<left||ix>=right) return false;

    return true;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>H>>W>>N>>ix>>iy>>S>>T;
    --ix,--iy;
    if(solve()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 920
n, m = map(int, input().split())
spots = list(map(int, input().split()))
spots.sort()
diff = []
for i in range(1, m):
    diff.append(abs(spots[i] - spots[i - 1]))
diff.sort(reverse=True)
ans = sum(diff[n - 1:])
print(ans)


Measured memory_bytes: 13968
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll INF=pow(10,18);

int N;vec A;ll M;
ll func(ll X){
    ll rev=0;
    for(int i=0;i<N;i++){
        auto itr=lower_bound(A.begin(),A.end(),X-A[i]);
        rev+=N-distance(A.begin(),itr);
    }
    return M-rev;
}
ll BS(ll l,ll r){
    if(r-l==1) return l;
    ll m=(l+r)/2;
    if(func(m)<=0) return BS(m,r);
    else           return BS(l,m);
}

int main(){
    cin>>N>>M;
    A.resize(N);
    for(int i=0;i<N;i++) cin>>A[i];
    sort(A.begin(),A.end());
    A.push_back(INF);
    vec S(N+1);S[0]=0;
    for(int i=1;i<=N;i++){
        S[i]=S[i-1]+A[N-i];
    }
    ll X=BS(0,INF),ans=X*func(X+1);
    for(int i=0;i<N;i++){
        auto itr=upper_bound(A.begin(),A.end(),X-A[i]);
        ans+=A[i]*(N-distance(A.begin(),itr))+S[N-distance(A.begin(),itr)];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

void dfs(ll a, bool t, const vvll &e, deque<ll> &q, vb &ald){
    if(ald[a]){return;}
    ald[a] = true;
    if(t){
        vll m(0);
        for(auto x: e[a]){
            if(!ald[x]){m.emplace_back(x);}
        }
        if(sz(m)==0){return;}
        else{
            q.push_back(m[0]);
            dfs(m[0], true, e, q, ald);
        }
    }else{
        vll m(0);
        for(auto x: e[a]){
            if(!ald[x]){m.emplace_back(x);}
        }
        if(sz(m)==0){return;}
        else{
            q.push_front(m[0]);
            dfs(m[0], false, e, q, ald);
        }
    }
}

int main(){
    ll N, M; cin >> N >> M;
    vvll e(N+1, vll(0));
    rep(i, 0, M){
        ll a, b; cin >> a >> b;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    deque<ll> q;
    q.push_back(1);
    vb ald(N+1, false);
    if(sz(e[1])==1){
        dfs(1, true, e, q, ald);
    }
    else{
        ald[1] = true;
        q.push_front(e[1][0]);
        dfs(e[1][0], false, e, q, ald);
        rep(i, 1, sz(e[1])){
            if(!ald[e[1][i]]){
               q.push_back(e[1][i]);
               dfs(e[1][i], true, e, q, ald); 
               break;
            }
        }
    }
    vll ans(0);
    while(!q.empty()){
        ll g = q.front();
        q.pop_front();
        ans.emplace_back(g);
    }
    prtl(sz(ans));
    for(auto x: ans){
        prt(x); prt(" ");
    }
}

Measured memory_bytes: 19968
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	double x, h;
	cout << setprecision(11);
	while (cin >> x >> h&&x&&h) {
		double a = x*pow(2, 0.5) / 2;
		double b = pow(a*a + h*h, 0.5);
		double c = x / 2;
		double d = pow(b*b - c*c, 0.5);
		cout << x*x + x*d / 2 * 4 << endl;
	}
	return 0;
}

Measured memory_bytes: 3408
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,x,d=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<a+1;i++){
		for(int j=0;j<b+1;j++){
			for(int k=0;k<c+1;k++){
				if(i*500+j*100+k*50==x){
					d++;
				}
			}
		}
	}
	cout<<d<<endl;
	
}

Measured memory_bytes: 256
A = [1, 2, 3, 5, 8, 13, 21]
MOD = 10**9 + 7
H, W, K = map(int, input().split())
if W == 0:
    print(1)
    exit()
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
    for j in range(i + 1):
        for k in [-1, 0, 1]:
            if not 0 <= j + k < W: continue
            if not 0 <= j < W: continue
            if k == -1:
                left = max(0, j - 1 - 1)
                right = max(0, W - j - 2)
            elif k == 0:
                left = max(0, j - 1)
                right = max(0, W - j - 2)
            elif k == 1:
                left = max(0, j - 1)
                right = max(0, W - j - 2 - 1)
            dp[i][j] += dp[i - 1][j + k] * A[left] * A[right]
            dp[i][j] %= MOD
print(dp[H][K - 1])

Measured memory_bytes: 3064
#include <stdio.h>
#define exchange(a,b) {tmp=a;a=b;b=tmp;}

int Partition(int *A,int p,int r){
  int j,tmp;
  int x = A[r];
  int i = p-1;
  for (j = p;j<r;j++){
    if (A[j] <= x){
      i = i+1;
      exchange(A[i],A[j]);  
    }
  } 
  exchange(A[i+1],A[r]);

  return i+1;
}

int main(){
  int A[100000],n,i,k;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  k=Partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i == k){    
      printf("[%d]",A[i]);
    }else{
      printf("%d",A[i]);
    }
    if(i<n-1)
      printf(" ");
  }
  printf("\n");

  return 0;
  
}

Measured memory_bytes: 992
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M >> K;
	int sum = N + M + K;
	if (M > K)swap(M, K);
	vector<long long int>by(sum + 11, 1);
	vector<long long int>rev(sum + 11, 1);
	for (int i = 2; i <= sum + 10; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	long long int ans = power(3, M + K, MOD);
	//long long int sum = 1;
	long long int cnt = 1;
	for (int i = N + 1; i <= sum; i++) {
		long long int add = by[i - 1];
		add *= rev[N - 1];
		add %= MOD;
		add *= rev[i - N];
		add %= MOD;
		int l = i - N - 1 - M, r = K;
		cnt *= 2;
		if (l >= 0) {
			long long int minus = by[i - 1 - N];
			minus *= rev[l];
			minus %= MOD;
			minus *= rev[i - 1 - N - l];
			minus %= MOD;
			cnt -= minus;
		}
		if (r <= i - 1 - N) {
			long long int minus = by[i - 1 - N];
			minus *= rev[r];
			minus %= MOD;
			minus *= rev[i - 1 - N - r];
			minus %= MOD;
			cnt -= minus;
		}
		cnt += MOD*2;
		//cout << i << " " << cnt << endl;
		cnt %= MOD;
		add *= cnt;
		add %= MOD;
		add *= power(3, sum - i, MOD);
		add %= MOD;
		ans += add;
		ans %= MOD;
	}
	cout << ans << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    int ans = 0, curMin = 1e9;
    rep(i, n) {
        curMin = min(p[i], curMin);
        if (curMin == p[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

    string ans;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'a') {
            ans += 'a';
            continue;
        }

        if (k >= 'z' - s[i] + 1) {
            ans += 'a';
            k -= 'z' - s[i] + 1;
        } else {
            ans += s[i];
        }
    }

    if (k > 0) {
        ans.back() = 'a' + (ans.back() - 'a' + (k % 26)) % 26;
    }

    cout << ans << endl;
}

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

using namespace std;

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

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

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

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


signed main(void) {
    int n;
    while(cin >> n, n){
        vi a(n+1);
        rep(i,n)cin >> a[i];
        a[n] = -1;
        int l = 0;
        rep(r,n){
            if(a[r]+1 != a[r+1]){
                if(l)cout << " ";
                if(l == r)cout << a[l];
                else cout << a[l] << "-" << a[r];
                l = r+1;
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3020
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;



int main(){FAST;    
    string str;
    int n = 0;
    cin >> str;
    if(str[0] != 'A')
        return cout << "WA" ,0;

    forp(i ,0 ,str.size()){
        if(str[i] != 'A' && str[i] != 'C' && str[i] < 'a')
            return cout << "WA" ,0;
         if(str[i] == 'C' && i > 1 && i < str.size() - 1)
             n++;
    }
    n == 1 ? cout << "AC" : cout << "WA";

    return 0;

}
 










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

int main() {
	int N,D,count=0;
	cin >> N>>D;
	int* x= new int[N];
	int* y = new int[N];
	double* result = new double[N];
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		result[i] = sqrt((double)x[i] * x[i] + (double)y[i] * y[i]);
		if (result[i] <= D)count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 6788
#計算量 max(N ** 2, C ** 3)
N, C = map(int, input().split())
D = [0] * C
for i in range(C):
  D[i] = list(map(int, input().split()))
grid = [0] * N
for i in range(N):
  grid[i] = list(map(int, input().split()))
  
#print(D, grid) 
grid3 = [[0] * C for i in range(3)]
#grid[i][j]:3で割って余りが i のマスで、色がjであるマスの個数
for i in range(N):
  for j in range(N):
    nn = (i + j) % 3
    color = grid[i][j] - 1
    grid3[nn][color] += 1
#print(grid3)  

score = [[0] * C for i in range(3)]
#score[i][j]:3で割って余りが i のマスを、色jにするときの違和感
#3 * C * C
for j in range(C):
  for i in range(3):
    for k in range(C): 
      score[i][j] += grid3[i][k] * D[k][j]
#print(score)            
ans = 10 ** 10  
for i in range(C):
  for j in range(C):
    if i != j:
      for k in range(C):
        if (i != k) and (j != k):
          now = score[0][i] + score[1][j] + score[2][k]
          ans = min(ans, now)
print(ans)      





Measured memory_bytes: 70700
#include <stdio.h>
#define Max 100000

#define N -1

struct Node{
int parent,left,right;
};
struct Node type[Max];
int D[Max];

void print(int u){
  int c,i;
  printf("node %d: ",u);
  
  printf("parent = %d, ",type[u].parent);

  printf("depth = %d, ",D[u]);

  if(type[u].parent == N){ printf("root, ");
  }
  else if(type[u].left == N){
    printf("leaf, ");
    
  }
  else printf("internal node, ");

  
  printf("[");

  c=type[u].left;

  for(i=0;c!=N;i++){

    if(i!=0)printf(", ");
      printf("%d",c);
  c=type[c].right;
  }

  printf("]\n");

}

void setdepth(int u,int p){
  D[u]=p;
  if(type[u].right != N) setdepth(type[u].right,p);
  if(type[u].left != N) setdepth(type[u].left,p+1);
}

int main(){
  int i,j,n,o,p,q,r,l;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    type[i].parent=N;
    
      type[i].left=N;
      type[i].right=N;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&o,&p);
    for(j=0;j<p;j++){
      
      scanf("%d",&q);
      if(j==0){type[o].left=q;}
      else {type[l].right=q;}
      l=q;
      type[q].parent=o;
    }
  }
  for(i=0;i<n;i++){
    if(type[i].parent == N){r=i;
    }
    
  }
  
  setdepth(r,0);

  
  for(i=0;i<n;i++)print(i);

  return 0;
}



Measured memory_bytes: 6384
#include <iostream>
using namespace std;
int main()
{
    int house[4][30] = {};
    int n, b, f, r, v;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> b >> f >> r >> v;
        house[b - 1][((f - 1) * 10) + (r - 1)] += v;
    }

    for (int i = 0; i < 4; i++)
    {
        for (int t = 0; t < 30; t++)
        {
            if (t % 10 == 0)
                cout << ' ';

            cout << house[i][t];
            if ((i >= 4 - 1) && t >= 30 - 1) {
                cout << endl;
                cin >> n;
                return 0;
            }

            if ((t + 1) % 10 != 0)
                cout << ' ';
            else
                cout << endl;
        }
        cout << "####################" << endl;
    }

}




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

int h,w;
string s[2000];

int u[2000][2000];
int d[2000][2000];
int l[2000][2000];
int r[2000][2000];

signed main() {
  cin >> h >> w;
  rep(i, h) cin >> s[i];

  int c;
  rep(i, h) {
    c=0;
    rep(j, w) {
      if(s[i][j] == '#') { c = -1; }
      l[i][j] = c++;
    }
  }
  rep(i, h) {
    c=0;
    for(int j=w-1; j>=0; j--) {
      if(s[i][j] == '#') { c = -1; }
      r[i][j] = c++;
    }
  }
  rep(j, w) {
    c=0;
    rep(i, h) {
      if(s[i][j] == '#') { c = -1; }
      u[i][j] = c++;
    }
  }
  rep(j, w) {
    c=0;
    for(int i=h-1; i>=0; i--) {
      if(s[i][j] == '#') { c = -1; }
      d[i][j] = c++;
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) {
    if(s[i][j] == '#') continue;
    ans = max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] + 1);
  }
  cout << ans << endl;

}


Measured memory_bytes: 66816
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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





int main() {
    vector<int>a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int b;
    cin>>b;
    cout<<a.at(b-1)<<endl;


    return 0;
}


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

using namespace std;
int main()
{
    string s[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}, t;
    cin>> t;

    for(int i=0; i<7; i++)
    {
        if(t==s[i])
        {
            cout<<(7-i)<< endl;
            return 0;
        }
    }
return 0;
}


Measured memory_bytes: 256
MAX = 10**5
N = int(input())
A = list(map(int, input().split()))

numlist = [0] * (MAX+1)
for i in range(N):
  numlist[A[i]] += 1
sumA = sum(A)
  
Q = int(input())
for i in range(Q):
  b, c = map(int, input().split())
  bcount = numlist[b]
  numlist[b] = 0
  numlist[c] += bcount
  sumA = sumA - bcount*b + bcount*c
  print(sumA)

Measured memory_bytes: 84200
<?php

//標準入力
class Scanner {
  private $arr = [];
  private $count = 0;
  private $pointer = 0;
  public function next() {
      if($this->pointer >= $this->count) {
          $str = trim(fgets(STDIN));
          $this->arr = explode(' ', $str);
          $this->count = count($this->arr);
          $this->pointer = 0;
      }
      $result = $this->arr[$this->pointer];
      $this->pointer++;
      return $result;
  }
  public function hasNext() {
      return $this->pointer < $this->count;
  }
  public function nextInt() {
      return (int)$this->next();
  }
  public function nextDouble() {
      return (double)$this->next();
  }
}

//標準出力
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}



$sc = new Scanner();
$P = $sc->nextInt();
$Q = $sc->nextInt();
$R = $sc->nextInt();

$A = $P + $Q;
$B = $Q + $R;
$C = $R + $P;

echo min(array($A,$B,$C)).PHP_EOL;


?>


Measured memory_bytes: 4856
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <deque>
#include <queue>

#define pb push_back
#define mp make_pair
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, loop=b; i<=loop; ++i)
#define REV(i, a, b) for(int i=a, loop=b; i>=loop; --i)
#define mize(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)
#define shl(k) ((k) << 1)
using namespace std;

typedef pair<int64_t, int64_t> ii;
const int N = 1e5+5;
int n, a[N], b[N];
int64_t ans[N];
map<int, int> Map;
ii bit[N];

ii operator - (ii a, ii b) { return mp(a.x-b.x, a.y-b.y); }
ii operator + (ii a, ii b) { return mp(a.x+b.x, a.y+b.y); }
void update(int y)
{
    ii tmp = mp(y, 1);
    for(int i=Map[y]; i>0; i-=i&-i)
        bit[i] = bit[i] + tmp;
}
ii get(int i)
{
    ii res = mp(0, 0); for(; i<=n; i+=i&-i)
    res = res + bit[i]; return res;
}
int main()
{
    ios::sync_with_stdio(); cin.tie(0);

    cin >> n;
    FOR(i, 1, n) {
        cin >> a[i];
        Map[a[i]] = 0;
        b[i] = max(b[i-1], a[i]);
    }

    int num = 0;
    for(auto &tmp: Map) tmp.y = ++num;

    ii x, y;
    REV(i, n, 2) {
        update(a[i]);
        if (b[i-1] < b[i]) {
            x = get(Map[b[i]]);
            y = get(Map[b[i-1]]);
            ans[i] = (y.x-x.x + x.y*b[i]) - y.y*b[i-1];
        }
    }

    FOR(i, 1, n) ans[1] += a[i]-ans[i];
    FOR(i, 1, n) cout << ans[i] << '\n';
}


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

using namespace std;

int main(){
    long long int N,K,ans=0;
    cin >> N >> K;
    vector<long long int> V(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }

    for(long long int i=0;i<K;i++){
        vector<long long int> left;
        long long int L=0,in = 0;

        in = min(N,i+1);

        for(int j=0;j<in;j++){
            left.push_back(V[j]);
            L += V[j];
        }

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

        for(long long int j=0;j<min((long long int)left.size(),(K-in));j++){
            if(left[j]<0){
                L -= left[j];
            }else{
                break;
            }
        }
        ans = max(ans,L);
    }

    for(long long int i=0;i<K;i++){
        vector<long long int> right;
        long long int R=0,in=0;

        in = min(N,i+1);

        for(int j=0;j<in;j++){
            right.push_back(V[N-1-j]);
            R += V[N-1-j];
        }

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

        for(long long int j=0;j<min((long long int)right.size(),(K-in));j++){
            if(right[j]<0){
                R -= right[j];
            }else{
                break;
            }
        }

        ans = max(ans,R);
    }

    for(long long int i=1;i<K;i++){
        long long int in=0;

        in = min(N,i+1);

        for(long long int j=1;j<in;j++){
            vector<long long int> both;
            long long int LR=0;

            for(long long int k=0;k<j;k++){
                both.push_back(V[k]);
                LR += V[k];
            }

            for(long long int k=0;k<in-j;k++){
                both.push_back(V[N-1-k]);
                LR += V[N-1-k];
            }

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

            for(long long int k=0;k<min((long long int)both.size(),(K-in));k++){
                if(both[k]<0){
                    LR -= both[k];
                }else{
                    break;
                }
            }
            ans = max(LR,ans);
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


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

    ans = 0
    for i in range(1 << n):
        check = True
        for j in range(m):
            ki = q[j][0]
            tmp_c = 0
            for k in range(1, ki + 1):
                if i & (1 << (q[j][k] - 1)):
                    tmp_c += 1
            if tmp_c % 2 != p[j]:
                check = False
                break
        if check:
            ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 40944
#include <stdio.h>

int main(void){
  
  int m,n=0,i=0,push=0;
  scanf("%d",&m);
  (void)getchar();

  for(i=0;i<m;i++){
    
    while((n=getchar())!='\n'){
      if(n=='1'){
	while((n = getchar())!='0')push++;
	if(push%5==0)putchar('.');
	if(push%5==1)putchar(',');
	if(push%5==2)putchar('!');
	if(push%5==3)putchar('?');
	if(push%5==4)putchar(' ');
	push=0;
      }
      
      else if(n=='2'){
	while((n = getchar())!='0')push++;
	putchar('a'+push%3);
	push=0;
      }
      
      else if(n=='3'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('d'+push%3);
	push=0;
      }
      
      else if(n=='4'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('g'+push%3);
	push=0;
      }
      
      else if(n=='5'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('j'+push%3);
	push=0;
      }
      
      else if(n=='6'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('m'+push%3);
	push=0;
      }
      
      else if(n=='7'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('p'+push%4);
	push=0;
      }
      
      else if(n=='8'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('t'+push%3);
	push=0;
      }
      
      else if(n=='9'){
	while((n = getchar())!='0'){
	  push++;
	}
	putchar('w'+push%4);
	push=0;
      }
    }
    putchar('\n');
  }
  return 0;
}

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

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N);
    priority_queue<ll> que; 
    rep(i,N){
        cin >> A[i];
        que.push(A[i]);
    }
    rep(i,M){
        ll a = que.top()/2;
        que.pop();
        que.push(a);
    }
    ll sum = 0;
    rep(i,N){
        sum += que.top();
        que.pop();
    }

    cout << sum << endl;

}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int keta(ll x) {
	int ret = 0;
	while(x > 0) {
		ret++;
		x/=10;
	}
	return ret;
}

set<ll> all_divisor(ll n){
	set<ll> res;
	for(ll i = 1; i*i<= n; i++){
		if(n%i==0){res.insert(i);res.insert(n/i);}
	}
	return res;
}

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

	ll n;
	cin >> n;
	int ans = INF;
	auto u = all_divisor(n);
	for(auto e: u){
		chmin(ans, max(keta(e), keta(n/e)));
	}
	cout << ans << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
#define MAX_N 100010
#define MAX_Q 50010
int n, q;
int t[MAX_Q];
set<int> s;

void input() {
  cin >> n;
  rep(i, 0, n) {
    int _s;
    cin >> _s;
    s.insert(_s);
  }
  cin >> q;
  rep(i, 0, q) cin >> t[i];
}

void solve() {
  int rsl = 0;
  rep(i, 0, q) {
    auto it = s.find(t[i]);
    if(it != s.end()) ++rsl;
  }
  cout << rsl << endl;
}

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




Measured memory_bytes: 7908
K, X = list(map(int, input().split()))
end_l = max(-1000000, X - K + 1)
end_r = min(1000000, X + K - 1)
ans = ""
for i in range(end_l, end_r):
    ans += str(i)
    ans += " "
ans += str(end_r)
print(ans)


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {          
            var str = Console.ReadLine();
            var arr = str.Split(' ');
            var numberInt1 = int.Parse(arr[0]);
            var numberInt2 = int.Parse(arr[1]);

            var multiResult = numberInt1 * numberInt2;

            var divisionResult = multiResult % 2;
            var result = "Odd";
            if (divisionResult == 0) 
            {
                result = "Even";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    string a = "ACGT";
    cin >> S;
    int size = S.size();
    int ans = 0;
    int count = 0;
    rep(i, 0, size)
    {
        rep(j, 0, 4)
        {
            if (S.at(i) == a.at(j))
            {
                count++;
                break;
            }
            if (j == 3)
            {
                if (ans < count)
                {
                    ans = count;
                }
                count = 0;
            }
        }
    }
    if (ans < count)
    {
        ans = count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}


int main(){
    ll x,y,n,m,p,h,k,max=-10000000,min=1000000000,ans=0,sum=0;
    string s,t;
    bool f=true;
    cin >> x >> y;
    if(x==0){
        if(y>0){
            cout << y << endl;
        }
        else{
            cout << abs(y)+1 << endl;
        }
    }
    else if(y==0){
        if(x>0){
            cout << x+1 << endl;
        }
        else{
            cout << abs(x) << endl;
        }
    }
    else if(x>0 && y>0){
        if(y>x){  // 10:11
            cout << y-x << endl;
        }
        else{      // 10:5
            if(x-y+2 < x+y+1)
                cout << x-y+2 << endl;
            else
            {
                cout << x+y+1 << endl;
            }
            
        }
    }
    else if (x<0&&y<0){
        if(x > y){   // -10 : -11
            cout << abs(y-x)+2 << endl;
        }
        else{        // -10 : -5
            cout << y-x << endl;
        }
    }
    else{ //どちらかがマイナス
        if(x>0){    // 10 : -5  10 : -11
            cout << abs(x+y)+1 << endl;
        }
        else{
            if(abs(x+y)+1 < (-1*x)+y)   // -10 : 11
                cout << abs(x+y)+1 << endl;
            else{              // -10 : 5 
                cout << (-1*x)+y << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,ans = 0;
    cin >> n;
    // a*b + c = n
    // a*b = n - c
    // a*b < n となるabの組を見つければいい
    for(int i=1;i<n;i++){
        ans += (n-1)/i;
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int len = s.size();
  vector<char> v(len, ' ');
  
  for (int i = 0, j = 0; i < len; i++) {
    char ch = s.at(i);
    if (ch == '0' || ch == '1') {
      v.at(j) = ch;
      j++;
    } else if (ch == 'B') {
      if (j >= 1) {
        j--;
        v.at(j) = ' ';
      } else {
        v.at(j) = ' ';
      }
    }
  }
  
  for (int i = 0; i < len; i++) {
    if (v.at(i) != ' ') {
      cout << v.at(i);
    }
    if (i == (len-1)) {
      cout << endl;
    }
  }
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int mod = 998244353;
const int maxn = 1e6 + 5; 
 
int fac[maxn], inv[maxn];
 
int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}
 
void pre_comb(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++){
        fac[i] = 1LL * fac[i - 1] * i % mod;
    }
    inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
    for(int i = maxn - 2;i >= 0;i--){
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    }
}
 
int comb(int n, int m){
    if(m > n or m < 0) return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, a, b;
    ll k;
    cin >> n >> a >> b >> k;
    int ans = 0;
    pre_comb();
    for(int i = 0;1LL * i * a <= k and i <= n;i++){
        ll res = k - 1LL * i * a;
        if(res % b == 0){
            ll m = res / b;        
            if(m <= n){
                add(ans, 1LL * comb(n, i) * comb(n, m) % mod);  
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=2000+10;
int n,x,y;
int ans[N];
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
    	for(int j=i+1;j<=n;j++){
    		int d=min(j-i,abs(x-i)+1+abs(y-j));
    		ans[d]++;
    	}
    }
    for(int i=1;i<n;i++)cout<<ans[i]<<"\n";
    return 0;
}

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

int check(int A, int B ){
  int counter = 0;
  for (int i = A; i <= B; i++)
  {
    int r = i;
    int one = r % 10; r /= 10;
    int two = r % 10; r /= 10;
    int three = r % 10; r /= 10;
    int four = r % 10; r /= 10;
    int five = r % 10; 

    if (one == five && two == four)
    {
      counter++;
    }
    
  }
  return counter;
}

int main() {
  int A, B; cin >> A >> B;
  int ans = check(A, B);
  cout << ans << endl;
}

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

int main(void) {
	string s,str;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (i % 2 == 0) str += s[i];
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;

#define MAX 505
P p[1005];

int n;

int main(){
  cin>>n;
  string s;
  cin>>s;
  int ans=0;
  for(int i=0; i<n; i++){
    string t;
    cin>>t;
    bool ok=false;
    for(int j=0; j<t.size(); j++){
      if(t[j]==s[0]){
        for(int v=j+1; v<t.size(); v++){
          if(t[v]==s[1]){
            int w=2;
            for(int k=v+v-j; k<t.size(); k+=v-j){
              if(s[w]!=t[k]) {
                goto a;
              }
              if(w==s.size()-1) {
                ok=true;
                goto b;
              }
              w++;
            }
          }
        a:;
        }
      }
    }
  b:;
    if(ok) {
      ans++;
    }
  }
  
  cout<<ans<<en
}


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

int main() {
    int n;
    cin >> n;
    string s = to_string(n);

    rep(i, 3) {
        if (s[i] == '1')
            cout << 9;
        else
            cout << 1;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,h,m,s;
	scanf("%d",&a);
	h=a/3600;
	m=a%3600/60;
	s=a%3600%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int h[100001];

int main(){
    long long int n, a, b;
    cin >> n >> a >> b;
    long long int sum=0;
    for(int i=0;i<n;++i){
        cin >> h[i];
        sum += h[i];
    }
    long long int mt = ceil((double)sum / b);
    long long int left = 0, right = mt;
    while(right - left > 1){
        long long int t = left + (right - left) / 2;
        long long int cnt = 0;
        for(int i=0;i<n;++i){
            if(h[i] > b * t)cnt += ceil((double)(h[i]-b*t)/(a-b));
        }
        if(cnt > t)left = t;
        else right = t;
    }

    printf("%lld\n",right);


    return 0;
}

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

using namespace std;

#define endl "\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int INF = 2e9;
const int MAX=1e7;
const int mod=1e9+7;


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

	int n;
	while(cin>>n){
		set<int>s;
		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			s.insert(x);
		}
		cout<<s.size()<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,W;
  cin >> H >> W;
  vvi A(H,vi(W));
  rep(i,H) {
    rep(j,W) {
      cin >> A[i][j];
    }
  }
  rep(i,H) {
    rep(j,W) {
      int x;
      cin >> x;
      A[i][j] -= x;
    }
  }
  int ma = 200*(H+W);
  int mid = ma/2;
  vvi dp(W,vi(ma,0));
  
  rep(i,H) {
    vvi dp2(W,vi(ma,0));
    if(i==0) {
      dp2[0][mid+A[0][0]] = 1;
      dp2[0][mid-A[0][0]] = 1;
    }
    rep(j,W) {
      if(j>0) {
        rep(k,ma) {
          if(k-A[i][j]>=0&&k-A[i][j]<ma&&dp2[j-1][k-A[i][j]]) {
            dp2[j][k] = 1;
          }
          if(k+A[i][j]>=0&&k+A[i][j]<ma&&dp2[j-1][k+A[i][j]]) {
            dp2[j][k] = 1;
          }
        }
      }
      if(i>0) {
        rep(k,ma) {
          if(k-A[i][j]>=0&&k-A[i][j]<ma&&dp[j][k-A[i][j]]) {
            dp2[j][k] = 1;
          }
          if(k+A[i][j]>=0&&k+A[i][j]<ma&&dp[j][k+A[i][j]]) {
            dp2[j][k] = 1;
          }
        }
      }
    }
    dp = dp2;
  }
  int ans = INF;
  rep(k,ma) {
    
    if(dp[W-1][k]) {
      ans = min(ans,abs(k-mid));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 22500
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int N, M;
int p[100005];
ll dist[100005];
int find(int a){
	if(a==p[a]) return a;
	int pa=p[a];
	p[a]=find(pa);
	dist[a]+=dist[pa];
	return p[a];
}
bool merge(int a,int b,int d){
	int pa=find(a), pb=find(b);
	if(pa==pb){
		return dist[a]==dist[b]+d;
	}
	else{
		p[pa]=pb;
		dist[pa]=d-dist[a]+dist[b];
		return 1;
	}
}
int main(){
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++)
		p[i]=i;
	while(M--){
		int L,R,D; scanf("%d %d %d",&L,&R,&D);
		if(!merge(L,R,D)) return !printf("No");
	}
	puts("Yes");

}

Measured memory_bytes: 1280