akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int n;

long long x[2];

long long a[maxn];

int read() {
  if (scanf("%d%lld%lld", &n, &x[0], &x[1]) < 3) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
  }
  return 1;
}

int last[2][maxn];

int dp[2][maxn];

void solve() {
  for (int it = 0; it < 2; ++it) {
    last[it][0] = -1;
    for (int i = 1; i < n; ++i) {
      last[it][i] = (a[i] - a[i - 1] < x[it]) ? i : last[it][i - 1];
    }
  }

  memset(dp, 0, sizeof(dp));
  dp[0][0] = dp[1][0] = 1;
  int res = 0;

  int npos[2] = {0, 0};
  for (int i = 0; i + 1 < n; ++i) {
    for (int type = 0; type < 2; ++type) {
      int cur = dp[type][i];
      if (!cur) {
        continue;
      }
      //eprintf("dp[%d][%d] = %d\n", type, i, cur);
      int &ni = npos[type];
      while (ni < n && a[ni] < a[i] + x[type]) {
        ++ni;
      }
      if (ni == i + 1) {
        add(dp[0][i + 1], cur);
        add(dp[1][i + 1], cur);
      } else {
        if (last[!type][ni - 1] <= i + 1) {
          add(dp[!type][ni - 1], cur);
        }
      }
    }
  }
  add(res, dp[0][n - 1]);
  add(res, dp[1][n - 1]);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int N, M, K;
    cin >> N >> M >> K;
    if( N<K && K<M)cout <<  "Yes"  << endl;
    else if(M<K && K<N) cout << "Yes" << endl;
    else cout << "No" <<endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

from fractions import gcd

mod = int(1e9 + 7)

lcm = 1
for x in A:
    lcm = lcm * x // gcd(lcm, x)
lcm %= mod

ans = 0
for x in A:
    ans += lcm * pow(x, mod - 2, mod)
    ans %= mod

print(ans)


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m), per(n);
    rep(i, m) cin >> a[i] >> b[i];
    rep(i, n) per[i] = i + 1;

    int ans = 0;
    do
    {
        if (per[0] != 1)
        {
            continue;
        }
        bool all_path = true;
        rep(i, n - 1)
        {
            bool ck = false;
            rep(j, m)
            {
                if ((per[i] == a[j] && per[i + 1] == b[j]) || (per[i + 1] == a[j] && per[i] == b[j]))
                {
                    ck = true;
                }
            }
            if (!ck)
            {
                all_path = false;
            }
        }
        if (all_path)
        {
            ans++;
        }
    } while (next_permutation(all(per)));

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


Measured memory_bytes: 3636
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B, C, X;

int main()
{
  scanf( "%d%d%d%d", &A, &B, &C, &X );

  int ans = 0;
  rep( a, A+1 ) rep( b, B+1 ) rep( c, C+1 )
  {
    if( 500*a+100*b+50*c == X )
      ++ans;
  }

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	ll ans;

	cin >> n;

	V a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cin >> c[i];
	}

	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));

	V bn(n), cn(n);
	ll num;
	rep(i, n) {
		auto itr = lower_bound(ALL(a), b[i]);
		num = itr - a.begin();
		if (i == 0) {
			bn[i] = num;
		}
		else {
			bn[i] = bn[i - 1] + num;
		}
	}

	rep(i, n) {
		auto itr = lower_bound(ALL(b), c[i]);
		num = itr - b.begin();
		if (num > 0) {
			cn[i] = bn[num - 1];
		}
	}

	ans = 0;
	rep(i, n) {
		ans += cn[i];
	}

	cout << ans << "\n";
}

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

	solve_abc_c();

	return 0;
}

Measured memory_bytes: 4224
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int>p(n),r(m);
	for (int i = 0; i < n; i++)cin >> p[i];
	for (int i = 0; i < m; i++)cin >> r[i];
	sort(p.begin(), p.end());
	sort(r.begin(), r.end());
	for (int i = -200; i <= 150; i++) {
		if (i > x&&i <= y) {
			if (i > p[n - 1] && i <= r[0]) {
				cout << "No War" << endl;
				return 0;
			}
		}
	}
	cout << "War" << endl;


	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(b<c || d<a){
		printf("0\n");
	}
	else if(c<=a && b<=d){
		printf("%d\n",b-a);
	}
	else if(a<=c && d<=b){
		printf("%d\n",d-c);
	}
	else if(a<=c && b<=d){
		printf("%d\n",b-c);
	}
	else if(c<=a && d<=b){
		printf("%d\n",d-a);
	}
	return 0;
}

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

using namespace std;

string s[200005], an[1000005];
map<string, int> mp;

