akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  lint A[N],B[N];
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  lint Asum=0,Bsum=0;
  rep(i,N) Asum+=A[i],Bsum+=B[i];
  if(Asum>Bsum) cout << "No" << endl;
  else{
    lint dis=0,turn=Bsum-Asum;
    rep(i,N) dis+=max(0LL,(B[i]-A[i]+1)/2);
    if(turn<dis) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  long long ans = 0;
  for (int i = 1; i <= N; ++i)
    if (i % 3 != 0 && i % 5 != 0)
      ans += i;
  cout << ans << endl;
}

Measured memory_bytes: 3596
import sys
C=range(1001)
m=0
d=[[0 for i in C] for j in range(2)]
for s in sys.stdin.readlines():
    if s=="\n":m+=1
    else:
        a,b=map(int,s.split(','))
        d[m][a]+=1
for i in C:
    a=d[0][i]
    b=d[1][i]
    if a and b:print i,a+b

Measured memory_bytes: 4240
#include<stdio.h>

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

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

int main(){
  int N,K;
  string S;
  cin >> N >> K >> S;
  
  char small;
  switch(S.at(K-1)){
    case 'A':
      small = 'a';
      break;
    case 'B':
      small = 'b';
      break;
    case 'C':
      small = 'c';
      break;
  }
  S.at(K-1) = small;
  cout << S << endl;
}

Measured memory_bytes: 3596
N,Q = map(int,input().split())
S =input()
l_r = []
for i in range(Q):
  l_r.append(list(map(int,input().split())) )

#先に部分話でSの中のACの数を数えておく
ac_wa = [0] #ACの登場回数の累積和を計算 0文字めは先に足しとく 
for i in range(1,N):
  if (S[i] == "C" and S[i-1] == "A"): #その文字がCで前の文字がAの時のみにカウントを1つたす
    ac_wa.append(ac_wa[i-1]+1)
  else:
    ac_wa.append(ac_wa[i-1])
#出力
for i in range(Q):
  r = ac_wa[l_r[i][1]-1] 
  l = ac_wa[l_r[i][0]-1]
  ans = r-l
  print(ans)

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

using namespace std;

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

    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

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

    int res = 1;
    for (int i = 1; i < n; i++) {
        if (d[i - 1] < d[i]) {
            res++;
        }
    }

    cout << res << endl;
}


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

int main() {
  int N;
  cin >> N ;
  vector<int> A(N);
  for (int i;i<N;i++) {
    cin >> A[i];
  }
  int s=0;
  bool a=false;
  while(true){
    for(int i=0;i<N;i++){
      if(A[i]%2!=0) {a=true;break;}
      A[i]/=2;
    }
    if(a) break;
    s++;
  }
  cout<<s<<endl;
}

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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
  int n;
  int k;
  cin >> n >> k;
  int ans = 0;
  int h;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h >= k) {
        ans++;
    }
  }

  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;

int n,m,u,v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];


int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to: eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
using namespace std;
int main(){
   

    int n,k;
    cin >> n >>k;
    vector<ll> l(k),r(k);
    REP(i,k){
        cin >> l[i] >> r[i];
    }
    int mod = 998244353;

    vector<ll> dp(n+1),dpsum(n+1);
    dp[1] = 1;
    
    for(int i = 1; i<=n;i++){
        REP(j,k){
            int li = i - r[j];
            int ri = i - l[j];
            li = max(li,1);
            if(ri <0) continue;

            dp[i] += (dpsum[ri] - dpsum[li-1]+mod)%mod;
        }
        dpsum[i] = (dpsum[i-1] + dp[i]+mod)%mod;

    }
    
    cout << (dp[n]+mod)%mod <<endl;
}





Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,L;
    cin >> N >> L;
    vector<string> v(N);
    for(int i = 0;i <N;++i){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    for(int i= 0;i < N;++i){
        cout << v[i];
    }
    cout << '\n';
}



