akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 

//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,idx,ans;
ll x[500005],y[500005],z[500005];
bool flag[500005];
char s[500005];

void dfs(ll idx){
    ll a = idx;
    y[a] = 0;
    ll cnt = 1;
    while(x[a+1] == 1){
        y[a+1] = max(y[a+1],cnt);
        cnt++;
        a++;
    }
    a = idx;
    cnt = 1;
    while(x[a] == 2){
        y[a-1] = max(y[a-1],cnt);
        cnt++;
        a--;
    }
}
int main(){
    cin >> s;
    n = strlen(s);
    x[0] = 2;
    for(int i=0;i<n;i++){
        if(s[i] == '>'){
            x[i+1] = 2;
        }else{
            x[i+1] = 1;
        }
    }
    x[n+1] = 1;
    for(int i=0;i<n+1;i++){
        if(x[i] == 2 && x[i+1] == 1){
            dfs(i);
        }
    }
    ans = 0;
    for(int i=0;i<n+1;i++){
        //pe(y[i]);
        ans += y[i];
    }
    p(ans);




    return 0;
}











Measured memory_bytes: 22272
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash() = default;
    
  void set(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH = RollingHash< 1000000007 >;

int main() {
    int n;
    cin >> n;
    
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        s[i] += s[i];
    }
    
    vector<string> tmp = s;
    
    s.insert(s.end(), tmp.begin(), tmp.end());
        
    vector<string> t(s.size(), string(2 * n, 0));
    
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            t[i][j] = s[j][i];       
        }
    }
    
    vector<RH> sh(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        sh[i].set(s[i]);
    }
    
    vector<RH> th(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        th[i].set(t[i]);
    }
    
    int ans = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            //if (sh[i].get(j, j + n) == th[j].get(i, i + n)) {
            bool ok = true;
            
            for (int k = 0; k < n; k++) {
                if (memcmp(s[i + k].c_str() + j, t[j + k].c_str() + i, n) != 0) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

int n,m;
char ch[555][555];
bool bol[555][555];
int w[7][5];

bool ok(int a,int b){
	if(a<=n&&a>0&&b<=m&&b>0)
		return true;
	return false;
}

int dfs(int x,int y){
	if(ch[x][y]=='.'||!ok(x,y)||bol[x][y])
		return 0;
	bol[x][y]=true;
	int sum=1;
	for(int i=1;i<=4;i++){
		int xx=x+w[i][1];
		int yy=y+w[i][2];
		sum+=dfs(xx,yy);
	}
	return sum;
}

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	w[1][1]=0;	w[1][2]=1;
	w[2][1]=0;	w[2][2]=-1;
	w[3][1]=1;	w[3][2]=0;
	w[4][1]=-1;	w[4][2]=0;
	
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		string cs;
		cin>>cs;
		for(int j=0;j<m;j++){
			ch[i][j+1]=cs[j];
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(ch[i][j]=='#'&&!bol[i][j]){
				if(dfs(i,j)==1){
					cout<<"No";
					return 0;
				}
			}
		}
	cout<<"Yes";
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int d, c;
  cin>> d>> c;
  cout<< d*c<< endl;

}

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

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

    for (int i = -118; i < 119; i++) {
        for (int j = -119; j < 118; j++) {
            if (pow(i, 5.0) - pow(j, 5.0) == n) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4104
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		int l, r; cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


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

int main(){
 int A, B, C;
 cin >> A >> B >> C;

  int ans = C-(A-B);

  if(ans > 0){
   cout << C-(A-B) <<endl;
  } else {
    cout << 0 << endl;
  }


}


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

int main() {
  int x;
  cin >> x;
  vector<bool> boo(x + 1);

  int b = 2;
  for (int i = 1; i < x; i++) {
    int p = 2;
    while (pow(b, p) <= x) {
      boo[pow(b, p)] = true;
      p++;
    }
    b++;
  }

  for (int i = x; i >= 0; i--) {
    if (boo[i]) {
      cout << i << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int M[10];

void bubbleSort(int M[], int N) {
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int i = N - 1; i > 0; --i) {
			if (M[i - 1] > M[i]) {
				int t = M[i];
				M[i] = M[i - 1];
				M[i - 1] = t;
				flag = 1;
			}
		}
	}
}

int main() {
	for (int i = 0; i < 10; ++i) {
		cin >> M[i];
	}

	bubbleSort(M, 10);

	for (int i = 1; i < 4; ++i) {
		cout << M[10 - i] << endl;
	}
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabr(i, a, b) for(int i = int(b)-1; i >= int(a); i--)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 4e5;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    deque<char> t;
    for (char c : s) t.pb(c);
    int q;
    int rev = 0;
    cin >> q;
    forn(i, q) {
        int typ;
        cin >> typ;
        if (typ == 1) {
            rev ^= 1;
        } else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if (f == 1) {
                if (rev) t.pb(c);
                else t.push_front(c);
            } else {
                if (!rev) t.pb(c);
                else t.push_front(c);
            }
        }
    }
    string ans = "";
    if (!rev) while (!t.empty()) cout << t.front(), t.pop_front();
    else while (!t.empty()) cout << t.back(), t.pop_back();
    return 0;
}

Measured memory_bytes: 976
import bisect


n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())
query = [list(map(int, input().split())) for i in range(q)]

log_size = n.bit_length() + 1
double = [[0] * n for i in range(log_size)]

for i in range(n):
    double[0][i] = bisect.bisect_right(x, x[i] + l) - 1

for k in range(1, log_size):
    for i in range(n):
        double[k][i] = double[k - 1][double[k - 1][i]]
        
for a, b in query:
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    ans = 10 ** 18
    tmp = 0
    for k in range(log_size)[::-1]:
        if double[k][a] >= b:
            ans = min(ans, 2 ** k + tmp)
        else:
            a = double[k][a]
            tmp += 2 ** k
    print(ans)

Measured memory_bytes: 100888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
vector<int> dx = {0,0,1,-1};
vector<int> dy = {1,-1,0,0};

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    --sx;--sy;--gx;--gy;
    vector<string> maze(h);
    rep(i,h) cin >> maze[i];
    vector<vector<int>> dist(h,vector<int>(w,INF));
    auto id = [&](int i,int j){ return i + h * j;};
    queue<int> q;
    q.push(id(sx,sy));
    dist[sx][sy] = 0;
    while(!q.empty()){
        int x = q.front() % h;
        int y = q.front() / h;
        q.pop();

        rep(p,4){
            for(int l=1;l<=k;l++){
                int now_x = x + dx[p]*l;
                int now_y = y + dy[p]*l;

                if(now_x < 0 || h <= now_x || now_y < 0 || w <= now_y) break;
                if(maze[now_x][now_y]=='@') break;
                if(dist[now_x][now_y] <= dist[x][y]) break;
                if(dist[now_x][now_y] > dist[x][y] + 1){
                    dist[now_x][now_y] = dist[x][y] + 1;
                    q.push(id(now_x,now_y));
                }
            }
        }
    }
    /*
    rep(i,h){
        rep(j,w) cout << dist[i][j] << " ";
        cout << endl;
    }
    */
    cout << (dist[gx][gy]==INF?-1:dist[gx][gy]) << endl;
    return 0;
}

