akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

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

	if(s <= "2019/04/30")
		puts("Heisei");
	else
		puts("TBD");
	return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
n, m = map(int, raw_input().split())
S = []
for _ in range(m):
    line = map(int, raw_input().split())
    S.append(line[1:])
P = map(int, raw_input().split())
perms = [[0] * n]
for i in range(n):
    for j in range(len(perms)):
        p2 = deepcopy(perms[j])
        p2[i] = 1
        perms.append(p2)
ways = 0
for perm in perms:
    satisfy = True
    for k in range(m):
        count = 0
        for s in S[k]:
            if perm[s-1] == 1:
                count += 1
        if count % 2 != P[k]:
            satisfy = False
            break
    if satisfy:
        ways += 1
print ways

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
    int a,b,h;
    cin>>a>>b>>h;
    int sum=0,did=0;
    if(1<=a<=100 && 1<=b<=100 && 1<=h<=100 && h%2==0)
    {
    sum=((a+b)*h);
    did=(0.5*sum);
    }
       cout<<did<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int i,j,n,ans,flag[50000];

int main(){
	memset(flag,0,sizeof(int)*50000);
	for(i=2;i<=50000;i++){
		if(flag[i]==0){
			for(j=2;j*i<=50000;j++){
				flag[j*i]=1;
			}
		}
	}
	
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;ans=0;
		for(i=2;i<=n/2;i++){
			if(n-i>1 && flag[i]==0 && flag[n-i]==0)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 604
#include <stdio.h> 
 int main(void){
 int n,debt =100000;
 double tem;
 scanf("%d",&n);  
 for(;n>0;n--){      
  tem = debt*1.05;
  if((int)tem%1000==0)     
     debt = tem;
  else{
       tem=tem/1000;
       debt =tem+1;
       debt = debt*1000;   
    }  
    } 
  printf("%d\n",debt);     
 return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){

	int N;
	int a[100000];
	int num[100000];
	int sum[100000];
	for(int i=0;i<100000;i++){
		num[i] = 0;
		sum[i] = 0;
	}

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		num[a[i]]++;
	}

	sum[0] = num[0] + num[1];
	sum[99999] = num[99998] + num[99999];
	for(int i=1;i<99999;i++){
		sum[i] = num[i-1] + num[i] + num[i+1];
	}

	sort(sum,sum+100000);
	reverse(sum,sum+100000);

	printf("%d\n",sum[0]);

	return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	static Puzzle[][] p = new Puzzle[5][5];
	static Puzzle[] tmp;
	static int ans;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		while(N--!=0){
			p = new Puzzle[5][5];
			tmp = new Puzzle[10];
			ans=0;
			for(int i = 0;i<5;i++){
				for(int j = 0;j<5;j++){
					p[i][j]= new Puzzle(0,0,0,0);
				}
			}
			for(int i = 1;i<=9;i++){
				String str = cin.next();
				char[] s = str.toCharArray();
				tmp[i]=new Puzzle(s[0],s[1],s[2],s[3]);
			}
			piece(0);
			System.out.println(ans);
		}
	}
	static void piece(int a){
		if(a==9){
			ans++;
			return;
		}
		int x = a/3+1;
		int y = a%3+1;
		if(a==1){
		//System.out.println(a+" "+ x+" " +y);
		}
		for(int i = 1;i<=9;i++){
			for(int j = 1;j<=4;j++){
				if(tmp[i].top==0){
					break;
				}
				if(set(x,y,tmp[i])){
					p[x][y]=tmp[i];
					Puzzle puz = tmp[i];
					tmp[i]=new Puzzle(0,0,0,0);
					piece(a+1);
					tmp[i]=puz;
					p[x][y]=new Puzzle(0,0,0,0);
				}
				tmp[i].turn();
			}
		}
	}
	static boolean set(int x,int y,Puzzle puzzle){
		if(!(Math.abs(puzzle.top-p[x-1][y].bottom) == 32 || p[x-1][y].bottom==0)){
			return false;
		}
		if(!(Math.abs(puzzle.left-p[x][y-1].right) == 32 || p[x][y-1].right==0)){
			return false;
		}
		if(!(Math.abs(puzzle.bottom-p[x+1][y].top) == 32 || p[x+1][y].top==0)){
			return false;
		}
		if(!(Math.abs(puzzle.right-p[x][y+1].left) == 32 || p[x][y+1].left==0)){
			return false;
		}
		return true;
		
	}
}
class Puzzle{
	int top;
	int bottom;
	int right;
	int left;
	Puzzle(int a,int b,int c,int d){
		top=a;bottom=c;right=b;left=d;
	}
	void turn(){
		int tmp = top;
		top = right;
		right = bottom;
		bottom = left;
		left = tmp;
		
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    REP(i, A + 1) {
        int R1 = X - 500 * i;
        if (R1 == 0) {
            res++;
            break;
        } else if (R1 < 0) {
            break;
        }
        REP(j, B + 1) {
            int R2 = R1 - 100 * j;
            if (R2 == 0) {
                res++;
                break;
            } else if (R2 < 0) {
                break;
            }
            if (R2 % 50 == 0 && R2 / 50 <= C) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

J=[a[i-1]+i for i in range(1,n+1)]
I=[i-a[i-1] for i in range(1,n+1)]
dj=Counter(J)
di=Counter(I)
ans=0
for i in dj:
  if i in di:
    ans+=(dj[i]*di[i])
print(ans)

Measured memory_bytes: 63664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vector<int> 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));

  ll sum = 0;
  rep(i, n){
    int x = b[i];
    auto ab = a.begin();
    auto ae = lower_bound(all(a), x);
    int da = distance(ab, ae);
    auto cb = upper_bound(all(c), x);
    auto ce = c.end();
    int dc = distance(cb, ce);
    sum += (ll)da * (ll)dc;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  cout << a+b+c-max({a,b,c}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

vector<string> stk;

void find() {

}

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

    for (char i = 'a'; i <= 'z'; i++) {
        for (int j = 0; j < s.size(); j++) {
            if (s[j] == i) {
                for (int l = 1; l <= k; l++) {
                    stk.pb(s.substr(j, l));
                }
            }
        }
    }

    sort(stk.begin(), stk.end());

    if (k == 1) {
        cout << stk[0] << endl;
        return 0;
    } else {
        int cnt = 1;
        for (int i = 1; i <= stk.size(); i++) {
            if (stk[i - 1] != stk[i]) cnt++;
            if (cnt == k) {
                cout << stk[i] << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 1660
n=int(input())
red=[[] for i in range(n)]
blue=[[] for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    red[i].append(a)
    red[i].append(b)
for i in range(n):
    a,b=map(int,input().split())
    blue[i].append(a)
    blue[i].append(b)
red=sorted(red)
blue=sorted(blue)
ans=0
for i in range(n):
    x=blue[i][0]
    y=blue[i][1]
    maxy=-1
    for j in range(n):
        if x>red[j][0] and y>red[j][1]:
            maxy=max(maxy,red[j][1])
    for j in range(n):
        if x>red[j][0] and maxy==red[j][1]:
            ans+=1
            red[j][0]=1000
            break
print(ans)


Measured memory_bytes: 9052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
ll x;
int n;
int a, b;
int main() {
  cin>>a>>b;
  if (a == b) cout<<"Draw"<<endl;
  else {
  	if (a == 1) cout<<"Alice"<<endl;
    else if (b == 1) cout<<"Bob"<<endl;
    else if (a<b) cout<<"Bob"<<endl;
    else cout<<"Alice"<<endl;
  }
	return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s;
    cin >> s;
    reverse(all(s));
    s = s.substr(8);
    reverse(all(s));
    cout<<s<<endl;
    return 0;
}

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

int main() {
  int N;
  int x[110000], y[110000], t[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i=0; i < N; i++)  cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  bool can = true;
  for (int i=0; i < N; i++) {
    int time = t[i+1] - t[i];
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (time < dist || time%2 != dist%2) can = false;
  }
  
  if (can) cout << "Yes" << endl;
  else     cout << "No" << endl;
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1)
            (res *= a) %= MOD;
        n >>= 1;
        (a *= a) %= MOD;
    }
    return res;
}

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

    int N;
    cin >> N;
    map<pll, int> cnt;
    for (int i = 0; i < N; ++i) {
        ll A, B;
        cin >> A >> B;
        if (A < 0 || (A == 0 && B < 0))
            A = -A, B = -B;
        if (A != 0 || B != 0) {
            ll g = gcd(A, B);
            A /= g, B /= g;
        }
        cnt[{A, B}]++;
    }

    ll ans = 1;
    for (auto i : cnt) {
        pll tmp = {i.first.second, -i.first.first};
        if (tmp == pll{0, 0})
            continue;

        if (tmp.first < 0 || (tmp.first == 0 && tmp.second < 0)) {
            tmp.first = -tmp.first;
            tmp.second = -tmp.second;
        }

        ll tmp2 = 0;
        if (cnt.find(tmp) != cnt.end()) {
            if (i.first > tmp)
                continue;
            tmp2 = modpow(2, i.second) + modpow(2, cnt[tmp]) - 1 + MOD;
            tmp2 %= MOD;
        } else
            tmp2 = modpow(2, i.second);
        (ans *= tmp2) %= MOD;
    }
    ans--;
    ans += cnt[{0, 0}] + MOD;
    ans %= MOD;

    cout << ans << endl;

    return 0;
}


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

int main() {
    int n;cin>>n;
    int trip[n+1][3];
    trip[0][0]=0;
    trip[0][1]=0;
    trip[0][2]=0;
    for(int i=1;i<n+1;i++){
        for(int j=0;j<3;j++){
            cin>>trip[i][j];
        }
    }
    int loop=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            int dis=max(trip[i][1],trip[i+1][1])-min(trip[i][1],trip[i+1][1])+max(trip[i][2],trip[i+1][2])-min(trip[i][2],trip[i+1][2]);
            int ti=trip[i+1][0]-trip[i][0];
            if(dis<=ti){
                if(dis%2==ti%2){
                    continue;
                }
                else loop=0;
            }else loop=0;
        }
    }
    if(loop==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
 vector<int> l(N);
 for(int i = 0; i<N;i++){
  cin >> l.at(i);
 }
  sort(l.begin(),l.end());
  int sum = 0;
  for(int i = 0; i<N-1;i++){
    sum += l.at(i);
  }
  
  if(sum > l.at(N-1)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 4444444
ll n,m;
ll b[555][555];
ll dp[2][MAX];

ll a1(){
  ll res=0;
  for(ll i=0;i<1<<n;i++){
    ll cnt=0;
    ll s[555]={};
    for(ll j=0;j<n;j++){
      if(i>>j&1){
	cnt++;
	for(int k=0;k<m;k++){
	  s[k]^=b[j][k];
	}
      }
    }
    int flg=0;
    for(int j=0;j<m;j++)if(s[j])flg=1;
    if(flg)continue;
    res=max(res,cnt);
  }

  return res;
}

ll a2(){
  ll res=0;

   ll bx[555]={};
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(b[i][j])bx[i]+=pow(2,j);
    }
  }
  
  for(ll i=0;i<1<<n;i++){
    ll cnt=0;
    ll s=0;
    for(ll j=0;j<n;j++){
      if(i>>j&1){
	cnt++;
	s^=bx[j];
      }
    }
    if(s)continue;
    res=max(res,cnt);
  }

  return res;
}



ll dn(){
  fill_n(*dp,2*MAX,-1);
  ll bx[555]={};
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(b[i][j])bx[i]+=pow(2,j);
    }
  }
  dp[0][0]=0;
  ll rm=1<<(m+1);
  for(ll i=0;i<n;i++){
    
    for(ll j=0;j<rm;j++)dp[(i+1)%2][j]=-1;
    
    for(ll j=0;j<rm;j++){
      ll ni=i%2;
      ll nx=(i+1)%2;
      if(dp[ni][j]==-1)continue;
      dp[nx][j]=max(dp[nx][j],dp[ni][j]);
      dp[nx][j^bx[i]]=max(dp[nx][j^bx[i]],dp[ni][j]+1);
    }
  }
  
  return dp[n%2][0];
}

int main(){
  
  while(cin>>n>>m,n){

    fill_n(*b,555*555,0);
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++){
	char a;
	cin>>a;
	if(a=='1')b[i][j]=1;
      }
    //cout<<a1()<<" "<<a2()<<" "<<dn()<<endl;
    
    if(n<=15)cout<<a1()<<endl;
    else if(n<=22)cout<<a2()<<endl;
    else cout<<dn()<<endl;
  }
  return 0;
}



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

int main() {
	int c[3][3];
	rep (i, 3) rep (j, 3) cin >> c[i][j];

	bool ok = false;
	if (c[2][0] - c[1][0] == c[2][1] - c[1][1] && c[2][0] - c[1][0] == c[2][2] - c[1][2] &&
			c[1][0] - c[0][0] == c[1][1] - c[0][1] && c[1][0] - c[0][0] == c[1][2] - c[0][2]
			) ok = true;

	if (ok)yn
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main(){
 int x[2];
 int a,b,ans,temp;
  
 scanf("%d %d\n", &a, &b);
   
 if( a >= b ){
  x[0] = a;
  x[1] = b;
 }else if( a < b ){
  x[0] = b;
  x[1] = a;
 }
  
 while( x[1] > 0 ){
  temp = x[1];
  x[1] = x[0] % temp;
  x[0] = temp;
 }
  
 ans=x[0];
  
 printf("%d\n", ans);
  
 return 0;
  
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
//int int_max = 2147483647;
i64 INF = 1e12;
int max_n = 1e5;

template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

int main(int argc, char **argv) {
    i64 n,w;
    cin >> n >> w;

    vector<i64> weight(n+1);
    vector<i64> cost(n+1);
    for (int i=1; i<n+1; ++i) {
        cin >> weight[i] >> cost[i];
    }
    i64 max_val = 1000 * (n+1);
    mat2d_t<i64> dp(n+1, max_val, INF);
    dp[0][0] = 0;
    for (int i=1; i<n+1; ++i) {
        i64 w_i = weight[i];
        i64 v_i = cost[i];

        for (int j=0; j<max_val; ++j) {
            if (j-v_i >= 0 && dp[i-1][j-v_i] + w_i <= w) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v_i] + w_i);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    i64 ans{0};
    for (i64 i=0; i<max_val; ++i) {
        if (dp[n][i] != INF) {
            ans = max(i, ans);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    if(n%2==0)print(0.50)
    else print((n/2+1)/(1.0*n))
    
    return 0;
}

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

using namespace std;

int main(){
  int X, Y;
  cin >> X >> Y;
  if(X*4<Y){
    cout << "No";
  }else if(X*2 > Y){
    cout << "No";
  }else if(Y%2==1){
    cout << "No";
  }else{
    cout <<"Yes";
  }
  return 0;
}


Measured memory_bytes: 3628
S = str(input())
for i in range(len(S)-1,1,-1):
    tmp = S[0:i]
    if len(tmp)%2==0:
        flag = True
        for j in range(len(tmp)//2):
            if tmp[j]!=tmp[len(tmp)//2+j]:
                flag = False
                break
        if flag == True:
            print(len(tmp))
            break


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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



int main() {

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    int temp=1000000;

    rep(i,n)
    {
        if(p[i]<=temp)
        {
             ans += 1;
             temp = p[i];

        }
        
    }

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans=0;
    if(a > b){
        ans += b;
    }else{
        ans += a;
    }
    if(c > d){
        ans += d;
    }else{
        ans += c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    string ans = (a*b%2==0) ? "No" : "Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	long long kei = 0, syou = 1000005, dai = -1000005;
	for (int i=0; i < n; i++) {
		long long v;
		cin >> v;
		syou = min(syou, v);
		dai = max(dai, v);
		kei += v;
	}
	cout << syou <<" "<<dai <<" "<< kei << endl;
}


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

int main()
{
	int n;
	vector<int> list;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		list.push_back(num);
	}

	int proc_count = 0;
	while (true)
	{
		bool valid = true;
		for (int i = 0; i < n; i++)
		{
			if (list[i] % 2 > 0)
			{
				valid = false;
				break;
			}
			else
			{
				list[i] /= 2;
			}
		}

		if (valid == true)
		{
			proc_count++;
		}
		else
		{
			break;
		}
	}

	cout << proc_count << endl;
}



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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

void solve(){
   string s;
   cin >> s;

   int sum = 0;
   for(char c : s)   sum += c - '0';
   cout << (sum  % 9 == 0 ? "Yes" : "No") << "\n";
}

int32_t main(){
   fast;
   int t = 1;
   // cin >> t;
   while(t--)  solve();   
}

Measured memory_bytes: 3776
// C - Lower
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<long long> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<long long> a(n);
	for (int i = 1; i < n; i++)
		a[i] = h[i] <= h[i - 1] ? 1 : -1000000000;
	long long ans = 0, here = 0;
	for (int i = 0; i < n; i++) {
		here = max(0LL, here + a[i]);
		ans = max(ans, here);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
n,m = map(int,input().split())
a = set(map(int,input().split()))
b = set(map(int,input().split()))
i = sorted(a&b)
u = sorted(a|b)
print(len(i),len(u))
for x in i:
    print(x)
for x in u:
    print(x)


Measured memory_bytes: 39144
from sys import stdin
import numpy as np
def main():
    n = int(stdin.readline().rstrip())
    a = list(map(int,stdin.readline().rstrip().split()))
    a = np.array(a)
    mod = 10**9+7
    point = 0
    for i in range(61):
        b = (a >> i)&1
        x = np.count_nonzero(b)
        y = n-x
        point += x*y*(2**i)%mod
    print(point%mod)
if __name__ == "__main__":
    main()

Measured memory_bytes: 51100
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;

ll dp[100001];
bool live[100001];

int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    P = t1*(a1-b1);
    Q = t2*(a2-b2);
    if(P > 0) P *= -1, Q *= -1;
    if(P + Q < 0) cout << 0;
    else if(P + Q == 0) cout << "infinity";
    else {
        S = (-1*P)/(P+Q);
        T = (-1*P)%(P+Q);
        if(T == 0) cout << S*2;
        else cout << S*2+1;
    }                                                                                                
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    string r,g,b;
    cin >> r >> g >> b;
    YES(stoi(r+g+b)%4 == 0);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
P f(int x) {
  int a = x%10;
  int b = 0;
  while (x) {
    b = x;
    x /= 10;
  }
  return P(a,b);
}
 
int main() {
  int n;
  cin >> n;
  map<P,int> freq;
  for (int i = 1; i <= n; ++i) {
    P p = f(i);
    freq[p]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def solve(h, w, a):
    a = list(map(list, a))
    total = 0
    for r in range(h):
        for c in range(w):
            if a[r][c] == "#":
                total += 1
    que = [(0,0)]
    a[0][0] = "."
    while que:
        cr, cc = que.pop(0)
        for dr, dc in [(1,0),(0,1)]:
            nr, nc = cr+dr, cc+dc
            if (0 <= nc < w) and (0 <= nr < h) and a[nr][nc] == "#":
                a[nr][nc] = "."
                que.append((nr, nc))
    return "Possible" if (a[h-1][w-1] == ".") and (total == h+w-1) else "Impossible"

h, w = map(int, input().split())
a = [input() for r in range(h)]
print(solve(h, w, a))

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def EulerTour(graph, root=1):
    global ind_L, ind_R, parent
    N = len(graph) - 1
    stack = [-root, root]
    tour = []
    i = -1
    while stack:
        v = stack.pop()
        i += 1
        if v > 0:
            ind_L[v] = i
            p = parent[v]
            for w in graph[v]:
                if w == p:
                    continue
                parent[w] = v
                stack.append(-w)
                stack.append(w)
        else:
            ind_R[-v] = i
        yield v
    return tour, ind_L, ind_R, parent


N = int(readline())
graph = [[] for _ in range(N + 1)]
parent = [0] * (N + 1)
ind_L = [0] * (N + 1)
ind_R = [0] * (N + 1)
C = (0,) + tuple(map(int, readline().split()))
m = map(int, read().split())
for a, b in zip(m, m):
    graph[a].append(b)
    graph[b].append(a)

removed = [0] * (N + 1)
answer = [N * (N + 1) // 2] * (N + 1)
memo = [0] * (N + 1)

for v in EulerTour(graph):
    if v > 0:
        memo[v] = removed[C[parent[v]]]
    else:
        v = -v
        removed[C[v]] += 1
        c = C[parent[v]]
        x = (ind_R[v] - ind_L[v]) // 2 + 1  # subtree size
        x -= removed[c] - memo[v]
        answer[c] -= x * (x + 1) // 2
        removed[c] += x

for i, x in enumerate(removed):
    x = N - x
    answer[i] -= x * (x + 1) // 2
print('\n'.join(map(str, answer[1:])))


Measured memory_bytes: 96664
n = int(input())
              
def primes(n):
    p = []    
    i = 1     
    while True:
        i += 1
        if i * i > n:
            break
        ok = True
        for j in p:
            if i % j == 0:
                ok = False
                break
        if ok:
            p.append(i)
    return p  
p = primes(n) 
              
ans = 0       
for i in range(1, len(p)):
    for j in range(i+1, len(p)):
        for k in range(j+1, len(p)):
            if p[i] * p[j] * p[k] <= n:
                ans += 1
              
for i in range(1, len(p)):
    for j in range(i+1, len(p)):
        if p[i] * p[i] * p[i] * p[j] <= n:
            ans += 1
print(ans)



Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s; cin >> s;
    string t; cin >> t;
    int n = s.size();
    int ans = 0;
    rep(i,n){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    size_t n = s.size(), k = n/2;
    char c = s[k];
    for ( ; k<n; k++)
        if (s[k] != c || s[n - k - 1] != c) 
            break;
    cout << k << '\n';
    return 0;
}

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

// Credit to Errichto for the template!
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
    sim > struct rge { c b, e; };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c* x) -> decltype(cout << *x, 0);
    sim > char dud(...);
    struct debug {
#ifdef LOCAL
      ~debug() { cout << endl; }
      eni(!=) cout << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
      ris << "(" << d.first << ", " << d.second << ")";
    }
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

long long N, M, F[500100], FD[500100], MOD = 1e9 + 7;
long long L[500100], W[500100];

long long pw(long long x, long long p) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    long long ret = pw(x, p / 2);
    return (ret * ret) % MOD;
  } {
    long long ret = pw(x, p - 1);
    return (ret * x) % MOD;
  }
}

long long C(long long n, long long x) {
  if (x > n) return 0;
  long long ret = F[n];
  ret = (ret * FD[x]) % MOD;
  ret = (ret * FD[n - x]) % MOD;
  return ret;
}

long long countAtLeast(long long x) {
  //long long ret = C(N, x);
  long long ret = 1;
  ret = (ret * C(M, x)) % MOD;
  ret = (ret * F[x]) % MOD;
  ret = (ret * C(M - x, N - x)) % MOD;
  ret = (ret * F[N - x]) % MOD;
  ret = (ret * C(M - x, N - x)) % MOD;
  ret = (ret * F[N - x]) % MOD;
  return ret;
}

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

  F[0] = 1;
  FD[0] = pw(F[0], MOD - 2);
  for (long long i = 1; i < 500100; i++) {
    F[i] = (F[i - 1] * i) % MOD;
    FD[i] = pw(F[i], MOD - 2);
  }

  cin >> N >> M;

  L[N] = countAtLeast(N);
  W[N] = L[N];
  debug() << imie(N) imie(L[N]);
  for (int x = N - 1; x >= 1; x--) {
    L[x] = countAtLeast(x);
    debug() << imie(x) imie(L[x]);
    W[x] = (L[x] - L[x + 1] + MOD) % MOD;
  }

  long long ret = 0;
  for (int x = 1; x <= N; x++) {
    long long ways = 1;
    ways = (ways * C(N, x)) % MOD;
    ways = (ways * W[x]) % MOD;
    ways = (ways * F[x]) % MOD;
    ways = (ways * F[N - x]) % MOD;
    ways = (ways * F[N - x]) % MOD;
    ret = (ret + ways) % MOD;
  }
  debug() << imie(ret);

  long long everything = (C(M, N) * C(M, N)) % MOD;
  everything = (everything * F[N]) % MOD;
  everything = (everything * F[N]) % MOD;
  debug() << imie(everything);

  for (int l = 1; l <= N; l++) {
    long long term = (MOD + pw(-1, l)) % MOD;
    term = (term * C(N, l)) % MOD;
    term = (term * countAtLeast(l)) % MOD;

    everything = (everything + term) % MOD;
  }

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


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  string S,T;
  int ans = 0;
  cin >> S;
  cin >> T;
  if (S[0] == T[0]) ans++;
  if (S[1] == T[1]) ans++;
  if (S[2] == T[2]) ans++;
  cout << ans << endl;
}


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

int main(){
    char b;
    char ans;

    cin >> b;

    if(b=='A'){
        ans ='T';
    }
    if(b=='T'){
        ans = 'A';
    }
    if(b=='C'){
        ans = 'G';
    }
    if(b=='G'){
        ans = 'C';
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n;
long double ans = 0.0, dp[ 3003 ][ 3003 ];
vector< long double > p( 3003 ), pro( 3003, 1 );

long double solve( int i, int heads )
{
	if( i == 0 )
	{
		return !heads;
	}
	else if( i >= 1 && heads == 0 )
	{
		return pro[ i ];
	}
	if( dp[ i ][ heads ] >= 0 )
	{
		return dp[ i ][ heads ];
	}
	dp[ i ][ heads ] = p[ i ] * solve( i - 1, heads - 1 ) + ( 1 - p[ i ] ) * solve( i - 1, heads );
	return dp[ i ][ heads ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> p[ i ];		
	}
	for( int i = 1; i <= n; ++i )
	{
		pro[ i ] = pro[ i - 1 ] * ( 1 - p[ i ] );		
	}
	for( int i = n / 2 + 1; i <= n; ++i )
	{
		ans += solve( n, i );
	}
	cout << setprecision( 15 ) << fixed << ans << "\n";
	return 0;
}

Measured memory_bytes: 141568
#include<stdio.h>
main(){
  int N,H,W,i,count=0;
  int a[1000],b[1000];
  scanf("%d %d %d",&N,&H,&W);
  for(i=0;i<N;++i){
      scanf("%d %d",&a[i],&b[i]);
      if((a[i]>=H)&&(b[i]>=W))++count;
  }
printf("%d",count);

return 0;
}

Measured memory_bytes: 128
num1, num2 = [int(i) for i in input().split()]
num3 = [int(i) for i in input().split()]

numArray = [[0]*2]*num2

for index3 in range(num2):
    numArray[index3] = [int(j) for j in input().split()]

numArray.sort(key=lambda x:(-x[1]))

fg1 = True

for index1 in range(num2):
    for index2 in range(numArray[index1][0]):
        num3.append(numArray[index1][1])
        if len(num3)>=(num1*2):
            fg1= False
            break
    if fg1 == False:
        break

num3.sort(reverse=True)

sum1 = 0
for index4 in range(num1):
    sum1 +=num3[index4]

print(str(sum1))


Measured memory_bytes: 29816
def base_10to(n,m):
    if (n//m):
        return base_10to(n//m, m) + str(n%m)
    return str(n%m)

n,a,b,c = map(int, input().split())
l = [int(input()) for i in range(n)]

ans = float('inf')

for i in range(4**n):
    d = base_10to(i,4).zfill(n)
    x = 0
    y = 0
    z = 0
    e = 0
    for j in range(n):
        if d[j]=='0':
            x+=l[j]
            e+=1
        elif d[j]=='1':
            y+=l[j]
            e+=1
        elif d[j]=='2':
            z+=l[j]
            e+=1
    if x==0 or y==0 or z==0:
        continue
    ans = min(abs(x-a)+abs(y-b)+abs(z-c)+(e-3)*10,ans)
print(ans)



Measured memory_bytes: 83304
#! /usr/bin/env python
# -*- coding: utf-8 -*-

l = []
while True:
    values = map(int, raw_input().split())
    if values[0] == 0 and values[1] == 0:
        break
    else:
        l.append(values)

for v in l:
    if v[0] < v[1]:
        print('%d %d') % (v[0], v[1])
    else:
        print('%d %d') % (v[1], v[0])

Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<int> era(int N){
	vector<int> is_prime(N+1,1);
	is_prime[0]=0;
	is_prime[1]=0;
	for(int p=2;p*p<=N;p++){
		if(!is_prime[p])continue;
		for(int i=p*2;i<=N;i+=p)is_prime[i]=0;
	}
	return is_prime;
}

signed main(){
	vector<int> pri=era(100000+1000);
	int Q; cin>>Q;
	vector<int> l(Q),r(Q);
	for(int i=0;i<Q;i++)cin>>l[i]>>r[i];
	vector<int> ans(100000+1000,0);
	int maxr=*max_element(r.begin(),r.end());
	for(int i=1;i<maxr+100;i++){
		ans[i]+=ans[i-1];
		if(i%2==1 && pri[i] && pri[(i+1)/2])ans[i]++;
	}
	for(int i=0;i<Q;i++){
		cout<<ans[r[i]]-ans[l[i]-1]<<endl;
	}
	return 0;

}

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


int main(){
    int n, k;
    long long w = 0;
    cin >> n >> k;
    int W[n];
    for (int i = 0; i < n; i++) { cin >> W[i]; w += W[i]; }
    
    if (k >= n) {sort(W, W+n); cout << W[n-1] << endl; }
    else if (k == 1) { cout << w << endl; }
    else {
        long l = 0, r = 1000000000;
        while(r - l > 1){
            long m = (l+r)/2;
            int i = 0, x = 0;
            for (int j = 0; j < k; j++) {
                long long s = 0;
                while (s + W[i] <= m) {                        
                    s += W[i]; i++;
                    if (i == n) { x = 1; break; }
                }
            }
            if (x == 1) r = m;
            else l = m;
        }
        cout << r << endl;
    }
    return 0;
}


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

int main() {
  
  int X=0, A=0, B=0;
  
  cin >> X >> A >> B;
  
  int day = B-A;
  
  if(0<day && day<=X) {
    
    cout << "safe" << endl;
    
  } else if(0<day && X<day) {
    
    cout << "dangerous" << endl;
    
  } else {
    
    cout << "delicious" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
//ITNOA
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
const long long INF=1e9+10,MAX=100,MOD=1e9+7;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
void OUT(long double o,int x){
	 cout<<fixed<<setprecision(x)<<o;
	 return;
}
ll a[1000][10][10];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,i=0;
	string s1,s2;
	cin>>n>>s1>>s2;
	if(s1[0]==s2[0]){
		a[0][1][1]=1;
		a[0][2][2]=1;
		a[0][3][3]=1;
		i=1;
	}
	else{
		a[0][1][2]=1;
		a[1][1][2]=1;
		a[0][1][3]=1;
		a[1][1][3]=1;
		a[0][2][1]=1;
		a[1][2][1]=1;
		a[0][2][3]=1;
		a[1][2][3]=1;
		a[0][3][1]=1;
		a[1][3][1]=1;
		a[0][3][2]=1;
		a[1][3][2]=1;
		i=2;
	}
	for(;i<n;){
		if(s1[i]==s2[i]){
			for(ll j=1;j<=3;j++){
				for(ll k=1;k<=3;k++){
					for(ll h=1;h<=3;h++){
						if(h!=j&&k!=j)
							a[i][j][j]=(a[i][j][j]+a[i-1][k][h])%MOD;
					}
				}
			}
			i++;
		}
		else{
			for(ll j=1;j<=3;j++){
				for(ll k=1;k<=3;k++){
					for(ll h=1;h<=3;h++){
						for(ll l=1;l<=3;l++){
							if((h!=j&&l!=k)&&j!=k){
								a[i][j][k]=(a[i][j][k]+a[i-1][h][l])%MOD;
								a[i+1][j][k]=(a[i+1][j][k]+a[i-1][h][l])%MOD;
							}
						}
					}
				}
			}
			i+=2;
		}
	}
	ll ans=0;
	for(ll i=1;i<=3;i++){
		for(ll j=1;j<=3;j++)
			ans=(ans+a[n-1][i][j])%MOD;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h): #すべての行の塗りつぶし方を2進数で列挙する
 for paint_w in range(2**w): #すべての列の塗りつぶし方を2進数で列挙する
   cnt=0
   for i in range(h): #すべてのi行目j列目の要素についてみる
     for j in range(w):
       if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
         if board[i][j]=='#': #塗りつぶされないマスが黒マスであれば個数を+1する
           cnt+=1
   if cnt==k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
     ans+=1
print(ans)

Measured memory_bytes: 9072
import math
import itertools
import sys
input = sys.stdin.readline


def f(x, y, z):
    return x**2+y**2+z**2+x*y+y*z+z*x


N = int(input())

ans = [0 for _ in range(N)]
lim = 101
for x in range(1, lim):
    for y in range(1, lim):
        for z in range(1, lim):
            A = f(x, y, z)
            if A <= N:
                ans[A-1] += 1
for i in range(N):
    print(ans[i])


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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		br.close();

		int ans = 0;
		String t = "";
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length; i++) {
			sb.append(s[i]);
			String u = sb.toString();
			if (t.equals(u)) {
				sb.append(s[i]);
			} else {
				t = u;
				sb = new StringBuilder();
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

#pragma GCC optimize("O3")

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

bool is_palindrome(string s) {
	string t(s.rbegin(), s.rend());
	return s == t;
}

void solve(){
	string s;
	cin >> s;
	bool is;
	int n = s.size();
	is = is_palindrome(s) && is_palindrome(s.substr(0, (n-1)/2)) && is_palindrome(s.substr((n+1/2)));
	
	cout << (is ? "Yes" : "No");
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    solve();
    
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int	a[2];
  int i = 0;
  long int  c = 0;

  cin >> a[0] >> a[1];
  
  int	b[a[0]];
  

  for(i = 0;i < a[0];i++){
  	cin >> b[i];
  }
  
  for(i = 0;i < a[0];i++){
  	c = c + b[i];
  }
  i = 4 * a[1];
  if(c % i!=0){
  	c = c / i;
    c = c+ 1;
  }else{
  	c = c / i;
  }
  for(i = 0;i < a[0];i++){
  	if(b[i] < c){
    	b[i] = 0;
    }
  }
  
  c = 0;
  
  for(i = 0;i < a[0];i++){
  	if(b[i] != 0){
    	c = c + 1;
    }
  }
  
  if(c >= a[1]){
  	cout << "Yes";
    return 0;
  }else{
  	cout << "No";
     return 0;
  }
}

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

int main()
{
   int n, i, ans;
   cin >> n;
   int v[n],c[n];

   for(int i=0; i<n; i++)
   	cin>>v[i];
   for(int i=0; i<n; i++)
   	cin>>c[i];
   
   for(int i=0; i<n; i++)
   {
   	v[i] = v[i] - c[i];
   	if(v[i]>0)
   		ans+=v[i];
   }

   ans = max(0,ans);
   cout<<ans;
   cout << endl;
   return 0;
}
 

Measured memory_bytes: 256
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


n = int(input())
A = list(map(int, input().split()))
all_pattern = n * (n+1) // 2
check = all_pattern // 2 + bool(all_pattern % 2)
X = sorted(A)

left = 0
right = n

while left + 1 < right:
    idx = (left+right) // 2
    x = X[idx]
    up_or_down = [1 if num >= x else -1 for num in A]
    cumsum = [n]
    total = n
    for point in up_or_down:
        total += point
        cumsum.append(total)

    tree = Bit(2*n+1)
    pattern = 0
    for p in cumsum:
        pattern += tree.sum(p)
        tree.add(p, 1)

    if pattern >= check:
        left = idx
    else:
        right = idx

print(X[left])


Measured memory_bytes: 123364
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int b,c,d=0,e,f;cin>>b>>c;
  string a;cin>>a;
  int g[b];
  rep(i,b){
    g[i]=0;
      if(a[i-1]=='A'&&a[i]=='C')d++;
        g[i]=d;
    }
  rep(i,c){
    cin>>e>>f;
    cout<<g[f-1]-g[e-1]<<endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans = gcd(a,b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define N 100005
using namespace std;
int n, m;
int a[N];
bool can[N];
ll f[N];
int main() {
  scanf ("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf ("%d", &a[i]), can[a[i]] = 1;
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (can[i] == 1) continue;
    f[i] = (f[i - 1] + f[i - 2]) % MOD;
  }
  cout << f[n] << endl;
  return 0;
}


Measured memory_bytes: 1280