akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;

class State{
public:
  string str;
  int cnt;
};

int bfs(string s, string t, vector<string> &input, map<string, string> &conv){
  State u, v;
  queue<State> Q;
  u.str = s;
  u.cnt = 0;
  Q.push(u);
  while(!Q.empty()){
    u = Q.front(); Q.pop();
    //cout << "======= " << u.str << ' ' << u.cnt << endl;
    if(u.str == t) return u.cnt;
    for(int i=0;i<input.size();i++){
      bool change = false;
      string now = u.str;
      for(int j=0;j+(int)input[i].size()<=now.size();j++){
	bool same = true;
	for(int k=0;k<input[i].size();k++){
	  if(now[j+k] != input[i][k]){
	    same = false;
	    break;
	  }
        }
	if(same){
	  //cout << now << ' ' << input[i] << ' ';
	  change = true;
          string tmp = "";
	  for(int k=0;k<j;k++){
	    tmp += now[k];
	  }
          tmp += conv[input[i]];
          for(int k=j+(int)input[i].size();k<now.size();k++){
            tmp += now[k];
          }
	  now = tmp;
	  j += (int)conv[input[i]].size()-1;
	  //cout << now << ' ' << j << endl;
        }
      }
      if(change){
	v.str = now;
	v.cnt = u.cnt+1;
	if(v.str.size() > t.size()) continue;
	Q.push(v);
      }
    }
  }
  return -1;
}
  
main(){
  int n;
  while(cin >> n){
    if(n == 0) break;
    vector<string> input;
    map<string, string> conv;
    for(int i=0;i<n;i++){
      string a, b;
      cin >> a >> b;
      input.push_back(a);
      conv[a] = b;
    }
    string s, t;
    cin >> s >> t;
    cout << bfs(s, t, input, conv) << endl;
  }
  return 0;
}

Measured memory_bytes: 1084
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a>=13)printf("%d\n", b);
    else if(a>=6)printf("%d\n", b/2);
    else printf("0\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool check(int n){
    if(n%3==0||n%5==0) return false;
    else return true;
}
int main(){
    int n;
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(check(i)==true) ans+=i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, arr[85], pre=1;
ll ans = 1000;

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> arr[i];
	FOR(i, 1, n) {
		if (i == n or arr[i] > arr[i+1]) {
			ll cur = ans/arr[pre]; ans %= arr[pre];
			ans += cur * arr[i];
			pre = i+1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n;
    cin >> n;
    vector<i64> x(n);
    for (int i = 0; i < n; ++i) cin >> x[i];
    i64 ans = 1ll << 60;
    for (int p = 1; p <= 100; ++p) {
        i64 scr = 0;
        for (int i = 0; i < n; ++i) {
            int a = x[i] - p;
            scr += a * a;
        }
        ans = min(ans, scr);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    vector <int>v;
    int n;
    cin >> n;
    bool prime[n+100]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n+100; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n+100; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n+100; p++)
    { 
       if (prime[p]) 
          v.push_back(p);
    }
    for (int i = 0; i < n+100; ++i)
    {   
        if(v[i] >= n)
        {
            cout << v[i];
            return 0;
        }
    }
    return 0;
}

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

int main(){
  list<int>A;
  int n;
  scanf("%d",&n);
  char c[20];int t;
  for(int i=0;i<n;i++){
    scanf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&t);
      A.push_front(t);
    }
    else if(c[6]=='F'){
      A.pop_front();
    }
    else if(c[6]=='L'){
      A.pop_back();
    }
    else if(c[0]=='d'){
      scanf("%d",&t);
      for(list<int>::iterator it =A.begin();it!=A.end();it++){
        if(*it == t){
          A.erase(it);
          break;
        }
      }
    }
  }
  int i=0;
  for(list<int>::iterator it=A.begin();it!=A.end();it++){
    if(i++){cout << " ";}
    cout << *it;
  }
  cout <<endl;
}


