akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s;
  cin >> s;
  int ss = count(s.begin(), s.end(), '1');
  cout << ss << "\n";
}


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

int main() {
char b;
cin >> b;
if(b=='A'){
cout <<'T';
}
else if(b=='T'){
cout <<'A';
}
else if(b=='C'){
cout <<'G';
}
else if(b=='G'){
cout <<'C';
}
return 0;
}

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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int x;
	cin >> x;
	int r = x % 500;
	cout << 1000 * (x / 500) + r - r % 5;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

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 DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string str;
	int q;
	cin >> str >> q;
	deque<char> dq;
	for(char el: str) dq.push_back(el);

	int ori = 0;
	while(q--) {
		int ty;
		cin >> ty;
		if(ty == 1) {
			ori ^= 1;
		} else {
			int f;
			char c;
			cin >> f >> c; f--;
			if(f ^ ori) dq.push_back(c);
			else dq.push_front(c);
		}
	}

	while(dq.size()) {
		if(!ori) {
			cout << dq.front(); dq.pop_front();
		} else {
			cout << dq.back(); dq.pop_back();
		}
	}

	cout << '\n';
}



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

vector<vector<char>> s(52, vector<char>(52, '#'));
vector<vector<int>> s_count(52, vector<int>(52, 0));
queue<pair<int, int>> q;
int H, W, tmp_count;

bool push_q(int m, int n)
{
  if (s[m][n] != '#' && !s_count[m][n])
  {
    s_count[m][n] = tmp_count + 1;
    if (m == H && n == W)
      return (true);
    q.push(make_pair(m, n));
  }
  return (false);
}

