akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int N, K, C;

using pint = pair<int,int>;
vector<pint> sub(const string &S) {
    int N = S.size();
    int cur = 0, last = -C-1;
    vector<pint> res(N+1, {cur, C});
    for (int i = 0; i < N; ++i) {
        if (i - last > C && S[i] == 'o') {
         ++cur, last = i;
        }
        res[i+1] = pint(cur, i - last);
    }
    return res;
}

string S;
void solve() {
    const auto &left = sub(S);
    string T = S;
    reverse(T.begin(), T.end());
    const auto &right = sub(T);

    //COUT(left); COUT(right);

    vector<int> res;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'x') continue;
        auto l = left[i];
        auto r = right[N-i-1];

        if (l.first + r.first < K) res.push_back(i+1);
        else if (l.first + r.first == K
        && l.second + r.second + 1 < C) res.push_back(i+1);

/*
        COUT("-------------");
        COUT(i);
        COUT(l);
        COUT(r);
        */
    }
    for (auto v : res) cout << v << endl;
}

int main() {
    while (cin >> N >> K >> C >> S) {
        solve();
    }
}

















Measured memory_bytes: 5880
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val preorder: Vector[Int] = io.StdIn.readLine().split(" ").map(_.toInt).toVector
  val inorder: Vector[Int] = io.StdIn.readLine().split(" ").map(_.toInt).toVector
  val postorder = toPostOrder(inorder)
  println(postorder.mkString(" "))

  def toPostOrder(l: Vector[Int]): Vector[Int] = l match {
    case Vector() | Vector(_) => l
    case _ => {
      val p: Int = l.indices.minBy(i => preorder.indexOf(l(i)))
      val left: Vector[Int] = l.take(p)
      val right: Vector[Int] = l.drop(p+1)
      toPostOrder(left) ++ toPostOrder(right) ++ Vector(l(p))
    }
  }
}


Measured memory_bytes: 44456
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int data[10][3][4];
int main(){
	REP(i,10) REP(j,3) REP(k,4) data[i][j][k] = 0;
	int n;
	cin >> n;
	REP(i,n){
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		data[r-1][f-1][b-1]+=v;
	}
	REP(j,4){
		REP(k,3){
			REP(h,10) {
				cout << " " << data[h][k][j];
			}
			cout << endl;
		}

		if(j!=3) cout << "####################" << endl;
	}
}

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

int main()
{
    int a, b, c, d, e, k, tmp=0;
    vector<int> sa(5);

    for (int i = 0; i < 5;i++){
        cin >> sa.at(i);
    }
    cin >> k;

    for (int i = 0; i < 5; i++){
        for (int j = 0; j < 5 - i;j++){
            if(sa.at(i) - sa.at(j)>k){
                tmp = 1;
            }
        }
    }
    if(tmp==0){
        cout << "Yay!" << endl;
    }
    else if(tmp=1){
        cout << ":(" << endl;
    }

    
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d', $n, $total);
$x = 0;
$y = 0;
for($x = 0; $x <= $n; $x++) {
    for($y = 0; $y <= $n; $y++) {
        $z = $n - $x - $y;
        if( (10000 * $x) + (5000 * $y) + (1000 * $z) == $total && $z >= 0) {
                
            echo($x . ' ' . $y . ' ' . $z . ' ');
            exit();
        }
    }
}
echo('-1 -1 -1');

Measured memory_bytes: 4604
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

def f(n):
    nn = min(a[n], b[n])
    nnn = min(a[n+1], b[n] - nn)
    a[n+1] -= nnn
    return nn + nnn

for i in range(n):
    ans += f(i)

print(ans)

Measured memory_bytes: 19116
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, d = LI()
    xy = LIR(n)
    ans = 0
    for x, y in xy:
        ans += d >= sqrt(x ** 2 + y ** 2)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 89572
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    }
    return d < 0? -1 : 1;
}

