akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll A, B, C, K; cin >> A >> B >> C >> K;
	ll sum = 0;
	if (K < A) {
		cout << K << endl;
		return;
	}
	sum += A;
	K -= A;
	if (K < B) {
		cout << sum << endl;
		return;
	}
	K -= B;
	cout << sum - K << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
int main(){
    int N;
    cin >> N;
    int t = N;
    int sum = 0;
    int dig;
    while(t){
        dig = t % 10;
        sum = sum + dig;
        t = t / 10;
    }
    if(N % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int m; cin >> m;
  vector<int> p(m), x(m);
  rep(i, m) cin >> p[i] >> x[i];

  int sum = 0;
  rep(i, n) sum += a[i];
  rep(i, m) {
    cout<<sum-a[p[i]-1]+x[i]<<endl;
  }
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> A(n, -1);
	int v, w;
	bool flag = true;
	for (int i = 0; i < m; i++) {
		cin >> v >> w;
		if (A[v - 1] == -1) {
			A[v - 1] = w;
		}
		else {
			if (A[v - 1] != w) {
				flag = false;
				break;
			}
		}
	}
	if (n > 1 && A[0] == 0)  flag = false;
	if (n > 1 && A[0] == -1)  A[0] = 1;
	if (flag) {
		for (int i = 0; i < n; i++) {
			if (A[i] != -1)  cout << A[i];
			else  cout << 0;
		}
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}

}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	string s1,s2;
	cin >> s1 >> s2;
	string s = s1 + s2;
	int x = stoi(s);
	string ans = "No";
	for (int i = 1; i < x; ++i) {
		if (x == i * i) ans = "Yes";
	}
	cout << ans << endl;
	
} 

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

using namespace std;
typedef pair<string, int> P;
/** Problem0179 : Mysterious Worm **/
int bfs(string in)
{
	queue<P> Q;
	map<string, int> d;
	
	Q.push(P(in, 0));
	
	while (Q.size()) {
		P p = Q.front(); Q.pop();
		string s = p.first;
		
		if (d[s]) continue;
		
		bool flag=true;
		rep(i, s.length()-1) {
			if (s[i] != s[i+1]) {
				flag = false;
				break;
			}
		}
		if (flag)
			return p.second;
		
		d[s] = 1;
		
		rep(i, s.length()-1) {
			string ns = s;
			if (s[i] != s[i+1]) {
				char c1 = s[i], c2 = s[i+1], nc;
				if (c1 != 'r' && c2 != 'r')
					nc = 'r';
				else if (c1 != 'g' && c2 != 'g')
					nc = 'g';
				else if (c1 != 'b' && c2 != 'b')
					nc = 'b';
				
				ns[i]=nc;
				ns[i+1]=nc;
				
				Q.push(P(ns, p.second+1));
			}
		}
	}
	return -1;
}

int main()
{
	string s;
	int ans;
	while (cin>>s, s!="0") {
		ans = bfs(s);
		if (ans >= 0)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
from itertools import accumulate
N, Q =map(int, input().split())
s = input()
AC = [0]*(N-1)
for i in range(N-1):
  if s[i:i+2] == 'AC':
    AC[i] = 1   
B = [0] +AC
B = list(accumulate(B))
for i in range(Q):
  l,r = map(int, input().split())
  print(B[r-1]-B[l-1])
  

Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    double r;
    cin >> r;
    cout << r*M_PI*2 << endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, e = 1;
    ll b[200005] = {}, c[200005] = {}, d[200005] = {};
    ll z = mod * 890328ll;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], b[i] = b[i - 1] + a[i];
    for (int i = 2; i < n; i++) {
        while (b[e] + b[e] < b[i]) e++;
        ll f = abs(b[e] + b[e] - b[i]), g = abs(b[e - 1] + b[e - 1] - b[i]);
        //cout << e << ' ' << f << ' ' << g << ' ';
        if (f < g) c[i] = min(b[e], b[i] - b[e]), d[i] = max(b[e], b[i] - b[e]);
        else c[i] = min(b[e - 1], b[i] - b[e - 1]), d[i] = max(b[e - 1], b[i] - b[e - 1]);
        //cout << c[i] << ' ' << d[i] << '\n';
    }
    reverse(a + 1, a + n + 1);
    reverse(c + 1, c + n + 1);
    reverse(d + 1, d + n + 1);
    for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
    e = 1;
    for (int i = 2; i + 1 < n; i++) {
        while (b[e] + b[e] < b[i]) e++;
        ll f = abs(b[e] + b[e] - b[i]), g = abs(b[e - 1] + b[e - 1] - b[i]), x, y;
        if (e == i) f = g = mod * 890328ll;
        //cout << e << ' ' << f << ' ' << g << ' ';
        if (f < g) x = min(b[e], b[i] - b[e]), y = max(b[e], b[i] - b[e]);
        else x = min(b[e - 1], b[i] - b[e - 1]), y = max(b[e - 1], b[i] - b[e - 1]);
        //cout << x << ' ' << y << ' ' << c[i + 1] << ' ' << d[i + 1] << '\n';
        z = min(z, max(d[i + 1], y) - min(c[i + 1], x));
    }
    cout << z;
}


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

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

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

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

