akhauriyash/Code-Regression huggingface dataset:
/*input
10 3 4 2 5
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 1010
#define INF 0x3f3f3f3f
#define mod 1000000007LL

int N , A , B , C , D;
int c[MAX][MAX] , gi[MAX] , ni[MAX] , np[MAX][MAX] , dp[MAX][MAX];
void U(int &now , int val){ now = (now + val) % mod; }
int32_t main(){
    IOS;
    gi[0] = ni[0] = ni[1] = 1;
    REP(i , 1 , MAX) gi[i] = gi[i - 1] * i % mod;
    REP(i , 2 , MAX) ni[i] = ni[mod % i] * (mod - mod / i) % mod;
    REP(i , 2 , MAX) ni[i] = ni[i - 1] * ni[i] % mod;
    REP(i , 1 , MAX) REP(j , 1 , MAX){
        if(j == 1) np[i][j] = ni[i];
        else np[i][j] = np[i][j - 1] * ni[i] % mod;
    }
    REP(i , 0 , MAX) REP(j , 0 , i + 1){
        if(i == j) c[i][j] = 1;
        else c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }

    cin >> N >> A >> B >> C >> D;
    dp[A][N] = 1;
    REP(i , A , B + 1){
        REP(j , 0 , N + 1){
            // DB4(i , j , dp[i][j] , "");
            U(dp[i + 1][j] , dp[i][j]);
            REP(k , C , D + 1){
                if(k * i > j) break;
                else {
                    int all = k * i;
                    int tmp = gi[all] * np[i][k] % mod * ni[k] % mod;
                    U(dp[i + 1][j - all] , dp[i][j] * c[j][all] % mod * tmp % mod);
                }
            }
        }
    }
    cout << dp[B + 1][0] << endl;
    return 0;
}

Measured memory_bytes: 24192
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S, T;
	cin >> S >> T;
	bool ook = false;
	rrep(i, 0, SZ(S))
	{
		bool ok = true;
		rep(j, 0, SZ(T))
		{
			if (S[i + j] != '?'&&S[i + j] != T[j])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			rep(j, 0, SZ(T))
			{
				S[i + j] = T[j];
			}
			ook = true;
			break;
		}
	}

	rep(i, 0, SZ(S))
	{
		if (S[i] == '?')
		{
			S[i] = 'a';
		}
	}

	if (!ook)
	{
		cout << "UNRESTORABLE" << endl;
	}
	else
	{
		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	unsigned short A, B;
	short a, b, yen;
	scanf("%hu %hu", &A, &B);
	for (yen = 1; yen <= 1000; yen++) {
		a = yen * 0.08;
		b = yen * 0.10;
		if (a == A && b == B) {
			break;
		}
	}
	if (1000 < yen) {
		yen = -1;
	}
	printf("%hd\n", yen);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001]={};
int main(){
  int n,t,s,a,b,ans=0;
  cin >> n >> t >> s;
  for(int i=1;i<=n;i++){
    cin >> a >> b;
    for(int j=0;j<=t;j++){
      dp[i][j] = dp[i-1][j];
      if(j >= b && !(j-b < s && s < j)) dp[i][j] = max(dp[i][j],dp[i-1][j-b]+a);
      if(i == n) ans = max(ans,dp[i][j]);
    }
  }
  cout << ans << endl;
  return (0);
}

Measured memory_bytes: 38268
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	lnt n;
	std::cin >> n;
	lnt ans=0;
	for(lnt a=1;a<n;a++) {
		ans+=(n-1)/a;
	}
	print(ans);
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    if (v[0] > 0) {
        cout << -1 << endl;
        return 0;
    }
    long long int res = 0;
    int last = 0;
    for (int i = 1; i < n; i++) {

        if (v[i] == 0) {
            last = 0;
            continue;
        }
        last++;
        if (last < v[i]) {
            cout << -1 << endl;
            return 0;
        }
        if (v[i] - v[i - 1] >= 2) {
            cout << -1 << endl;
            return 0;
        }
        if (v[i] >= 2 && v[i - 1] == 0) {
            cout << -1 << endl;
            return 0;
        }
        if (v[i] == v[i - 1] + 1) {
            res++;
            continue;
        }
        res += v[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a;
  rep(i, n)
  {
    int x;
    cin >> x;
    a.push_back(x);
  }

  sort(a.begin(), a.end());

  int ans = 0;
  rep(i, k)
  {
    ans += a[i];
  }

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

Measured memory_bytes: 3636
#include<stdio.h>
main(){
int a,b,c,x,y,z;
scanf("%d%d%d",&a,&b,&c);
if(a>b){
x=a;
a=b;
b=x;
}
if(b>c){
y=b;
b=c;
c=y;
}
if(a>b){
z=a;
a=b;
b=z;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

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

def solve():
    N, K = list(map(int, input().split()))
    S = input()
    
    ans = ""
    for i in range(N):
        if i == K-1:
            ans += S[i].lower()
            continue
        ans += S[i]
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(long.Parse).ToArray();

        var ans = a.Select(x => x - 1).Sum();

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28448
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

 int n;
 string s;
 cin>>n;
 cin>>s;
 int blue,red;
 blue = 0;
 red = 0;
 REP(i,n){
  if(s[i]=='R')red++;
  if(s[i]=='B')blue++;
 }
 if(red>blue){
  cout<<"Yes"<<endl;
 }else{
  cout<<"No"<<endl;
 }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

typedef Segment Line;

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}

// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// 1:???????¨??????? -1:????¨??????? 2:p2-p0-p1 -2:p0-p1-p2 0:p2???p0-p1???
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1-p0;
  Vector b = p2-p0;
  if (cross(a, b) > EPS) return 1;
  if (cross(a, b) < -EPS) return -1;
  if (dot(a, b) < -EPS) return 2;
  if (a.norm() < b.norm()) return -2;

  return 0;
}


// p1!=p2????????????p3!=p4????????¶
bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 &&
          ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
  return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

// ??´???l??¨???p????????¢
double getDistanceLP(Line l, Point p) {
  return abs(cross(l.p2-l.p1, p-l.p1))/abs(l.p2-l.p1);
}

// ??????s??¨???p????????¢
double getDistanceSP(Segment s, Point p) {
  if (dot(s.p2-s.p1, p-s.p1) < 0.0) return abs(p-s.p1);
  if (dot(s.p1-s.p2, p-s.p2) < 0.0) return abs(p-s.p2);
  return getDistanceLP(s, p);
}

// ??????s1??¨??????s2????????¢
double getDistance(Segment s1, Segment s2) {
  if (intersect(s1, s2)) return 0.0;
  return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)),
             min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)));
}

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    Segment s1, s2;
    cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y
        >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
    cout << fixed << setprecision(20) << getDistance(s1, s2) << endl;
  }
}

Measured memory_bytes: 1292
n = int(input())
A = [int(a) for a in input().split()]

max_val = max(A)
mid_val = max_val - max_val//2

# print("max_val: {}, mid_val: {}".format(max_val, mid_val))

m = 0
for a in A:
    # print(abs(a - mid_val))
    # print(abs(m - mid_val))
    if abs(a - mid_val) < abs(m - mid_val):
        m = a
    # print("m: {}".format(m))

print("{} {}".format(max_val, m))


Measured memory_bytes: 14052
// #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
 #pragma GCC target("avx", "avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
// #define double ld
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}


signed main() {
    accell();
    string a, b;
    cin >> a >> b;
    int c, d;
    cin >> c >> d;
    string e;
    cin >> e;
    if (e == a)
        --c;
    else
        --d;
    cout << c << ' ' << d  << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int N, A[110];
	int i, j, a;
	int S = 0, T = 0;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (i = 0; i < N; ++i) {
		for (j = i+1; j < N; ++j) {
			if (A[i]<A[j]) {
				a = A[i];
				A[i] = A[j];
				A[j] = a;
			}
		}
	}
	for (i = 0; i < N; ++i) {
		if (i%2==0) {
			S = S + A[i];
		}
		else {
			T = T + A[i];
		}
	}
	cout << S - T << endl;
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[1010];
int a[2010],b[2010],c[2010];
int main()
{
	int n,m;lint out=0,inf=1E18+10;
	cin>>n>>m;
	rep(i,m){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--;b[i]--;
	}
	rep(i,1010) dp[i]=-inf;dp[0]=0;
	rep(i,5010){
		int t=0;
		rep(j,m){
			//cout<<a[j]<<' '<<b[i]<<endl;
			if(dp[a[j]]+c[j]>dp[b[j]]){
				dp[b[j]]=dp[a[j]]+c[j];
				if(b[j]==n-1) t=1;
			}
		}
		if(i>4000 && t>0){
			cout<<"inf"<<endl;return 0;
		}
	}
	cout<<dp[n-1]<<endl;
}


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

int M=1e9+7;
vector<vector<long long>> product(vector<vector<long long>>A,vector<vector<long long>>B){
	
	int n=A.size();
	int m=A[0].size();
	assert(m==B.size());
	int m2=B[0].size();
	vector<vector<long long>>C(n,vector<long long>(m2));
	for(int i=0;i<n;i++){
		for(int j=0;j<m2;j++){
			for(int k=0;k<m;k++) C[i][j]=(C[i][j]+(A[i][k]*B[k][j])%M)%M;
		}
	}
	return C;
}
vector<vector<long long>> expo(unsigned long long n, vector<vector<long long>>A){
	if(n==1) return A;
	if(n%2==1){
		return product(expo(n-1,A),A);
	}
	auto a=expo(n/2,A);
	return product(a,a);
}
void solve(){
	unsigned long long n,m,K,ans;
	cin>>n>>K;
	vector<vector<long long>>A(n,vector<long long>(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>A[i][j];
	auto X=expo(K,A);
	ans=0;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) ans=(ans+X[i][j])%M;
	cout<<ans<<"\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N, M, C;
	cin >> N >> M >> C;
	VI B(M);
	REP(i, M) {
		cin >> B[i];
	}
	VVI A(N);
	REP(i, N) {
		A[i].resize(M);
	}
	REP(i, N) {
		REP(j, M) {
			cin >> A[i][j];
		}
	}
	LL count = 0;
	REP(i, N) {
		LL sum = C;
		REP(j, M) {
			sum += A[i][j] * B[j];
		}
		if (sum > 0) {
			count++;
		}
	}

	cout << count << endl;
	
	
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int n;
	double t,a,h[1000],H,MIN=0x3f3f3f;
	cin>>n>>t>>a;
	for(int i=0;i<n;i++){
		cin>>H;
		H=t-H*0.006;
		h[i]=abs(H-a);
		MIN=min(MIN,h[i]);
	}
	for(int i=0;i<n;i++){
		if(h[i]==MIN){
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;		






int main() {

	string s;
	string t;
	int q;
	cin >> s >> t >> q;

	VI x(s.size() + 1, 0);
	VI y(t.size() + 1, 0);

	REP(i, s.size()) {
		if (s[i] == 'B')x[i + 1] = x[i] + 2;
		else x[i + 1] = x[i] + 1;
	}

	REP(i, t.size()) {
		if (t[i] == 'B')y[i + 1] = y[i] + 2;
		else y[i + 1] = y[i] + 1;
	}

	REP(i, q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		if ((x[b] - x[a - 1]) % 3 == (y[d] - y[c - 1]) % 3)cout << "YES" << endl;
		else cout << "NO" << endl;

	}



	return 0;

}

Measured memory_bytes: 1664
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#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 <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string S;
    cin >> S;

    vector<string> inputs = {
            "dream",
            "dreamer",
            "erase",
            "eraser"
    };

    reverse(S.begin(), S.end());
    for (int i = 0; i < inputs.size(); i++) reverse(inputs[i].begin(), inputs[i].end());

    int pos = 0;
    while (true) {
        bool update = false;
        for (int i = 0; i < inputs.size(); i++) {
            if (S.substr(pos, inputs[i].size()) == inputs[i]) {
                update = true;
                pos += inputs[i].size();
                break;
            }
        }
        if (!update) break;
    }

    if (pos == S.size()) cout << "YES" << endl;
    else cout << "NO" << endl;

}




























Measured memory_bytes: 512
# 埋める配列
# dp[i][j] : i日目にjに行くときのi日目までの幸福の総和の最大値

# 計算方法
# dp[0][j] = 0
# dp[i][j] = max(dp[i - 1][k] + 増える幸福度)
# j != k となるようにする

# 埋める順序
# iは小さい順jは好きな順

N = int(input())
ABC = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for j in range(3)] for i in range(N + 1)]
#print(dp)

for i in range(1, N + 1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + ABC[i - 1][j])
print(max(dp[-1]))

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

int main()
{
    long long x;
    cin>>x;
    long long sum = 0;
    for(long long i = 1; i<= 1e9; i++)
    {
        sum += i;
        if(sum >= x)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,j,n,k,m;
    cin>>n>>m;
    for(i=m-n+1; i<=m; i++)
    {
        cout<<i<<" ";
    }
    for(i=m+1; i<=m+n-1; i++)
    {
        cout<<i<<" ";
    }

    cout<<endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r=sc.nextInt();
        int D=sc.nextInt();
        int x=sc.nextInt();
        int ans[]=new int[11];
        ans[0]=x;
        for (int i=0 ; i<10; i++)
        {
            ans[i+1]=r*ans[i]-D;
            System.out.println(ans[i+1]);
        }

    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int x,y;
  cin>>x>>y;
  cout<<(x+y/2)<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3596
package main

import "fmt"

func main() {
    var N int
    fmt.Scan(&N)
    for i := 0; i < N; i++{
        var A string
        fmt.Scan(&A)
        if A == "Y" {
            fmt.Println("Four")
            return
        }
    }
    fmt.Println("Three")
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
long long n, m;
long long ans, cnt, SSK;//saisyoukoubaisu
bool ck;
vector<long long> ai(100010);
long long gcd(long long a, long long b){
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b ;
}
void solve(){
    for(int i = 0; i < n; i++){
        SSK = lcm(SSK, ai.at(i));
    }
    ans = m / SSK;
    if(ans % 2 == 1){
        ans /= 2;
        ans += 1;
    }
    else{
        ans /= 2;
    }
    cout << ans << endl;
    dump(SSK);
}
int main(){
    SSK = 1;
    ck = true;
    cin >> n >> m;
    int memo;
    cnt = 1;
    for(int i = 0; i < n; i++){
        cin >> ai.at(i);
        if(i == 0){
            memo = ai.at(0);
            memo /= 2;
            while(memo % 2 == 0){
                memo /= 2;
                cnt *= 2;
            }
            dump(memo);
        }
        if(ai.at(i) % 2 == 1){
            ck = false;
            break;
        }
        else{
            ai.at(i)/=2;
            if(ai.at(i) % cnt != 0 || ai.at(i) % (cnt * 2) == 0){
                ck = false;
            break;
            }
        }
    }
    if(ck){
    solve();
    }
    else{
        cout << "0" << endl;
    }
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;

signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
using namespace std;
int main(){
    string a, b;
    cin >> a >> b;
    int m = a.size();
    int n = b.size();
    int L[m+1][n+1];
    for(int i = 0; i <= m; i++){
    	L[i][0] = 0;
    }
    for(int i = 0; i <= n; i++){
    	L[0][i] = 0;
    }
    for(int i = 1; i <= m; i++){
    	for(int j = 1; j <= n; j++){
    		if(a[i-1] == b[j-1]){
    			L[i][j] = L[i-1][j-1] + 1;
    		}
    		else{
    			L[i][j] = max(L[i-1][j], L[i][j-1]);
    		}
    	}
    }
    int i = m;
    int j = n;
    string ans = "";
    while(i > 0 && j > 0){
    	if(a[i-1] == b[j-1]){
    		ans += a[i-1];
    		i--;
    		j--;
    		continue;
    	}
    	if(L[i][j] == L[i-1][j]){
    		i--;
    	}
    	else if(L[i][j] == L[i][j-1]){
    		j--;
    	}
    	else{
    		i--;
    		j--;
    	}
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}

Measured memory_bytes: 38700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;

int main()
{
    string S;
    int Q;

    cin >> S >> Q;

    ll rev_count = 0;

    deque<char> ans;
    for (char c : S)
    {
        ans.push_back(c);
    }

    rep(i, Q)
    {
        int q;
        cin >> q;

        if (q == 1)
        {
            rev_count += 1;
        }
        else
        {
            int F;
            char C;
            cin >> F >> C;

            if (F == 1)
            {
                if (rev_count % 2 == 1)
                {
                    ans.push_back(C);
                }
                else
                {
                    ans.push_front(C);
                }
            }
            else
            {
                if (rev_count % 2 == 1)
                {
                    ans.push_front(C);
                }
                else
                {
                    ans.push_back(C);
                }
            }
        }
    }

    if (rev_count % 2 == 1)
    {
        reverse(ans.begin(), ans.end());
    }

    for (char c : ans)
    {
        cout << c;
    }

    cout << endl;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
XYH = [[int(i) for i in input().split()] for _ in range(N)]

XYH.sort(key = lambda x:-x[2])

X0,Y0,H0 = XYH[0]

if N == 1:
    print(X0,Y0,H0)
    exit()

for Cx in range(101):
    for Cy in range(101):
        H = H0 + abs(X0 - Cx) + abs(Y0 - Cy)
        flag = True
        for X,Y,h in XYH[1:]:
            if h == max(H - abs(X - Cx) - abs(Y - Cy), 0):
                continue
            flag = False
        if flag:
            print(Cx,Cy,H)

Measured memory_bytes: 3064
n = int(input())
a = [int(x) for x in input().split()]

money=1000
kabukosuu=0

for i in range(n-1):
    money+=kabukosuu*a[i]
    kabukosuu=0
    if a[i]<a[i+1]:
        kabukosuu=money//a[i]
        money=money%a[i]
    
money+=kabukosuu*a[n-1]

print(money)

Measured memory_bytes: 9128
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    [a, b, c, d]<- getLine
    if a  == b && a == c  || b == c && b == d then putStrLn "Yes" else  putStrLn "No"

Measured memory_bytes: 380
K, N = map(int, input().split(' '))
A_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(N):
    l = A_ls[(i + 1) % N] - A_ls[i]
    if l < 0:
        l = K - A_ls[i] + A_ls[(i + 1) % N]
    if rst == -1:
        rst = l
    else:
        rst = max(rst, l)
print(K - rst)

Measured memory_bytes: 32360
#include<bits/stdc++.h>
using namespace std;
char str[1010];
void Ask(int x){
	printf("%d\n",x);fflush(stdout);
	scanf("%s",str);
}
int main(){
	int n;
	scanf("%d",&n);
	int l=0,r=n,mid;
	int vl;
	Ask(0);
	if(str[0]=='V') return 0;
	if(str[0]=='M') vl=1;
	else vl=0;
	while(r-l>1){
		mid=(l+r)>>1;
		Ask(mid);
		if(str[0]=='V') return 0;
		if(((mid-l)&1)==((str[0]=='M')==vl))
			r=mid;
		else{
			l=mid;
			vl=(str[0]=='M');
		}
	}
	return 0;
}


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

bool ok(string s, int l, int r) {
    bool ac = true;
    for(int i = l; i < r - 1; i++) {
        if(s[i] == '#' && s[i + 1] == '#') ac = false;
    }
    return ac;
}

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    if(c < d) {
        if(ok(s, a, c) && ok(s, b, d)) {
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else {
        if(!ok(s, a, c)) cout << "No" << endl;
        else {
            string ans = "No";
            for(int i = b - 1; i < d; i++) {
                if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') ans = "Yes";
            }
            cout << ans << endl;
        }
    }
    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i=0; i<k; i++){
    ans += a[i];
  }
  cout << ans << endl;
}

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

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

  // 全部単体でまかなう
  int sum;
  sum = A * X + B * Y;
  int min = sum;

  // AかBの少ない方の数をCでまかなう（不足分は単体でまかなう）
  int a = X;
  int b = Y;
  sum = 0;
  while(a > 0 && b > 0){
    sum += C * 2;
    a--;
    b--;
  }
  if(a > 0){
    sum += a * A;
  }
  if(b > 0){
    sum += b * B;
  }
  if(min > sum){
    min = sum;
  }

  // AかBの多い数をCでまかなう（過分はそのままｍ）
  sum = 0;
  if(X > Y){
    sum = C * X * 2;
  }else{
    sum = C * Y * 2;
  }
  if(min > sum){
    min = sum;
  }

  cout << min << endl;
}

Measured memory_bytes: 256
local msq = math.sqrt
local n = io.read("*n")
local x, y = {}, {}
for i = 1, n do
  x[i], y[i] = io.read("*n", "*n")
end
local function getlen(i, j)
  return msq((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]))
end
local tot = 1
for i = 2, n do
  tot = tot * i
end
local function getpattern(n, patall, idx)
  local used = {}
  local retary = {}
  local div = patall
  for i = 1, n do used[i] = false end
  for i = n, 1, -1 do
    div = div // i
    local v_idx = idx // div
    idx = idx % div
    local tmp_idx = 0
    for j = 1, n do
      if not used[j] then
        if tmp_idx == v_idx then
          table.insert(retary, j)
          used[j] = true
          break
        else
          tmp_idx = tmp_idx + 1
        end
      end
    end
  end
  return retary
end
local ans = 0
for i = 0, tot - 1 do
  local ary = getpattern(n, tot, i)
  for j = 1, n - 1 do
    ans = ans + getlen(ary[j], ary[j + 1])
  end
end
print(ans / tot)


Measured memory_bytes: 2956
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np

INF = 2**30
n = int(input())
P = list(map(int, input().split()))
T = [[] for _ in range(n)]
for i, p in enumerate(P, 1):
  T[p-1].append(i)
X = list(map(int, input().split()))
D = [-1]*n
def dfs(v):
  if D[v] != -1:
    return D[v]
  l = len(T[v])
  x = X[v]
  dp = np.full(x+1, INF, dtype=np.int64)
  dp[0] = 0
  for i, nv in enumerate(T[v]):
    k = np.full(x+1, INF, dtype=np.int64)
    if x+1 >= X[nv]:
      np.minimum(k[X[nv]:], dp[:x+1-X[nv]]+dfs(nv), out=k[X[nv]:])
    if x+1 >= dfs(nv):
      np.minimum(k[dfs(nv):], dp[:x+1-dfs(nv)]+X[nv], out=k[dfs(nv):])
    dp = k.copy()
  res = dp.min()
  D[v] = res
  return res
ans = dfs(0)
if ans == INF:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 34472
n = int(input())
li_a = map(int, input().split())
li_a_left = list()
total = 0
for l in li_a:
    if len(li_a_left) == 0:
        li_a_left.append(l)
    else:
        li_a_left.append(li_a_left[-1] + l)
    total += l

print(min(abs(left - (total - left)) for left in li_a_left))


Measured memory_bytes: 28300
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){

  int n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}

Measured memory_bytes: 256
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

sum = 0
ans = 0

for i in range(a[0]):
    sum += (1 + b[i])/2
    if i > a[1]-1:
        sum -= (1 + b[i-a[1]])/2
    if ans < sum:
        ans = sum

print(ans)


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

int main()
{
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    if(y>2019)cout << "TBD";
    else if(y==2019 and m>4)cout << "TBD";
    else if(y==2019 and d>30)cout << "TBD";
    else  cout << "Heisei";
}


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

int main() {
  vector<int> hoge(3);
  for (int i = 0; i < 3; i++) {
    cin >> hoge.at(i);
  }
  
  int five = 0;
  int seven = 0;
  for (int i = 0; i < 3; i++) {
    if (hoge.at(i) == 5) {
      five++;
    } else if (hoge.at(i) == 7) {
      seven++;
    }
  }
    
  if (five == 2 && seven == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;



ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

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


ll n;
cin>>n;
if(n%1000==0)cout<<"0";
else cout<<1000-n%1000;
}


Measured memory_bytes: 3620
n,m,q = map(int,input().split())

table = []
for i in range(n+1):
    table.append([0]*(n+1))
for i in range(m):
    a,b = map(int,input().split())
    table[b][a] += 1

#2...n
for i in range(2,n+1):

    #1...n-1
    for j in range(1,n+2-i):
        table[i+j-1][j] += table[i+j-1][j+1]+table[i+j-2][j]-table[i+j-2][j+1]

for _ in range(q):
    start,end = map(int,input().split())
    print(table[end][start])


Measured memory_bytes: 9388
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	rep(i, s.size() - 1) {
		if (s.at(i) == s.at(i + 1)) {
			cout << i + 1 << " " << i + 2 << endl; return 0;
		}
	}
	rep(i, s.size() - 2) {
		if (s.at(i) == s.at(i + 2)) {
			cout << i + 1 << " " << i + 3 << endl; return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
dic = {}
ans = 0
for i in range(N):
    s = [v for v in input()]
    s.sort()
    word = ''.join(s)    

    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1

for word in dic:
    num = dic[word]
    ans += (num * (num - 1)) // 2

print(ans)


Measured memory_bytes: 61272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=105;
vector<int> E[N];
int dep[N],par[N];
void DFS(int u, int p)
{
	par[u]=p;
	dep[u]=dep[p]+1;
	for(int v:E[u]) if(v!=p) DFS(v,u);
}
int cmx[N];
void Take(int u, int p, int d)
{
	cmx[d]=max(cmx[d],(int)E[u].size()-(p!=0));
    for(int v:E[u]) if(v!=p) Take(v,u,d+1);
}
int main()
{
	int n,i,u,v;
	scanf("%i",&n);
	vector<int> cen;
	for(i=1;i<n;i++) scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u);
	DFS(1,0);
	int den=0,qen=0;
	for(i=1;i<=n;i++) if(dep[i]>dep[den]) den=i;
	DFS(den,0);
	for(i=1;i<=n;i++) if(dep[i]>dep[qen]) qen=i;
	int D=dep[qen];
	for(i=qen;i;i=par[i])
	{
		if((D&1) && dep[i]==(D+1)/2) cen.pb(i);
		if(!(D&1) && (dep[i]==D/2 || dep[i]==D/2+1)) cen.pb(i);
	}
	if(cen.size()==2)
	{
		Take(cen[0],cen[1],1);
		Take(cen[1],cen[0],1);
		ll ans=2;
		for(i=1;i<=(D+1)/2-1;i++) ans*=cmx[i];
		printf("%i %lld\n",(D+1)/2,ans);
	}
	else
	{
		for(v:E[cen[0]]) Take(v,cen[0],1);
		ll ans=0,tmp=E[cen[0]].size();
		for(i=1;i<(D+1)/2-1;i++) tmp*=cmx[i],cmx[i]=0;
		ans=tmp;
		for(v:E[cen[0]])
		{
			Take(v,cen[0],1);
			Take(cen[0],v,1);
			tmp=2;
			for(i=1;i<=(D+1)/2-1;i++) tmp*=cmx[i],cmx[i]=0;
			ans=min(ans,tmp);
		}
		printf("%i %lld\n",(D+1)/2,ans);
	}
	return 0;
}

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

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
const int limit = 410;
using pint = pair<int,int>;

int h,w;
vector<string>s;

ll numb=0,numw=0;
bool paint[limit][limit];
void dfs(int x, int y){
  paint[x][y]=true;
  if(s[x][y]=='#') numb++;
  else numw++;
  
  for(int i=0; i<4; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    
    if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
    if(s[x][y] == s[nx][ny])continue;
    if(paint[nx][ny]) continue;
    
    dfs(nx,ny);
  }  
}

int main(){
  cin >> h >> w;
  s.resize(h);
  for(int i=0; i<h; i++) cin >> s[i];
  
  ll ans=0;
  for(int x=0; x<h; x++){
   for(int y=0; y<w; y++){
     if(paint[x][y]) continue;
     numb = numw = 0;
     dfs(x,y);
     ans+= numb*numw;
   }
  }
  
  
  cout << ans << endl;
  
  
  return 0;
  
  
  
}
  
  
  
  


Measured memory_bytes: 18176
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  char s[11];
  scanf("%s",s);
  int n=strlen(s);
  if(n>=4&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
    printf("Yes\n");
  else
    printf("No\n");
}

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

long tr(int x) {
	return  1l * x * x * x; //long型にするため1l
}

int main() {
	int n, k;
	long c = 0;
	cin >> n >> k;

	if (k % 2 == 0) {
		c=tr((n + k / 2) / k);
	}
	cout << tr(n / k) + c << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>)
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) a.size()
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl
#define debgp(a) cout<<#a<<" "<<a.fi<<" "<<a,se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(const auto&y:a){for(const auto&x:y)cout<<x<<" ";cout<<endl;}
#define fi first
#define se second
#define V vector
#define P pair
#define PQ priority_queue
typedef long long ll;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<PL> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<class T>T gcd(T a,T b){return (b==0?a:gcd(b,a%b));}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*a;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  str s;
  cin>>s;
  str akiba="#KIHBR#";
  bool ans=true;
  s='#'+s+'#';
  for(int i=1;i<SZ(s);++i){
    if(s[i]=='A' && i!=SZ(s)-1 && s[i+1]=='A')ans=false;
    if(s[i]=='K' && (s[i-1]!='#' && s[i-1]!='A'))ans=false;
    if(s[i]=='K' && s[i+1]!='I')ans=false;
    if(s[i]=='I' && s[i+1]!='H')ans=false;
    if(s[i]=='H' && (s[i+1]!='A' && s[i+1]!='B'))ans=false;
    if(s[i]=='B' && (s[i+1]!='A' && s[i+1]!='R'))ans=false;
    if(s[i]=='R' && (s[i+1]!='#' && s[i+1]!='A'))ans=false;
  }
  for(auto itr=s.begin();itr<s.end();){
    if(*itr=='A')s.erase(itr);
    else itr++;
  }
  //debg(s);debg(akiba);debg(ans);

  cout<<(s==akiba&&ans?"YES":"NO")<<endl;
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
#define N 500000
 
void merge(int*, int, int);
 
int a[N],n,count=0;
int temp[N];
 
 
int main(){
 
  int i,j;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 
    merge(a,0,n-1);
 
  for(i=0;i<n-1;i++) printf("%d ",a[i]);
  printf("%d",a[n-1]);
  printf("\n%d\n",count);
 
  return 0;
}
 
 
void merge(int x[],int left,int right){
 
  int mid,i,j,k;
 
  if(left>=right) return;
 
  mid=(left+right)/2;
 
  merge(x,left,mid);
  merge(x,(mid+1),right);
 
  for(i=left;i<=mid;i++){
    temp[i]=x[i];
  }
 
  for(i=(mid+1),j=right;i<=right;i++,j--){
    temp[i]=x[j];
  }
 
  i=left;
  j=right;
 
  for(k=left;k<=right;k++){
 
    if(temp[i]<=temp[j]) x[k]=temp[i++];
    else x[k]=temp[j--];
 
    count++;
}
 
}

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

using ll = long long;

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

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

int main() {
  ll N;
  scanf("%lld", &N);

  //map<ll, ll> mp= prime_factor(N);
  vector<ll> ve = enum_div(N);
  ll ans = N;
  for (auto f : ve) {
    ans = min(ans, (f - 1) + (N / f - 1));
  }

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

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

#define endl '\n'

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

    map <int, int> m;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int v;
        cin >> v;
        m[v]++;
    }
    int res = 0;
    for(auto i : m) {
        if(i.second % 2 == 1)
            res++;
    }
    cout << res;
    
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N, W;
ll dp[105][100005];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i = 0; i < N; i++) {
        cin>>w[i]>>v[i];
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(i == 0) { if(j >= w[i]) dp[i][j] = v[i];}
            else if(j - w[i] >= 0) dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    cout<<dp[N-1][W]<<endl;

    return 0;
}

Measured memory_bytes: 80128