Measured memory_bytes: 34372
// https://atcoder.jp/contests/dp/tasks/dp_a

#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N;
  cin >> N;

  V<ll> hs(N);
  rep(i, 0, N) cin >> hs[i];

  ll INF = 1e18;

  V<ll> dp(N, INF);
  dp[0] = 0;

  rep(i, 0, N) {
    if (i + 1 < N) {
      chmin(dp[i + 1], dp[i] + abs(hs[i + 1] - hs[i]));
    }

    if (i + 2 < N) {
      chmin(dp[i + 2], dp[i] + abs(hs[i + 2] - hs[i]));
    }
  }

  cout << dp[N - 1] << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, 0, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	int ans = 1;
	for (int i = 2; i <= 31; ++i) {
		for (int j = 2; j <= 9; ++j) {
			int now = pow(i, j);
			if (now > x) continue;
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
ll MOD = 1000000007;

ll x[110],y[110],h[110];
int main(){
   ios::sync_with_stdio(false);
   cin.tie(0);

   ll n;
   cin >> n;
   for(int i=0; i < n; i++) cin >> x[i] >> y[i] >> h[i];

   for(ll cx=0; cx <= 100; cx++){
       for(ll cy=0; cy <= 100; cy++){
           ll th;
           for(int i=0; i < n; i++){
                th=h[i] + abs(x[i] - cx) + abs(y[i] - cy);
                if(h[i] != 0)break;
           }
           ll H;
           bool f = true;
           for(int i=0; i < n; i++){
               H = max(ll(0),th - abs(x[i] - cx) - abs(y[i] - cy));
               if(H != h[i]){
                   f = false;
                   break;
               }
           }
          
           if(f){
               cout << cx << " " <<  cy << " " << th << endl;
               return 0;
           }
       }
   }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main()
{
	int N, X, T;
	cin >> N >> X >> T;

	int x, t;
	x = X;
	t = T;

	while (true)
	{
		if (x >= N) break;
		x += X;
		t += T;
	}

	cout << t;

	return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define L first
#define R second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int S[] = {-1, 0, 1, 2, 0, -1, 2, 0, 1, 2};

int main(void){
    int res;
    for(string steps; cin >> steps, steps != "#"; cout << res << endl){
        res = inf;
        pii foot = mp(1, 1);
     
        rep(z, 2){
            int cnt = 0;
            bool isR = !z;

            rep(i, steps.size()){
                int next = S[steps[i] - '0'];
                if(i == 0){
                    if(isR) foot.R = next;
                    else    foot.L = next;
                    isR = !isR;
                    continue;
                }
                if(isR){
                    if(foot.L <= next){
                        foot.R = next;
                        isR = !isR;
                    }
                    else{
                        foot.L = next;
                        cnt++;
                    }
                }
                else{
                    if(next <= foot.R){
                        foot.L = next;
                        isR = !isR;
                    }
                    else{
                        foot.R = next;
                        cnt++;
                    }
                }
            }
            res = min(res, cnt);
        }
    }

	return 0;
}

Measured memory_bytes: 1316
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)



int main() {
	int n, m,ans,maxv=-1;
	string s,key;
	map<string, int> mp1, mp2;
	cin >> n;
	rep(i, n) {
		cin >> s;
		mp1[s]++;
	}
	cin >> m;
	rep(i, m) {
		cin >> s;
		mp2[s]++;
	}

	for (auto itr = mp1.begin(); itr !=mp1.end(); ++itr) {
		key = itr->first;
		ans = itr->second;

		if (mp2[key] != 0) ans -= mp2[key];
		if (max(maxv, ans) == ans) {
			maxv = ans;
		}
	}
	if (maxv < 0) maxv = 0;
	cout << maxv << endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  vector<int> h(N);
  REP(i, N) cin >> h[i];
  sort(ALL(h));

  int ok = h[N-1];
  int ng = -1;
  while(ok-ng > 1){
    int mid = (ok+ng)/2;
    int cnt = 0;
    REP(i, N){
      if(h[i]-mid*B > 0) cnt += (h[i]-mid*B+(A-B)-1)/(A-B);
    }
    if(cnt <= mid) ok = mid;
    else ng = mid;
  }

  cout << ok << endl;

  return 0;
}

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



int main(){
    int N;
    cin>>N;
vector<long double> x(N);
vector<string> S(N);
long double sum=0.0;
for (int i=0;i<N;i++){
    cin>>x.at(i)>>S.at(i);
    if(S.at(i)=="BTC"){
        x.at(i)*=380000.0;
    }
}
for(int i=0;i<N;i++){
   sum+=x.at(i);
}
cout<<sum<<endl;
}



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

int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<vector<int>>data(N,vector<int>(M+1));
  for(int i=0;i<N;i++){
    for(int j=0;j<M+1;j++){
      cin >> data.at(i).at(j);
    }
  }
  int ans=10000000;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bool b=true;
    for(int i=1;i<M+1;i++){
      int a=0;
      for(int j=0;j<N;j++){
        if(tmp&(1<<j)){
          a+=data.at(j).at(i);
        }
      }
      if(a<X) b=false;
    }
    if(b){
      int x=0;
      for(int j=0;j<N;j++){
        if(tmp&(1<<j)) x+=data.at(j).at(0);
      }
      ans=min(ans,x);
    }
  }
  if(ans==10000000) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 3600
#119_C
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9

def dfs(x,a,b,c):
    if x==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    res0=dfs(x+1,a,b,c)
    res1=dfs(x+1,a+l[x],b,c)+10
    res2=dfs(x+1,a,b+l[x],c)+10
    res3=dfs(x+1,a,b,c+l[x])+10
    return min(res0,res1,res2,res3)
    
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int b[]=sc.nextIntArray(n-1);
        long s=0,p=0;
        s=b[0]*2;

        for (int i = 1; i < b.length; i++) {
        	if(b[i]<b[i-1]) {
        		s-=b[i-1];
        		s+=b[i]*2;
        	} else 
        	s+=b[i];
		}
        
        out.println(s);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21204
//============================================================================
// Name        : AOJ.cpp
// Author      : a
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int X;
	cin >> X;
	cout << X*X*X << endl; // prints !!!Hello World!!!
	return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

int main()
{
	ll n,m;
	cin>>n>>m;

	vector<ll> v1[m];

	for(ll i = 0 ; i < m ; i++)
	{
		ll t1;
		cin>>t1;

		for(ll j = 0 ; j < t1; j++)
		{
			ll t2;
			cin>>t2;
			t2--;
			v1[i].push_back(t2);
		}
	}

	ll p[m];

	for(ll i = 0 ; i < m ; i++)
	{
		cin>>p[i];
	}

	ll ans = 0;

	for(ll i = 0 ; i < (1<<n) ; i++)
	{
		map<ll,ll> hm;

		vector<ll> v(n,0);

		ll t3 = i;

		ll cnt = n;
		
		ll x = 0;
		
		while(cnt)
		{
			if(t3 % 2 == 1)
			{
				v[x] = 1;
			}

			t3 /= 2;
			cnt--;
			x++;
		}

		reverse(v.begin(),v.end());

		for(ll k = 0 ; k < n ; k++)
		{
			hm[k] = v[k];
		}

		ll p1[m];

		for(ll k = 0 ; k < m ; k++)
		{
			ll cnt = 0;
			for(ll j = 0 ; j < v1[k].size(); j++)
			{
				cnt += hm[v1[k][j]];
			}

			p1[k] = cnt%2;
		}

		bool flag = true;

		for(ll k = 0 ; k < m ; k++)
		{
			if(p[k] != p1[k])
			{
				flag = false;
			}
		}

		if(flag)
		{
			ans++;
		}

	}

	cout<<ans<<endl;

}	

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

using namespace std;

bool graph[8][8]={};

int DFS (int v,int N,bool visited[8]/*訪れたノード*/){
    //最後かどうか確認する
    bool all_visited=true;
    for(int i=0;i<N;++i){
        if(visited[i]==false){
            all_visited=false;
        }
    }
    //最後だったら
    if(all_visited){
        return 1;
    }

    int ret=0;

    for(int i=0;i<N;++i){
        //道がなければ無視
        if(graph[v][i]==false)continue;
        //訪れたことがあればむし
        if(visited[i])continue;

        visited[i]=true;
        ret+=DFS(i,N,visited);
        visited[i]=false;
    }

    return ret;
}

int main(){
    int N,M;
    cin>>N>>M;

    for(int i=0;i<M;++i){
        int A,B;
        cin>>A>>B;
        graph[A-1][B-1]=graph[B-1][A-1]=true;
    }

    bool visited[8]={};

    visited[0]=true;
    cout<<DFS(0,N,visited)<<endl;
    return 0;


}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	count := 0.
	for i := 0; i < N; i++ {
		sc.Scan()
		a, _ := strconv.ParseFloat(sc.Text(), 64)
		count += 1 / a
	}

	fmt.Print(1 / count)
}


Measured memory_bytes: 640
# coding: utf-8
x = int(input())

if x >= 400 and x <= 599:
    ans = 8
elif x >= 600 and x <= 799:
    ans = 7
elif x >= 800 and x <= 999:
    ans = 6
elif x >= 1000 and x <= 1199:
    ans = 5
elif x >= 1200 and x <= 1399:
    ans = 4
elif x >= 1400 and x <= 1599:
    ans = 3
elif x >= 1600 and x <= 1799:
    ans = 2
elif x >= 1800 and x <= 1999:
    ans = 1



print(ans)


Measured memory_bytes: 9180
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ns()
if n[0] == n[1] == n[2]:
    print("Yes")
elif n[1] == n[2] == n[3]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
from collections import deque
K = int( input())
V = [0]*K
q = deque([(1,1)])
while q:
    x, r = q.popleft()
    if x == 0:
        ans = r
        break
    if V[x] == 1:
        continue
    V[x] = 1
    if V[10*x%K] == 0:
        q.appendleft((10*x%K, r))
    if V[(x+1)%K] == 0:
        q.append(((x+1)%K, r+1))
print(ans)

Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
template<class T>void ExEuclid(T n, T m, T &a, T &b, T &gcd){if(m==0){gcd=n;a=1;b=0;return;}ExEuclid(m,n%m,a,b,gcd);T x=a;a=b;b=x-(n/m)*a;}
template<class T>T gcd(T n, T m){if(m==0){return n;}gcd(m,n%m);}
template<class T>T lcm(T n, T m){return (n*m)/gcd(n,m);}
template<class T>string to_string(T n){string s="";while(n)s+=((n%10)+'0'),n/=10;reverse(s.begin(),s.end());return s;}
template<class T>ll to_int(T s){ll num=0,power=0;for(int i=s.size()-1; i>=0; i--)num+=(pow(10.0,power++)*(s[i]-'0'));return num;}
template<class T>bool is_mod(T n, T m){if(n%m==0)return true;return false;}
template<class T>bool is_upper(T s){for(int i=0; i<s.size(); i++)if(s[i]>90 || s[i]<65)return false;return true;}
template<class T>bool is_lower(T s){for(int i=0; i<s.size(); i++)if(s[i]>122 || s[i]<97)return false;return true;}
template<class T>T mod(T n, T m){return ((n%m)+m)%m;}
template<class T>T Big_mod(T base, T power, T MOD){
    if(power==1)return base;
    if(power & 1)return ((base%MOD)*(Big_mod(base,power-1,MOD))%MOD)%MOD;
    else {T temp=(Big_mod(base,power>>1,MOD));return ((temp%MOD)*(temp%MOD))%MOD;}
}



int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    faster_io;
    int a[6];
    int ans=0,mn=10;
    for(int i=0; i<5; i++){
        cin>>a[i];
        if(a[i]%10)ans+=ceil(double(a[i])/10.0)*10;
        else ans+=a[i];
        if(a[i]%10)mn=min(mn,a[i]%10);
    }
    cout<<ans-10+mn<<endl;
    return 0;
}



		

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  string s; cin >> s;
  ll n = s.size();

  bool ans = true;

  rep(i, n) if (s[i] != s[n-1-i]) ans = false;
  int a = (n-1)/2;
  rep(i, a) if (s[i] != s[a-1-i]) ans = false;
  int b = a+1;
  rep(i, a) if (s[b+i] != s[n-1-i]) ans = false;

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 連結成分の大きさを見るだけだった
# 言語と二部グラフを作る

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N,M = map(int,input().split())
row = []
col = []
for i in range(N):
    K,*L = map(int,input().split())
    row += [i] * K
    col += [x-1+N for x in L]

