akhauriyash/Code-Regression huggingface dataset:
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int x;
		cin>>x;
		ll int n=100;
		for(ll int i=1;true;i++)
		{
			ll int tmp=n/100;
			n+=tmp;
			if(n>=x)
			{
				cout<<i<<endl;
				return 0;
			}		
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	
	string d;
	map<char,int> a;
	a['I']=1;
	a['V']=5;
	a['X']=10;
	a['L']=50;
	a['C']=100;
	a['D']=500;
	a['M']=1000;
	while(cin>>d){
	int s=0,m=100000000;
	for(int i=0;i<d.size();i++){
		int k=a[d[i]];
		if(m<k) s-=m*2;
		s+=k;
		m=k;			
	}
	
	cout<<s<<endl;
	}
	
}

Measured memory_bytes: 1184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   if(s[0]== s[1]&& s[1]== s[2]){cout << "Yes" << endl;}
   else if(s[1]== s[2]&& s[2]== s[3]){cout << "Yes" << endl;}
   else{cout << "No" << endl;}

   return 0;
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())
X-=1
Y-=1
ans=[0]*(N-1)

for l in range(N):
  for r in range(l+1,N):
    a=min(r-l,abs(X-l)+abs(Y-r)+1)
    ans[a-1]+=1
    
for a in ans:
  print(a)

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

int main(){
  long long a,ans=0;
  cin >> a;
  for(int i=1;i<=a;i++){
    if(i%3!=0 && i%5!=0){
      ans+=i;
    }
  }
  cout <<ans<<endl;
  }


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int c = a + b;
  if (c==3)
  cout << 3 << endl;
  else if (c==4)
  cout << 2 << endl;
  else
  cout << 1 << endl;
}

Measured memory_bytes: 3464
#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool search(string& s, int idx, int accum, string rep) {
  if (idx == 4) {
    if (accum == 7) {
      cout << rep << "=7" << endl;
      return true;
    }
    return false;
  }

  int digit = s[idx] - '0';

  if (rep.size() != 0) {
    if (search(s, idx + 1, accum + digit, rep + "+" + s[idx]))
      return true;
    if (search(s, idx + 1, accum - digit, rep + "-" + s[idx]))
      return true;
  } else {
    if (search(s, idx + 1, accum + digit, string(1, s[idx])))
      return true;
    if (search(s, idx - digit, accum - digit, string(1, s[idx])))
      return true;
  }
  return false;
}

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

  search(s, 0, 0, "");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n>m){
        for(int i=0;i<n;i++)
            printf("%c",m+'0');
    }else{
        for(int i=0;i<m;i++)
            printf("%c",n+'0');
    }
    return 0;
}


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

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

    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if((a[n-i-1] + ans)%b[n-i-1] == 0){continue;}
        else{ans += b[n-i-1] - (a[n-i-1] + ans)%b[n-i-1];}
    }
    cout << ans << "\n";
}


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

int main() {
	long long n,i,j,sum=0,ans=0,count=0,x,y,l,r;
    cin>>n;
    long long a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(i%2==0 && a[i]%2==1)
        count++;
    }
    cout<<count;
	
}

Measured memory_bytes: 3588
s = input()

arr = s.replace('BC','D').replace('B','C').split('C')

cnt = 0

for sub in arr:
  if len(sub) <= 1:
    continue
  ds = 0
  for i in range(len(sub)):
    if sub[i] is 'D':
      ds += 1
      cnt += i - ds + 1
print(cnt)
      

Measured memory_bytes: 5736
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

typedef long long value; // 格納するデータの型
const value INIT = 0ll; // 初期値．目的に応じて，適切な値に変更すること．

class segment_tree {
private:
	int n;
	vector<value> dat;

	value func(value a, value b) const { // ノードの値を決める為の関数
		return max(a, b);
	}

