akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::vector;
using std::cin;
using std::map;
using std::multimap;
using std::set;
using std::multiset;

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; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll n, m;
	cin >> n >> m;
	auto all = prime_decomposition(m);

	set<ll> memo;
	ll ans = 1;
	REPC(x, all) {
		if (memo.find(x) != memo.end()) { continue; }
		memo.emplace(x);
		ll c = all.count(x);
		ans *= comb(c + n - 1, c);
		ans %= MOD;
	}
	cout << ans << endl;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

template<class T>
struct RMQ {
    T sz;
    T sq;

    std::vector<T> data;
    std::vector<T> bucket;
    RMQ(T size){
        sq = std::ceil(std::sqrt(size));
        sz = size;
        data.resize(size, -1);
        bucket.resize(sq, -1);
    }  
    RMQ(T size, T init): data(size, init){
        sq = std::ceil(std::sqrt(size));
        sz = size;
        data.resize(size, init);
        bucket.resize(sq, init);
    }
    void update(T i, T x) {
        data[i] = x;
        T minVal = data[i];
        T k = i / sq;
        FOR(j,k*sq,(k+1)*sq) {
            minVal = std::min(minVal, data[j]);
        }
        bucket[k] = minVal;
    }
    T find(T s, T t) {
        if(s == t) return data[s];
        T val = (1LL << 31) - 1;
        REP(i, sq) {
            T l = i*sq, r = (i+1)*sq;
            if(r <= s || t <= l) {
                continue;
            }
            
            if(s <= l && r <= t) {
                val = std::min(val, bucket[i]);
            } else {
                FOR(j, std::max(s, l), std::min(t, r) + 1) {
                    val = std::min(val, data[j]);
                }
            }
        }
        return val;
    }
};

