akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch TakahashiAndCards | diff TakahashiAndCards.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address TakahashiAndCards.cpp && ./a.out

/*

 7/16/2020

 9:03-

 */

const int MAX_N=50+1;
int X[MAX_N];
int N,A;

const int MAX_S=MAX_N*MAX_N;
LL dp[MAX_N][MAX_S];
void solve() {
  dp[0][0]=1;
  REP(i,N)for(int cnt=N-1; cnt>=0; --cnt) for(int sum=MAX_S-1; sum>=0; --sum) {
    //if(dp[cnt][sum]>0) dump(i,cnt,sum,dp[cnt][sum]);
    if(sum+X[i]<MAX_S) dp[cnt+1][sum+X[i]]+=dp[cnt][sum];
  }
  LL res=0;
  FORE(cnt,1,N) {
    res+=dp[cnt][cnt*A];
    //if(dp[cnt][cnt*A]>0) dump(cnt,cnt*A,dp[cnt][cnt*A]);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>A;
  REP(i,N) cin>>X[i];
  solve();

  return 0;
}


Measured memory_bytes: 4624
#include<stdio.h>
#define g getchar()
inline void r(int *x){
	*x=0;
	char c=g;
	while(c<'0')c=g;
	while(c>='0'){*x=*x*10+c-48;c=g;}
}
int x[100000];
int main(){
	int n,a,b;r(&n);r(&a);r(&b);long d=0;r(&x[0]);
	for(int i=1;i<n;i++){
		r(&x[i]);
		d+=(long)a*(x[i]-x[i-1])>b?b:(long)a*(x[i]-x[i-1]);
	}
	printf("%ld\n",d);
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    set<int> c;
    int x = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        x ^= a[i];
        c.insert(a[i]);
    }

    // if (N == 3) {
    cout << (x == 0 ? "Yes" : "No") << endl;
    // } else {
    //     for (int i = 0; i < N; ++i) {
    //         if (c.count(x ^ a[i]) && a[i] != (x ^ a[i])) {
    //             cout << "Yes" << endl;
    //             return 0;
    //         }
    //     }

    //     cout << "No" << endl;
    // }
    return 0;
}

Measured memory_bytes: 4224
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        
        int [] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int N = a[0];
        int W = a[1];
        //ジャグ配列の宣言
        int[][] dp = new int[110][]; 
        for(int i = 0; i < dp.Length; i++)
        {
            dp[i] = new int[10010];
        }
        
        int[] weight = new int[110];
        int[] value = new int[110];
        
        for(int i = 0; i < N; i++)
        {
            int[] b = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();
            value[i] = b[0];
            weight[i] = b[1];
        }
        
        //dp初期化
        for(int w = 0; w < W; w++)
        {
            dp[0][w] = 0;
        }
        
        for(int i = 0; i < N; i++)
        {
            for(int w = 0; w <= W; w++)
            {
                if(w >= weight[i]) dp[i + 1][w] = Math.Max(dp[i][w - weight[i]] + value[i], dp[i][w]);
                else  dp[i + 1][w] = dp[i][w];
            }
        }
        
        Console.WriteLine(dp[N][W]);
    }
}



Measured memory_bytes: 22360
import math