	value query(int a, int b, int k, int l, int r) const {
		if(r <= a || b <= l) // 求める区間が，ノードの区間と重なっていない．
			return INIT;

		if(a <= l && r <= b) { // 求める区間が，ノードの区間を完全に含む．
			return dat[k];
		}
		else {
			const int mid = (l + r) / 2;
			const value vl = query(a, b, k * 2 + 1, l, mid);
			const value vr = query(a, b, k * 2 + 2, mid, r);
			return func(vl, vr);
		}
	}

public:
	segment_tree(int n_) {
		n = 1;
		while(n < n_)
			n *= 2;

		dat.assign(4 * n - 1, INIT);
	}

	void update(int k, value a) { // k番目の要素をaに更新する．
		k += n - 1;
		dat[k] = a;
		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	value query(int a, int b) { // [a, b)に対するクエリ
		return query(a, b, 0, 0, n);
	}
};

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

	int m;
	cin >> m;

	segment_tree segt(m);

	long long mx = 0;
	for(int i = 0; i < m; ++i) {
		int w;
		cin >> w;

		long long tmp = segt.query(1, w) + w;
		segt.update(w, tmp);
		chmax(mx, tmp);
	}

	cout << ((m + 1ll) * m / 2ll - mx) << endl;
	return EXIT_SUCCESS;
}

Measured memory_bytes: 5164
#pragma GCC optimize(2)
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#define lowbit(n) n & (-n)
#define lson rt<<1
#define rson rt<<1|1
#define ls lson, l, mid
#define rs rson, mid+1, r
#define clc(a, b) memset(a, b, sizeof(a))
#define Buff ios::sync_with_stdio(false)
#define rush() int Case = 0; int T; scanf("%d", &T);  while(T--)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define per(i, a, b) for(int i = a; i >= b; i --)
#define reps(i, a, b) for(int i = a; b; i ++)
#define read(a) scanf("%d", &a)
#define readd(a) scanf("%lf", &a)
#define readl(a) scanf("%lld", &a)
#define readc(a) scanf("%c", &a)
#define reads(a) scanf("%s", a)
#define sqr(x) x*x
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>PII;
const int mod = 998244353;
const double eps = 1e-6;
const int N = 2e5+7;
ll sum[N << 2], power[N << 2], pow10[N];
int color[N << 2];
void pushdown(int rt)
{
    if(color[rt] == -1) return ;
    color[lson] = color[rson] = color[rt];
    sum[lson] = power[lson] * 1ll * color[rt] % mod;
    sum[rson] = power[rson] * 1ll * color[rt] % mod;
    color[rt] = -1;
}
void pushup(int rt)
{
    sum[rt] = (sum[lson] + sum[rson]) % mod;
    if(color[lson] != color[rson])  color[rt] = -1;
    else                            color[rt] = color[lson];
}
void build(int rt, int l, int r)
{
    if(l == r)
    {
        color[rt] = 1;
        power[rt] = pow10[l];
        sum[rt] = power[rt];
//        printf("sum[rt] = %lld\n", sum[rt]);
        return ;
    }
    int mid = l + r >> 1;
    build(ls);  build(rs);
    pushup(rt);
    power[rt] = (power[lson] + power[rson]) % mod;
}
void update(int rt, int l, int r, int L, int R, int x)
{
    if(l >= L && r <= R)
    {
        sum[rt] = power[rt] * 1ll * x % mod;
        color[rt] = x;
        return ;
    }
    pushdown(rt);
    int mid = l + r >> 1;
    if(L <= mid)    update(ls, L, R, x);
    if(R > mid)     update(rs, L, R, x);
    pushup(rt);
}
int main()
{
    int n, q;
    read(n);    read(q);
    pow10[n] = 1ll;
    per(i, n-1, 1)  pow10[i] = pow10[i+1] * 10ll % mod;
//    rep(i, 1, n)    cout << pow10[i] <<" ";puts("");
    build(1, 1, n);
    while(q --)
    {
        int l, r, x;
        read(l);    read(r);    read(x);
        update(1, 1, n, l, r, x);
        printf("%lld\n", sum[1]);
    }
	return 0;
}


