akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int a, b;
	while (cin >> a >> b) {
		if (a == 0)break;
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if (i == 0 ||i==a-1|| j == 0 || j == b - 1)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0,w=0,t=0,r=0;
  cin>>n;
  while(n--){
    char ch[5];
    cin>>ch;
    if(ch[0]=='A')
      a++;
    if(ch[0]=='W')
      w++;
    if(ch[0]=='T')
      t++;
    if(ch[0]=='R')
      r++;
  }cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<w<<endl;
  cout<<"TLE x "<<t<<endl;
  cout<<"RE x "<<r<<endl;
  return 0;
}
  

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


int main(){
   int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e=(c+b-1)/b;
  int f=(a+d-1)/d;
  if(e <= f) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  


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

int main(){
    int n,k; cin>>n>>k;
    int p1;
    for(int i=1; i<=n; i++){
        int a; cin>>a;
        if(a==1) p1=i;
    }
    int ans;
    ans = (n-1)/(k-1) + ((n-1)%(k-1)!=0);
    
    cout << ans << endl;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,K;
signed main() {
    cin>>N>>K;
    int a1=N/K;
    int a2=0;
    if(K%2==0)a2=(N+K/2)/K;
    cout<<a1*a1*a1+a2*a2*a2<<endl;
}

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

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long
#define MP make_pair

int i,j,i_b,j_b;
vector<pair<LL,int>> x;
vector<pair<LL,int>> y;
vector<LL> x_val;
vector<LL> y_val;
pair<LL,int> tmp;

int rmind(int ind,vector<pair<LL,int>> v){
  REP(k,v.size()){
    if(v[k].second == ind)
      return k;
  }
}

int main(){
  int n,k;
  LL xv,yv;
  cin>>n>>k;
  REP(i,n){
    cin>>xv>>yv;
    x.push_back(MP(xv,i));
    y.push_back(MP(yv,i));
  }
  
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  LL score=(y[n-1].first-y[0].first)*(x[n-1].first-x[0].first);

  vector<pair<LL,int>> dumx_pre3=x;
  vector<pair<LL,int>> dumy_pre3=y;
  vector<pair<LL,int>> dumx_pre2;
  vector<pair<LL,int>> dumy_pre2;
  vector<pair<LL,int>> dumx_pre;
  vector<pair<LL,int>> dumy_pre;
  vector<pair<LL,int>> dumx;
  vector<pair<LL,int>> dumy;
  
  REP(i,n){
    if(n-i<k)
      break;
    dumx_pre2=dumx_pre3;
    dumy_pre2=dumy_pre3;
    REP(i_b,n-i){
      if(n-i-i_b<k)
	break;
      dumx_pre=dumx_pre2;
      dumy_pre=dumy_pre2;
      REP(j,n-i-i_b){
	if(n-i-i_b-j<k)
	  break;
	dumx=dumx_pre;
	dumy=dumy_pre;
	REP(j_b,n-i-i_b-j){
	  /*
	  REP(k,dumx.size())
	    cout <<dumx[k].first <<" " <<dumx[k].second << " ";
	  cout<<endl;
	  REP(k,dumy.size())
	    cout << dumy[k].first <<" "<<dumy[k].second << " ";
	  cout<<endl;
	  cout<<(dumy.back().first-dumy[0].first)*(dumx.back().first-dumx[0].first)<<endl;
	  */
	  if(n-i-i_b-j-j_b<k)
	    break;
	  if(score > (dumy.back().first-dumy[0].first)*(dumx.back().first-dumx[0].first))
	    score = (dumy.back().first-dumy[0].first)*(dumx.back().first-dumx[0].first);
	  tmp=dumy.back();
	  dumy.pop_back();
	  dumx.erase(dumx.begin()+rmind(tmp.second,dumx));
	}
	tmp=dumy_pre[0];
	dumy_pre.erase(dumy_pre.begin());
	dumx_pre.erase(dumx_pre.begin()+rmind(tmp.second,dumx_pre));
      }
      tmp=dumx_pre2.back();
      dumx_pre2.pop_back();
      dumy_pre2.erase(dumy_pre2.begin()+rmind(tmp.second,dumy_pre2));
    }
    tmp=dumx_pre3[0];
    dumx_pre3.erase(dumx_pre3.begin());
    dumy_pre3.erase(dumy_pre3.begin()+rmind(tmp.second,dumy_pre3));
  }
  cout<<score<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n; 
    vector<int> w(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        sum += w[i];
    }
    int mn = INT_MAX, s1 = 0;
    for(int i = 0; i < n; i++){
        s1 += w[i];
        mn = min(mn, abs(s1 * 2 - sum));
    }
    cout << mn << endl;
    return 0;
}

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

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


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// type alias
using ll = long long;
using ull = unsigned long long;

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}


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

	string S;
	cin >> S;

	char curr = S[0];
	bool isBad = false;
	for (ll i = 1; i < 4; ++i)
	{
		if (curr == S[i])
		{
			isBad = true;
			break;
		}
		curr = S[i];
	}

	cout << (isBad ? "Bad" : "Good") << endl;

	return 0;
}