graph = csr_matrix(([1]*len(row), (row,col)), (N+M,N+M))

_,comp = connected_components(graph)

bl = (comp[:N] == comp[0]).all()

answer = 'YES' if bl else 'NO'
print(answer)

Measured memory_bytes: 27232
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int H,W; cin >> H >> W;
	vector<vector<char>> a(H,vector<char>(W));
	rep(i,H)rep(j,W) cin >> a[i][j];
	map<int,int> num;
	rep(i,H)rep(j,W){
		num[a[i][j]-'a']++;
	}
	for(auto &v : num){
		v.second %= 4;
	}
	if(H % 2 == 0 && W % 2 == 0){
		bool ok = true;
		for(auto v : num){
			if(v.second != 0) ok = false;
		}
		cout << (ok ? "Yes" : "No") << endl;
		return 0;
	}
	else{
		int cnt1 = 0;
		int cnt2 = 0;
		int cnt3 = 0;
		for(auto v : num){
			if(v.second == 1) cnt1++;
			if(v.second == 2) cnt2++;
			if(v.second == 3) cnt3++;
		}
		bool ok = false;
		if(H % 2 == 1 && W % 2 == 1){
			if(cnt1 + cnt3 == 1 && cnt2 + cnt3 <= H/2 + W/2) ok = true;
		}
		else if(H % 2 == 0 && W % 2 == 1){
			if(cnt1 + cnt3 == 0 && cnt2 <= H/2) ok = true;
		}
		else{
			if(cnt1 + cnt3 == 0 && cnt2 <= W/2) ok = true;
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
}



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

def find_pow(x):
    if x==1:
        return 0
    else:
        res = 0
        t = 1
        while(t <= x):
            t *= 2
            res +=1
    return res-1

p = find_pow(H)
res = 0
for i in range(p+1):
    res +=2**i
print(res)

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int n,d,x;
  cin>>n>>d>>x;
  int a;
  for(int i=0; i<n; i++){
    cin >>a;
    x += (d-1)/a + 1;
  }
  cout << x << endl;
  return 0;
}
  