Measured memory_bytes: 14964
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<int> dp,d2;
int main()
{
	int x,y,h=0,w=0,h2=0,d=0,now=0;
	string s;cin>>s;
	cin>>x>>y;
	dp.pb(0);d2.pb(0);
	rep(i,s.size()){
		if(s[i]=='T'){
			vector<int> ne;
			if(d==0){
				rep(j,dp.size()) ne.pb(dp[j]+now);
				dp=ne;d=1;
			}
			else if(d==1){
				rep(j,d2.size()) ne.pb(d2[j]+now),ne.pb(d2[j]-now);
				d2=ne;d=2;
			}
			else{
				rep(j,dp.size()) ne.pb(dp[j]+now),ne.pb(dp[j]-now);
				dp=ne;d=1;
			}
			now=0;
			sort(All(dp));dp.erase(unique(All(dp)),dp.end());
			sort(All(d2));d2.erase(unique(All(d2)),d2.end());
		}
		else now++;
		//cout<<dp<<' '<<d2<<endl;
	}
	vector<int> ne;
	if(d==0){
		rep(j,dp.size()) ne.pb(dp[j]+now);
		dp=ne;d=1;
	}
	else if(d==1){
		rep(j,d2.size()) ne.pb(d2[j]+now),ne.pb(d2[j]-now);
		d2=ne;d=2;
	}
	else{
		rep(j,dp.size()) ne.pb(dp[j]+now),ne.pb(dp[j]-now);
		dp=ne;d=1;
	}
	//cout<<dp<<' '<<d2<<endl;
	bool ox=false,oy=false;
	rep(i,dp.size()){
		if(dp[i]==x) ox=true;
	}
	rep(i,d2.size()){
		if(d2[i]==y) oy=true;
	}
	if(ox && oy) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        q: usize,
        s: chars,
        l: [(usize, usize); q],
    }
    let mut hold: Vec<i32> = vec![0; n];

    for i in 0..n-1 {
        hold[i+1] = hold[i] + if s[i] == 'A' && s[i+1] == 'C' { 1 } else { 0 };
    }

    for i in l {
        println!("{}", hold[i.1 - 1] - hold[i.0 - 1]);
    }
}



Measured memory_bytes: 6908
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<P> b(a);
  rep(i,a)
    cin>>b[i].first>>b[i].second;
  sort(all(b));
  out(b[a-1].first+b[a-1].second);
  
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length();
  if(s[l-1]=='<')s=s+'>';
  if(s[0]=='>')s='<'+s;
  l=s.length();
  vector<ll>id;
  rep(i,l-1){
    if(s[i]=='<'&&s[i+1]=='>')id.push_back(i);
  }
  ll res=0;
  for(auto ti:id){
    ll tl=ti,tr=ti;
    while(tl-1>=0&&s[tl-1]=='<')tl--;
    while(tr+1<l&&s[tr+1]=='>')tr++;
    tl=ti-tl+1;
    tr=tr-ti;
    ll ma,mi;
    ma=max(tl,tr)+1;
    mi=min(tl,tr);
  //  cout<<ti<<" "<<ma<<" "<<mi<<endl;
    res+=ma*(ma-1)/2+mi*(mi-1)/2;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[100005];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a + 1, a + 1 + n);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if ((i - a[i].second) % 2)
			cnt++;
	}
	printf("%d\n", cnt / 2);
	return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 18;

int a[MAX];
int b[MAX];

void bad()
{
	cout << -1;
	exit(0);
}

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
		cin >> a[i];
	priority_queue<PII> pq;
	FOR(i, 0, n)
	{
		cin >> b[i];
		if(b[i] < a[i])
			bad();
		pq.push(MP(b[i], i));
	}
	LL ans = 0;
	while(!pq.empty())
	{
		int pos = pq.top().second;
		pq.pop();
		if(a[pos] < b[pos])
		{
			
			int l = b[pos - 1 >= 0 ? pos - 1 : pos - 1 + n];
			int r = b[pos + 1 < n ? pos + 1 : pos + 1 - n];
			int cnt = (b[pos] - a[pos]) / (l + r);
			if(cnt == 0)
				bad();
			ans += cnt;
			b[pos] -= cnt * (l + r);
			pq.push(MP(b[pos], pos));
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    int n;
    cin >> n;

    int k, c;
    cin >> k >> c;

    string s;
    cin >> s;

    vector<int> l(k), r(k);
    {
      int ptr = 0;
      int last = -1;
      for (int i = 0; ptr < k; ++i) {
        if (s[i] == 'x')
          continue;
        if (last >= 0 && last + c >= i)
          continue;
        l[ptr++] = i;
        last = i;
      }
    }

    {
      int ptr = k - 1;
      int last = -1;
      for (int i = n - 1; ptr >= 0; --i) {
        if (s[i] == 'x')
          continue;
        if (last >= 0 && i + c >= last)
          continue;
        last = i;
        r[ptr--] = i;
      }
    }

    for (int i = 0; i < k; ++i) {
      if (l[i] == r[i]) {
        cout << l[i] + 1 << endl;
      }
    }
  }
}