Measured memory_bytes: 12172
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >> b;
    if (a*b%2!=0){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
  # import bisect
  # from collections import Counter
  # from collections import defaultdict
  # from collections import deque
  # from copy import deepcopy
  # from itertools import accumulate
  # from itertools import combinations
  # from itertools import permutations
  # from itertools import product
  # import numpy as np
  import sys
  sys.setrecursionlimit(10**6)
  readline = sys.stdin.readline
  ints = lambda: map(int, readline().split())
  floats = lambda: map(float, readline().split())
  pyes = lambda: print("Yes")
  pno = lambda: print("No")
  lli = lambda I, J: [[0] * J for _ in range(I)]
  mod = 10**9+7

  n, m = ints()
  l, r = [[0, 10], [10, 100], [100, 1000]][n - 1]
  sc = [list(ints()) for _ in range(m)]
  for i in range(l, r):
    x = str(i)
    if all([x[s - 1] == str(c) for s, c in sc]):
      print(i)
      exit()
  print(-1)

if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main()
{
    int N;
    std::cin >>N;
    int y = lcm(2, N);
    std::cout << y << std::endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    int m,area;
    scanf("%d%d%d",&a,&b,&c);
    m=(a+b+c)/2;
    area=sqrt(m*(m-a)*(m-b)*(m-c));
    printf("%d\n",area);
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    
    vector<int> L(N + 1, 0);
    for(int i = 1; i < N; i++) {
        for(int j = i + 1; j <= N; j++) {
            int l = min(j - i, abs(X - i) + abs(j - Y) + 1);
            L[l]++;
        }
    }
    for(int i = 1; i <= N-1; i++) {
        cout << L[i] << endl;
    }
}

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

using namespace std;

#define pb push_back
typedef long long ll;

int main(){
    int n;
    cin >> n;
    double res = 0;
    double a;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a != 0)
            res += 1/a;
    }

    res = 1/res;

    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,X;