using namespace std;

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

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

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  ll a[n], b[n];
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i] - (i+1);
  }
  sort(b, b+n);
  int med;
  if(n % 2 == 1) {
    med = b[n/2];
  } else {
    med = (b[n/2-1] + b[n/2])/2;
  }
  long long ans = 0;
  for(int i = 0; i < n; ++i) {
    ans += abs(b[i] - med);
  }
  cout << ans << endl;

  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M, K;
    cin >> N >> M >> K;
    Vl A(N), B(M);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < M; i++) {
        cin >> B[i];
    }
    Vl cumA(N + 1), cumB(M + 1);
    for (ll i = 0; i < N; i++) {
        cumA[i + 1] = cumA[i] + A[i];
    }
    for (ll i = 0; i < M; i++) {
        cumB[i + 1] = cumB[i] + B[i];
    }

    ll ans = 0;
    ll idx = M;
    for (ll i = 0; i <= N; i++) {
        if (cumA[i] > K) break;
        while (idx >= 0 && cumA[i] + cumB[idx] > K) {
            --idx;
        }
        ans = max(ans, i + idx);
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 9516
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

#define LL long long

const int MAXN = 500000 + 5;



int main()
{
    string S;
    cin >> S;
    int ans, cnt;
    ans = cnt = 0;
    for (int i = 0; i < S.length(); i ++){
        if (S[i] == 'R'){
            cnt ++;
        }
        else{
            cnt = 0;
        }
        if (cnt > ans){
            ans = cnt;
        }
    }
    cout << ans;
    system("pause");
    return 0;
}

Measured memory_bytes: 3684
object Main extends App {

  import scala.io.StdIn._

  val Array(w, h) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.split(' ').map(_.toLong) :+ 0L} :+ Array.tabulate(w + 1){_ ⇒ 0L}
  for (i ← (0 until h).reverse; j ← (0 until w).reverse) {
    state(i)(j) += state(i)(j + 1) + state(i + 1)(j) - state(i + 1)(j + 1)
  }
  val memo = Array.tabulate(h)({_ ⇒ Array.tabulate(w){_ ⇒ None: Option[Long]}})
  memo(h - 1)(w - 1) = if (((w + h) % 2 == 0 && state(h - 1)(w - 1) > 0) || ((w + h) % 2 == 1 && state(h - 1)(w - 1) < 0)) Some(state(h - 1)(w - 1)) else Some(-state(h - 1)(w - 1))
  val res = math.abs(solve(0, 0))
  println(res)
  def solve(x: Int, y: Int): Long = {
    if (x == w || y == h) 0
    else memo(y)(x) match {
      case Some(r) ⇒ r
      case None if (x + y) % 2 == 1 ⇒
        math.min(solve(x + 1, y) - state(y)(x) + state(y)(x + 1), solve(x, y + 1) + state(y)(x) - state(y + 1)(x)).also{r ⇒ memo(y)(x) = Some(r)}
      case None ⇒
        math.max(solve(x + 1, y) - state(y)(x) + state(y)(x + 1), solve(x, y + 1) + state(y)(x) - state(y + 1)(x)).also{r ⇒ memo(y)(x) = Some(r)}
    }
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, H; scanf("%d %d", &N, &H);
  vector<int> W(N), T(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &W[i], &T[i]);
  }
  sort(T.begin(), T.end(), greater<int>());
  sort(W.begin(), W.end(), greater<int>());
  int ans = 0, i = 0;
  while (H > 0 and i < N and T[i] > W[0]) {
    H -= T[i];
    ++i;
    ++ans;
  }
  if (H > 0) {
    ans += (H + W[0] - 1) / W[0];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
<>;$P=8*atan2 1,1;
for$s(@a=<>){
	($x,$y)=glob$s;
	@b=sort{$a<=>$b}map{/ /;atan2$'-$y,$`-$x}grep$_ ne$s,@a;
	push@b,"@b"+$P;
	printf"%f\n",sort{$b<=>$a}0,map+($b[$_]-$b[$_-1])/$P-.5,1..$#b;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	string s;
	cin>>s;
	ll n=s.size();
	ll tr=1;
	for(ll i=0;i<n;i++)
	{
		if(s[i]!=s[n-i-1])
		{
			cout<<"No\n";
			exit(0);
		}
	}
	for(ll i=0;i<n/2;i++)
	{
		if(s[i]!=s[(n/2)-i-1])
		{
			cout<<"No\n";
			exit(0);
		}
	}
	for(ll i=(n/2)+1;i<n;i++)
	{
		if(s[i]!=s[n-i-1+(n/2+1)])
		{
			cout<<"No\n";
			exit(0);
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

bool haveone(const string s) {
    for (auto &&item : s) {
        if (item == '1') {
            return true;
        }
    }
    return false;
}

int main() {
    string a, b;
    cin >> a >> b;

    const int n = a.length();

    if (!haveone(b)) {
        if (!haveone(a)){
            cout << 0 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }

    auto ls = [&](const int p, const int s) {
        return (p - s + n + n) % n;
    };

    auto rs = [&](const int p, const int s) {
        return (p + s) % n;
    };

    auto dist = [&](const int p, const int q) {
        return min(abs(q - p), n - abs(q - p));
    };

    vector<int> mls(n, n), mrs(n, n);
    for (int i = 0; i < n; ++i) {
        if (a[i] == '0') {
            continue;
        }
        for (int d = 0; d < n; ++d) {
            if (b[ls(i, d)] == '1') {
                mls[i] = min(mls[i], d);
            }
            if (b[rs(i, d)] == '1') {
                mrs[i] = min(mrs[i], d);
            }
        }
    }

    auto cost = [&](const int mxl, const int mxr, const int fls) {
        const int lpos = ls(0, mxl);
        const int rpos = rs(0, mxr);
        const int goal = ls(0, fls);
        const int lf = mxl * 2 + mxr + dist(rpos, goal);
        const int rf = mxr * 2 + mxl + dist(lpos, goal);
        return min(lf, rf);
    };

    int ans = 1 << 25;
    for (int fls = 0; fls < n; ++fls) {
        priority_queue<pair<int, int>> lrs;
        int add_cost = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] == '1' && b[ls(i, fls)] == '0') {
                lrs.emplace(mls[i], mrs[i]);
            }
            if (a[i] == '0' && b[ls(i, fls)] == '1') {
                add_cost += 1;
            }
        }
        const int decr_cost = lrs.size();

        int maxr = 0;
        while (not lrs.empty()) {
            auto t = lrs.top();
            lrs.pop();

            const int maxl = t.first;
            const int tans = decr_cost + cost(maxl, maxr, fls) + add_cost;
            ans = min<int>(ans, tans);

            maxr = max(maxr, t.second);
        }
        ans = min<int>(ans, decr_cost + cost(0, maxr, fls) + add_cost);
    }

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

Measured memory_bytes: 888
#include<iostream>
using namespace std;
void OutPut(int a[][10]) {
  for(int i=0; i<3; i++) {
    for(int j=0;j<10; j++) {
      cout << ' ' << a[i][j];
    }
    cout << endl;
  }
}
void Input(int a[][10], int b, int c, int d) {
  a[b-1][c-1] += d;
  if(a[b-1][c-1]<0) a[b-1][c-1]=0;
}
int main() {
  int Floor1[3][10]={};
  int Floor2[3][10]={};
  int Floor3[3][10]={};
  int Floor4[3][10]={};

  int n, b, f, r, v;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> b >> f >> r >> v;
    switch (b) {
      case 1: { Input(Floor1,f,r,v); break; }
      case 2: { Input(Floor2,f,r,v); break; }
      case 3: { Input(Floor3,f,r,v); break; }
      case 4: { Input(Floor4,f,r,v); break; }
    }
  }
  OutPut(Floor1);
  cout << "####################\n";
  OutPut(Floor2);
  cout << "####################\n";
  OutPut(Floor3);
  cout << "####################\n";
  OutPut(Floor4);
  return 0;

}



Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>

int main() {
	
	int n, d, x;
	cin >> n >> d >> x;
	int r = 0;
	for (int i = 0; i < n; i++) {
		r++;
		int p; cin >> p;
		r += (d - 1) / p;
		
	}
	cout << r+x << endl;
	return 0;
}

Measured memory_bytes: 256
NM = [int(i) for i in input().split()]
N = NM[0]
M = NM[1]
datalist = []
index = 0
cost = 0
num = 1
total_cost = 0
while(N > 0):
    data = [int(i) for i in input().split()]
    datalist.append(data)
    N -= 1
datalist.sort(key=lambda x:x[0])
while(M > 0):
    M -= datalist[index][num]
    total_cost += datalist[index][cost] * datalist[index][num]
    if(M < 0):
        n = abs(M)
        total_cost -= n * datalist[index][cost]
    index += 1
print(total_cost)

Measured memory_bytes: 22756
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;cin>>n;
  vector<pair<int,int>>p(n);
  
  rep(i,n){
    int x,y;
    cin>>x>>y;
    p[i]=make_pair(y,x);
  }
  sort(p.begin(),p.end());
  ll sum=0;
  rep(i,n){
    sum+=p[i].second;
    if(p[i].first<sum){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 1792
# include <iostream>
# include <vector>
# include <map>
using namespace std;

# define ll long long

bool checkPager(string s, int from, int to){
  for(int i=from; i<to; i++){
    if(s[i] == '#' && s[i+1] == '#') return true;
  }
  return false;
}

bool checkTitik(string s, int from, int to){
  for(int i=from; i<=to; i++){
    if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') return true;
  }
  return false;
}

int main(){
  
  int N, A, B, goalA, goalB;
  cin >> N >> A >> B >> goalA >> goalB;
  N--; A--; B--; goalA--; goalB--;
  
  string s;
  cin >> s;
  
  bool possible = false;
  if(checkPager(s, A, goalA) || checkPager(s, B, goalB)) possible = false;
  else if(goalA < goalB) possible = true;
  else if(checkTitik(s, B, goalB)) possible = true;
  
  cout << (possible ? "Yes" : "No") << endl;
  
  return 0;
} 



Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    string s;
    cin >> s;

    char c1 = s[0];
    char c2 = s[s.size()-1];
    bool gusu = (s.size() % 2 == 0);
    if(c1 == c2){
        if(gusu) cout << "First" << endl;
        else cout << "Second" << endl;
    } else {
        if(gusu) cout << "Second" << endl;
        else cout << "First" << endl;
    }
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next())-1;
		int b = Integer.parseInt(sc.next())-1;
		int c = Integer.parseInt(sc.next())-1;
		int d = Integer.parseInt(sc.next())-1;
		
		char []p = sc.next().toCharArray();
		
		
		for(int i = a ; i < Math.max(c,d) ;i++) {
			if(p[i]== '#' && p[i+1] == '#') {
				System.out.println("No");
				return;
			}
		}
		
		if(c < d) {
			System.out.println("Yes");
		}
		else {
			int len = 0;
			int max = 0;
			for(int i = b-1 ; i <= d+1 ;i++) {
				if(p[i] == '.') {
					len++;
				}
				else {
					max = Math.max(max, len);
					len = 0;
				}
			}
			max = Math.max(max, len);
			String ans = max >= 3 ? "Yes":"No";
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 28372
m=10**9+7;f=lambda a:max(0,(a-l)//k+1);r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()));s=-1;i=j=k=l=1
	while l<=x and k+l<=y:k,l,s=l,k+l,s+1;a=f(y)+f(x)
	for c in r(s):
		k,l=j,i+j*2
		for _ in r(s-c):k,l=l,k+l
		a,i,j=a+(y>=k)*f(x)+(x>=k)*f(y),j,i+j
	if x<2 or y<3:print(1,x*y%m)
	else:print(s+1,a%m)

Measured memory_bytes: 80864
N = int(input())
V = map(int, input().split())

import collections

E = []
O = []
for i, v in enumerate(V):
  if i % 2 == 0:
    E.append(v)
  else:
    O.append(v)

ec = collections.Counter(E)
oc = collections.Counter(O)
e_common = ec.most_common()
o_common = oc.most_common()

E1 = e_common[0][1]
E2 = 0
if len(e_common) > 1:
  E2 = e_common[1][1]

O1 = o_common[0][1]
O2 = 0
if len(o_common) > 1:
  O2 = o_common[1][1]

if e_common[0][0] == o_common[0][0]:
  A1 = N - E1 - O2
  A2 = N - O1 - E2
  print(min(A1, A2))
else:
  ans = N - E1 - O1
  print(ans)


Measured memory_bytes: 23348
using System;
using System.Collections.Generic;
using System.Linq;

namespace Volume24_2406
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var sandGlassCount = Convert.ToInt32(input[0]);
            var BoiledTime = Convert.ToInt32(input[1]);
            var Tolerance = Convert.ToInt32(input[2]);

            List<SandGlass> sandGlasses = new List<SandGlass>(sandGlassCount);
            input = Console.ReadLine().Split(' ');
            for (var i = 0; i < sandGlassCount; i++)
            {
                var sandGrass = new SandGlass(i + 1);
                sandGrass.Time = Convert.ToInt32(input[i]);
                sandGlasses.Add(sandGrass);
            }

            var BoiledTimeMin = BoiledTime - Tolerance;
            var BoiledTimeMax = BoiledTime + Tolerance;

            SandGlass result = null;

            sandGlasses = sandGlasses.Where(sandGlass => sandGlass.Time <= BoiledTimeMax).ToList();

            foreach(var sandGlass in sandGlasses)
            {
                for (int j = sandGlass.Time; j <= BoiledTimeMax; j += sandGlass.Time)
                {
                    if (BoiledTimeMin <= j && j <= BoiledTimeMax)
                    {
                        result = sandGlass;
                        break;
                    }
                }
                if (result != null) break;
            }
            Console.WriteLine(result != null ? result.ID.ToString() : "-1");
        }

        public class SandGlass
        {
            public int ID { get; protected set; }
            public int Time { get; set; }
            public SandGlass(int id)
            {
                ID = id;
            }
        }
    }
}

Measured memory_bytes: 9616
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#define N 1000000007
#define M 1000
using namespace std;

int main() {
	long long n,ans=1;
	long long yaku[M]={0};
	cin>>n;
	
	for(int i=1;i<=n;i++){
		int a=i;
		int cnt=2;
		while(a!=1){
			if(a%cnt==0){
				a=a/cnt;
				yaku[cnt]++;
			}else{
				cnt++;
			}
		}
	}
	
	for(int i=0;i<M;i++){
		ans=(ans*(yaku[i]+1))%N;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char island[15][15];
int dx[] = {0,1,-1,0};
int dy[] = {1,0,0,-1};
int count=0;

void check(int a, int b)
{
    int c,d, i;
    island[a][b] = 0;
    for(i = 0; i < 4; i++)
    {
        c = dx[i] + b;
        d = dy[i] + a;
        if(0 <= c && c < 12 && 0 <= d && d < 12 && island[d][c] == '1')
        {
            check(d,c);
        }
    }
}

int main()
{
    while(1)
    {
        int i, j;
        for(i = 0; i < 12; i++)
        {
            for(j = 0; j < 12; j++)
            {
                if (scanf(" %c", &island[i][j]) == EOF) return 0;
            }
        }
        /*
        for(i = 0; i < 12; i++)
        {
            for(j = 0; j < 12; j++)
            {
                printf("%c", island[i][j]);
            }
            puts("");
        }**/
        
        for(i = 0; i < 12; i++)
        {
            for(j = 0; j < 12; j++)
            {
                if(island[i][j] == '1')
                {
                    check(i,j);
                    count++;
                }
            }
        }
        printf("%d\n",count);
        count = 0;
    }

}

Measured memory_bytes: 968
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    visited = [False] * n
    route = [-1] * n
    now = 0
    start = -1
    for i in range(k):
        if visited[now]:
            for j in reversed(range(i)):
                if route[j] == now:
                    start = j
                    break
            loop = i-j
            pos = (k-start) % loop
            print(route[start+pos]+1)
            return

        route[i] = now
        visited[now] = True
        now = a[now]-1

    print(now+1)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 100052
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n, m; cin >> n >> m;
  vector<P> p(n);
  rep(i, n) cin >> p[i].fs >> p[i].sc;

  sort(ALL(p));
  ll sum = 0;
  int c = 0;
  rep(i, n){
    if(p[i].sc + c >= m){
      ll k = (m - c) * p[i].fs;
      cout << sum + k << endl;
      return 0;
    }else{
      sum += p[i].sc * p[i].fs;
      c += p[i].sc;
    }
    // cout << sum <<" " << c <<endl;
  }

  return 0;
}


Measured memory_bytes: 1792
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b, c = map(int, input().split())

if a <= c <= b or a >= c >= b:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 7880
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

seek :: String -> Char -> Maybe Int
seek s c = elemIndex c s

main = do
  [s] <- getString
  print $ (length s - fromJust (seek (reverse s) 'Z')) - fromJust (seek s 'A')



Measured memory_bytes: 14716
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println((a <= 9) && (b <= 9) ? a * b : "-1");
        sc.close();
    }
}


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

using ll = long long;

const int MAXN=200001;
const int p=int(1e9)+7;

int fac[200001];

int mod_exp(int a, int b)
{
	if(b==0) return 1;

	ll ans=mod_exp(a,int(b/2));
	ans*=ans;
	ans%=ll(p);

	if(b%2==1) ans*=ll(a);
	ans%=p;

	return ans;
}

int choose(int a, int b)
{
	ll cur = ll(fac[a]);
	cur*=ll(mod_exp(fac[b],p-2));
	cur%=ll(p);
	cur*=ll(mod_exp(fac[a-b],p-2));
	cur%=ll(p);
	return int(cur);
}

int sz[MAXN];
int sub[MAXN];
ll ans[MAXN];

bool sz_vis[MAXN];
bool sub_vis[MAXN];
bool ans_vis[MAXN];

int n;

vector<int> adj[MAXN];

void sz_dfs(int v)
{
	sz_vis[v]=1;

	for(auto u:adj[v])
	{
		if(sz_vis[u]) continue;
		sz_dfs(u);
		sz[v]+=sz[u];
	}

	sz[v]++;
}

void sub_dfs(int v)
{
	sub_vis[v]=1;

	ll v_ans=1LL;
	int left = sz[v]-1;

	for(auto u:adj[v])
	{
		if(sub_vis[u]) continue;

		sub_dfs(u);

		v_ans*=ll(sub[u]);
		v_ans%=ll(p);
		v_ans*=ll(choose(left,sz[u]));
		v_ans%=ll(p);
		left-=sz[u];
	}

	sub[v]=int(v_ans);
}

void ans_dfs(int v, int par)
{
	ans_vis[v]=1;

	if(par!=-1)
	{
		ll par_ans = ans[par];
		par_ans*=mod_exp(choose(n-1,sz[v]),p-2); // divide out by number of ways to interweave this child
		par_ans%=ll(p);
		par_ans*=mod_exp(sub[v],p-2); // divide out by number of ways for a given interweaving
		par_ans%=ll(p);

		// cout << v << " " << cur_ans << endl;
		
		// now interweave cur_ans from parent and sub[v]

		ll cur_ans = choose(n-1,sz[v]-1);
		cur_ans *= ll(sub[v]);
		cur_ans %= ll(p);
		cur_ans *= par_ans;
		cur_ans %= ll(p);

		ans[v]=cur_ans;
	}

	for(auto u:adj[v])
	{
		if(ans_vis[u]) continue;
		ans_dfs(u,v);
	}
}

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	cin>>n;

	fac[0]=1;
	for(int i=1; i<MAXN; i++)
	{
		ll cur = ll(i)*ll(fac[i-1]);
		fac[i]=int(cur%ll(p));
	}

	for(int i=1; i<n; i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	sz_dfs(1);
	sub_dfs(1);

	// work out the answer for 1

	ans[1]=sub[1];

	ans_dfs(1,-1);

	for(int i=1; i<=n; i++)
	{
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 18420
from collections import deque
N=int(input())
ver=[[] for i in range(N)] # (vertex,cost) in each vertex
for _ in range(N-1):
  a,b,c=map(int,input().split())
  ver[a-1].append((b-1,c))
  ver[b-1].append((a-1,c))

Q,K=map(int,input().split())

par=[-2 for i in range(N)]
par[K-1]=-1
q=deque([K-1])
while q:
    i=q.popleft()
    for j,c in ver[i]:
        if par[j]==-2:
            par[j]=i
            q.append(j)

cost=[-1 for i in range(N)]
cost[K-1]=0
stack=[[K-1,0]]
while stack:
    i,c=stack.pop()
    for j,d in ver[i]:
        if par[i]!=j:
            cost[j]=c+d
            stack.append([j,cost[j]])
# print(cost)
for _ in range(Q):
  x,y=map(int,input().split())
  print(cost[x-1]+cost[y-1])

  

Measured memory_bytes: 50224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

//#define DEBUG

string secret = "azAZ0990ZAza";
const int inf = 100000000;

int local(const string a, const string b) {
  vector< vector<int> > dp;

  dp = vector< vector<int> >(a.size() + 1, vector<int>(b.size() + 1, inf));
  dp[0][0] = 0;
  for (int i = 0; i <= a.size(); i++) {
    for (int j = 0; j <= b.size(); j++) {
      if (i > 0) 
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);

      if (j > 0) 
        dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);

      if (i > 0 && j > 0)
        dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1);

      if (i > 0 && j > 0 && a[i - 1] == b[j - 1])
        dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
    }
  }


  return dp[a.size()][b.size()];
}

int asked = 0;

int ask(const string s) {
  cerr << ++asked << '\n';

  #ifdef DEBUG
    return local(secret, s);
  #endif

  int x;
  cout << "? " << s << endl;
  cin >> x;
  return x;
}

const int maxLen = 128;

int total = 0;
vector<char> chars;
vector<string> parts;

int similarity(const string x) {
  return x.size() + total - ask(x);
}

string full(char c, int cnt) {
  string ans;
  ans.resize(cnt);
  for (int i = 0; i < cnt; i++) ans[i] = c;
  return ans;
}

bool cmp(string a, string b) {
  return a.size() > b.size();
}

string combine(const string le, const string ri, int l, int r) {
  string ans = "";

  for (int i = 0; i < l; i++) ans.pb(le[i]);
  for (int i = r; i >= 1; i--) ans.pb(ri[ri.size() - i]);

  return ans;
}

string merge(string le, string ri) {
  int l, r, pivot;
  string ans = "";

  l = 0;
  r = ri.size();
  pivot = similarity(combine(le, ri, l, r)); 

  while (l < le.size() || r > 0) {
    if (r == -1) break;

    if (l == le.size()) {
      ans.pb(ri[ri.size() - r]);
      r--;
      continue;
    }

    int aux = similarity(combine(le, ri, l + 1, r));
    if (pivot + 2 == aux) {
      ans.pb(le[l]);
      l++;
      pivot += 2;
    } else {
      ans.pb(ri[ri.size() - r]);
      r--;
      pivot -= 2;
    }
  }

  return ans;
}

int main()
{
  for (char c = 'a'; c <= 'z'; c++) chars.pb(c);
  for (char c = 'A'; c <= 'Z'; c++) chars.pb(c);
  for (char c = '0'; c <= '9'; c++) chars.pb(c);

  secret = "";
  srand(time(NULL));
  for (int i = 0; i < 97; i++) secret.pb(chars[rand() % 3]);

  for (auto c: chars) {
    int cnt = maxLen - ask(full(c, maxLen));
    if (cnt == 0) continue;
    parts.pb(full(c, cnt));
    total += cnt;
  }

  while (parts.size() > 1) {
    sort(parts.begin(), parts.end(), cmp);
    string a = parts.back(); parts.pop_back();
    string b = parts.back(); parts.pop_back();
    parts.pb(merge(a, b));
  }

  #ifdef DEBUG
  assert(parts[0] == secret);
  cerr << (parts[0] == secret) << '\n';
  #endif

  cout << "! " << parts[0] << endl;

  return 0;
}


Measured memory_bytes: 3776
# author:  Taichicchi
# created: 29.09.2020 22:35:47

import sys
n = int(input())

a = list(map(int, input().split()))

cnt = 0

for l in a:
    if l % 2:
        pass
    elif l % 4:
        cnt += 1
    else:
        cnt += 2

# print(f"{cnt=}")

if cnt // 2 >= n // 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 20020
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

typedef long long int lli;

int main()
{
	lli N;
	cin >> N;
	vector<lli> A;
	vector<lli> ans;
	A.resize(N);
	ans.resize(N);
	lli S =0;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		S += A[i];
	}

	{
		int i = 0;
		lli sum = 0;
		for (int j = 1; j < N; j += 2)
		{
			sum += A[(i + j) % N];
		}
		ans[i] = S - sum * 2;
	}
	
	for (int i = 0; i < N - 1; i++)
	{
		ans[i + 1] = A[i] * 2 - ans[i];
	}

	for (int i = 0; i < N; i++)
	{
		cout << ans[i] << (i == N - 1 ? "" : " ");
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace  std;
const ll INF = 1e18;
const ll MOD = 1000000007;
const int N = 101;
int n,x,t;


int main(){
    fastIO;
    cin>>n>>x>>t;
    int pieces = 0;
    int ans = 0;
    while(pieces<n){
        pieces+=x;
        ans+=t;
    }
    cout<<ans;
}


Measured memory_bytes: 3636
import math
import sys
N,K=map(int,input().split())
pi=list(map(int,input().split()))
dice=[0]*N
for i in range(N):
    dice[i]=pi[i]*(pi[i]+1)/2/(pi[i])
#print(dice)
a = sum(dice[0:K])
max=a
for i in range(1,N-K+1):
    a=a-dice[i-1]+dice[K+i-1]
    #print(dice[i:i+K])
    if a>max:
        max=a

print(max)



Measured memory_bytes: 73224
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define sz(x) ((int) x.size())
#define mp(x,y) make_pair(x,y)
#define f first
#define s second
#define pb push_back
#define P pair<ll,ll>
#define w(x) ll x; cin>>x; while(x--)
#define all(x) (x).begin(),(x).end()
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
const ll mod=1e9+7;

void go() {
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
const ll N=600;
ll H[N][N];
bool occ[N][N];
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};
void dfs(ll x,ll y,ll n){
    ll z=H[x][y]+occ[x][y];
    F(i,0,3){
        ll x1=x+dx[i];
        ll y1=y+dy[i];
        if(x1<1 || x1>n || y1<1 || y1>n)continue;
        if(H[x1][y1] > z){
            H[x1][y1]=z;
            dfs(x1,y1,n);
        }
    }

}
int main(){
    go();
    ll n;
    cin>>n;
    F(i,1,n){
        F(j,1,n){
            H[i][j]=min(min(i,n+1-i),min(j,n+1-j))-1;
            occ[i][j]=true;
        }
    }
    ll ans=0;
    F(i,1,n*n){
        ll a;
        cin>>a;
        ll x=(a+n-1)/n;
        ll y=a%n;
        if(y==0)y=n;
        //else x+=1;
        ans+=H[x][y];
        occ[x][y]=false;
        dfs(x,y,n);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 21728
#include <stdio.h>
#include <math.h>

int main( void )
{
 int D , N , a , ans , i;
 
scanf( "%d %d" , &D , &N );

a = pow( 100 , D );
ans = 0;
for( i=1; i<=N ; i++)
 ans += a;

if( N==100)
 ans +=a;

printf( "%d" , ans );

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if(((r <= x) && (w - r) >= x) && (r <= y) && (h - r) >= y ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
}

int main()
{
	zanj0();
	lli a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3612
N, Q = map(int, input().split())
s = input()
td = [input().split() for _ in range(Q)]
def C(x):
    if x == -1:
        return True
    if x == N:
        return False
    for t, d in td:
        if s[x] != t:
            continue
        if d == 'L':
            if x == 0:
                return True
            x-=1
        else:
            if x == N-1:
                return False
            x+=1
    return False
ans = N
ok = -1
ng = N
while ng-ok>1:
    mid = (ok+ng)//2
    if C(mid):
        ok = mid
    else:
        ng = mid
ans-=ok+1
s = list(reversed(s))
td = [[t, 'L'] if d == 'R' else [t, 'R'] for t, d in td]
ok = -1
ng = N
while ng-ok>1:
    mid = (ok+ng)//2
    if C(mid):
        ok = mid
    else:
        ng = mid    
ans-=ok+1
print(ans)

Measured memory_bytes: 126156
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	VVi c(3,Vi(3));
	bool ans=true;
	Vi sum1(3,0);
	Vi sum2(3,0);
	rep(i,3){
		rep(j,3){
			cin>>c[i][j];
			sum1[i]+=c[i][j];
			sum2[j]+=c[i][j];
		}
	}
	sort(all(sum1));
	sort(all(sum2));
	rep(i,2){
		ans&=!((sum1[i+1]-sum1[0])%3);
		ans&=!((sum2[i+1]-sum2[0])%3);
	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
void merge(int *,int,int,int);
void mergesort(int *,int,int);
int num=0;
int main(){
  int i,n,l=0,m;
  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  int r=n;
  mergesort(S,l,r);
  for(i=0;i<n;i++){
    if(i<n-1) printf("%d ",S[i]);
    else printf("%d\n",S[i]);
  }
  printf("%d\n",num);
  return 0;
}
void merge(int *A,int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j,k;
  int L[n1],R[n2];
  for(i = 0;i<n1;i++) L[i] = A[left + i];
  for(i = 0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    num++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }
}
void mergesort(int *A,int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }
}


Measured memory_bytes: 5632
input()
A = [int(a) for a in input().split()]
abs_sum = sum(abs(a) for a in A)
if 0 in A:
    print(abs_sum)
    exit()

neg_count = sum(a < 0 for a in A)
print(abs_sum - (0 if neg_count % 2 == 0 else 2 * min(abs(a) for a in A)))

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0;i<N;i++)cin >> L[i];
  int cnt=1; int d=0;
  for(int i=0;i<N;i++){
    d=d+L[i];
    if(d<=X)cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k[15],s[15][15];
int p[15];
int n,m;
int ans;
int check(int x){
	for(int i=0;i<m;i++){
			int l=0;
		for(int j=0;j<k[i];j++){
			l^=((x>>s[i][j])&1);
		}
		if(l!=p[i])
			return 0;
	}
	return 1;
}
int main(){
	
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&k[i]);
		for(int j=0;j<k[i];j++){
			scanf("%d",&s[i][j]);
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++)
		scanf("%d",&p[i]);
	ans=0;
	for(int i=0;i<(1<<n);i++){
		if(check(i))
			ans++;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    auto calc = [&] (int mask) {
        ll ret = 0LL;
        rep(i, n) {
            if((mask | a[i]) == mask) ret += b[i];
        }
        return ret;
    };

    ll ans = calc(k);
    rep(i, 30) {
        if(k & (1<<i)) {
            ll tmp = k - (1<<i);
            tmp |= (1<<i)-1;
            ans = max(ans, calc(tmp));
        }
    }

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

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int X, Y; cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs1 = Console.ReadLine().Split(' ');
            int n = int.Parse(inputs1[0]);
            int x = int.Parse(inputs1[1]);
            string[] inputs2 = Console.ReadLine().Split(' ');
            int[] x_Rpos = new int[n];
            for(int i = 0; i < inputs2.Length; i++)
            {
                x_Rpos[i] = Math.Abs(int.Parse(inputs2[i]) - x);
            }
            Array.Sort(x_Rpos);
            int[] nums = new int[n-1];
            for(int i = 1; i < n; i++)
            {
                nums[i-1] = G(x_Rpos[0], x_Rpos[i]); 
            }
            Array.Sort(nums);
            Array.Reverse(nums);
            int result = 0;
            for(int i = 0; i < nums.Length; i++)
            {
                if (Judge(x_Rpos, nums[i]))
                {
                    result = i;
                    break;
                }
            }
            if (n == 1) Console.WriteLine(x_Rpos[0]);
            else Console.WriteLine(nums[result]);
            Console.ReadLine();
        }

        static int G(int i1, int i2)
        {
            if (i2 % i1 != 0) return G(i2%i1, i1);
            else return i1;
        }

        static bool Judge(int[] array, int d)
        {
            for(int i = 0; i < array.Length; i++)
            {
                if (array[i] % d != 0) return false;
            }
            return true;
        }
    }
}


Measured memory_bytes: 20832