Measured memory_bytes: 5012
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        long t = sc.nextLong();
        long a = sc.nextLong();
        long nt = 0,na = 0;
        for (int i = 1;i < n;i++) {
            nt = sc.nextLong();
            na = sc.nextLong();
            long m = Math.max((t-1)/nt+1,(a-1)/na+1);
            t = nt*m;
            a = na*m;
        }
        
        System.out.println(t+a);
    }
}


Measured memory_bytes: 13432
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[200009];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  if(n%2==0){
    for(int i=n-1;0<=i;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=0;i<n;i+=2){
      if(i+2>=n)cout<<a[i]<<endl;
      else cout<<a[i]<<' ';
    }
  }
  else{
    if(n==1){
      cout<<a[0]<<endl;
      return(0);
    }
    for(int i=n-1;0<=i;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=1;i<n;i+=2){
      if(i+2>=n)cout<<a[i]<<endl;
      else cout<<a[i]<<' ';
    }
  }
  return(0);
}


Measured memory_bytes: 3712
a = 0
w = 0
r = 0
t = 0
for _ in range(int(input())):
	s = input()
	if s=="AC":
		a+=1
	elif s=="WA":
		w+=1
	elif s=="TLE":
		t+=1
	else:
		r+=1
print("AC "+"x "+str(a))
print("WA "+"x "+str(w))
print("TLE "+"x "+str(t))
print("RE "+"x "+str(r))

Measured memory_bytes: 9236
#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
 
double d(double x, double y, double z, double w){
    double ret;
    ret = pow(x - z , 2) + pow(y - w , 2);
    return sqrtf(ret);
}
 
int main(){
    int n;
    double x[2], y[2], r[2], dd;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> x[0] >> y[0] >> r[0] >> x[1] >> y[1] >> r[1];
        dd = d(x[0], y[0], x[1], y[1]);
        if(dd > (r[0]+r[1])){
            cout << 0 << endl;
        }
        else if(dd + r[0] < r[1]){
            cout << -2 << endl;
        }
        else if (dd + r[1] < r[0]) {
            cout << 2 << endl;
        }
        else {
            cout << 1 << endl;
        }
    }
    return 0;
}

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

int main(){
    int n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    ll g=__gcd(n,m);
    ll ans=n/g*m;
    for(int i=0,j=0; i<n; i+=n/g,j+=m/g){
        if(s[i]!=t[j])ans=-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N,count;
   cin>>N;
   count=0;
   vector<int> A(N),B(N-1);
   for(int i=0;i<N-1;i++){
      cin>>B.at(i);
   }

   A.at(0)=B.at(0);
   A.at(N-1)=B.at(N-2);
   for(int i=1;i<N-1;i++){
      A.at(i)=min(B.at(i-1),B.at(i));
   }
   for(int i=0;i<N;i++){
      count+=A.at(i);
   }
   cout<<count<<endl;
}

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

int main(){
  int a,b,c,d,e;
  cin>>a>>b;
  for(c=b;c<=b+a-1;c++){
    d=d+c;
  }
  e=b*(a+b-1);
  if(e<=0){
    cout << d;
  }
  else if(b>0){
    cout << d-b;
  }
  else cout<< d-a-b+1;
  return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)

nc=[-1]*(n+1)
def nConb(n):
  if nc[n] != -1:
    return nc[n]
  nc[n]=n*(n-1)//2
  return nc[n]

temp=0
for k,v in c.items():
  temp+=nConb(v)

for i in range(n):
  if c[a[i]] == 1:
    print(temp)
  else:
    print(temp-(c[a[i]]-1))

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            HashSet<string> s = new HashSet<string>();
            for (int i = 0; i < N; i++) s.Add(Console.ReadLine());
            Console.WriteLine(s.Count);
        }
    }
}