Measured memory_bytes: 256
"use strict";

function difference(setA, setB) {
    var _difference = new Set(setA);
    for (var elem of setB) {
        _difference.delete(elem);
    }
    return _difference;
}

function main(input) {
    let line = input.split("\n");
    let AB = new Set(line.slice(0, line.length - 1));
    console.log(Array.from(difference(new Set(["1", "2", "3"]), AB).values())[0]);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29564
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    void dfs(long len, long m, string s)
    {
        if (len == N)
        {
            writeln(s);
            return;
        }
        foreach (x; 0 .. m)
            dfs(len + 1, m, s ~ cast(char)('a' + x));
        dfs(len + 1, m + 1, s ~ cast(char)('a' + m));
    }

    dfs(0, 0, "");
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
string alpha = "abcdefghijklmnopqrstuvwxyz";
int main()
{
    ll n;
    cin >> n;
    string ans;
    while(n > 0)
    {
        n--;
        int num = n % 26;
        ans += alpha[num];
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3640
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    c = input()

    if c in "aiueo":
        print("vowel")
    else:
        print("consonant")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
int lcm(int a, int b)
{
  return a / __gcd(a, b) * b;
}
void solve()
{
  int x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  int f = x / d;
  x = x - min(k, f) * d;
  k -= f;
  int ans = x;
  if (k > 0)
  {
    if (k % 2)
    {
      ans = abs(x - d);
    }
  }
  cout << ans << endl;
}
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  tc = 1;
  //cin >> tc;
  while (tc--)
  {
    solve();
  }

  return 0;
}

Measured memory_bytes: 3672
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		long N = keyboard.nextLong();
		long Max = 0;
		
		for (long i = 1; i*i <= N; i++) {
			if(N%i == 0) {
				Max = i;
			} 
		}

		System.out.println(Max + N/Max -2);
		keyboard.close();
	}
}