int main(){
	int n, ans = 0, cnt = 0 ; cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> s[i];
		++mp[s[i]];
		ans = max(ans, mp[s[i]]);
	}
	for(int i = 1; i <= n; ++i)
		if(mp[s[i]] == ans){
			--mp[s[i]]; an[++cnt] = s[i];
		}
	sort(an + 1, an + 1 + cnt);
	for(int i = 1; i <= cnt; ++i)
		cout << an[i] << endl;
	return 0;
}


Measured memory_bytes: 34560
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct BIT
{
	int bit[SIZE];
	
	void init()
	{
		memset(bit,0,sizeof(bit));
	}
	void add(int k,int x)
	{
		while(k<SIZE)
		{
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int get(int k)
	{
		int ret=0;
		while(k>0)
		{
			ret+=bit[k];
			k-=k&-k;
		}
		return ret;
	}
	int get(int s,int t)
	{
		return get(t)-get(s-1);
	}
};
BIT bit;
int mp[3][SIZE];
int A[SIZE],B[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<n;j++)
		{
			int a;
			scanf("%d",&a);
			mp[i][j]=a;
		}
	}
	int S=0,T=0;
	for(int i=0;i<n;i++)
	{
		int a=min(mp[0][i],min(mp[1][i],mp[2][i]));
		int b=max(mp[0][i],max(mp[1][i],mp[2][i]));
		if(b-a!=2||a%3!=1)
		{
			puts("No");
			return 0;
		}
		A[i]=a/3;
		if(A[i]%2!=i%2||mp[1][i]!=(a+b)/2)
		{
			puts("No");
			return 0;
		}
		B[i]=(a==mp[0][i])?0:1;
		int zan=(abs(i-A[i])/2)%2;
		B[i]^=zan;
		//printf("%d %d\n",A[i],B[i]);
		if(i%2==0) S^=B[i];
		else T^=B[i];
	}
	for(int i=0;i<2;i++)
	{
		bit.init();
		ll sum=0;
		for(int j=i;j<n;j+=2)
		{
			sum+=bit.get(A[j]+2,n);
			bit.add(A[j]+1,1);
		}
		//printf("%lld\n",sum);
		if(i==0)
		{
			if(sum%2!=T)
			{
				puts("No");
				return 0;
			}
		}
		else
		{
			if(sum%2!=S)
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 10000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int compare_long(const void *a, const void *b) {
	return *(long*)a - *(long*)b;
}

int main() {
	long N;
	char s[100001];
	long i, j;
	long ans = INF;
	long tmp;
	long data[100001];
	long a[101];
	int l = 1, r = 2;
	int count[26] = {0};
	int len;
	
	scanf("%s", s);
	len = strlen(s);
	count[s[l-1] - 'a']++;
	count[s[r-1] - 'a']++;
	while(r <= len) {
		if(count[s[r-1] - 'a'] >= 2) {
			printf("%d %d\n", l, r);
			return 0;
		}
		if(r - l >= 2) {
			count[s[l-1] - 'a']--;
			l++;
		} else {
			r++;
			count[s[r-1] - 'a']++;
		}
	}
	
	printf("-1 -1\n");
	
	return 0;
}

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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    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 dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};









int main(){
  ll N;
  cin >> N;
  int ans = INF;
  for(ll i = 1; i * i <= N; i++){
    if(N % i == 0) {
      ll a = N / i;
      string x = to_string(i);
      string y = to_string(a);
      ans = min(ans, max((int)x.length(), (int)y.length()));
      if(x.length() == y.length()) break;
    }
  }

  print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  for(int i=0;i<2;i++){
  if(A>=B){
    ans+=A;
    A-=1;
  }
  else if(A<B){
    ans+=B;
    B-=1;
  }
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, K; cin >> N >> K;
	int cnt = 0, ans = 0;
	while (true) {
		cnt += K;
		ans++;
		if (N <= cnt) {
			cout << ans << endl;
			return 0;
		}
		cnt--;
	}
}

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

int main(){
    while(1){
    int x,y;
    cin >> x >> y;
    if(x==0 &&y==0)break;
    if(x>y){
        cout << y;
        cout << ' ';
        cout << x <<endl;
    }else{
        cout << x;
        cout << ' ';
        cout << y <<endl;
   }
}
}


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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}
	if (mas[r] == val)
		return r;
	if (mas[l] == val)
		return l;
	return -1;
}
template<typename T>
int UBS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}

	if (mas[l] >= val)
		return l;
	if (mas[r] >= val)
		return r;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