Measured memory_bytes: 47428
#include<stdio.h>

int main(void){
   int p;
   scanf("%d",&p);
   if(p%10==2||p%10==4||p%10==5||p%10==7||p%10==9){
      printf("hon");
   }else if(p%10==0||p%10==1||p%10==6||p%10==8){
      printf("pon");
   }else if(p%10==3){
      printf("bon");
   }

   return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int n;

int main() {
    cin >> n;
    int x = n % 10;
    if (x == 3) {
        cout << "bon" << endl;
    } else if (x == 0 || x == 1 || x == 6 || x == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<uint64_t> num(N);
  for(auto& n : num) {std::cin >> n;}
  bool b = true;
  for(int i = N - 2; i >= 0; --i) {
    if(num[i] > num[i+1]) {--num[i];}
    if(num[i] > num[i+1]) {
      b = false;
      break;
    }
  }
  if(b) {std::cout << "Yes" << std::endl;}
  else {std::cout << "No" << std::endl;}
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int X,A,B;
    std::cin >> X >> A >> B;
    std::cout << (X-A)%B << std::endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a==c-b) puts("YES");
  else puts("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  int n = s.size();
  vector<int> ans(n, 1);

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R' && s[i + 1] == 'R') {
      ans[i + 1] += ans[i];
      ans[i] = 0;
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'L' && s[i - 1] == 'L') {
      ans[i - 1] += ans[i];
      ans[i] = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      int t = ans[i] + ans[i + 1];
      if (t % 2 == 0) {
        ans[i] = ans[i + 1] = t / 2;
      } else {
        int r = ans[i];
        int l = ans[i + 1];
        ans[i] = (r + 1) / 2 + l / 2;
        ans[i + 1] = r / 2 + (l + 1) / 2;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << ln;
  }

  return 0;
}

Measured memory_bytes: 1104
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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 N;
string S;

int main() {
    cin >> N >> S;
    int ans = 0;
    char pre = S[0];
    FOR (i, 1, N) {
        if (S[i] != pre) {
            ans++;
        }
        pre = S[i];
    }
    ans++;
    cout << ans << endl;
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,p;
    cin >> a >> p;
    p+=a*3;
    cout <<p/2<< "\n";
}

Measured memory_bytes: 256
from itertools import combinations
H, W = map( int, input().split())
A = [ list( input()) for _ in range(H)]
for X in combinations([i for i in range(H+W-2)], H-1):
    I = [0]*(H+W-2)
    for i in range(H-1):
        I[X[i]] = 1
    B = [ ["."]*W for _ in range(H)]
    B[0][0] = "#"
    nowx = 0
    nowy = 0
    for i in range(H+W-2):
        if I[i] == 1:
            if A[nowx+1][nowy] == "#":
                nowx += 1
        else:
            if A[nowx][nowy+1] == "#":
                nowy += 1
        B[nowx][nowy] = "#"
    if nowx == H-1 and nowy == W-1:
        break
ans = "Possible"
for i in range(H):
    for j in range(W):
        if not A[i][j] == B[i][j]:
            ans = "Impossible"

print(ans)


Measured memory_bytes: 3444
#include<cstdio>
#include<queue>
#include<algorithm>
#define MAXN 100013
using namespace std;
long long ans;
int n,m;
int a[MAXN];
queue<int>q1,q2;
int main(){
	ans=0;
	while(!q1.empty())q1.pop();
	while(!q2.empty())q2.pop();
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
	} 
	sort(a+1,a+n+1);
	for(int i=n;i;--i){
		q1.push(a[i]);
	}
	while(m--){
		if(q1.empty()&&q2.empty())break;
		if(q2.empty()){
			q2.push(q1.front()>>1);
			q1.pop();
			continue;
		}
		if(q1.empty()){
			q2.push(q2.front()>>1);
			q2.pop();
			continue;
		}
		if(q1.front()>q2.front()){
			q2.push(q1.front()>>1);
			q1.pop();
			continue;
		}
		q2.push(q2.front()>>1);
		q2.pop();
	}
	while(!q1.empty()){
		ans+=q1.front();q1.pop();
	}
	while(!q2.empty()){
		ans+=q2.front();q2.pop();
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>c){
		cout<<"NO"<<endl;
	}
	else if(c-a<b){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
N = int(input())
T = []
for i in range(N):
   T.append(tuple(map(int, input().split())))

T = sorted(T, key=lambda x:x[1])
t = 0
for a, b in T:
  t += a
  if t > b:
    print("No")
    quit()
print("Yes")

Measured memory_bytes: 33472
#include <stdio.h>
#define max(a, b) ((a)<(b) ? (b) : (a))

int ans = 0;
int a[52], b[52], c[52], d[52];

void dfs(int array[], int m, int n, int q){
  if(array[0] == n){
    int sum = 0;
    for(int i=0; i<q; i++)
      if(array[b[i]] - array[a[i]] == c[i])
	sum += d[i];
    ans = max(ans, sum);
    return;
  }

  int start = (array[0] == 0 ? 1 : array[array[0]]);
  for(int i=start; i<=m; i++){
    array[++array[0]] = i;
    dfs(array, m, n, q);
    array[0]--;
  }
}

int main(){
  int n, m, q;  scanf("%d%d%d", &n, &m, &q);
  for(int i=0; i<q; i++)
    scanf("%d %d %d %d", a+i, b+i, c+i, d+i);

  int array[15] = {0};
  dfs(array, m, n, q);

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
long long a[1200];
int main(){
    int n;
    cin>>n;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=n;i++)
        a[i]=a[i-2]+a[i-1];
    cout<<a[n];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int num[50500],n,ma,anslow=0,anshigh=0;
    ma=sqrt(50500);
    for(int i=1;i<50500;i++)num[i]=0;
    for(int i=2;i<ma;i++){
        if(num[i]==0){
            for(int j=2;j*i<50500;j++)num[j*i]=1;
        }
    }
    while(cin>>n){
        for(int i=1;anslow==0||anshigh==0;i++){
            if(num[n-i]==0&&anslow==0)anslow=n-i;
            if(num[n+i]==0&&anshigh==0)anshigh=n+i;
        }
        cout<<anslow<<" "<<anshigh<<endl;
        anshigh=0;anslow=0;
    }
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
long long gcd(long long a, long long b) {
  /* the greatest common divisor*/
  while (b != 0) {
    long long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) {
  /*the least common multiple*/
  return (a / gcd(a, b)) * b;
}



int main() {
  int n;
  cin>>n;
  LL prev;
  cin>> prev;
  REP(i,0,n-1){
    LL now;
    cin>>now;
    prev=gcd(prev,now);
  }
  cout<<prev<<endl;


  return 0;
}


Measured memory_bytes: 256
inputs = []
loop do
    input = gets.split(" ")
    input.map!(&:to_i)
    if input[0] == 0 && input[1] == 0; break; end
    inputs << input
end
inputs.each do |input|
    input[0].times do |h|
        input[1].times do |w|
            if h == 0 || h == input[0]-1 || w == 0 || w == input[1]-1
                print "#"
            else
                print "."
            end
        end
        print "\n"
    end
    print "\n"
end


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

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


int main()
{
int n;
cin>>n;
int a,b;
cin>>a>>b;
int ans=0;
for(int i=1; i<=n; i++)
{
    int c = i/10000;
    int d = i/1000%10;
    int e = i/100%10;
    int f = i/10%10;
    int g = i%10;
    int sum = c+d+e+f+g;
    if(a<=sum&&sum<=b)  ans+=i;
}
cout<<ans<<endl;
}

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int a[4];
   rep(i,0,4)scanf("%d",&a[i]);
   sort(a,a+4);
   printf("%d\n",abs(a[0]+a[3]-a[1]-a[2]));
   return 0;
}


Measured memory_bytes: 3272
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

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

int main(){
    int n, m, cx, cy, dir, k;
    char cmd[20];

    while(scanf("%d %d\n", &n, &m)){
        if(!(n||m)) break;
        cx = cy = 1;
        dir = 0;
        while(1){
            scanf("%s",cmd);
            if(string(cmd) == "FORWARD"){
                scanf("%d",&k);
                cx += k*dx[dir];
                cy += k*dy[dir];
                if(cx < 1) cx = 1;
                if(cx > n) cx = n;
                if(cy < 1) cy = 1;
                if(cy > m) cy = m;
            }
            else if(string(cmd) == "BACKWARD"){
                scanf("%d",&k);
                cx += k*dx[(dir+2)%4];
                cy += k*dy[(dir+2)%4];
                if(cx < 1) cx = 1;
                if(cx > n) cx = n;
                if(cy < 1) cy = 1;
                if(cy > m) cy = m;
            }
            else if(string(cmd) == "RIGHT"){
                dir = (dir+1)%4;
            }
            else if(string(cmd) == "LEFT"){
                dir = (dir+3)%4;
            }
            else if(string(cmd) == "STOP"){
                printf("%d %d\n",cx, cy);
                break;
            }
            scanf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;
typedef long long signed int ll;

constexpr int inf = INT32_MAX / 2;
constexpr int mod = 1000000007;
constexpr int maxn = 100000;

class djikstra {
private:
	ll* d = nullptr;
	map<int, map<int, ll>> p;
	int sz = 0;
public:
	void add_path(int from, int to, ll cost) {
		p[from][to] = cost;
	}
	void compute(int from,int nodes) {
		sz = nodes;
		if (d != nullptr) delete d;
		d = new ll[nodes];
		auto cmp = [this](int a, int b) {return d[a] > d[b]; };
		priority_queue <ll, vector<ll>, decltype(cmp)> q(cmp);
		for (int i = 0; i < nodes; i++) d[i] = INT64_MAX / 2;
		d[from] = 0;
		q.push(from);
		while (!q.empty()) {
			for (auto& e : p[q.top()]) {
				if (d[e.first] > d[q.top()] + e.second) {
					d[e.first] = d[q.top()] + e.second;
					q.push(e.first);
				}
			}
			q.pop();
		}
	}
	ll operator[](int node) {
		if (node >= sz) return INT64_MAX/2;
		return d[node];
	}
};

int n, m, q, l, r;
vector<pair<int, int>> s;

int dp[501][501];
int rec(int p, int q) {
	if (dp[p][q] == -1) {
		dp[p][q] = (upper_bound(s.begin(), s.end(), make_pair(p, q)) - lower_bound(s.begin(), s.end(), make_pair(p, p)));
		if (p + 1 <= q) dp[p][q] += rec(p + 1, q);
	}
	return dp[p][q];
}

int main() {
	for (int i = 0; i < 501; i++) for (int j = 0; j < 501; j++)dp[i][j] = -1;
	cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		s.emplace_back(l, r);
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < q; i++) {
		int u, v;
		cin >> u >> v;
		cout << rec(u, v) << endl;
	}
}


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


int main(){
  string s, t;
  int m;

  cin >> s ;

  m = s.length();
  for (int i = 0; i < m; i++){
    t += "x";
  }

  cout << t << endl;
  return 0;
}


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

int n;

void dfs(string s, char mx) {
    if (s.length() == n) {
        printf("%s\n", s.c_str());
    } else {
        for (char c = 'a'; c <= mx; ++c) {
            dfs(s + c, c == mx ? (mx + 1) : mx);
        }
    }
}

int main() {
    scanf("%d", &n);
    dfs("", 'a');
    return 0;
}


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

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

int main(){
	int val[5] = {0, 6000,4000,3000,2000};
	rep(i,4){
		int t, n;
		cin >> t >> n;
		cout << val[t]*n << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int A,B;
    cin >> A >> B;
    bool ans[3]={};
    ans[A-1]=true;
    ans[B-1]=true;
    rep(i,3) if(!ans[i]) cout << i+1 << endl;

}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
e = [list() for _ in range(n)]
for _ in range(q):
    a, b, c, d = map(int, input().split())
    e[b - 1].append((a - 1, c, d))
a = [0] * n
ans = 0
cur = 0
def dfs(u):
    global cur, ans
    if u >= n:
        ans = max(ans, cur)
        return
    for i in range(a[u - 1] if u else 1, m + 1):
        a[u] = i
        for b, c, d in e[u]:
            if i - a[b] == c:
                cur += d
        dfs(u + 1)
        for b, c, d in e[u]:
            if i - a[b] == c:
                cur -= d
dfs(0)
print(ans)

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	string s=readString();
	bool p=false,q=false;
	for(auto c:s)
		if(c=='C')
			p=true;
		else if(c=='F'&&p)
			q=true;
	if(q)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}


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

int main(){
    int a;
    cin>>a;
    vector<int> data(a);
    for(int k = 0; k < a; k++){
        cin>>data[k];
    }
    int swap = 0;
    for(int i = 0; i < a; i++){
        int minj = i;
        for(int j = i; j < a; j++){
            if(data[j] < data[minj]){
                minj = j;
//                swap++;
            }
        }
        if(data[minj] != data[i]){
            int tmp = data[minj];
            data[minj] = data[i];
            data[i] = tmp;
            swap++;
        }
//        swap(data[minj], data[i]);
    }
    for(int i = 0; i < a; i++){
        cout<<data[i];
        if(i != a-1){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }
    cout<<swap<<endl;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  
  int ans = 0;
  for (int bit = 28; bit >= 0; bit--) {
    vector<int> c(n), d(n);
    for (int i = 0; i < n; i++) c.at(i) = a.at(i) % (1 << (bit + 1));
    for (int i = 0; i < n; i++) d.at(i) = b.at(i) % (1 << (bit + 1));
    sort(d.begin(), d.end());
    ll count = 0;
    for (int i = 0; i < n; i++) {
      int it1, it2, it3, it4;
      int l = -1, r = n;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (c.at(i) + d.at(mid) >= (1 << bit)) r = mid;
        else l = mid;
      }
      it1 = r;
      l = -1, r = n;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (c.at(i) + d.at(mid) >= (1 << bit) * 2) r = mid;
        else l = mid;
      }
      it2 = r;
      l = -1, r = n;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (c.at(i) + d.at(mid) >= (1 << bit) * 3) r = mid;
        else l = mid;
      }
      it3 = r;
      l = -1, r = n;
      while (r - l > 1) {
        int mid = (l + r) / 2;
        if (c.at(i) + d.at(mid) >= (1 << bit) * 4) r = mid;
        else l = mid;
      }
      it4 = r;
      count += (it2 - it1) + (it4 - it3);
    }
    if (count % 2 == 1) ans += (1 << bit);
  }
  
  cout << ans << '\n';
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	string t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	int ans = m;
	for(int i=0;i+m-1<n;i++) {
		int c = 0;
		for(int j=0;j<m;j++) {
			if(s[i+j]!=t[j])
				c++;
		}	
		ans = min(ans, c);
	}

	cout<<ans<<"\n";

	return 0;
}

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

int main(){
  long long int n,p[5],min;
  
  
  cin >> n;
  for(int i=0; i<5; i++){
    cin >> p[i];
  }
  
  min = p[0];
  for(int i=0; i<5; i++){
    if( p[i] < min ) min = p[i];
  }
    
  cout << (n + (min-1))/min + 4 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	int i,j,num;
	int q,w,e,r,t,y;

	while(scanf("%d",&n),n){
		num=0;
		for(i=1;i*i<n;i++){
			if(n%i==0) num=num+i+n/i;
		}
		num-=n;
		if(num==n){
			printf("perfect number\n");
		}
		else if(num>n){
			printf("abundant number\n");
		}
		else {
			printf("deficient number\n");
		}
	}
	return 0 ;
}

Measured memory_bytes: 584