struct Vector {
    double x, y;
    Vector(double x=0, double y=0): x(x), y(y){
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

Vector operator+(const Vector& a, const Vector& b) {
    return Vector(a.x + b.x, a.y + b.y);
}

Vector operator*(const Vector& a, const double p) {
    return Vector(a.x * p, a.y * p);
}


bool intersectProp(const Point& a1, const Point& a2, const Point& b1, const Point& b2) {
    double c1 = cross(a2 - a1, b1 - a1);
    double c2 = cross(a2 - a1, b2 - a1);
    double c3 = cross(b2 - b1, a1 - b1);
    double c4 = cross(b2 - b1, a2 - b1);
    
    return dcmp(c1 * c2) == -1 && dcmp(c3 * c4) == -1;
}

bool onSegment(const Point& a, const Point& b, const Point& p) {
    Vector pa = a - p;
    Vector pb = b - p;
    return dcmp(cross(pa, pb)) == 0 && dcmp(dot(pa, pb)) <= 0;
}

bool intersect(const Point& a1, const Point& a2, const Point& b1, const Point& b2) {
    return intersectProp(a1, a2, b1, b2) || onSegment(a1, a2, b1) 
            || onSegment(a1, a2, b2) || onSegment(b1, b2, a1) || onSegment(b1, b2, a2);
}

Point lineIntesection(const Point& p, const Vector& v, const Point& q, const Vector& w) {
    Vector u = p - q;
    return p + v * (cross(w, u) / cross(v, w)); 
}

int main() {
    Point points[4];
    int q;
    cin >> q;
    for (int kase = 0; kase < q; kase++) {
        for (int i = 0; i < 4; i++) {
            cin >> points[i].x >> points[i].y;
        }
        Vector v1 = points[1] - points[0];
        Vector v2 = points[3] - points[2];

        Vector p = lineIntesection(points[0], v1, points[2], v2);
        
        cout << fixed << setprecision(8) << p.x << " " << p.y << endl;
    }
   
    return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	vector<pair<LL,int>> d(N);
	repp(i,0,N) cin >> d[i].second >> d[i].first;
	sort(d.begin(),d.end(),greater<pair<LL,int>>());
	vector<int> b(N+1,0);
	LL x = 0;
	LL s = 0;
	stack<LL> sushi;
	repp(i,0,K){
		s += d[i].first;
		if(b[d[i].second]) sushi.push(d[i].first);
		else {
			b[d[i].second] = 1;
			++x;
		}
	}
	int p = K;
	LL ans = s+x*x;
	while(!sushi.empty()){
		while(p < N && b[d[p].second]) ++p;
		if(p == N) break;
		b[d[p].second] = 1;
		s += d[p].first - sushi.top();
		sushi.pop();
		++x;
		ans = max(ans,s+x*x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int dp[3010][3010];

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int n = (int)s.size();
    int m = (int)t.size();
    // calc LCS length
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j] + 1);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            chmax(dp[i+1][j+1],dp[i][j+1]);
        }
    }
    // restore LCS
    string ans = "";
    int i = n, j = m;
    while(i > 0 && j > 0){
        if(dp[i][j]==dp[i-1][j]){
            --i;
        } else if(dp[i][j]==dp[i][j-1]){
            --j;
        } else {
            ans = s[i-1] + ans;
            --i;--j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {
   string S,T;
   cin>>S>>T;
   cout<<T<<S<<endl;






   return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	flag := 0
	for i := a; i <= b; i++ {
		if i % k == 0 {
			flag = 1
		}
	}
	if flag == 1 {
		fmt.Println("OK")
	} else {
		fmt.Println("NG");
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> a(N);
    rep(i,N)cin >> a[i];
    vector<int> _max = a;
    sort(All(_max));
    rep(i,N){
        if(_max[N-1]!=a[i])cout << _max[N-1] << endl;
        else cout << _max[N-2] << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	double sum=0;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		sum+=1.0/x;
	}
	cout<<1.0/sum;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	string s;
	cin >> s;
	rep(i, sz(s)) s[i] = 'x';
	cout << s;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[0]+[int(i) for i in input().split()]+[0]
S=0
for i in range(N+1):
  S+=abs(A[i]-A[i+1])
for i in range(1,N+1):
  Ki=abs(A[i-1]-A[i+1])-abs(A[i]-A[i+1])-abs(A[i]-A[i-1])
  print(S+Ki)


Measured memory_bytes: 14176
def nCr(n, r):
    r = min(r, n-r)
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i
    return numerator // denominator

N= int(input())
s = [''.join(sorted(list(input()))) for i in range(N)]

dic={}
for i in s:
	if i in dic:
		dic[i] +=1
	else:
		dic[i] = 1

result = 0
for j in dic.values():
	if j > 1:
		result += nCr(j,2)

print(result)


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

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


ll inv(ll a,ll p) {

	ll res = 1;

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



int main()
{
	
	int N;
	cin >> N;

	ll ans1 = inv(10, N);
	ll ans2 = inv(9, N);
	ll ans3 = inv(8, N);

	ans1 -= ans2*2-ans3;
	while(ans1<0)
	ans1 += MOD;
	ce((ans1%MOD))

    return 0;
}



Measured memory_bytes: 3620
n = gets.to_i
strs = []
n.times do
  strs << gets.chomp!.to_s
end

ary = strs.group_by(&:itself)
lists = ary.map{|k, v| [k, v.count]}.sort
max = ary.map{|k, v| v.count}.max
lists.each do |k, v|
  puts k if v == max
end


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli i,o,t,j,l,s,z;
lli ans = 0;

bool solve(){

}

int main(){
  cin >> i >> o >> t >> j >> l >> s >> z;
  ans += i/2*2;
  ans += o;
  ans += j/2*2;
  ans += l/2*2;
  if(i != 0 && j != 0 && l != 0){
    i--,j--,l--;
    lli mem = 0;
    mem += i/2*2;
    mem += o;
    mem += j/2*2;
    mem += l/2*2;
    mem += 3;
    ans = max(ans,mem);
  }
  cout << ans << endl;

}


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

int main()
{
    int N, M;
    cin >> N >> M;

    vector<int> X(M);
    for (int i = 0; i < M; i++)
    {
        cin >> X[i];
    }

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

    vector<pair<int, int>> diff(M - 1);
    for (int i = 0; i < M - 1; i++)
    {
        diff[i] = make_pair(abs(X[i] - X[i + 1]), i);
    }

    sort(diff.begin(), diff.end(), greater<>());

    long long ans = 0;
    for (int i = N - 1; i < diff.size(); i++)
    {
        ans += diff[i].first;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
using System;
class Program{
  static string s;
  static string t;
  static int n;
  static bool JUDGE(int m){
    bool f = true;
    for (int i = 0;i < m;i++)
      f = f && s[n-m+i] == t[i];
    return f;
  }
  static void Main(){
    n = int.Parse(Console.ReadLine());
    s = Console.ReadLine();
    t = Console.ReadLine();
    for (int i = n;i >= 0;i--){
      if (JUDGE(i)){
        Console.WriteLine(2 * n - i);
        break;
      }
    }
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class Count2D{
public:
  int n;
  vector<vector<int> > dat;
  
  Count2D(){}
  Count2D(int n_){ //x,y
    n=1;
    while(n < n_) n*=2;
    dat.resize(2*n-1);
  }

  Count2D(int n_,vector<pair<int,int> > A){
    n=1;
    while(n < n_) n*=2;
    dat.resize(2*n-1);
    
    for(auto a:A){
      int x,y; tie(x,y) = a;
      dat[x+n-1].push_back(y);
    }
    
    function<void(int)> init=[&](int k){
      if(k >= n-1) {sort(dat[k].begin(),dat[k].end());return;}
      init(k*2+1), init(k*2+2);
      
      const auto &a = dat[k*2+1], &b = dat[k*2+2];
      auto &c = dat[k];
      int i = 0, j = 0;
      while(i < (int)a.size() || j < (int)b.size()){
        if(i == (int)a.size()) c.push_back(b[j++]);
        else if(j == (int)b.size()) c.push_back(a[i++]);
        else if(a[i] < b[j]) c.push_back(a[i++]);
        else c.push_back(b[j++]);
      }
    };
    init(0);
  }
  
  void update(int x,int y){

    auto insert = [&](vector<int> &A,int a){
      A.push_back(a);
      int idx = (int)A.size()-1;
      while(idx && A[idx-1] > A[idx]) swap(A[idx-1],A[idx]),idx--;
    };
    
    x += n-1;
    insert(dat[x],y);
    while(x>0) x=(x-1)/2, insert(dat[x],y);
  }
  
  //[x,X)かつ[y,Y)の点の数を求める count(x,X,y,Y,0,0,n)
  int count(int x,int X,int y,int Y,int k=0,int l=0,int r=-1){
    if(r == -1) r = n, assert(x < n && X <= n);
    if(r<=x||X<=l)return 0;
    if(x<=l&&r<=X){
      int a = lower_bound(dat[k].begin(),dat[k].end(),y) - dat[k].begin();
      int b = upper_bound(dat[k].begin(),dat[k].end(),Y) - dat[k].begin();
      return b - a;
    }
    
    int vl=count(x,X,y,Y,k*2+1,l,(l+r)/2);
    int vr=count(x,X,y,Y,k*2+2,(l+r)/2,r);
    return vl + vr;
  }
};

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

  vector<P> A(m);
  cin>>A;

  Count2D count(n+1,A);
  auto calc = [&](int k){
    int res = 0;
    for(int i=0;i<=n;i+=k) if(i+1 <= n) res += count.count(i+1,min(n+1,i+k+1),i+k,INF);
    return res;
  };
  
  for(int i=1;i<=n;i++){
    int ans = calc(i);
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 78924
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
      r = vector<int>(N, -1);
    }
 
    int root(int x) {
      if (r[x] < 0) return x;
      return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) return false;
      if (r[x] > r[y]) swap(x, y);
      r[x] += r[y];
      r[y] = x;
      return true;
    }
 
    int size(int x) {
      return -r[root(x)];
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++){
      int A, B;
      cin >> A >> B;
      A -= 1; 
      B -= 1;
      UF.unite(A, B);
    }
 
    //最大の友達集合を求める
    int ans = 0;
    for (int i = 0; i < N; i++){
      ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}



Measured memory_bytes: 4036
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=INT()
    b=INT()
    c=INT()
    d=INT()
    e=INT()
    ct=0
    alls=[a,b,c,d,e]
    for i in alls:
        if i%10!=0:
            ct+=(i//10+1)*10
        else:
            ct+=i
    f=max((10-a%10)%10,(10-b%10)%10,(10-c%10)%10,(10-d%10)%10,(10-e%10)%10,)
    ct=ct-f
        
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string a,b;
int much;
int main()
{
    cin>>a;
    b=a;
    much=a.size();
    reverse(a.begin(),a.end());//reverse函数nb！（撕心裂肺
    for(int i=0;i<much;i++)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int w, h;
char tile[20][20];
int cnt = 0;
int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };

void f(int x, int y){
	tile[x][y] = '#';
	cnt++;
	for (int i = 0; i < 4; i++){
		int X = x + dx[i];
		int Y = y + dy[i];
		if (tile[X][Y] != '#' && 0 <= X && X < w && 0 <= Y && Y < h){
			f(X, Y);
		}
	}
}

int main(){

	while (cin >> w >> h, w + h != 0){
		cnt = 0;
		for (int y = 0; y < h; y++){
			for (int x = 0; x < w; x++){
				cin >> tile[x][y];
			}
		}

		for (int y = 0; y < h; y++){
			for (int x = 0; x < w; x++){
				if (tile[x][y] == '@') f(x, y);
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
// http://koturn.hatenablog.com/entry/2016/02/04/050000#cpp
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int A, B, T;
  cin >> A >> B >> T;
  int time;
  time = T / A;
  cout << time * B << endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
def main():
    from heapq import heappush, heappop
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

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

    dd = []
    for _ in range(N):
        t, d = map(int, input().split())
        t -= 1
        dd.append((d, t))
    dd.sort(key=itemgetter(0), reverse=True)

    ret = 0
    biggest = [-1] * N
    h = []
    kinds = 0
    for d, t in dd[:K]:
        ret += d
        if ~biggest[t]:
            if biggest[t] > d:
                heappush(h, d)
            else:
                heappush(h, biggest[t])
                biggest[t] = d
        else:
            kinds += 1
            ret += kinds * 2 - 1
            biggest[t] = d

    ans = ret
    for d, t in dd[K:]:
        if ~biggest[t]: continue
        if not h: break
        kinds += 1
        diff = d + kinds * 2 - 1 - h[0]
        ret += diff
        if ans < ret: ans = ret
        biggest[t] = d
        heappop(h)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18396
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-10;
int p,q,a,n;
int rec(int x,int y,int cnt,int num){
	if(cnt>n)return 0;
	if(x*p==y*q)return 1;
	if(x*p< y*q)return 0;
	int res=0;
	for(int i=num;i*x<=a;i++){
		res+=rec(x*i,y*i+x,cnt+1,i);
	}
	return res;
}
int main(){
	while(cin>>p>>q>>a>>n&&(p||q||a||n)){
		cout<<rec(1,0,0,1)<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
    ll a, b, c, k;cin >> a >> b >> c >> k;
    if (k % 2 == 1) {
        cout << b - a << endl;
    }
    else
        cout << a - b << endl;
}

Measured memory_bytes: 256
N = int(input())

X = int(N/1.08)
i = 0
while True:
  if int((X+i)*1.08) == N:
    print(int(X+i))
    break
  elif int((X + i)* 1.08) > N:
    print(":(")
    break
  else:
    i += 1

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

int main() {
  int X, Y;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++) {
    if (2*i+(X-i)*4 == Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

#define ll long long int
void insertionSort(int arr[], int n)
{
   int i, key, j;
   for (i = 1; i < n; i++)
   {
       key = arr[i];
       j = i-1;

       while (j >= 0 && arr[j] > key)
       {
           arr[j+1] = arr[j];
           j = j-1;
       }
       arr[j+1] = key;
   }
}
int binarySearch(int arr[], int l, int r, int x)
{
   if (r >= l)
   {
        int mid = l + (r - l)/2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid-1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid+1, r, x);
   }

   // We reach here when element is not
   // present in array
   return -1;
}

int gcd(int u, int v)
{
    return (v != 0) ? gcd(v, u % v) : u;
}

int cdig(int b)
{
    int a=b;
    int count=0;
    while(a)
    {
        a=a/10;
        count++;
    }
    return count;
}

int dig_sum(int a)
{
    int b,sum=0;
    while(a)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}

int abs(int a)
{
    if(a<0)
    {
        a=a*(-1);
        return a;
    }
    return a;
}

int ar_to_num(int ar[],int n)
{
    int sum=0;
    for(int i=0,j=n-1;i<n;i++,j--)
    {
        sum=sum+(ar[i]*pow(10,j));
    }
    return sum;
}

int pow(int a,int n)
{
    if(n==0)
        return 1;
    int b=1;
    for(int i=0;i<n;i++)
        b*=a;
    return b;
}


int main()
{
    int a,b;
    int a1,a2,b1,b2,count=0;
    cin>>a;
    if(a%2==0)
    {
        a1=a/2;
        a2=a/2;
    }
    else
    {
        a1=a/2;
        a2=a/2+1;
    }
    cout<<a1*a2<<endl;
    return 0;
}


Measured memory_bytes: 256
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    string s;
    cin >> s;
    if(s=="ABC") cout<<"ARC";
    else
    cout<<"ABC"<<endl;
    return 0;
}

/* Pooja Yadav */

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

typedef long long ll;
struct edge {ll to;ll cost;};
const int nmax = 100000;
vector<edge> g[nmax+2];
bool used[nmax+2];
vector<ll> dist(nmax+2);
void dfs(ll s, ll d) {
  if(used[s]) return;
  dist[s] = d;
  used[s] = true;
  for(int i=0;i<g[s].size();i++) {
    if(used[g[s][i].to]) continue;
    dfs(g[s][i].to, d+g[s][i].cost);
  }
}
int main() {
  ll n;
  cin >> n;

  for(int i=0;i<n-1;i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    edge e1 = {a, c}, e2 = {b, c};
    g[b].push_back(e1);
    g[a].push_back(e2);
  }
  ll q, k;
  cin >> q >> k;
  k--;
  //kからの最短距離
  for(int i=0;i<nmax;i++) used[i] = false;
  dfs(k, 0);
  vector<int> x(q), y(q);
  for(int i=0;i<q;i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }

  for(int i=0;i<q;i++) {
    cout << dist[x[i]] + dist[y[i]] << endl;
  }

}


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

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;

const int NMAX = 1e4 + 5;

int N;
int c[NMAX], col[NMAX];
int g[NMAX];
vector<int> edg[NMAX];
priority_queue< pii, vector<pii>, greater<pii> > hp;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i < N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y);
        edg[y].push_back(x);
    }

    for(int i = 1; i <= N; i++)
    {
        g[i] = int(edg[i].size());
        hp.push({g[i], i});
    }

    for(int i = 1; i <= N; i++)  scanf("%d", &c[i]);
    sort(c + 1, c + N + 1);

    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        int nod;
        while(!hp.empty())
        {
            nod = hp.top().second;
            hp.pop();
            if(g[nod] != -1)    break;
        }

        ans += c[i] * g[nod];
        g[nod] = -1;
        for(auto nxt: edg[nod])
            if(g[nxt] != -1)
            {
                g[nxt]--;
                hp.push({g[nxt], nxt});
            }
        col[nod] = c[i];
    }

    printf("%d\n", ans);
    for(int i = 1; i <= N; i++)
        printf("%d%c", col[i], " \n"[i == N]);

    return 0;
}


Measured memory_bytes: 1152
import Control.Applicative ((<$>))
import Control.Monad (replicateM, forM_)

solve :: [Int] -> [Int] -> [Int] -> String
solve [] bs cs = "YES"
solve (a:as) bb@(b:bs) cc@(c:cs)
  | a > b && a > c = if b >= c
                       then solve as (a:bb) cc
                       else solve as bb (a:cc)
  | a > b          = solve as (a:bb) cc
  | a > c          = solve as bb (a:cc)
  | otherwise      = "NO"

main = do
  n <- (read :: String -> Int) <$> getLine
  xs <-  replicateM n getLine
  let xs' = fmap words xs
      xs'' = fmap (\a -> fmap (\aa -> (read :: String -> Int) aa) a) xs' in
    do
      forM_ xs'' (\as -> putStrLn (solve as [0] [0]))

Measured memory_bytes: 4148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main(){
	
	long N,M;
	cin >> N >> M;

	vector< vector<long> > A;
	A = vector< vector<long> > (N,vector<long>(2,0));

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

 	sort(A.begin(),A.end());
 	long ans = 0;

	for (int i = 0; i < N; i++){
		if(A[i][1] < M ){
			ans += A[i][1] * A[i][0]; 
			M = M - A[i][1];
		}
		else{
			ans += M * A[i][0];
			break;
		}
	}

	cout << ans <<"\n";

	return 0;
}

Measured memory_bytes: 5760
import math
def main():
    X = int(input())
    if X == 2:
        print(X)
        return
    if X % 2 == 0:
        X = X + 1
    while True:
        if trial_division(X):
            print(X)
            break
        X += 2
def trial_division(t):
    d = int(math.sqrt(t))
    for i in range(2, d):
        if t % i == 0:
            return False
    return True
main()


Measured memory_bytes: 38384
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>

void preprocess(const std::string &s, std::string &t) {
  t.clear();
  for (char ch: s)
    if (!isdigit(ch))
      t += ch;
}

constexpr intmax_t MOD=1e9+7;

intmax_t modpow(intmax_t base, intmax_t iexp, intmax_t init=1) {
  intmax_t res=init%MOD;
  for (intmax_t dbl=base; iexp; iexp>>=1) {
    if (iexp & 1) res = res*dbl % MOD;
    dbl = dbl*dbl % MOD;
  }
  return res;
}

class Circuit {
  intmax_t a;
  int m;
  // (ways of evaluate-to-true, x)

public:
  Circuit(): a(1), m(1) {}
  Circuit(intmax_t a, int m): a(a), m(m) {}

  Circuit &operator |=(const Circuit &oth) {
    intmax_t b=oth.a, n=oth.m;
    intmax_t aa;

    aa = (modpow(2, m, b) + modpow(2, n, a)) % MOD;
    aa -= a*b % MOD;
    if (aa < 0) aa += MOD;
    a = aa;
    m += n;
    return *this;
  }

  Circuit operator &=(const Circuit &oth) {
    a *= oth.a;
    a %= MOD;
    m += oth.m;
    return *this;
  }

  Circuit operator ~() const {
    intmax_t tilde=modpow(2, m)-a;
    if (tilde < 0) tilde += MOD;
    return {tilde, m};
  }

  intmax_t ways() const {
    return a;
  }
};

static const std::vector<std::string> ops={"|", "&"};
Circuit parse(const std::string &s, size_t &i, size_t preced=0) {
  if (preced == ops.size()) {
    if (s[i] == '(') {
      Circuit res=parse(s, ++i, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    if (s[i] == '~') {
      return ~parse(s, ++i, preced);
    }
    if (s[i] == 'x') {
      while (++i < s.length() && isdigit(s[i])) {}
      // ++i;
      return Circuit();
    }
    assert(false);
  }

  Circuit res=parse(s, i, preced+1);
  while (i < s.length()) {
    char op=s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    Circuit tmp=parse(s, ++i, preced+1);
    if (op == '&') res &= tmp;
    if (op == '|') res |= tmp;
  }
  return res;
}

size_t closing(
    const std::string &s, size_t pos, char open, char close) {

  if (s[pos] != open) return pos;
  size_t opening=1;
  while (++pos < s.length()) {
    if (s[pos] == open) ++opening;
    if (s[pos] == close) if (--opening == 0) return ++pos;
  }
  assert(false);
}

char buf[1000010];
int main() {
  scanf("%s", buf);
  std::string s=std::move(buf), t;
  preprocess(s, t);
  s.clear();
  size_t i=0;
  if (t[0] == '(') {
    if (closing(t, 0, '(', ')') == t.length())
      if (std::count(t.begin(), t.end(), 'x') == 1)
        // :(
        return !printf("1\n");
  }
  printf("%jd\n", parse(t, i).ways());
}



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

int main() {
  ll a,b;cin>>a>>b;
  if(a>0&&b>0)cout<<"Positive"<<endl;
  else if((a<0&&b<0)&&(abs(a-b)+1)%2==0)cout<<"Positive"<<endl;
  else if((a<0&&b<0)&&(abs(a-b)+1)%2==1)cout<<"Negative"<<endl;
  else cout<<"Zero"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int mat[1005][1005];
int d[1005][1005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int h, w;
	cin >> h >> w;
	
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	FOR(i,1,h+1) {
		FOR(j,1,w+1) {
			char x;
			cin >> x;
			mat[i][j]=x=='.';
		}
	}
	
	
	
	FOR(i,1,h+1) {
		FOR(j,1,w+1) {
			d[i][j]=1001001001;
		}
	}
	
	//0-1 bfs
	deque<pair<int,int>> q;
	q.push_front({x1,y1});
	d[x1][y1]=0;
	while (!q.empty()) {
	    auto p = q.front();
	    int x = p.F;
	    int y = p.S;
	    q.pop_front();
	    FOR(i,max(1,x-2),min(h,x+2)+1) {
	    	FOR(j,max(1,y-2),min(w,y+2)+1) {
	    		if (!mat[i][j]) {
	    			continue;
	    		}
	    		int w = (llabs(i-x)+llabs(j-y)) != 1;
	    		if (d[x][y] + w < d[i][j]) {
					d[i][j] = d[x][y] + w;
					if (w == 1)
						q.push_back({i,j});
					else
						q.push_front({i,j});
				}
	    	}
	    }
	}
	
	cout << (d[x2][y2] < 10000000 ? d[x2][y2] : -1) << "\n";	

}


Measured memory_bytes: 11472
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	int H,W,D,Q;
	cin>>H>>W>>D;
	vector<vector<tuple<int,int,int,int>>> tab(D,vector<tuple<int,int,int,int>>());
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			int n;
			cin>>n;
			tab[n%D].push_back(make_tuple(n,i,j,0));
		}
	}
	cin>>Q;
	vector<int> L(Q),R(Q);
	for(int i=0;i<Q;i++) cin>>L[i]>>R[i];
	for(int i=0;i<D;i++) sort(tab[i].begin(),tab[i].end());
	for(int i=0;i<D;i++){
		for(int j=0;j<tab[i].size();j++){
			if(j==0) continue;
			get<3>(tab[i][j]) = get<3>(tab[i][j-1]) + abs(get<1>(tab[i][j])-get<1>(tab[i][j-1])) + abs(get<2>(tab[i][j])-get<2>(tab[i][j-1]));
		}
	}
	for(int i=0;i<Q;i++){
		cout<<get<3>(tab[R[i]%D][(R[i]-1)/D])-get<3>(tab[L[i]%D][(L[i]-1)/D])<<endl;
	}
	return 0;
}

Measured memory_bytes: 6144
W = input()
if W[0] == 'R' and  W[1] == 'R' and  W[2] == 'R':
    print(3)
elif (W[0] == 'R' and  W[1] == 'R') or (W[1] == 'R' and  W[2] == 'R'):
    print(2)
elif W[0] == 'S' and  W[1] == 'S' and  W[2] == 'S':
    print(0)
else:
    print(1)

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

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


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, permutations, combinations, accumulate
from bisect import bisect_left, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor


def input_list():
    return list(map(int, input().split()))


def input_int():
    return int(input())


S = input()
T = input()
max_cnt = 0
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        if T[j] == S[i + j]:
            cnt += 1
    max_cnt = max(max_cnt, cnt)
print(len(T) - max_cnt)


Measured memory_bytes: 72964
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define pf push_front
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long
int power(int x, int p, int M)
{
    if (p == 0)
        return 1;
    int y = power(x, p / 2, M);
    y *= y;
    y %= M;
    if (p % 2 == 0)
        return y;
    y *= x;
    y %= M;
    return y;
}
signed main()
{
    rootdada;

    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    int ans = 0;
    if (p == 2 || p == 5)
    {
        rep(i, 0, n)
        {
            if ((s[i] - '0') % p == 0)
                ans += i + 1;
        }
    }
    else
    {
        s += "0";
        map<int, int> mp;
        mp[0]++;
        vector<int> r(n + 1);
        int cnt = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            r[i] = (s[i] - '0') * power(10, cnt++, p) + r[i + 1];
            r[i] %= p;
            ans += mp[r[i]];
            mp[r[i]]++;
        }
        // rep(i, 0, n)
        //         cout
        //     << r[i] << " ";
        // cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2580
from copy import deepcopy
n=int(input())
A=list(map(int, input().split()))
B=[0]+deepcopy(A)+[0]
total=0
b=0
for a in A:
    total+=abs(a-b)
    b=a
total+=abs(b)
for i in range(1,n+1):
    z,x,c=B[i-1], B[i], B[i+1]
    print(total-abs(x-z)-abs(c-x)+abs(c-z))

Measured memory_bytes: 20844
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int left = 0, right = 0;
    rep(i, n) {
        if (s[i] == '(') right++;
        else {
            if (right <= 0) left++;
            else right--;
        }
    }
    string ans = "";
    rep(i, left) ans += "(";
    ans += s;
    rep(i, right) ans += ")";

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

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
    public static void main(String[] args){
    BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
    try {
	int n = Integer.valueOf(sc.readLine());
	TreeMap<String, Integer> map1 = new TreeMap<String, Integer>();
	TreeMap<String, Integer> map2 = new TreeMap<String, Integer>();
	TreeMap<String, Integer> map3 = new TreeMap<String, Integer>();
	TreeMap<String, Integer> map4 = new TreeMap<String, Integer>();
	TreeMap<String, Integer> map5 = new TreeMap<String, Integer>();
	for(int i=0; i<n; i++){
		String[] st = sc.readLine().split(" ");
		int num = Integer.valueOf(st[1]);
		if(st[0].length()==1){
			if(map1.containsKey(st[0])){
				num += map1.get(st[0]);
				map1.remove(st[0]);
				}
			map1.put(st[0],num);}
		else if(st[0].length()==2){
			if(map2.containsKey(st[0])){
				num += map2.get(st[0]);
				map2.remove(st[0]);
				}
			map2.put(st[0],num);}
		else if(st[0].length()==3){
			if(map3.containsKey(st[0])){
				num += map3.get(st[0]);
				map3.remove(st[0]);
				}
			map3.put(st[0],num);}
		else if(st[0].length()==4){
			if(map4.containsKey(st[0])){
				num += map4.get(st[0]);
				map4.remove(st[0]);
				}
			map4.put(st[0],num);}
		else if(st[0].length()==5){
			if(map5.containsKey(st[0])){
				num += map5.get(st[0]);
				map5.remove(st[0]);
				}
			map5.put(st[0],num);}
		}

	for (Map.Entry<String, Integer>	entry : map1.entrySet()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
	for (Map.Entry<String, Integer>	entry : map2.entrySet()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
	for (Map.Entry<String, Integer>	entry : map3.entrySet()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
	for (Map.Entry<String, Integer>	entry : map4.entrySet()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
	for (Map.Entry<String, Integer>	entry : map5.entrySet()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
    }catch(Exception e){
        System.out.println("Error");
    }
    }
}

Measured memory_bytes: 35100
*a,=input()
c=0
for i in range(len(a)-1):
    if a[i]=="0" and a[i+1]=="0":
        a[i+1]="1"
        c+=1
    elif a[i]=="1" and a[i+1]=="1":
        a[i+1]="0"
        c+=1
print(c)

Measured memory_bytes: 3956
#include<stdio.h>
/*
間隔は
*/
int sum(int n){
    int i,sum=0;
    for(i=0;i<n;i++){
        sum += i;
    }
    return sum;
}

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int gap = b-a;
    printf("%d\n",sum(gap)-a);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for(i=a;i<b;i++)

set<ll>::iterator it;
ll mod = 1000000007;
ll power(ll a,ll b)
{
	ll p = 1;
	a = a%mod;
	while(b>0)
	{
		if(b%2==1)
			p=((p%mod)*(a%mod))%mod;
		b=b>>1;
		a=((a%mod)*(a%mod))%mod;
	}
	return p;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,n,x,y,d;
	ll an = 0;
	cin>>n>>d;
	while(n--)
	{
		cin>>x>>y;
		if(x*x + y*y <= d*d)
			an++;
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 3660
from sys import stdin
input = stdin.readline
N,M = map(int, input().split())
H = [0] + list(map(int, input().split()))
L = [0] + [1]*N
for m in range(M):
    A,B = map(int, input().split())
    if H[A] > H[B]:
        L[B] = 0
    elif H[A] < H[B]:
        L[A] = 0
    else:
        L[A], L[B] = 0, 0
print(sum(L))


Measured memory_bytes: 20216