akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		//a～bまでの整数の内、cの約数がいくつあるかを調べる
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int count=0;
		for(int i=a;i<=b;i++){
			if(c%i==0){
				count++;
			}
		}
		System.out.println(count);
	}

}



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

long long mod = 1000000007;

int main () {
  vector<long long> kai(3030);
  vector<long long> gkai(3030);
  long long bk = 1;
  long long bkt;
  long long bkmod;
  for (int i=1; i<3030; i++) {
    bk *= i;
    bk %= mod;
    kai[i] = bk;
    bkmod = bk;
    for (int i=0; i<9; i++) {
      bkt = bkmod;
      for (int j=0; j<9; j++) {
        bkmod *= bkt;
        bkmod %= mod;
      }
    }
    for (int i=0; i<5; i++) {
      bkmod *= bk;
      bkmod %= mod;
    }
    gkai[i] = bkmod;
  }
  kai[0] = kai[1];
  gkai[0] = gkai[1];
  
  int N,M;
  string S;
  cin >> N >> M >> S;
  vector<long long> l(M+1,N+1),r(M+1,N+1);
  for (int i=0; i<M; i++) {
    cin >> l[i] >> r[i];
    if (i >= 1) {
      if (l[i] == l[i-1]) {
        l[i-1] = -1;
        r[i] = max(r[i],r[i-1]);
      }
    }
  }
  vector<int> n1(N+1,0);
  for (int i=0; i<N; i++) {
    if (S[i] == '1') n1[i+1] = n1[i] + 1;
    else n1[i+1] = n1[i];
  }
  long long L=0;
  long long R=0;
  long long com;
  long long ll,rr;
  vector<vector<long long>> dp(N+1,vector<long long>(N+1,0));
  for (int i=0; i<M+1; i++) {
    ll = l[i];
    rr = r[i];
    if (ll == -1) continue;
    if(L == 0) {
      dp[ll-1][n1[ll-1]] = 1;
      L = ll;
      R = rr;
      continue;
    }
    if (R < ll) {
      for (int j=n1[R]-(R-L+1); j<n1[R]+1; j++) {
        if (j<0) continue;
        com = kai[R-L+1] * gkai[n1[R]-j] % mod * gkai[(R-L+1)-(n1[R]-j)] % mod;
        dp[ll-1][n1[ll-1]] += dp[L-1][j] * com % mod;
      }
      dp[ll-1][n1[ll-1]] %= mod;
      L = l[i];
      R = r[i];
      continue;
    }
    for (int j=n1[R]-(R-ll+1); j<n1[R]+1; j++) {
      for (int k=0; k<=ll-L; k++) {
        if (j-k < 0) continue;
        com = kai[ll-L] * gkai[k] % mod * gkai[ll-L-k] % mod;
        dp[ll-1][j] += dp[L-1][j-k] * com % mod;
      }
      dp[ll-1][j] %= mod;
    }
    L = ll;
    R = max(rr,R);
  }
  cout << dp[N][n1[N]] << endl;
  return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>
int main(){
    char s[6],a,b,c,d;
    scanf("%s",s);
    a=s[2];b=s[3];c=s[4];d=s[5];
    if(c==d && a==b){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
/**
 *    author:  tourist
 *    created: 26.11.2019 03:24:57       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int b = 1; b <= n; b++) {
    for (int a = 0; a <= n; a += b) {
      int from = max(a + k, 1);
      int to = min(a + b - 1, n);
      if (from <= to) {
        ans += to - from + 1;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int n,k;
int A[200000];
int K[200000];

bool check(int x){
  int res = 0;
  rep(i,0,n){
    int need = x/K[i];
    if(need < A[i]) res += A[i]-need;
  }
  return (res <= k);
}

signed main(){
  cin >> n >> k;
  rep(i,0,n) cin >> A[i];
  rep(i,0,n) cin >> K[i];
  sort(A, A+n);
  sort(K, K+n, greater<>());
  int ng = -1;
  int ok = 1e13;
  while(ok - ng > 1){
    int mid = (ok+ng)/2;
    // cout << "a" << mid << " " << check(mid) << endl;
    if(check(mid)) ok = mid;
    else ng = mid;
    // cout << ok << " " << ng << endl;
  }
  cout << ok << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int dp[105][10005] = {};

int main() {
	int n, w; cin >> n >> w;
	vector<int> value(n), weight(n);
	rep(i, n) cin >> value[i] >> weight[i];

	//vvi dp(n + 1, vi(n+1));
	//初期条件
	//for(int j = 0; j<= w; j++) dp[0][j] = 0;

	rep(i, n) for(int j = 0; j <= w; j++) {
		//dp[i+1][j] := i番目で重さj以下のときの最大value和
		if (weight[i] <= j) dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
		else dp[i + 1][j] = dp[i][j];
	}

	cout << dp[n][w] << endl;
}



Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
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; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { cout << -1 << '\n'; exit(0); }
// const int INF  = 1<<30;
const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n, k; cin >> n >> k;
  Vll p(n), c(n); cin >> p >> c;
  rep(i, n) --p[i];

  ll ans = -INFll;
  rep(i, n) {
    Vll sc(n+1);

    ll st = -1;

    int x = i;
    rep(j, n) {
      x = p[x];
      sc[j+1] = sc[j] + c[x];

      if (x == i) {
        st = j+1;
        break;
      }
    }

    ll sum = sc[st];
    ll m = k / st;

    ll per = 0;
    ll kk = k;
    if (sum > 0) {
      if (kk >= 2*st) {
        per += sum * (m-1);
        kk -= st * (m-1);
      }
    }
    else kk = min(kk, n);

    x = i;
    ll res = per;
    rep(j, kk) {
      x = p[x];
      res += c[x];
      chmax(ans, res);
      // cout << res << ' ';
    }
    // cout << '\n';
  }

  cout << ans << '\n';
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int T,A;
  cin >>T>>A;
  T=T*1000;
  A=A*1000;
    
  int min,answer,H;
  vector<int> Hs,tempel;
  min=100001;
  for(int i=0;i<N;i++){
    cin >> H;
    Hs.push_back(H);
  }
  for(int i=0;i<Hs.size();i++){
    tempel.push_back(T-Hs[i]*6-A);
  }
  min = abs(tempel[0]);
  answer=0;
  for(int i=0;i<tempel.size();i++){
    if(min>abs(tempel[i])){
      min=abs(tempel[i]);
      answer=i;
    }
  }
  cout<<answer+1;  
}

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

using namespace std;

int main(int argc, char *argv[]) {
    //
    //  リーダーより左にいる人は東 (W) になる
    //  リーダーより右にいる人は西 (E) を向く
    //
    //  つまり、Sをループし、その人がリーダーで
    //  あった場合に、以下の人数を数え、その最小値
    //  を求めればよい
    //
    //  * リーダーの左の人が E の人
    //  * リーダーの右の人が W の人
    //

    int N;
    string S;
    cin >> N >> S;

    vector<int> warr;
    vector<int> earr;

    int esum = 0;
    int wsum = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'E') {
            esum++;
        } 
        if (S[i] == 'W') {
            wsum++;
        } 
        warr.push_back(wsum);
        earr.push_back(esum);
    }

    int64_t ans = INT_MAX;
    for (int j = 0; j < N; j++) {
        //
        //  s[j] がリーダー
        //

        //  自分より左でWの人
        int w = warr[j];
        if (S[j] == 'W') {
            w--;
        }
        //  自分より右でEの人
        int e = earr[earr.size() - 1] - earr[j];

        int64_t tmp_ans = w + e;
        if (tmp_ans < ans) {
            ans = tmp_ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4984
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(b - a == c - b) {
      System.out.println("YES");
    }else {
      System.out.println("NO");
    }
  }
}


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

int main(){
  ll n,i,j,k;
  cin >> n;
  i=n/2;
  string a,c,b;
  k=0;
  if(n%2!=0)k=-1;
  cin >> a;
  for(j=0;j<i;j++){
    c=a.substr(0+j,1);
    b=a.substr(i+j,1);
    if(c!=b)k=-1;
  }
  if(k==0)cout << "Yes";
  else if(k==-1) cout << "No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while (true) {
				int a = sc.nextInt(); //第一入力
				int b = sc.nextInt(); //第二入力
				if(a == 0 && b == 0) {
					break;
				}
				for(int i = 0; i < a; i++) {
					for(int j = 0; j < b; j++) {
						System.out.print("#");
					}
					System.out.println("");
				}
				System.out.println();
			}
		}
	}
}




Measured memory_bytes: 32428
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;
use superslice::Ext;

#[fastout]
fn main() {
    input!{
        n: usize, m: usize, mut k: isize,
        mut a_vec: [isize; n],
        mut b_vec: [isize; m],
    }

    let mut ans = 0;
    // a_vec.reverse();
    // b_vec.reverse();

    let a_cumsum = std::iter::once(&0).chain(&a_vec).cumsum().collect::<Vec<isize>>();
    let b_cumsum = b_vec.iter().cumsum().collect::<Vec<isize>>();

    for (i, a) in a_cumsum.into_iter().enumerate() {
        if a > k {
            break;
        }
        let j = b_cumsum.upper_bound(&(k-a));
        ans = std::cmp::max(ans, i+j)
    }


    println!("{}", ans);
}


Measured memory_bytes: 12532
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>

using namespace std;

int main() {
  string str;
  long long k;
  cin >> str >> k;
  int i = 0;
  while (true) {
    if (i == str.size()) {
      while (k >= 'z' - 'a' + 1) {
        k -= 'z' - 'a' + 1;
      }
      str.back() += k;
      break;
    }
    long long ch = 'z' - str[i] + 1;
    if (str[i] != 'a'&&ch <= k) {
      k -= ch;
      str[i] = 'a';
    }
    ++i;
  }
  cout << str << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
string s,t;
cin>>s>>t;
for(int i=0;i<s.size();i++){
    bool k=true;
    for(int j=0;j<s.size();j++)if(s[j]!=t[(i+j)%s.size()]){
        k=false;
        break;
    }
    if(k){
        cout<<"Yes"<<endl;
        return 0;
    }

}
cout<<"No"<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll

int main() {
  ll n;
  cin>>n;
  vec a(n);
  loop(i,n){
    cin>>a[i];
  }
  ll count=0;
  ll minj;
  loop(i,n){
  minj=i;
  Loop(j,i,n){
  if(a[minj]>a[j]){
  minj=j;
  }
  }
  if(i!=minj){
  swap(a[i],a[minj]);
  count++;
  }
  }
  loop(i,n){
  if(i>=1){
  cout<<" ";
  }
  cout<<a[i];
  }
  cout<<""<<endl;
  cout<<count<<endl;
}


Measured memory_bytes: 3084
/*Binary Search Tree II
Write a program which performs the following operations to a binary search tree T by adding the find operation to A: Binary Search Tree I.

insert k: Insert a node containing k as key into T.
find k: Report whether T has a node containing k.
print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.
Input
In the first line, the number of operations m is given. In the following m lines, operations represented by insert k, find k or print are given.

Output
For each find k operation, print "yes" if T has a node containing k, "no" if not.

In addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key.

Constraints
The number of operations ≤500,000
The number of print operations ≤10.
?2,000,000,000≤key≤2,000,000,000
The height of the binary tree does not exceed 100 if you employ the above pseudo code.
The keys in the binary search tree are all different.*/
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <set>
using namespace std;

struct Node{
	int key;
	Node *parent,*left,*right;
};

Node *root,*NIL;
set<int> S;

void print_inorder(){
	for(set<int>::iterator it=S.begin();it!=S.end();it++)
		cout<<" "<<*it;
	cout<<endl;
}

void insert(int k){
	Node *y=NIL;
	Node *x=root;
	Node *z;
	z=(Node *)malloc(sizeof(Node));//随机分配区域节省内存 
	//先进行初始化 
	z->key=k;
	z->left=NIL;
	z->right=NIL;
	
	while(x!=NIL){
		y=x;
		if(z->key<x->key){
			x=x->left;
		}	
		else{
			x=x->right;
		}
	}
	z->parent=y;
	if(y==NIL){
		root=z;
	} 
	else{
		if(z->key<y->key){
			y->left=z;
		} 
		else{
			y->right=z;
		}
	}
}

void print_preorder(Node* u){
	if(u==NIL)
		return;
	cout<<" "<<u->key;
	print_preorder(u->left);
	print_preorder(u->right);
}

int main(){
	int n;
	cin>>n;
	string com;
	int k;

	for(int i=0;i<n;i++){
		cin>>com;
		if(com=="insert"){
			cin>>k;
			S.insert(k);
			insert(k);
		}
		else if(com=="find"){
			cin>>k;
			if(S.end()!=S.find(k))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
		else if(com=="print"){
			print_inorder();
			print_preorder(root);
			cout<<endl;
		}
	} 
	
	return 0;
}


Measured memory_bytes: 40660
def nyu():
    num1= input()
    num1 = int(num1)
    num2 = list(map(int,input().split()))
    #num2 = int(num2)
    return num1,num2


def check(A):
    max = 999999
    count = 0
    flg = 0
    for x in list(A):
        flg = 0
        count = 0
        while flg == 0:
            if x % 2 == 0:
                x = x/2
                count +=1
            else:
                if count<max:
                    max =count
                flg =1
                break   
    print(max)
             

N,A = nyu()
check(A)


Measured memory_bytes: 3060
/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 8/28/2020
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
const double PI = acos(-1);
const int MOD = 1000000007;

const int mxN = 100, mxW = 1e5;
int n, w;
ll dp[mxN+1][mxW+1];
vector<pair<int, int>> arr(mxN+1, {0, 0});

ll go(int i, int taken) {
	if(i == n) {
		return (taken+arr[i].first <= w ? arr[i].second : 0);
	}
	if(i > n || taken > w) {
		return (ll)-1e18;
	}
	if(dp[i][taken] != -1) {
		return dp[i][taken];
	}
	ll c1 = go(i+1, taken);
	ll c2 = (ll)-1e18;
	if(taken+arr[i].first <= w) c2 = go(i+1, taken+arr[i].first) + arr[i].second;
	ll ans = max(c1, c2);
	return dp[i][taken] = ans;
}

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

	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i].first >> arr[i].second;
	}
	memset(dp, -1, sizeof(dp));
	cout << go(1, 0);

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; ++i)
    cin >> s[i];

  map<vector<int>, long long> m;
  for (int i = 0; i < N; ++i) {
    vector<int> a(26);
    for (int j = 0; j < 10; ++j)
      ++a[s[i][j] - 'a'];
    ++m[a];
  }

  long long ans = 0;
  for (auto &i : m)
    ans += i.second * (i.second - 1) / 2;

  cout << ans << endl;
}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int N = 1e5+10;
int a[N],t;
ll ans;
string s;
int main()
{
    int x,y;
    cin>>s;
    for(int i=0;i<s.size();i++)
      if(s[i]=='A') {
      	x=i;break;
      }
      for(int i=s.size();i>0;i--)
      if(s[i]=='Z') {
      	y=i;break;
      }
      cout<<y-x+1;
    return 0;
}

  



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Solve();
            System.Console.WriteLine(Result);
        }

        public static string Result { get; set; }

        private static void Solve()
        {
            var s = Console.ReadLine();
            Result = rec(s).ToString();
        }

        private static long rec(string nums)
        {
            var res = nums.ToLong();
            if (nums.Length == 1) return res;

            for (var i = 1; i < nums.Length; ++i)
            {
                res += nums.Substring(0, i).ToLong() * (int)Math.Pow(2, nums.Length - 1 - i) + rec(nums.Substring(i));
            }
            return res;
        }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static int ReadInt()
            => ReadInts().First();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<String> ReadStrings()
            => Console.ReadLine().Split(' ');

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion
    }
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;

    string s;

    bool flag = 0;

    cin>>s;

    for(i=0;i<s.size();i++)
    {
        if(s[i]!=s[0])
        {
            flag = 1;
            break;
        }

        else{

            flag = 0;
        }
    }
    if(flag == 0)
    {
        cout<<"No";
    }
    else{

        cout<<"Yes";
    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String[] S = new String[n];

    for (int i = 0; i < n; i++) {
      S[i] = sc.next();
    }

    sc.close();

    // count[0]はaの個数、[1]はbの個数、[25]はzの個数
    int[] count = new int[26];

    for (int i = 0; i < S.length; i++) {

      int[] count_ = new int[26];
      
      for (int j = 0; j < S[i].length(); j++) {
        // aのASCIIコードは97
        count_[(int)S[i].charAt(j) - 97]++;
      }
      
      for (int j = 0; j < 26; j++) {
        if (i != 0) {
          count[j] = Math.min(count[j], count_[j]);
        } else {
          count[j] = count_[j];
        }
      }

    }

    for (int i = 0; i < 26; i++) {
      char string = (char) (i + 97);
      for (int j = 0; j < count[i]; j++) {
        System.out.print(string);
      }
    }

    System.out.println("");

  }

}

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

