akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
 
template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(const vector<T> &v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) の和を取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
};

int main(){
  int n=0,q=0;
  cin >> n >> q;
  auto f = [](int a, int b){return a + b;};
  SegmentTree<int> sg(n, f, 0);
  
  rep(i,q){
    int com = 0, x = 0, y = 0;
    cin >> com >> x >> y;
    if(com == 0){
      sg.update(x-1, sg.get(x-1) + y); //更新
    }
    else{
      cout << sg.query(x-1, y) << endl; //[x-1,y)を出力
    }
  }
}


Measured memory_bytes: 3892
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#define INF 0X3F3F3F3F
#define LL long long
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define FF(i,a,b) for(int i=a; i<=b; i++)
#define RR(i,a,b) for(int i=a; i>=b; i--)
#define FC(i,a,b) for(int i=a; i<b; i++)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define PRR(x,y) printf("%d%d\n",x,y)
#define CL(a,x) memset(a,x,sizeof(a))
#define MID int mid=((l+r)>>1)
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
#define _X sum[x]
#define _L sum[x<<1]
#define _R sum[x<<1|1]
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define MAIN 10000010
#define MAXN 50010
using namespace std;
int n,m,a[MAXN];
map <int,int> mm;
int main()
{
    mm.clear();
    SC(n);
    FF(i,1,n)
    {
        SC(m);
        mm[m]++;
    }
    map <int,int>::iterator it;
    int f1=-1,f2=-1;
    for(it=mm.end();it!=mm.begin(); it--)
    {
        if(it->second>1)
        {
            if(f1==-1) f1=it->first,it->second-=2;
        }
        if(it->second>1)
        {
            if(f2==-1) f2=it->first,it->second-=2;
        }
        if(f1!=-1&&f2!=-1) break;
    }
    it=mm.begin();
    if(it->second>1)
    {
        if(f1==-1) f1=it->first,it->second-=2;
    }
    if(it->second>1)
    {
        if(f2==-1) f2=it->first,it->second-=2;
    }
    if(f1==-1||f2==-1) printf("0\n");
    else
    {
        LL ans=(LL)f1*(LL)f2;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N,M;
	long long int X[1000] ,Y[1000],Z[1000] = { 0 };
	long long int max = 0;
	cin >> N >>M;
	for (int i=0; i < N;i++) {
		cin >> X[i] >> Y[i] >>Z[i];
	}

	for (int x = 0;x < 2;x++) {
		for (int y = 0;y < 2;y++) {
			for (int z = 0;z < 2;z++) {
				long long int v[1000] = { 0 };
				for (int i = 0;i < N;i++) {
					if (x == 0)
						v[i] += X[i];
					else
						v[i] -= X[i];
					if (y == 0)
						v[i] += Y[i];
					else
						v[i] -= Y[i];
					if (z == 0)
						v[i] += Z[i];
					else
						v[i] -= Z[i];
				}
				sort(v, v + N);
				long long int val=0;
				for (int i = 0;i < M;i++)
					val += v[N - 1 - i];
				if (x == 0 && y == 0 && z == 0)
					max = val;
				else if (val > max)
					max = val;
			}
		}
	}

	cout << max << endl;
	return 0;
}


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

int main(){
	int r, c, i, j;
	int n ,s;
	int w=0;

	cin >> r >> c;

	int a[r][c];

	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
		cin >> a[i][j];
		}
	}

	for(i=0; i<r; i++){
		n=0;
		for(j=0; j<c; j++){
			n = n + a[i][j];
			cout << a[i][j] << " ";
		}
		cout << n << endl;;
	}

	for(j=0; j<c; j++){
		s=0;
		for(i=0; i<r; i++){
			s = s + a[i][j];
		}
		w = w + s;
		cout << s <<" ";
	}

	cout << w << endl;

}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    auto f = [&MOD](auto& a, auto k){(a.second += (a.first += a.second * k) %= MOD) %= MOD; return a.first;};
    unsigned long N;
    cin >> N;
    vector<pair<pair<unsigned long, unsigned long>, unsigned long>> tapi(1048576, {{1, 0}, 0});
    unsigned long ans{0}, t{500000004}, a{0}, z{0}, A;
    while(cin >> A)
        if(a ^= A){
            ans += f(tapi[a].first, z - tapi[a].second);
            tapi[a].second = z;
        }else ++z, (t *= 2) %= MOD;
    cout << (a ? tapi[a].first.first : (ans + t) % MOD) << endl;
    return 0;
}

Measured memory_bytes: 24832
import java.util.Scanner;

public class Main {
    public static int s[];
    public static int n;
    public static int count = 0;
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        s = new int[n];
        int right = n - 1;
        for(int i = 0; i < n; i++){
            s[i] = scan.nextInt();
        }
        int q = scan.nextInt();
        for(int i = 0; i < q; i++){
            int m = scan.nextInt();
            solve(m, right, 0);
        }

