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

using namespace std;
const int maxn = 200005;
vector<vector<int>> G = vector<vector<int>>(maxn,vector<int>());
bool vis[maxn];
int   dp[maxn];
int g = INT_MIN;

int dfs(int v) {
    vis[v] = true;
    int ans = 0;
    for(int& i : G[v]) {
        if (vis[i]) ans = max(ans, dp[i]+1);
        else ans = max(ans, dfs(i)+1);
    }
    dp[v] = ans;
    g = max(g, ans);
    return ans;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m;
    cin >> n >> m;
    memset(vis, 0, sizeof vis);
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
    }
    for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i);
    cout<<g<<endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL N, X, M;
    cin >> N >> X >> M;
    map<int, int> mp;
    LL res = X;
    mp[X] = 1;
    for(LL i = 2; i <= N; ++i) {
        X = X % M * X % M;
        if(mp[X] != 0) {
            res += X;
            LL l = i - mp[X];
            mp.clear();
            LL t = X;
            LL sum = 0;
            while(!mp[t]) {
                mp[t] = true;
                t = t % M * t % M;
                sum += t;
            }
            res += ((N - i) / l) * sum;
            N = (N - i) % l;
            while(N--) {
                X = X % M * X % M;
                res += X;
            }
            break;
        }
        mp[X] = i;
        res += X;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 5896
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define INF 1000000000
 
vector <int> L[100001];
int V[100001];
queue<int> vv;

int main(){
    int N;
    cin >> N;
    int inp0, inp1;
    REP(i,N-1){
        cin >> inp0 >> inp1;
        L[inp0].push_back(inp1);
        L[inp1].push_back(inp0);
    }
    //fill(V, V+100001, INF);

    bool fe;
    int fnum = 0;
    int snum = 0;
    vv.push(1);
    vv.push(N);
    //f:1 s:-1
    V[1] = 1;
    V[N] = -1;
    int path = 0;
    while(!vv.empty()){
        int p = vv.front();
        if(V[p] == 1) fe = true;
        else fe = false;
        vv.pop();
        for(int i = 0; i < L[p].size(); i++){
            int next = L[p][i];
            if(V[next] != 0) continue;
            vv.push(next);
            V[next] = V[p];
            if(fe) fnum++;
            else snum++;
        } 
    }

    //printf("f:%d\ts:%d\n",fnum,snum);
    if(fnum > snum)
        cout << "Fennec" << endl;
    else
        cout << "Snuke" << endl;
    return 0;
}


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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n;

int main()
{
    read(n);
    if(n%2==0)return puts("-1"),0;
    int k=0,ans=0;
    while(1){
        k=k*10+7,k%=n;
        ans++;
        if(!k)break;
        if(ans>5e7)return puts("-1"),0;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	int cnt = 0;
	REP(i, n) {
		int f;
		cin >> f;
		if (f < a || f >= b)cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#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 mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

ll a[N];
int main(){
    std::ios::sync_with_stdio(false);
    int n,x;
    cin>>n>>x;
    rep(i,1,n)
        cin>>a[i];
    ll cnt=0;
    rep(i,1,n){
        int t=a[i]+a[i-1];
        if(t>x){
            cnt+=t-x;
            a[i]-=(t-x);
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
using T=pair<int,p32>;
int t,n,m,k,x,y,s;
const int MAXA=55,MAXN=55;
vector<T> adj[MAXN];
vp32 rate(MAXN);

vector<vector<int>> dist(MAXN,vector<int>(MAXN*MAXA,-1));

int32_t main()
{
    IOS;
    cin>>n>>m>>s;
    s=min(s,MAXN*MAXA-1);
    forn(i,m){
      int a,b;
      cin>>x>>y>>a>>b;
      adj[x].pb({y,{a,b}});
      adj[y].pb({x,{a,b}});
    }
    forsn(i,1,n+1) cin>>rate[i].fi>>rate[i].se;
    //now apply dijkstra
    priority_queue<T,vector<T>,greater<T> > pq;
    dist[1][s]=0;
    pq.push({0,{1,s}});
    while(!pq.empty()){
      auto t=pq.top();
      pq.pop();

      //go to all the next
      int i=t.se.fi;
      int j=t.se.se;
      
      // if(dist[i][j]!=-1) continue;

      int c=rate[i].fi; //coins
      int d=rate[i].se; //time
      
      if(j+c<MAXN*MAXA){
          if(dist[i][j+c]==-1 || dist[i][j+c]>dist[i][j]+d){
            dist[i][j+c]=dist[i][j]+d;
            pq.push({dist[i][j+c],{i,j+c}});
          }
      }

      for(auto next: adj[i]){
        int v=next.fi; //node
        int a=next.se.fi; //coins
        int b=next.se.se; //time
        if(j>=a){
          if(dist[v][j-a]==-1 || dist[v][j-a]>dist[i][j]+b){
            dist[v][j-a]=dist[i][j]+b;
            pq.push({dist[v][j-a],{v,j-a}});
          }
        }
      }

    }
    // dbg(dist[1][2]);
    forsn(i,2,n+1){
      int ans=-1;
      forn(j,MAXA*MAXN){
        if(dist[i][j]==-1) continue;
        if(ans==-1 || dist[i][j]<ans) ans=dist[i][j];
      }
      cout<<ans<<ln;
    }
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a-b)%c << endl;

}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int n1=0,n2=0,n4=0;
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		switch(t%4){
			case 2:
				n2++;
				break;
			case 0:
				n4++;
				break;
			default:
				n1++;
				break;
		}
	}
	//cout << n1 << " " << n2 << " " << n4 << endl;
	bool flag=false;
	if(n1==n4+1 && n2%2==0)flag=true;
	else if(n1<=n4) flag=true;
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int A_MAX = 100000+50;

long N,MAX;
long cards[A_MAX] = {};

long calcRight(long c){
  for(long i=c+1;i<=MAX;i++)
    if(cards[i]>=2) return i;
  return -1;
}

long calcLeft(long c){
  for(long i=c-1;i>=0;i--)
    if(cards[i]>=2) return i;
  return -1;
}

long calcNum(){
  long sum = 0;
  for(long i=0;i<=MAX;i++)
    if(cards[i]>=1)sum++;
  return sum;
}

int main(){
  MAX = 0;
  cin >> N;
  for(long i=0;i<N;i++){
    long a;
    cin >> a;
    cards[a]++;
    
    if(MAX < a) MAX = a;
  }

  int head = 0,tail = MAX;

  while(true){
    if(cards[head] <= 1)
      head = calcRight(head);
    if(cards[tail] <= 1)
      tail = calcLeft(tail);
    
    if(head == -1){
      cout << calcNum() << endl;
      return 0;
    }
    if(head == tail){
      if(cards[head]%2==0){
	cout << calcNum()-1 << endl;
	return 0;
      }else{
	cout << calcNum() << endl;
	return 0;
      }      
    }
    cards[head]--;
    cards[tail]--; 
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);

  if( N == 1 ){
    cout << abs(A.at(0)-Y) << endl;
    return 0;
  }

  int ans = max(abs(A[N-1]-A[N-2]), abs(A[N-1]-Y));
  cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
c=[0]*5
for i in range(N):
    S=input()
    a=S[0]
    if a=="M":
        c[0]+=1
    if a=="A":
        c[1]+=1
    if a=="R":
        c[2]+=1
    if a=="C":
        c[3]+=1
    if a=="H":
        c[4]+=1
ans=0

for i in range(5):
    for j in range(5):
        for k in range(5):
            if i<j<k:
                ans+=c[i]*c[j]*c[k]
print(ans)


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

int main(void) {
	int n,d1,d2,cnt = 0;

	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> d1 >> d2;

		if (d1 == d2) {
			cnt++;
		}
		else {
			cnt = 0;
		}

		if (cnt == 3) {
			cout << "Yes" << endl;
			break;
		}
		else if(i == n-1){
			cout << "No" << endl;
		}
	}
}

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

int main(int argc, const char * argv[]) {
    int N, D;
    cin >> N;
    cin >> D;
    
    int man = 0;
    int tree = 0;
    do {
        tree += 2 * D + 1;
        man++;
    }while(tree < N);
    
    cout << man << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <math.h>
#include<stdio.h>
int main()
{
	char a[4];
	gets(a);
	int i=0, j=0, k=0;
	for (int n = 0; n < 4; n++)
	{
		switch (a[n])
		{
		case 'a':i++; break;
		case 'b':j++; break;
		case 'c':k++; break;
		}
	}
	if (i&&j&&k)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
import java .util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int W=sc.nextInt();
        int H=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
        if(x+r>W||y+r>H||x>W||y>H||x<0||y<0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 26352
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
ans=sum(B)
for i in range(n-1):
	if A[i]+1==A[i+1]:
		ans+=C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    long long int X;
    cin >> N >> X;
    vector<long long int> v1,v2;
    for(int i = 0;i < N;i++)
    {
        long long int x;
        cin >> x;
        v1.push_back(fabs(x - X));
    }
    if(v1.size() >= 2)
    {
        while(v1.at(0) % v1.at(1) != 0)
        {
            long long int r = v1.at(0) % v1.at(1);
            v1.at(0) = v1.at(1);
            v1.at(1) = r;
        }
        v2.push_back(v1.at(1));
        for(int i = 0;i + 2 < N;i++)
        {
            while(v2.at(i) % v1.at(i + 2) != 0)
            {
                long long int r = v2.at(i) % v1.at(i + 2);
                v2.at(i) = v1.at(i + 2);
                v1.at(i + 2) = r; 
            }
            v2.push_back(v1.at(i + 2));
        }
        cout << v2.at(v2.size() - 1);
    }
    else
    {
        cout << v1.at(0);
    }

    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll ceil1(ll n,ll m){
    if(n%m==0){return n/m;}
    return n/m +1;}


void solve(){
	ll i,j,k,n;
    cin>>n;
    map<string,ll> mp;
    string s;
    for(i=0;i<n;i++){
    	cin>>s;
    	mp[s]++;
    }
    ll t=0;
    for(auto x: mp){
    	t=max(t,x.second);
    }
    vector<string> sss;
    for(auto x:mp){
    	if(x.second==t){
    		sss.push_back(x.first);
    	}
    }
    sort(sss.begin(),sss.end());
    
    for(auto u:sss)
    {
    	cout<<u<<endl;
    }
    
    
    
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 25584
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#define ll long long 
#define dd double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<pair<pair<string,int>,int>> v;
  int i;
  string s;
  int p;
  for(i=0;i<n;i++){
  	cin>>s>>p;
  	v.push_back(make_pair(make_pair(s,-p),i+1));
  	
  }
  
//  cout<<endl;
//  for(i=0;i<n;i++){
//  	cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
//  }
  
  sort(v.begin(),v.end());
//  cout<<endl;
//  for(i=0;i<n;i++){
//  	cout<<v[i].first.first<<" "<<v[i].first.second<<" "<<v[i].second<<endl;
//  }
  
//  cout<<endl;
    for(i=0;i<n;i++){
  	cout<<v[i].second<<endl;
  }
  
  return 0;
} 

Measured memory_bytes: 3684
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let count: usize = read();
    let mut numbers: Vec<u16> = vec![];

    for _ in 0..count {
        let number: u16 = read();
        numbers.push(number);
    }

    for index in 1..count {
        for (i, number) in numbers.iter().enumerate() {
            if i != (numbers.len() - 1) {
                print!("{} ", number);
            } else {
                println!("{}", number);
            }
        }
        let v = numbers[index];
        let mut j = (index - 1) as i32;
        while j >= 0 && numbers[j as usize] > v {
            numbers[(j + 1) as usize] = numbers[j as usize];
            j -= 1;
        }
        numbers[(j + 1) as usize] = v;
    }

    for (i, number) in numbers.iter().enumerate() {
        if i != (numbers.len() - 1) {
            print!("{} ", number);
        } else {
            println!("{}", number);
        }
    }
}



Measured memory_bytes: 5036
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> A(m);
    REP(i, m) {
        cin >> A[i];
        n -= A[i];
    }
    if (n < 0) {
        cout << -1 << endl;
    }
    else {
        cout << n << endl;
    }
}

Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
		for (int i = 0; i < M; i++) {
			max = Math.max(max, sc.nextInt());
			min = Math.min(min, sc.nextInt());
		}
		out.println(Math.max(0, min - max + 1));
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 41076
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define swap(type,a,b) { type temp = a; a = b; b = temp; }
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}

int main(void) {
	// your code goes here
	int n,m,x,y,i,j,k,a[101],b[101];
	scanf("%d %d %d %d",&n,&m,&x,&y);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=m;i++) scanf("%d",&b[i]);
	for(i=x+1;i<=y;i++){
		int flag=0;
		for(j=1;j<=n;j++){
			if(a[j]>=i) flag++;
		}
		for(j=1;j<=m;j++){
			if(b[j]<i) flag++;
		}
		if(flag==0) {
			printf("No War\n");
			return 0;
		}
	}
	printf("War\n");
	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n ; cin >>n;
  vector<ll> x(n);
  vector<ll> X(n);
  rep(i,n) cin >>x[i];
  rep(i,n) X[i]=x[i];
  sort(all(x));
  ll first=x[n/2-1];
  ll second=x[n/2];
  rep(i,n){
    if(X[i]<second)cout << x[n/2]<<endl;
    else cout <<x[n/2-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 6488
### main

w, h, n = gets.strip.split(' ').map{|s| s.to_i}

pts = n.times.map{gets.strip.split(' ').map{|s| s.to_i - 1}}

x0, y0 = pts.shift
sumd = 0

for pt1 in pts
  x1, y1 = pt1
  dx = x1 - x0
  dy = y1 - y0

  if dx < 0
    dx = -dx
    dy = -dy
  end

  if dy >= 0
    sumd += [dx, dy].max
  else
    sumd += (dx - dy)
  end

  x0, y0 = x1, y1
end

puts sumd

Measured memory_bytes: 6120
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, t, s; cin >> d >> t >> s;
    if ((d + s - 1) / s <= t) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,t;
  cin >> n >> t;
  
  int ti[n];
  REP(i,n){
    cin >> ti[i];
  }
  
  int ans = t;
  int before = 0;
  REP(i,n){
    if(ti[i] - before < t) ans += ti[i] - before;
    else ans += t;
    before = ti[i];
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm> 
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    long long N;
    long long mn = 1145141919810893;
    long long k=0;
    long long sum=0;
    long long a[214514];
    cin >> N;
    REP(i,N){cin >> a[i];sum+=a[i];}
    REP(i,N-1){
        k+=a[i];
        mn=min(mn,abs(sum-2*k));
    }
    
    cout << mn << endl;
return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func xor(n int) int {
	if n%4 == 0 {
		return n
	} else if n%4 == 1 {
		return 1
	} else if n%4 == 2 {
		return 1 ^ n
	} else {
		return 0
	}
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(xor(a-1) ^ xor(b))
}


Measured memory_bytes: 512
import java.util.*;

class Main{
	public static void main (String[] args ){
		int x,y;
		int z = 0;
		Scanner in = new Scanner(System.in);
		while(true){
			x = in.nextInt();
			y = in.nextInt();
			if( x == 0 && y == 0){
				break;
			}else if (x <= y ){
				System.out.println(String.valueOf(x) + ' ' + String.valueOf(y));
			} else {
				System.out.println(String.valueOf(y) + ' ' + String.valueOf(x));
			}
		}
	}
}

Measured memory_bytes: 27152
#include<stdio.h>

#define INFTY 10000
#define black 2
#define gray 1
#define white 0
#define MAX 100

int n,A[MAX][MAX];

int prim()
{
  int i,v,u,min_v;
  int a[MAX],b[MAX],IRO[MAX];

  for(i=0;i<n;i++)
    {
      a[i] = INFTY;
      b[i] = -1;
      IRO[i] = white;
    }

  a[0] = 0;

  while(1)
    {
      min_v = INFTY;
      u = -1;
      for(i=0;i<n;i++)
	{
	  if(min_v > a[i] && IRO[i] != black)
	    {
	      u = i;
	      min_v = a[i];
	    }
	}
      if(u==-1) break;
      IRO[u] = black;
      for(v=0;v<n;v++)
	{
	  if(IRO[v] != black && A[u][v] != INFTY)
	    {
	      if(a[v]>A[u][v])
		{
		  a[v]=A[u][v];
		  b[v] = u;
		  IRO[v] = gray;
		}
	    }
	}
    }
  int sum =0;

  for(i=0;i<n;i++)
    {
      if(b[i] != -1) sum += A[i][b[i]];
    }

  return sum;
}

int main()
{
  int e,i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&e);
	  A[i][j] = (e==-1) ? INFTY : e;
	}
    }
  printf("%d\n",prim());


  return 0;
}
  
      



Measured memory_bytes: 2744
#include <cstdio>
#include <cstdlib>
typedef struct {
	long long cost, ddl;
} St;

int n;
St a[200005];

int cmp(const void *a, const void *b)
{
	St x = *(St *) a, y = *(St *) b;
	return x.ddl > y.ddl ? 1: -1;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i].cost, &a[i].ddl);
	}
	qsort(a, n, sizeof(a[0]), cmp);
	long long time = 0;
	int flag = 1;
	for (int i = 0; i < n; i++) {
		time += a[i].cost;
		if (time > a[i].ddl) {
			flag = 0;
			break;
		}
	}
	if (flag)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() 
{
  ll n;
  cin>>n;
  ll a[n],b[n],c[n];
  for( ll i=0;i<n;i++)
  {
      cin>>a[i]>>b[i]>>c[i];
  }
  ll dp[3][n];
  dp[0][0]=a[0];
  dp[1][0]=b[0];
  dp[2][0]=c[0];
  for(ll i=1;i<n;i++)
  {
      dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
      dp[1][i]=b[i]+max(dp[2][i-1],dp[0][i-1]);
      dp[2][i]=c[i]+max(dp[0][i-1],dp[1][i-1]);
      
  }
  ll s=max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]);
  cout<<s<<endl;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 1;

    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    while ((a-1)*(ans-1) + a < b) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main() {
    int a[100];
    int n, i;
    
    cin >> n;
    
    for (i=0; i<n; i++){
        cin >> a[i];
    }
    
    for (i=0; i<n-1; i++){
        cout << a[n-i-1] << " ";
    }
    
    cout << a[0] << endl;
}


Measured memory_bytes: 3092
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n, l = rli()
s = []
for i in range(n):
    s.append(input())
s.sort()
print(pli(s))


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

#define MAX 200
int n;
vector<vector<int>> adj_mat(MAX, vector<int>(MAX, 0));

queue<int> q;
vector<int> visited(MAX, -1);
vector<int> d(MAX, -1);

void add_queue(int node){
    // cout << "node " << node << " unvisited & adj";
    rep(i, n){
        if(adj_mat.at(node).at(i) == 1 && visited.at(i) == -1){
            // nodeに隣接し、まだ訪れていないノード
            q.push(i);
            d.at(i) = d.at(node) + 1;
            visited.at(i) = 1;
            // cout << " " << i;

        }
    }
    // cout << endl;
}

void bfs(int node){
    q.push(node);
    d.at(node) = 0;
    visited.at(node) = 1;
    while(q.size() != 0){
        int visited_node = q.front();
        q.pop();
        // visited.at(visited_node) = 1;
        add_queue(visited_node);

    }
}

int main(){
    cin >> n;

    // 隣接行列の作成
    rep(i, n){
        int u, k; cin >> u >> k;
        rep(j, k){
            int v; cin >> v;
            adj_mat.at(u-1).at(v-1) = 1;
        }
    }

    bfs(0);
    rep(i, n){
        cout << i+1 << " " << d.at(i) << endl;
    }

}


Measured memory_bytes: 3288
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
string s;
bool flag=1;
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>s;
	if(s.size()%2) flag=0;
	for(int i=0;i<s.size();i+=2) if(s[i]!='h') flag=0;
	for(int i=1;i<s.size();i+=2) if(s[i]!='i') flag=0;
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	long long a, b, c, t;
	long long x, y, z;
	scanf("%lld %lld", &a, &x);
	scanf("%lld %lld", &b, &y);
	scanf("%lld", &t);
	if (x <= y) {
		printf("NO\n");
      return 0;
	}
	c = abs(a - b);
	z = (x - y)*t;
	if (c <= z) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 1648
A, B, C = map(int, input().split())
ans = 0
cont = True
while cont:
    if A == B == C and A%2==0 :
        ans = -1
        break
    elif A%2==0 and B%2==0 and C%2==0:
        b_A = A
        b_B = B
        b_C = C
        A = b_B//2 + b_C//2
        B = b_A//2 + b_C//2
        C = b_A//2 + b_B//2
        ans += 1
    else:
        break
print(ans)

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

// int calculatedValue(int a, int b, int c);

int calc(int a, int b, int c);

int gcd(int a, int b);

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

    vector<vector<vector<int> > > table(K + 1, vector<vector<int> >(K + 1, vector<int>(K + 1, -1)));

    int ans = 0;

    for (int a = 1; a <= K; a++)
    {

        for (int b = 1; b <= K; b++)
        {
            for (int c = 1; c <= K; c++)
            {
                //3つの数字は、a,b,c
                ans = ans + calc(a, b, c);
            }
        }
    }

    cout << ans << endl;
}

int calc(int a, int b, int c)
{
    //aとbの最大公約数を求めて、それとcの最大公約数を求める
    int temp = gcd(a, b);
    return gcd(temp, c);
}

int gcd(int a, int b)
{
    //小さい数をbにする
    if(a < b)
    {
        int temp = a;
        a = b;
        b = temp;
    }

    while(1)
    {
        //aとbの最大公約数を求めるのは、aをbで割ったあまりと、bの最大公約数を求めれば良い
        a = a%b; //このaとbの最大公約数を求めればよくなった

        if(a == 0)
        {
            return b;
        }

        int temp = a;
        a = b;
        b = temp;
    }
}



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

int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 3520
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(n-1) :
    total=a[i]+a[i+1]-x
    if total>0:
        count+=total
        if a[i+1]<total:
            a[i+1]=0
            a[i]-=total-a[i+1]
        
        else:
            a[i+1]-=total

print(count)

Measured memory_bytes: 14060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int a,b; cin >> a >> b;
    int c,d; cin >> c >> d;
  	int turn1 = (c-1+b) / b;
    int turn2 = (a-1+d) / d;
    if (turn1 <= turn2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ b.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/


Measured memory_bytes: 3612
# coding: utf-8
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

A, B, C = 0, 0, 0 #最後に各活動を行った幸福度の和
for _ in range(N):
    a, b, c = map(int, input().split())
    A, B, C = max(B, C) + a, max(C, A) + b, max(A, B) + c
ans = max(A, B, C)

print(ans)

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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << endl;
}


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

int n,m;
vector<set<int>>a;
vector<bool> vi(n);

int cnt=0;

int dfs(int x , int p) {
         if(vi[x]) return 0;
          cnt++;
         vi[x]=true;
         

         for( auto y: a[x]) {
               if(y !=p) dfs(y,x);
         }

         return cnt;
}


void solve() {
    cin>>n>>m;
a=vector<set<int>>(n);
vi=vector<bool>(n,false);

int u,v;
for(int i=0;i<m;i++) {
     cin>>u>>v;
     u-- ; v--;
      a[u].insert(v);
      a[v].insert(u);
}

//   for(int i=0;i<n;i++) {
//         for(auto x: a[i]) cout<<x<<" ";
//         cout<<endl;
//   }
int m=-1;

for(int j=0;j<n;j++) {
       cnt=0; 
   if(!vi[j]) m=max(m,dfs(j,-1));
}

cout<<m;
     
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
     freopen("in.txt","r",stdin);
      
     #endif

     int t;
     t=1;
     while(t--) solve();


   return 0;
}


Measured memory_bytes: 40612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
    int n;cin >> n;
    int g = pow(10,6);
    vec d(g);
    vec a(n);
    rep(i, n){
        cin >> a[i];
    }
    for(int x : a){
        if(d[x] != 0){
            d[x] = 2;
            continue;
        }
        for(int i = x;i <= g;i += x){
            d[i]++;
        }
    }
    int sum = 0;
    for(int x: a){
        if(d[x] == 1){
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 7952
N = int(input())
counts = [0]*4
for _ in range(N):
  s = input()
  if s == "AC":
    counts[0] += 1
  elif s == "WA":
    counts[1] += 1
  elif s == "TLE":
    counts[2] += 1
  else:
    counts[3] += 1
print("AC x {}".format(counts[0]))
print("WA x {}".format(counts[1]))
print("TLE x {}".format(counts[2]))
print("RE x {}".format(counts[3]))

Measured memory_bytes: 9216
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

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

  char now='a';
  while(true){
    switch(now){
      case 'a':
        if(a.size()==0){
          cout<<"A"<<endl;
          return 0;
        }
        now=a[0];
        a=a.substr(1);
        break;
      case 'b':
        if(b.size()==0){
          cout<<"B"<<endl;
          return 0;
        }
        now=b[0];
        b=b.substr(1);
        break;
      case 'c':
        if(c.size()==0){
          cout<<"C"<<endl;
          return 0;
        }
        now=c[0];
        c=c.substr(1);
        break;
    }
  }

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size(),x;
  
  int min=1000;
  for (int i=0;i<n-2;i++) {
    int a=s.at(i)-'0',b=s.at(i+1)-'0',c=s.at(i+2)-'0';
    x = 100*a+10*b+c;
    if (min > abs(x-753)) {
      min = abs(x-753);
    }
  }
  
  cout << min;
}

Measured memory_bytes: 256
N = int(input())
G = {k: [] for k in range(N)}
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        G[i].append((x-1, y))

ans = 0
for i in range(2 ** N):
    flg = True
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            for x, y in G[j]:
                if (i >> x) & 1 != y:
                    flg = False
    if flg:
        c = 0
        for k in range(N):
            if ((i >> k) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                c += 1
        ans = max(ans, c)

print(ans)


Measured memory_bytes: 42604
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  vector<int> vc{};
  for (int i = 1; i <= 100000; i += 2) {
    if (isSosuu(i) && isSosuu((i+1) / 2)) {
      vc.push_back(i);
    }
  }
  boost::sort(vc, std::less<int>());
  int Q; cin >> Q;
  for (int _ = 0; _ < Q; ++_) {
    int l, r; cin >> l >> r;
    auto itrL = boost::lower_bound(vc, l);
    auto itrR = boost::upper_bound(vc, r);
    auto distance = std::distance(itrL, itrR);
    cout << distance << CRLF;
  }

  return;
}

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

  solve();

  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;

int n;
vector<vector<int>> g(150000+5);
vector<vector<pair<double,double>>> vp(150000+5);
double ans[150000+5];

void dfs1(int now,int par){
    int size=g[now].size();
    if (par!=-1) size-=1;
    for(auto nx: g[now]){
        if (nx==par) continue;
        dfs1(nx,now);
    }
    double v=0.0;
    double p=0.0;
    for (auto nx: g[now]){
        if (nx==par) continue;
        v+=(vp[nx][0].fi+vp[nx][0].se)/size;
        p+=vp[nx][0].se/size;
    }
    if (p==0.0) vp[now].pb(make_pair(0.0,1.0));
    else vp[now].pb(make_pair(v,p));
    return ;
}

void dfs2(int now,int par,double v,double p){
    double sumv=0.0;
    double sump=0.0;
    int size=g[now].size();
    for(auto nx: g[now]){
        if (nx==par){
            ans[now]+=v/size+p/size;
            sumv+=v+p;
            sump+=p;
        }
        else{
            ans[now]+=vp[nx][0].fi/size+vp[nx][0].se/size;
            sumv+=vp[nx][0].fi+vp[nx][0].se;
            sump+=vp[nx][0].se;
        }
    }
    for(auto nx: g[now]){
        if (nx==par) continue;
        if (size==1) dfs2(nx,now,0,1.0);
        else dfs2(nx,now,(sumv-(vp[nx][0].fi+vp[nx][0].se))/(size-1),(sump-vp[nx][0].se)/(size-1));
    }
    return ;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        u--;v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs1(0,-1);
    //cout << vp[0][0].fi << vp[0][0].se << endl;
    //rep(i,12) cout << vp[i][0].fi << vp[i][0].se << endl;
    dfs2(0,-1,0.0,0.0);
    rep(i,n) cout << fixed << setprecision(10) << ans[i] << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;++i)
#define SET(a,c) memset(a,c,sizeof(a))

const int MAX_N = 100;
const int INF = 0x3F3F3F3F;

int n, d[MAX_N], G[MAX_N][MAX_N] = {0};

void bfs(int s) {
  int u;
  queue<int> q;
  q.push(s);
  SET(d, INF);
  d[s] = 0;
  while (!q.empty()) {
    u = q.front(); q.pop();
    REP(v, n) {
      if (!G[u][v]) continue;
      if (d[v] != INF) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  REP(i, n) cout << i + 1 << ' ' << ( (d[i] == INF) ? (-1) : d[i] ) << endl;
}

int main() {
  int u, k, v;
  cin >> n;
  REP(i, n) {
    cin >> u >> k;
    REP(j, k) {
      cin >> v;
      G[u - 1][v - 1] = 1;
    }
  }
  bfs(0);
  return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) cout << "bust" << endl;
  else if (a + b + c <= 21) cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll A[100002], B[100002];
bool one[100002];
ll n, k;
int main(){
    cin >> n >> k; 
    ll total = 0;
    for (int i = 0; i < n; i ++) {
        cin >> A[i] >> B[i];
        if (A[i] <= k) {
            total += B[i];
            one[i] = 1;
        }else one[i] = 0;
    }
    ll logk = 0, kk = k << 1;
    while (kk >>= 1 > 0) logk ++;
    ll ans = 0;
    for (int i = logk - 1; i >= 0; i --) {
        if ((k >> i) & 1) {
            ll tmp = total;
            for (int j = 0; j < n; j ++) {
                if (one[j] && ((A[j] >> i) & 1) == 1) tmp -= B[j];
            }
            ans = max(ans, tmp);
        } else {
            for (int j = 0; j < n; j ++) {
                if (((A[j] >> i) & 1) == 1 && one[j]) {
                    total -= B[j];
                    one[j] = 0;
                }
            }
        }
    }
    ans = max(ans, total); 
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 1920
N,M = map(int,input().split())

Problem = [[] for _ in range(N)]

for i in  range(M):
    p,S = input().split()
    p = int(p) - 1
    if (len(Problem[p])==0) or (len(Problem[p])>0 and Problem[p][-1]=='WA'):
        Problem[p].append(S)
ans_AC = 0
ans_WA = 0

for i in range(N):
    if 'AC' in Problem[i]:
        ans_AC += 1
        ans_WA += Problem[i].count('WA')

print('{} {}'.format(ans_AC,ans_WA))

Measured memory_bytes: 20376
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;
int dp[3010][3010][2] = {0};

//----------------------------------------------------------------
signed main(){
   
    int n;
	cin >> n;
	vll a(n);
	int s = 0;

	rep(i,n){
		cin >> a[i];
		s += a[i];
	}

	int x = 0,y = 0,z = 0;
	rep(i,n){
		if(x + a[i] == s/2){
			cout << 0 << endl;
			return 0;
		}
		if(x + a[i] < s/2){
			x += a[i];
		}else{
			y = a[i];
			z = s - x - a[i];
			break;
		}
	}

	cout << min(abs(x+y-z),abs(-x+y+z)) << endl;



	
	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_b

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

using namespace std;
typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


const int q = 1e9+9;


int main()
{
    int n,ans=0;
    cin>>n;
    if(n<4){
        cout<<"No"<<endl;
        return 0;
    }
    if(n%4==0 || n%7==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        ans=n;
        while(ans>3){
            ans-=4;
            if(ans%7==0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        ans=n;
        while(ans>3){
            ans-=7;
            if(ans%4==0){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

    return 0;
}
// gotcha;


Measured memory_bytes: 256