akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N;
string s[100000];
bool b;
ll m,a,r,c,h;
int main()
{
	cin>>N;
	rep(i,N) cin>>s[i];
	rep(i,N){
		if(s[i][0]=='M') m++;
		else if(s[i][0]=='A') a++;
		else if(s[i][0]=='R') r++;
		else if(s[i][0]=='C') c++;
		else if(s[i][0]=='H') h++;
	}
	cout<<m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h<<endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc116/a.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int x, y, z;
    cin >> x >> y >> z;
    cout << x * y / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var r2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int ret = 0;
            for (int i = 1; i <= N; i++)
            {
                var sum = r1.Take(i).Sum() + r2.Skip(i - 1).Take(N - i + 1).Sum();
                if (ret < sum)
                {
                    ret = sum;
                }
            }
            Console.WriteLine(ret);
        }

        
    }
}

Measured memory_bytes: 13396
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {

	ll N;
	cin >> N;
	ll s = 0;
	rep(i, 10) {
		ll tmp = N;
		ll pow = 1;
		rep(j, i) pow *= 10;
		tmp /= pow;
		tmp %= 10;
		s += tmp;
	}

	cout << (N % s == 0 ? "Yes" : "No") << endl;
}

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

using namespace std;

#define ll long long

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

  int n, d;
  cin >> n >> d;
  int cnt = 0;
  while (n--) {
    ll a, b;
    cin >> a >> b;
    if (sqrt(a * a + b * b) <= d) cnt++;
  }
  cout << cnt << "\n";

  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N;
    cin >> N;
    map<string,int>counter;
    for (int i=0; i<N; i++) {
        string key;
        cin >> key;
        if (counter.count(key) > 0) {
            counter[key] = counter[key] + 1;
        } else {
            counter[key] = 1;
        }
    }

    int64_t M;
    cin >> M;
    for (int i=0; i<M; i++) {
        string key;
        cin >> key;
        if (counter.count(key) > 0) {
            counter[key] = counter[key] - 1;
        } else {
            counter[key] = -1;
        }
    }

    int sum = 0;
    for (auto i = counter.begin(); i != counter.end(); ++i) {
        if (i->second > sum) {
            sum = i->second;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

class edge{
    public:
    int to, weight;
};

vector<edge> edges[100005];

bool ans[100005];

void dfs(int v, int prev) {
    for (auto u : edges[v]) {
        if(u.to == prev) continue;
        if(u.weight%2==0){
            ans[u.to] = ans[v];
        }else{
            ans[u.to] = !ans[v];
        }
        dfs(u.to, v);
    }
}


int main(){
    int n;
    cin >> n;
    rep(i, n-1){
        int u, v, w;
        cin >> u >> v >> w;
        edge e;
        v--;
        u--;
        e.to = v;
        e.weight = w;
        edges[u].emplace_back(e);
        e.to = u;
        edges[v].emplace_back(e);
    }

    rep(i, n){
        ans[i] = false;
    }

    dfs(0, -1);

    rep(i, n){
        if(ans[i]) {
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1100000000

int main(){
	
	int n;
	cin>>n;
	
	if(n==1)cout<<1<<endl;
	else if(n==2)cout<<4<<endl;
	else{
		vector<int> dp(n+1,0),sum(n+1,0);
		dp[0] = 1;
		sum[0] = 1;
		for(int i=1;i<=n;i++){
			dp[i] = sum[i-1];
			if(i!=1)dp[i] = mod(dp[i] - dp[i-2]);
			sum[i] = mod(sum[i-1] + dp[i]);
		}
		int ans = 0;
		ans = dp.back();
		ans = mod(ans + mod(dp[n-1]*(n-1)));
		for(int i=n-2;i>=0;i--){
			int k = 1+i;
			ans = mod(ans + mod(dp[i] * mod((n-k-1)*(n-1))));
			ans = mod(ans + mod(dp[i] * mod(k * n)));
			
		}
		
		
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 8064
a, b = gets.chomp.split.map(&:to_i)
n = (1..1000).bsearch {|x| (x * 0.08).to_i >= a && (x * 0.10).to_i >= b }
puts (n.nil? || (0.08 * n).to_i != a || (0.10 * n).to_i != b)? "-1" : n


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

void insertionSort(int A[], int N) {
  for (int i = 1; i < N; i++) {
    for (int i = 0; i < N; i++) {
      if (i == N - 1) {
        cout << A[i] << endl;
      } else {
        cout << A[i] << " ";
      }
    }

    int v = A[i];
    int j = i - 1;

    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
  }

  for (int i = 0; i < N; i++) {
      if (i == N - 1) {
        cout << A[i] << endl;
      } else {
        cout << A[i] << " ";
      }
    }
}

int main() {
  int N;
  cin >> N;
  int A[100];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  insertionSort(A, N);
  return 0;
}


Measured memory_bytes: 3092
from collections import deque

def shuffle(target, num):
    que = deque(list(target))
    [que.append(que.popleft()) for _ in range(int(num))]
    return "".join(que)

text = input()
while True:
    if text == "-": break
    count = input()
    for _ in range(int(count)):
        n = input()
        text = shuffle(text, n)
    print(text)
    text = input()


Measured memory_bytes: 6004
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int a,b;
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b;
	a=a-b*2;
	if (a<0) a=0;
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int n, d;
    cin >> n >> d;
    int yu = 40 * 40 * d;
    set<int> s;
    for (int i=1; i*i<=yu; i++) {
        s.insert(i*i);
    }
    vector<vector<int> > x(n, vector<int> (d));
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            int dis = 0;
            for (int k=0; k<d; k++) {
                dis += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
            }
            if (s.count(dis)) ans++;
        }
    }
    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    else {
        return false;
    }
}
struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    string s;
    int f = true;
    while (cin >> s) {
        for (auto&c : s) {
            if ('a' <= c && c <= 'z') {
                c = c - 'a' + 'A';
            }
            else if ('A' <= c && c <= 'Z') {
                c = c - 'A' + 'a';
            }
        }
        if (!f) cout << " ";
        else f = false;
        cout << s;
    }
    cout << endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cctype>
#include <stack>
#include <map>
#include <cstring>
#include <sstream>
#include <set>
#include <list>
#include <fstream>
#include <iomanip>
#include <assert.h>

#define ll long long
#define ull unsigned long long
#define pii std::pair<int, int>
#define op                            \
    std::ios::sync_with_stdio(false);\
    std::cin.tie(0);

const int INF = 0x3f3f3f3f;
const int maxn = (100000 + 5);
const int mod = (1000000007);

int main()
{
    op
    std::string s;
    char c;
    int t,f,q;
    int cnt=0;
    std::cin>>s;
    std::cin>>q;
    std::deque<char> str;
    for(char a:s) str.push_back(a);
    while(q--)
    {
        std::cin>>t;
        if(t==1)
            cnt++;
        else if(t==2)
        {
            std::cin>>f;
            std::cin>>c;
            if(f==1)
            {
                if(cnt%2) str.push_back(c);
                else str.push_front(c);
            }
            else
            {
                if(cnt%2) str.push_front(c);
                else str.push_back(c);
            }
        }
    }
    if(cnt%2) reverse(str.begin(),str.end());
    std::string ans;
    for(char i: str)
        ans+=i;
    std::cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1368
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MOD(x) ((x)%mod)
int n;
map<pair<int,int>,bool>m;
struct point
{
	long long x,y;
	int id;
}p[100005];
int cnt;
struct edge
{
	int u,v;
	long long w;
}e[400005];
bool cmp1(point a,point b)
{
	return a.x<b.x;
}
bool cmp2(point a,point b)
{
	return a.y<b.y;
}
bool cmp3(edge a,edge b)
{
	return a.w<b.w;
}
int fa[100005];
int find(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
long long sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&p[i].x,&p[i].y);
		p[i].id=i;
	}
	sort(p+1,p+1+n,cmp1);
	for(int i=1;i<n;i++)
	{
		if(m[make_pair(p[i].id,p[i+1].id)]) continue;
		if(m[make_pair(p[i+1].id,p[i].id)]) continue;
		m[make_pair(p[i].id,p[i+1].id)]=1;
		cnt++;
		e[cnt].u=p[i].id;
		e[cnt].v=p[i+1].id;
		e[cnt].w=min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y));
	}
	sort(p+1,p+1+n,cmp2);
	for(int i=1;i<n;i++)
	{
		if(m[make_pair(p[i].id,p[i+1].id)]) continue;
		if(m[make_pair(p[i+1].id,p[i].id)]) continue;
		m[make_pair(p[i].id,p[i+1].id)]=1;
		cnt++;
		e[cnt].u=p[i].id;
		e[cnt].v=p[i+1].id;
		e[cnt].w=min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y));
	}
	sort(e+1,e+1+cnt,cmp3);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=cnt;i++)
	{
		if(find(e[i].u)==find(e[i].v)) continue;
		fa[find(e[i].u)]=find(e[i].v);
		sum+=e[i].w;
	}
	printf("%lld",sum);
	return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int x, y; cin >> x >> y;

    int a[13] = {};
    a[1] = 1;
    a[3] = 1;
    a[5] = 1;
    a[7] = 1;
    a[8] = 1;
    a[10] = 1;
    a[12] = 1;

    a[4] = 2;
    a[6] = 2;
    a[9] = 2;
    a[11] = 2;

    a[2] = 3;

    if (a[x] == a[y]) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