        System.out.println(count);
        scan.close();
    }

    public static void solve(int key, int right, int left){
        int m = (left + right) / 2;
        while(left <= right) {
            if (s[m] == key) {
                count = count + 1;
                return;
            } else if (s[m] > key) {
                right = m - 1;
            } else {
                 left = m + 1;
            }
            m = (left + right) / 2;
        }
    }
}


Measured memory_bytes: 80680
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

struct UnionFind{
  VI par;
  VI siz;
  UnionFind(int N):par(N),siz(N){
    rep(i,N){
      par[i]=i;
      siz[i]=1;
    }
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
    siz[ry]=siz[rx]+siz[ry];
  }
  int size(int x){
    return siz[root(x)];
  }
  bool same(int x, int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};

int main(){
  int N,K,L;
  cin>>N>>K>>L;
  VI P(K),Q(K);
  rep(i,K) cin>>P[i]>>Q[i];
  VI R(L),S(L);
  rep(i,L) cin>>R[i]>>S[i];
  UnionFind uf1(N),uf2(N);
  rep(i,K) uf1.unite(P[i]-1,Q[i]-1);
  rep(i,L) uf2.unite(R[i]-1,S[i]-1);
  map<PII,int> X;
  rep(i,N) X[mp(uf1.root(i),uf2.root(i))]++;
  rep(i,N) cout<<X[mp(uf1.root(i),uf2.root(i))]<<" ";
  cout<<endl;
}

Measured memory_bytes: 16640
import math
from decimal import Decimal
N, K = [int(item) for item in input().split()]
b = 0
for i in range(1, N+1):
  tmp = i
  cnt = 0
  while tmp < K:
    tmp *= 2
    cnt += 1
  if i == 1:
    a = (N * 2 ** cnt)
  b += (a / (N * 2 ** cnt))
print(Decimal(b/ a))

Measured memory_bytes: 5588
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


bool check(vector<long long> &A, long long n, long long K) {
  long long N = A.size();
  vector<long long> s(N);
  vector<long long> p(N);
  vector<long long> cs(N);
  vector<long long> cp(N);

  for (int i = 0; i < N; i++) {
    s[i] = A[i] - (A[i]/n)*n;
    p[i] = (A[i]/n + 1)*n - A[i];
  }

  sort(s.begin(), s.end());
  sort(p.begin(), p.end());

  cs[0] = s[0];
  cp[0] = p[0];
  for (int i = 1; i < N; i++) {
    cs[i] = cs[i-1] + s[i];
    cp[i] = cp[i-1] + p[i];
  }

  for (int i = 0; i < N-1; i++) {
    if (cs[i] == cp[N-2-i]) {
      return K >= cs[i];
    } else if(cs[i] > cp[N-2-i]) {
      return false;
    }
  }
}


void solve(long long N, long long K, std::vector<long long> A){
  long long s = accumulate(A.begin(), A.end(), 0LL);
  multiset<long long> m;
  long long i = 1;
  while (i*i <= s) {
    if ((s%i)==0) {
      m.insert(i);
      m.insert(s/i);
    }
    i++;
  }
  auto itr = m.end();
  itr--;
  while (itr != m.begin()) {
    if (check(A, *itr, K)) {
      std::cout << *itr << std::endl;
      return;
    }
    itr--;
  }
  std::cout << 1 << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main ()
{
    int n,i;
    scanf("%d",&n);
    long long int a[n+3];
    for(i=0; i<n; i++)
        scanf("%lld",&a[i]);
    int zero =0;
    for(i=0; i<n; i++)
        if(a[i]==0)
                zero ++;
    if(zero >0)
    {
        printf("0\n");
        return 0;
    }
    long long prod =1;
    for(i=0; i<n; i++)
    {
        if(a[i ] <=1000000000000000000/ prod )
        {
            prod *=a[i];
        }
        else
        {
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",prod );
}


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

using namespace std;

const int mod = 1e9 + 7;
const int N = 300005;

int n;
int f[N][5][3][3];
// (pos, gap, parity of segment, number of ones before pos)
string s;

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

int main() {
	ios::sync_with_stdio(false);
	cin >> s, n = s.size();
	if (s[0] == '0' || s[0] == '?') {
		f[0][2][1][0] = 1;
	}
	if (s[0] == '1' || s[0] == '?') {
		f[0][3][0][2] = 1;
	}
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 5; ++j) {
			if (s[i] == '1' || s[i] == '?') {
				add(f[i][min(4, j + 1)][0][2], f[i - 1][j][0][2]);
			}
			for (int k = 1; k < 3; ++k) {
				if (s[i] == '1' || s[i] == '?') {
					if (i < (n - 1)) {
						add(f[i][j][k ^ 3][1], f[i - 1][j][k][0]);
					}
					else if (j) {
						add(f[i][min(4, j + 1 - k)][0][2], f[i - 1][j][k][0]);
					}
					add(f[i][min(4, j + 2 - (k ^ 3))][0][2], f[i - 1][j][k][1]);
				}
				for (int l = 0; l < 2; ++l) {
					if (s[i] == '0' || s[i] == '?') {
						add(f[i][j][k ^ 3][0], f[i - 1][j][k][l]);
					}
				}
			}
			if (s[i] == '0' || s[i] == '?') {
				add(f[i][j][1][0], f[i - 1][j][0][2]);
			}
		}
	}
	int res = 0;
	for (int i = 0; i < 5; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (i - j >= 2) {
					add(res, f[n - 1][i][j][k]);
				}
			}
		}
	}
	cout << res;
}