Measured memory_bytes: 256
a=[int(input())for _ in[0]*int(input())]
m=a[-1]+1
def f(S):
 x=1
 while 2*x*-~x<m:
  if(S-x)%(2*x+1)==0:return 0
  x+=1
 return 1
print(sum(f(S)for S in a))


Measured memory_bytes: 8004
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = sorted(LIST())
B = sorted(LIST())
C = sorted(LIST())

ans = 0
for i in range(N):
	ans += bisect_left(A, B[i]) * (N - bisect(C, B[i]))

print(ans)



Measured memory_bytes: 32452
#include <stdio.h>
int N;
void Print(int *);
//関数について
void InsertionSort(int A[]){
  int i,j;
  int value;
  for(i=1;i<N;i++){
    value=A[i];
    j=i-1;
    while( j>=0 && A[j] > value){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=value;
    Print(A);
  }
}

void Print(int A[]){
  int i;
  for(i=0;i<N;i++){
     if(i>0)printf(" "); 
    printf("%d",A[i]);

  }
  printf("\n");
}

int main(){
  int A[1000];
  int i;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  Print(A);
  InsertionSort(A);

  return 0;
}




Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
//
	int n;
	cin >> n;
	long double s, b;
	std::priority_queue<long double, std::vector<long double>, std::greater<long double> > que;
	rep0(i, n - 1) {
		double a;
		cin >> a;
		que.push(a);
	}
	rep0(j, n - 2) {
		s = que.top();
		que.pop();
		b = que.top();
		que.pop();
		que.push((s + b) / 2);
	}
	cout << que.top() << endl;


	return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
a = []
b = []

for i in range(1,A+1):
  if A%i==0:
    a.append(i)
for j in range(1,B+1):
  if B%j==0:
    b.append(j)

abset = list(sorted(set(a)&set(b)))[::-1]

print(abset[K-1])

Measured memory_bytes: 3064
N = gets.to_i
A = gets.split.map(&:to_i).sort
MAX = 10**6
E = [0] * (MAX+1)

A.each do |a|
    am = a
    if E[am] >= 1
        E[am] += 1
        next
    end
    while am <= MAX do
        E[am] += 1
        am += a
    end
end

cnt = 0
A.each do |a|
    if E[a] == 1
        cnt += 1
    end
end
puts cnt

Measured memory_bytes: 38392
#include<stdio.h>
int main()
{
    long long int a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(k>a)
    {
        k=k-a;
        a=0;
        if(k>b)
        {
            k=k-b;
            b=0;
        }
        else{
            b=b-k;
        }
    }
    else{
        a=a-k;
    }
    printf("%lld %lld\n",a,b);

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

const int MAX_N = 1e4 + 4;
int n, k;
bool Mark[MAX_N];

bool cant (int m) {
	while (m) {
		if (Mark[m % 10])
			return true;

		m /= 10;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		Mark[a] = true;
	}

	while (cant(n))
		n++;

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int N = sc.nextInt(), M = sc.nextInt();
        City[] cities = new City[M];
        for (int i = 0; i < M; i++) {
            cities[i] = (new City(i, sc.nextInt(), sc.nextInt()));
        }
        Arrays.sort(cities, Comparator.comparingInt(city -> city.year));
        String[] ans = new String[M];
        int[] count = new int[N + 1];
        for (int i = 0; i < M; i++) {
            count[cities[i].pref]++;
            ans[cities[i].order] = String.format("%06d", cities[i].pref) + String.format("%06d", count[cities[i].pref]);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < M; i++) {
            sb.append(ans[i]).append("\n");
        }
        System.out.print(sb);
    }

    class City {

        int order, pref, year;

        public City(int order, int pref, int year) {
            this.order = order;
            this.pref = pref;
            this.year = year;
        }
    }
}

Measured memory_bytes: 171628
def main():
    from collections import deque

    n, q, *abpx = map(int, open(0).read().split())

    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    q = deque([])
    q.append([1, 0])
    while q:
        i, c = q.pop()
        if vis[i]:
            continue
        vis[i] = True
        ch = g[i]
        w = c + f[i]
        k[i] = w
        for u, v in zip(ch, [w] * len(ch)):
            q.appendleft([u, v])

    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95620
s = input()
A = [[5, "dream"], [7, "dreamer"], [5, "erase"], [6, "eraser"]]
g = 0
while len(s) > 0:
  f = 0
  for i in range(4):
    if len(s) >= A[i][0]:
      if s[-A[i][0]:] == A[i][1]:
        s = s[:-A[i][0]]
        f = 1
        break
  if f == 0:
    print("NO")
    g = 1
    break
if g == 0:
  print("YES")

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

int main() {
  int  N, Y;
  cin >> N >> Y;
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      int sum = 10000 * i + 5000 * j + 1000 * (N - i - j);
      if (sum == Y && N - i - j >= 0) {
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  
  cout << -1 << " " << -1 << " "<< -1 << endl;
  return 0;
 
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int w, h, n, x[100], y[100], a[100];
	bool p[101][101];
	
	fill(p[0], p[101], false);
	
	cin >> w >> h >> n;
	for(int i=0; i<n; i++)
		cin >> x[i] >> y[i] >> a[i];
	
	for(int i=0; i<n; i++){
		switch(a[i]){
			case 1:
				fill(p[1], p[x[i]+1], true);
				break;
				
			case 2:
				fill(p[x[i]+1], p[w+1], true);
				break;
				
			case 3:
				for(int a=1; a<=w; a++){
					for(int b=1; b<=y[i]; b++)
						p[a][b]=true;
				}
				break;
				
			case 4:
				for(int a=1; a<=w; a++){
					for(int b=y[i]+1; b<=h; b++)
						p[a][b]=true;
				}
				break;
		}
	}
	
	int ans=0;
	for(int a=1; a<=w; a++){
		for(int b=1; b<=h; b++){
			if(p[a][b]==false)
				ans++;
		}
	}
	
	cout << ans << '\n';
	return 0;
}

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

using namespace std;


int main() {
    int n;
    cin>>n;
    int num[n];
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
    }
    if(n==1){
        cout<<num[0]<<endl;
        return 0;
    }
    for (int j = n-1; j >=0 ; j-=2) {
        cout<<num[j]<<" ";
    }
    if(n%2==0){
        for (int i = 0; i < n-2; i+=2) {
            cout<<num[i]<<" ";
        }
        cout<<num[n-2]<<endl;
    }
    else{
        for (int i = 1; i < n-2; i+=2) {
            cout<<num[i]<<" ";
        }
        cout<<num[n-2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2944
n,m,x,y=map(int,input().split())
*a,=map(int,input().split())
*b,=map(int,input().split())

for z in range(x+1,y+1):
  if max(a)<z and min(b)>=z:
    print("No War")
    break
else:
  print("War")


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        int current = in.nextInt();
        int count = 0;
        int result = 0;
        for (int i = 1; i < n; i++) {
            final int next = in.nextInt();
            if (current >= next) {
                count++;
                result = Math.max(result, count);
            } else {
                count = 0;
            }
            current = next;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 48532
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 200055, mod = 1e9 + 7;

int f[N];
int fact[N], invf[N];

int g(int x, int y) {
    if(x < 0 || y < 0) {
        return 0;
    }
    int res = (fact[x + y] * (ll)invf[x]) % mod;
    res = (res * (ll)invf[y]) % mod;
    return res;
}

int po(int x, int y) {
    int res = 1;
    while(y > 0) {
        if(y & 1) {
            res = (res * (ll)x) % mod;
        }
        x = (x * (ll)x) % mod;
        y /= 2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    fact[0] = invf[0] = 1;
    rep(i, 1, (int)N) {
        fact[i] = (fact[i - 1] * (ll)i) % mod;
        invf[i] = po(fact[i], mod - 2);
    }
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    rep(i, 0, n) {
        cin >> a[i].first >> a[i].second;
    }
    a.emplace_back(make_pair(h, w));
    sort(a.begin(), a.end());
    n++;
    rep(i, 0, n) {
        f[i] = g(a[i].first - 1, a[i].second - 1);
        pr(a[i], f[i]);
        rep(j, 0, i) {
            f[i] = (f[i] - f[j] * (ll)g(a[i].first - a[j].first,
                                        a[i].second - a[j].second)) % mod;
            if(f[i] < 0) {
                f[i] += mod;
            }
            pr(i, j, a[j], f[i]);
        }
    }
    cout << f[n - 1] << endl;
}

Measured memory_bytes: 1920
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
p = LIST()
cnt = 0

for i in range(1, n-1):
	if p[i] > min(p[i-1], p[i+1]) and p[i] < max(p[i-1], p[i+1]):
		cnt += 1

print(cnt)

Measured memory_bytes: 5144
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int P=sc.nextInt();
		int Q=sc.nextInt();
		int R=sc.nextInt();
		sc.close();
		int max=P;
		int result;
		if(max<Q) {
			max=Q;
		}
		if(max<R) {
			max=R;
		}
		result=P+Q+R-max;
		System.out.println(result);
	}
}

Measured memory_bytes: 23892
# coding: utf-8
N,A,B=map(int,input().split())

if abs(A-B)%2==0:
    ans=(B-A)//2
else:
    m1=N-B
    m2=A-1
    
    ans=min(m1+(N-A-m1-1)//2+1,m2+(B-1-m2-1)//2+1)

print(ans)



Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int x,y;
  double w,h;
  int m;
  double ans;
  scanf("%lf %lf %d %d",&w,&h,&x,&y);
  if(w<1 || h>1000000000)return 0;
  if(0>x || x>w)return 0;
  if(0>y || y>h)return 0;

  if(w/2==x && h/2==y)m = 1;
  else m=0;

  ans = w*h/2;
  printf("%lf %d\n",ans ,m);

  return 0;
}


Measured memory_bytes: 128
import math
import bisect
import sys
input = sys.stdin.readline
q = int(input())

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False

prime = set([i for i, f in enumerate(sieve_of_erastosthenes(10**5)) if f])
like = []
for p in prime:
    if (p+1)//2 in prime:
        like.append(p)
like.sort()

for i in range(q):
    l, r = map(int, input().split())
    st = bisect.bisect_left(like, l)
    en = bisect.bisect_right(like, r)

    print(en-st)

Measured memory_bytes: 61728
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll R,G;
	while(cin>>R>>G) {
		cout<<2*G-R<<endl;
	}
	
	return 0;
}


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

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

int main(void) {

  for(;;) {
    int x, y, s;
    std::cin >> x >> y >> s;
    if( x == 0 and y == 0 and s == 0 ) break;

    int res = 0;
    for(int i = 1; i <= s; ++i) {
      for(int j = 1; j <= s; ++j) {
        if( (i * (100 + x) / 100) + (j * (100 + x) / 100) == s ) {
          res = std::max(res, (i * (100 + y) / 100) + (j * (100 + y) / 100));
        }
      }
    }

    std::cout << res << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
//#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int H, W, A[88][88], B[88][88];
//
int dp[88][88][6411*4];
const int AD = 6411*2;
void solve()
{
    cin>>H>>W;
    forn(i, H) forn(j, W)
    {
        cin >> A[i][j];
    }
    forn(i, H) forn(j, W)
    {
        cin >> B[i][j];
    }
    dp[0][0][AD + A[0][0] - B[0][0]] = 1;
    dp[0][0][AD - A[0][0] + B[0][0]] = 1;
    //
    forn(i, H) forn(j, W) forn(dt, 6411*4)
    {
        int ab = A[i][j] - B[i][j];
        if (j)
        {
            if (dt - ab >= 0)
                dp[i][j][dt] |= dp[i][j-1][dt - ab];
            if (dt + ab < 6411*4)
                dp[i][j][dt] |= dp[i][j-1][dt + ab];
        }
        if (i)
        {
            if (dt - ab >= 0)
                dp[i][j][dt] |= dp[i-1][j][dt - ab];
            if (dt + ab < 6411*4)
                dp[i][j][dt] |= dp[i-1][j][dt + ab];
        }
    }
    int ans = 1e9;
    forn(dt, 6411*4)
    {
        if (dp[H-1][W-1][dt]) ans = min(ans, abs(dt - AD));
    }
    cout << ans << '\n';
}


signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    // cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 644988