//#include "SaveFuncs.cpp"

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr int DIV = 1000000007;	// 10e9+7
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; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
string strMulti(string t, int n) { string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }

/*****/

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

	int max = -INF;

	chmax(max, A + B);
	chmax(max, A - B);
	chmax(max, A * B);

	cout << max << endl;

	return 0;
}

/*****/

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

	Main();

	return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s;
	cin >> s;
	vector<int>ret;
	rep(i, s.size()) {
		if (s[i] == '0')ret.pb(0);
		else if (s[i] == '1')ret.pb(1);
		else if (s[i] == 'B' && ret.size() > 0) {
			ret.pop_back();
		}
	}
	for (auto a: ret)cout << a;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, A, B, Pi;
    cin >> N >> A >> B;
    ll c1 = 0;
    ll c2 = 0;
    ll c3 = 0;
    for(int i=0;i<N;i++){
        cin >> Pi;
        if(Pi <= A) c1++;
        else if(Pi <= B) c2++;
        else c3++;
    }

    cout<<min(c1, min(c2,c3))<<endl;

    return 0;
}

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

int main() {
    int X; cin >> X;
    // 100003 is prime number
    const int MAXP = 100003;
    vector<bool> isp(MAXP + 1, true);
    isp[0] = isp[1] = false;
    for(int i = 2; i <= MAXP; ++i) {
        if(isp[i]) {
            for(ll j = (ll)i * i; j <= MAXP; j += i) {
                isp[j] = false;
            }
        }
    }
    for(int i = X; i <= MAXP; ++i) {
        if(isp[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll i, j, k;

int main(){
    scanf("%lld", &N);
    ll ans = 0;
    rep(i,1,N+1){
        j = N / i;
        if(N%i==0){
            --j;
        }
        ans += j;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	sort(a.begin(),a.end());
	int maxd2 = (a[a.size()-1]+1)/2;
	int min=a[0];
	rep(i,a.size()-1)
	{
		//cout<<abs(maxd2-a[i])<<endl;
		if(abs(maxd2-min)>abs(maxd2-a[i]))
		min = a[i];
	}
	cout<<a[a.size()-1]<<" "<<min<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int area = a*b;
	int length = 2*(a+b);
	System.out.println(area + " " + length);
    }
}

Measured memory_bytes: 26112
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	string s;
	cin >> n;
	cin >> s;

	string t = s.substr(0, n / 2);

	if (t+t==s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

struct Point{
	long long X,Y;
	inline void read(){scanf("%lld%lld",&X,&Y);}
	inline long long plength(){return X*X+Y*Y;}
	Point(){X=Y=0;}
	Point(long long X_,long long Y_){X=X_,Y=Y_;}
};
struct Line{
	Point A,B;
	inline void read(){A.read(),B.read();}
	Line(){}
	Line(const Point &A_,const Point &B_){A=A_,B=B_;}
};
typedef Point Vector;
inline Vector operator - (const Point &A,const Point &B){return Vector(A.X-B.X,A.Y-B.Y);}
inline long long operator ^ (const Point &A,const Point &B){return A.X*B.X+A.Y*B.Y;}
inline long long operator * (const Point &A,const Point &B){return A.X*B.Y-A.Y*B.X;}
inline Point operator + (const Point &A,const Vector &B){return Point(A.X+B.X,A.Y+B.Y);}
inline Vector operator * (const Vector &A,long long k){return Vector(A.X*k,A.Y*k);}

int Q;

inline long long sqr(long long k){return k*k;}

Point Projection(const Line &L,const Point &P){
	long long len=((P-L.A)^(L.B-L.A))/(L.B-L.A).plength();
	return L.A*(1-len)+L.B*len;
}

Point Reflection(const Line &L,const Point &P){
	Point projection=Projection(L,P);
	return projection+(projection-P);
}

inline bool isParallel(const Line &T,const Line &W){return (T.B-T.A)*(W.B-W.A)==0;}
inline bool isOrthogonal(const Line &T,const Line &W){return ((T.B-T.A)^(W.B-W.A))==0;}

Line A,B;

int main(){
	scanf("%d",&Q);
	while (Q--){
		A.read(),B.read();
		if (isParallel(A,B)) puts("2");
		else if (isOrthogonal(A,B)) puts("1");
		else puts("0");
	}
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()

const int INIT = 0;//適当に変える

int gcd(int x, int y) {
  return y ? gcd(y, x % y) : x;
}

struct segmentTree{
private:
    int n;
    vector<int> node;

public:
    segmentTree(vector<int> vec){
        int sz = vec.size();
        n = 1;while(n<sz)n*=2;
        node.resize(2*n-1,INIT);

        For(i,0,sz){
            node[i+(n-1)] = vec[i];
        }
        for(int i=n-2;i>-1;i--){
            node[i] = gcd(node[2*i+1],node[2*i+2]);//演算子は適当に
        }
    }
    void update(int x,int val){
        x+=(n-1);
        node[x]=val;
        while(x){
            x=(x-1)/2;
            node[x]=gcd(node[2*x+1],node[2*x+2]);//演算子は適当に
        }
    }

    //区間[a,b) k:今見ているノード 
    int get(int a, int b, int k=0, int l=0, int r=-1) {
        // 最初に呼び出されたときの対象区間は [0, n)
        if(r < 0) r = n;

        // 要求区間と対象区間が交わらない
        if(r <= a || b <= l) return INIT;

        // 要求区間が対象区間を完全に被覆
        if(a <= l && r <= b) return node[k];

        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        int vl = get(a, b, 2*k+1, l, (l+r)/2);
        int vr = get(a, b, 2*k+2, (l+r)/2, r);
        int val = gcd(vl, vr);//演算子は適当に
        return val;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    For(i,0,n) cin >> vec[i];
    segmentTree segTree(vec);
    int ans=max(segTree.get(0,n-1),segTree.get(1,n));
    For(i,1,n-1){
        ans=max(ans,gcd(segTree.get(0,i),segTree.get(i+1,n)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b!=c){
        cout<<"Yes"<<endl;
        
    }else if(a==c&&a!=b){
        cout<<"Yes"<<endl;
    }else if(b==c&&c!=a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> ALSUM(N+1);
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
        ALSUM[i+1] = ALSUM[i] + A[i];
        ALSUM[i+1]%=MOD;
    }
    ll ans = 0;
    rep(i,N){
        ll tmp = A[i]*(ALSUM[N]+MOD-ALSUM[i+1]);
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const ll MOD=998244353;

int main(){
  ll N, K; cin >> N >> K; int ans = 0;
  while(N>0){
    N/=K; ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string input;

    cin >> input;

    std::istringstream stream(input);
    std::vector<std::string> result;
    std::string field;

    while (std::getline(stream,field,'/')) {
        result.push_back(field);
    }

    int year = stoi(result[0]);
    int month = stoi(result[1]);
    int day = stoi(result[2]);
    if (month < 4) {
        cout << "Heisei";
    }
    else if (month==4) {
        if (day <= 30) {
            cout << "Heisei";
        }
        else {
            cout << "TBD";
        }
    }
    else {
        cout << "TBD";
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
S = {}
Answer = 2
for i in range(M):
    s,c = map(int,input().split())
    s = str(s)
    if s not in S:
        S[s] = str(c)
    else:
        if str(c) != S[s]:
            Answer = -1
            break
        else:
            continue
if N >= 2:
    if '1' in S:
        if N== 2 and S['1'] == '0':
            Answer = -1
        elif N == 3 and S['1'] == '0':
            Answer = -1
if Answer != -1:
    if '1' not in S and N >=2:
        Answer = '1'
    elif '1' not in S and N == 1:
        Answer ='0'
    else:
        Answer = S['1']
    for i in range(1,N):
        stri = str(i+1)
        if stri in S:
            Answer = Answer + S[stri]
        else:
            Answer = Answer + '0'
print(int(Answer))

Measured memory_bytes: 9248
function Main(input) {
  let i = input.split("\n")
  let count = i[0].split(" ")[1]
  let price = 0
  let all = i[1].split(" ")
  all = all.sort((a,b)=>+a - +b)
  for (let i = 0; i < count; i++) {
    price += +all[i]
  }
  console.log(price)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29676
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m=0,c=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>=a[i+1])
            c++;
        else
        {
            m=max(c,m);
            c=0;
        }
    }
    m=max(c,m);
    cout<<m<<endl;



}
//Alhamdulillah












Measured memory_bytes: 4000
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    s=input()
    if s == "AC":
        ac+=1
    elif s == "WA":
        wa+=1
    elif s == "TLE":
        tle+=1
    else:
        re+=1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))
    

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
char inv(char s){
	if(s == 'B') return 'W';
	else if(s == 'W') return 'B';
	else exit(1);
}

#define N 212345
vpii g[N];
int d[N];
vi od;
char s[N] = {}; // answer
int e[N]; // answer (weight of edges)

set<int> st;
void dfa(int a, int dd){
	if(d[a] != dd) return;
	if(st.find(a) != st.end()) return;
	st.emplace(a);
	DEBUG("  %d\n", a);
	for(auto &edge : g[a]) dfa(edge.first, dd);
}

void dfb(int a){
	for(auto &edge : g[a]){
		int i = edge.first;
		if(d[i] != d[a]) continue;
		if(s[i]) continue;
		s[i] = inv(s[a]), e[edge.second] = d[a];
		DEBUG(" s[%d]=%c, e[%d]=%d\n", i, s[i], edge.second, e[edge.second]);
		dfb(i);
	}
}

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, n) scanf("%d", d+i);
	REP(i, m){
		int u, v; scanf("%d%d", &u, &v); u--; v--;
		g[u].EB(v, i);
		g[v].EB(u, i);
	}

	fill(e, e+m, 1'000'000'000);

	REP(i, n) od.EB(i);
	sort(ALL(od), [](auto &x, auto &y){ return d[x] < d[y]; });
	for(const int &i : od){
		if(s[i]) continue;
		st.clear();
		DEBUG("Connected component of %d (d = %d)\n", i, d[i]);
		dfa(i, d[i]);
		if(st.size() == 1){
			int p = -1, r = -1, q = -1;
			for(auto &i : st){
				for(auto &edge : g[i]){
					if(d[i] > d[edge.first]){
						p = i;
						r = edge.first;
						q = edge.second;
						continue;
					}
				}
			}
			DEBUG(" (p, q) = (%d, %d)\n", p, q);
			if( p == -1 ) {
				printf("-1\n");
				return 0;
			}
			s[p] = inv(s[r]), e[q] = d[p];
			DEBUG(" s[%d]=%c, e[%d]=%d\n", p, s[p], q, e[q]);
			dfb(p);
		} else {
			s[i] = 'B';
			DEBUG(" s[%d]=%c\n", i, s[i]);
			dfb(i);
		}
	}
	
	printf("%s\n", s);
	REP(i, m){
		printf("%d\n", e[i]);
	}
}


Measured memory_bytes: 16888
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  //#define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       //Keys that pass all gates
       //Smart question and solution!
       //brute force, searching for all i in every [L,R](j) would be O(n^2)
       //Optimal smart way is O(M)
       int n,m,l,r,L,R=INT_MAX;
       cin>>n>>m;
       for (int i = 0; i < m; ++i)
       {
          cin>>l>>r;
          L=max(L,l);
          R=min(R,r);
       }
       if(L<=R)
       cout<<R-L+1;
        else cout<<0;
        return 0;
       }
       

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e5 + 10;

int n, m;

int b[MAXN], vis[MAXN], f[MAXN];
map<ll, ll> mp;
map<ll, ll> st[MAXN];

void prework(){
	m = 0;
	int N = 1e3 + 10;
	for(int i = 2; i <= N; i++)
		vis[i] = 0;
	for(int i = 2; i <= N; ){
		b[++m] = i;
		for(int j = i; j <= N; j += i)
			vis[j] = 1;
		while(i <= N && vis[i])
			i++;
	}
//	cout<<m<<endl;
}

int cnt;

void read(){
	scanf("%d", &n);
	mp.clear();
	cnt = 0;
	for(int i = 1; i <= n; i++){
	//	cout<<i<<'='<<endl;
		ll x;
		scanf("%lld", &x);
	//	cout<<x<<endl;
		for(ll j = 2; j * j * j <= x; j++){
		//	cout<<j<<endl;
			while (x % (j * j * j) == 0){
				x /= (j * j * j);
			}
		}
		ll z = x;
		ll y = 1;
	//	cout<<x<<' '<<y<<' '<<z<<endl;
		int msk = 0, num = 0;
		for(int j = 1; j <= m && x > 1; j++){
		//	cout<<j<<endl;
			if (x % b[j] == 0){
				y *= b[j];
				x /= b[j];
				msk <<= 1;
				if (x % b[j] == 0) {
					x /= b[j];
					msk |= 1;
				}
				num++;
			}
		}
		if (x != 1){
			ll qq = (ll)(sqrt(x + 0.5));
			if (qq * qq == x){
				y *= qq;
				num++;
				msk <<= 1; msk |= 1;
			}
			else{
				y *= x;
				num++;
				msk <<= 1;
			}
		}
	//	cout<<' '<<y<<' '<<num<<' '<<msk<<endl;
		auto Nico = mp.find(y);
		if (Nico == mp.end()){
			cnt++;
			mp[y] = cnt;
			f[cnt] = (1 << num) - 1;
			st[cnt].clear();
			st[cnt][msk] = 1;
		}
		else{
			int p = Nico->second;
			auto Umi = st[p].find(msk);
			if (Umi == st[p].end()){
				st[p][msk] = 1;
			}
			else
				Umi->second = Umi->second + 1;
		}
	}
//	puts("= -");
}

PII C[MAXN];

void solve(){
	int ans = 0;
//	cout<<"map: "<<mp.size()<<endl;
	for(auto i = mp.begin(); i != mp.end(); i++){
		ll y = i->first, z = i->second;
	//	cout<<"==========================="<<endl<<y<<' '<<z<<' '<<' '<<f[z]<<endl;
		if (y == 1){
			ans++;
		}
		else{
			int ooo = f[z];
			int o = 0;
		//	cout<<st[z].size()<<endl;
			for(auto j = st[z].begin(); j != st[z].end(); j++){
				o++;
				C[o] = PII(j->first, j->second);
			//	cout<<C[o].	first<<' '<<C[o].second<<endl;
			}
			for(int j = 1; j <= o; j++){
				auto Nico = st[z].find(ooo ^ C[j].first);
				if (Nico == st[z].end()){
					ans += st[z][C[j].first];
				}
				else{
					ans += max((ll)st[z][C[j].first], Nico->second);
					Nico->second = 0;
					st[z][C[j].first] = 0;
				}
			}
		}
	}
	cout<<ans<<endl;
}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		prework();
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 22528
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define nl "\n"
#define fr first
#define sc second
#define MP make_pair
#define pb push_back
#define VI vector<int>
#define VII vector<ll>
#define MAP map <int,int>
#define PI pair < int , int >
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define precise(n) fixed(cout);cout<<setprecision(n)

const int N = (int)4e7;
const int MOD = (int)1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;

#ifdef CODE_MAFIA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    ///Let the showdown begin

    int t;
    cin >> t;

    while (t--)
    {
        cout << "ACL";
    }

    ///Happily DONE

    return 0;
}


Measured memory_bytes: 3556
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int H,W;
int N;
int ans[101][101];
queue<int> que;

void calc() {
  rep(i, H) {
    if (i%2==0) {
      rep(j, W) {
        int q = que.front();que.pop();
        ans[i][j] = q;
      }
    } else {
      for (int j=W-1; j>=0; j--) {
        int q = que.front();que.pop();
        ans[i][j] = q;
      }
    }
  }
}

int main() {
  INCANT;
  cin >> H >> W;
  cin >> N;
  int a;
  rep(i, N) {
    cin >> a;
    while(a--) que.push(i+1);
  }
  calc();
  rep(i, H) {
    rep(j, W) cout << ans[i][j] << ' ';
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
while(a,b,c=gets.split.map(&:to_i))!=[-1,-1,-1]
if 2.step(16).none?{|base|begin Integer(a.to_s(base))==b rescue nil end} then p -1;next end
(a+1).step(c){|i|b=2.step(16).map{|base|begin z=i.to_s(base).to_i;b<=z ? z : 1e9 rescue 1e9 end}.min}
p b
end

Measured memory_bytes: 2564
import sys
# input = sys.stdin.readline
inf = 10 ** 18

N = int(input())
A = list(map(int, input().split()))

from collections import deque

A = deque(sorted(A))

pm = N % 2
ans = []
for i in range(N - 2):
    # print("#", list(A))
    A_min = A.popleft()
    A_max = A.pop()
    #
    A_dif = A_max - A_min
    if A_dif - A[0] > A[-1] - (-A_dif):
        ans.append((A_max, A_min))
        A.append(A_max - A_min)
    else:
        ans.append((A_min, A_max))
        A.appendleft(A_min - A_max)
    
ans.append((A[1], A[0]))

print(A[1] - A[0])
for x, y in ans: print(x, y)

Measured memory_bytes: 19280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var rl = spr(RL()).Select(x=>(int)c2i(x)).ToList();
            var ret = rl.First() * rl.Last();


            Console.WriteLine(ret);
            Console.ReadLine();
        
        }
        
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 28328
N,M = map(int,input().split())
A = set(int(input()) for m in range(M))
dp = (N+1)*[0]
dp[0] = 1

for n in range(1,N+1):
  if n not in A:
    dp[n] = (dp[n-2]+dp[n-1])%(10**9+7)

print(dp[-1])

Measured memory_bytes: 17236
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 1e5+2;
const int mod = 1e9+7;
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
signed main()
{
    fast;
    int n,m;
    cin>>n>>m;
    int dp[n+1][m+1];
    char a[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cin>>a[i][j];
    }
    dp[1][1] = 1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j] == '#')
            {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j]+= add(dp[i-1][j],dp[i][j-1]);
           // cout<<dp[i][j]<<" ";
        }
       // cout<<endl;
    }
    cout<<dp[n][m];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  string S; cin >> S;
  if(S == "RRR"){
    cout << "3";
  }
  else if(S == "RRS" || S == "SRR"){
    cout << "2";
  }
  else if(S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR"){
    cout << "1";
  }
  else{
    cout << "0";
  }
}

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

static const int MAX=1e5+1;
static const int INF=1e8;

int N;
vector<vector<int>> g(MAX); //有向グラフの隣接リスト
vector<int> out; //頂点をトポロジカルソートした配列
bool used[MAX]={};
int ind[MAX];
vector<int> dist(MAX,0);

void bfs(int s){
    queue<int> q;
    q.push(s);
    used[s]=true;
    dist[s]=0;
    while(!q.empty()){
        int u=q.front(); q.pop();
        out.push_back(u);
        for(auto it=g[u].begin();it!=g[u].end();it++){
            int v=*it;
            ind[v]--;
            dist[v]=max(dist[u]+1,dist[v]);
            if(ind[v]==0&&used[v]==false){ //入次数が0になったら追加
                used[v]=true; //再訪しない
                q.push(v);
            }
        }
    }
}

void tsort(){
    for(int i=0;i<N;i++){
        ind[i]=0;
    }
    for(int u=0;u<N;u++){
        for(auto it=g[u].begin();it!=g[u].end();it++){
            int v=*it;
            ind[v]++; //各頂点の次数を計算
        }
    }
    for(int u=0;u<N;u++){
        if(ind[u]==0&&used[u]==false) bfs(u);
    }
    //for(int i=0;i<out.size();i++){
        //cout << out[i] << endl;
    //}
}

int main(){
    cin >> N;
    int M; cin >> M;
    int a[N-1+M],b[N-1+M];
    for(int i=0;i<N-1+M;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        g[a[i]].push_back(b[i]);
    }
    tsort();
    int ans[N]={};
    for(int i=0;i<N-1+M;i++){
        if(dist[b[i]]-dist[a[i]]==1){
            ans[b[i]]=a[i]+1;
        }
    }
    for(int i=0;i<N;i++){
        cout << ans[i] << endl;
    }
    
}


Measured memory_bytes: 8824
n, l = map(int, input().split())
if l >= 0:
    print(((n - 1) * l) + int(n * (n - 1) / 2))
elif l + n - 1 < 0:
    print(((n - 1) * l) + int((n - 1) * (n - 2)/ 2))
else:
    i = 0
    while l + i < 0:
        i = i + 1
    left = -1 * (l + i)
    right = l + i + 1
    m = min(left, right)
    print((n * l) + int(n * (n - 1) / 2) - m)

Measured memory_bytes: 3064
n, q = map(int, input().split())
tasks = [(li[0], int(li[1])) for li in [input().split() for _ in range(n)]]

elapsed = 0
while len(tasks):
    name, time = tasks.pop(0)
    if time > q:
        elapsed += q
        tasks.append((name, time - q))
    else:
        elapsed += time
        print('{0} {1}'.format(name, elapsed))

Measured memory_bytes: 22972
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n = read::<usize>();
    let a = read::<String>().chars().collect::<Vec<char>>();

    for i in 0..n/2 {
        if a[i] != a[i+n/2] {
            println!("No");
            return;
        }
    }

    if n % 2 == 0 {
        println!("Yes");
        return;
    }
    println!("No");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(x);
	int ans;
	if(x < 600) ans = 8;
	else if(x < 800) ans = 7;
	else if(x < 1000) ans = 6;
	else if(x < 1200) ans = 5;
	else if(x < 1400) ans = 4;
	else if(x < 1600) ans = 3;
	else if(x < 1800) ans = 2;
	else ans = 1;
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


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

int N;
int V[270000], W[270000];
int Q;
int dp[550][100100];

void dfs(int v, int d) {
    if (v>N || d>9) return;
    rep(i, 100100) {
        dp[v][i] = dp[v/2][i];
        if (i>=W[v-1]) dp[v][i] = max(dp[v][i], dp[v/2][i-W[v-1]]+V[v-1]);
    }
    dfs(2*v, d+1);
    dfs(2*v+1, d+1);
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> V[i] >> W[i];
    rep(i, 550) rep(j, 100100) dp[i][j] = 0;
    dfs(1, 1);
    rep(i, 550) for (int j=1; j<100100; j++) dp[i][j] = max(dp[i][j], dp[i][j-1]);
    
    cin >> Q;
    while (Q--) {
        int v, L; cin >> v >> L;
        if (v<=511) printf("%lld\n", dp[v][L]);
        else {
            vector<int> vl, wl;
            while (v>511) {
                vl.pb(V[v-1]);
                wl.pb(W[v-1]);
                v /= 2;
            }
            int ans = 0;
            rep(S, 1<<(vl.size())) {
                int now_v = 0, now_w = 0;
                rep(i, vl.size()) {
                    if ((S>>i)&1) {
                        now_v += vl[i];
                        now_w += wl[i];
                    }
                }
                if (now_w>L) continue;
                ans = max(ans, now_v+dp[v][L-now_w]);
            }
            printf("%lld\n", ans);
        }
    }
}

Measured memory_bytes: 437940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	cin>>x;
	vector<bool> expo(x+1);
	
	expo[1] =1;
	for(int b=2;b<=x;b++)
	{
		int v=b*b;
		while(v<=x)
		{
			expo[v]=1;
			v*=b;
		}
	}
	
	for(int i=x;i>=1;i--)
	   if(expo[i])
	   {
	   	   cout<<i<<endl;
	   	   return 0;
	   }
	   
}

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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    if(k == 1)cout << "OK" << endl;
    else if(k >=a && k <= b)cout << "OK" << endl;
    else if (k == 0)cout << "NG" << endl;
    else{
        int some,ans;
        some = a % k;
        ans = a - some + k;
        if(ans <= b && ans >= a)cout << "OK" << endl;
        else if(ans - k <= b && ans - k >= a)cout << "OK" << endl;
        else cout << "NG" << endl;
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  string s; cin >> s;
  int n = s.size();
  ll d[n+1][13];
  ll mod = 1e9+7;
  memset(d,0,sizeof(d));
  d[0][0] = 1;

  for(int i=1;i<=n;i++){
    char c = s[i-1];
    for(int j=0;j<10;j++){
      if(c=='?'||j==c-'0'){
        for(int k=0;k<13;k++){
          d[i][(10*k+j)%13] += d[i-1][k];
          d[i][(10*k+j)%13] %= mod;
        }
      }      
    }
  }
  cout << d[n][5] << endl;
}


Measured memory_bytes: 13908
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] num = new int[N];
		int add=0;
		for (int i=0;i<N ;i++ ) {
			num[i]=scan.nextInt();
			add+=num[i];
		}

		double hei = (double)add/N;

		double min = 200;
		int mem = 0;
		double mai = 0;
		for (int i=0;i<N ;i++ ) {
			mai = hei-num[i];
			if(mai<0){mai*=-1;}
			if(mai<min){
				min=mai;
				mem=i;
			}
		}
		System.out.println(mem);

	}
}

Measured memory_bytes: 23252