Measured memory_bytes: 53396
#include<iostream>
#include<cmath>
using namespace std;
int n,a[100005],dp[100005];
long long sum=0;
int main() 
{
   cin>>n;
   for(int i=1;i<=n;i++)
    cin>>a[i];
   dp[0]=dp[1]=0;
   dp[2]=abs(a[2]-a[1]);
   for(int i=3;i<=n;i++)
   {
   	dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i]-a[i-2]));
	} 
   
   cout<<dp[n];
	return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    // 整数の入力
    long a[5];
    long delay;
  	long choke;
    long N;

    choke = pow(10,15);
    cin >> N;
    for(int i =0 ; i < 5; i++){
        cin >> a[i];
        if(a[i] < choke){
            choke = a[i];
        }
    }
    if(N % choke == 0){
        delay = N / choke - 1;
    }else{
        delay = N / choke;
    }
  
    cout << (5 + delay) << endl ;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a=0,c[200005]={};
    int ans=0,d=0;
	string s[200005],s1[200005],s2[200005];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
  	sort(s,s+n);
  	int b=1;
  	for(int i=0;i<n;i++){
      if(s[i]==s1[b-1]){
        c[b-1]++;
      }
      else{
          s1[b]=s[i];
        c[b]=1;
        b++;
      }
      }
	for(int i=0;i<b;i++){
		if(c[i]>ans){
			ans=c[i];
		}
	}
	for(int i=0;i<b;i++){
		if(ans==c[i]){
			s2[d]=s1[i];
			d++;
		}
	}
	sort(s2,s2+d);
	for(int i=0;i<d;i++){
		cout<<s2[i]<<endl;
	}
  return(0);
}