set<int>A;

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

int main()
{
	cin>>N>>X;
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		A.insert(abs(X-a));
	}
	int t = 0;
	for (auto a : A)
	{
		if (t == 0)
		{
			t = a;
		}
		else
		{
			t = gcd(max(a, t), min(a, t));
		}
	}
	printf("%d\n", t);
}


Measured memory_bytes: 4864
import sys
sys.setrecursionlimit(1000000)


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

p=[[] for _ in range(n)]

for _ in range(m):
    x,y=map(int,input().split())
    p[x-1].append(y-1)

f=[-1 for _ in range(n)]

def calc(x):
    if f[x]!=-1:
        return f[x]
    if len(p[x])==0:
        f[x]=0
        return 0
    f[x]=max([calc(i) for i in p[x]])+1
    return f[x]

m=0
for i in range(n):
    if f[i]!=-1:
        continue
    m=max(m,calc(i))
print(m)


Measured memory_bytes: 177136
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		int cnt=1;
		for (i = 1; i < n; i++) {
			if(s[i]!=s[i-1]) {
				cnt++;
			}
		}
		out.println(cnt);
	}
}


Measured memory_bytes: 26260
#include <cstdio>
using namespace std;
typedef long long ll;
ll a,b,c,k;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(a-b>(ll)1e18)
		puts("Unfair");
	else
		printf("%lld\n",(!(k&1))?a-b:b-a);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;



struct RollingHash{
  typedef unsigned long long ull;
  string S;
  ull B;
  Int len;
  vector<ull> hash,p;
  RollingHash(){}
  RollingHash(string S_,ull B_ = 1e9+7):
    S(S_),B(B_),len(S.length()),hash(len+1),p(len+1){
    hash[0] = 0; p[0] = 1;
    for(Int i=0;i<len;i++){
      hash[i+1] = hash[i] * B + S[i];
      p[i+1] = p[i] * B;
    }
  }

  ull find(Int l,Int r){
    return hash[r] - hash[l] * p[r-l];
  }
};


signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  cin>>n;
  vector<string> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  
  string t;
  cin>>t;
  
  vector<RollingHash> rhs;
  for(Int i=0;i<n;i++) rhs.push_back(RollingHash(s[i]));
  using ull=RollingHash::ull;
  vector< vector<Int> > l(26);
  vector< vector<ull> > v(26);
  for(Int i=0;i<n;i++){
    l[s[i][0]-'a'].push_back(s[i].size());
    v[s[i][0]-'a'].push_back(rhs[i].find(0,s[i].size()));
  }
  
  RollingHash rht(t);
  vector<Int> dp(t.size()+1,0);
  dp[0]=1;
  const Int MOD=1e9+7;
  for(Int i=0;i<(Int)t.size();i++){
    if(!dp[i]) continue;
    for(Int j=0;j<(Int)l[t[i]-'a'].size();j++){
      if(i+l[t[i]-'a'][j]>(Int)t.size()) continue;
      if(rht.find(i,i+l[t[i]-'a'][j])==v[t[i]-'a'][j]){
	dp[i+l[t[i]-'a'][j]]+=dp[i];
	dp[i+l[t[i]-'a'][j]]%=MOD;
      }
    }
  }
  cout<<dp.back()<<endl;
  return 0;
}



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