Measured memory_bytes: 35756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
ll m=0,a=0,r=0,c=0,h=0,n,ans=0,x[6];
string s;
ll xx(int a1,int a2,int a3){
	return x[a1]*x[a2]*x[a3];
}

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>s;
		if(s[0]=='M')m++;
		else if(s[0]=='A')a++;
		else if(s[0]=='R')r++;
		else if(s[0]=='C')c++;
		else if(s[0]=='H')h++;
	}
	x[1]=a;
	x[2]=r;
	x[3]=m;
	x[4]=c;
	x[5]=h;
	FOR(i,1,6){
		FOR(j,i+1,6){
			FOR(k,j+1,6){
				ans+=xx(i,j,k);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	ll d = linf;
	ll N; cin >> N;
	rep(i, 0, 5) {
		ll a; cin >> a;
		MIN(d, a);
	}
	cout << (N + d - 1) / d + 4 << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int N, K;
ll fact[110000];
ll invfact[110000];

ll inv(ll a) {

	ll res = 1;
	int p = MOD - 2;
	while (p > 0) {
		if ((p & 1) == 1) { res *= a; res %= MOD; }
		a = a * a % MOD;
		p >>= 1;
	}
	return res;
}

ll combo(int n, int k) {
	ll res = fact[n];
	res *= invfact[k];
	res %= MOD;
	res *= invfact[n - k];
	return res % MOD;
}

void factpre() {
	fact[0] = 1;
	fx(N) {
		fact[x + 1] = fact[x] * (x + 1);
		fact[x + 1] %= MOD;
	}
	invfact[N] = inv(fact[N]);
	for (int x = N - 1; x >= 0; x--) {
		invfact[x] = invfact[x + 1] * (x + 1);
		invfact[x] %= MOD;
	}
}


int main()
{

	cin >> N >> K;
	vecl(A);
	fx(N) {
		vecpl(A);
	}
	sorts(A);

	ll ans = 0;
	factpre();

	fx(N) {
		ll sum = 0;
		if (x + 1 >= K) {
			sum += combo(x,K - 1)*A[x];
		}
		if (x<=N-K) {
			sum -= combo(N - x - 1, K-1)*A[x];
		}
		ans += sum % MOD;
		ans %= MOD;
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 2676
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	var a, b int
	fmt.Scan(&a, &b)
	var u string
	fmt.Scan(&u)
	if s == u {
		a--
	}
	if t == u {
		b--
	}
	fmt.Println(a, b);
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    cnt = 0
    for i in range(len(s)):
        if i >= len(s)//2:
            break
        if s[i] != s[len(s)-1-i]:
            cnt += 1
    print(cnt)

main()



Measured memory_bytes: 6736
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <string>
#include  <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define lrep(i, n, m) for(int i = n; i < m; i++)

typedef long long ll;
const int MAX = INT_MAX;

int main()
{	
	int n;
	cin >> n;
	vector<int> Ans(n, 0);
	//vector<int> A(n - 1);
	int v;
	rep(i, n - 1) {
		cin >> v;
		Ans[v - 1]++;
	}
	for (int k : Ans) {
		cout << k << endl;
	}
}

Measured memory_bytes: 3988
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 4e5 + 5;

int a[N];
 
inline void solve() {
 	int n, ans(0), y;
 	cin >> n >> y;
 	vector < int > v(n);
 	for (int &x : v) {
 		cin >> x;
 		ans += x >= y;
 	}
 	cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t; while(t--)
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int n;
  cin >> n;
  if (n % 2 == 0){
    P(n);
  }
  else{
    P(n*2);
  }
}

int main() {
  solve();
  return 0;
}


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

void caesar(const char *str, char *d_str, const int n) {                        
    int i, len;                                                                 
    len = strlen(str);                                                          
    for (i = 0; i < len; i++) {                                                 
        if (isalpha(str[i]))                                                    
            d_str[i] = str[i] + n  > 'z' ? str[i] + n - 26 : str[i] + n;        
        else                                                                    
            d_str[i] = str[i];                                                  
    }                                                                           
    d_str[i] = '\0';                                                            
}

int main(void) {                                                                
    char str[100];                                                              
    char d_str[100];                                                            
    int n = 1;                                                                  
                                                                                
    while (fgets(str, 100, stdin) != NULL) {                                    
        n = 1;                                                                  
        while (1) {                                                             
            caesar(str, d_str, n++);                                            
            if (strstr(d_str, "the") || strstr(d_str, "this") || strstr(d_str, \
"that"))                                                                        
                break;                                                          
        }                                                                       
        printf("%s", d_str);                                                    
    }                                                                           
    return 0;                                                                   
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// https://atcoder.jp/contests/agc005/submissions/6751268

const int N = 200001;
vector<int> pos(N);
int main() {
    int n;
    cin >> n;
    
    rep(i, n) {
        int tmp;
        cin >> tmp;
        pos[tmp] = i + 1;
    }
    
    ll ans = 0;
    set<int> s = {0, n + 1}; // 0とn+1がsetに入ってるという意味
    
    for (int i = 1; i <= n; ++i) {
        auto it = s.lower_bound(pos[i]);
        int r = *it;
        int l = *(--it);
        // out(l << " " << pos[i] << " " << r);
        ans += i * 1LL * (pos[i] - l) * (r - pos[i]);
        
        s.insert(pos[i]);
    }
    
    out(ans);
}



Measured memory_bytes: 10368
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, j, buf;
	char str[32];
	gets(str);
	i = 0;
	j = strlen(str) - 1;
	while(i<j){
		buf = str[i];
		str[i] = str[j];
		str[j] = buf;
		i++;
		j--;
	}
	printf("%s\n", str);
	return 0;

}

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

using namespace std;

typedef long long LL;

const int maxn = 4e2 + 5;
const int P = 1e9 + 7;

int n, C, A[maxn], B[maxn], mi[maxn][maxn], f[maxn][maxn];
int maxv;

inline int read(){
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
	while(isdigit(ch)){u = u * 10 + ch - 48; ch = getchar();} return u * f;
}

inline int pls(int x, int y){x += y; return x >= P ? x - P : x;}

inline int mul(int x, int y){LL rnt = 1ll * x * y; return (int)(rnt >= P ? rnt % P : rnt);}

int main(){
	n = read(); C = read();
	for(register int i = 1; i <= n; i++)A[i] = read();
	for(register int i = 1; i <= n; i++)maxv = max(maxv, B[i] = read());
	for(register int i = 1; i <= maxv; i++){
		mi[i][0] = 1;
		for(register int j = 1; j <= C; j++)
			mi[i][j] = mul(mi[i][j - 1], i);
	}
	f[0][0] = 1;
	for(register int i = 1; i <= n; i++)
		for(register int k = 0; k <= C; k++){
			int res = 0;
			for(register int j = A[i]; j <= B[i]; j++)res = pls(res, mi[j][k]);
			for(register int j = k; j <= C; j++)
				f[i][j] = pls(f[i][j], mul(f[i - 1][j - k], res));
		}
	cout << f[n][C];
	return 0;
}
/*
2 3
1 1
1 1

*/

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n, a, b;
	cin >> n >> a >> b;
	if(a > b) {
		cout << "0" << endl;
		return 0;
	}
	if(n == 1) {
		if(a == b) {
			cout << "1" << endl;
			return 0;
		} else {
			cout << "0" << endl;
			return 0;
		}
	}

	long long int ans = (b - a) * (n - 2) + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
INF = 1001001001
from collections import deque
di = [-1, 0, 1 ,0]
dj = [ 0,-1, 0, 1]

H, W = map(int, input().split())
S = [input() for _ in range(H)]

ans = 0
for si in range(H):
    for sj in range(W):
        if S[si][sj] == '#': continue
        q = deque([(si, sj)])
        d = [[INF] * W for _ in range(H)]
        d[si][sj] = 0
        while q:
            i, j = q.popleft()
            for dir in range(4):
                ni = i + di[dir]
                nj = j + dj[dir]
                if (ni<0 or ni>=H or nj<0 or nj>=W): continue
                if S[ni][nj] == '#': continue
                if d[ni][nj] == INF:
                    d[ni][nj] = d[i][j] + 1
                    q.append((ni,nj))
        tmp = 0
        for i in range(H):
            for j in range(W):
                if d[i][j] != INF:
                    tmp = max(tmp, d[i][j])
        ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(void)
{
    int n,q;
    cin >> n >> q;
    vector<int> a(327680,0);
    REP(i,n){
        int tmp;
        cin >> tmp;
        a[tmp+1]=tmp;
    }
    REP(i,327670) a[i+1]=max(a[i+1],a[i]);
    REP(i,q){
        int m,answer=0;
        cin >> m;
        for(int j=m;j<327600;j+=m) answer=max(answer,a[j]%m);
        cout << answer << endl;
    }
    return 0;
}

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

typedef struct date{
  long long min;
  long long max;
}date;

int cmp( const void *p, const void *q ) {
    return  ((date*)q)->min - ((date*)p)->min ;
}

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

  if(n == m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}


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

int main() {
    int N, K; cin >> N >> K;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i], ++a[i]; // 1 足しておく

    // 累積和
    vector<long long> s(N+1, 0);
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

    // K 差を見ていく
    long long res = 0;
    for (int i = 0; i+K <= N; ++i) res = max(res, s[i+K] - s[i]);
    cout << fixed << setprecision(10) << (double)(res)/2 << endl;
}


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

using namespace std;
//#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;

vector<int> indisler[200005];
pair<int, int> adji[200005];
pair<int, int> adjg[200005];

int main(){
	int n;
	ll k;
	cin >> n >> k;
	vector<int> arr(n);
	for (int i = 0; i < n; i++){
		cin >> arr[i];
		indisler[arr[i]].pb(i+1);
	}
	
	for (int i = 0; i < 200005; i++){
		if (indisler[i].size() == 0) continue;
		for (int j = indisler[i].size()-1; j > 0; j--){
			adji[indisler[i][j]] = (mp(indisler[i][j-1]-1, 0));
			adjg[indisler[i][j-1]-1] = (mp(indisler[i][j], 0));
		}
		adji[indisler[i][0]] = mp(indisler[i][indisler[i].size()-1]-1, 1);
		adjg[indisler[i][indisler[i].size()-1]-1] = mp(indisler[i][0], 1);
	}
	adji[0] = mp(n, 1);
	adjg[n] = mp(0, 1);
	
	/*for (int i = 0; i <= n; i++){
		cout << i << ": " << adji[i].first << ", " << adji[i].second << endl;
	}
	cout << endl;
	for (int i = 0; i <= n; i++){
		cout << i << ": " << adjg[i].first << ", " << adjg[i].second << endl;
	}
	cout << endl;*/
	
	int node = n;
	ll mod = 0;
	while (1){
		mod += adji[node].second;
		node = adji[node].first;
		if (node == n) break;
	}
	
	k %= mod;
	
	node = n;
	while (1){
		k -= adjg[node].second;
		if (k < 0) break;
		node = adjg[node].first;
	}
	
	bitset<200005> vis;
	vis.reset();
	
	vector<int> ans;
	
	
	for (int i = node; i < n; i++){
		//prarrv(ans);
		if (vis[arr[i]] == 0){
			//cout << "al: " << arr[i] << endl;
			ans.pb(arr[i]);
			vis[arr[i]] = 1;
		} else {
			int sil = arr[i];
			vis[sil] = 0;
			//ans.pop_back();
			while (ans[ans.size()-1] != sil){
				//cout << ans.size() << endl;
				vis[ans[ans.size()-1]] = 0;
				ans.pop_back();
			}
			ans.pop_back();
		}
	}
	
	for (int i = 0; i < ans.size(); i++) cout << ans[i] << " "; cout << endl;
}


Measured memory_bytes: 17272
la=[]
for i in range(3):
    la.append(list(map(int,input().split())))
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if la[j][k]==b:
                la[j][k]=-1
f=0
for i in range(3):
    for j in range(3):
        if la[i][j]!=-1:
            break
    else:
        f=1
        break
if f==0:
    for i in range(3):
        for j in range(3):
            if la[j][i]!=-1:
                break
        else:
            f=1
            break
if f==0:
    if la[0][0]==-1 and la[1][1]==-1 and la[2][2]==-1:
        f=1
    elif la[0][2]==-1 and la[1][1]==-1 and la[2][0]==-1:
        f=1
if f==1:
    print('Yes')
else:
    print("No")


Measured memory_bytes: 3064
n,m = map(int, raw_input().split())
np=[]
mp=[]
for i in xrange(0, n):
  np.append(raw_input())
for i in xrange(0, m):
  mp.append(raw_input())
 
for i in xrange(0,n-m+1):
  for j in xrange(0, n-m+1):
    flag = True
    for x in xrange(0, m):
      for y in xrange(0, m):
        if mp[x][y] != np[i+x][j+y]:
          flag = False
          break
      if flag == False:
        break
    if flag:
      print "Yes"
      break
  if flag: break
if flag==False: print "No"

Measured memory_bytes: 2692
//AtCoder ABC085 B - Kagami Mochi
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    vector<ll> dn(N,0);
    for(auto&& d:dn){
        cin>>d;
    }
    sort(dn.begin(),dn.end());
    ll ans=0;
    ll cur=0;
    for(const auto& d:dn){
        if(cur<d){
            cur=d;
           ++ans; 
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

temp = input().split()
n = int(temp[0])
a = int(temp[1])
b = int(temp[2])

def digitsSum(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num = math.floor(num/10)
    return sum

answer = 0
for i in range(1,n+1):
    s = digitsSum(i)
    if a <= s <= b:
        answer += i

print(answer)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int bubbleSort(int a[], int n) {
    bool flag = true;
    int sw = 0;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; --j) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                flag = true;
                sw++;
            }
        }
    }
    return sw;
}

void trace(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}

int main() {
    int n;
    int a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int sw = bubbleSort(a, n);
    trace(a, n);
    cout << sw << endl;
    return 0;
}

Measured memory_bytes: 3204
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  int n=S.size();

  for(int i=n-1;i>0;--i){
    string sub_s=S.substr(0,i);
    int size=sub_s.size();
    if(size%2==1) continue;
    string first=sub_s.substr(0,size/2);
    string second=sub_s.substr(size/2,size/2);
    if(first==second){
      cout << size << endl;
      break;
    }
  }
  

  return 0;
}


Measured memory_bytes: 3632
N=int(input())
S=input()
V=[]
for i in range(len(S)):
  if ord(S[i])+N>90:
    V.append(chr(int(ord(S[i]))+N-26))
  else:
    V.append(chr(int(ord(S[i]))+N))
print("".join(map(str,V)))

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
b = [list(map(int, input().split())) for _ in range(h)]
ab = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        ab[i][j] = abs(a[i][j] - b[i][j])

m = 12800
dp = [[0] * w for _ in range(h)]
dp[0][0] = (1 << (m + ab[0][0])) | (1 << (m - ab[0][0]))
for i in range(h):
    for j in range(w):
        for dx, dy in [(1, 0), (0, 1)]:
            nx, ny = i + dx, j + dy
            if 0 <= nx < h and 0 <= ny < w:
                dp[nx][ny] = dp[nx][ny] | (dp[i][j] << ab[nx][ny])
                dp[nx][ny] = dp[nx][ny] | (dp[i][j] >> ab[nx][ny])

#print(dp[-1][-1])
for i in range(m+1):
    if (dp[h-1][w-1] >> i) & 1:
        ans = m - i

print(ans)



Measured memory_bytes: 60380
#include<bits/stdc++.h>
using namespace std;
int n , a , maxx;
long long ans;
int main()
{
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i++ )
	{
		scanf("%d" , &a);
		maxx = max(maxx , a);
		ans += maxx - a;
	}
	printf("%lld" , ans);
    return 0;
}

Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>
using namespace std;
const int mod=1e9+7;
const int r=(mod+1)>>1;
inline int add(int x)
{
	return x>=mod?x-mod:x;
}
int n,Q;
int a[3050];
int f[3050][3050]; 
int t[3050][3050];
int main()
{
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(a[i]>a[j]) f[i][j]=1;
		}
	} 
	for(int i=1;i<=Q;++i)
	{
		int x,y; scanf("%d%d",&x,&y);
		for(int j=1;j<=n;++j) if(j!=x)
		{
			t[j][x]=1ll*(f[j][x]+f[j][y])*r%mod;
			t[x][j]=1ll*(f[x][j]+f[y][j])*r%mod;
		}
		for(int j=1;j<=n;++j) if(j!=y)
		{
			t[j][y]=1ll*(f[j][y]+f[j][x])*r%mod;
			t[y][j]=1ll*(f[y][j]+f[x][j])*r%mod;
		}
		t[x][y]=1ll*(f[x][y]+f[y][x])*r%mod;
		t[y][x]=1ll*(f[y][x]+f[x][y])*r%mod;
		for(int j=1;j<=n;++j) if(j!=x)
		{
			f[j][x]=t[j][x];
			f[x][j]=t[x][j];
		}
		for(int j=1;j<=n;++j) if(j!=y)
		{
			f[j][y]=t[j][y];
			f[y][j]=t[y][j];
		}
		f[x][y]=t[x][y];
		f[y][x]=t[y][x];
	}
	int an=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			an=add(an+f[i][j]);
		}
	}
	for(int i=1;i<=Q;++i)
	{
		an=add(an<<1);
	}
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 72952
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int l=n%10;
  if(l==2||l==4||l==5||l==7||l==9)
    cout<<"hon";
  else if(l==0||l==1||l==6||l==8)
    cout<<"pon";
  else
 
    cout<<"bon";
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int []height = new int[10];
        for(int i =0;i<height.length;i++){
            height[i]=sc.nextInt();
           
        }
        Arrays.sort(height);
        for (int j=9;6<j;j--){
            System.out.println(height[j]);
        }

    }
}