Measured memory_bytes: 18176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if(a+b<=16 && a<=8 && b<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
int main(){
    ll n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    ll ans = INF;
    ll sum = 0;
    rep(i,n){
        if(a[i] > b[i])chmin(ans, b[i]);
        sum += a[i];
    }
    cout << (ans == INF ? 0 : sum - ans) << endl;
}

Measured memory_bytes: 512
n = 10**6
pr = Array.new(n,1)
(2..1000).each{|i|
	next if pr[i] == 0
	j = i * i
	while j < n
		pr[j] = 0
		j += i
	end
}
pr[0] = pr[1] = 0
(2..n).each{|i|
	pr[i] = pr[i] == 1 ? pr[i-1]+1 : pr[i-1]
}
while gets
	p pr[$_.to_i]
end

Measured memory_bytes: 13912
#include <stdio.h>
int main()
{
	int n,i,j,time=0,min=10;
	int hero[5];
	for(i=0;i<5;i++)
		scanf("%d",&hero[i]);
	for(i=0;i<5;i++)
	{
		if(hero[i]%10)
		{
			if(hero[i]%10<min)
			{
				min=hero[i]%10;
				j=i;
			}
		}
	}
	for(i=0;i<5;i++)
	{
		if(i!=j)
		{
			while(hero[i]%10)
			{
				hero[i]++;
			}
			time+=hero[i];
		}
	}
	time+=hero[j];
	printf("%d\n",time);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
int n,ans,i;
  scanf("%d",&n);
  ans=1;
  int h[n],max[n];
  for(i=0;i<n;++i)
  {
  scanf("%d",&h[i]);
  }
  max[0]=h[0];
  for(i=0;i<n-1;++i)
  {
  if(max[i]<=h[i+1]) {max[i+1]=h[i+1];
                    ans++;
                    }
  else max[i+1]=max[i];
  }
  printf("%d",ans);
return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int A, B, C, D;
int N;
int INF = 1e9;
vector<int > l;
int dfs(int depth,int a,int b,int c)
{
  if(depth == N){
    // return min({a,b,c})>0? abs(a-A)+abs(b-B)+abs(c-C)-30:1e9;
   if(min({a, b, c}) > 0){
     return abs(A - a) + abs(B - b) + abs(C - c) - 30;
   }else{
     return INF;
   }
  }
  int ret0 = dfs(depth + 1, a, b, c);
  int reta = dfs(depth + 1, a + l[depth], b, c) + 10;
  int retb = dfs(depth + 1, a, b + l[depth], c) + 10;
  int retc = dfs(depth + 1, a, b, c + l[depth]) + 10;
  return min({reta,retb, retc, ret0});
}
int main()
{
  cin >> N >> A>>B>> C;
  l.resize(N);
  REP(i, N){cin >> l[i];}
  cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#define N 200005
#define LL long long
using namespace std;

struct node
{
	int s,nxt;
}p[N<<1];
int h[N];
LL f[N];
int n,tot;
void adeg(int x,int y)
{
	p[++tot].s=y; p[tot].nxt=h[x]; h[x]=tot;
}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		adeg(u,v); adeg(v,u);
	}
	f[n]=1;
	for(i=n-1;i>=1;i--)
	{
		f[i]=f[i+1]+n-i+1;
		for(j=h[i];j;j=p[j].nxt)
			if(p[j].s>i) f[i]-=(n-p[j].s+1);
	}
	LL ans=0;
	for(i=1;i<=n;i++)
		ans+=f[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1005;
char s[maxn];
int cnt[maxn];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	rep(i,1,n){
		cnt[s[i]]=1;
	}
	bool res=1;
	if((cnt['N']||cnt['S'])&&(!(cnt['N']&&cnt['S'])))
		res=0;
	if((cnt['W']||cnt['E'])&&(!(cnt['W']&&cnt['E'])))
		res=0;
	puts(res?"Yes":"No");
    return 0;
}


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

ll X,Y,Z,A,B,C,N;
ll t[MAX],u[MAX],ans[1000];

ll calc(ll h,ll w,ll n){
  ll a=(n<h?0LL:n-h+1);
  ll b=(n<w?n:w-1LL);
  return max(0LL,b-a+1LL);
}

ll sum(ll a,ll b){
  return u[b]-(0<=a-1?u[a-1]:0LL);
}

int main(){
  /*
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        cout<<i<<' '<<j<<' '<<k<<' '<<calc(i,j,k)<<endl;
      }
    }
  }
  */
  cin>>X>>Y>>Z>>A>>B>>C>>N;
  t[0]=u[0]=1;
  for(ll i=1;i<X+Y;i++){
    t[i]+=calc(X-A,Y-B,i);
    t[i]+=calc(X-A,B+1,i);
    t[i]+=calc(A+1,Y-B,i);
    t[i]+=calc(A+1,B+1,i);
    if(A+i<X)t[i]--;
    if(B+i<Y)t[i]--;
    if(0<=A-i)t[i]--;
    if(0<=B-i)t[i]--;
  }
  
  for(int i=1;i<MAX;i++)u[i]=t[i]+u[i-1];

  for(ll i=0,j=0;i<X+Y+Z;i++,j=(j+1==N?0:j+1)){
    ans[j]+=sum(i-C,i);
    ans[j]+=sum(i-(Z-C-1),i);
    ans[j]-=t[i];
  }
  for(ll i=0;i<N;i++){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 46216
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<P> l;
    rep(i,q){
        int u,y;
        cin >> u >> y;
        u--; y--;
        l.push_back(P(u,y));
    }
    vector<int> t(n);
    int cnt = 0;
    rep1(i,1,n){
        if(s[i] == 'C' && s[i-1] == 'A'){
            cnt++;
        }
        t[i] = cnt;
    }

    rep(i,q){
        int ans = t[l[i].second] - t[l[i].first];
        cout << ans << endl;
    }

}

Measured memory_bytes: 2116
def bubblesort(a)
  c = 0
  flag = 1
  while flag > 0
    flag = 0
    (a.size - 1).times do |j|
      if a[j] > a[j + 1]
        a[j], a[j + 1] = a[j + 1], a[j]
        flag = 1
        c += 1
      end
    end
  end
  [a, c]
end
gets
a, b = bubblesort(gets.split.map &:to_i)
puts "#{a.join(' ')}\n#{b}"

Measured memory_bytes: 8680
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val s = br.readLine()!!
    val t = br.readLine()!!
    for (i in s.indices) {
        val prefix = s.substring(i)
        if (t.startsWith(prefix)) {
            out.println(n + i)
            return
        }
    }

    out.println(s.length + t.length)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  string s; cin >> s;
  cout << s[0] << s[1] << s[2];
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3596
import math

A, B, H, M = map(int, input().split())

A_degree = H * 30 + 0.5 * M
B_degree = M * 6

AB = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(A_degree - B_degree)))
print(AB)


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    int A, B, C;
    cin >> A >> B >> C;
    int dif = A ^ B ^ C;
    int cnt = (dif == A) + (dif == B) + (dif == C);
    cout << (cnt == 1 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
	int n, j, i, aux, cont=0;
	scanf("%i", &n);
	int x[n], y[n], z[n];
	for(j=0; j<n; j++){
		scanf("%i", &x[j]);
	}
	for(j=0; j<n; j++){
		scanf("%i", &y[j]);
	}
	for(j=0; j<n; j++){
		z[j]=x[j]-y[j];
		if(z[j]>0)
			cont+=z[j];

	}

		printf("%i\n", cont);
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n, m, k, a, ans=0;
  cin >> n >> m;
  vector<int> count(m, 0);
  
  for(int i=0; i<n; i++){
    cin >> k;
    for(int j=0; j<k; j++){
      cin >> a; 
      a--;
      count[a]++;
    }
  }
  
  for(int i=0; i<m; i++){
    if(count[i]==n) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for (int i = (a); i >= (b); --i)
#define Rep(i, a, b) for (int i = (a); i < (b); ++i)
#define Repd(i, a, b) for(int i = (a); i > (b); --i)
#define endl '\n'
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;

const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
const ll limit3 = 1e4 + 5;

ll test;
ll n;
ll res = 0, sum = 0, ans = 0, kd, hkd;
bool ok = false;
string s, t;

void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
void ReadIn(){
    cin >> s;
    cin >> t;
    for(ll i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            cout <<"No";
            return;
        }
    }
    cout <<"Yes";
}
int main(){
    FastIn();
    ReadIn();
}
/*
5
4 4 5 3 1

2 2 1 1 1
3 3 3 2 1
*/
/*
* Ctrl + Shift + K Delete Line
* Ctrl + / TOGGLE LINE COMMENT
Ctrl + F Find
* Ctrl + H  REPLACE
* shift + alt + f FORMAT CODE DOCUMENT
Shift + alt + uparrow/downarrow Copy line up/down
Ctrl + ]/[ INDENT/OUTDENT LINE
Quy Hoạch Động
2 kiểu
+ Đếm cách
+ Dùng ít nhất
*/


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

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

	int ans = 0;
	if (a >= b) {
		ans += a; a--;
	}
	else {
		ans += b; b--;
	}
	ans += max(a,b);
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 256
import math

i = list(map(int, input().split()))
A = i[0]
B = i[1]

A_min = math.ceil(float(A)/0.08)
A_max = math.floor(float(A+1)/0.08)

A_list = [i for i in range(A_min, A_max)]

B_min = math.ceil(float(B)/0.10)
B_max = math.floor(float(B+1)/0.10)

B_list = [i for i in range(B_min, B_max)]

A_set = set(A_list)
B_set = set(B_list)
matched_list = sorted(list(A_set & B_set))

if matched_list != []:
    print(matched_list[0])
else:
    print(-1)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] array = new String[2];
    int[] numbers = new int[2];
    String inputStr;
    StringBuilder sb = new StringBuilder();
    while(true) {
      inputStr = br.readLine();
      array = inputStr.split(" ");
      numbers[0] = Integer.parseInt(array[0]);
      numbers[1] = Integer.parseInt(array[1]);
      if (numbers[0] == 0 && numbers[1] == 0) {
        break;
      }
      else {
        if (numbers[0] < numbers[1]) {
          sb.append(Integer.toString(numbers[0])).append(" ").append(Integer.toString(numbers[1])).append("\n");
        }
        else {
          sb.append(Integer.toString(numbers[1])).append(" ").append(Integer.toString(numbers[0])).append("\n");
        }
      }
    }
    sb.delete(sb.length() - 1, sb.length());
    System.out.println(sb);
  }
}

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

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

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

    int ans = 2 * a - 1;
    ans = max(ans, 2 * b - 1);
    ans = max(ans, a + b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    ll temp1;
    ll temp2;
    temp1=b;
    b=a;
    a=temp1;
    temp2=c;
    c=a;
    a=temp2;
    cout<<a<<" "<<b<<" "<<c<<"\n";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>	// require INT_MAX etc
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;
typedef pair<int, int> P; // to, cost, order

const int MAX_N = 100000;
int par[MAX_N];
int rank[MAX_N];
vector <P> G[MAX_N];

// nvfÅú»
int init (int n )
{
	for (int i = 0; i < n; ++i ){
		par[i] = i;
		rank[i] = 0;
		G[i].clear();
	} // end for
}

// ØÌªðßé
int find (int x )
{
	if (par[x] == x )
		return x;

	// eðké
	return par[x] = find (par[x] );
}

// xÆyÌ®·éWð}[W
void unite (int x, int y )
{
	x = find (x);
	y = find (y);

	// eªêÈç½àµÈ¢
	if (x == y )
		return;

	// Nª¬³¢ûÌØðÔçº°é
	if (rank[x] < rank[y] ){
		// x ð y ÉÔçº°é
		par[x] = y;
	}else{
		// Nª¯¶© rank[x] > rank[y]
		par[y] = x;
		if (rank[x] == rank[y] )
			rank[x]++;
	} // end if
}

// xÆyª¯¶WÉ®·é©Û©
bool same (int x, int y )
{
	return (find (x) == find (y) );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.hf", "r", stdin );
	int n;

	while (cin >> n && n ){
		
		// ú»
		init (n );
		
		for (int i = 0; i < n; ++i ){
			int to1, cost1, to2, cost2;
			cin >> to1 >> cost1 >> to2 >> cost2;
			unite (i, to1 ); unite(i, to2 );
			G[i].push_back (P(to1, cost1) ); G[i].push_back (P(to2, cost2 ) );
		} // end for

		map <int, set <int> > group;
		int res = 1;

		for (int i = 0; i < n; ++i )
			group[find(i)].insert(i);

		map<int, set<int> >::iterator it = group.begin();
		for (; it != group.end(); ++it ){
			map<int, int, greater<int> > max_cost;
			set<int> s = (*it).second;
			set<int>::iterator jt = s.begin();
			for (; jt != s.end(); ++jt ){
				int from = (*jt);
				max_cost[G[from][0].second]++;
				max_cost[G[from][1].second]++;
			} // end for
			res = res * ((*max_cost.begin()).second)/2 % 10007; 
		} // end for

		cout << res << endl;		

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    double x;
    cin >> x;
    double n = 100;
    while (n < x) {
        n *= 1.01;
        n = floor(n);
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll A[N+1];
    rep(i,N+1) cin >> A[i];
    ll B[N+1];
    rep(i,N) cin >> B[i];
    B[N] = 0;
    ll out = 0;
    ll add = 0;
    rep(i,N+1){
        if(A[i]<B[i]+add){
            out += A[i];
            add = min(B[i]+add-A[i],B[i]);
        }else{
            out += B[i]+add;
            add = 0;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>

int eq[52];
int dsu[52];
int n;
int ways[2300][52], _[2300];
long long bit[2300];
int cnt;

int find(int x){return x == dsu[x] ? x : dsu[x] = find(dsu[x]);}

void dfs(int i, long long b){
  int j, k;
  int _dsu[52] = {};
  
  for (j = 1; j < i; j++)
    if (eq[j] == 0){
      for (k = 1; k <= j; k++)
	if (find(k) != find(n - j + k)) break;
      if (k > j) return;
    }

  if (i == n){
    cnt++;
    for (j = 1; j <= n; j++){
      ways[cnt][j] = eq[j];
      _[cnt] += (dsu[j] == j);
      bit[cnt] = b;
    }
    return;
  }

  for (j = 1; j <= n; j++) _dsu[j] = dsu[j];
  dfs(i + 1, b);
  eq[i] = 1;
  for (j = 1; j <= i; j++) dsu[find(j)] = find(n - i + j);
  dfs(i + 1, b | (1ll << i));
  for (j = 1; j <= n; j++) dsu[j] = _dsu[j];
  eq[i] = 0;
}

void prepare(){
  for (int i = 1; i <= n; i++) dsu[i] = i;
  dfs(1, 0);
}

const int ljz = 1000000007;
int Tm(int x, int y){long long a = x, b = y; return (a * b) % ljz;}
void MOD(int &x){if (x >= ljz) x -= ljz; if (x < 0) x += ljz;}

int m, a;
int pw[2322], gtf[2322];
int f[221][2];
int ans;
int G[2322];

void doit(int *w, int bh){
  int i, j, k;
  for (i = 1; i <= m + 1; i++) f[i][0] = f[i][1] = 0;
  for (i = 1; i <= m - n + 1; i++) f[i][1] = pw[i - 1];
  for (i = 1; i <= m - n + 1; i++)
    for (k = 0; k < 2; k++)
      if (f[i][k])
	for (j = i + 1; j <= m - n + 1; j++){
	  if (j - i < n){
	    if (w[n + i - j])
	      MOD(f[j][k ^ 1] += f[i][k]);
	  } else
	    MOD(f[j][k ^ 1] += Tm(f[i][k], pw[j - i - n]));
	}
  for (i = 1; i <= m - n + 1; i++){
    int q; MOD(q = f[i][1] - f[i][0]);
    MOD(ans += Tm(q, Tm(G[bh], pw[m - i - n + 1])));
  }
}

int main(){
  int i, j;
  scanf("%d %d %d", &m, &n, &a);
  for (i = pw[0] = 1; i <= m; i++) pw[i] = Tm(pw[i - 1], a);
  prepare();
  ans = 0;
  for (i = cnt; i; i--){
    G[i] = pw[_[i]];
    for (j = cnt; j > i; j--)
      if ((bit[i] & bit[j]) == bit[i])
	MOD(G[i] -= G[j]);
  }
  for (i = 1; i <= cnt; i++) doit(ways[i], i);
  printf("%d\n", ans);
  return 0;
}

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

int main(){
    int N, M;
    string tmp;
    unordered_map<string, int> gain;
    int max;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        auto itr = gain.find(tmp);
        if (itr != gain.end()) {
            gain[tmp]++;
        } else {
            gain[tmp] = 1;
        }
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> tmp;
        auto itr = gain.find(tmp);
        if (itr != gain.end()) {
            gain[tmp]--;
        }
    }
    max = 0;
    for (auto itr = gain.begin(); itr != gain.end(); itr++) {
        if (itr->second > max) {
            max = itr->second;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
  	int	A;
  	int	B;
  	int num;
  
  	num = scanf("%d %d", &A, &B);
  	if (num != 2)
      	return (0);
  
  	if (A - 2 * B > 0)
	  	printf("%d", A - 2 * B);
  	else
      	printf("%d", 0);
  
  	return (0);
}
  

Measured memory_bytes: 128
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let d = read int
    match d with
    | 22 -> "Christmas Eve Eve Eve"
    | 23 -> "Christmas Eve Eve"
    | 24 -> "Christmas Eve"
    | 25 -> "Christmas"
    |> printfn "%s"
    0

Measured memory_bytes: 14044
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define out(a) debg(a);
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
// template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    cout << max({a*c, a*d, b*c, b*d}) << endl;
    return 0;
}


Measured memory_bytes: 3760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
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()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, c; cin >> a >> b >> c;
  cout << (a <= c && c <= b ? "Yes\n" : "No\n");
  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>L(M);
    vector<int>R(M);
    for (int i = 0; i < M; ++i) {
        cin >> L[i] >> R[i];
    }
    int min1 = L[0], max1 = R[0];
    int flag = 0;
    for (int i = 1; i < M; ++i) {
        min1 = max(min1, L[i]);
        max1 = min(max1, R[i]);
    }
    int ans = max1 - min1 + 1;
    if(ans > 0){
        cout << ans;
    }else{
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[200005];
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	int flag=0;
	for(int i=0;i<(n-1);i++)
	{
		if(a[i]==a[i+1])
		{
			printf("NO\n");
			flag=1;
			break;
		}		
	}
	if(flag==0)
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 1024
A, B, K = map(int, input().split())
ans1 = set()
ans2 = set()
for i in range(A, B + 1):
  if len(ans1) < K:
    ans1.add(i)
  else:
    break
    
for i in reversed(range(A, B + 1)):
  if len(ans2) < K:
    ans2.add(i)
  else:
    break

ans = ans1 | ans2
for a in sorted(list(ans)):
  print(a)

Measured memory_bytes: 3064
#include <stdio.h>

// nは配列の要素数
int binarySearch(int A[], int n, int key) {
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (A[mid] == key) {
            return 1;
        } else if (key < A[mid]) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return 0;
}

int main(void) {
    int n, q, i, key;
    int cnt = 0;
    int S[100000];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", S + i);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (binarySearch(S, n, key)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 2112
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::f64::consts::PI;
fn main() {
    input!{
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }
    let theta = (60. * h - 11. * m).abs() / 360. * PI;
    let x2 = a * a + b * b - 2. * a * b * theta.min(2. * PI - theta).cos();
    println!("{}", x2.sqrt());
}

Measured memory_bytes: 2936
from itertools import combinations_with_replacement

N,M,Q=list(map(int,input().split()))
query=[list(map(int,input().split())) for _ in range(Q)]

seq=list(range(1,M+1))
ret=0

for A in combinations_with_replacement(seq,N):
    tmp=0
    for a,b,c,d in query:
        if A[b-1]-A[a-1]==c:
            tmp+=d
    
    ret=max(tmp,ret)

print(ret)

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int a[3] = {-1, -1, -1};
	int n, m;
	cin >> n >> m;
	RC(i, m){
		int s, c;
		cin >> s >> c;
		--s;
		if(a[s] == -1){
			a[s] = c;
		}else if(a[s] != c){
			cout << -1 << endl;
			return 0;
		}
	}
	if(n != 1 && a[0] == 0){
		cout << -1 << endl;
		return 0;
	}
	if(a[0] == -1){
		if(n == 1){
			a[0] = 0;
		}else{
			a[0] = 1;
		}
	}
	if(a[1] == -1) a[1] = 0;
	if(a[2] == -1) a[2] = 0;
	RC(i, n){
		cout << a[i];
	}
	cout << endl;
}


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

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

int main() {

	int N;
	int t[110000], x[110000], y[110000];
	int dift, difx, dify;
	int i;
	bool ans = true;

	cin >> N;
	t[0] = 0; x[0] = 0; y[0] = 0;
	REP(i, N){
		cin >> t[i+1] >> x[i+1] >> y[i+1];
	}

	REP(i, N){
		dift = (t[i+1]-t[i]);
		difx = abs(x[i+1]-x[i]);
		dify = abs(y[i+1]-y[i]);
		if( dift < ( difx + dify ) ){
			ans = false;
		}
		//cout << ( difx + dify ) % 2 << endl;
		if( dift % 2 != (( difx + dify ) % 2) ){
			ans = false;
		}
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0; 
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

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

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

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

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

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

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

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

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

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

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

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

struct Pos{
	int x,y;
};

ostream& operator<<(ostream& os,const Pos& p){
	cout<<"("<<p.x<<" "<<p.y<<")";
	return os;
}

vector<Pos> Solve(vi arg){
	int n=arg.size();
	if(n==4)
		return vector<Pos>{
			Pos{0,0},
			Pos{1,0},
			Pos{1,1},
			Pos{0,1}
		};
	REP(rem,n)
		if(arg[rem]!=arg[(rem+1)%n]){
			vi nx;
			REP(i,n)if(i!=rem&&i!=(rem+1)%n)
				nx.PB(arg[i]);
			vector<Pos> sub=Solve(nx);
			vector<Pos> ret(n);
			if(rem<n-1){
				REP(i,rem)
					ret[i]=sub[i];
				FOR(i,rem+2,n)
					ret[i]=sub[i-2];
			}else
				REP(i,n-2)
					ret[i+1]=sub[i];
			for(auto& r:ret)
				r.x*=2,r.y*=2;
			Pos a=ret[(rem-1+n)%n],b=ret[(rem+2)%n],c=ret[(rem+3)%n];
			Pos p=Pos{b.x-a.x,b.y-a.y},q=Pos{c.x-b.x,c.y-b.y};
			const auto conv=[](int x){
				return x?x/abs(x):0;
			};
			p.x=conv(p.x),p.y=conv(p.y);
			q.x=conv(q.x),q.y=conv(q.y);
			ret[rem]=Pos{a.x+p.x,a.y+p.y};
			if(arg[rem]!=arg[(rem+2)%n])
				q.x*=-1,q.y*=-1;
			ret[(rem+1)%n]=ret[rem];
			ret[(rem+1)%n].x+=q.x;
			ret[(rem+1)%n].y+=q.y;
			ret[(rem+2)%n].x+=q.x;
			ret[(rem+2)%n].y+=q.y;
			map<int,int> xc,yc;
			for(auto& r:ret)
				xc[r.x]=0,yc[r.y]=0;
			int tmp=0;
			for(auto& kv:xc)
				kv.second=tmp++;
			tmp=0;
			for(auto& kv:yc)
				kv.second=tmp++;
			for(auto& r:ret)
				r.x=xc[r.x],r.y=yc[r.y];
			return ret;
		}
	assert(false);
}

int main(){
	vi arg;
	int n=read();
	REP(i,n)
		arg.PB(read());
	if(n<4||n%2==1||accumulate(ALL(arg),0)!=180*(n-2)){
		cout<<-1<<endl;
		return 0;
	}
	auto ans=Solve(arg);
	REP(i,n)
		printf("%d %d\n",ans[i].x,ans[i].y);
}


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


using namespace std;

typedef long long ll;

double eps = 1e-9;

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

   float d,t,s;
   cin>>d>>t>>s;
   float T = d/s;

   if(T+eps<t || fabs(T-t)<=eps)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }

}



Measured memory_bytes: 3736
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n, p, a, sum;
LL cnt, ans;
LL qwe(LL x, LL y){
	LL t = 1LL;
	while(y){
		if(y & 1)t *= x;
		y /= 2;
		x *= x;
	}
	return t;
}
LL C(LL n, LL y){
	LL t = 1, ant = 1;
	for(LL i = n; i >= n - y + 1; i--){
		ant *= i;
		while(ant % t == 0 && t < y){
			ant /= t;
			t++;
		}
	}
	while(t <= y){
		ant /= t;
		t++;
	}
	return ant;
}
int main(){
	scanf("%lld %lld", &n, &p);
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a);
		if(a & 1)cnt++;
	}
	sum = qwe(2, n - cnt);
	if(p == 1){
		for(int i = 1; i <= cnt; i++){
			if(i & 1)ans += C(cnt, i);
		}
	}
	else {
		for(int i = 0; i <= cnt; i++)
		if(i % 2 == 0)ans += C(cnt, i);
	}
	printf("%lld\n", sum * ans);
	return 0;
}

Measured memory_bytes: 128