int main(){
    int n, q, c, x, y;
    std::cin >> n >> q;
    RMQ<long> rmq = RMQ<long>(100000, (1LL << 31) - 1);
    REP(i, q) {
        std::cin >> c >> x >> y;
        if(c == 0) {
            rmq.update(x, y);
        } else {
            std::cout << rmq.find(x, y) << std::endl;
        }
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
struct st{
  int v,s,d;
  st(){}
  st(int v,int s,int d):v(v),s(s),d(d){}
  bool operator<(const st a)const{
    return d>a.d;
  }
};
int dp[111][111];
signed main(){
  int n,m,c;
  while(cin>>n>>m>>c,n||m||c){
    //cout<<n<<" "<<m<<" "<<c<<endl;;
    vector<P> G[n];
    for(int i=0;i<m;i++){
      int u,v,d;
      cin>>u>>v>>d;
      u--;v--;
      G[u].emplace_back(v,d);
      //G[v].emplace_back(u,d);
    }
    int INF=1LL<<55LL;
    for(int i=0;i<111;i++)
      for(int j=0;j<111;j++)
	dp[i][j]=INF;
    priority_queue<st> q;
    dp[0][0]=0;
    q.emplace(0,0,0);
    while(!q.empty()){
      st p=q.top();q.pop();
      int v=p.v,s=p.s,d=p.d;
      if(dp[v][s]<d) continue;
      //cout<<v<<" "<<s<<":"<<d<<endl;
      for(P e:G[v]){
	{
	  int nv=e.first,ns=s,nd=d+e.second;
	  if(dp[nv][ns]>nd){
	    dp[nv][ns]=nd;
	    q.emplace(nv,ns,nd);
	  }
	}
	if(s<n){
	  int nv=e.first,ns=s+1,nd=d;
	  if(dp[nv][ns]>nd){
	    dp[nv][ns]=nd;
	    q.emplace(nv,ns,nd);
	  }
	}
      }
    }
    int ans=n;
    for(int i=0;i<=n;i++){
      //cout<<i<<":"<<dp[n-1][i]<<endl;
      if(dp[n-1][i]<=c){
	ans=i;
	break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3528
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int ans = 0;
			for (int i = 0; i < 3; i++) {
				if (s[i] == '1') {
					++ans;
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 11092
def main():
    N, K = map(int, input().split())
    P = list(map(lambda x: int(x) - 1, input().split()))
    C = list(map(int, input().split()))
    S = 0
    M = C[0]

    for s in range(N):
        t = 0
        p = s
        m = C[s]
        i = 0
        skipped = False
        while i < K:
            t += C[p]
            p = P[p]
            i += 1
            m = max(m, t)
            if p == s and not skipped:
                if t <= 0:
                    break
                skipped = True
                skip = K // i - 2
                if skip < 1:
                    continue
                t += t * skip
                m = max(m, t)
                i += i * skip
        M = max(M, m)

    return M

print(main())


Measured memory_bytes: 68748
l, r = map(int, input().split())
if r - l - 1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(r - l):
        for j in range(i + 1, r - l + 1):
            if ans > ((i + l) * (j + l)) % 2019:
                ans = ((i + l) * (j + l)) % 2019
    print(ans)

Measured memory_bytes: 3060
/**
 *    author:  tourist
 *    created: 20.05.2018 16:06:03       
**/
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector< vector<int> > g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  pair<int,long long> ans = make_pair(n + 1, -1);
  for (int i = 0; i < n; i++) {
    vector<int> dist(n, -1);
    vector<int> deg(n, -1);
    vector<int> que(1, i);
    dist[i] = 0;
    for (int b = 0; b < (int) que.size(); b++) {
      deg[que[b]] = 0;
      for (int u : g[que[b]]) {
        if (dist[u] == -1) {
          deg[que[b]]++;
          dist[u] = dist[que[b]] + 1;
          que.push_back(u);
        }
      }
    }
    vector<int> maxes(n, 0);
    for (int u = 0; u < n; u++) {
      maxes[dist[u]] = max(maxes[dist[u]], max(deg[u], 1));
    }
    pair<int, long long> cur = make_pair(0, 1);
    for (int u = 0; u < n; u++) {
      if (maxes[u] > 0) {
        cur.first = u + 1;
        cur.second *= maxes[u];
      }
    }
    debug(i, cur);
    ans = min(ans, cur);
  }
  for (int i = 0; i < n; i++) {
    for (int j : g[i]) {
      vector<int> dist(n, -1);
      vector<int> deg(n, -1);
      vector<int> que(1, i);
      dist[i] = 0;
      que.push_back(j);
      dist[j] = 0;
      for (int b = 0; b < (int) que.size(); b++) {
        deg[que[b]] = 0;
        for (int u : g[que[b]]) {
          if (dist[u] == -1) {
            deg[que[b]]++;
            dist[u] = dist[que[b]] + 1;
            que.push_back(u);
          }
        }
      }
      debug(dist, deg);
      vector<int> maxes(n, 0);
      for (int u = 0; u < n; u++) {
        maxes[dist[u]] = max(maxes[dist[u]], max(deg[u], 1));
      }
      pair<int, long long> cur = make_pair(0, 2);
      for (int u = 0; u < n; u++) {
        if (maxes[u] > 0) {
          cur.first = u + 1;
          cur.second *= maxes[u];
        }
      }
      debug(i, j, cur);
      ans = min(ans, cur);
    }
  }
  cout << ans.first << " " << ans.second << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;


void func()
{
	int32_t A, B, C, K;
	int32_t ans(0);
	cin >> A >> B >> C >> K;

	if (K <= A)
	{
		cout << K << endl;
		return;
	}

	K -= A;
	if (K <= B)
	{
		cout << A << endl;
		return;
	}

	K -= B;
	cout << A-K << endl;

	return;
}

int main() {

//	while (1)
		func();
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


const ll MOD = 1e9+7;

signed main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n){
        cin >> a[i];
    }
    sort(a,a+n,greater<ll>());

    ll sum = a[0];
    ll roopcnt = 1;
    ll index = 1;
    while(roopcnt <= n-2){
        sum += a[index];
        roopcnt++;
        if(roopcnt > n-2) break;
        sum += a[index++];
        roopcnt++;
    }

    cout << sum << endl;
}


Measured memory_bytes: 5176
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n").map(n => Number(n));
    let yen = input[0] - input[1];
    const B = input[2];
    while (yen >= B) {
        yen -= B;
    }
    console.log(yen);
}

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


Measured memory_bytes: 11468
#include <stdio.h>

#define MMAX 20
#define NMAX 1000000


int getData(int *data, int n)
{
	int i=0;

	for (i = 0; i<n; i++)
		scanf("%d", &(data[i]));
	return (i == n);
}

int M[MMAX];
int A[NMAX];
int cnt;

int initM(int n)
{

	int h=1, i=0, mmax;

	for (i = 0; i<MMAX; i++)
	{
		if (h > n) break;
		h = 3*h+1;
	}
	mmax = i;

	for (i = 0; i<mmax; i++)
	{
		h = (h-1)/3;
		M[i] = h;
	}	
	return mmax;
}


int insertionSort(int *data, int n, int g)
{
	int i, v;
	for (i = g; i < n; i++)
	{
		v = data[i];
		int j = i-g;
		while(j >= 0 && data[j]>v)
		{
			data[j+g] = data[j];
			j = j -g;
			cnt++;
		}
		data[j+g] = v;
	}
}

void printdata(int *data, int n)
{
	for(int i=0; i<n; i++)
		printf("%d\n",data[i]);
}

int shellSort(int *data, int n)
{
	int m = initM(n);

	for(int i = 0; i<m  ; i++)
	{
		insertionSort(data, n, M[i]);

	}
	
	printf("%d\n", m);
        for(int i=0; i<m; i++)
	{
		printf("%d%s", M[i], (i!=m-1)?" ":"\n");
	}
	printf("%d\n", cnt);
	printdata(data, n);

}

int main(int argc, char **argv)
{
	int n;
	cnt = 0;
	scanf("%d", &n);
	
	getData(A, n);
	shellSort(A, n);
	return 0;
}



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

class Program{
    public static void Main(){
	Solver solver=new Solver();
	int n=int.Parse(Console.ReadLine());
	for(int i=0;i<n;i++){
	    solver.Solve(Console.ReadLine());
	}
    }
}
class Solver{
    public void Solve(string str){
	string str_=Reverse(str);
	int len=str.Length;
	Dictionary<string,int> dic=new Dictionary<string,int>();
	for(int i=1;i<len;i++){
	    string[] l=new string[]{str.Substring(0,i),
				    str_.Substring(len-i)};
	    string[] r=new string[]{str.Substring(i),
				    str_.Substring(0,len-i)};
	    foreach(string l_ in l){
		foreach(string r_ in r){
		    if(!dic.ContainsKey(l_+r_))
			dic[l_+r_]=1;
		    if(!dic.ContainsKey(r_+l_))
			dic[r_+l_]=1;
		}
	    }
	}
	Console.WriteLine(dic.Count);
    }
    private string Reverse(string str){
	char[] str_=str.ToCharArray();
	Array.Reverse(str_);
	return new string(str_);
    }
}

Measured memory_bytes: 6268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm

//#include "BIT.h"

#define ERROR() cout << "ERROR!!" << endl; return 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 rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

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

  ll h, n;
	cin >> h >> n;

	vector<ll>  a(n), b(n);
	rep(i, n) {
	cin >> a[i] >> b[i];
	}

	vector<ll> dp(h+1,INF);
	dp[h] = 0;
	rrep(j, h+1) rep(i, n) {
		  dp[max(j-a[i], (ll)0)] = min(dp[max(j - a[i], (ll)0)], dp[j] + b[i]);
	}

	cout << dp[0] << endl;
}




Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AColorfulTransceivers {
public:
	void solve(istream& in, ostream& out) {
        int a, b, c, d;
        in >> a >> b >> c >> d;
        if(abs(a - c) <= d) out << "Yes" << endl;
        else if(abs(a-b) <= d && abs(b-c) <= d) out << "Yes" << endl;
        else out << "No" << endl;
	}
};

int main() {
	AColorfulTransceivers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;

int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	if(b < 0)return 0;
	int re = 1;
	while(b){
		if(b&1){
			re = mul(re, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return re;
}
int const N = 100000 + 5;
int fact[N], inverse[N];
void FAC(){
 	fact[0] = 1;
	for(int x = 1; x< N; x++){
		fact[x] = mul(fact[x-1], x);
	}
	inverse[N-1] = power(fact[N-1], mod -2);
	for(int x = N-2; x>= 0; x--){
		inverse[x] = mul(x + 1, inverse[x+1]);
	}

 }

int ncr(int a, int b){
	if(a < b)return 0;
	return mul(fact[a], mul(inverse[a-b], inverse[b]));
}


/******************************************************/

void solve(){
	char c;
	cin >> c;
	c ++;
	cout << c ;
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math
N = int(input())
h = list(map(int, input().split())) 

dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
 
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Measured memory_bytes: 14104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 100;

int n, m;
long long q[MAXN], tim[MAXN];
long long dans[MAXN];

void work()
{
	stack<long long> sta;
	sta.push(n);
	for(int i = 1; i <= m; i++)
	{
		while(!sta.empty() && sta.top() >= q[i])
			sta.pop();
		sta.push(q[i]);
	}
	m = 0;
	while(!sta.empty())
		q[++m] = sta.top(), sta.pop();
	reverse(q + 1, q + m + 1);

	// cerr << m << endl;

	tim[m] = 1;
	for(int i = m; i >= 1; i--)
	{
		long long k = q[i];
		int j = 0;
		while(j = lower_bound(q + 1, q + i + 1, k) - q - 1)
		{
			tim[j] += tim[i] * (k / q[j]);
			k %= q[j];
		}
		dans[1] += tim[i], dans[k + 1] -= tim[i];
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++)
		ans += dans[i], cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= m; i++)
		cin >> q[i];

	work();


	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		long k = sc.nextLong();
		Queue<Number> que = new PriorityQueue<>();
		for(int i = 0; i < n; i++) {
			long a =sc.nextLong();
			long b =sc.nextLong();
			que.offer(new Number(a,b));
		}
		
		long sum = 0, ans = 0;
		
		while (que.size() > 0) {
			Number number = que.poll();
			long num = number.number;
			sum += num;
			if (sum >= k) {
				ans = number.value;
				break;
			}
		}	
		
		out.println(ans);
		
		out.close();
	}
	static class Number implements Comparable<Number>{
		Long value;
		Long number;
		
		Number(long v, long n){
			this.value = v;
			this.number = n;
		}

		@Override
		public int compareTo(Number o) {
			
			return this.value.compareTo(o.value);
		}
		
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




Measured memory_bytes: 30700
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<ll, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  cin>>n;
  int d1;
  int d2;
  int now=0;
  int m=0;
  rep(i,n){
    cin>>d1>>d2;
    if(d1==d2) now++;
    else now=0;
    m=max(now,m);
  }
  
  Ans(m>=3);
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define N 222
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,G[N][N],ans,dep[N];
int col[N],vis[N];
char s[N];
queue<int> q;
bool dfs(int u){
	for(int i=1;i<=n;i++){
		if(G[u][i]){
			if(~col[i]){
				if(col[u]==col[i])return false;
			}
			else{
				col[i]=(col[u]^1);
				if(!dfs(i))return false;
			}
		}
	}
	return true;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		for(int j=1;j<=n;++j){
			G[i][j]=s[j]-'0';
		}
	}
	memset(col,-1,sizeof(col));
	col[1]=0;
	if(!dfs(1)){
		return !printf("-1\n");
	}
	for(int S=1;S<=n;++S){
		q.push(S);
		memset(dep,0,sizeof(dep));
		dep[S]=1;
		while(!q.empty()){
			int u=q.front();
			q.pop();
			for(int v=1;v<=n;++v){
				if(!G[u][v]||dep[v])continue;
				dep[v]=dep[u]+1;
				ans=max(ans,dep[v]);
				q.push(v);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;


int main()
{
  string S, T, A, B;
  cin >> S >> T;
  for(int i = 0; i < S.size(); i++) (i & 1 ? A : B) += S[i];

  auto check = [](string &a, string &b)
  {
    int tail = 0;
    for(int i = 0; i < a.size(); i++) {
      if(a[i] == b[tail])++tail;
      if(tail == b.size()) return (true);
    }
    return (false);
  };

  if(check(T, A) || check(T, B))cout << "Yes" << endl;
  else cout << "No" << endl;


}

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

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

  double ans = 0.0;
  for (int i = 0; i < N; i++) {
    double x = 0.0;
    scanf("%lf", &x);
    string u;
    cin >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * 380000.0;
    }
  }

  printf("%.16lf", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

set<ll> st;

void dfs(ll s) {
	if (to_string(s).size() >= 12) return;
	st.insert(s);
	dfs(s * 10 + s % 10);
	if (s % 10 <= 8) dfs(s * 10 + s % 10 + 1);
	if (s % 10 >= 1) dfs(s * 10 + s % 10 - 1);
}

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

	rrep (i, 9) dfs(i);

	for (auto it = st.begin(); it != st.end(); it++) {
		k--;
		if (k == 0) {
			cout << *it << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 27520
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool space(char c){
    return(c==' '||c==','||c=='.');
}
int main(){
    string str;
    getline(cin,str);
    string word;
    bool f=false;
    for(int i=0;i<str.length();i++){
        if(space(str[i])){
            if(word.length()>=3&&word.length()<=6){
                if(f)cout<<" ";
                cout<<word;
                f=true;
            }
            word="";
        }
        else word+=str[i];
    }
    cout<<endl;
}

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

using namespace std;
mt19937_64 rng(58);

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = ""; for (const auto &x : v) { if (!first) res += ", "; first = false; res += to_string(x); } return "{" + res + "}"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int area(vector<vector<int>> &c, int h1, int w1, int h2, int w2) {
    h2--;
    w2--;
    return c[h1 + 1][w1 + 1] - c[h1 + 1][w2 + 1] - c[h2 + 1][w1 + 1] + c[h2 + 1][w2 + 1];
};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    vector<vector<int>> c(h + 1, vector<int>(w + 1));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            c[i + 1][j + 1] = (s[i][j] == '1') + c[i][j + 1] + c[i + 1][j] - c[i][j];
        }
    }

    long long ans = h + w + 1;

    for (int i = 0; i < (1 << (h - 1)); i++) {
        vector<int> rows;
        rows.push_back(0);
        for (int j = 0; j < h - 1; j++) if ((i >> j) & 1) rows.push_back(j+1);
        rows.push_back(h);
        long long cut = rows.size() - 2;
        debug(rows);
        int last = -1;
        // greedy
        bool possible = true;
        for (int x = 0; x < w; x++) {
            bool can = true;
            for (int j = 0; j < rows.size() - 1; j++) {
                int a = area(c, rows[j + 1] - 1, x, rows[j], last + 1);
                debug(rows[j + 1] - 1, x, rows[j], last + 1, a);
                if (a > k) {
                    can = false;
                    break;
                }
            }
            if (!can) {
                if (x > last + 1) {
                    last = x - 1;
                    cut++;
                    debug(x, cut);
                } else {
                    possible = false;
                    break;
                }
            }
        }
        debug(possible, cut);
        if (possible)
            ans = min(cut, ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
N = int(input())
t0, x0, y0 = (0, 0, 0)

for _ in range(N):
	t1, x1, y1 = map(int, input().split())
	if abs(x1-x0)+abs(y1-y0) > t1-t0 or (abs(x1-x0)+abs(y1-y0))%2 != (t1-t0)%2:
		print('No')
		break
	t0, x0, y0 = t1, x1, y1
else:
	print('Yes')

Measured memory_bytes: 3064
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = int(input())
    a = list(str(n))
    A = [int(a[i]) for i in range(len(a))]
    A = sum(A)
    if n % A == 0:
        print('Yes')
    else: print('No')
    
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 27172
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int n = b - a;
		int num = 0;
		for(int i = 1;i < n;i++){
			num += i;
		}
		System.out.println(num-a);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
  vector<pair<int,int>> t(5);
  int result = 0;
  for( int i = 0; i < 5; ++i ){
    cin >> t[i].second;
    t[i].first = t[i].second % 10;
    if( t[i].first == 0 ){ t[i].first = 10; }
  }
  sort(t.begin(), t.end(), greater<pair<int,int>>());
  for( int i = 0; i < 5; ++i ){
    result = (result+9)/10*10;
    // cout << t[i].first << "," << t[i].second << endl;
    result += t[i].second;
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;

    int[] s;
    int   num;

    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());

      s = new int[3];
      s[0] = Integer.parseInt(in_str.substring(0, 1));
      s[1] = Integer.parseInt(in_str.substring(1, 2));
      s[2] = Integer.parseInt(in_str.substring(2, 3));

      num = 0;
      if(1 == s[0]){num++;}
      if(1 == s[1]){num++;}
      if(1 == s[2]){num++;}

      UtilLog.ans_ln("" + num);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


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

int main(){
	string s;
	cin>>s;
	long long cnt=0;
	for(int i=0;i<(1<<s.size()-1);i++){
		long long ans=0;
		long long res=0;
		for(int j=0;j<s.size();j++){
			res=res*10+(long long)(s[j]-'0');
			if(j<s.size()-1&&((i>>j)&1)){
				ans=ans+res;
				res=0;
			}
		}
		ans+=res;
		cnt+=ans;
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
	long a,b,i,j,n,cur=0,ans=0;
	cin >> n >> a >> b;
	for(i=1; i<=n; i++){
		cur=0;
		j=i;
		while(j>0){
			cur+=j%10;
			j/=10;
		}
		if(a<=cur&&cur<=b) ans+=i;
		
	}
	cout << ans;
}

Measured memory_bytes: 256
a, b, c = input().strip().split()
a, b, c = [int(a), int(b), int(c)]
if(c-a-b < 0):
  print("No")
  exit(0)

if a*a+b*b+c*c-2*b*c-2*c*a > 2*a*b:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
//在 POJ 和小白菜中，万能库禁用！
//在 USACO中请用文件。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#define inf 2139062143   //2147483647.
#define mod 1000000007
//data:
using namespace std;
typedef long long LL;
const int N = 1100005, INF = 1<<25;
int in[N], n, cc[129];
bool used[N];
char str[N];
vector<int>g[129];
int lowbit(int t)
{
    return t&(t^(t-1));
}
int sum(int end)
{
    int ans=0;
    while(end>0)
    {
        ans+=in[end];
        end-=lowbit(end);
    }
    return ans;
}
void add(int pos ,int num)
{
    while(pos<=n)
    {
        in[pos]+=num;
        pos+=lowbit(pos);
    }
}
void solve()
{
    memset(in, 0, sizeof(in));
    for(int i=1; i<=n+1; i++)
    {
        add(i,1);
    }
    LL ans = 0;
    int v,u,sze;
    char s;
    memset(used, 0, sizeof(used));
    for(int i=1; i<=n; i++){
        if(!used[i]){
            s = str[i];
            sze = g[s].size();
            u = g[s][sze-1];
            if(i == u)
            {
                ans += (sum(n) - sum(i))/2;
            }
            else
            {
                ans += sum(n) - sum(u);
            }
            add(u, -1);
            add(i, -1);
            used[i] = used[u] = 1;
            g[s].erase(g[s].end()-1);
        }
    }
    printf("%lld\n", ans);
}
int main()
{
    scanf("%s", str+1);
    n = strlen(str+1);
    memset(cc, 0, sizeof(cc));
    for(int i=1; i<129; i++) g[i].clear();
    for(int i=1; i<=n; i++){
        cc[str[i]]++;
    	g[str[i]].push_back(i);
    }
	int flag = 0;
    for(int i=0; i<26; i++)
    {
        if(cc['a'+i]%2) flag++;
        if(cc['A'+i]%2) flag++;
    }
    if(flag > 1){
        printf("-1\n");
    }else{
    	solve();
    }
    return 0;
}

Measured memory_bytes: 6904
#include <stdio.h>

int main(void) {
	int  n, k;
	scanf("%d %d", &n, &k);
	char s[n];
	scanf("%s", s);
	s[k-1] = s[k-1] + 32;

	for (int i = 0; i < n; ++i) {
		printf("%c", s[i]);
	}



	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(lambda x: int(x)-1, input().split())
    adj[A].append(B)
    adj[B].append(A)

from collections import deque

queue = deque([0])
visit = [-1] * N
visit[0] = 1

while queue:
    now = queue.popleft()
    for u in adj[now]:
        if visit[u] < 0:
            queue.append(u)
            visit[u] = visit[now] + 1

print('Yes')
for i in range(1,N):
    for u in adj[i]:
        if visit[u] == visit[i]-1:
            print(u+1)
            break

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

#define int long long
static const int INF = 0x3f3f3f3f;
static const int MOD = 1000000007;

//0-origin
template <typename T>
struct FenwickTree {
	vector<T> data;
	FenwickTree(int n) : data(n, 0) {}
        //v[i] += x
	void add(int i, T x) { 
                for (int p = i; p < (int)data.size(); p |= p + 1) data[p] = data[p] + x % MOD;
        }
        //[0, i)
	T sum(int i) {
		T s = 0;
                for (int p = i - 1; p >= 0; p = (p & (p + 1)) - 1) s = s + data[p] % MOD;
		return s;
	}
        //[l, r)
	T sum(int l, int r) { return (sum(r) - sum(l) % MOD + MOD) % MOD; }
};

void solve() {
        int n;
        cin >> n;
        vector<pair<int, int>> p(n);
        for (int i = 0; i < n; i ++) cin >> p[i].first >> p[i].second;

        //compressing
        vector<int> v(n);
        for (int i = 0; i < n; i ++) v[i] = p[i].second;
        sort(all(v));
        map<int, int> zip;
        int cnt = 1;
        for (int i = 0; i < n; i ++) zip[v[i]] = cnt ++;
        for (int i = 0; i < n; i ++) p[i].second = zip[p[i].second];

        sort(all(p));
        vector<int> r(n), l(n);
        r[0] = p[0].second, l[n - 1] = p[n - 1].second;
        for (int i = 1; i < n; i ++) r[i] = max(r[i - 1], p[i].second);
        for (int i = n - 2; i >= 0; i --) l[i] = min(l[i + 1], p[i].second);
        FenwickTree<int> ft(n + 10);
        ft.add(0, 1);
        for (int i = 0; i < n; i ++) ft.add(r[i], ft.sum(l[i] - 1, r[i] + 1));
        cout << (ft.sum(n, n + 1) % MOD + MOD) % MOD << endl;
        return;
}

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



Measured memory_bytes: 22144
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
string s;
int r[4007],b[4007],g[4007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    cin>>s;
    if(s[0]=='R')
        r[0]=1;
    else if(s[0]=='B')
        b[0]=1;
    else if(s[0]=='G')
        g[0]=1;
    for(int i=1;i<n;++i){
        r[i]=r[i-1];
        b[i]=b[i-1];
        g[i]=g[i-1];
        if(s[i]=='R')
            ++r[i];
        else if(s[i]=='B')
            ++b[i];
        else if(s[i]=='G')
            ++g[i];
    }
    int flag=0,flag2=0;
    long long sum=0;
    for(int i=0;i<n-2;++i){
        flag=0;
        if(s[i]=='R')
            flag=1;
        else if(s[i]=='B')
            flag=2;
        else if(s[i]=='G')
            flag=3;
        for(int j=i+1;j<n-1;++j){
            flag2=0;
            if(s[i]==s[j])
                continue;
            if(s[j]=='R')
                flag2=1;
            else if(s[j]=='B')
                flag2=2;
            else if(s[j]=='G')
                flag2=3;
            if(flag==1&&flag2==2){
                sum+=g[n-1]-g[j];
                if(j+j-i<n&&s[j+j-i]=='G')
                    --sum;
            }
            else if(flag==1&&flag2==3){
                sum+=b[n-1]-b[j];
                if(j+j-i<n&&s[j+j-i]=='B')
                    --sum;
            }
            else if(flag==2&&flag2==1){
                sum+=g[n-1]-g[j];
                if(j+j-i<n&&s[j+j-i]=='G')
                    --sum;
            }
            else if(flag==2&&flag2==3){
                sum+=r[n-1]-r[j];
                if(j+j-i<n&&s[j+j-i]=='R')
                    --sum;
            }
            else if(flag==3&&flag2==1){
                sum+=b[n-1]-b[j];
                if(j+j-i<n&&s[j+j-i]=='B')
                    --sum;
            }
            else if(flag==3&&flag2==2){
                sum+=r[n-1]-r[j];
                if(j+j-i<n&&s[j+j-i]=='R')
                    --sum;
            }
        }
    }
    cout<<sum;
    return 0;
}



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

def abc154a(s, t, a, b, u):
    if(s == u):
        a -= 1
    else:
        b -= 1
    return(a, b)

###
# main

# input
(s, t) = input().split()
(a, b) = map(int, input().split())
u = input()

(new_a, new_b) = abc154a(s, t, a, b, u)

# output
print(str(new_a) + " " + str(new_b))


Measured memory_bytes: 3060
#include <iostream>
#include <stack>

using namespace std;

long long int db[100][21];

int main() {
  int N;
  int num[100];
  int ans;
  cin >> N;
  N--;
  for (int i = 0; i < N; i++) cin >> num[i];
  cin >> ans;

  db[0][num[0]] = 1;
  for (int i = 0; i < N-1; i++) {
    for (int j = 0; j < 21; j++) {
      if (j + num[i+1] <= 20) db[i+1][j + num[i+1]] += db[i][j];
      if (j - num[i+1] >= 0)  db[i+1][j - num[i+1]] += db[i][j];
    }

  }
  cout << db[N-1][ans] << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, K, H[101010], dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    
    rep(i, 0, N) dp[i] = inf;
    dp[0] = 0;

    rep(i, 0, N) {
        rep(k, 1, K + 1) chmin(dp[i + k], dp[i] + abs(H[i] - H[i + k]));
    }

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


Measured memory_bytes: 4384
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;
void func()
{
	string S;
	string head, tail;
	int T, F, Q;
	bool isReverse=false;
	char c;
	cin >> S;
	cin >> Q;
	for (int i = 0; i < Q; ++i)
	{
		cin >> T;
		if (T==1)
		{
			isReverse = !isReverse;
		}
		else
		{
			cin >> F >> c;
			if (F == 1)
			{
				if (isReverse)
				{
					tail = tail + c;
				}
				else
				{
					head = c + head;
				}
			}
			else
			{
				if (isReverse)
				{
					head = c + head;
				}
				else
				{
					tail = tail + c;
				}
			}
		}
	}
	S = head + S + tail;
	if (isReverse)
	{
		reverse(S.begin(), S.end());
	}
	cout << S <<endl;
}

int main() {
//	while(1)
	func();
	return 0;
}


Measured memory_bytes: 3892
#include<stdio.h>
int main(void){
    int a,h,m,d,e;
    h=3600;
    m=60;
    scanf("%d",&a);
    d=a-((a/h)*h);
    e=d/m;
    printf("%d:%d:%d\n",a/h,e,a-(a/h*h+e*m));
    return 0;
}

Measured memory_bytes: 592
n, m = map(int, input().split())
lr_list = [list(map(int, input().split())) for _ in range(m)]
left = max([l for l, r in lr_list])
right = min([r for l, r in lr_list])
if left > right:
    print(0)
else:
    print(right - left + 1)

Measured memory_bytes: 28264
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <cmath>

int main(){
    
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> b(n);

    for(int i=0;i < n + 1;i++) cin >> a[i];
    for(int i = 0;i < n;i++) cin >> b[i];
    ll ans = 0LL;
    for(int i=0;i < n;i++){

        //先ずは左を全力で倒す
        ll left = min(a[i],b[i]);
        ans += left;
        a[i] -= left;
        b[i] -= left;

        //残った分で右を倒す
        ll right = min(a[i + 1],b[i]);
        ans += right;
        a[i + 1] -= right;
        b[i] -= right; 



    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int N;
int a[110];
int ans=0;

void print() {
	cout<<a[0];
	for(int i=1; i<N; i++) {
		cout<<" "<<a[i];
	}
	cout<<endl;
}
void BubbleSort() {
	for(int i=0; i<N-1; i++) {
		for(int j=N-1; j>i; j--) {
			if(a[j]<a[j-1]) {
				swap(a[j],a[j-1]);
				ans++;
			//	print();
			}
		}
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>N;
	for(int i=0; i<N; i++) {
		cin>>a[i];
	}
	BubbleSort();
	print();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3212