vector<ll> h;
ll m = LL_INF;
ll f(int l,int r){
	ll mn = LL_INF;
	for(int i = l; i <=r ; ++i){
		if(h[i] < mn)
			mn = h[i];
	}
	ll count = mn - m;
	for(int i =l; i <= r; ++i)
	{
		h[i] -= mn - m;
	}
	ll cur_l =  -1;
	ll cur_r = -1;
	if(h[l] != m){
		cur_l = l;
	}
	ll res = count;
	for(int i = l + 1; i <= r; ++i){
		if(cur_l == -1){
			if(h[i] > m)
				cur_l = i;
		}else{
			if(h[i]==m){
				cur_r = i - 1;
				res+= f(cur_l,cur_r);
				cur_l = -1;
				cur_r = -1;
			}
		}
	}
	if(cur_l != -1 && cur_r == -1)
		res+= f(cur_l,r);
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	int n;
	cin >> n;
	h.resize(n);
	for(int i = 0;i < n; ++i){
		cin >> h[i];
		if(h[i] < m)
			m = h[i];
	}
	cout << f(0,n -1) + m;


	return 0;
}

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

int main() {
    int K,S;
    cin >> K >> S;
    int ans = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int z = S-x-y;
            if (z >= 0 and z <= K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);



void solve(int T){
    int a,b;
    cin>>a>>b;
    b+=b;
    cout<<max(a-b,0)<<"\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3672
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, int K, vi &L){
	sort(allr(L));
	int sumL = 0;
	rp(i, 0, K){
		sumL += L[i];
	}
	return sumL;
}

int main(){
	int N,K; cin>>N>>K;
	vi L(N);
	rp(i, 0, N) cin>>L[i];
	ote(solve(N, K, L));
}


Measured memory_bytes: 256
import math

N=int(input())
P=[list(map(int,input().split())) for i in range(N)]

def div2(x,y):
    if x>0:
        return (1,y/x)
    elif x<0:
        return (-1,y/x)
    else:
        if y>0:
            return (-1,-float("inf"))
        else:
            return (1,-float("inf"))

P.sort(key=lambda x:div2(x[0],x[1]))

ANS=0

for i in range(N):
    for j in range(i,N):
        x0=y0=0
        x1=y1=0

        for k in range(N):
            if i<=k<=j:
                x0+=P[k][0]
                y0+=P[k][1]
            else:
                x1+=P[k][0]
                y1+=P[k][1]

        ANS=max(ANS,x0**2+y0**2,x1**2+y1**2)

print(math.sqrt(ANS))


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace std;
using lli = long long int;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (b % a == 0 ? a + b : b - a) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void);

int main(void){
    
    int time;
    int hour, minute, second;
    
    scanf("%d", &time);
    
    hour = time / 3600;
    minute = (time % 3600) / 60;
    second = (time % 3600) % 60;
    
    printf("%d:%d:%d\n",hour, minute, second);
    
    return 0;
}