if __name__ == '__main__':
    n = int(input())
    t, a = map(int, input().split())
    h = map(int, input().split())

    diff = 0
    answer = -1
    first = True

    for index, height in enumerate(h):
        temp = t - height * 0.006
        current_diff = math.fabs(a - temp)
        #print(index, temp, current_diff)

        if current_diff <= diff or first:
            diff = current_diff
            answer = index
            first = False

    print(answer+1)


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



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  ll ok=0,ng=2e5+7;
  auto check=[&](ll b){
    ll tm=0;
    rep(i,n){
      auto lb=lower_bound(all(a),b-a[i]);
      ll ttm=(a.end()-lb);
      tm+=ttm*2;
      //if(lb!=a.end()&&*lb<=a[i])tm--;
    }

    return tm/2>=m;
  };
  while(abs(ok-ng)>1){
    ll nn=(ok+ng)/2;
    if(check(nn))ok=nn;
    else ng=nn;
  }
  ll res=0;
  vector<ll>sa(n+1);
  rep(i,n)sa[i+1]=sa[i]+a[i];
  ll cnt=0;
  rep(i,n){
    auto lb=lower_bound(all(a),ng-a[i]);
    res+=(a.end()-lb)*a[i]*2;
    cnt+=a.end()-lb;
  }
  res+=(m-cnt)*ok;
  cout<<res<<endl;





  return 0;

}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;

    ll N, K;
    cin >> N >> K;
    vector<pll> P;
    for(i = 0; i < K; i++) {
        ll l, r;
        cin >> l >> r;
        P.push_back(pll(l, r));
    }
    vll C(N, 0);
    C[0] = 1;
    C[1] = -1;
    ll c = 0;
    for(i = 0; i < N; i++) {
        c = (c + C[i]) % MOD;
        for(j = 0; j < K; j++) {
            ll l = P[j].first;
            ll r = P[j].second;
            if(i + l < N) {
                C[i + l] = (C[i + l] + c) % MOD;
            }
            if(i + r + 1 < N) {
                C[i + r + 1] = (C[i + r + 1] + MOD - c) % MOD;
            }
        }
    }
    cout << c << endl;

    return 0;
}


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

