akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int sx,sy;
char mas[8][8];
int d[] = {-3,-2,-1,1,2,3};

void rec(int x,int y){
  mas[y][x] = '0';
  for(int i=0;i<6;i++){
    int nx = x + d[i];
    int ny = y + d[i];
    if(mas[y][nx] == '1' && nx >= 0 && nx < 8) rec(nx,y);
    if(mas[ny][x] == '1' && ny >= 0 && ny < 8) rec(x,ny);
  }
}

int main(){
  int n; cin >> n;
  for(int k=1;k<=n;k++){
    string tr; getline(cin,tr);
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++) cin >> mas[i][j];
    }
    cin >> sx >> sy;
    rec(--sx,--sy);
    cout << "Data " << k << ":\n"; 
    for(int i=0;i<8;i++){
      for(int j=0;j<8;j++) cout << mas[i][j];
      cout << endl;
    }
  }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

constexpr ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    vector<ll> vs(n);
    rep(i, n) cin >> vs[i];
    sort(vs.begin(), vs.end());
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (vs[i] == vs[j]) continue;
            for (int k = j + 1; k < n; k++) {
                if (vs[i] == vs[k]) continue;
                if (vs[j] == vs[k]) continue;
                if (vs[k] < vs[i] + vs[j]) {
                    sum++;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "yes" : "no");}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(a,n);
  arr(b,n);
  arr(c,n);

  sortall(a);
  sortall(b);
  sortall(c);

  ll ans=0;
  rep(i,n){
    auto top = lower_bound(all(a), b[i]);
    auto btm = upper_bound(all(c), b[i]);

    ans += (top - a.begin())*(c.end() - btm);
    //prt2(top - a.begin(),c.end() - btm);
  }
  prt(ans);
}


Measured memory_bytes: 1408
n,m,c = map(int,input().split())
b = [int(x) for x in input().split()]

ans = 0
for _ in range(n):
  a = [int(x) for x in input().split()]
  tsum = c
  for x,y in zip(a,b):
    tsum+=x*y
  if tsum > 0:ans+=1
    
print(ans)
    
  

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;

    int min_index = -1;
    double min_diff = 10000000000;
    REP(i,N){
        int h;
        cin >> h;
        double temp = T - h*0.006;
        double diff = fabs(temp - A);
        if(diff < min_diff){
            min_diff = diff;
            min_index = i;
        }
        //cout << min_index << endl;
    }

    cout << min_index+1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll f[20];

int main()
{
  ll a[3];
  for(ll i=0;i<3;i++)
  {
    cin>>a[i];
    f[a[i]]++;
  }
  if(f[5]==2&&f[7]==1){cout<<"YES"<<endl;exit(0);}
  cout<<"NO"<<endl;
}


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

int main(void){
  char n[200001] ;
  // printf("input N > \n") ;
  fflush( stdout ) ;
  fscanf( stdin, "%s", n ) ;
  // printf( "%s\n", n ) ;
  int l = strlen(n) ;
  // printf( "%d\n", l ) ;
  int S = 0 ;
  int i, k ;
  for( i = 0 ; i < l ; i++ ) {
  	k = n[i] - '0' ;
  	if( 0 <= k && k<= 9 ) {
  	  S += k ;
  	} else {
  	  // printf("This is not a integer.\n") ;
  	  return 1 ;
  	}
  }
  // printf( "%d\n", S ) ;
  if( S % 9 == 0 ) {
  	printf("Yes") ;
  } else {
  	printf("No") ;
  }
  return 0 ;
}

Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
#define SZ(a) int((a).size())
typedef vector<int> VI;
#define pb push_back

const int N=100010;
int n,L,q,x[N],g[20][N];

int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",x+i);
	}
	scanf("%d %d",&L,&q);
	rep(i,0,n) g[0][i]=upper_bound(x,x+n,x[i]+L)-x-1;
	rep(k,1,20) rep(i,0,n) g[k][i]=g[k-1][g[k-1][i]];
	rep(i,0,q) {
		int x,y;
		scanf("%d %d",&x,&y); x--; y--;
		if (x>y) swap(x,y);
		int ans=0;
		per(k,20,0) if (g[k][x]<y) {
			x=g[k][x];
			ans+=1<<k;
		}
		printf("%d\n",ans+1);
	}
}