Measured memory_bytes: 2100
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define N 1000000007
int sumit(int n,long long int *a){
	long long int suma=0;
	long long int ax1,ax2;
	for(int i=1; i<n; i++){
		suma+=(a[i]-a[i-1])*i*(n-i);
		suma%=N;
	}
	return suma;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	long long int sumx,sumy;
	long long int sum;
	long long int x[100005],y[100005];
	for(int i=0; i<n; i++){
		scanf("%lld",&x[i]);
	}
	for(int i=0; i<m; i++){
		scanf("%lld",&y[i]);
	}
	sumx=sumit(n,x);
	sumy=sumit(m,y);
	sum=sumx*sumy;
	sum%=N;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner

object Main extends App {
  val sc=new java.util.Scanner(System.in)
  val n,m = sc.nextInt()
  val A = (0 until n) map (_ => sc.nextInt())
  
  def solve(n : Int, m : Int, A : Seq[Int]) : String = {
    val popular = A.sum.toDouble / 4.0 / m
    if(A.count(s => s >= popular) >= m) "Yes"
    else "No"
  }

  println(solve(n,m,A))
}

Measured memory_bytes: 27320
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
string S;

/*
dream   dream
dream   erase
dreamer dream
dreamer erase
erase   dream
erase   erase
eraser  dream
eraser  erase

dream 無し
終

dream d
drea

dream er
ase
dre
era
終

erase 無し
終

erase d
ream

erase e
ras

erase r
era
dre
終

*/

bool check(string s, int p) {
    int c = (int)s.size();
    int i = 0;
    while (s[i] == S[p] && i < (int)s.size() && p < (int)S.size()) {
        p++;
        i++;
        c--;
    }
    if (c == 0) return true;
    return false;
}

int main(void) {
    cin >> S;
    int n = S.size();

    int i = 0;
    while (i < n) {
        if(check("dream", i)) {
            i += 5;
            if (check("er", i)) {
                i += 2;
                if (check("a", i)) {
                  i -= 2;
                }
            }
        } else if (check("erase", i)) {
          i += 5;
            if (check("r", i)) {
              i += 1;
            }
        } else {
            puts("NO");
            return 0;
        }

    }
  
    puts("YES");

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=51;
const int mod=1e9+7;
int n,m,q,fac[N<<2],ifac[N<<2];

namespace utils{
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

template <class T>
inline int fpow(int x,T t){
	int ans=1;
	for(; t; x=(lint)x*x%mod,t>>=1){
		if(t&1) ans=(lint)ans*x%mod;
	}
	return ans;
}

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

inline void init_C(){
	const int N=::N<<2;
	fac[0]=1;
	for(int i=1; i<N; ++i){
		fac[i]=(lint)fac[i-1]*i%mod;
	}
	ifac[N-1]=fpow(fac[N-1],mod-2);
	for(int i=N-1; i; --i){
		ifac[i-1]=(lint)ifac[i]*i%mod;
	}
}

inline int C(const int x,const int y){
	assert(x<201);
	if(x<y) return 0;
	return (lint)fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}

int polya(const int x){
	lint ans=0;
	for(int i=1; i<=x; ++i){
		ans+=fpow(q,gcd(x,i));
	}
	ans%=mod;
	return (lint)ans*fpow(x,mod-2)%mod;
}

namespace G{
	int cnt,ans=1,cscc,con_e,fir[N],bel[N],dfn[N];
	struct edge{
		int to,nx;
	}eg[N<<2];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void tarjan(const int x,const int fa){
		static int cnd,top,low[N],stk[N];
		stk[++top]=x;
		dfn[x]=low[x]=++cnd;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			if(y==fa) continue;
			if(dfn[y]){
				apn(low[x],dfn[y]);
				continue;
			}
			tarjan(y,x);
			if(low[y]<dfn[x]){
				apn(low[x],low[y]);
				continue;
			}
			++cscc;
			int cnt_p=1,cnt_e=0;
			for(int i=top; stk[i]!=x; --i){
				bel[stk[i]]=cscc;
			}
			bel[x]=cscc;
			//printf("%d ",x);
			for(int j=stk[top--]; ; j=stk[top--]){
				//printf("%d ",j);
				++cnt_p;
				for(int k=fir[j]; k; k=eg[k].nx){
					int l=eg[k].to;
					//printf("%d->%d: %d\n",j,l,(l>j||l==x)&&bel[l]==bel[j]);
					cnt_e+=(l>j||l==x)&&bel[l]==bel[j];
				}
				if(j==y) break;
			}
			/*
			puts("");
			printf("cnt_p: %d,cnt_e: %d\n",cnt_p,cnt_e);
			*/
			if(cnt_p>cnt_e){
				assert(cnt_e<=1);
				ans=(lint)ans*fpow(q,cnt_e)%mod;
			}
			else if(cnt_p==cnt_e){
				ans=(lint)ans*polya(cnt_e)%mod;
			}
			else if(cnt_p<cnt_e){
				ans=(lint)ans*C(cnt_e+q-1,q-1)%mod;
			}
			else assert(0);
			bel[x]=0;
			//puts("---");
		}
	}
}

int main(){
	n=nxi(),m=nxi(),q=nxi();
	init_C();
	for(int i=1; i<=m; ++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
		G::add(b,a);
	}
	for(int i=1; i<=n; ++i){
		if(!G::dfn[i]) G::tarjan(i,0);
	}
	printf("%d\n",G::ans);
	return 0;
}


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

using namespace std;
struct CinInit
{
    CinInit()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} CinInit;

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

    printf("%s\n", (a <= c && c <= b) || (b <= c && c <= a) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int D=Integer.parseInt(sc.next());
int N=Integer.parseInt(sc.next());
    switch (D) {
        case 0:
            if(N!=100){System.out.println(N);}else{System.out.println(101);}
            break;
        case 1:
            {
                int i=0,count=0;
                while(true){i++;
                if(i%100==0&&i%10000!=0&&i%1000000!=0)count++;
                if(count==N){System.out.println(i);break;}
                }               break;
            }
        default:
            {
                int i=0,count=0;
                while(true){i++;
                if(i%10000==0&&i%1000000!=0)count++;
                if(count==N){System.out.println(i);break;}
                }               break;
            }
    }


}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    if (s.size()%2==1){
        cout<<"No\n";
        return 0;
    }
    for (ll i=0;i<s.size();i++){
        if (!((i%2==0&&s[i]=='h')||(i%2==1&&s[i]=='i'))){
            cout<<"No\n";
            return 0;

        }
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int n;
   cin>>n;
   int a[n];
   unordered_map<int,int> m;
   for(int i=0;i<n;i++){
    cin>>a[i];
   }
   int allgcd=a[0];
   for(int i=1;i<n;i++){
    allgcd=__gcd(a[i],allgcd);
   }
   const int N=1000001;
   vector<char> is_prime(N+1, true);
   is_prime[0] = is_prime[1] = false;
   for (int i = 2; i <= N; i++) {
    if (is_prime[i] && (long long)i * i <= N) {
        for (int j = i * i; j <= N; j += i)
            is_prime[j] = false;
    }
   }
   vector<int> c;
   for(int i=0;i<=N;i++){
       if(is_prime[i]){
           c.emplace_back(i);
       }
   }
  int g=1;
   for(int i=0;i<n;i++){
       int l=a[i];
       if(is_prime[l]){
           m[l]++;
           if(m[l]>1){
           	 g=0;
           	 i=n;
           }
       }else{
      for(int j=0;j<(int)c.size();j++){
          if(is_prime[l]){
              m[l]++;
              if(m[l]>1){
              	g=0;
              	i=n;
              }
              break;
          }
        if(l%c[j]==0){
          m[c[j]]++;
          if(m[c[j]]>1){
          	g=0;
          	i=n;
          	break;
          }
          while(l%c[j]==0){
               l=l/c[j];
          }
        }
        if(l<c[j]){
            break;
        }
      }
       }
   }
   
   if(g){
    cout<<"pairwise coprime"<<"\n";
    return 0;
   }
   if(allgcd==1){
      cout<<"setwise coprime"<<"\n";
      return 0;
   }
   cout<<"not coprime"<<"\n";
   return 0;


   
}


Measured memory_bytes: 8748
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	ll n,k;
	cin>>n>>k;
   ll h[n],dp[n]={0};
   for(i=1;i<n;i++)
   dp[i]=1e17;
	for(i=0;i<n;i++)
	cin>>h[i];
	for(i=1;i<n;i++)
	{
		for(j=i-1;j>=max(0ll,i-k);j--)
		dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	cout<<dp[n-1];
	cout<<"\n"; 
 } 
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  scanf("%d",&n);
  double p = 0, d;
  for(int i =  0; i < n; i++){
    cin >> d;
    p += 1.0/d;
  }
  printf("%.10lf\n",1.0/p);
}

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

numberdict = dict()
for i in range(N):
    A_i = int(input())
    if A_i in numberdict:
        numberdict[A_i] += 1
    else:
        numberdict[A_i] = 1
ans = 0
for j in numberdict.keys():
    if numberdict[j] % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 15076
var fs = require('fs');

// class Stdin
function Stdin() {
  this.__input = null;
  this.__lines = [];
  this.__index = 0;
}
Stdin.prototype.init = function() {
  this.__input = fs.readFileSync('/dev/stdin', 'utf-8');
  this.__lines = this.__input.split("\n");
  this.__index = 0;
}
Stdin.prototype.readline = function() {
  if(this.__index === this.__lines.length) this.init();
  return this.__lines[this.__index++];
};
Stdin.prototype.readlines = function() {
  if(this.__index === this.__lines.length) this.init();
  cur = this.__index; this.__index = this.__lines.length;
  return this.__lines.slice(cur);
};
var stdin = new Stdin;

Array.prototype.imap = function() { return this.map((x)=>parseInt(x)); }
Array.prototype.fmap = function() { return this.map((x)=>parseFloat(x)); }
Array.prototype.smap = function() { return this.map((x)=>String(x)); }
Array.prototype.ffill = function(cb) {
  for(var i=0; i<this.length; ++i) { this[i] = cb(i); } return this;
}
Array.prototype.max = function(cb) {
  if(this.length === 0) return undefined;
  res = cb ? cb(this[0], 0) : this[0];
  for(var i=1; i<this.length; ++i){ var val = cb ? cb(this[i], i) : this[i]; if(res < val) res = val; }
  return res;
}
Array.prototype.min = function(cb) {
  if(this.length === 0) return undefined;
  res = cb ? cb(this[0], 0) : this[0];
  for(var i=1; i<this.length; ++i){ var val = cb ? cb(this[i], i) : this[i]; if(val < res) res = val; }
  return res;
}
Array.prototype.sum = function(cb) {
  if(this.length === 0) return undefined;
  res = cb ? cb(this[0], 0) : this[0];
  for(var i=1; i<this.length; ++i) res += cb ? cb(this[i], i) : this[i];
  return res;
}

Number.prototype.times = function(cb) { res = []; for(var i=0; i<this; ++i) res.push(cb ? cb(i) : i); return res; }

Object.prototype.forEach = function(cb) { Object.keys(this).forEach(cb); }
Object.prototype.map = function(cb) { Object.keys(this).map(cb); }

console.log((5).times(x=>stdin.readline()).imap().sum(x=>x<40?40:x)/5);

Measured memory_bytes: 15192
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int h,w,k;
    cin>>h>>w>>k;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    int ans = 0;
    for(int r=0;r<(1<<h);r++){
        string t[h];

        for(int c=0;c<(1<<w);c++){
            for(int i=0;i<h;i++)t[i] = s[i];
            for(int i=0;i<h;i++){
                if((1<<i) & r){
                    for(int j=0;j<w;j++)t[i][j] = ',';
                }
            }
            for(int i=0;i<w;i++){
                if((1<<i) & c){
                    for(int j=0;j<h;j++) t[j][i] = ',';
                }
            }
            int cnt = 0;
            for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(t[i][j] == '#')cnt++;
            if(cnt == k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    
    int d, t, s;
    cin >> d >> t >> s;

    if(t * s < d){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;

}

Measured memory_bytes: 3632
x,y=map(int, input().split())
coin=0
if x==1 and y==1:
  coin+=400000
if x==1:
  coin+=300000
if y==1:
  coin+=300000
if x==2:
  coin+=200000
if y==2:
  coin+=200000
if x==3:
  coin+=100000
if y==3:
  coin+=100000
print(coin)


Measured memory_bytes: 9080
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
s = input()
mod = 1000000007
a = 0
mae = 0
usi = s.count("?")
c = s.count("C")
ans = 0
for i in range(len(s)):
  if s[i] == "B":
    ans += (a*c*(power_func(3,usi+mae,mod)))%mod+(mae*c*(power_func(3,usi+mae-1,mod)))%mod+(usi*a*(power_func(3,usi+mae-1,mod)))%mod+(usi*mae*(power_func(3,usi+mae-2,mod)))%mod
  if s[i] == "?":
    usi -= 1
    ans += (a*c*(power_func(3,usi+mae,mod)))%mod+(mae*c*(power_func(3,usi+mae-1,mod)))%mod+(usi*a*(power_func(3,usi+mae-1,mod)))%mod+(usi*mae*(power_func(3,usi+mae-2,mod)))%mod
    mae +=1
  if s[i] == "A":
    a +=1
  if s[i] == "C":
    c -=1
print(int(ans%mod))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;



int main(){
    ll N, K; cin >> N >> K;
    ll SUM1 = 0, SUM2 = 0;
    for(int i = 0; i < K-1; i++) SUM1 += i;
    for(int i = 0; i < K-1; i++) SUM2 += N-i;
    ll ans = 0;
    for(int i = K-1; i <= N; i++){
        SUM1 += i;
        SUM2 += N-i;
        ans += SUM2-SUM1+1;
        ans %= MOD;
        //cout << SUM1 << " " << SUM2 << endl;
    }
    cout << ans << endl;



}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int sum, i, box=0;;
	char s[101] ;
	char *p;
	scanf("%s", &s);
	p = s;
	sum = strlen(p);
	for (i = 0; i < sum/2; i++)
	{
		if (*(p+i) != *((p+sum-1)-i))
			box++;
	}
	printf("%d", box);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String a=sc.next();
    String b=sc.next();
    String c=sc.next();
    int a1=Integer.parseInt(a);
    int b1=Integer.parseInt(b);
    int c1=Integer.parseInt(c);
    int max=0;

    int ab=Integer.parseInt(a+b);
    max=Math.max(max,ab+c1);
    int ba=Integer.parseInt(b+a);
    max=Math.max(max,ba+c1);
    int ac=Integer.parseInt(a+c);
    max=Math.max(max,ac+b1);
    int ca=Integer.parseInt(c+a);
    max=Math.max(max,ca+b1);
    int bc=Integer.parseInt(b+c);
    max=Math.max(max,bc+a1);
    int cb=Integer.parseInt(c+b);
    max=Math.max(max,cb+a1);


    System.out.println(max);



  }
}


Measured memory_bytes: 21716
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll A[N]; F0R(i, N) cin >> A[i];
    F0R(i, N) {
        if (A[i] == 0) {
            cout << 0 << nl; return 0;
        }
    }
    ld L = 0;
    F0R(i, N) {
        L += log10(A[i]);
    }
    if (L > 18.1) {
        cout << -1 << nl; return 0;
    }
    ll ans = 1; F0R(i, N) ans *= A[i];
    if (ans > 1000000000000000000) {
        cout << -1 << nl; return 0;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 4720
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()


if M == 1:
  print(0)
  exit()

interval = [0] * (M - 1)
for i in range(M-1):
  interval[i] = X[i+1] - X[i]
  
interval.sort()
ans = 0
for i in range(len(interval) - (N-1)):
  ans += interval[i]
  
print(ans)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define loop(i, a, n) for(ll i = (a); i < (n); i++)
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

int main(){
    ll n; cin >> n;
    map<ll, ll> a;
    ll sum = 0;
    rep(i, n) {
        ll tmp; cin >> tmp;
        a[tmp]++;
        sum += tmp;
    }
    ll q; cin >> q;
    rep(i, q) {
        ll b, c; cin >> b >> c;
        a[c] += a[b];
        sum -= b*a[b];
        sum += c*a[b];
        a[b] = 0;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 9516
import sys
import itertools

def main():
	
    # sys.stdin = open('input150c.txt')
	
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))

    permutations = list(itertools.permutations(range(1, n+1)))

    a = permutations.index(p)
    b = permutations.index(q)

    print(abs(a - b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8052
#include<stdio.h>
int main(){
  char a[11],b[11],c[11];
  int x,y;
  scanf("%s%s%s",a,b,c);
  for(x=0;a[x];x++);for(y=0;b[y];y++);
  printf("%s",a[x-1]==b[0]&&b[y-1]==c[0]?"YES":"NO");
}


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

using namespace std;

int main()
{
  long n;
  cin >> n;
  //vector<string>vec;
  int arr[4] = {0,0,0,0};
  for(int i=0;i<n;i++)
  {
    string str;
    cin >> str;
    if(str == "AC")
      arr[0]++;
    else if(str == "WA")
      arr[1]++;
    else if(str == "TLE")
      arr[2]++;
    else
      arr[3]++;
  }
  cout << "AC x " << arr[0] << endl;
  cout << "WA x " << arr[1] << endl;
  cout << "TLE x " << arr[2] << endl;
  cout << "RE x " << arr[3] << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e4 + 9;
ll freq[N];

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n, k;
	string str;
	cin >> n >> k;
	cin >> str;
  if(k==2 || k==5){
      ll ans = 0 ;
      for(int i=0;i<n;++i)
      	if((str[i]-'0')%k == 0) ans += i+1 ;
      cout << ans;
      return 0;
  }
	reverse(str.begin(), str.end());
	ll prv = 0, tmp = 1;
	freq[0]++;
	for (int i = 0; i < n; ++i) {
		prv += (str[i] - '0') * tmp;
		prv %= k;
		freq[prv]++;
		tmp *= 10;
		tmp %= k;
	}
	ll ans = 0;
	for (int i = 0; i < k; ++i)
		ans += (ll)freq[i] * (freq[i] - 1) / 2;
	cout << ans;
	return 0;
}


Measured memory_bytes: 720
#include <iostream>

using namespace std;

int main(){

    int a, b, max;
    cin >> a >> b;

    max = a + b;
    if(max < (a - b)){
        max = a - b;
    }
    if(max < (a * b)){
        max = a * b;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,k,d;
int main()
{
	cin>>x>>k>>d;
	if(x<0) x=-x;
	if(k<=x/d) cout<<x-k*d;
	else
	{
		if((k-x/d)%2==0)
		cout<<abs(x-(x/d)*d);
		else
		cout<<abs(x-(x/d+1)*d); 
	}
	return 0;
}

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

using namespace std;

int N, Q;
string s;

int main() {
	cin >> N >> Q;
	cin >> s;
	vector<int> sum(N);
	sum[0] = 0;
	for (int i = 1; i < N; i++) {
		if (s[i - 1] == 'A' && s[i] == 'C')sum[i] = sum[i - 1] + 1;
		else { sum[i] = sum[i - 1]; }
	}

	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		r--;
		cout << sum[r] - sum[l - 1] << endl;
	}
}

Measured memory_bytes: 1408
#include <stdio.h>

int main() {
  int a,b,x = 0;
  int c;

  scanf("%d %d %d", &a,&b,&x);

    if(a+b >= x && x >= a){
      printf("YES");
    } else {
      printf("NO");
    }

  // if(flag == 1){
  // } else {
  //   printf("NO");
  // }

  return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N, K, x, sum int
	fmt.Scan(&N, &K)
	for i := 0; i < N; i++ {
		fmt.Scan(&x)
		sum += Min(x, K-x) * 2
	}
	fmt.Println(sum)
}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<time.h>
#include<string>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define int long long
#define double long double
using namespace std;
#define PI  3.1415926535898
#define eqs 1e-17
const long long max_ = 5e5 + 7;
const int mod = 998244355;
const int inf = 1e9 + 7;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline void write(int x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
int f[max_][12], sum[max_],k;
void dfs(int num, int wei,int now) {
	for (int i = now - 1; i <= now + 1; i++) {
		if (i >= 0 && i <= 9) {
			if (num <= f[wei - 1][i]) {
				cout << i;
				dfs(num, wei - 1, i); break;
			}else num -= f[wei - 1][i];
		}
	}
	/*for (int i = 0; i <= 9; i++) {
		if (num <= f[wei][i]) {
			cout << i;
			dfs(num, wei - 1, i);
			
			break;
		}
		else num -= f[wei][i];
	}*/
}
signed main() {
	for (int i = 0; i <= 9; i++) { f[1][i] = 1; }
	sum[1] = 9;
	for (int i = 2; i <= 12; i++) {//位数
		for (int j = 0; j <= 9; j++) {
			f[i][j] = f[i - 1][j];
			if (j + 1 <= 9)
				f[i][j] += f[i - 1][j + 1];
			if (j - 1 >= 0)
				f[i][j] += f[i - 1][j - 1];
		}
		int v = 0;
		for (int j = 1; j <= 9; j++)v += f[i][j];
		sum[i] = sum[i - 1];
		sum[i] += v;
	}
	k = read();
	int weishu = 0;
	for (int i = 1; i <= 12; i++) {
		if (sum[i] >= k && sum[i - 1] < k) {
			weishu = i; break;
		}
	}
	k -= sum[weishu - 1];
	int first = 0;
	for (int i = 1; i <= 9; i++) {
		if (k <= f[weishu][i]) {
			first = i; break;
		}
		else k -= f[weishu][i];
	}
	cout << first;
	dfs(k, weishu , first);
	return 0;
}

Measured memory_bytes: 2432
k=int(input())
print(50)
if k==0:
  for i in range(50):
    print(49-i,end=" ")
    print()
else:
  a=(k-1)//50
  b=k%50
  if b==0:
    for i in range(50):
      print(50+a-i)
      print()
  else:
    for i in range(50):
      b=b-1
      if b>=0:
        print(50+a-i)
      else:
        print(50+a-i-1)
      if i==49:
        print()


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int n;
    cin >> n;
    cout << 48 - n << endl;
    return 0;
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> K(M);
    vector<int> S(M * N + 10, 0);
    for(int i = 0; i < M; i++){
        cin >> K[i];
        
        for(int j = M * i; j < M * i + K[i]; j++){
            cin >> S[j];
        }
    }
    vector<int> p(M);
    for(int i = 0; i < M; i++){
        cin >> p[i];
    }
    
    int ans = 0;
    
    for(int i = 1; i <= (1 << N); i++){
        bool flag = true;
        
        for(int j = 0; j < M; j++){
            int cnt = 0;
            
            for(int k = M * j; k < M * j + K[j]; k++){
                if((1<<(S[k]-1)) & i)   cnt++;
            }
            
            if(cnt % 2 != p[j]){
                flag = false;
                break;
            }
        }
        
        if(flag)        ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;
int A[MAX_N], N;

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

int work() {
  int even = 0, odd = 0;
  for (int i = 1; i <= N; ++i)
    if (A[i] & 1) odd++;
    else even++;
  if (even & 1)
    return 1;
  else if (!(even & 1) && odd > 1) 
    return 0;
  else {
    for (int i = 1; i <= N; ++i)
      if (A[i] & 1) {
	if (A[i] == 1) return 0;
	A[i]--;
	break;
      }
    int g = A[1];
    for (int i = 2; i <= N; ++i)
      g = gcd(g, A[i]);
    for (int i = 1; i <= N; ++i)
      A[i] /= g;
    return work() ^ 1;
  }
}

int main() {


  int T = 1;
  //scanf("%d", &T);
  
  while (T--) {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i)
      scanf("%d", &A[i]);
    bool flag = work();
    if (flag)
      puts("First");
    else
      puts("Second");
  }
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
  
  int n;
  cin>>n;
  vector<int> v(n);
  int f=0;
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
    
  }
  
  for(int i=0;i<n;i++)
  {
  	if(v[i]%2==0)
    {
      if(v[i]%3!=0 && v[i]%5!=0)
      {
        cout<<"DENIED";
        f=1;
        break;
      }
    }
    if(f==1)
      break;
  }
  if(f==0)
    cout<<"APPROVED";
  return 0;
}

Measured memory_bytes: 384
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h,w,a,b = readInts()
for _ in range(b):
    print('0' * a + '1' * (w-a))
for _ in range(h-b):
    print('1' * a + '0' * (w-a))


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, string>> p(m);
    bool flg[n];
    rep(i, n) flg[i] = true;
    rep(i, m) cin >> p[i].first >> p[i].second;
    int cor, wro = 0;
    vector<int> correct;

    int tmp[n] = {0};
    rep(i, m)
    {
        if (p[i].second == "WA" && flg[p[i].first - 1])
            tmp[p[i].first - 1]++;
        else if (p[i].second == "AC")
        {
            if (flg[p[i].first - 1])
                wro += tmp[p[i].first - 1];
            flg[p[i].first - 1] = false;
        }
    }

    rep(i, m) if (p[i].second == "AC") correct.push_back(p[i].first);
    sort(correct.begin(), correct.end());
    correct.erase(unique(correct.begin(), correct.end()), correct.end());
    cor = correct.size();

    cout << cor << ' ' << wro << endl;

    return 0;
}

Measured memory_bytes: 7676