Measured memory_bytes: 256
class BIT1():
    """
    Binary Indexed Tree (1-indexed)
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)

    def build(self, data):
        pass

    def add(self, idx, x):
        # add x to idx-th element
        # idx: 1-indexed
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        # get sum of [1, idx]
        # idx: 1-indexed
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s

    def bisect_left(self, w):
        # condition : always all element is not minus
        # return minimum idx where bit.sum(idx) >= w
        if w <= 0:
            return 0
        idx = 0  # self.bit[idx] < w
        k = 1 << ((self.n).bit_length() - 1)
        while k > 0:
            if idx + k <= self.n and self.bit[idx + k] < w:
                w -= self.bit[idx + k]
                idx += k
            k = k >> 1
        return idx + 1

    def bisect_right(self, w):
        # condition : always all element is not minus
        # return minimum idx where bit.sum(idx) > w
        if w < 0:
            return 0
        idx = 0  # self.bit[idx] <= w
        k = 1 << ((self.n).bit_length() - 1)
        while k > 0:
            if idx + k <= self.n and self.bit[idx + k] <= w:
                w -= self.bit[idx + k]
                idx += k
            k = k >> 1
        return idx + 1


n = int(input())
p = list(map(int, input().split()))

p2idx = [0] * (n + 1)
for i in range(1, n + 1):
    p2idx[p[i - 1]] = i

ans = 0
bit = BIT1(n)
for x in reversed(range(1, n + 1)):
    idx = p2idx[x]
    bit.add(idx, 1)
    idx_rank = bit.sum(idx)
    idx_l2 = bit.bisect_left(idx_rank - 2)
    idx_l1 = bit.bisect_left(idx_rank - 1)
    idx_r1 = bit.bisect_left(idx_rank + 1)
    idx_r2 = bit.bisect_left(idx_rank + 2)

    cnt = 0
    cnt += (idx_l1 - idx_l2) * (idx_r1 - idx)
    cnt += (idx - idx_l1) * (idx_r2 - idx_r1)
    ans += x * cnt
    # print(x, idx, idx_l, idx_r, (idx - idx_l) * (idx_r - idx))

print(ans)


Measured memory_bytes: 57768
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int sw[111]; FOR(i,0,111) sw[i] = 0;
  sw[a]++;sw[b]--;sw[c]++;sw[d]--;
  FOR(i,1,111) sw[i] += sw[i-1];
  int ans = 0;
  FOR(i,0,111) if(sw[i] == 2) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  ll big = n / 500;
  ll res = n % 500;
  ll sma = res / 5;

  ll ans = big * 1000 + sma * 5;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
string s;
string st;
cin >> s;
for (auto i = s.begin(); i != s.end(); i++) {
if (*i=='B') {
if (st.size()!=0) st.pop_back();
}
else st.push_back(*i);
}
cout << st << endl;
return 0;
}

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

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}
int pr[1000005];
vector<int>divi[1000005];
void bin()
{
    for(int i=2;i<=1000000;i++)
    {
        if(pr[i]==0)
        {
            for(int j=i;j<=1000000;j+=i)
            {
                pr[j]=1;
                divi[j].push_back(i);
            }
        }
    }
}

int mm[1000005];
int ans[1000005];

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    int a[n+1];
    bin();
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int g=0;
    bool flag=true;
    for(int i=n;i>=1;i--)
    {
        g=__gcd(a[i],g);
        for(auto j:divi[a[i]])
        {
            if(mm[j])
                flag=false;
            mm[j]=1;
        }
    }

    if(flag)
    {
        cout<<"pairwise coprime";
    }
    else if(g==1)
    {
        cout<<"setwise coprime";
    }
    else
        cout<<"not coprime";

}

Measured memory_bytes: 96984
#include<bits/stdc++.h>
using namespace std;
void leftrotate(string &s, int d)
{
    reverse(s.begin(), s.begin()+d);
    reverse(s.begin()+d, s.end());
    reverse(s.begin(), s.end());
}
 
// In-place rotates s towards right by d
void rightrotate(string &s, int d)
{
   leftrotate(s, s.length()-d);
}
main()
{
	string s1,s2;
	cin>>s1>>s2;
	int flag = 1;
	int i =0;
	while(i < s1.length())
	{
		if(s1 == s2)
		{
			flag =0;
			break;
		}
		rightrotate(s1, 1);
		i++;
	}
	if(flag == 0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();

		int num = Integer.parseInt(a + b);

		int root = (int) Math.sqrt(num);

		if (Math.pow(root, 2) == num) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}

int main() {
   ll a, b; cin>>a>>b;
   cout<<(a*b)/(__gcd(a,b))<<endl;
   return 0;
}
/*

*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N;
    cin >> N;
    vector<int> T(N);
    CINVEC(T);
    int M;
    cin >> M;
    vector<pair<int, int>> px(M);
    CINVEC(px);
    REP(i, M)px[i].first--;

    int sum = accumulate(ALL(T), 0);
    REP(i, M) {
        cout << sum - T[px[i].first] + px[i].second << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	string s[100];
	for(int i=0;i<a;i++)
	{
  		cin>>s[i];
	}
	sort(s,s+a);
	for(int i=0;i<a;i++)
		cout<<s[i];
	cout<<endl;

return 0;
}


Measured memory_bytes: 256
n , m = map(int , input().split())
dp = []
for i in range(n + 1):
    dp.append([])
    for j in range(m + 1):
        dp[i].append(0)
arr = []
for i in range(n):
    arr.append(input())
dp[1][1] = 1
for i in range(1,n + 1):
    for j in range(1,m + 1):
        if arr[i - 1][j - 1] == '#' or (i == 1 and j == 1):
            continue
        dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
print(dp[n][m] % 1000000007)

Measured memory_bytes: 168100
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
  int n, k;
  int d[101];
  int a[101][101];
  int res[101];

  cin >> n >> k;
  for(int i = 0; i < k; i++){
    cin >> d[i];
    for (int j = 0; j < d[i]; j++){
      cin >> a[j][i];
    }
  }

  for(int t = 0; t < n; t++){
    for(int i = 0; i < k; i++){
      for(int j = 0; j < d[i]; j++){
        if(a[j][i] == t + 1) res[t] = 1;
      }
    }
  }

  int counter = 0;
  for(int i = 0; i < n; i++){
    if(res[i] == 0) counter ++;
  }

  cout << counter << endl;
  


  return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
    cout << "ABC" + s << endl;


    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <tuple>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#pragma GCC target ("avx2")

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

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

int main(){
  	cin.tie(0);
  	cout.tie(0);
  	ios::sync_with_stdio(false);
	
	long long n, num = 0;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(num + 1 == a[i]){
			num++;
		}
	}
	if(num == 0){
		cout << -1 << endl;
	}else{
		cout << n - num << endl;
	}
	return 0;
}


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

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    if (B - A + 1 <= 2 * K){
        for (int i = A; i <= B; i++){
            cout << i << endl;
        }
    }
    else{
        for (int i = A; i < A + K; i++){
            cout << i << endl;
        }
        for (int i = B - K + 1; i <= B; i++){
            cout << i << endl;
        }
    }
}



Measured memory_bytes: 256
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 2e3+50;
int d[N][N];

vector<int> G[N];

int n, x, y;

void bfs(int s, int d[]) {
    queue<int> q;
    const int INF = 0x3f3f3f3f;
    memset(d, INF, sizeof(int) * (n + 1));
    q.push(s);
    d[s] = 0;
    while (!q.empty()) {
        int u = q.front();
        // dbg(s, u, d[u]);
        q.pop();
        for (int v : G[u]) {
            if (d[v] > d[u] + 1) {
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }
}
int cnt[N];

void add(int x, int y) {
    G[x].push_back(y);
    G[y].push_back(x);
}

int main(int argc, char const *argv[]) {
    // code
    scanf("%d%d%d", &n, &x, &y);
    add(x, y);
    for (int i=1; i<n; ++i)
        add(i, i+1);
    for (int i=1; i<=n; ++i)
        bfs(i, d[i]);
    for (int i=1; i<=n; ++i)
        for (int j=i+1; j<=n; ++j)
            cnt[d[i][j]]++;
    for (int i=1; i<n; ++i)
        printf("%d\n", cnt[i]);
    return 0;
}


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

int main(){
  int s,count;
  count = 0;
  cin >>s;
  for (int i=0;i<3;i++){
    if (s%10==1){
      count++;
      s = (s-1)/10;
    }
    else{
      s = s/10;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  int k;
  int min;
  cin >> n >>k;
  vector<int> tree(n);
  for(int i=0;i<n;i++){
    cin >> tree[i];
  }
  sort(tree.begin(),tree.end());
  min=tree[k-1]-tree[0];
  for(int j=0;j<n-k+1;j++){
    if(min>(tree[k-1+j]-tree[j])){
      min=tree[k-1+j]-tree[j];
    }
  }
  cout<<min;
  return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int count = 0;
		while(sc.hasNext()) {
			String tmp = sc.next();
			if(tmp.length()%2 == 0 && tmp.substring(0, tmp.length()/2+1).equals(R(tmp.substring(tmp.length()/2-1, tmp.length())))){
				count++;
			}
			if(tmp.length()%2 == 1 && tmp.substring(0, tmp.length()/2+1).equals(R(tmp.substring(tmp.length()/2, tmp.length())))) {
				count++;
			}
		}
		out.println(count);
		out.flush();
	}
	public static String R(String a) {
		StringBuffer ret = new StringBuffer();
		for(int i = a.length()-1; i >= 0; i--) {
			ret.append(a.charAt(i));
		}
		return ret.toString();
	}
}

//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 17052
S = input()
N = len(S)

eo = [0, 0]
A = [0] * N

f = False
for i in range(N):
    if S[i] == "R":
        eo[f] += 1
    else:
        A[i-1] += eo[not f]
        A[i] += eo[f]
        eo = [0, 0]
    
    f = not f

s_ = S[::-1]
S = s_
a_ = A[::-1]
A = a_
eo = [0, 0]
f = False
for i in range(N):
    if S[i] == "L":
        eo[f] += 1
    else:
        A[i-1] += eo[not f]
        A[i] += eo[f]
        eo = [0, 0]
    
    f = not f


a_ = A[::-1]
A = a_

for a in A[:-1]:
    print(a, end=" ")
print(A[-1])

Measured memory_bytes: 5596
// AOJ 2254: Fastest Route
// 2017.11.10 bal4u@uu

#include <stdio.h>
#include <string.h>

int t[17][18];
int dp[65600];

char buf[300], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, j, k, a, b, lim;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = getint();
		for (i = 0; i < n; i++) {
			fgets(p=buf, 300, stdin);
			for (j = 0; j <= n; j++) t[i][j] = getint(), p++;
		}
		lim = 1 << n;
		memset(dp, 0x55, sizeof(dp)); dp[0] = 0;
		for (i = 0; i < lim; i++) for (a = 1, j = 0; j < n; j++, a <<= 1) {
			int x = t[j][0];
			for (b = 1, k = 0; k < n; k++, b <<= 1) if (i & b) {
				if (x > t[j][k+1]) x = t[j][k+1];
			}
			if (dp[i | a] > dp[i] + x) dp[i | a] = dp[i] + x;
		}
		printf("%d\n", dp[lim-1]);
	}
	return 0;
}

Measured memory_bytes: 1920
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int i = 0;
        int[] dataAry = new int[5];
        Scanner sc = new Scanner(System.in);
        while ( i < 5 ) {
            dataAry[i] = sc.nextInt();
            i++;
        }
        Arrays.sort(dataAry);

        for ( i = 0; i < 3; i++ ) {
            int temp = dataAry[i];
            dataAry[i] = dataAry[4 - i];
            dataAry[4 - i] = temp;
        }

        i = 0;
        while ( i < 4 ) {
            System.out.print(dataAry[i] + " ");
            i++;
        }

        System.out.println(dataAry[4]);
    }
}

Measured memory_bytes: 12000
//
//  main.cpp
//  miney
//
//  Created by h3037153 on 2018/04/09.
//  Copyright © 2018年 h3037153aa. All rights reserved.
//

#include<iostream>

using namespace std;

int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<(min(A,B)+min(C,D))<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin>>n;
  vector<P> A(n);
  cin>>A;
 
  multiset<int> Neg, Pos;
  Neg.insert(A[0].first);
  Pos.insert(A[0].first);
  int dL = 0, dR = 0, ans = 0;
  
  for(int i=1;i<n;i++){
    int l0, r0; tie(l0, r0) = A[i-1];
    int l1, r1; tie(l1, r1) = A[i];
    int L = *(--Neg.end());
    int R = *Pos.begin();
    dR += r0 - l0;
    dL += r1 - l1;
    
    if(l1 + dL < L){ //接してなくて左側にある。
      ans += abs(l1 + dL - L);

      Neg.erase(Neg.find(L));   //古いLを消す
      Pos.insert(-(dL+dR) + L); //今入っているRよりも左側に行かないといけないので
      
      Neg.insert(l1 + dL);
      Neg.insert(l1 + dL);
        
    }
    else if(R + dR < l1){
      ans += abs(R + dR - l1);
      
      Pos.erase(Pos.find(R)); //古いRを消す
      Neg.insert(R + (dR + dL));      

      
      Pos.insert(l1-dR);
      Pos.insert(l1-dR);
    }
    else { //接している。移動する場合の変曲点のみを追加する。
      Neg.insert(l1 + dL);
      Pos.insert(l1 - dR);
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct LongestCommonSubstring{
  struct node{
    int value;
    node *next;
    node(int value,node *next):value(value),next(next){}
  };
  const int INF=1<<28;
  string x,y;
  LongestCommonSubstring(){}
  LongestCommonSubstring(string x,string y):x(x),y(y){}
  string lcs(){
    int n=x.size(),m=y.size();
    map<char,vector<int> > M;
    for(int j=m-1;j>=0;j--) M[y[j]].push_back(j);
    vector<int> xs(n+1,INF);
    xs[0]=-INF;
    vector<node* > link(n+1);
    for(int i=0;i<n;i++){
      if(M.count(x[i])){
	vector<int> ys=M[x[i]];
	for(int j=0;j<(int)ys.size();j++){
	  int k=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),ys[j]));
	  xs[k]=ys[j];
	  link[k]=new node(y[ys[j]],link[k-1]);
	}
      }
    }
    string res;
    int l=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),INF-1))-1;
    for(node *p=link[l];p!=NULL;p=p->next)
      res.push_back(p->value);
    return res;
  }
};
//END CUT HERE
signed main(){
  int q;
  cin>>q;
  while(q--){
    string x,y;
    cin>>x>>y;
    LongestCommonSubstring lcs(x,y);
    cout<<lcs.lcs().size()<<endl;
  }
  return 0;
}
/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C&lang=jp
*/

Measured memory_bytes: 51012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll X; cin>>X;
	ll st=100, year=0;
	while(st < X){
		ll interst=st/100;
		st += interst;
		year++;
	}
	cout<<year<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int t=0,ans=0;
    string s;
    cin >> s;
    for (int i=0;i<s.size();i++){
        if (t%2==0){
            if (s.at(i)=='0') ans++;
        }
        else {if (s.at(i)=='1') ans++;}
        t++;
    }
    if (ans>s.size()-ans) ans=s.size()-ans;
    cout << ans << endl;
}


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

int main(){
  
  int H,A;
  cin >> H >> A;
  
  int i=0;
  while(i<10000){
    H-=A;
    i++;
    
    if(H<=0){
      break;
    } 
  }
  cout << i <<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	m := nextInt()
	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

using namespace std;
typedef long long int lli;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
typedef pair<lli, lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX = 1e9 + 7;

int main()
{
    fast;
    int t = 1;
    while (t--)
    {
        int n, x, t;
        cin >> n >> x >> t;
        //cout << (n % x) << " ";
        if ((n % x) == 0)
        {
            //cout << "hi";
            lli ans = (t * (n / x));
            cout << ans << "\n";
        }
        else
        {
            lli ans = (t * (n / x + 1));
            cout << ans << "\n";
        }
    }
    return 0;
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b && b<=c && a<=c){
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<=c && c<=b && a<=c){
		cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(b<=a && a<=c && b<=c){
		cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<=c && c<=a && b<=a){
		cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else if(c<=a && a<=b && c<=b){
		cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else if(c<=b && b<=a && c<=a){
		cout<<c<<" "<<b<<" "<<a<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3076
lst=["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
moji = str(input())
ans = "z"
cnt = 0
for i in range(26):
  if lst[i] not in moji and lst[i] <= ans:
    ans = lst[i]
    cnt += 1
if cnt > 0:
  print(ans)
elif cnt==0:
  print("None")
  

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N;
    string S[1005];

    cin >> N;
    for (int i = 0; i < N; i++) cin >> S[i];

    cout << count(S, S + N, "E869120") << endl;
    return (0);
}



Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M, Q;
vector<int> G[100000];
int QC[100001];
int D[100000][11];
int C[100000], T[100000];

bool fg(P a, P b) {
  return a._1 < b._1 && a._2 <= b._2;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  priority_queue<P2> q;
  cin >> Q;
  rep(i, Q) {
    int v, d;
    cin >> v >> d >> QC[i+1];
    v--;
    D[v][d] = i+1;
    q.push(P2(i+1, P(v, d)));
  }
  while (!q.empty()) {
    int r = q.top()._1,
        v = q.top()._2._1,
        d = q.top()._2._2;
    q.pop();
    if (D[v][d] > r) continue;

    if (d == 0) continue;
    for (int t : G[v]) {
      if (D[t][d-1] < r) {
        D[t][d-1] = r;
        q.push(P2(D[t][d-1], P(t, d-1)));
      }
    }
  }
  rep(i, N) {
    int q = *max_element(D[i], D[i]+11);
    cout << QC[q] << "\n";
  }
  return 0;
}


Measured memory_bytes: 19180
INF = 10000000

n = int(input())
m = int(input())

table = [[INF for i in range(n)] for j in range(n)]

for l in range(m):
    a,b,c,d = [int(i) for i in input().split(",")]
    table[a-1][b-1] = c
    table[b-1][a-1] = d
s,g,V,P = [int(i) for i in input().split(",")]

visited = [False for i in range(n)]
cost = [INF for i in range(n)]

cost[s-1] = 0

while True:
    v = -1
    for i in range(n):
        if visited[i] == False and (v == -1 or cost[i] < cost[v]):
            v = i
    if v == -1:
        break
    visited[v] = True
    for i in range(n):
        cost[i] = min(cost[i], cost[v] + table[v][i])

ans = cost[g-1]

visited = [False for i in range(n)]
cost = [INF for i in range(n)]

cost[g-1] = 0

while True:
    v = -1
    for i in range(n):
        if visited[i] == False and (v == -1 or cost[i] < cost[v]):
            v = i
    if v == -1:
        break
    visited[v] = True
    for i in range(n):
        cost[i] = min(cost[i], cost[v] + table[v][i])

ans += cost[s-1]

print(V-P-ans)


Measured memory_bytes: 5616
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<climits>
#include<cassert>
#include<cmath>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 110

using namespace std;

int V,E,ans;
vector<int> G[MAX];
int COST[MAX][MAX];
bool used[MAX];

void dfs(int node,deque<int>& deq,int sp){
  if(node >= 15)return;

  if(node >= 2){
    int tmp = [&]()mutable->int{
      int ret = 0;
      int mincost[node];
      rep(i,node) mincost[i] = IINF;
      for(int i=0;i<node;i++){
	for(int j=i+1;j<node;j++){
	  int cost = COST[deq[i]][deq[j]];
	  if(cost==0)return -1;
	  mincost[i] = min(mincost[i],cost);
	  mincost[j] = min(mincost[j],cost);
	}
      }
      rep(i,node) ret += mincost[i]; 
      return ret;
    }();
    if(tmp != -1)ans = max(ans,tmp);
  }

  REP(i,sp,V){
    if(used[i])continue;
    if(G[i].size() < node)continue;
    used[i] = true;
    deq.push_back(i);
    dfs(node+1,deq,i+1);
    deq.pop_back();
    used[i] = false;
  }
}

int main()
{
  cin >> V >> E;
  rep(i,E){
    int u,v,f;
    cin >> u >> v >> f;
    u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
    COST[u][v] = COST[v][u] = f;
  }

  deque<int> deq;
  dfs(0,deq,0);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
  int R, C, n;
  cin >> R >> C >> n;
  rep(i,n) {
    int r, c, v;
    cin >> r >> c >> v;
    a[r-1][c-1] = v;
  }

  rep(i,R)rep(j,C) {
    for (int k = 2; k >= 0; k--) {
      chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
    }
    rep(k,4) {
      chmax(dp[i+1][j][0], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }

  ll ans = 0;
  rep(k,4) chmax(ans, dp[R-1][C-1][k]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 320548
from collections import defaultdict
from bisect import bisect,bisect_left
def eratosthenes(n):
    prime = []
    limit = n**0.5
    numbers = [i for i in range(2,n+1)]
    while True:
        p = numbers[0]
        if limit <= p:
            return prime + numbers
        prime.append(p)
        numbers = [i for i in numbers if i%p != 0]
    return prime
prime = eratosthenes(10**5)
p_d = defaultdict(lambda:0)
prime17 = []
for p in prime:
    p_d[p] = 1
for p in prime:
    if p_d[(p+1)/2] == 1:
        prime17.append(p)

Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    l = bisect_left(prime17,l)
    r = bisect(prime17,r)
    print(r-l)

Measured memory_bytes: 8660
#include "bits/stdc++.h"
using namespace std;

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string s, t;
    cin >> s >> t;

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

    string u;
    cin >> u;

    if (s == u) {
        cout << a - 1 << " " << b << endl;
    }
    else {
        cout << a << " " << b - 1 << endl;
    }

    return 0;
}


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

// 三桁の暗証番号は000-999のどれかでしかないので暗証番号を決め打ちしてそれをSから作れるかを調べる

int main() {
    int N, cnt = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i < 1000; i++) {
        vector<int> c = {
            i/100, (i/10)%10, i%10
        };
        int f = 0;
        for (int j = 0; j < N; j++) {
            if (S.at(j) == ('0' + c.at(f))) {
                f++;
            }
            if (f == 3) {
                break;
            }
        }
        if (f == 3) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    s =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = s.rfind('Z')-s.find('A')+1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 39920
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
	}
	
	const int N=1e6+10;
	int x[N];
	void main()
	{PRE();
		int n=qread(),R=qread();int ans;
		if(n<=10) ans=R+100*(10-n); else ans=R;write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"\n---------------------Zory-------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 80384
N = int(input())
p_list = []
for i in range(N):
  s = input().split(' ')
  p_list.append(s)
X = input()
flg = False
time = 0
count = 0
for sound in p_list:
  if sound[0] == X:
    time = int(sound[1])
    flg = True
  if flg:
    count += int(sound[1])
print(count-time)

Measured memory_bytes: 3064
n = int(input())
a = [0] * (n + 2)
A = list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] = A[i - 1]
d = [abs(a[i + 1] - a[i]) for i in range(n + 1)]
s = sum(d)
print(s - d[0] - d[1] + abs(a[2]))
for i in range(2, n):
    print(s - d[i - 1] - d[i] + abs(a[i + 1] - a[i - 1]))
print(s - d[-1] - d[-2] + abs(a[-3]))

Measured memory_bytes: 14940
while True:
    n, x = list(map(int, input().split(" ")))
    if (n == 0) and (x == 0):
        break
    ans = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if x == i+j+k:
#                     print("%d %d %d"%(i, j, k))
                    ans += 1
                    break
    print (ans)
                    

Measured memory_bytes: 7676
//11
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>

using namespace std;

struct NM{
  map<string,int> m;
  vector<string> v;
  void rec(string s){
    if(!m.count(s)){
      m[s]=v.size();
      v.push_back(s);
    }
  }
};

int main(){
  for(int n;scanf("%d",&n),n;){
    NM nm;
    int d[200][200];
    fill(d[0],d[200],1<<29);
    for(int i=0;i<200;i++){
      d[i][i]=0;
    }
    int s[100],t[100],c[100];
    for(int i=0;i<n;i++){
      char a[17],b[17];
      int cs;
      scanf(" 1 %s = 10^%d %s",a,&cs,b);
      nm.rec(a);
      nm.rec(b);
      s[i]=nm.m[a];
      t[i]=nm.m[b];
      c[i]=cs;
      d[s[i]][t[i]]=cs;
      d[t[i]][s[i]]=-cs;
    }
    for(int i=0;i<200;i++){
      for(int j=0;j<200;j++){
	for(int k=0;k<200;k++){
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
	}
      }
    }
    int i;
    for(i=0;i<n;i++){
      if(d[s[i]][t[i]]!=c[i])break;
    }
    puts((i==n)?"Yes":"No");
  }
  return 0;
}

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

int main() {
  long long x, y, z;
  cin >> x >> y;
  
  bool exist = false;
  for(int i=1; i<=y; i++) {
    z = x*i;
    if(x%y==0) break;
    if(z%y!=0) {
      exist = true;
      break; 
    }
  }
  if(exist) cout << z << endl;
  else cout << -1 << endl;
  return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    ll n;
    cin >> n;

    // 処理
    ll sum = 1;
    for (int i = 1; i <= n; i++) {
        sum *= i;
        sum = sum % mod;
    }

    // 出力
    cout << sum << endl;

    return 0;
}


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

int pow100 (int n)
{
  int r = 1;
  for (int i = 0; i < n; ++i) r *= 100;
  return r;
}

int main()
{
  int d, n;
  cin >> d >> n;
  cout << pow100 (d) * (n == 100 ? n + 1 : n) << endl;
}

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

int main(void)
{
  unsigned long long N, A, B;
  cin >> N >> A >> B;
  unsigned long long diff = B - A;
  if (A > B || (N == 1 && A != B)) {
    cout << 0 << endl;
  } else {
    cout << diff * (N-2) + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 256