Measured memory_bytes: 17168
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){
    int N;
    long long int A[200001],count=0,ans=0;
    long long int mod=1000000007;
    cin>>N;
    for(int i=0;i<N;i++)    cin>>A[i];

    for(int i=N-1;i>0;i--){
        count=(count+A[i])%mod;
        ans=(ans+count*A[i-1])%mod;
    }

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

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int a, b, x;
	cin >> a >> b >> x;

	ld l = 0, r = b;
	for (int it = 100; it--; )
	{
		ld m = (l+r) / 2.0;

		ld y = a*a*m + a*a*(b-m)/2;
		if (y > x)
			r = m;
		else
			l = m;
	}

//	debug(l);
	ld g = (b-l) / sqrtl((a*a + (b-l)*(b-l)));

	cout.precision(15);
	cout << fixed;
	if (l < 1e-7)
	{
//		debug("here");
		l = 0, r = a;
		for (int it = 100; it--; )
		{
			ld m = (l+r) / 2.0;

			ld y = a*b*m/2;
			if (y > x)
				r = m;
			else
				l = m;
		}

		g = /*acosl(-1.0) / 2 - */l / sqrtl(l*l + b*b);
		if (g > 1) g = 1;
		if (g < -1) g = -1;
		cout << 90 - asinl(g) / acosl(-1.0) * 180 << "\n";
		return 0;
	}

	if (g > 1) g = 1;
	if (g < -1) g = -1;
//	debug(g);
//	debug(asinl(g));
//	debug(acosl(-1.0));
	cout << asinl(g) / acosl(-1.0) * 180 << "\n";

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int X;
  cin>>X;
  
  if(X%100==0){
    cout<<1<<endl;
    return 0;
  }
  else{
    int N=X/100;
    int amari=X%100;
    for(int a=0;a<=N;++a){
      for(int b=0;a+b<=N;++b){
        for(int c=0;a+b+c<=N;++c){
          for(int d=0;a+b+c+d<=N;++d){
            for(int e=0;a+b+c+d+e<=N;++e){
              int total=5*a+4*b+3*c+2*d+e;
              if(total==amari){
                cout<<1<<endl;
                return 0;
              }
            }
          }
        }
      }
    }
  }
  
  cout<<0<<endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ull unsigned long long
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

//最大公約数
	long long GCD(long long a, long long b) {
		if (a < b)
			swap(a, b);
		if (b == 0) return a;
		else return GCD(b, a % b);
	}
	//素数判定
	bool sosuu_check(int num) {
		int i;
		for (i = 2; i <= sqrt(num); ++i) {
			if (num%i == 0)
				return false;
		}
		return (num < 2) ? false : true;
	}
	
	int check(int N, int a, int b) {
		int A,B,i;
		if (a > b) {
			A = a;
			B = b;
		}
		else {
			A = b;
			B = a;
		}
		for (i = N / b; i > 0; i--) {
			if ((N - b * i) % a == 0) {
				return i;
			}
		}
		return 0;
	}
	//コンビネーション(n,r)
	ull combination(int n, int r) {
		if (r * 2 > n) r = n - r;
		ull dividend = 1;
		ull divisor = 1;
		for (int i = 1; i <= r; ++i) {
			dividend *= (n - i + 1);
			divisor *= i;
		}
		return dividend / divisor;
	}

	void Swap(int* left, int* right)
	{
		int temp = *left;
		*left = *right;
		*right = temp;
	}

int main() {
	string S;
	cin >> S;
	int i, j, ans = 0, len = 0;
	REP(i, S.size()) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
			len++;
		}
		else {
			len = 0;
		}
		ans = max(ans, len);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)1e6 + 5;