int main() {
  int X;
  cin >> X;
  int ans;
  int x_500;
  int x_5;
  x_500 = X / 500;
  x_5 = (X - x_500 * 500) / 5;
  ans = x_500 * 1000 + x_5 * 5;
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INF = 2147483647;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int i;
	ll n, cnts[5], cnt = 0;
	for (i = 0; i < 5; i++) cnts[i] = 0;
	cin >> n;
	for (i = 0; i < n; i++){
		string tmp;
		cin >> tmp;
		if (tmp[0] == 'M') cnts[0]++;
		if (tmp[0] == 'A') cnts[1]++;
		if (tmp[0] == 'R') cnts[2]++;
		if (tmp[0] == 'C') cnts[3]++;
		if (tmp[0] == 'H') cnts[4]++;
	}
	for (int a = 0; a < 3; a++){
		for (int b = a + 1; b < 4; b++){
			for (int c = b + 1; c < 5; c++){
				cnt += cnts[a] * cnts[b] * cnts[c];
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int A, B;
	scanf("%d %d", &A,&B);
	
	if( A <= 8 && A >= 1 && B <= 8 && B >= 1){
		printf("Yay!");
	}else{
		printf(":(");
	}
	
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
constexpr ll mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

using namespace std;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    for(auto & t : a )cin>>t;
    for(auto & t : b) cin>>t;
    vector<ll> sa(n+1),sb(m);
    for(int i=0;i<n;++i){
        sa[i+1] = sa[i] + a[i];
    }
    sb[0] = b[0];
    for(int i=1;i<m;++i){
        sb[i] = sb[i-1] + b[i];
    }
    int ma = 0;
    for(int i=0;i<=n;++i){
        int sum = sa[i];
        if(k - sum < 0)break;
        int num = upper_bound(sb.begin(),sb.end(),k-sum) - sb.begin();
        ma  = max(ma,i+num);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const int INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};

int main(){
  int n;
  cin >> n;
  vector<long long> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i)){
          long long lm = max(l.at(i),l.at(j));
          lm = max(lm,l.at(k));
          if(2 * lm < l.at(i) + l.at(j) + l.at(k))ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using i64 = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int K = 1000;
const int NMAX = 1000;
#define FILENAME ""   

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen("symposium.in", "r", stdin);
//	freopen("symposium.out", "w", stdout);
   	ll n, m;
   	cin >> n >> m;
   	vector <ll> a;
   	for (int i = 0; i < n; i++)
   	{
   		ll x;
   		cin >> x;
   		a.pb(x);                
   	}
   	ll ans = (abs(a[0] - m));
   	for (int i = 1; i < n; i++)
   	{
   	 	ans = gcd(ans, abs(a[i] -m));
   	}
   	cout << ans;
   	re 0;
}

Measured memory_bytes: 1400
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e2+50;
const int mod=1e9+7;
using namespace std;
int n,i,j,x,y,l[nmax],cur,rs,bl,t;
pair<int,int>mx;
vector<int>a[nmax];
bitset<nmax>viz;
char c;
queue<int>q;
void dfs(int x)
{
	viz[x]=1;
	cur=max(cur,l[x]);
	for(int i=0;i<a[x].size();i++)
	{
		int y=a[x][i];
		if(viz[y])continue;
		dfs(y);
	}
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>c;
			if(c=='1')
			{
				a[i].pb(j);
			}
		}
	}
	for(t=1;t<=n;t++)
	{
		mx=mkp(0,0);
		while(!q.empty())q.pop();
		viz.reset();
		q.push(t);
		viz[t]=1;
		l[t]=1;
		while(!q.empty())
		{
			x=q.front();
			q.pop();
			for(i=0;i<a[x].size();i++)
			{
				y=a[x][i];
				if(viz[y])continue;
				l[y]=l[x]+1;
				q.push(y);
				viz[y]=1;
			}
		}
		bl=0;
		for(i=1;i<=n;i++)
		{
			for(j=0;j<a[i].size();j++)
			{
				y=a[i][j];
				if(abs(l[i]-l[y])!=1)
				{
					bl=1;
					break;
				}
			}
			if(bl)break;
		}
		if(!bl)
		{
			viz.reset();
			viz[t]=1;
			for(i=1;i<=n;i++)
			{
				if(viz[i])continue;
				cur=0;
				dfs(i);
				if(cur>mx.fr)mx=mkp(cur,mx.fr);
				else if(cur>=mx.sc)mx.sc=cur;
			}
			mx.sc=max(mx.sc,1);
			rs=max(rs,mx.fr+mx.sc-1);
		}
	}
	if(rs)rc(rs);
	rc(-1);
	return 0;
}


Measured memory_bytes: 512
my $s = <STDIN>;
chomp $s;
my ($n, $p) = split ' ', $s;
my @str = reverse <> =~ /./g;
my @c = 1;
my $t = 1;
my $output = '';
my $a = 0;
foreach my $i (@str) {
    if ($p != 2 and $p != 5) {
        $output += $c[$a = ($a + $i * $t) % $p]++;
    }
    else {
        $output += $n-- * !($i % $p);
    }
    $t = $t * 10 % $p;
}
print $output;

Measured memory_bytes: 32204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n),v(n);
    ll vmax=0;
    rep(i,n){
        cin>>w[i]>>v[i];
    }
    vmax=100010;

    ll dp[n+1][vmax];

    rep(i,n+1)rep(j,vmax)dp[i][j]=LLINF;
    dp[0][0]=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<vmax;j++){
            if(j-v[i]>=0){
                chmin(dp[i+1][j],dp[i][j- v[i]] + w[i]);
            }
            
            chmin(dp[i+1][j],dp[i][j]);
            
        }
    }/*
    for(int i=0;i<n;i++){
        for(int j=0;j<vmax;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl<<endl;
    }/*/
    ll ans = 0;
    for (int i=0;i<vmax;i++) {
        if (dp[n][i] <= W) ans = i;
    }

    cout<<ans<<endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 79360