signed main() {
    string s;
    cin >> s;
    
    if ( s == "Sunny" ) {
        cout << "Cloudy\n";
    } else if ( s == "Rainy" ) {
        cout << "Sunny\n";
    } else {
        cout << "Rainy\n";
    }
    return (0);
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i, j;
    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++) {
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <string>
#include <cmath>
using namespace std;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if(a<b && b<c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() {
  int n, count=1, a=0, b=0;
  cin >> n;
  vector<int> num(n), p(n), q(n);
  rep (i, n) {
    cin >> p[i];
    num[i] = i+1;
  }
  rep (i, n) cin >> q[i];

  do {
    if (p == num) a = count;
    if (q == num) b = count;
    ++count;
  } while (next_permutation(num.begin(), num.end()));

  cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace _20190307_03 {
    class Program {
        static void Main(string[] args) {
            var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n = line[0];
            var m = line[1];
            var bridgeList = new int[m, 2];
            for (int i = 0; i < m; i++) {
                var bridge = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                bridgeList[m - i - 1, 0] = bridge[0];
                bridgeList[m - i - 1, 1] = bridge[1];
            }
            var uf = new UnionFindMethod(n);
            var answer = new long[m];
            var max = mC2(n);
            answer[m - 1] = max;
            for (int i = 0; i < m - 1; i++) {
                var i1 = bridgeList[i, 0] - 1;
                var i2 = bridgeList[i, 1] - 1;
                if (uf.IsSame(i1,i2)) {
                    answer[m - i - 2] = answer[m - i - 1];
                } else {
                    answer[m - i - 2] = answer[m - i - 1] - uf.GetSize(i1) * uf.GetSize(i2);
                    uf.Unite(i1, i2);
                }
            }
            foreach (var a in answer) {
                Console.WriteLine(a);
            }
        }

        static long mC2(long m) {
            return m * (m - 1) / 2;
        }
    }

    class UnionFindMethod {
        public int[] Parent { get; private set; }

        public UnionFindMethod(int n) {
            Parent = Enumerable.Repeat(-1, n).ToArray();
        }

        public int Root(int x) {
            return Parent[x] < 0 ? x : Parent[x] = Root(Parent[x]);
        }

        public void Unite(int x, int y) {
            var rx = Root(x);
            var ry = Root(y);
            if (rx == ry) return;
            Parent[rx] += Parent[ry];
            Parent[ry] = rx;
        }

        public int GetSize(int x) {
            return -Parent[Root(x)];
        }

        public bool IsSame(int x, int y) {
            return Root(x) == Root(y);
        }
    }
}

Measured memory_bytes: 21048
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

#include <cstdio>

using namespace std;

int main()
{
	int l[10], v[2];
	while (scanf("%d", &l[0]) != EOF)
	{
		vector<double> a;
		a.push_back(0);
		a.push_back(l[0]);
		for (int i = 1; i < 10; i++)
		{
			scanf(",%d", &l[i]);
			a.push_back(a.back() + l[i]);
		}
		scanf(",%d,%d", &v[0], &v[1]);
		double w = a.back() / (v[0] + v[1]);
		w *= v[0];
		for (int i = 1; i < a.size(); i++)
		{
			if (a[i] == w)
			{
				cout << i  << endl;
				break;
			}
			if (a[i]>w&&a[i - 1] < w)
			{
				cout << i << endl;
				break;
			}
		}

	}


}

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

int main(){
    string str;
    int i, n=3, a=0, b=0; 
    cin >> str;
    for (i=0; i<n; i++){
        if (str.substr(i, 1) == "A") a++;
        else if (str.substr(i, 1) == "B") b++;
    }
    if(a*b != 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main(){
  int n;cin>>n;
  if(n<105) cout<<0<<endl;
  else if(n<135) cout<<1<<endl;
  else if(n<165) cout<<2<<endl;
  else if(n<189) cout<<3<<endl;
  else if(n<195) cout<<4<<endl;
  else cout<<5<<endl;
  return 0;
}


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

int main() {
  int W,H,N;
  cin>>W>>H>>N;
  
  // W×H要素の２次元配列
  int A[110][110]={0};
 
  // 黒くなったら、A=1
  for(int i=0;i<N;++i){
    int x,y,a;
    cin>>x>>y>>a;
    
    if(a==1){
      for(int j=0;j<x;++j){
        for(int k=0;k<H;++k){
          A[j][k]=1;
        }
      }
    }
    
    if(a==2){
      for(int j=x;j<W;++j){
        for(int k=0;k<H;++k){
          A[j][k]=1;
        }
      }
    }
    
    if(a==3){
      for(int j=0;j<W;++j){
        for(int k=0;k<y;++k){
          A[j][k]=1;
        }
      }
    }
    
    if(a==4){
      for(int j=0;j<W;++j){
        for(int k=y;k<H;++k){
          A[j][k]=1;
        }
      }
    }
    
  }
  
  // 白い部分（A=0）の個数の計算
  int ans=0;
  for(int i=0;i<W;++i){
    for(int j=0;j<H;++j){
      if(A[i][j]==0)
        ++ans;
    }
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    diagonal_string();
}

fn diagonal_string() {
    let c1: String = read();
    let c2: String = read();
    let c3: String = read();
    let c1v = c1.chars().collect::<Vec<char>>();
    let c2v = c2.chars().collect::<Vec<char>>();
    let c3v = c3.chars().collect::<Vec<char>>();
    println!("{}{}{}", c1v[0], c2v[1], c3v[2]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
ll x, k, d;

bool check() {
    
}

int main(){
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d > k) {
        cout << x - k * d << endl;
    } else {
        ll cnt = x / d;
        ll rem = k - cnt;
        if(rem % 2 == 0) cout << x % d << endl;
        else cout << d - (x % d) << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
n, m = list(map(int, input().split()))
num_list = []
for i in range(m):
    num_list.append(list(map(int, input().split())))

ans = []

# 全てのlist[1]を基準にソートしていく
num_list.sort(key=lambda x: x[1])
# print(num_list)
# print(num_list[0][1] - 1)
cnt = 0
ans.append(num_list[0][1] - 1)
for i in num_list:
    cnt += 1
    last = ans[-1]
    # print('比較対象', last, " と ", i[1])
    if last not in range(i[0], i[1] + 1):
        # print(cnt, "番目")
        # print(i[1] - 1)
        # print('')
        ans.append(i[1] - 1)

print(len(ans))


Measured memory_bytes: 29072
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());

    if a + b >= 10 {
        println!("error");
        return;
    }
    println!("{}", a + b);
    return;
}


Measured memory_bytes: 4352
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];



int main() {
    string s;
    cin>>s;
    int cou=0;
    rep(i,s.size()/2){
        if(s.at(i)!=s.at(s.size()-1-i)){
            cou++;
        }
    }
    cout<<cou<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
typedef pair<int,int> P;
typedef pair<int,P> PP;

signed main(){
  int n,m,t,p;
  while(1){
    cin>>n>>m>>t>>p;
    if(n+m+t+p==0)break;
    int ma[400][400]={};
    for(int i=0;i<m;i++){
	 for(int j=0;j<n;j++){
	   ma[i][j]=1;
	 }
    }

    int h=m;
  
    for(int i=0;i<t;i++){

	 int d,c;
	 cin>>d>>c;
	 if(d==1){

	   for(int i=0;i<m;i++){
		for(int j=0;j<c;j++){
		  ma[i][2*c-1-j]+=ma[i][j];
		  ma[i][j]=0;
		}
	   }
	 
	 }else{

	   h=max(c,h-c);
	 
	   for(int i=0;i<n;i++){
		for(int j=0;j<c;j++){
		  ma[2*c-1-j][i]+=ma[j][i];
		  ma[j][i]=0;
		}
	   }
	 
	 }
    
	 [&](){
	   for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
		  if(ma[i][j]==0)continue;
		  for(int x=0;x<100;x++){
		    for(int y=0;y<100;y++){
			 ma[x][y]=ma[i+x][j+y];
			 ma[i+x][j+y]=0;
		    }
		  }
		  return;
		}
	   }
	 }();
	 /*
	   cout<<"ma"<<endl;
	   for(int i=0;i<m;i++){
	   for(int j=0;j<n;j++){
	   cout<<ma[i][j]<<" ";
	   }
	   cout<<endl;
	   }
	 //*/ 
    
    }
    //  dbg(h);
    for(int i=0;i<p;i++){
	 int x,y;
	 cin>>x>>y;
	 cout<<ma[y][x]<<endl;
    }
  }
  return 0;
}



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

int imos[6005][6005]={0};

int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W')y += k;
        x %= 2*k;
        y %= 2*k;
        for(int m=0;m<2;++m){
            for(int a=0;a<2;++a){
                for(int b=0;b<2;++b){
                    int nx = x + 2*a*k;
                    int ny = y + 2*b*k;
                    int left_x = nx, right_x = nx + k;
                    int bottom_y = ny, top_y = ny + k;
                    imos[bottom_y][left_x]++;
                    imos[top_y][left_x]--;
                    imos[bottom_y][right_x]--;
                    imos[top_y][right_x]++;
                }
            }
            x += k;
            y += k;
        }
    }

    for(int i=0;i<=6*k;++i){
        for(int j=1;j<=6*k;++j)
            imos[i][j] += imos[i][j-1];
    }

    int ans = 0;
    for(int j=0;j<=6*k;++j){
        for(int i=1;i<=6*k;++i){
            imos[i][j] += imos[i-1][j];
            ans = max(ans, imos[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 141056
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            if a[i+k][j:j+m]!=b[k]:
                flag = False
                break
        if flag:
            ans = "Yes"
            break
print(ans)

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

int main(void) {
  string str;
  int a,n;
  int flag;
  int bingo[3][3];
  int count;
  
  for(int i=0; i<3; i++){
    getline(cin, str);
    istringstream s(str);
    s >> bingo[0][i] >> bingo[1][i] >> bingo[2][i];
  }
  
  cin >> n;
  
  for(int i=0; i<n; i++){
    cin >> a;
    flag = 0;
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(bingo[j][k] == a){
          bingo[j][k] = 0;
          flag = 1;
          break;
        }
      }
      if(flag) break;
    }
  }
  
  flag = 0;
  for(int j=0; j<3; j++){
    count = 0;
    for(int k=0; k<3; k++){
        if(bingo[j][k] == 0){
          count++;
        }
    }
    if(count == 3){
        flag = 1;
        break;
    }

    count = 0;
    for(int k=0; k<3; k++){
        if(bingo[k][j] == 0){
          count++;
        }
    }
    if(count == 3){
        flag = 1;
        break;
    }

    count = 0;
    for(int k=0; k<3; k++){
        if(bingo[k][k] == 0){
          count++;
        }
    }
    if(count == 3){
        flag = 1;
        break;
    }

    count = 0;
    for(int k=0; k<3; k++){
        if(bingo[2-k][k] == 0){
          count++;
        }
    }
    if(count == 3){
        flag = 1;
        break;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

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


int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A*B >= C*D) cout << A*B << endl;
    else cout << C*D << endl;
}



Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define NN (1<<29)
using namespace std;
int n,m,r,ans=NN,d[9],dist[201][201];
bool flag[9];
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
void dfs(int cnt,int now,int dd)
{
    if(cnt==r)
    {
        ans=min(dd,ans);
        return;
    }
    else
    {
        rep(i,r)
        if(!flag[i])
        {
            flag[i]=true;
            if(now==-1)
            {
                dfs(cnt+1,i,0);
            }
            else
            {
                dfs(cnt+1,i,dd+dist[d[now]][d[i]]);
            }
            flag[i]=false;
        }
        return;
    }
}
int main()
{
    cin>>n>>m>>r;
    int a,b,c;
    rep(i,r)
    {
        cin>>d[i];
        d[i]--;
    }
    
    rep(i,n)
    {
        rep(j,n)
        {
            dist[i][j]=NN;
        }
        dist[i][i]=0;
    }
    rep(i,m)
    {
        cin>>a>>b>>c;
        dist[--a][--b]=c;
        dist[b][a]=c;
    }
    rep(k,n)
    {
        rep(i,n)
        {
            rep(j,n)
            {
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
            
        }
        
    }
    rep(i,r)
    {
        flag[i]=false;
    }
    dfs(0,-1,0);
    W(ans)
    return 0;
}

Measured memory_bytes: 384
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(i,n) cin >> a.at(0).at(i);
  rep(i,n) cin >> a.at(1).at(i);
  int ma = 0;
  int count = 0;
  for(int i=0;i<n;i++){
    count = 0;
    for(int j=0;j<=i;j++){
      count += a.at(0).at(j);
    }
    for(int k=i;k<n;k++){
      count += a.at(1).at(k);
    }
    ma = max(ma,count);
  }
  cout << ma << endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int h = sc.nextInt(), w = sc.nextInt();
		String[] s = new String[h];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next();
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < w + 2; i++) {
			sb.append("#");
		}
		System.out.println(sb);
		for (int i = 0; i < h; i++) {
			System.out.println("#" + s[i] + "#");
		}
		System.out.println(sb);
	}
}

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

using namespace std;
using lint = long long;

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<pair<lint, lint> > A(N + M);
    for(int i = 0; i < N; i++){
        cin >> A[i].first;
        A[i].second = 1;
    }
    //vector<pair<lint, lint> > nums(M);

    for(int i = 0; i < M; i++){
        int b, c;
        cin >> b >> c;
        A[N+i].first = c;
        A[N+i].second = b;
                //nums[i].first = c;
        //nums[i].second = b;
    }
    
    sort(A.begin(), A.end(), greater<pair<lint, lint> >());
    //sort(nums.begin(), nums.end(), greater<pair<lint, lint> >());

    /*
    int ia = 0;
    int in = 0;
    int max_n = nums.size();
    lint sum = 0;
    for(int i = 0; i < N; i++){
        if(max_n <=  in && A[ia].first > nums[in].first){
            sum += A[ia];
            ia++;
        }
        else{
            sum += ch[ic];
            ic++;
        }
    }
    */

    lint sum = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < A[i].second; j++){
            sum += A[i].first;
            cnt++;
            //cout << A[i].first << endl;
            if(cnt >= N){
                cout << sum << endl;
                return 0;
            }
        }
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 3328
ans=[]
ans2=[]
n=int(input())
a=n//100
b=(n-a*100)//10
c=n-a*100-b*10
ans.append(a)
ans.append(b)
ans.append(c)
for i in ans:
    if i==1:
        ans2.append(str(9))
    else:
        ans2.append(str(1))
print(''.join(ans2))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int maxValue = 1e5 + 5;

int main(){
	string a , b;
	cin>>a>>b;
	int n = a.size() , m = b.size();
	int dp[n + 1][m + 1];
	for(int i = 0; i <= n; i++){
	    for(int j = 0; j <= m; j++){
	        dp[i][j] = 0;
	    }
	}
	for(int i = 1; i <= n; i++){
	    for(int j = 1; j <= m; j++){
	        if(a[i - 1] == b[j - 1]){
	            dp[i][j] = dp[i - 1][j - 1] + 1;
	        }
	        else{
	            dp[i][j] = max(dp[i][j - 1] , dp[i - 1][j]);
	        }
	    }
	}
// 	cout<<dp[n][m]<<endl;;
	int j = m , count = dp[n][m];
	string ans(count , '.');
	for(int i = n; i > 0; i--){
	    j = m;
	    for(;j > 0; j--){
	        if((dp[i - 1][j - 1] == (dp[i][j] - 1)) && (a[i - 1] == b[j - 1]) && (dp[i][j] == count)){
	            ans[count - 1] = b[j - 1];
	            j--;
	            count--;
	            break;
	        }
	    }
	    
	}
	cout<<ans;
}

Measured memory_bytes: 38748
#include<bits/stdc++.h>
using namespace std;
#define ll long long 

int n;
ll cnt[6];

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cnt[0] = 1;
	for(int i = 1; i <= 5; i++) cnt[i] = cnt[i - 1] * 10;
	cin >> n;
	string s;
	s = to_string(n);
	//s = "25";
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		int fi = i % 10;
		int la = 0;
		int k = i;
		
		while(k){
			if(k / 10 == 0) la = k;
			k /= 10;
		}	
		//cout << i << " " << fi << " " << la << endl;
		if(!fi) continue;
		for(int j = 1; j <= s.size(); j++){
			if(j == 1) {
				if(la == fi)ans++;
				if(j == s.size() && fi > s[0] - '0') ans--;
			}
			else if(j >= 2 && j < s.size()) {
				ans += cnt[j - 2];
			} 
			else {
				if(fi > s[0] - '0') continue;
				if(fi < s[0] - '0') ans += cnt[j - 2];
				else {
					ll tmp = 0;
					for(int k = 1; k < s.size() - 1; k++) tmp = tmp * 10 + s[k] - '0';
					if(la <= s[s.size() - 1] - '0') tmp++;
					ans += tmp;
					//cout << "tmp" << " " << j << " " <<  tmp << endl;
				}
			}
		}
		//cout << ans << endl;
	}		
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    s=input()
    lst=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
    print(lst[lst.index(s)+1])
    
main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

ll inf=1e18;

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> f(n,vector<ll> (10));
  vector<vector<ll>> c(n,vector<ll> (11));
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<10;j++) {
      cin >> f[i][j];
    }
  }
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<11;j++) {
      cin >> c[i][j];
    }
  }
  ll ans=-inf;
  for(ll i=1;i<(1<<10);i++) {
    bitset<10> bit(i);
    ll tans=0;
    for(ll j=0;j<n;j++) {
      ll count=0;
      for(ll k=0;k<10;k++) {
        if(f[j][k]&&bit.test(k)) {
          count++;
        }
      }
      tans+=c[j][count];
    }
    ans=max(ans,tans);
  }
  cout << ans << endl;
}

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