const int mod = (int)1e9 + 9;
using namespace std;

ll x[maxn];
int v[maxn];
ll c[maxn], cc[maxn];
ll cmx[maxn], ccmx[maxn];

int main()
{
	//input
	int n; ll C; scanf("%d %lld", &n, &C);
	for(int i = 1; i <= n; i++) scanf("%lld %d", &x[i], &v[i]);
	//solve
	for(int i = 1; i <= n; i++){
		c[i] = c[i-1] + v[i] - (x[i] - x[i-1]);
		cmx[i] = max(cmx[i-1], c[i]);
	}
	x[n+1] = C;
	for(int i = n; i >= 1; i--){
		cc[n-i+1] = cc[n-i] + v[i] - (x[i+1] - x[i]);
		ccmx[n-i+1] = max(ccmx[n-i], cc[n-i+1]); 
	}
	ll ans = 0;
	for(int i = 0; i <= n; i++){
		ans = max(ans, c[i] - x[i] + ccmx[n-i]);
		ans = max(ans, cc[i] - C + x[n-i+1] + cmx[n-i]);
	}
	//output
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    追加クエリの傾き a が単調の場合しか使えない (単調でない場合はLi Chao Treeを使う)
*/
template <typename T, bool isMin>
struct CHT {
#define F first
#define S second
    using P = pair<T, T>;
    deque<P> H;

    bool empty() const {
        return H.empty();
    }

    void clear() {
        H.clear();
    }

    inline int sgn(T x) {
        return x == 0 ? 0 : (x < 0 ? -1 : 1);
    }

    inline bool check(const P& a, const P& b, const P& c) {
        if (b.S == a.S || c.S == b.S)
            return sgn(b.F - a.F) * sgn(c.S - b.S) >=
                   sgn(c.F - b.F) * sgn(b.S - a.S);
        return (long double)(b.F - a.F) * sgn(c.S - b.S) /
                   (long double)(abs(b.S - a.S)) >=
               (long double)(c.F - b.F) * sgn(b.S - a.S) /
                   (long double)(abs(c.S - b.S));
    }

    void add(T a, T b) {
        if (!isMin) a *= -1, b *= -1;
        P line(a, b);
        if (empty()) {
            H.emplace_front(line);
            return;
        }
        if (H.front().F <= a) {
            if (H.front().F == a) {
                if (H.front().S <= b) return;
                H.pop_front();
            }
            while (H.size() > 1 && check(line, H.front(), H[1])) H.pop_front();
            H.emplace_front(line);
        } else {
            assert(a <= H.back().F);
            if (H.back().F == a) {
                if (H.back().S <= b) return;
                H.pop_back();
            }
            while (H.size() > 1 && check(H[H.size() - 2], H.back(), line))
                H.pop_back();
            H.emplace_back(line);
        }
    }

    inline T getY(const P& a, const T& x) {
        return a.F * x + a.S;
    }

    T query(T x) {
        assert(!empty());
        int l = -1, r = H.size() - 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (getY(H[m], x) >= getY(H[m + 1], x))
                l = m;
            else
                r = m;
        }
        if (isMin) return getY(H[r], x);
        return -getY(H[r], x);
    }
};