import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
L = lr()
L.sort()
answer = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        index = bisect_left(L, (L[i]+L[j]))
        answer += index - j - 1

print(answer)


Measured memory_bytes: 44380
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))
from itertools import product

def main():
    N = int(input())
    adj = [inpl() for _ in range(N)]
    need = [[True]*N for _ in range(N)]
    ok = True
    res = 0
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if adj[i][j] < adj[i][k] + adj[k][j]:
                    continue
                elif i == k or j == k:
                    continue
                elif adj[i][j] == adj[i][k] + adj[k][j]:
                    need[i][j] = False
                    need[j][i] = False
                else:
                    ok = False
    if ok:
        for i in range(N):
            for j in range(i+1, N):
                if need[i][j]:
                    res += adj[i][j]
        print(res)
    else:
        print(-1)

main()

Measured memory_bytes: 45020
"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
import math
import sys
# input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp(): #Reads integer input
    return(int(input()))
def inlt(): #Reads list of int
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr(): #Reads numbers into separate var
    return(map(int,input().split()))

n = int(input())
stones = inlt()
dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(stones[1] - stones[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(stones[i] - stones[i-1]), dp[i-2] + abs(stones[i] - stones[i-2]))
print(dp[n-1])

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

int main() {
  int a, b, ans;
  char op;
  while (cin >> a >> op >> b, op != '?') {
    if (op == '+')
      ans = a + b;
    else if (op == '-')
      ans = a - b;
    else if (op == '*')
      ans = a * b;
    else if (op == '/')
      ans = a / b;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3028
#include <stdio.h>
#include <math.h>

int main()
{
	double r;
	double area, circumference;

	scanf("%lf", &r);

	area = pow(r, 2.0)*M_PI;
	circumference = 2*r*M_PI;

	printf("%lf %lf\n", area, circumference);

	return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
   int a[101],b[101];
   int n;
   while(cin>>n&&n>0&&n<101)
   {
       int temp;
       if(n<4)
       {
           cout<<"No"<<endl;
           continue;
       }
       if(n%4==0)
       {
           int x=n/4;
           if(x>0)
           {
               cout<<"Yes"<<endl;
           }
           else
           {
               cout<<"No"<<endl;
           }
           continue;
       }
       if(n%7==0)
       {
           int y=n/7;
           if(y>0)
           {
               cout<<"Yes"<<endl;
           }
           else
           {
               cout<<"No"<<endl;
           }
           continue;
       }
       temp=n/4;
       int flag=0,tt=0;
       if(temp*4>n)
       {
           temp--;
       }
       for(int i=0;i<=temp;i++)
       {
           int uu;
           uu=i*4;
           if((n-uu)%7==0)
           {
               tt=1;
               flag=(n-uu)/7;
               if(i+flag>=2)
               {cout<<"Yes"<<endl;}
               break;
           }
       }
       if(tt!=1)
       {cout<<"No"<<endl;}

   }
    return 0;
}

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

  int tmp[5];

int main() {

 int A,B; cin >> A >> B;
 int cnt = 0;
 int num;
  for ( int i = A; i <= B; i++ ) {
    num = i;
    for ( int j = 0; j < 5; j++ ) {

      tmp[j] = num % 10;
      num -= tmp[j];
      num /= 10;
    }
    if ( tmp[0] == tmp[4] && tmp[1] == tmp[3] ) cnt++;
 }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>

#define MAX_N   100
#define MAX_W   10000

using namespace std;

int n, W;
int w[MAX_N], v[MAX_N];

int dp[MAX_N + 1][MAX_W + 1];   // DPテーブル

void solve()
{
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      if (j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
  printf("%d\n", dp[n][W]);
}

int main(void)
{
  int i;
  cin >> n >> W;

  for (i = 0; i < n; i++) {
    cin >> v[i] >> w[i];
  }

  solve();

  return 0;
}

Measured memory_bytes: 5052
package main

import (
	"fmt"
	"math"
)

func main()  {
	var n, d int
	fmt.Scan(&n, &d)

	x := make([][]float64, n)
	for i:=0; i<n; i++ {
		x[i] = make([]float64, d)
		for j:=0; j<d; j++ {
			fmt.Scan(&x[i][j])
		}
	}

	ans := 0
	for i:=0; i<n-1; i++ {
		for j := i+1; j < n; j++ {
			var sum, tmp float64
			for k:=0;k<d;k++ {
				tmp = math.Abs(x[i][k] - x[j][k])
				tmp *= tmp
				sum += tmp
			}
			sum = math.Sqrt(sum)
			if sum == float64(int64(sum)) {
				ans++
			}
		}
	}

	fmt.Println(ans)
}

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

int n;
set<int> st;
vector<int> ans;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    st.insert(x);
  }
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if(st.find(x) != st.end()) ans.push_back(x);
  }
  cout << ans.size() << endl;
  return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}

string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}

int main(){
    vecll a(5);
    ll ma=10;
    ll ans=0;
    rep(i,5){
        a[i]=in();
        ll x=a[i]%10;
        ans += (a[i]+9)/10*10;
        if(x!=0) ma=min(ma,x);
    }
    ans -= 10;
    ans+= ma;
    cout<<ans<<endl;
}


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

int main(){
	cout<<fixed<<setprecision(12);

	double a, b, C, c, S, L, h, rad;

	cin>>a>>b>>C;
	
	rad = C / 180 * acos(-1);

	S = (a * b * sin(rad)) / 2;
	c = sqrt(a * a + b * b -2 * a * b * cos(rad));
	L = a + b + c;
	h = 2 * S / a;
	
	cout<<S<<endl<<L<<endl<<h<<endl;
	
	return 0;	
}


Measured memory_bytes: 3512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());
    int f1 = false;
    int ls = 0;
    for(int i = 0; i < n - 1; i++) {
        if(!f1 && a[i] == a[i + 1]) {
            f1 = true;
            ls = a[i];
            i++;
        } else if(f1 && a[i] == a[i + 1]) {
            cout << ls * a[i] << endl;
            return 0;
        }
    }

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

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