int main() {
	int w; scanf("%d", &w);
	string s;
	while (w) { s += to_string(w % 3); w /= 3; }
	string a, b;
	bool back = false;
	for (char c : s) {
		if (c == '2'&&back) { a += '0'; b += '0'; }
		else if (c == '2') { back = true; a += '1'; b += '0'; }
		else if (c == '1'&&back) { a += '1'; b += '0'; }
		else if (back) { back = false; a += '0'; b += '1'; }
		else { a += '0'; b += c; }
	}
	if (back)b += '1';
	string ans;
	rep(i, max(a.size(), b.size())) {
		if (i < a.size() && a[i] == '1')ans += '-';
		else if (i < b.size() && b[i] == '1')ans += '+';
		else ans += '0';
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;

int main() {
    int n; 
    cin >> n;
    unordered_set<int> aa;
    rep(i, n) {
        int a;
        cin >> a;
        aa.insert(a);
    }
    if (aa.size() == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
int n,a[Maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	printf("%d",a[n/2+1]-a[n/2]);
	return 0;
}

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

int main() {
  int64_t N,A,B;
  cin >> N>>A>>B;
  

  
  if((B-A)%2==0){
      cout<<(B-A)/2<<endl;
    
  }
  else{
    if(B-1<N-A){
    cout <<(A+B-1)/2<< endl;
    }
    else{
       cout <<N-(A+B-1)/2<< endl;
    }
  }
}





Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    readln.chomp.enumerate.array.pipe!(
        s =>
        ((s.length==2 && s.front.value==s.back.value) ? [[1, 2]] : []) ~ (s.length-2).iota.map!(
            i => s[i..i+3]
        ).map!(
            a => (a[0].value==a[1].value || a[1].value==a[2].value || a[2].value==a[0].value) ? [a[0].index+1, a[2].index+1].to!(int[]) : [-1, -1]
        ).array
    ).fold!(
        (a, b) => a && (b.front<0 || (writeln(b.front, " ", b.back), false))
    )(true) && writeln("-1 -1");
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  string s;
  cin >> s;
  int n = sz(s);
  int ans = 0;
  int now = 0;
  rep(i, n) {
    if (s[i] == 'T') now += 1;
    if (s[i] == 'S') now -= 1;
    amax(ans, now);
  }
  ans <<= 1;
  cout << ans << endl;
}


Measured memory_bytes: 720