signed main() {
    int n;
    ll c;
    cin >> n >> c;
    ll h[n];
    rep(i, n) {
        cin >> h[i];
    }
    CHT<ll, true> cht;
    ll dp[n];
    dp[0] = 0;
    rep(i, n) {
        if(i) dp[i] = cht.query(h[i]) + h[i] * h[i];
        cht.add(-2 * h[i], h[i] * h[i] + dp[i] + c);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;
int main(){
	long long t,a,n;
	cin>>t>>a>>n;
	for(int i = 1;i <= n;i++){
		if(i%2!=0){
			if(t%2==0){
				a += t/2;
				t /= 2;
			}else{
				t -= 1;
				a += t/2;
				t /= 2; 
			}
		}else{
			if(a%2 ==0){
			t += a/2;
			a /= 2;
		}else{
			a -= 1;
			t += a/2;
			a /= 2; 
			}
		}
		
	
	}
	cout<<t<<" "<<a;
}

Measured memory_bytes: 256
from sys import exit
from itertools import product
import numpy as np
HWK,*sss = open(0).read().splitlines()
H,W,K = map(int, HWK.split())
sss = [list(map(int, list(ss))) for ss in sss]
sss = np.cumsum(sss, axis=0)
 
if H == 1 or W == 1:
    print(0--sss[-1][-1]//K)
    exit()
 
ans = float('inf')
for flgs in product([False, True], repeat=H-1):
    cnt = sum(flgs)
    tsss = sss[[*flgs, True]]
    tsss = np.concatenate((tsss[:1], np.diff(tsss, axis=0)), axis=0).T
 
    tmp = 0
    succ = True
    for cur in tsss:
        new = tmp + cur
        if new.max() <= K:
            tmp = new
        else:
            cnt += 1
            if cur.max() > K:
                succ = False
                break
            else:
                tmp = cur
#     print(flgs)
#     print(cnt, ans, tsss)
    if succ:
        ans = min(ans, cnt)
 
print(ans)

Measured memory_bytes: 27384
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    c = s.count("0")
    print(2*min(c,len(s)-c))
    return

#B
def B():
    n = I()
    h = LI()
    ans = 0
    m = min(h)
    while m:
        ans += m
        k = max(h)
        for i in range(n):
            if h[i] >= m:
                h[i] -= m
                if h[i]:k = min(k,h[i])
            else:break
        m = k
    print(ans)
    return

#C
def C():
    n,k = LI()
    x = LI()
    ans = float("inf")
    j = bisect.bisect_left(x,0)
    if n == 1:
        print(abs(x[0]))
        quit()
    if j < n:
        if x[j] == 0:
            k -= 1
            x.pop(j)
            n -= 1
    for i in range(n):
        if i < j:
            if abs(i-j) > k:continue
            elif abs(i-j) == k:ans = min(ans,abs(x[i]))
            elif k+i-1 < n:
                ans = min(ans,abs(x[i])+x[k+i-1]-x[i])
        else:
            if abs(i-j)+1 > k:continue
            elif abs(i-j)+1 == k:ans = min(ans,x[i])
            elif i-k+1 >= 0:
                ans = min(ans,abs(x[i])+x[i]-x[i-k+1])

    print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    ans = 0
    p = [1<<i for i in range(100)]
    for i in range(n):
        l = 0
        r = 100
        while r-l > 1:
            m = (l+r)//2
            if a[i]%p[m] == 0:
                l = m
            else:
                r = m
        ans += l
    print(ans)
    return

#E
def E():
    s = LI()
    s.sort()
    ans = s[2]-s[1]
    s[0] += s[2]-s[1]
    s[1] = s[2]
    if s[0]%2 != s[1]%2:
        ans += (s[1]+1-s[0])//2+1
    else:
        ans += (s[1]-s[0])//2
    print(ans)
    return

#F
def F():
    n = I()
    s = SR(n)
    for i in range(n):
        d = defaultdict(int)
        for j in range(len(s[i])):
            d[s[i][j]] += 1
            s[i][j] += str(d[s[i][j]])
    ans = set(s[0])
    for i in range(1,n):
        ans = ans&set(s[i])
    ans = list(ans)
    ans.sort()
    for i in ans:
        print(i[0],end = "")
    print()
    return

#G
def G():
    s = S()
    ans = 0
    for i in range(len(s)-1):
        if s[i] != s[i+1]:ans += 1
    print(ans)
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    G()


Measured memory_bytes: 52208
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
const ll mod = 1000000007;
const ll mod9 = 1000000009;

signed main(){
    ll n;
    ll l[109];
    cin>>n;
    rep(i,n) cin>>l[i];
    ll ct=0;
    rep(i,n){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]) ct++;
            }
        }
    }
    cout<<ct<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define mod 2019
using namespace std;
typedef long long ll;

int num,p=1,cnt[2025];
string s;
ll ans;

int main()
{
	cin>>s;
	for(int i=sz(s)-1;i>=0;i--)
	{
		num+=(s[i]-'0')*p;
		num%=mod;
		p*=10;
		p%=mod;
		cnt[num]++;
	}
	for(int i=0;i<mod;i++)
		ans+=ll(cnt[i])*ll(cnt[i]-1);
	cout<<ans/2+cnt[0]<<endl;
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  N = N*(N-1)/2;
  M = M*(M-1)/2;
  cout << N+M;
  return 0;
}

Measured memory_bytes: 256