akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
ll n,ar[N][3],dp[N][4];
ll maxval(ll i,ll last_use){
	if(i>n){
		return 0;
	}
	if(dp[i][last_use]!=-1){
		return dp[i][last_use];
	}
	ll a,b;
	if(last_use==1){
		a=maxval(i+1,2)+ar[i][1];
		b=maxval(i+1,3)+ar[i][2];
	}
	else if(last_use==2){
		a=maxval(i+1,1)+ar[i][0];
		b=maxval(i+1,3)+ar[i][2];
	}
	else {
		a=maxval(i+1,2)+ar[i][1];
		b=maxval(i+1,1)+ar[i][0];
	}
	return dp[i][last_use]=max(a,b);
}
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(i=1;i<=n;i++){
		cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
	}

	k=max(maxval(2,1)+ar[1][0],max(maxval(2,2)+ar[1][1],maxval(2,3)+ar[1][2]));
	cout<<k;
	return 0;
}


Measured memory_bytes: 21888
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int N = 1e5 + 10;
const ll inf = 5e18;
std::unordered_map<ll, ll> mp;

ll res, flag = 10;
ll weight[102], val[102], dp[102][N];

ll go(ll idx ,ll pic ,ll n, ll w){
	if(idx == n + 1) return 0;
	if(dp[idx][pic] != -1) return dp[idx][pic];
	ll xx = -inf, yy = -inf;
	if(pic + weight[idx] <= w) xx = val[idx] + go(idx + 1, pic + weight[idx], n, w);
	yy = go(idx + 1, pic, n, w);
	return dp[idx][pic] = max(xx, yy);
}

void solve() {
	ll n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; ++i){
		cin >> weight[i] >> val[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << go(1, 0, n, w);

}

int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while(t--){  
    solve();
  }
    return 0;
}

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

int main() {
	int a;
	cin >> a;
	string s;
	cin >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	xx := make([]int, n)
	yy := make([]int, n)
	for i := 0; i < n; i++ {
		xx[i] = getNextInt(scanner)
		yy[i] = getNextInt(scanner)
	}

	var ans float64
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			ans += math.Sqrt(math.Pow(float64(xx[i]-xx[j]), 2) + math.Pow(float64(yy[i]-yy[j]), 2))
		}
	}
	fmt.Fprintln(writer, ans*2/float64(n))
}


Measured memory_bytes: 640
//============================================================================
// Name        : alds1_5_c_KochCurve.cpp
// Author      : lovesaemi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