int main() {
    int n, x;
    cin >> n;
    char com[20];
    list<int> v;
    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'i') {
            cin >> x;
            v.push_front(x);
        } else if (com[6] == 'F') {
            v.pop_front();
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[0] == 'd') {
            cin >> x;
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) cout << " ";
        cout << *it;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 34340
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	if (A + B >= 10) {
		cout << "error" << endl;
	} else {
		cout << A + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n, m, _;
  cin >> n >> m >> _;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) cin >> s[i];
  vector<vector<int>> columns(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') {
        columns[i].push_back(j);
      }
    }
  }

  vector<int> rows;
  for (int i = 0; i < n; ++i) {
    if (columns[i].size() > 0) {
      rows.push_back(i);
    }
  }

  int curColor = 0;

  vector<vector<int>> result(n, vector<int>(m));

  for (int i = 0; i < rows.size(); ++i) {
    int leftRow = (i == 0) ? 0 : rows[i - 1] + 1;
    int rightRow = (i == rows.size() - 1) ? n - 1 : rows[i];

    const auto& cols = columns[rows[i]];
    for (int j = 0; j < cols.size(); ++j) {
      int leftCol = (j == 0) ? 0 : cols[j - 1] + 1;
      int rightCol = (j == cols.size() - 1) ? m - 1 : cols[j];

      curColor++;
      for (int r = leftRow; r <= rightRow; ++r) for (int c = leftCol; c <= rightCol; ++c) {
        result[r][c] = curColor;
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (j != 0) cout << " ";
      cout << result[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main()
{
	int i, N;
	char S[4001];
	scanf("%d", &N);
	scanf("%s", S);
	
	long long R = 0, G = 0, B = 0, ans = 0;
	for (i = 0; i < N; i++) {
		if (S[i] == 'R') {
			ans += G * B;
			R++;
		} else if (S[i] == 'G') {
			ans += B * R;
			G++;
		} else {
			ans += R * G;
			B++;
		}
	}
	
	int j;
	for (i = 0; i < N; i++) {
		for (j = 1; j < (N - i + 1) / 2; j++) {
			if (S[i] != S[i+j] && S[i+j] != S[i+j*2] && S[i+j*2] != S[i]) ans--;
		}
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1716
#include <iostream>

using namespace std;

struct node {int p=-1, l=-1, r=-1, s=-1, deg=-1, dep=-1, h=-1;};
node T[25];

void print(int n){
    for(int i=0;i<n;i++){
        cout << "node " << i;
        cout << ": parent = " << T[i].p;
        cout << ", sibling = " << T[i].s;
        cout << ", degree = " << T[i].deg;
        cout << ", depth = " << T[i].dep;
        cout << ", height = " << T[i].h;
        if(T[i].dep==0){
            cout << ", root" << endl;
        }
        else if(T[i].h==0){
            cout << ", leaf" << endl;
        }
        else{
            cout << ", internal node" << endl;
        }
    }
}

int heightdetect(int id, int h){
    int left = T[id].l;
    int right = T[id].r;
    if(left==-1&&right==-1) return h;
    else if(left==-1) return heightdetect(right, h+1);
    else if(right==-1) return heightdetect(left, h+1);
    //else return (heightdetect(right, h+1)>heightdetect(left, h+1))?heightdetect(right, h+1):heightdetect(left, h+1);
    else return max(heightdetect(right, h+1), heightdetect(left, h+1));
}

void rec1(int n){
    for(int i=0;i<n;i++){
        int par = T[i].p;
        int d = 0;
        while(par!=-1){
            par = T[par].p;
            d++;
        }
        T[i].dep = d;
    }
}

void rec2(int n){
    for(int i=0;i<n;i++){
        T[i].h = heightdetect(i, 0);
    }
}

int main(){
    int n, id, left, right, root;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> id >> left >> right;
        if(left<0&&right<0){
            T[id].deg = 0;
        }
        else if(left<0||right<0){
            T[id].deg = 1;
        }
        else{
            T[id].deg = 2;
        }
        T[id].r = right;
        T[id].l = left;
        if(left!=-1) T[left].s = right;
        if(right!=-1) T[right].s = left;
        if(left!=-1) T[left].p = id;
        if(right!=-1) T[right].p = id;
    }
    
    rec1(n);
    rec2(n);

    print(n);

    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
//int P[1010],L[1010],R[1010],H[1010],C=1;
int P[4][1010],C=1,H[1010];
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(N[i],s);}
int h(int a){return H[P[2][a]]-H[P[1][a]];}
void rotl(int a){
  int b=P[1][a],r=P[0][a];
  P[1][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[2][b])P[0][P[2][b]]=a;
  P[1][a]=P[2][b];
  P[2][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[1][b]])+1;
}
void rotr(int a){
  int b=P[2][a],r=P[0][a];
  P[2][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[1][b])P[0][P[1][b]]=a;
  P[2][a]=P[1][b];
  P[1][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[2][b]])+1;
}
int mfind(char *x){
  int i,j,r,n;
  if(C==1){
    P[1][0]=C;
    //N[C]=x;
    strcpy(N[C],x);
    P[0][C++]=0;
    return 1;
  }
  for(i=1;r=hyouka(i,x);i=n){
    if(r<0){
      if(P[1][i]==0){
	P[1][i]=C;
	P[0][C]=i;
	H[i]=MAX(1,H[i]);
	//N[C]=x;
	strcpy(N[C],x);
	C++;
      }
      n=P[1][i];
    }
    else{
      if(P[2][i]==0){
	P[2][i]=C;
	P[0][C]=i;
	H[i]=MAX(1,H[i]);
	strcpy(N[C],x);
	//N[C]=x;
	C++;
      }
      n=P[2][i];
    }
  }//printf("%d\n",i);
  j=P[0][i];
  while(1){
    if(h(j)<-1){
      if(h(P[1][j])>0)rotl(P[1][j]);
      rotr(j);
      break;
    }
    if(h(j)>1){
      if(h(P[2][j])<0)rotr(P[2][j]);
      rotl(j);
      break;
    }
    if(h(j)==0)break;
    j=P[0][j];
    if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
}

Measured memory_bytes: 564
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int frq[50];
int main(){
	Lancer();
	ll n, m, k, a,res=0;
	cin >> n >> m;
	for (int i = 0; i < n;i++){
		cin >> k;
		for (int j = 0; j < k; j++){
			cin >> a;
			frq[a]++;
		}
	}
	for (int i = 1; i <= m; i++){
		if (frq[i] == n)
			res++;
	}
	cout << res;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mod 1000000007
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<ll>dp(3);
    for(ll d=0;d<n;d++)
    {
        vector<ll>ndp(3,0);
        vector<ll>c(3);
        rep(i,0,3)
        {
            cin>>c[i];
        }
        rep(i,0,3)
        {
            rep(j,0,3)
            {
                if(i!=j)
                {
                    ndp[j]=max(ndp[j],c[j]+dp[i]);
                }

            }

        }
         dp=ndp;
    }
   cout<<max(dp[0],max(dp[1],dp[2]));
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b=0,c=0,d[110];
  cin >>a>>b;
  for(int n=0;n<a;n++){
    cin >>d[n];
  }
  sort(d,d+a);
  for(int n=0;n<a;n++){
    if(b-d[n]>=0) b-=d[n],c++;
    else break;
  }
  while(1){
    if(b-d[0]>=0) b-=d[0],c++;
    else break;
  }
  cout <<c<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int X, Y;

signed main(void) {
    cin>>X>>Y;

    int t=X;
    int ans=0;
    while(t<=Y) {
        t*=2;
        ans++;
        cerr<<t<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	// your code goes here
	int m;
	cin >> m;
	int five_h=m/500;
	m%=500;
	int five=m/5;
	cout << (five_h*1000)+(five*5) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string f;
	cin >> f;
	map<string,bool> M;
	char pre = f[SZ(f) - 1];
	M[f] = true;
	FOR(i, 1, N) {
		string s;
		cin >> s;
		if (pre != s[0] || M[s]) {
			cout << "No" << endl;
			PAU;
			return 0;
		}
		M[s] = true;
		pre = s[SZ(s) - 1];
	}
	cout << "Yes" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

c_p = 0
c_q = 0
count = 0
for i in itertools.permutations(sorted(p),len(p)):

    if p == list(i):
        c_p = count
    if q == list(i):
        c_q = count
    count += 1

print(abs(c_p - c_q))

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>

int main()
{
    int H, W;
    std::cin >> H >> W;

    std::vector<std::vector<int>> A(H, std::vector<int>(W));

    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            std::cin >> A[h][w];
        }
    }

    int cnt = 0;
    std::vector<int> ope;
    for (int h = 0; h < H - 1; h++)
    {
        for (int w = 0; w < W; w++)
        {
            if (A[h][w] % 2 == 1)
            {
                cnt++;
                ope.emplace_back(h + 1);
                ope.emplace_back(w + 1);
                ope.emplace_back(h + 1 + 1);
                ope.emplace_back(w + 1);
                A[h][w]--;
                A[h + 1][w]++;
            }
        }
    }

    int h = H - 1;
    for (int w = 0; w < W - 1; w++)
    {
        if (A[h][w] % 2 == 1)
        {
            cnt++;
            ope.emplace_back(h + 1);
            ope.emplace_back(w + 1);
            ope.emplace_back(h + 1);
            ope.emplace_back(w + 1 + 1);
            A[h][w]--;
            A[h][w + 1]++;
        }
    }
    std::cout << cnt << std::endl;

    for (int i = 0; i < ope.size(); i++)
    {
        std::cout << ope[i];
        if ((i + 1) % 4 == 0)std::cout << std::endl;
        else std::cout << " ";
    }
    std::cout << std::endl;
    return 0;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

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

int main() {
    ll i, j, k;
    string s, ans = "";
    cin >> s;
    for(auto c : s) {
        if(c != 'B') {
            ans += c;
        } else {
            if(ans.length() > 0) {
                ans = ans.substr(0, ans.length() - 1);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP(i, N) {
        cin >> V[i];
    }
    int R = min(N, K);
    int res = 0;
    REP(a, R + 1) {
        REP(b, R - a + 1) {
            int sum = 0;
            priority_queue<int> que;
            REP(i, a) {
                sum += V[i];
                que.push(-V[i]);
            }
            REP(i, b) {
                sum += V[N - 1 - i];
                que.push(-V[N - 1 - i]);
            }
            if (que.empty()) {
                continue;
            }
            REP(i, K - a - b) {
                if (que.empty()) {
                    break;
                }
                int v = -que.top();
                que.pop();
                if (v >= 0) {
                    break;
                }
                sum -= v;
            }
            amax(res, sum);
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <queue>
#include <vector>

#define rep(i,min,max) for(int i=min;i<max;i++)
#define rrep(i,min,max) for(int i=max;i>=min;i--)

using namespace std;

int main(){
  int a, b;
  int ans = 0;
  cin >> a >> b;
  
  if(a > b)
    ans += a--;
  else
    ans += b--;  
  if(a > b)
    ans += a--;
  else
    ans += b--;

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define MAXN 105

int a[MAXN], sum;
int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum += a[i]; 
	}
	std::sort(a+1, a+1+n);
	for(int i = 1; i <= n; i++) {
		if(sum % 10 != 0) {
			printf("%d", sum);
			return 0;
		}else if(a[i] % 10 == 0) 
			continue; 
		else if(a[i] % 10 != 0)
			sum -= a[i];
	}
	printf("0");
	return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        FOR(i,0,n)
            cin >> A[i];
        sort(ALL(A)); vector<PII> step;
        if (A.size() == 2) {
            const int x = A[1];
            const int y = A[0];
            A[n-1] = x-y;
            step.push_back(PII(x,y));
        }
        else if (A[n-1] > 0) {
            int j = 1;
            while (j < n-1 && A[j] < 0)
                j++;
            FOR(k,j,n-1) {
                const int x = A[0];
                const int y = A[k];
                A[0] = x-y;
                step.push_back(PII(x,y));
            }
            FOR(i,0,j) {
                const int x = A[n-1];
                const int y = A[i];
                A[n-1] = x-y;
                step.push_back(PII(x,y));
            }
        }
        else {
            const int x = A[n-1];
            const int y = A[n-2];
            A[n-1] = x-y;
            step.push_back(PII(x,y));
            FOR(i,0,n-2) {
                const int x = A[n-1];
                const int y = A[i];
                A[n-1] = x-y;
                step.push_back(PII(x,y));
            }
        }
        cout << A[n-1] << endl;
        FOR_ALL(x,step)
            cout << x->first << ' ' << x->second << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> s(h);
  for(auto&& e: s) 
  {
    cin>>e;
  }
  vector<vector<int>> number(h,vector<int>(w,0));
  int cnt=1;
  
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      number[i][j]=cnt;
      if(s[i][j]=='#') cnt++;
    }
    if(s[i][w-1]=='.')
    {
      for (int j = 0; j < w; ++j)
      {
        if(number[i][j]==cnt) number[i][j]--;
      }
    }
    cnt=number[i][w-1]+1;
  }

  vector<int> no_hash;
  for (int i = 0; i < h; ++i)
  {
    bool flag=true;
    for (int j = 0; j < w; ++j)
    {
      if(s[i][j]=='#') flag=false; 
    }
    if(flag)
    {
      no_hash.push_back(i);
    }
  }
  if(!no_hash.empty() && *no_hash.rbegin()==h-1)
  {
    int tmp=h-1;
    while(tmp!=0)
    {
      tmp--;
      if(!binary_search(no_hash.begin(), no_hash.end(),tmp))
      {
        break;
      }
    }
    while(tmp!=h-1)
    {
      tmp++;
      for (int j = 0; j < w; ++j)
      {
        number[tmp][j]=number[tmp-1][j];
      }
    }
  }

  for (int i = 0; i < no_hash.size(); ++i)
  {
    int tmp=no_hash[i];
    while(tmp!=h-1)
    {
      tmp++;
      if(!binary_search(no_hash.begin(), no_hash.end(),tmp))
      {
        break;
      }
    }
    while(tmp!=no_hash[i])
    {
      tmp--;
      for (int j = 0; j < w; ++j)
      {
        number[tmp][j]=number[tmp+1][j];
      }
    }
  }


  //output
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      cout<<number[i][j]<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;

int main() {
	int j = 0, k = 0, l = 0, m = 0;
	for (int i = 0; i < 4; i++) {
		int a;
		cin >> a;
		if (a == 1)j++;
		else if (a == 9)k++;
		else if (a == 7)l++;
		else if (a == 4)m++;
	}
	if (j == 1 && k == 1 && l == 1 && m == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+9;
const int MOD = 2;

int n;
int a[N], b[N];

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

    for(int i = n; i >= 1; i--) {
        b[i] = a[i];
        for(int j = 2*i; j <= n; j += i) {
            b[i] -= b[j];
            b[i] = (b[i] + MOD) % MOD;
        }
    }

    vector<int> ans;
    for(int i = 1; i <= n; i++)
        if(b[i] == 1)  ans.push_back(i);

    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++)
        cout << ans[i] << (i == ans.size()-1 ? "\n" : " ");
}

Measured memory_bytes: 3064
import sys
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10 ** 9 + 7
def LI(): return map(int, sys.stdin.readline().split())

def main():
    n, k = LI()
    g = [[] for i in range(n+1)]
    for i in range(n-1):
        a, b = LI()
        g[a].append(b)
        g[b].append(a)

    s = 1
    Q = deque([s])
    ans = k
    Qappend = Q.append
    searched = [0] * (n+1)
    searched[s] = 1
    Qp = Q.popleft
    cand = k - 1
    while Q:
        temp = 1
        v = Qp()
        for i in g[v]:
            if searched[i] == 1:
                continue
            searched[i] = 1
            temp = temp * cand % MOD
            cand -= 1
            Qappend(i)
        ans = ans * temp % MOD
        cand = k - 2
    print(ans % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23824
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define ll long long 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second

using namespace std;

int n , w;
vvi v(110 , vi(4));

ll dp[110][100010];

ll solve(int i , int wt ){

	if(wt ==0 || i ==n+1)return 0;

	if(dp[i][wt] != -1)return dp[i][wt];

	if(v[i][1] > wt) return dp[i][wt]=solve(i+1 , wt);

 
    return dp[i][wt]= max(	v[i][2] + solve( i+1 , wt - v[i][1]) ,solve(i+1 , wt) );
	
}

int main(){   

fastio
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt","w", stdout);
// #endif

cin>>n>>w;
for(int i =1; i<=n ; i++)cin>>v[i][1]>>v[i][2];

memset(dp ,-1, sizeof(dp));
cout<<solve(1 , w);


return 0;
}


Measured memory_bytes: 86272
from sys import stdin
s = list(map(int, list(stdin.readline().rstrip())))
ans_list = [0, 1] * (len(s) // 2)
if len(s) % 2 == 1: ans_list.append(0)
count = 0
for i, ans in zip(s, ans_list):
    if i != ans:
        count += 1
print("{}".format(min(count, len(s) - count)))

Measured memory_bytes: 49400
n = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
for p in range(1,4):
    print("{0:.6f}".format(sum([abs(a-b)**p for a,b in zip(X,Y)])**(1/p)))
print("{0:.6f}".format(max([abs(a-b) for a,b in zip(X,Y)])))


Measured memory_bytes: 5656
import sys
input = sys.stdin.readline

N,M=map(int,input().split())

EIN=[0]*N
EOUT=[0]*N

EINLIST=[[] for i in range(N)]
EOUTLIST=[[] for i in range(N)]

for i in range(M):
    x,y=map(int,input().split())
    x-=1
    y-=1

    EOUT[x]+=1
    EIN[y]+=1

    EOUTLIST[x].append(y)
    EINLIST[y].append(x)

from collections import deque

Q=deque()
USE=[1]*N

for i in range(N):
    if EIN[i]==0 or EOUT[i]==0:
        Q.append(i)
        USE[i]=0

while Q:
    x=Q.pop()

    for to in EOUTLIST[x]:
        if USE[to]==0:
            continue
        EIN[to]-=1
        if EIN[to]==0:
            Q.append(to)
            USE[to]=0

    for fr in EINLIST[x]:
        if USE[fr]==0:
            continue
        EOUT[fr]-=1
        if EOUT[fr]==0:
            Q.append(fr)
            USE[fr]=0
            
def loopfind():
    for i in range(N):
        if USE[i]==1:
            break
    else:
        return []
    
    Q=deque()
    Q.append(i)
    USESET={i}
    ANS=[i]

    while True:
        for to in EOUTLIST[ANS[-1]]:
            if USE[to]==1:
                nextv=to
                break

        if nextv in USESET:
            break
        else:
            ANS.append(nextv)
            USESET.add(nextv)

    x=ANS.index(nextv)
    return ANS[x:]
        

def shortcut(ANS):
    #print(ANS)

    ANSSET=set(ANS)
    LEN=len(ANS)
    flag=0

    for i in range(LEN):
        for to in EOUTLIST[ANS[i]]:
            if to in ANSSET and ANS[(i+1)%LEN]!=to:
                flag=1
                x=ANS.index(to)

                #print(ANS,i,x)

                break
        if flag:
            break
    #print(flag)

    if flag:
        if x<i:
            return shortcut(ANS[x:i+1])
        else:
            return shortcut(ANS[x:]+ANS[:i+1])

    else:
        return ANS

ANS=shortcut(loopfind())
if len(ANS)==0:
    print(-1)
else:
    print(len(ANS))
    for ans in ANS:
        print(ans+1)
        


Measured memory_bytes: 3828
#include <stdio.h>

int main(){
    int n[100];//要素数100のn
    int a;  //入力する要素数
    scanf("%d",&a);
    for(int i=0;i<a;i++){
        scanf("%d",&n[i]);
    }
    for(int i=a-1;i>0;i--){
        printf("%d ",n[i]);
    }printf("%d",n[0]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

/*
struct Edge{
    int u,v,weight;
    bool operator<(Edge const& other) {
        return weight<other.weight;
    }
};

vector<int> parent,rank;

void make_set(int v) {
    parent[v]=v;
    rank[v]=0;
}

int find_set(int v) {
    if(v==parent[v])
        return v;
    return parent[v]=find_set(parent[v]);
}

void union_sets(int a,int b) {
    a=find_set(a);
    b=find_set(b);
    if(a!=b){
        if(rank[a]<rank[b])
            swap(a,b);
        parent[b]=a;
        if(rank[a]==rank[b])
            rank[a]++;
    }
}*/

/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2; p*p<=n; p++)
        if (prime[p] == true)
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/

int solve(){
    int n;
    cin>>n;
	string al="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string s;
	cin>>s;
	rep(i,0,s.length()){
		int a=((s[i]-'A')+n)%26;
		cout<<al[a];
	}
	cout<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=1, tail, n;

void enqueue(P x){
Q[tail] = x;
if(tail+1 == LEN)tail = 0;
else tail++;
}

P dequeue(){
  P x;
x = Q[head];
if(head+1 ==LEN)head=0;
else head++;
return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  // P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  tail = n+1;
  while(1){
    if(Q[head].t <= q){
      elaps += Q[head].t;
      printf("%s %d\n", Q[head].name, elaps);
                  dequeue();
                  c++;
                  if (c == n) break;
              } else {
                  Q[head].t -= q;
                  elaps += q;
                  enqueue(dequeue());
              }
          }
  return 0;
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll gcd(ll a, ll b) {
    ll tmp;
    while (b) {
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}
ll lcm (ll a, ll b) {
    return a / gcd(a, b) * b;
}
/* main */
int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) a[i] /= 2;
    ll b = 1;
    for (int i = 0; i < N; i++) {
        b = lcm(b, a[i]);
    }
    for (ll ai : a) {
        if ((b / ai) % 2) continue;
        cout << 0 << '\n';
        return 0;
    }

    ll ans = (M / b + 1) / 2;
    cout << ans << '\n';
}


Measured memory_bytes: 1152
import java.util.*;
import java.io.*;

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		HashMap<String, Integer> map  = new HashMap<>(); 
		int a = in.readInt();
		for(int i = 0; i<a; i++) {
			String key = in.readString(); 
			if(map.containsKey(key)) {
				map.put(key, map.get(key)+1); 
			}
			else map.put(key, 1); 
		}
		int b = in.readInt(); 
		for(int i = 0; i<b; i++) {
			String key = in.readString();
			if(map.containsKey(key)) 
				map.put(key, map.get(key)-1); 
			else map.put(key, 1); 
		}
		
		int max = Integer.MIN_VALUE; 
		for(Integer i : map.values()) {
			if(max < i) max =i; 
		}
		System.out.println(Math.max(0,max)); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21204
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int a, b;
	int cnt = 0;
	string tmp,rev;
	cin >> a >> b;
	int ad;
	while (a <= b) {
		ad = a;
		tmp = to_string(ad);
		rev = tmp;
		reverse(all(rev));
		if (tmp == rev)cnt++;
		a++;
	}
	cout << cnt << endl;
}



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

const int maxn = 4e3+5;
char s[maxn], t[maxn];
int n, m, dp[maxn][maxn], nxt[maxn][maxn], nxts[maxn][2], nxtt[maxn][2]; 

int solve(int i, int j){
	if (i == n+2 && j == m+2) return 0;
	if (dp[i][j] != -1) return dp[i][j];
	int ret = dp[i][j] = maxn;
	for(int x = 0; x<=1; x++) {
		ret = 1 + solve(nxts[i][x]+1, nxtt[j][x]+1);
		if (ret < dp[i][j]) dp[i][j] = ret, nxt[i][j] = x;
	}
	return dp[i][j];
}

void reconstruct(int i, int j){
	if (i == n+2 && j == m+2) return;
	int x = nxt[i][j];
	printf("%d", x);
	reconstruct(nxts[i][x]+1, nxtt[j][x]+1);
}

int main(){
	scanf("%s", s+1);
	scanf("%s", t+1);
	n = strlen(s+1), m = strlen(t+1);
	for(int x = 0; x<=1; x++) {
		nxts[n+1][x] = nxts[n+2][x] = n+1;
		nxtt[m+1][x] = nxtt[m+2][x] = m+1;
	}
	for(int i = n; i>=0; i--){ 
		for(int x = 0; x<=1; x++){
			nxts[i][x] = (s[i] == '0'+x) ? i : nxts[i+1][x];
		}
	}

	for(int i = m; i>=0; i--){
		for(int x = 0; x<=1; x++){
			nxtt[i][x] = (t[i] == '0'+x) ? i : nxtt[i+1][x];
		}
	}

	memset(dp, -1, sizeof(dp));
	solve(0, 0);
	reconstruct(0, 0);
	puts("");
	return 0;
}


Measured memory_bytes: 114008
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string a,b,c;
	cin>>a>>b;
	int l1=a.size();
	int l2=b.size();
	for(int i=0;i<min(l1,l2);i++)
	{
		cout<<a[i]<<b[i];
	}
	if(l1>l2) 
	{
		for(int i=l2;i<l1;i++) cout<<a[i];
	}
	else
	{
		for(int i=l1;i<l2;i++) cout<<b[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int a,b;cin >> a>> b;
  cout << a-b+ 1<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,x,y=0,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1;
    cin>>n;
    ll ar[n];
    rep(i,0,n)
    cin>>ar[i];
    ll dp[n+1][2]; // 0 denotes multiplied by -1 and 1 not
    dp[0][0]=0;
    dp[0][1]=0;
    dp[1][0]=-1*ar[0];
    dp[1][1]=ar[0];
    rep(i,2,n)
    {
        dp[i][0]=max(dp[i-1][0]+ar[i-1],dp[i-1][1]-ar[i-1]); // This means we are multiplying the i and i-1 by -1
        dp[i][1]=max(dp[i-1][1]+ar[i-1],dp[i-1][0]-ar[i-1]);
    }
    dp[n][1]=max(dp[n-1][1]+ar[n-1],dp[n-1][0]-ar[n-1]);
    cout<<dp[n][1];


}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 2560
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,a,b;
	string s;
	cin>>a>>b;
	if(a%500<=b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}








Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100],t[100];
	int a,i,x=0,y=0,j,c=0,n=0;
	scanf("%s",s);
	a=strlen(s);
	x=(a-1)/2; y=(a+3)/2;
	for(i=0;i<x;i++) if(s[i]!=s[a-1-i]) n=1;
	if(n==1) printf("No\n");
	else{
		for(i=0;i<x;i++){
				if(s[i]!=s[x+1+i]) c=1;
		}
		if(c!=1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1612
#include <bits/stdc++.h>
#define SIZE 200105
#define INF 100000000000LL
using namespace std;
typedef long long ll;
int n;
ll ara[SIZE];

ll f(ll b){
	ll sum=0;
	for(int i=1; i<=n; i++){
		sum+=abs(ara[i]-(b+i));
	}
	return sum;
}

ll ternary_search(){
	ll high=INF;
	ll low=-INF;
	ll mid;
	while(high>low){
		mid=(high+low)>>1;
		if(f(mid+1)<f(mid)) low=mid+1;
		else high=mid;
	}
	return f(high);
}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%lld", &ara[i]);
	printf("%lld\n", ternary_search());
	return 0;
}


Measured memory_bytes: 1792