Measured memory_bytes: 9088
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,m;cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}
  
  

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unordered_map>
# include <unordered_set>
//#include <bits/stdc++.h>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forx(i,x,n) for (int i = x; i < (n); i++)
#define form(i, n) for (int i = n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pf push_front
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned ll
#define srt(a) sort(a.begin(), a.end());
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define ar array
#define endl '\n';
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }
 
const ll MAXN = 32005, K = 200043, M = 1000043, INF = 1e18 + 7;
// the good way to get PI number
const ld PI = acos(-1.0);
ll MOD = 1e9 + 7;

template <class T> T sqr(T a) {
    return a * a;
}

ll mul(ll a, ll b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll sum(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll sub(ll a, ll b) {
    return sum(a, MOD - b);
}

ll bin_pow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    
    vl a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    ll ans = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if (a[i] == 0) {
            ans += sum / 2;
            sum = 0;
        }
    }
    ans += sum / 2;
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
//    cin >> t;
    
    while (t --> 0)
        solve();
    return 0;
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;

	ll kotae = 0;
	if (I && J && L && I % 2 + J % 2 + L % 2 >= 2) {
		kotae += 3;
		I--;
		J--;
		L--;
	}
	kotae += I / 2 * 2;
	kotae += O;
	kotae += J / 2 * 2;
	kotae += L / 2 * 2;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
import numpy as np

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()

arr = []

for l in range(1,k+1):
    for m in range(1,(k+1)//l+1):
        for n in range(1,(k+1)//(l*m)+1):
            # print(l,m,n)
            if l-1 < x and m-1 < y and n-1 < z:
                arr.append(a[l-1]+b[m-1]+c[n-1])

arr.sort()
arr.reverse()

for i in range(k):
    print(arr[i])


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    // (n-1)^2のbit全探索
    for (int bit = 0; bit < 1 << (n - 1); bit++) {
        // ある種類のbit探索のたびに初期化
        ll sum = 0;
        // char->int
        ll a = s[0] - '0';
        // 文字列を探索する
        for (int i = 0; i < n - 1; i++) {
            // 両辺のbitがともに1のとき，'+'があるとする
            if (bit & (1 << i)) {
                // sumにaを足す．
                sum += a;
                // 今までに足した分は初期化
                a = 0;
            }
            // 直前が'+'のときは次の数字を足す
            // 直前が'+'のときは今までのものを
            // e.g. "110"->1->1*10+1->(1*10+1)*10+0
            a = a * 10 + s[i + 1] - '0';
        }
        // 最後のaの分を足せていないので足す
        sum += a;
        // これまでのsumの分を足す
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int n, height[100001];
ll cost[100001];

int solve(){
	cost[1] = 0;
	cost[2] = abs(height[2] - height[1]);
	for(int i = 3; i <= n; ++i){
		ll a = cost[i - 1] + abs(height[i] - height[i - 1]);
		ll b = cost[i - 2] + abs(height[i] - height[i - 2]);
		cost[i] = min(a, b);
	}
	return cost[n];
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> height[i];
	}

	cout << solve();
	return 0;
}

Measured memory_bytes: 4804
import sys
readline = sys.stdin.readline

import collections
class Dinic:
    def __init__(self, vnum):
        self.edge = [[] for i in range(vnum)]
        self.n = vnum
        # infはint型の方が良いかもね
        self.inf = float('inf')
    def addedge(self, st, en, c):
        self.edge[st].append([en, c, len(self.edge[en])])
        self.edge[en].append([st, 0, len(self.edge[st])-1])
    def bfs(self, vst):
        dist = [-1]*self.n
        dist[vst] = 0
        Q = collections.deque([vst])
        while Q:
            nv = Q.popleft()
            for vt, c, r in self.edge[nv]:
                if dist[vt] == -1 and c > 0:
                    dist[vt] = dist[nv] + 1
                    Q.append(vt)
        self.dist = dist
    def dfs(self, nv, en, nf):
        nextv = self.nextv
        if nv == en:
            return nf
        dist = self.dist
        ist = nextv[nv]
        for i, (vt, c, r) in enumerate(self.edge[nv][ist:], ist):
            if dist[nv] < dist[vt] and c > 0:
                df = self.dfs(vt, en, min(nf, c))
                if df > 0:
                    self.edge[nv][i][1] -= df
                    self.edge[vt][r][1] += df
                    return df
            nextv[nv] += 1
        return 0
    def getmf(self, st, en):
        mf = 0
        while True:
            self.bfs(st)
            if self.dist[en] == -1:
                break
            self.nextv = [0]*self.n
            while True:
                fl = self.dfs(st, en, self.inf)
                if fl > 0:
                    mf += fl
                else:
                    break
        return mf



N, M = map(int, readline().split())
A = [list(map(int, readline().split())) for _ in range(N)]


B = [[None]*M for _ in range(N)]

st = 2*N
en = 2*N+1
used = set()
for num in range(M):
    T = Dinic(2*N+2)
    for i in range(N):
        T.addedge(st, i, 1)
        T.addedge(N+i, en, 1)
        for j in range(M):
            aij = A[i][j]
            if aij not in used:
                T.addedge(i, N+(aij-1)//M, 1)
    
    T.getmf(st, en)
    for i in range(N):
        candi = [e for e, cost, _ in T.edge[i+N] if cost == 1][0]
        for j in range(M):
            if A[candi][j] not in used and (A[candi][j]-1)//M == i:
                used.add(A[candi][j])
                B[candi][num] = A[candi][j]
                break
C = list(map(list, zip(*B)))
C = [sorted(c) for c in C]
C = list(map(list, zip(*C)))

for b in B:
    print(*b)

for c in C:
    print(*c)


Measured memory_bytes: 122844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380



int main() {
	int n;
	cin >> n;
	vector<LLI> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	LLI ans = 0;
	REP(i, n - 1) {
		if (a[i] % 2 == 1) {
			if (0 < a[i] && 0 < a[i + 1]) {
				a[i]--;
				a[i+1]--;
				ans++;
			}
		}
	}
	REP(i, n) {
		ans += a[i] / 2;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1024
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
    return res;
}
const int N=5e5+5;
int fac[N],ifac[N],bin[2][N],n,m,res,d;
inline int C(R int n,R int m){return 1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
inline int A(R int n,R int m){return mul(fac[n],ifac[n-m]);}
void init(){
	if(n>m)swap(n,m);
	bin[0][0]=bin[1][0]=fac[0]=ifac[0]=1;
	fp(i,1,m){
		fac[i]=mul(fac[i-1],i),
		bin[0][i]=mul(bin[0][i-1],m+1),
		bin[1][i]=mul(bin[1][i-1],n+1);
	}
	ifac[m]=ksm(fac[m],P-2);
	fd(i,m-1,1)ifac[i]=mul(ifac[i+1],i+1);
}
int main(){
	scanf("%d%d",&n,&m),init();
	fp(i,0,n){
		d=1ll*C(n,i)*A(m,i)%P*bin[0][n-i]%P*bin[1][m-i]%P;
		upd(res,(i&1)?P-d:d);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 8064
/**
 *    author:  tourist
 *    created: 11.01.2020 14:33:51       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> deg(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
    deg[a[i]] += 1;
  }
  vector<int> b(n, -1);
  vector<int> used(n, 0);
  function<void(int, int)> Dfs = [&](int v, int mn) {
    if (v == n) {
      for (int i = 0; i < n; i++) {
        if (i > 0) {
          cout << " ";
        }
        cout << b[i] + 1;
      }
      cout << '\n';
      exit(0);
    }
    if (v > 0) {
      int who = a[b[v - 1]];
      if (!used[who] && deg[who] == n - v - 1) {
        return;
      }
    }
    while (used[mn]) {
      ++mn;
    }
    for (int i = mn; i < n; i++) {
      if (used[i]) {
        continue;
      }
      if (v > 0 && i == a[b[v - 1]]) {
        continue;
      }
      int new_mn = mn;
      if (i == mn) {
        ++new_mn;
      }
      b[v] = i;
      --deg[a[i]];
      used[i] = 1;
      Dfs(v + 1, new_mn);
      used[i] = 0;
      ++deg[a[i]];
      b[v] = -1;
    }
  };
  Dfs(0, 0);
  cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 11776
// g++ -std=c++17 -O2 -Wall A.cpp -o A -D _DEBUG

#include <bits/stdc++.h>
using namespace std;
 
int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false); 
    cin.tie(NULL);
 
    string s;
    cin >> s;
    if (*s.rbegin() != 's') {
        s.append("s");
    } else {
        s.append("es");
    }
    cout << s;
}

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

#define NMIN 1
#define NMAX 36

struct Card{
char suit;
char value;  
};


void bubble(struct Card A[],int N){
  int i,j;
 struct Card t;
  for(i=0;i<N;i++){
for(j=N-1;j>=i;j--){
  if(A[j].value<A[j-1].value){
    t=A[j];
    A[j]=A[j-1];
    A[j-1]=t;
  }
}    
  }
}

void selection(struct Card A[],int N){
  int i,j,minj;
 struct Card t;
  for(i=0;i<N;i++){
minj=i; 
for(j=i;j<N;j++){
  if(A[j].value<A[minj].value) minj=j;
}
t=A[i];
A[i]=A[minj];
A[minj]=t;
  }
}

void print(struct Card A[],int N){
int i;
for(i=0;i<N;i++){
  if(i>0) printf(" ");
  printf("%c%c",A[i].suit,A[i].value);
}
 printf("\n");
}

int isStable(struct Card C1[],struct Card C2[],int N){
int i;
  for(i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}



int main(){
int N,i,j;
struct Card C1[NMAX],C2[NMAX];
char ch;
scanf("%d",&N);
if(N<NMIN||N>NMAX) exit(1);
for(i=0;i<N;i++){
  scanf(" %c%c",&C1[i].suit,&C1[i].value);
}
for(i=0;i<N;i++){
C2[i]=C1[i];
}
bubble(C1,N);
selection(C2,N);

print(C1,N);
printf("Stable\n");
print(C2,N);
if(isStable(C1,C2,N)==1){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}
  return 0;
}



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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	int x = 0;
	for (auto o : s)
	{
		x += (o == 'I'?1:-1);
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

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

// a 進法で n の桁和
int func(int n, int a) {
	int res = 0;
	while (n > 0) {
		res += n%a;
		n /= a;
	}
	return res;
}

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

	int res = N; // INF
	for (int i = 0; i <= N; ++i) {
		int tmp = func(i, 6) + func(N - i, 9);
		res = min(res, tmp);
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;

    int l[n],r[n]; 
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>l[i]>>r[i];
        sum+=r[i]-l[i]+1;
    }

	
    cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
#define maxn 200005
using namespace std;
inline int read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
stack <int> Q, F;
int L[maxn * 20], R[maxn * 20], t[maxn], sum[maxn * 20], lx[maxn],rx[maxn],ly[maxn],ry[maxn],a[maxn];
long long cnt, n, ans, ansx , p, anss, sumx;
int build(int l,int r)
{
    int num=++cnt;
    if(l!=r)
    {
        int mid=(l+r)>>1;
        L[num]=build(l,mid);
        R[num]=build(mid+1,r);
    }
    return num;
}
int update(int pre,int l,int r,int x)
{
    int num=++cnt;
    L[num]=L[pre];R[num]=R[pre];sum[num]=sum[pre]+1;
    if(l!=r)
    {
        int mid=(l+r)>>1;
        if(x<=mid)L[num]=update(L[pre],l,mid,x);
        else R[num]=update(R[pre],mid+1,r,x);
    }
    return num;
}
int query(int k, int v, int l, int r, int Lc ,int Rc)
{
    int mid = l + r >> 1, res = 0;
    if(r <= Rc && l >= Lc) { res = sum[k] - sum[v]; return res;}
    if (Lc <= mid)
       res += query(L[k], L[v], l, mid, Lc, Rc);
    if (Rc > mid)
       res += query(R[k], R[v], mid + 1, r, Lc, Rc);
    return res;

}
int main() {
    n = read();
    for(int i = 1; i <= n; i++) a[i] = read();
    for(int i = 1; i <= n; i++)
    {
        while(!Q.empty() && Q.top() < a[i])
            Q.pop(),F.pop();
            if(!Q.empty()) lx[i] = F.top();
            Q.push(a[i]); F.push(i);
    }
    while(!Q.empty()) Q.pop(), F.pop();
    for(int i = n; i >= 1; i--)
    {
        while(!Q.empty() && Q.top() < a[i])
            Q.pop(),F.pop();
            if(!Q.empty()) rx[i] = F.top();
            else rx[i] = n + 1;
            Q.push(a[i]); F.push(i);
    }
    t[0] = build(1, n);
    for(int i = 1; i <= n; i++)
    {
     t[i] = update( t[i - 1], 1, n, a[i]);
    }
    for(int i = 1; i <= n; i++)
    {
                p = rx[i]; ansx = sumx = 0;
                int l = rx[i] + 1, r = n ;
                while(l <= r){
                    int mid = l + r >> 1;
                    ans = query(t[mid], t[p], 1, n, a[i], n);
                    if(ans) { ansx++; r = mid - 1; sumx = mid;}
                    else l = mid + 1;
                }
                if(ansx == 0) sumx = n + 1;
                ry[i] = sumx;
                ansx = sumx = 0; p = lx[i] - 1;
                l = 1, r = lx[i] - 1;
                while(l <= r){
                    int mid = l + r >> 1;
                    ans = query(t[p], t[mid - 1], 1, n, a[i], n);
                    if(ans) { ansx++; l = mid + 1; sumx = mid;}
                    else r = mid - 1;
                }
                if(ansx == 0) sumx = 0;
                ly[i] = sumx;
    }
    for(int i = 1; i <= n; i++)
    {
             anss += 1ll *  (ry[i] - rx[i]) * (i - lx[i]) * a[i] + 1ll * (lx[i] - ly[i]) * (rx[i] - i) * a[i];
    }
    printf("%lld\n", anss);
  return 0;
}

Measured memory_bytes: 32896
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    ll n,x,t;
    cin >> n >> x >> t;

    ll ans = n/x;
    if(n%x != 0){
        ans = (ans+1)*t;
    }else{
        ans = ans*t;
    }
    
    

    cout << ans << endl;
}




Measured memory_bytes: 3620
using System;
class aizu{
    public static int Main(){
        int i,j;
        int[] n = new int[10000];
        string[] str = new string[10000];

        for( ; ; ){
            str = Console.ReadLine().Split(' ');
            for(i=0;i<2;i++)
                n[i] = int.Parse(str[i]);
            if(n[0]+n[1]==0) break;
            for(i=0;i<n[0];i++){
                for(j=0;j<n[1];j++){
                    if(i%2==0 && j%2==0 || i%2!=0 && j%2!=0)
                        Console.Write("#");
                    else
                        Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }        
        return 0;
    }  
}

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

int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n; i += r)
        for (int j = 0; i + j <= n; j += g)
            ans += ((n - i - j) % b == 0);
    cout << ans;
    return 0;
}

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

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = 0 ;

            foreach (char cs in s)
            {
                n += cs - '0';

            }

            if (n % 9 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }


        }
    }
}

Measured memory_bytes: 26412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int n,k;
vector<int>a;
ll solve(){
   ll ans=0;
   rep(i,k)ans+=a[i];

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

    cin>>n>>k;
    a.resize(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        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);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int r;
    cin>>r;
    double pi = 3.14159265359;
    double ans = 2.0*pi*r;
    cout<<fixed<<setprecision(20)<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();
            var re = "No";

            if(n[2] >= n[0] && n[2] <= n[1]) {
                re = "Yes";
            }

            Console.WriteLine(re);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

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

const int mo=998244353;

int main() {
  ll n,ans=1,tmp;
  cin >> n;
  vector<ll>d(n);
  rep(i,n) {
  	cin >> tmp;
  	if(i==0 && tmp!=0){
  		cout << 0 <<endl;
  		return 0;
  	}
  	if(i!=0 && tmp==0){
  		cout << 0 <<endl;
  		return 0;
  	}
  	d.at(tmp)++;
  }
  tmp=1;
  for(ll i=1;i<n;i++){
  	if(d.at(i)==0){
  		ans=0;
  	}
  	else{
  		rep(j,d.at(i)) ans=(ans*d.at(i-1))%mo;
  	}
  	tmp+=d.at(i);
  	if(tmp==n) break;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<double> d(n, 0);
    double v_total = 0.0;

    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    std::sort(d.begin(), d.end());
    v_total = d[0];

    for (int i = 1; i < n; i++)
    {
        v_total = (v_total + d[i]) / 2.0;
    }
    cout << v_total;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))

#print(n)
#print(b)

score = b[0]+b[n-2]
#print(b[0],b[n-2])

for i in range(0,n-2):
	score = score + min(b[i],b[i+1])
#	print(min(b[i],b[i+1]))
print(score)

Measured memory_bytes: 3060
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string t;
    string s;
    cin >> t;
    cin >> s;
    int cnt = 0;
    rep(i, 3) {
        if (t[i] == s[i]) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
open System

let W,H,x,y=stdin.ReadLine().Split()|>Array.map double|>fun c -> double c.[0],double c.[1],double c.[2],double c.[3]
[<EntryPoint>]
let main argv =
    if (x=(W/2.0))&&(y=(H/2.0)) then 1 else 0
    |>printfn "%f %d" (H*W/2.0)
    0

Measured memory_bytes: 14160
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
a,b=n1()
print(a*b)

Measured memory_bytes: 9232
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll fin, n;
ll A[222], K[222];

ll grundy(ll a, ll k)
{
	while(1)
	{
		if(a%k==0) return a/k;
		if(a<k) return 0;
		ll nxt_aim=k*(a/k);
		ll jump_size=a/k+1;
		ll jump_time=max(1LL,(a-nxt_aim+jump_size-1)/jump_size);
		a-=jump_size*jump_time;
	}
}

int main(void)
{
	cin>>n; ll i;
	for(i=1 ; i<=n ; i++) cin>>A[i]>>K[i];
	for(i=1 ; i<=n ; i++) fin^=grundy(A[i],K[i]);
	if(fin==0) cout<<"Aoki";
	else cout<<"Takahashi"; return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
set<string> st;
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 19220
S = input()
N = len(S)
X = (N-1)//2
flag = True
bun = True
if X%2 == 0:
  bun = False

for i in range((N-1)//2):
  if S[i] != S[-1-i]:
    flag = False
if bun == True:
  for i in range((X-1)//2):
    if S[i] != S[X-i-1]:
      flag = False
  for i in range((X-1)//2):
    if S[X+1+i] != S[-1-i]:
      flag = False
else:
  for i in range(X//2):
    if S[i] != S[X-i-1]:
      flag = False
  for i in range(X//2):
    if S[X+1+i] != S[-1-i]:
      flag = False
    
if N == 5:
  if S[0] != S[1]:
    flag = False
  elif S[-1] != S[-2]:
    flag = False
if flag == False:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    static int n;
    // Nodeのリスト
    static List<Node> nodes = new List<Node>();
    // 辿っているQueue
    static Queue<Node> queue = new Queue<Node>();

    // Node
    class Node
    {
        // 距離
        public int dist = -1;
        // 隣接NodeのId（index）
        public List<int> adjacentIds;
    }

    // メイン
    static void Main(string[] args)
    {
        Parse();
        
        Bfs(nodes[0]);

        Print();
    }

    // 入力をパース
    static void Parse()
    {
        // 行数を取得
        n = int.Parse(Console.ReadLine().Split()[0]);

        // nodeを作成
        for (int i = 0; i < n; i++)
        {
            nodes.Add(new Node());
        }

        // nodeの中身設定
        for (int i = 0; i < n; i++)
        {
            List<int> nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToList();
            nodes[nums[0] - 1].adjacentIds = nums.GetRange(2, nums[1]).Select(id => id - 1).ToList();
        }
    }

    // 幅優先探索
    static void Bfs(Node start)
    {
        start.dist = 0;
        queue.Enqueue(start);
        while (queue.Count() > 0)
        {
            Node node = queue.Dequeue();
            foreach (var id in node.adjacentIds)
            {
                if (nodes[id].dist == -1)
                {
                    nodes[id].dist = node.dist + 1;
                    queue.Enqueue(nodes[id]);
                }
            }
        }
    }

    // 出力
    static void Print()
    {
        for (int i = 0; i < n; i++)
        {
            System.Console.WriteLine(string.Format("{0} {1}", i + 1, nodes[i].dist));
        }
    }
}



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

int main(void)
{
    const char *clist[3] = {"hon", "pon", "bon"};
    int tlist [10]= {1,1,0,2,0,0,1,0,1,0};
    int n;
    cin >> n;
    cout << clist[tlist[n%10]];
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>

int main(){
  long int a;
  long int ans=0;
  scanf(" %ld",&a);
  ans +=((a/500)*(1000));
  a%=500;
  ans += (a-(a%5));
  printf("%d\n",ans);
  return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using SLL = signed long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();
const unsigned long long int ULLINF = numeric_limits<unsigned long long int>::max();

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

    LL x, k, d;
    cin >> x >> k >> d;

    LL step = 0;
    LL tmp = abs(x%d);
    step = abs(x/d);
    if (step<=k) { 
        if (x>=0) x = tmp;
        else x = tmp * -1;
    } else {
        if (x>=0) x = x - k*d;
        else x = x + k*d;
        step = k;
    }
    
    if ((k-step)%2 == 0) cout << abs(x) << endl;
    else cout << min(abs(x+d), abs(x-d)) << endl;

    return 0;
}


Measured memory_bytes: 3668
from heapq import heappop, heappush

n, m = map(int, input().split())

g = [[] for __ in range(n)]

for _ in range(m):
    l, r, c = map(int, input().split())
    g[l-1].append((r-1, c))

for i in range(1, n):
    g[i].append((i-1, 0))


d = [10**18] * n
d[0] = 0
q = [(0, 0)]
while q:
    dist_u, u = heappop(q)
    if d[u] < dist_u:
        continue
    for v, c in g[u]:
        if d[v] > dist_u + c:
            d[v] = dist_u + c
            heappush(q, (d[v], v))


print(d[n-1] if d[n-1] != 10**18 else -1)


Measured memory_bytes: 75940
use proconio::{fastout, input};

use proconio::marker::Usize1;

struct FenwickTree {
    seg: Vec<i64>,
}

impl FenwickTree {
    fn new(n: usize) -> Self {
        FenwickTree {
            seg: vec![0; n + 1],
        }
    }
    fn len(&self) -> usize {
        self.seg.len() - 1
    }
    fn add(&mut self, i: usize, x: i64) {
        let mut i = i + 1;
        while i <= self.len() {
            self.seg[i] += x;
            i += i & -(i as isize) as usize;
        }
    }
    fn sum(&self, i: usize) -> i64 {
        let mut s = 0;
        let mut i = i;
        while i > 0 {
            s += self.seg[i];
            i -= i & -(i as isize) as usize;
        }
        s
    }
}

#[fastout]
fn main() {
    input! {
        n: usize, q: usize,
        cc: [Usize1; n],
        lr: [(Usize1, Usize1); q],
    }
    let mut ft = FenwickTree::new(n);
    let mut ls = vec![None; n];
    let mut ilr = lr.into_iter().enumerate().collect::<Vec<_>>();
    ilr.sort_by_key(|&(_i, (_l, r))| r);
    let mut ans = vec![0; q];
    let mut j = 0;
    for i in 0..n {
        let c = cc[i];
        if let Some(i) = ls[c] {
            ft.add(i, -1);
        }
        ls[c] = Some(i);
        ft.add(i, 1);
        while j < q && (ilr[j].1).1 <= i {
            ans[ilr[j].0] = ft.sum((ilr[j].1).1 + 1) - ft.sum((ilr[j].1).0);
            j += 1;
        }
    }
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 45104
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b,c;
	cin>>n;
	a=n/100;
	b=(n-(a*100))/10;
	c=n-(a*100+b*10);
	if(a==c){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //test only

#include<bits/stdc++.h>
using namespace std;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  int i;
  rep(i,n) cin >> a[i];
  vector<ll> count(100001,0);
  ll sum = 0;
  rep(i,n)
  {
    count[a[i]]++;
    sum += a[i];
  }
  int q;
  cin >> q;
  rep(i,q)
  {
   ll b,c;
   cin >> b >> c;
   sum -= count[b]*b;
   sum += count[b]*c;
   count[c] += count[b];
   count[b] = 0; 
   cout << sum << endl;
  }
}


Measured memory_bytes: 4844
import math
import decimal
decimal.getcontext().prec=40

s=int(input())
if s==10**18:
  print(10**9,0,0,10**9,0,0)
else:
  x1,x2,x3,y1,y2,y3=[0,0,0,0,0,0]
  l=decimal.Decimal(s).sqrt()
  if decimal.Decimal(l%1)<0.5:
    x1,y2=int(l),int(l)+1
  else:
    x1,y2=int(l)+1,int(l)+1
  x2=decimal.Decimal(decimal.Decimal(x1*y2)-s)
  y1=1
  print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

P fin(int n){
    int a, b;
    a = n%10;

    while(n){
        b = n;
        n /= 10;
    }
    return P(a, b);
}

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

    map<P, int> mp;
    FOR(i, 1, N){
        P p = fin(i);
        mp[p]++;
    }
    
    int ans = 0;
    FOR(i, 1, N){
        P p = fin(i);
        P q(p.second, p.first);
        ans += mp[q];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
long long a[200000];
int main(){
  int n;
  long long sum=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    a[n+i] = a[i];
    sum += a[i];
  }
  long long l=0,r=(long long)10e14,mid;
  long long cnt1,cnt2,num1,num2,ma,ans=0;
  while(l <= r){
    mid = (l+r)/2;
    ma = 0;
    cnt1 = 0;
    cnt2 = 0;
    num1 = 0;
    for(int i=0;i<n;i++){
      while(cnt1 < mid && num1 < i+n){
	cnt1 += a[num1];
	if(i != 0) cnt2 -= a[num1];
	num1++;
      }
      if(i == 0) num2 = num1;
      while(cnt2 < mid && num2 < i+n){
	cnt2 += a[num2];
	num2++;
      }
      ma = max(ma, min(min(cnt1,cnt2),sum-(cnt1+cnt2)));
      cnt1 -= a[i];
    }

    if(ma >= mid){
      ans = max(ans,ma);
      l = mid+1;
    }else{
      r = mid-1;
    }

  }
  printf("%lld\n",ans);
  return(0);
}



Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define N 100001

int ans[N] ;

int main() {
    int n;

    cin >> n;

    int a[n];

    for (int i = 0;i < n;i++) {
        cin >> a[i];
    }

    ans[1] = abs(a[0] - a[1]);

    for (int i = 2;i < n;i++) {
        ans[i] = min((ans[i - 1] + abs(a[i] - a[i - 1])), (ans[i - 2] + abs(a[i] - a[i - 2])));
    }

    cout << ans[n - 1];

}

Measured memory_bytes: 1024