int main()
{
  int w_count = 0, m, n;
  pair<int, int> tmp;


  cin >> H >> W;
  for (int i = 1; i <= H; i++)
  {
    for (int j = 1; j <= W; j++)
    {
      cin >> s[i][j];
      if (s[i][j] == '.')
        w_count++;
    }
  }
  q.push(make_pair(1, 1));
  while (!q.empty())
  {
    tmp = q.front();
    q.pop();
    m = tmp.first;
    n = tmp.second;
    tmp_count = s_count[m][n];
    if (push_q(m + 1, n) || push_q(m - 1, n) || push_q(m, n + 1) || push_q(m, n - 1))
      break;
  }
  if (s_count[H][W] == 0)
    cout << -1 << endl;
  else
    cout << w_count - s_count[H][W] - 1 << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = [0]*N
# 非破壊的に逆順で返す
for i in reversed(range(1, N+1)):
    v = A[i-1]
    # range(start, stop, step)
    for j in range(i, N+1, i):
        v += ans[j-1]
    # 箱に入れるかを決める
    ans[i-1] = v % 2

M = sum(ans)
print(M)
if M:
    # もし入っていれば、その添字に１を足して入れる。それをanpac
    print(*(i+1 for i, b in enumerate(ans) if b == 1))


Measured memory_bytes: 72080
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
int d[210][210];
 
int n, m, r;
void wf() {
    for(int k=1; k<n; ++k) {
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}
 
signed main() {
    cin >> n >> m >> r;
    for(int i=0; i<201; ++i) {
        for(int j=0; j<201; ++j) {
            if(i==j) d[i][j] = 0;
            else d[i][j] = (1<<30);
        }
    }
    vector<int> v(r);
    for(int i=0; i<r; ++i) {
        cin >> v[i];
        v[i]--;
    }
    sort(v.begin(), v.end());
 
    for(int i=0; i<m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    wf();
 
    int ans = (1<<30);
    do {
        int tmp = 0;
        for(int i=1; i<v.size(); ++i) tmp += d[v[i-1]][v[i]];
        ans = min(ans, tmp);
    } while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 512
import sys
fl=sys.stdout.flush
res=['Vacant','Male','Female']

def main():
    n=int(input())
    r=['' for _ in range(n)]
    print(0)
    fl()
    r[0]=input()
    if r[0]==res[0]:
        return
    
    print(n-1) # even
    r[n-1]=input()
    fl()
    if r[n-1]==res[0]:
        return
    ll,rr=0,n-1
    while rr-ll>1:
        mid=(rr+ll)//2
        print(mid)
        fl()
        r[mid]=input()
        if r[mid]==res[0]:
            return
        if (r[mid]==r[rr])^((rr-mid)%2==0):
            ll=mid
        else:
            rr=mid
    
main()

Measured memory_bytes: 4588
#include <iostream>
#include <cstdio>
#include <cmath>
#define N 90005
using namespace std;
int h, w, d, q, l, r, a[N], b[N], s[N];
int main() {
	int i, j, t;
	scanf("%d%d%d", &h, &w, &d);
	for(i=0; i<h; i++) for(j=0; j<w; j++) {
		scanf("%d", &t);
		a[t] = i;
		b[t] = j;
	}
	for(i=d+1; i<=h*w; i++) {
		s[i] = s[i-d] + abs(a[i] - a[i-d]) + abs(b[i] - b[i-d]);
	}
	scanf("%d", &q);
	while(q--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", s[r] - s[l]);
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>

using namespace std;

int main()
{
    long long int N, i, ans_ten = 1, ans_eight = 1, ans_nine = 1, ans;
    cin>>N;
    for(i=1;i<=N;i+=1)
    {
        ans_ten = (ans_ten * 10)%1000000007;
        ans_eight = (ans_eight * 8)%1000000007;
        ans_nine = (ans_nine * 9)%1000000007;
    }
    ans = (((ans_ten - ans_nine)%1000000007 + (ans_eight - ans_nine)%1000000007)%1000000007 + 1000000007)%1000000007;
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
#define all(x) x.begin(), x.end()

int n;

char xs[4010];

using V=bitset<4000>;

const ll mod = 998244353;

ll Pow(ll b, ll e){
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=mod;
		e>>=1; (b*=b)%=mod;
	}
	return ret;
}

bool exi[4010];
V key[4010];
void Input(){
	static char buf[4010];
	scanf("%s", buf);
	int l = strlen(buf);
	V v; for(int i=l-1; 0<=i; --i) v[l-1-i]=(buf[i]=='1');
	int top = l-1;
	for(;;){
		bool zr = 0;
		while(exi[top]){
			v ^= key[top];
			while(!v[top]){
				if(top == 0){
					zr = 1;
					break;
				}
				--top;
			}
			if(zr) break;
		}
		if(zr) break;
		for(;!exi[top];){
			exi[top]=1; key[top]=v;
			if(top == 3999) break;
			++top; v<<=1;
		}
	}
}

int main()
{
	scanf("%d%s", &n, xs);
	for(int i=0; i<n; ++i) Input();
	
	vector<int> tops;
	int xt = strlen(xs);
	for(int i=xt-1; 0<=i; --i) if(exi[i]){
		tops.pb(i);
	}
	ll txc=0;
	
	reverse(xs, xs+xt);
	int p=0, tn=tops.size();
	while(tops[p] != xt-1) ++p;
	V cv;
	bool alive = 1;
	for(int i=xt-1; 0<=i; --i){
		if(xs[i]=='1'){
			if(cv[i]){
				if(p<tn && tops[p]==i){
					(txc += Pow(2, tn-p-1)) %= mod;
				}
			} else if(p<tn && tops[p]==i){
				(txc += Pow(2, tn-p-1)) %= mod;
				cv ^= key[i];
			} else {
				(txc += Pow(2, tn-p)) %= mod;
				alive = 0;
				break;
			}
		} else {
			if(cv[i]){
				if(p<tn && tops[p]==i){
					cv ^= key[i];
				} else {
					alive = 0;
					break;
				}
			}
		}
		if(p<tn && tops[p]==i) ++p;
	}
	if(alive) ++txc;
	printf("%lld\n", txc%mod);
	return 0;
}



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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  for (int i = 1; i <= k; ++i) {
    if (i % 2 == 1) {
      //高橋くんパート
      if (a % 2 == 1) {
        a--;
      }
      b += a / 2;
      a /= 2;
    } else {
      if (b % 2 == 1) {
        b--;
      }
      a += b / 2;
      b /= 2;
    }
  }

  cout << a << " " << b << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
int main() {
	
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int N;

	scanf("%d", &N);
	if (N >= 1000) {
		printf("ABD");
	}
	else {
		printf("ABC");
	}
	
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int inputN, inputA;
    scanf("%d", &inputN);
    int intArray[100];

    // Create an array to store the input
    for (int i = 0; i < inputN; i++)
    {
        scanf("%d", &inputA);
        intArray[i] = inputA;
    }

    // Check for values inside the loop
    for (int i = 0; i < inputN; i++)
    {
        if (intArray[i] % 2 != 0)
        {
            continue;
        }
        
        if(!(intArray[i] % 3 == 0 || intArray[i] % 5 == 0))
        {
            printf("DENIED \n");
            return 0;
        }
    }
    printf("APPROVED \n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if ((a < b) && (b < c)) {

			System.out.println("Yes");

		} else {

			System.out.println("No");

		}

		sc.close();

	}

}


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

int main() {
  long long n;
  long long ans = 0;
  long long count = 10;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0;
  }
  else {
    while (count <= n) {
      ans = ans + (n / count);
      count = count * 5;
    }
    cout << ans;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
using namespace std;
const int N =300000+5;
int f[N*4];
int a[N];
void updt(int rt,int l,int r,int x,int op){
	if(l==r){
		f[rt]=op;
		return ;
	}
	int mid=(l+r)/2;
	if(x<=mid)updt(lson,x,op);
	if(mid+1<=x)updt(rson,x,op);
	f[rt]=max(f[rt<<1],f[rt<<1|1]);
}
int query(int rt,int l,int r,int L,int R){
	if(L<=l&&r<=R)return f[rt];
	int mid=(l+r)/2,mx=0;
	if(mid>=L)mx=max(mx,query(lson,L,R));
	if(mid+1<=R)mx=max(mx,query(rson,L,R));
	return mx;
}
int main(){
	int n,k,res=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int l=max(0,a[i]-k),r=min(a[i]+k,300000);
	    int mx=query(1,1,300000,l,r);
		//printf("%d %d %d\n",l,r,query(1,1,300000,l,r));
		updt(1,1,300000,a[i],mx+1);
		res=max(res,mx+1);
	} 
	printf("%d\n",res);
	
} 

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

int main() {
    string S, T, U;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    cin >> U;
    if (S == U) {
        A = A - 1;
    } else if (T == U) {
        B = B - 1;
    }

    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
f=lambda:map(int,input().split())
h,w,m=f()
l,H,W=[],[0]*-~h,[0]*-~w
for _ in range(m):
  x,y=f()
  l+=[(x,y)]
  H[x]+=1
  W[y]+=1
s,t=max(H),max(W)
print(s+t-(H.count(s)*W.count(t)==sum(H[x]+W[y]==s+t for x,y in l)))

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

using namespace std;

typedef long long ll;

struct node{
	ll l, r, d;
	node() : l(0), r(0), d(0) {}
};

node T[202020];
char S[101010];
ll d, k, x;

void insert(ll p, char *S)
{
	if(!*S) return;
	
	if(*S == '0'){
		if(!T[p].l){
			T[p].l = ++k;
			T[k].d = T[p].d + 1;
		}
		insert(T[p].l, S + 1);
	}
	else{
		if(!T[p].r){
			T[p].r = ++k;
			T[k].d = T[p].d + 1;
		}
		insert(T[p].r, S + 1);
	}
}

int main()
{
	ll n, i;
	
	scanf("%lld%lld", &n, &d);
	
	k = 1;
	
	for(; n--; ){
		scanf("%s", S);
		insert(1, S);
	}
	
	for(i=1; i<=k; i++){
		if((T[i].l && !T[i].r) || (!T[i].l && T[i].r)){
			ll t = d - T[i].d;
			x ^= t & -t;
		}
	}
	
	printf("%s\n", x? "Alice" : "Bob");
	
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,i,ans=0;
  map<int,int> m;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>x;
    if(m.count(x)) m.at(x)++;
    else m[x]=1;
  }
  for(auto z:m) if(z.second%2==1) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 8148
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {k: i32, x: i32};

    let mut v = vec![];
    v.push(x);

    for i in 1..k {
        v.push(x - i);
        v.push(x + i);
    }

    v.sort();
    for i in v.iter() {
        print!("{} ", i);
    }
}


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

int main() {
  INCANT;
  cin >> S;
  n = S.size();
  char now = '-';
  int cnt=0;
  rep(i, n) {
    if (now==S[i]) continue;
    cnt++;
    now=S[i];
  }

  cout << cnt-1 << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[1010], c[1010];
int main() {
	int n, q;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> q;
	while (q--) {
		int b, m, e;
		cin >> b >> m >> e;
		for (int i = b; i < e; i++)c[b + ((i - b + e - m) % (e - b))] = a[i];
		for (int i = b; i < e; i++)a[i] = c[i];
	}
	rep(i, n)cout << a[i] << (i == n - 1 ? "\n" : " ");
	return 0;
}


Measured memory_bytes: 3060
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1000 + 20 , mod = 1e9 + 7 ;
int n , a , b , c , d , dp[N][N] ;
int C[N][N] , rev[N] ;

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
}

inline int pw (int a , int b) {
	int res = 1 ;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod ;
		a = 1ll * a * a % mod ;
		b >>= 1 ;
	}
	return res ;
}

inline void pre () {
	for (int i = 0 ; i < N ; i ++) {
		C[i][0] = C[i][i] = 1 ;

		for (int j = 1 ; j < i ; j ++) {
			C[i][j] = C[i - 1][j] ;
			add(C[i][j] , C[i - 1][j - 1]) ;
		}

		rev[i] = pw(i , mod - 2) ;
	}
}

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

	pre() ;

	cin >> n >> a >> b >> c >> d ;

	dp[n][0] = 1 ;
	
	for (int x = a ; x <= b ; x ++) {
		for (int i = 1 ; i <= n / x ; i ++) {
			for (int sum = 0 ; sum + x <= n ; sum ++) {
				add(dp[sum][i] , 1ll * C[sum + x][x] * dp[sum + x][i - 1] % mod * rev[i] % mod) ;	
			}
		}

		for (int i = 1 ; i <= n / x ; i ++) {
			for (int sum = 0 ; sum <= n ; sum ++) {
				if (c <= i && i <= d) add(dp[sum][0], dp[sum][i]) ;
				dp[sum][i] = 0 ;
			}
		}
	}

	cout << dp[0][0] << '\n' ;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = n;
  REP(i, n) {
    int t;
    cin >> t;
    if (t >= a && t < b)
      ans--;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll n, m; cin >> n >> m;
    vector<ll> p(m);
    vector<string> s(m);
    rep(i, m) cin >> p[i] >> s[i];

    vector<bool> ac(n, false);
    vector<ll> wa(n, 0);

    rep(i, m){
        if(ac[p[i]-1] == false){
            if(s[i] == "AC") ac[p[i]-1] = true;
            else if(s[i] == "WA") wa[p[i]-1]++;
        }
    }

    ll a = 0, b = 0;
    rep(i, n){
        if(ac[i]){
            a++;
            b += wa[i];
        }
    }

    cout << a << " " << b << endl;



    return 0;
}

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

int main() {
  int A,B,K;
  cin >> K >> A >> B;
  for (int i=1 ; i<=B/K+1 ; i++){
    if(A<=K*i&&K*i<=B){
      cout << "OK" << endl;
      return 0;
    }
  }
    cout << "NG" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
int ddx[] = {-1,1,-1,1}, ddy[] = {1,1,-1,-1};
vector<ll> prime;
 
// int fac[MAX_N], inv[MAX_N];
 
// template <class T = ll> T in() {T x; cin >> x; return (x);}
// void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
// ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
// ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
// ll POW(ll a, ll b) {ll c = 1LL; while (b > 0) {if (b & 1LL) {c = a * c%mod;}a = a * a%mod; b >>= 1LL;}return c;}
// void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
// ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
// void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
// template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
// template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}


bool solve() {
	string c; cin >> c;
	string boin = "aiueo";
	bool ok = false;
	REP (i,5) {
		if (c[0] == boin[i]) ok = true;
	}
	if (ok) cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

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

	solve();
}

Measured memory_bytes: 256
N = gets.chomp.to_i
a = Array.new(N+1)
total = Array.new(N+1,0)
str = gets.split
for i in 1..N do
    a[i] = str[i-1].to_i
    total[i] = total[i-1] + a[i]
end

min = total[N]
for i in 1...N do
    dif = total[i] - (total[N] - total[i])
    dif = dif.abs
    if dif < min
        min = dif
    end
end

puts min

Measured memory_bytes: 17668
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int dp1[N],dp2[N];
char s[N];
int main()
{
    int n;
    cin>>n;
    cin>>(s+1);
    for(int i=1;i<=n;i++)dp1[i]=dp1[i-1]+(s[i]=='.');
    for(int i=n;i>=0;i--)dp2[i]=dp2[i+1]+(s[i]=='#');
    int ans=n;
    for(int i=0;i<=n;i++)ans=min(i-dp1[i]+(n-i)-dp2[i],ans);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x,k,d;
	cin>>x>>k>>d;
	if(x==0)
	{
		if(k%2==0)
		   cout<<0<<endl;
		else
		   cout<<d<<endl;
		exit(0);
	}
	if(x<0)
	{
		int p=-x/d;
		if(x%d!=0)
		   p++;
		if(p>k)
		{
			cout<<abs(x+k*d)<<endl;
		}
		else
		{
			int val1=x+p*d;
			int val2=x+(p-1)*d;
			int k1=k-p;
			int k2=k1+1;
			if(k1%2!=0)
			{
				val1-=d;
				val1=abs(val1);
			}
			if(k2%2!=0)
			{
				val2+=d;
				val2=abs(val2);
			}
			val1=abs(val1);
			val2=abs(val2);
			cout<<min(val1,val2)<<endl;
		}
	}
	else
	{
		x*=-1;
		int p=-x/d;
		if(x%d!=0)
		   p++;
		if(p>k)
		{
			cout<<abs(x+k*d)<<endl;
		}
		else
		{
			int val1=x+p*d;
			int val2=x+(p-1)*d;
			int k1=k-p;
			int k2=k1+1;
			if(k1%2!=0)
			{
				val1-=d;
				val1=abs(val1);
			}
			if(k2%2!=0)
			{
				val2+=d;
				val2=abs(val2);
			}
			val1=abs(val1);
			val2=abs(val2);
			cout<<min(val1,val2)<<endl;
		}
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int ChangeToNum(string str)
{
	int num= 0, digit= 1;
	for(int i= 0; i < str.length(); i++)
	{
		switch(str[i])
		{
		case 'm': m:
			num+= 1000*digit;
			digit= 1;
			break;
		case 'c': c:
			num+= 100*digit;
			digit= 1;
			break;
		case 'x': x:
			num+= 10*digit;
			digit= 1;
			break;
		case 'i': i:
			num+= digit;
			digit= 1;
			break;
		default:
			digit= str[i]-'0';
		}
	}
	return num;
}

void ChangeToStr(int num)
{
	char str[9]= {};
	int idx= 0, check= 0, div= 1000;
	char mcxi[4]= {'m', 'c', 'x', 'i'};

	while(check!=4)
	{
		if(num/div != 0)
		{
			if(num/div != 1)
				str[idx++]= num/div+'0';
			str[idx++]= mcxi[check];
		}
		num%= div;
		div/= 10;
		check++;
	}
	str[idx]= '\0';

	cout<<str<<endl;
}

int main(void)
{
	int num;
	cin>>num;

	for(int i= 0; i < num; i++)
	{
		string str1, str2;
		cin>>str1>>str2;

		ChangeToStr(ChangeToNum(str1)+ChangeToNum(str2));
	}
	return 0;
}

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

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

    set<int> tmp;  // お姉ちゃんが言った数字の種類列挙
    for (int i=0; i<N; ++i) {
        tmp.insert(A[i]);
    }

    map<int, int> res;  // お姉ちゃんが言った数字のmap初期化
    auto itr = tmp.begin();
    for (int i = 0; itr != tmp.end(); itr++, i++) {
        res.insert(make_pair(A[i], 0));
    }

    // お姉ちゃんが言った数字を数える
    for (int i=0; i<N; ++i) {
        ++res[A[i]];
    }

    int count = 0;
    for (auto itr = res.begin(); itr != res.end(); ++itr) {
        int s = itr->second;
        if (s % 2 != 0) ++count;
    }

    cout << count << endl;

}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define INF MAX/2
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int (i)=0; (i) < (n); ++(i))
#define FOR(i,a,b) for (int (i)=(a); (i) < (b); ++(i))
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b) {while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b) {return a * b / get_gcd(a, b);}
bool chmin(int &a, int b) {if(a>b){a=b; return true;} else return false;}
bool chmax(int &a, int b) {if(a<b){a=b; return true;} else return false;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

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

  int N;
  string S;
  cin >> N >> S;

  if (N%2==0) {
    bool flag = true;
    for (int i=0; i < N/2; i++) {
      if (S[i] != S[i+N/2]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b - a) & 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


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

int main(){
  	int N, A;
	cin >> N;
  	cin >> A;
  	int remain = N % 500;
  	if(remain <= A){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N,K,R,S,P;
    cin>>N>>K>>R>>S>>P;
    string T;
    cin>>T;
    int t[N];
    int v[3]={R,S,P};
    for (int i=0;i<N;i++){
        if(T[i]=='r')t[i]=2;
        if(T[i]=='s')t[i]=0;
        if(T[i]=='p')t[i]=1;
    }
    int d[N][3]{};
    for( int i=0;i<K;i++){
        d[i][t[i]]=v[t[i]];
        for(int j=i+K;j<N;j+=K){
            for(int k=0;k<3;k++){
                if(t[j]==k){
                    d[j][k]=max(d[j-K][(k+1)%3],d[j-K][(k+2)%3])+v[k];
                } else{
                    d[j][k]=max(d[j-K][(k+1)%3],d[j-K][(k+2)%3]);
                }
            }
        }
    }

    int ans=0;
    for(int i=1;i<=K;i++){
        ans+=max(d[N-i][0],max(d[N-i][1],d[N-i][2]));
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int main() {
    int N, M;
    int red[MAX_N];
    int ct[MAX_N];

    cin >> N >> M;
    rep(i, N) ct[i] = 1;
    rep(i, N) red[i] = 0;
    red[0] = 1;
    rep(i, M){
        int x, y;
        cin >> x >> y;
        x--; y--; // index adjustment

        if(red[x]==1) red[y]=1;
        ct[x]--;
        ct[y]++;
        if(ct[x]==0) red[x]=0;
    }

    int ret = 0;
    rep(i, N) ret += red[i];
    cout << ret << endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll a,v;
    ll b,w;
    ll t;
    cin >>a >> v;
    cin >> b >> w;
    cin >> t;

    if(v-w <= 0){
        cout << "NO" << endl;
        return 0;
    }

    ll dis = (v-w)*t;

    if(v-w>0){
        if(abs(a-b) <= dis){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int X;
    cin>>X;
    X/=200;
    cout<<10-X<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  string s; cin >> s;
  vector<char> sv;
  string ans = "yes";

  for (char x : s) sv.push_back(x);

  sort(sv.begin(), sv.end());
  for (int i = 0; i < sv.size(); i++) {
    if (sv[i + 1] == sv[i]) {
      ans = "no";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define fi first
#define se second
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n, k, divn;
int divsor[N], dp[N];

void calc(int x)    {
    for(int i = 1; i * i <= x; ++i) {
        if(x % i == 0)  {
            divsor[++divn] = i;
            if(i * i < x) divsor[++divn] = x/i;
        }
    }
    sort(divsor + 1, divsor + divn + 1);
}

int powe(int x, int y){
    if(!y) return 1ll;
    int mid = powe(x, y/2);
    if(y%2) return mid * mid % MOD * x % MOD;
    else return mid * mid % MOD;
}

signed main()
{
    //freopen("test.inp", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    calc(n);

    int ans = 0ll;
    FOR(i, 1, divn)  {
        int cur = divsor[i];
        dp[i] = powe(k, (cur + 1) / 2);

        for(int j = 1; j < i; ++j)  if(cur % divsor[j] == 0) {
            dp[i] = (dp[i] - dp[j] + 1ll * MOD * MOD) % MOD;
        }
        if(cur % 2) ans = (ans + 1ll * cur * dp[i]) % MOD;
        else ans = (ans + 1ll * cur / 2 * dp[i]) % MOD;
    }
    cout << ans;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [[s for s in input()] for i in range(H)]

def make_red_map():
    red_map = [row[:] for row in a]
    for i in range(0, H, 2):
        for j in range(W - 1):
            if red_map[i][j] == '.':
                red_map[i][j] = '#'

    for i in range(H):
        # 赤全体を連結させる
        red_map[i][0] = '#'

    for i in range(H):
        for j in range(W):
            print(red_map[i][j], end = "")
        print()

def make_blue_map():
    blue_map = [row[:] for row in a]
    for i in range(1, H, 2):
        for j in range(1, W):
            if blue_map[i][j] == '.':
                blue_map[i][j] = '#'

    for i in range(H):
        # 赤全体を連結させる
        blue_map[i][W - 1] = '#'

    for i in range(H):
        for j in range(W):
            print(blue_map[i][j], end = "")
        print()

make_red_map()
print()
make_blue_map()


Measured memory_bytes: 9076
N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13
dist = [INF] * (N + 1)
dist[1] = 0
for _ in range(N - 1):
    for a, b, c in egdes:
        dist[b] = min(dist[b], dist[a] - c)
ans = dist[N]
for a, b, c in egdes:
    dist[b] = min(dist[b], dist[a] - c)
print(-ans if ans == dist[N] else 'inf')

Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= b * 2)
  {
    cout << "0";
    return 0;
  }
  cout << a - b * 2;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void)
{
  int A, B, K;
  cin >> A >> B >> K;

  if (B > A) {
    swap(A, B);
  }

  vector<int> divs;

  for (int i = A; i >= 1; i--) {
    if (A % i == 0 && B % i == 0) {
      divs.push_back(i);
    }
  }

  cout << divs[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long Q, std::string S, std::vector<long long> l, std::vector<long long> r)
{
    vector<ll> start;
    for (ll i = 0; i < N - 1; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'C')
        {
            start.push_back(i + 1);
        }
    }
    SORT(start);
    for (ll i = 0; i < Q; i++)
    {
        ll left = l[i];
        ll right = r[i] - 1;
        if (left != right)
        {
            ll s = lower_bound(start.begin(), start.end(), left) - start.begin();
            ll end = upper_bound(start.begin(), start.end(), right) - start.begin();

            cout <<  end - s << endl;
        }
        else
        {
            if (find(start.begin(), start.end(), left) == start.end())
            {
                cout << 0 << endl;
            }
            else
            {
                cout << 1 << endl;
            }
        }
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long Q;
    scanf("%lld", &Q);
    std::string S;
    std::cin >> S;
    std::vector<long long> l(Q);
    std::vector<long long> r(Q);
    for (int i = 0; i < Q; i++)
    {
        scanf("%lld", &l[i]);
        scanf("%lld", &r[i]);
    }
    solve(N, Q, S, std::move(l), std::move(r));
    return 0;
}


Measured memory_bytes: 3192
n = int(input())
l = list(map(int, input().split(" ")))

arr_arr = []

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            arr = sorted([l[i], l[j], l[k]])
            if (arr[0] + arr[1] > arr[2]) and ((arr[0] != arr[1])and(arr[1] != arr[2])):
                arr_arr.append(arr)

print(len(arr_arr))

Measured memory_bytes: 28200
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n = scanner.nextInt();
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int[] p=new int[n];
		int f=0;
		int s=0;
		int t=0;
		for(int i=0;i<n;i++) {
			p[i]=scanner.nextInt();
			if(p[i]<=a) {
				f++;
			}else if(p[i]<=b) {
				s++;
			}else {
				t++;
			}
		}
		int min=Math.min(f, s);
		min=Math.min(min, t);
		System.out.println(min);
	}
}

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: 23252
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;

ll N, A, B, C, D;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> A >> B >> C >> D;

  ll X = B-A;
  N = N-1;

  ll mi = -D*N;
  ll ma = -C*N;
  for(int i=0; i<=N; i++) {
    if (mi <= X && X <= ma) {
      cout << "YES" << endl;
      return 0;
    }
    mi += D+C;
    ma += D+C;
    //cout << mi << ',' << ma << endl;
  }
  cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX=100000;
static const int INFTY=(1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s]=true;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        out.push_back(u);
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0&&!V[v]){
                V[v]=true;
                q.push(v);
            }
        }
    }
}
void tsort(){
    for(int i=0;i<N;i++) indeg[i]=0;
    for(int u=0;u<N;u++){  
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]++;
        }
    }
    for(int u=0;u<N;u++){
        if(indeg[u]==0 && !V[u])
            bfs(u);
    }
    for(list<int>::iterator it=out.begin();it!=out.end();it++)
        cout<<*it<<"\n";
}
int main(){
    int s,t,M;
    cin>>N>>M;
    for(int i=0;i<N;i++)V[i]=false;
    for(int i=0;i<M;i++){
        cin>>s>>t;
        G[s].push_back(t);
    }
    tsort();
    return 0;

}



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

int main() {
  int h, w, i, j;
  cin >> h >> w;
  
  vector<string> map(h + 2);
  
  string foo = "";
  for (j = 0; j < w + 2; j++) {
    foo += ".";
  }
  
  map.at(0) = foo;
  map.at(h+1) = foo;

  for (i = 0; i < h; i++) {
    cin >> map.at(i+1);
  	map.at(i+1) = "." + map.at(i+1) + ".";
  }
  
  for (i = 1; i < h + 1; i++) {
    for (j = 1; j < w + 1; j++) {
      if (map.at(i).at(j) == '.') {
        int total = (map.at(i-1).at(j-1) == '#' )
          + (map.at(i-1).at(j) == '#' )
          + (map.at(i-1).at(j+1) == '#' )
          + (map.at(i).at(j-1) == '#' )
          + (map.at(i).at(j+1) == '#' )
          + (map.at(i+1).at(j-1) == '#' )
          + (map.at(i+1).at(j) == '#' )
          + (map.at(i+1).at(j+1) == '#' );
        cout << total;
      }
      else {
        cout << "#";
      }
    }
    cout << endl;
  }
}

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

int n, k;
typedef  long long ll;
int main()
{
    cin >> n >> k;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++)
    {
        int t, d;
        cin >> t >> d;
        v.push_back({d, t});
    }
    sort(v.begin(), v.end(), greater<pair<int, int>>());
    map<int, bool> type;
    priority_queue<int, vector<int>, greater<int>> pq;
    long long base = 0;
    for (int i = 0; i < k; i++)
    {
        if (type.find(v[i].second) != type.end())
            pq.push(v[i].first);
        base += v[i].first;
        type[v[i].second] = true;
    }
    ll ans = base + 1ll * type.size() * type.size();
    for (int i = k; i < n && pq.size() != 0; i++) {
        if (type.find(v[i].second) == type.end()) {
            base -= pq.top();
            pq.pop();
            base += v[i].first;
            type[v[i].second] = true;
            ll t = base + 1ll * type.size() * type.size();
            if (ans < t) ans = t;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4084
var
  a:array[0..105] of longint;
  n,s,i,m,x,y:longint;
begin
  readln(n);
  s:=0;
  for i:=1 to n do
   begin
     read(a[i]);
     s:=s+a[i];
   end;
  readln;
  readln(m);
  for i:=1 to m do
   begin
     readln(x,y);
     writeln(s+y-a[x]);
   end;
end.

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll n; cin >> n;
  // for (ll k = 2; k <= n; ++k) {
  //   ll now = n;
  //   while (now > 0 && now % k == 0) now /= k;
  //   cout << k << ' ' << now % k << '\n';
  // }
  set<ll> ans;
  ll k = 2;
  for (; k * k <= n; ++k) {
    ll now = n;
    while (now > 0 && now % k == 0) now /= k;
    if (now % k == 1) ans.emplace(k);
    if (n % k == 1) ans.emplace((n - 1) / k);
  }
  if (n - 1 >= 2) ans.emplace(n - 1);
  ans.emplace(n);
  cout << ans.size() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a[30]={0},p,q,m=0,b=1;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p>>q;
        a[p]+=q;
    }
    for(int i=0;i<30;i++){
        if(m<a[i]){
            m=a[i];
            b=i;
        }
    }
    cout<<b<<" "<<m<<endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define forr(x,n) for(int x = 0; x < n; ++x)
#define pr pair<int,int>
#define ll long long int
const int mod=998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a[3][3],c[3][3];
    forr(i,3)
    forr(j,3)
    cin>>a[i][j];
    int n;
    cin>>n;
    int b[n];
    forr(i,n)
    cin>>b[i];
    forr(i,3)
    {
        forr(j,3)
        {
            c[i][j]=0;
            forr(k,n)
            if(a[i][j]==b[k])
            c[i][j]=1;
        }
    }
    string ans="No";
    forr(j,3)
    if(c[0][j]+c[1][j]+c[2][j]==3)
    ans="Yes";
    forr(i,3)
    if(c[i][0]+c[i][1]+c[i][2]==3)
    ans="Yes";
    if(c[0][0]+c[1][1]+c[2][2]==3)
    ans="Yes";
    if(c[0][2]+c[1][1]+c[2][0]==3)
    ans="Yes";
    cout<<ans;

}


Measured memory_bytes: 256