using namespace std;

typedef long long ll;

const int MAXN = 100 * 1000 + 123;




bool inp[MAXN];
int ps[MAXN];

void gh() {
	inp[0] = inp[1] = true;
	for (int i = 2; i < MAXN; i++)
		if (!inp[i])
			for (ll j = (ll)i * i; j < MAXN; j += i)
				inp[j] = true;
}


int main() {
	gh();
	for (int i = 1; i < MAXN; i++) {
		ps[i] = ps[i - 1];
		if (!inp[i - 1] && !inp[i >> 1])
			ps[i]++;
	}
	int q, l, r;
	cin >> q;
	while (q--) {
		cin >> l >> r;
		cout << ps[r + 1] - ps[l] << '\n';
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int i,dp[100010][13];
char c;
int main()
{
	dp[0][0]=1;
	c=getchar();
	for(i=1;c!='\n';i++)
	{
		if('0'<=c&&c<='9')
			for(int j=0;j<13;j++)
				dp[i][(10*j+c-'0')%13]=dp[i-1][j];
		else
			for(int j=0;j<10;j++)
				for(int k=0;k<13;k++)
					dp[i][(10*k+j)%13]=(dp[i][(10*k+j)%13]+dp[i-1][k])%MOD;
		c=getchar();
	}
	printf("%d\n",dp[i-1][5]);
	return 0;
}

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

using namespace std;
#define ll long long

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    ll sum=0;
    for(int i=0;i<k;i++)
    {
        sum=sum+arr[i];
    }
    cout<<sum;
}


Measured memory_bytes: 3600
#include <iostream>
#include <math.h>
#include <list>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <climits>
#include <string>
#include <vector>

using namespace std;

#define endl '\n'
#define int long long
#define mod 1000000007

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

int32_t main() {
    
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n; cin>>n;

	vector<vector<int>> maxHappiness(n+1, vector<int>(4, 0));

	for(int i=1;i<=n;i++) {
		vector<int> happiness(4);

		for(int j=1;j<happiness.size();j++) {
			cin>>happiness[j];
				
			for(int k=1;k<happiness.size();k++) {
				if(j == k) continue;

				maxHappiness[i][j] = max(maxHappiness[i][j], maxHappiness[i-1][k]);
			}

			maxHappiness[i][j]+=happiness[j];
		}
	}

	int ans=0;
	for(int i=1;i<4;i++) {
		ans = max(ans, maxHappiness[n][i]);
	}
		
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define M 100000008

ll dp[101][100004];
ll o[101][100004];
ll pre[101][100004];
ll m = 1000000007;

int main()
{
	FAST;
	ll n, k, i, j;
	cin >> n >> k;
	ll a[n];
	fr(i,1,n+1)
		cin >> a[i];
	fr(i,1,n+1)
	{
		fr(j,0,100004)
		{
			if(i == 1)
			{
				if(j > a[i])
					dp[i][j] = 0;
				else if(j <= a[i])
					dp[i][j] = 1;
			}
			else
				dp[i][j] = (pre[i-1][j] - pre[i-1][max((ll)0,j-a[i])] + dp[i-1][max((ll)0,j-a[i])] + m)%m;
//			trace4(i,j,dp[i][j],a[i]);
		}
		pre[i][0] = dp[i][0];
		fr(j,1,100004)
			pre[i][j] = (pre[i][j-1] + dp[i][j])%m;
	}
//	cout << dp[1][0] << endl;
	cout << dp[n][k];
}


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

int main() {
    string S;
    cin >> S;

    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else if (S == "Rainy") cout << "Sunny" << endl;
}

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

int main() {
  int n; 
  cin >> n;
  if(n % 2 == 0){
    cout << (n / 2) * (n / 2) <<endl;
  }
  else if(n % 2 != 0){
    cout << ((n - 1) / 2) * ((n + 1) / 2)  << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin>>x;
    ll d=x/500;
    ll ans=d*1000ll;
    x-=d*500;
    ans+=(x/5)*5;
    cout<<ans<<"\n";
    return 0;
}

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

arr = [map(int,raw_input().split()) for i in range(2)]

ans = [[0 for i in range(n)] for j in range(2)]

ans[0][0] = arr[0][0]
ans[1][0] = arr[0][0] + arr[1][0]

for i in range(n-1):
	ans[0][i+1] = ans[0][i] + arr[0][i+1]

for i in range(n-1):
	ans[1][i+1] = max(ans[0][i+1] + arr[1][i+1], ans[1][i] + arr[1][i+1])

print ans[1][n-1]

Measured memory_bytes: 2696
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N,M,a,total(0);
    cin >> N >> M;
    vector<int> As;
    
    
    for(int i=0;i<N;++i){
        cin >> a;
        total += a;
        As.push_back(a);
    }
    sort( As.begin(), As.end(), greater<int>() );

    int cnt(0);
    for( auto a : As){
        if( a*4*M < total ) break;
        ++cnt;
    }

    if(cnt>=M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main(){

    string s;
    cin >>s;

if(s=="AAA"||s=="BBB"){cout << "No" <<endl;}else{cout << "Yes" <<endl;}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int x,a;
	cin>>x>>a;
	if(x<a)cout<<0<<endl;
	else cout<<10<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(2e5 + 5);
int n, x, freq[N];
int main() {
    DAU
    cin >> n;
    for (int i = 2; i <= n; ++i)
        cin >> x, ++freq[x];
    for (int i = 1; i <= n; ++i)
        cout << freq[i] << '\n';
    PLEC
}


Measured memory_bytes: 4448