struct Point {
	double x, y;
};
void koch(int n, Point a, Point b) {
	if (n == 0)
		return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main() {
	Point a, b;
	int n;
	scanf("%d", &n);
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}



Measured memory_bytes: 3196
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB=sorted(AB,key=lambda x:x[0])
lst=[]
heapify(lst)
st=1
value=0
idx=0
#print(AB)
while st<=M:
    #print(value)
    while idx<N and AB[idx][0]==st:
        heappush(lst,-AB[idx][1])
        idx+=1
    if lst:
        value-=heappop(lst)
    st+=1
print(value)


Measured memory_bytes: 82392
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <cstring>
#include <list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
static const double EPS = 1e-5;
static const int INFTY = (1<<21);
static const ll LLINFTY = (1LL<<53);
#define REP(i,m,n) for(i=m;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define out(a,b) (a<0||a>=b)
struct node{
  int tx,ty;
  int kx,ky;
  int c;
  int mini;
  node(){}
  node(int a,int b,int c_,int d,int e):tx(a),ty(b),kx(c_),ky(d),c(e),
  mini((abs(a-c_)+abs(b-d))*2){}
  bool operator>(const node& e)const{
    //return c+mini>e.c+e.mini;
    return c>e.c;
  }
};
bool used[50][50][50][50];
int dx[]={0,1,0,-1};
int dy[]={0,-1,0,1};
int main(void)
{
  int w,h,i,j,ii,jj;
  int tx,ty,kx,ky;
  int g[50][50];
  node p;
  for(;;){
    scanf("%d%d",&w,&h); if(!w)break;
    scanf("%d%d%d%d",&tx,&ty,&kx,&ky); tx--; ty--; kx--; ky--;
    rep(i,h)rep(j,w){
      scanf("%d",g[i]+j);
      rep(ii,h)rep(jj,w)used[i][j][ii][jj]=false;
    }
    priority_queue<node,vector<node>,greater<node> >q;
    q.push( node(tx,ty,kx,ky,0) );
    used[ty][tx][ky][kx]=true;
    while( !q.empty() ){
      p=q.top(); q.pop();
      if(p.tx==p.kx && p.ty==p.ky){
        printf("%d\n",p.c);
        goto END;
      }
      rep(i,4){
        tx=p.tx+dx[i]; ty=p.ty+dx[3-i];
        kx=p.kx+dy[i]; ky=p.ky+dy[3-i];
        if(out(tx,w)||out(ty,h)||g[ty][tx])tx=p.tx,ty=p.ty;
        if(out(kx,w)||out(ky,h)||g[ky][kx])kx=p.kx,ky=p.ky;
        if(!used[ty][tx][ky][kx]){
          used[ty][tx][ky][kx]=true;
          q.push(node(tx,ty,kx,ky,p.c+1));
        }
      }
    }
    puts("NA");
  END:;
  }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R PI = acos(-1.0);
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

int main(void) {
	ll sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	if (sx == tx) {
		if (sy > ty) swap(sy, ty);
		bool flag = false;

		int n;
		cin >> n;

		rep(i, n) {
			ll x, y;
			cin >> x >> y;
			if (sx == x and sy <= y and y <= ty) flag = true;
		}

		R ans = 100.0 * abs(ty - sy);
		if (flag) ans += 10.0 * PI - 20.0;
		cout.precision(20);
		cout << fixed << ans << endl;
		return 0;
	}

	if (sy == ty) {
		if (sx > tx) swap(sx, tx);
		bool flag = false;

		int n;
		cin >> n;

		rep(i, n) {
			ll x, y;
			cin >> x >> y;
			if (sy == y and sx <= x and x <= tx) flag = true;
		}

		R ans = 100.0 * abs(tx - sx);
		if (flag) ans += 10.0 * PI - 20.0;
		cout.precision(20);
		cout << fixed << ans << endl;
		return 0;
	}


	if (sy > ty) {
		swap(sx, tx);
		swap(sy, ty);
	}

	bool flip = false;
	if (sx > tx) {
		flip = true;
		sx = -sx, tx = -tx;
	}

	R ans = 100.0 * (abs(sx - tx) + abs(sy - ty));

	using pll = pair<ll, ll>;
	vector<pll> ary;

	int n;
	cin >> n;

	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		if (flip) x = -x;
		if (sx <= x and x <= tx and sy <= y and y <= ty) {
			ary.push_back(pll(y, x));
		}
	}

	const int m = ary.size();
	sort(begin(ary), end(ary));

	const int inf = 1 << 30;
	vector<int> dp(m + 1, inf);

	for (auto &it : ary) *lower_bound(begin(dp), end(dp), it.second) = it.second;
	const ll num = lower_bound(begin(dp), end(dp), inf) - begin(dp);
	ans -= 20.0 * num;
	ans += 5.0 * PI * num;

	if (num == min(ty - sy + 1, tx - sx + 1)) ans += 5.0 * PI;

	cout.precision(20);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 6256
import java.util.*;

class Main {

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

	public static void main(String[] args) {
      int N =sc.nextInt();
      long A[] = new long[N];
      for(int i=0;i<N;i++){
        A[i] = sc.nextLong();
      }
      Arrays.sort(A);
      long ans = 1;
      for(int i=0;i<N;i++){
        if(ans==0) break;
        if(A[i]>(long)Math.pow(10,18)/ans){
          ans = -1;
          break;
        }
        ans*=A[i];
      }
      System.out.println(ans);
	}
}

Measured memory_bytes: 61460
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> a;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
/*
	专 业 爆 搜
			--InterestingLSY 
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF 9999999
#define LINF 9999999999999999
#define SINF "%"
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll long long
#define ull unsigned ll
#define uchar unsigned char
#define sint short int
#define usint unsigned sint
#define xsize(a) sizeof(a)/1024/1024
#define fr(aaaaa,bbbbb) for(aaaaa = 1;aaaaa <= bbbbb;aaaaa++)
#define frr(aaaaa,bbbbb,ccccc) for(aaaaa = ccccc;aaaaa <= bbbbb;aaaaa++)
using namespace std;
#define MAXN 100100

char s[MAXN];
int n;
string ss[5];
int lens[5];

bool kmp(int pos,int id){
	for(int i = 0;i < lens[id];i++){
		if(s[pos+i] != ss[id][i])
			return 0;
	}
	return 1;
}

bool dp[MAXN];
bool vis[MAXN];
bool dfs(int pos){
	if(vis[pos]) return dp[pos];
	vis[pos] = 1;
	if(pos == n) return 1;
	bool ans = 0;
	for(int i = 1;i <= 4;i++)
		if(pos + i < n  &&  kmp(pos,i)){
			ans = dfs(pos + lens[i]);
			if(ans){
				dp[pos] = 1;
				return 1;
			}
		}
	dp[pos] = 0;
	return 0;
}

int main(){
	//freopen("C.txt","r",stdin);
	ms(vis);
	ss[1] = "dream"; ss[2] = "dreamer";
	ss[3] = "erase"; ss[4] = "eraser";
	for(int i = 1;i <= 4;i++)
		lens[i] = ss[i].length();
	
	scanf("%s",&s);
	n = strlen(s);
	
	if(dfs(0)) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
    using namespace std;
    
    
    int main(){
      int n , k , t;
      cin >> n >> k;
      double ans , temp;
      ans = 0;
      for(long i = 1 ; i <= n ; i++){
          temp = 1.0 / n;
          //cout << temp << endl;
          t = i;
          while(t < k){
              temp = temp / 2.0;
              t = t * 2;
          }
          ans += temp;
      }
      
      cout << setprecision(12) << ans << endl;
    
      return 0;
    }

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

vector<int> make(int n,int a,int b){
   if(n==1)return {a,b};
   int d=a^b,x=-1; rep(i,0,n)if(d>>i&1){x=i; break;}
   int ab=(a>>x&1)<<x,bb=(b>>x&1)<<x;
   int lb=((a>>(x+1))<<x)|(a&((1<<x)-1));
   int rb=((b>>(x+1))<<x)|(b&((1<<x)-1));
   auto v1=make(n-1,lb,lb^1),v2=make(n-1,lb^1,rb);
   vector<int> res(1<<n); int mask=(1<<x)-1;
   rep(i,0,1<<(n-1)){
      res[i]=((v1[i]>>x)<<(x+1))|(v1[i]&mask)|ab;
      res[i+(1<<(n-1))]=((v2[i]>>x)<<(x+1))|(v2[i]&mask)|bb;
   } return res;
}

int main(){
   int n,a,b; scanf("%d%d%d",&n,&a,&b);
   if(__builtin_popcount(a^b)%2==0)puts("NO");
   else{
      puts("YES");
      auto res=make(n,a,b);
      rep(i,0,1<<n)printf("%d\n",res[i]);
   }
   return 0;
}

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

int main()
{
	int m,d;
	int months[]={31,29,31,30,31,30,31,31,30,31,30,31};
	string days[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};

	while(cin>>m>>d,m)
	{
		int mm=0,cnt=0;
		while(1)
		{
			if(mm+1<m)
			{
				cnt+=months[mm++];
				continue;
			}
			cnt+=d;
			break;
		}
		cout<<days[cnt%7]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
 
int main() {
    int d[101][101] = { 0 };
    int c, r, i, j;
    scanf("%d%d", &c, &r);
    for (i = 0; i < c; i++) {
        for (j = 0; j < r; j++) {
            scanf("%d", &d[i][j]);
            d[i][r] += d[i][j];
            d[c][j] += d[i][j];
        }
        d[c][r] += d[i][r];
    }
    for (i = 0; i < c + 1; i++)
        for (j = 0; j < r + 1; j++)
            printf("%d%c", d[i][j],j<r?' ':'\n');
    return 0;
}


Measured memory_bytes: 2036
# -*- coding: utf-8 -*-

S = input().strip()

max_cnt=0
cnt=0
for i in range(len(S)):
    
    if S[i] in "ACGT":
        cnt += 1
    else:
        max_cnt = max(max_cnt,cnt)
        cnt = 0

max_cnt = max(max_cnt,cnt)
print(max_cnt)


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

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  string t ="";
  t+=s[0];
  char cur = s[0];
  
  for(int i = 1;i<n;i++){
    if(s[i]!=cur){
      t+=s[i];
      cur = s[i];

    }
  }
  
  cout << t.size() << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	long A, B, C, K;
	cin >> A >> B >> C >> K;

	if( K%2 == 0 ) {
		cout << A-B << endl;
	}
	else {
		cout << B-A << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}


int main(){
	ll n;
	cin >> n;
	vector<ll> x(n),y(n);
	REP(i,n) cin >> x[i] >> y[i];
	
	/*
	|x0-x1| + |y0-y1|
	
	x0 - x1 + y0 - y1
	-x0 + x1 - y0 + y1
	x0 - x1 - y0 + y1
	-x0 + x1 + y0 - y1
	
	(x0+y0) - (x1+y1)
	-(x0+y0) + (x1+y1)
	(x0-y0) - (x1-y1)
	-(x0-y0) + (x1-y1)

	*/

	ll maxsum=-3*(ll)1e9, maxdiff=-3*(ll)1e9, minsum=3*(ll)1e9, mindiff=3*(ll)1e9;
	REP(i,n){
		chmax(maxsum, x[i]+y[i]);
		chmax(maxdiff, x[i]-y[i]);
		chmin(minsum, x[i]+y[i]);
		chmin(mindiff, x[i]-y[i]);
	}
	
	ll ans = 0;
	chmax(ans, maxsum - minsum);
	chmax(ans, maxdiff - mindiff);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6428
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
using namespace std;
int n;

int main(){
    cin >> n;
    pair<pair<string,int>,int> p[n];
    for(int i=0;i<n;i++){
        string s;
        int t;
        cin >> s;
        cin >> t;
        p[i] = make_pair(make_pair(s,-t),i+1);
    }
    sort(p,p+n);
    for(int i=0;i<n;i++){
        cout << p[i].second<<endl;
    }

}

Measured memory_bytes: 256
s = input()
n = [0] * len(s)
s += "R"

start = 0
for i in range(1, len(s)):
    if s[i-1] != s[i]:
        cnt = i - start
        if s[i-1] == "L":
            if cnt % 2 == 1: n[start] += 1
            n[start-1] += cnt // 2
            n[start] += cnt // 2
        else:
            if cnt % 2 == 1: n[i-1] += 1
            n[i-1] += cnt // 2
            n[i] += cnt // 2
        start = i
op = ""
for i in range(len(n)):
    if i != 0: op += " "
    op += str(n[i])
print(op)


Measured memory_bytes: 4468
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>

constexpr long long MOD = 1000000007;

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::string str;
  std::cin >> str;
  str[K - 1] = 'a' + (str[K - 1] - 'A');
  std::cout << str << std::endl;
  return 0;
}



Measured memory_bytes: 256
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

//const int N = 1e3+1;
//ll n,m,k,q;


int main(){

    string a,b;
    int n;
    cin>>n;
    cin>>a>>b;

    for(int i=0;i<n;i++){
        putchar(a[i]);
        putchar(b[i]);
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> H >> W;
    ll ans = H*W, rect1, rect2, rect3, diff;
    if(H%3 == 0 || W%3 == 0) ans = 0;
    rep(i, H+1){
        rect1 = i*W;
        rect2 = (H-i)*(W/2);
        rect3 = (H-i)*(W-W/2);
        diff = max(abs(rect1 - rect2), max(abs(rect2 - rect3), abs(rect3 - rect1)));
        ans = min(ans, diff);

        rect2 = ((H-i)/2)*W;
        rect3 = ((H-i)-(H-i)/2)*W;
        diff = max(abs(rect1 - rect2), max(abs(rect2 - rect3), abs(rect3 - rect1)));
        ans = min(ans, diff);
    }
    rep(i, W+1){
        rect1 = i*H;
        rect2 = (W-i)*(H/2);
        rect3 = (W-i)*(H-H/2);
        diff = max(abs(rect1 - rect2), max(abs(rect2 - rect3), abs(rect3 - rect1)));
        ans = min(ans, diff);

        rect2 = ((W-i)/2)*H;
        rect3 = ((W-i)-(W-i)/2)*H;
        diff = max(abs(rect1 - rect2), max(abs(rect2 - rect3), abs(rect3 - rect1)));
        ans = min(ans, diff);

    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<int> Edge[200005],vec;
int mark[200005];
void dfs(int u)
{
    vec.push_back(u);
    for(int i=0; i<Edge[u].size(); i++)
    {
        int v=Edge[u][i];
        if(mark[v]==0)
        {
            mark[v]=1;
            dfs(v);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n,k;
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        ll v;
        cin>>v;
        Edge[i].push_back(v);
    }
    mark[1]=1;
    dfs(1);
    ll len=vec.size();
    if(k<len)
    {
        cout<<vec[k]<<endl;
        return 0;
    }
    ll idx=Edge[vec[len-1]][0];
    memset(mark,0,sizeof(mark));
    vec.clear();
    k-=(len-1);
    mark[idx]=1;
    dfs(idx);
    len=vec.size();
    idx=k%len;
    idx--;
    if(idx==-1)
        idx=len-1;
    cout<<vec[idx]<<endl;


    return 0;
}


Measured memory_bytes: 24884
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
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){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int A,B,C,K; cin>>A>>B>>C>>K;
    int ans = 0;
  if(A>=K) ans = K; 
  else if(A+B>=K) ans = A;
    if(A+B<K) ans = A-min(K-A-B,C);
    Out(ans);
}

Measured memory_bytes: 3656
n=int(input())
l=list(map(int,input().split()))
s=[]
i=0
c=1
while True:
  if i==n-1:
    s.append(c)
    break
  if l[i]!=l[i+1]:
    s.append(c)
    c=0
  c+=1
  i+=1
ans=0
for i in s:
  ans+=i//2
print(ans)

Measured memory_bytes: 3064
#include <iostream>
    #include <algorithm>
    using namespace std;
    #define mx 200000
    int main(){
        int n, k, mn;
        int h[mx], cost[mx];
        cin >> n >> k;
        for(int i = 1; i <= n; i++){
            cin >> h[i];
        }
        cost[1] = 0;
        for(int i = 2; i <= n; i++){
             mn = (abs(h[i] - h[i - 1])) + cost[i - 1];
            for(int j = 2; j <= k ; j++){
                if (i - j >= 1){
                    if(mn > ((abs(h[i] - h[i - j]) + cost[i - j]))){
                        mn = abs(h[i] - h[i - j]) + cost[i - j];
                    }
                }
            }
            cost[i] = mn;
        }
        cout << cost[n] << endl;
        return 0;
    }


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

map<ll, ll> primeFactor(ll n) {
  map<ll, ll> res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main() {
  ll n, d;
  cin >> n >> d;
  vector<vl> x(n, vl(d));
  rep(i, n) rep(j, d) cin >> x[i][j];
  ll ans = 0;
  rep(i, n - 1) rep2(j, i + 1, n) {
    ll s = 0;
    rep(k, d) s += pow(x[i][k] - x[j][k], 2);
    auto pf = primeFactor(s);
    bool ok = true;
    for(auto v : pf)
      if(v.second % 2) ok = false;
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3552
/*
    Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
To where it bent in the undergrowth;

Then took the other, as just as fair,
And having perhaps the better claim,
Because it was grassy and wanted wear;
Though as for that the passing there
Had worn them really about the same,

And both that morning equally lay
In leaves no step had trodden black.
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.

I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I—
I took the one less traveled by,
And that has made all the difference.
*/
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld long double
map<ll , ll>M;

int main()
{
    ll x , y;
    cin >> x >> y;
    cout << (x*y)/(__gcd(x ,y ));
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(a>b)
    swap(a, b);
  int ans = b - (a + w);
  if(ans<0)
    ans = 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  while(n!=0|k!=0){
    int max=0,ans,i;
    int a[n];
    for(i = 0;i < n;i++){
      scanf("%d",&a[i]);
      if(i < k){
	max += a[i];
	ans = max;
      }
      else {
	max = max + (a[i] - a[i-k]);
	if(ans < max) ans = max;
      }
    }
    printf("%d\n",ans);
    cin >> n >> k;
  }
  return (0);
}

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

long long gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main(void){
  int n;
  long long a=1;
  cin >> n;

  for(int i=0; i<n; i++){
    long long t;
    cin >> t;
    a=lcm(a, t);
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    #define int long long
    #define hell 998244353 
    #define endl "\n"
     
    int min(int a, int b){
     
        if(a>b)
            return b;
        return a;
    }
     
    int max(int a, int b){
     
        if(a>b)
            return a;
        return b;
    }
     
     
int32_t main()
{

    int k,x;
    cin>>k>>x;
   
    for(int i=x-k+1;i<x+k;i++)
        cout<<i<<" ";

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n, ans = 1;
  char s[100010];
  
  scanf("%d", &n);
  scanf("%s", s);
  
  for (int i = 0; i < n-1; i++) {
    if (s[i] != s[i+1]) ans++;
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))

MOD = 998244353

if D[0] != 0:
  print(0)
  exit()

M = max(D)
T = [0] * (M + 1)

for i in range(1, N):
  T[D[i]] += 1

if T[0] != 0:
  print(0)
  exit()

for i in range(1, M):
  if T[i] == 0:
    print(0)
    exit()

ans = 1
for i in range(2, M + 1):
  ans = ans * (T[i - 1] ** T[i]) % MOD

print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,p="ABC";
    int n,res=0;
    cin>>n>>s;
    for(int i=0;i<=n-3;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        res++;
    }
    cout<<res<<"\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll a[n];
		ll ans=1;
		ll z=1e18;
		for(int i=0;i<n;i++){
			ll k;
			cin>>k;
			if(k==0)
				ans=0;
			if(ans<=0)
				continue;
			if(k>z/ans){
				ans=-1;
			}
			else{
				ans*=k;
			}
			if(ans>z){
				ans=-1;
			}
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main() {

	
	
	int n,a[30001],i,cnt=0;
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		cnt += a[i];
	}
	printf("%d", cnt - n);

	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int main(){
    int a,b=0;
    scanf("%d %d",&a,&b);
    if(a>=13){
        printf("%d",b);
    }else{
        if(a<=5){
            printf("0");
        }else{
            printf("%d",b/2);
        }
    }
    return 0;
}

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

typedef long long ll;

ll two(ll n){
  ll ans=1;
  for(int i=0;i<n;i++){
    ans*=2;
  }
  return ans;
}
  
string bit(ll n){
  string ans="";
  for(int i=0;i<42;i++){
    char c='0'+n%2;
    ans=ans+c;
    n/=2;
  }
  return ans;
}

ll my_xor(ll n,ll m){
  string a=bit(n);
  string b=bit(m);
  ll ans=0;
  for(int i=0;i<40;i++){
    int x=a.at(i)-'0';
    int y=b.at(i)-'0';
    if(x+y==1){
      ans+=two(i);
    }
  }
  return ans;
}     

int main(){
  ll a,b;
  cin >> a >> b;
  if(a%2==0&&b%2==1){
    if((b-a)%4==1){
      cout << 1 << endl;
    }
    else{
      cout << 0 << endl;
    }
  }
  else if(a%2==0&&b%2==0){
    if((b-a)%4==2){
      cout << b+1 << endl;
    }
    else{
      cout << b << endl;
    }
  }
  else if(a%2==1&&b%2==1){
    if((b-a)%4==2){
      cout << a-1 << endl;
    }
    else{
      cout << a << endl;
    }
  }
  else{
    if((b-a)%4==3){
      cout << my_xor(a,b)-1 << endl;
    }
    else{
      cout << my_xor(a,b) << endl;
    }
  } 
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

typedef long long ll;

int main() {
	ll n, a, b; scanf("%lld %lld %lld", &n, &a, &b);
	if ((a > b) || ((n == 1) && (a < b))) {
		printf("0");
	} else if (n == 1 && a == b) {
		printf("1");
	} else {
		printf("%lld", (n - 2) * (b - a) + 1);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int a,b;cin>>a>>b;
  int ans=-1;
  fori(i,1,5000){
    int c=i*2/25;
    int d=i/10;
    if(c==a&&d==b){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, m, k[15], s[15][15], p[15];
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for (int i = 0; i < m; i++) cin >> p[i];
    
    int ans = 0;
    for (int i = 0; i < pow(2, n); i++) {
        bool on[15] = {};
        int ic = i;
        for (int i = 0; i < n; i++) {
            if (ic % 2 == 1) on[i] = true;
            ic /= 2;
        }
        
        int cnt[15] = {}, lamp = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < k[i]; j++) {
                if (on[s[i][j]]) cnt[i]++;
            }
            if (cnt[i] % 2 == p[i]) lamp++;
        }
        if (lamp == m) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N, C, K;
    cin >> N >> C >> K;
    vl T(N);
    rep(i, N) cin >> T[i];

    sortdown(T);

    ll bus=0, cnt=1, x=0;
    for(ll i=1; i<N; i++) {
        if(T[x]-T[i] > K or ++cnt>C ) {
            bus++;
            x=i;
            cnt=1;
        }
    }

    cout << bus + 1 << nl;
}


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

using namespace std;

#define LIMIT 100
#define MOD 1000000007ll
#define INF 1e9
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

bool check(int a){
  string s = "";
  while(a){
    s += (a%10) + '0';
    a/= 10;
  }
  reverse(s.begin(), s.end());
  int l = 0, r = s.size()-1;
  while(l < r){
    if(s[l] != s[r]) return false;
    l++;
    r--;
  }
  return true;
}
//  ***** MAIN *****
int main(){

  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  int t =0 ;
  for (int i = a; i <= b; ++i) {
    if(check(i)) t++;
  }

  std::cout << t << std::endl;

  return 0;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/abc077/tasks/arc084_a
# C - Snuke Festival
import bisect

N = int(input().split()[0])
a_list = sorted(list(map(int, input().split())))
b_list = sorted(list(map(int, input().split())))
c_list = sorted(list(map(int, input().split())))

comb_n = 0
comb_n_list = []

# 自分より大きい個数
start_c_index = 0
start_a_index = 0

for i in range(N):  # 10 ** 5
    b = b_list[i]
    a_n = bisect.bisect_left(a_list, b)
    c_n = N - bisect.bisect_right(c_list, b)
    comb_n += a_n * c_n
ans = comb_n
print(ans)


Measured memory_bytes: 23220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

void solve(int h, int w) {
  vector<vi> g(h + 2, vi(w + 2, -1));
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    int c;
    cin >> c;
    if(c == 1) g[i][j] = 0;
  }
  int ans = 0;
  rep2(a, 1, h + 1) rep2(b, 1, w + 1) {
    if(g[a][b] != 0) continue;
    ans++;
    g[a][b] = ans;
    stack<pair<int, int>> st;
    st.push(P(a, b));
    while(!st.empty()) {
      int i = st.top().first;
      int j = st.top().second;
      st.pop();
      rep(k, 8) {
        int ni = i + dir[k];
        int nj = j + dir[k + 1];
        if(g[ni][nj] != 0) continue;
        g[ni][nj] = g[i][j];
        st.push(P(ni, nj));
      }
    }
  }
  cout << ans << endl;
}

int main() {
  while(true) {
    int h, w;
    cin >> w >> h;
    if(h == 0 && w == 0) break;
    solve(h, w);
  }
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long ans = B;
		if(A<=5){
			ans = 0;
		} else if(A<=12){
			ans/= 2;
		}
		Console.WriteLine(ans);
	}
}

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

#define mod 1000000007

int main(void)
{
    unsigned int n, m;
    cin >> n >> m;

    //nを大きい方に
    if (n <= m)
    {
        swap(n, m);
    }

    if(n-m>1){
        cout << 0 << endl;
        return 0;
    }
    unsigned long long ans = 0, tempn, tempm, a, b;
    if (n - m == 1){
        tempn = 1;
        tempm = 1;
        while (n>1){
            tempn = tempn % mod * n % mod;
            n--;
        }
        while (m>1){
            tempm = tempm % mod * m % mod;
            m--;
        }
        ans = tempn * tempm % mod;
        cout << ans << endl;
        return 0;
    }

    unsigned long long temp;
    if (n - m == 0){
        ans = 0;
        temp = 1;
        while (n>1){
            temp = temp % mod * n % mod;
            n--;
        }
        ans = temp * temp % mod * 2 % mod;
        cout << ans << endl;
        return 0;
    }

    return 0;
}


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

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		double y=(2.0*x)/(a*b);
		double ans;
		if(y<=a)
			ans=Math.atan(a*b*b/(2.0*x))*180/Math.PI;
		else
			ans=Math.atan((b-((double)x/(a*a)))/(a/2.0))*180/Math.PI;
		out.print(ans);
		out.close();
	}
}


Measured memory_bytes: 20564
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s;cin>>s;
    ll q=in();
    string foo;
    getline(cin,foo);

    string ans(3000000,'\0');
    ll b=1000000,e=b+s.length();
    for(int i=0;i<s.length();++i)ans[b+i]=s[i];
    bool forward=true;

    for(int i=0;i<q;++i){
        string l;getline(cin,l);
        if(l[0]=='1'){
            forward^=true;
        }else{
            ll f=l[2]-'0';
            char c=l[4];
            if(forward^(f==2))ans[--b]=c;
            else ans[e++]=c;
        }
    }

    if(forward){
        for(int i=0;i<ans.length();++i){
            if(ans[i]!='\0'){
                cout<<ans[i];
            }
        }
    }else{
        for(int i=ans.length()-1;i>=0;--i){
            if(ans[i]!='\0'){
                cout<<ans[i];
            }
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3840
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
// #include <variant>

// Yay!!
#define endl codeforces

// macros for iterator
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)

// alias
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;

// variadic min/max
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }

// variadic chmin/chmax
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

// multi demension array
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type;

// fill container
// template <typename T, typename F, typename... Args> 
// void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } }

// make multi dimension vector
template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); }
template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); }

// init
namespace init__ { 
struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; 
}


int main() {
    std::string s;
    std::cin >> s;
    ll wcnt = 0, bcnt = 0;
    s += 'z';
    char cur = 'z';
    for (char c : s) {
        if (cur != c) {
            if (cur == 'W') wcnt++;
            if (cur == 'B') bcnt++;
        }
        cur = c;
    }

    std::cout << wcnt + bcnt - 1 << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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 ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    vector<ll> c(n-1), s(n-1), f(n-1);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    rep(j, n) {
        ll now = 0;
        Rep(i, j, n-1) {
            if(now < s[i]) now = s[i];
            else if(now % f[i] != 0) now = (now + f[i]) / f[i] * f[i];
            now += c[i];
        }
        cout << now << endl;
    }
}

Measured memory_bytes: 3556
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>memo(N+1, 0);

    for (int i = 1; i <= N; i++) {
        for (int j = 1; i*j <=N ; j+=2) {
            memo[i*j]++;
        }
    }

    cout << count(memo.begin(), memo.end(), 8) << endl;

    return 0;
}

Measured memory_bytes: 256