akhauriyash/Code-Regression huggingface dataset:
def prime_number(n):
    lis= []
    for i in range(2,n+1):
        j = 2
        flag = 0
        
        while j*j <= i:
            if i%j ==0:
                flag = 1
                break
            else:
                j +=1
        if flag ==0:
            lis.append(i)
    return lis



N= int(input())
m = 10**9+7
pri_num = prime_number(N)
dic = {}

for i in range(2,N+1):
    for pri in pri_num:
        while i>0:
            if i % pri == 0:
                if pri in dic:
                    dic[pri] +=1
                else:
                    dic[pri]=1
                i = i//pri

            else:
                break

count = 1
for val in dic.values():
    count = (count*(val+1))%m
print(count)

            


Measured memory_bytes: 9144
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	str s; get s;
	long w; get w;

	for (int i = 0; i < s.length(); i += w){
		put s.at(i);
	}
}

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


Measured memory_bytes: 256
from collections import defaultdict

H, W, N = map(int, input().split())

mem = defaultdict(int)
for _ in range(N) :
    a, b = map(int, input().split())
    for i in range(max(2, a-1), min(H-1, a+1)+1) :
        for j in range(max(2, b-1), min(W-1, b+1)+1) :
            mem[(i, j)] += 1
            
ret = [0] * 10
for k, v in mem.items() :
    ret[v] += 1

ret[0] = (H - 2) * (W - 2) - sum(ret)
 
for r in ret :
    print(r)


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

int main() {
	int a, b;
	cin >> a >> b;
	string s, t;
	char p = a + '0';
	char k = b + '0';
	while (b > 0) {
		s += p;
		b--;
	}
	while (a > 0) {
		t += k;
		a--;
	}
	if (s >= t) cout << t << endl;
	else cout << s << endl;
	return 0;
}


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

using namespace std;

int N;
const int LEN = 10;
int arr[LEN+1];
vector<int> bucket[2];

bool dfs(int n, int idx)
{
    if (n == LEN)
        return true;
    vector<int>& buc = bucket[idx];
    if (!buc.empty() && arr[n] < buc.back()) return false;
    buc.push_back(arr[n]);
    bool res[2];
    res[0] = dfs(n+1, 0);
    if (res[0]) goto finish;
    res[1] = dfs(n+1, 1);
finish:
    buc.erase(buc.end()-1);
    return res[0] || res[1];
}

int main()
{
    scanf("%d", &N);
    for (int j = 0; j < N; j++) {
        for (int i = 0; i < LEN; i++) {
            scanf("%d", &arr[i]);
        }
        if (dfs(0, 0) || dfs(0, 1)) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <algorithm>

using namespace std;

int n;

int main()
{
    scanf("%d", &n);
    int cnt = 0, flag = 0;
    for (int i = 1; i <= n; i ++ )
    {
        int a, b;
        scanf("%d%d", &a, &b);
        if (a == b) cnt ++;
        if (a != b) cnt = 0;
        if (cnt == 3) flag = 1;
    }

    if (flag) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 3760
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
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;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int h,w,n;
  cin >> h >> w >> n;

  int x = max(h,w);

  cout << n/x + (n%x>0) << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    vector<vector<ll>> v(m+1);
    REP(i, n) {
        if(m-a[i]>=0) v[m-a[i]].push_back(i);
    }

    ll ret = 0;
    set<PII> st;
    for(ll i=m; i>=0; --i) {
        // i日目に受けられる仕事
        for(auto j: v[i]) {
            st.insert({-b[j], j});
        }
        // cout << i << " " << st << endl;
        if(st.size()) {
            ret -= (*st.begin()).first;
            st.erase(st.begin());
        }
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 11392
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	int cnt = 0;
	vector<int> a(n);
	ll sum = 0;
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}
	rep(i,n){
		if(a[i]*4*m >= sum) cnt++;
	}
	if(cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> a(n), b(n), c(n);
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, n) cin >> b[i];
   rep(i, 0, n) cin >> c[i];
   sort(all(a));
   sort(all(c));
   ll ans = 0;
   for (int i = 0; i < n; i++) {
      int l = lower_bound(all(a), b[i]) - a.begin();
      int r = c.end() - upper_bound(all(c), b[i]);
      ans += (ll)l * r;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int M, D;
  cin >> M >> D;
  int ans = 0;
  for(int d = 1; d <= D; d++){
    int d1 = d % 10;
    int d10 = d / 10;
    if(d1 >= 2 && d10 >= 2 && d1 * d10 <= M) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def primes(n):
    i = 1
    p = [2]
    while i+2 <= n:
        flag = True
        i += 2
        for j in range(3, int(i**(1/2))+1, 2):
            if i % j == 0:
                flag = False
                break
        if flag:
            p.append(i)
    return p
            
n = int(input())
p = primes(10**5+10)
print([i for i in p if i >= n][0])
        

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A[i] = a - 1;
    }


    ll cnt = 0;
    ll cur = 0;
    bool ok = true;
    while (cur != 1) {
        cur = A[cur];
        ++cnt;
        if (cnt == N) {
            ok = false;
            break;
        }
    }

    if (ok)
        cout << cnt << endl;
    else
        cout << -1 << endl;
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 15;

int main()
{
	int a,b,h,ans;
	cin >> a >> b >> h;
	ans = ((a + b)*h)/2;
	cout << ans << endl;
	return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	ll n;
	cin >> n;
	
	vector<ll> v(5);
	for(int i = 0; i < 5; i++) {
		cin >> v[i];
	}
	
	ll ans = ceil((n - 1) / *min_element(ALL(v))) + 5;
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static int n;
    public static int s;
    public static int cnt;

    public static void search(int i,int l,int m){
        if(i==n){
            if(l==0){
                cnt+=1;
            }
        }
        if(l<0){
            return;
        }
        for(int o=Math.min(m, 9);o>=0;o--){
            search(i+1,l-o,o-1);
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        s=sc.nextInt();
        while(n!=0 || s!=0){
            cnt=0;
            search(0, s, s);
            System.out.println(cnt);
            n=sc.nextInt();
            s=sc.nextInt();
        }
        sc.close();
    }
}



Measured memory_bytes: 26132
#include <stdio.h>
int main(void){
    
   int H,W,i,j;
   
   while(1){
       scanf("%d %d",&H,&W);
       if(H==0 && W==0) break;
       else{
           for(i=0;i<H;i++){
               for(j=0;j<W;j++) printf("#");
               printf("\n");
           }
       }
       printf("\n");
   }
   
    return 0;
    
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int main(){
	ios::sync_with_stdio(false);

    int n;
    cin>>n;
    vl a(n);
    REP(i,0,n)cin>>a[i];
    sort(a.begin(),a.end());
    int I=0;
    while(I<(n-1)){
        for(int i=I+1;i<n;i++){
            a[i]=a[i]%a[I];
        }
        sort(a.begin(),a.end());
        for(int i=I;i<n;i++){
            if(a[i]!=0){
                I=i;
                break;
            }
        }
    }
    cout<<a[n-1]<<"\n";

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define lson t << 1, l, mid
#define rson t << 1 | 1, mid + 1, r
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i > b; i--)
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 2e5 + 5;

int n;
LL a[N], sum[N];

int main()
{
//	ios::sync_with_stdio(false);
	scanf("%d", &n);
	rep(i, 1, n + 1)  scanf("%lld", &a[i]);
	rep(i, 1, n + 1)  sum[i] = sum[i - 1] + a[i];
	LL ans = (1LL << 60);
	rep(i, 1, n)
		ans = min(ans, abs(sum[i] - (sum[n] - sum[i])));
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3328
using System;

public class B
{
  public static void Main()
  {
    int num = int.Parse(Console.ReadLine().Replace(" ", ""));
    float sqrt = (float)Math.Sqrt(num);
    if(sqrt == (int)sqrt)
    {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//A
int main() {
	ll X;
	scanf("%lld", &X);
	ll Y;
	scanf("%lld", &Y);

	ll result = 0;

	if (X == 3) {
		result += 100000;
	}
	else if (X == 2) {
		result += 200000;
	}
	else if (X == 1) {
		result += 300000;
	}

	if (Y == 3) {
		result += 100000;
	}
	else if (Y == 2) {
		result += 200000;
	}
	else if (Y == 1) {
		result += 300000;
	}

	if (X == 1 && Y == 1) {
		result += 400000;
	}

	printf("%lld\n", result);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
vector<int>v[N];
int c[N],d[N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,i,x,y;
	long long s=0;
	cin>>n;
	for(i=1;i<n;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(i=0;i<n;i++)
	{
		cin>>c[i];
		s+=c[i];
	}
	sort(c,c+n);
	s-=c[n-1];
	queue<int>q;
	int p=n-1;
	d[1]=c[p--];
	q.push(1);
	while(q.size())
	{
		x=q.front();
		q.pop();
		for(i=0;i<(int)v[x].size();i++)
		{
			if(d[v[x][i]]==0)
			{
				d[v[x][i]]=c[p--];
				q.push(v[x][i]);
			}
		}
	}
	cout<<s<<'\n';
	for(i=1;i<n;i++)
		cout<<d[i]<<' ';
	cout<<d[i]<<'\n';
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b;
    cin >> a >> b;
    cout << 2 * b - a;
}

Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Buffer(make([]byte, 64*1024*1024), 64*1024*1024)
  sc.Scan()
  strArr := strings.Split(sc.Text(), " ")
  N, _ := strconv.Atoi(strArr[0])
  T, _ := strconv.Atoi(strArr[1])
  sc.Scan()
  strArr = strings.Split(sc.Text(), " ")
  coml := 0
  a := 0
  for i := 0; i < N; i++ {
    t, _ := strconv.Atoi(strArr[i])
    if t < a {
      coml += t-a+T
    } else {
      coml += T
    }
    a = t+T
  }
  fmt.Println(coml)
}


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

fn main(){
    let n: usize = read();
    let l: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    let mut po: usize = 0;
    for i in 0..n-1 {
        if a[i] + a[i+1] >= l {
            po = i + 1;
            break;
        }
    }
    if po == 0 {
        println!("{}", "Impossible");
    } else {
        println!("{}", "Possible");
        for i in 1..po {
            println!("{}", i);
        }
        for i in 1..n-po {
            println!("{}", n - i);
        }
        println!("{}", po);
    }
}

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

Measured memory_bytes: 4860
// https://beta.atcoder.jp/contests/abc102/tasks/arc100_b

#include<bits/stdc++.h>
#define ll long long

using namespace std;
ll n, a[1000000], c[1000000], ans = 1e18;

void cal(int i, int j, int k){
    if (0 <= i && i < j && j < k && k < n){
        ll sum[] = {
            c[i],
            c[j] - c[i],
            c[k] - c[j],
            c[n-1] - c[k],
        };
        ans = min(ans, *max_element(sum, sum + 4) - *min_element(sum, sum + 4));
    }
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    partial_sum(a, a + n, c);
    for (int j = 0; j < n; j++){ // [0, j), [j, n]
        int i = lower_bound(c + 0, c + j, (c[j-1] + 1)/2) - c;
        int k = lower_bound(c + j, c + n, c[j-1] + (c[n-1] - c[j-1] + 1)/2) - c;
        cal(i, j - 1, k);
        cal(i - 1, j - 1, k);
        cal(i, j - 1, k - 1);
        cal(i - 1, j - 1, k - 1);
    }
    cout << ans;
}


/*
10
10 71 84 33 6 47 23 25 52 64

ans: 36

*/

Measured memory_bytes: 5888
import sys
input = sys.stdin.readline
r,c,k = map(int,input().split())
l = [[0]*c for i in range(r)] 
for i in range(k):
    x,y,v = map(int,input().split())
    l[x-1][y-1] = v
dp = [[0]*4 for i in range(c+1)]

for i in range(r):
    ndp = [[0]*4 for i in range(c+1)]
    for j in range(c):
        M = max(dp[j+1])
        if l[i][j]>0:
            v = l[i][j]
            ndp[j+1][0] = max(M,dp[j][0],ndp[j][0])
            ndp[j+1][1] = max(M+v,dp[j][0]+v,ndp[j][0]+v,dp[j][1],ndp[j][1])
            ndp[j+1][2] = max(dp[j][1]+v,ndp[j][1]+v,dp[j][2],ndp[j][2])
            ndp[j+1][3] = max(dp[j][2]+v,ndp[j][2]+v,dp[j][3],ndp[j][3])
        else:
            ndp[j+1][0] = max(M,dp[j][0],ndp[j][0])
            ndp[j+1][1] = max(dp[j][1],ndp[j][1])
            ndp[j+1][2] = max(dp[j][2],ndp[j][2])
            ndp[j+1][3] = max(dp[j][3],ndp[j][3])
    dp = ndp
print(max(dp[-1]))

Measured memory_bytes: 224400
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>

#define ll long long
#define db double
#define rg register int

using namespace std;

ll ans;
int n,rt;
ll d[100005];
int sz[100005];
int bg[100005];

struct su{
	int to,v,next;
}b[200005];
int tou[200005],top;

inline int qr(){
	register char ch; register bool sign=0; rg res=0;
	while(!isdigit(ch=getchar()))if(ch=='-')sign=1;
	while(isdigit(ch))res=res*10+(ch^48),ch=getchar();
	if(sign)return -res; else return res;
}

inline void find(int i,int fa){
	sz[i]=1;
	for(rg j=tou[i];j;j=b[j].next){
		rg to=b[j].to; if(to==fa)continue;
		find(to,i); sz[i]+=sz[to];
		bg[i]=max(bg[i],sz[to]);
	} bg[i]=max(bg[i],n-sz[i]);
	if(bg[i]<bg[rt]) rt=i;
}

inline void dfs(int i,int fa){
	sz[i]=1; ans+=d[i];
	for(rg j=tou[i];j;j=b[j].next){
		rg to=b[j].to; if(to==fa)continue;
		d[to]=d[i]+b[j].v; dfs(to,i); sz[i]+=sz[to];
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=qr(); bg[0]=n;
	for(rg i=1;i<n;++i){
		rg x=qr(),y=qr(),v=qr();
		b[++top]=su{y,v,tou[x]}; tou[x]=top;
		b[++top]=su{x,v,tou[y]}; tou[y]=top;
	} find(1,0); d[rt]=0; dfs(rt,0); ans<<=1;
	rg mx=1e9;
	for(rg j=tou[rt];j;j=b[j].next){
		rg to=b[j].to;
		if(!(n&1)&&sz[to]==n/2){
			printf("%lld\n",ans-b[j].v); return 0;
		} mx=min(mx,b[j].v);
	} printf("%lld\n",ans-mx);
	return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  int n;
  cin >> n;
  int count = 40;
  ll nn = abs(n);
  if(n > 0){
    rep(i,count){
      if(i%2 == 1){
        if(nn>>i&1){
          nn += pow(2,i+1);
        }
      }
    }
  }
  else{
    rep(i,count){
      if(i%2 == 0){
        if(nn>>i&1){
          nn += pow(2,i+1);
        }
      }
    }
  }
  if(n != 0){
    for(int i = count;i>=0;i--){
      if(nn>>i&1){
        if((ll)(pow(2,i))<=nn){
          cout << 1;
        }
      }
      else{
        if((ll)(pow(2,i))<=nn){
          cout << 0;
        }
      }
    }
  }
  else{
    cout << 0 << endl;
  }
}



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

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

  vector<int> x(n);
  vector<int> y(n);

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

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

  int c[2];
  c[0] = y[n/2 - 1];
  c[1] = y[n/2];

  for(int i = 0; i < n; i++){
    if(c[0] == c[1]) cout << c[0] << endl;
    else if(c[0] < x[i]) cout << c[0] << endl;
    else cout << c[1] << endl;
  }

  return 0;

}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 103;

int n;char s[_],t[_];

int main()
{
	n=ty(),ts(s+1),ts(t+1);
	for(int i=n;i>=0;i--)
	{
		for(int j=1;j<=i;j++)
			if(s[n-i+j]!=t[j])goto fail;
		printf("%d\n",n+n-i);
		return 0;
	fail:;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[1010][1010];

//long longしか使わない
int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll res = 0;
	ll ans = min(k, a) - max(res, k - a - b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
// inputに入力データ全体が入る
function Main(input) {
    var N = input[0].split(" ")[0]-0;
    var K = input[0].split(" ")[1]-0;
    var list = input[1].split(" ").join("");
    var ex = new RegExp("[" + list + "]");
    while(true){
        if(!ex.test(N.toString())) break;
        N++;
    }
    console.log(N);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 10408
n,m,x,y = input().split()
xn_list = map(int, input().split())
ym_list = map(int, input().split())

res = 'No War'
xn_max = max(xn_list)
ym_min = min(ym_list)
y = int(y)
x = int(x)

if xn_max >= ym_min or xn_max >= y or x >= ym_min:
    res = 'War'

print(res)


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

int main() {
  int n;cin>>n;
  vector<pair<double, string>> v(n);
  double ans=0;
  rep(i,n){
    cin>>v.at(i).first>>v.at(i).second;
    double v1=v.at(i).first;
    string v2=v.at(i).second;
    if(v2=="JPY")ans+=v1;
    else{ans+=v1*380000;}
  }
  cout<<ans;            
}
      



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    repl(i, 1, n) {
        int k = n - i;
        const auto &pf = prime_factorize(k);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans += res;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

ll N;

void solve()
{
	ll ans = 0;
	ll p = N / 11, r = N % 11;
	if(r==0){
		ans = 2*p;
	}else if(r <= 6){
		ans = 2*p + 1;
	}else{
		ans = 2*p + 2;
	}
	cout << ans << endl;
}

int main()
{
	cin >> N;
	solve();
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int s[100000];
  for(int i=0;i<100000;i++){
    s[i]=0;
  }
  for(int i=0;i<n;i++){
    s[a[i]]++;
  }
  int ans=0;
  for(int i=0;i<99998;i++){
    ans=max(ans,s[i]+s[i+1]+s[i+2]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys

s = tuple(sys.stdin.readline().rstrip())

l = len(s)

# print(l)

def op(n):
  if n == "0":
    return ""
  else:
    return "+"


res = []
for i in range(2**(l-1)):
  
  ops = [op(x) for x in tuple(format(i*2, 'b').zfill(l))]
  
  # print(s)
  # print(ops)

  eq = ''
  for num, j in zip(s, ops):
    eq = eq + num + j
  
  res.append(eval(eq))

print(sum(res))

Measured memory_bytes: 3064
N, M, K = map(int, input().split())
a_l = list(map(int, input().split()))
b_l = list(map(int, input().split()))

i_l, j_l = [0], [0]

best0 = M
ans = 0

for i in range(N):
    i_l.append(i_l[i] + a_l[i])

for i in range(M):
    j_l.append(j_l[i] + b_l[i])

# for j in range(M):
#     total += b_l[j]
#     if total > K:
#         best0 = j-1
#         break
#     elif total == K:
#         best0 = j
#     else:
#         continue

for k in range(N+1):
    if i_l[k] > K:
        break
    while i_l[k] + j_l[best0] > K:
        best0 -= 1
    ans = max(ans, k+best0)
print(ans)
    

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

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

    float ans = ceil(n/2)/n;

    printf("%0.6f", ans);
    //cout << 10/3 << setprecision(4);
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>

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

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	string t = "...";
	int k; 
	string s;
	cin >> k;
	cin >> s;
	if (s.size() <= k) {
		cout << s << endl;
	}
	else {
		string a = "";
		rep(i, k)  a += s[i];
		a += t;
		cout << a << endl;
	}
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main() {
    while(1) {
        string s;
        getline(cin, s);

        if (s == ".") break;
        string b = "";
        for (int i = 0; i < s.size(); ++i) {
            char c = s[i];
            if (c == '(' || c == ')' || c == '[' || c == ']') {
                b.push_back(c);
            }
        }
        
        stack<char> stack;
        bool ok = true;
        //cout << b << endl;
        for (int i = 0; i < b.size(); ++i) {
            switch(b[i]) {
                case '(':
                case '[':
                    stack.push(b[i]);
                break;
                case ')':
                    if (stack.empty()) {ok = false; break;}
                    if (stack.top() == '(') stack.pop();
                    else ok = false;
                break;
                case ']':
                    if (stack.empty()) {ok = false; break;}
                    if (stack.top() == '[') stack.pop();
                    else ok = false;
                break;
            }

            if (!ok) break;
            //cout << stack.size() << endl;
        }

        ok = ok && (stack.size() == 0);

        cout << (ok ? "yes" : "no") << endl;
    }
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)
const int B=700;

bool mycomp(pair<  pair<ll,ll> ,ll > a,pair<  pair<ll,ll> ,ll > b) {
    return a.first.first/B < b.first.first/B || (a.first.first/B == b.first.first/B && a.first.second < b.first.second);
}
const int N=500005;
int mp[N]={0};

void solve() {
    ll n, q;
    cin >> n >> q;
    ll a[n];
    for (long int i = 0; i < n; i++)
        cin >> a[i];

    vector<pair<pair<ll, ll>, ll> > v;
    for (long int i = 0; i < q; i++) {
        ll l, r;
        cin >> l >> r;
        l--, r--;
        v.pb({{l, r}, i});
    }
    sort(v.begin(), v.end(), mycomp);
    ll L = v[0].first.first;
    ll R = v[0].first.second, cnt = 0;
    ll ans[q];
    for (ll i = L; i <= R; i++) {
        mp[a[i]]++;
        if (mp[a[i]] == 1)
            cnt++;
    }
    ans[v[0].second] = cnt;
    for (ll i = 1; i < q; i++) {
        ll pL = v[i].first.first;
        ll pR = v[i].first.second;
        while (L < pL) {
            mp[a[L]]--;
            if (mp[a[L]] == 0) cnt--;
            L++;
        }
        while (pL < L) {
            L--;
            mp[a[L]]++;
            if (mp[a[L]] == 1) cnt++;
        }
        while (R > pR) {
            mp[a[R]]--;
            if (mp[a[R]] == 0) cnt--;
            R--;
        }
        while (R < pR) {
            R++;
            mp[a[R]]++;
            if (mp[a[R]] == 1) cnt++;
        }
        ans[v[i].second] = cnt;
    }
    for (ll i = 0; i < q; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n;
    cin>>s;
    int ans=0;
    for(int i = 0; i < n; ++i){
        set<char> s1;
        set<char> s2;
        // cerr<<"ok"<<endl;
        // cerr<<i<<endl;
        for(int j = 0; j <= i; ++j){
            s1.insert(s[j]);
            // cerr<<s[j]<<endl;
            // cerr<<s1[s1.size()]<<endl;
        }
        //cerr<<"---"<<endl;
        for(int j = i+1; j < n; ++j){
            // cerr<<s[j]<<endl;
            s2.insert(s[j]);
            // cerr<<s2[s2.size()]<<endl;
        }

        int sz=0;
        
        for(auto x : s1){
            if(s2.find(x)!=s2.end()) ++sz;
        }
        
        ans=max(ans,sz);
    }
    cout<<ans<<endl;

    return 0;
}

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

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

    int ans = 0;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i % 2 == 0 && a[i] % 2 == 1) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 1e5 + 5;
int n, k;
int h[MXN];
int dp[MXN];

int Dp(int idx) {
    if(idx == n - 1) return 0;
    if(dp[idx] != -1) return dp[idx];
    int ans = 1e9;
    for(int i = idx + 1; i <= min(n - 1, idx + k); i++) {
        ans = min(ans, Dp(i) + abs(h[idx] - h[i]));
    }
    return dp[idx] = ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    memset(dp, -1, sizeof dp);
    cout << Dp(0) << endl;
    return 0;
}

Measured memory_bytes: 9004
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int ans[100][100] = {};
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 100; j++) {
      ans[i][j] = 1;
    }
  }
  int a, b;
  cin >> a >> b;
  a--; b--;
  int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 100; j++) {
      if (a == 0) break;
      if (ans[i][j] == 0) continue;
      bool ok = true;
      for (int u = 0; u < 4; u++) {
        for (int v = 0; v < 4; v++) {
          int x = i + dx[u];
          int y = j + dy[v];
          if (x < 0 || x >= 100 || y < 0 || y >= 100) continue;
          if (ans[x][y] == 0) ok = false;
        }
      }
      if (ok) {
        ans[i][j] = 0;
        a--;
      }
    }
  }
  for (int i = 50; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (b == 0) break;
      if (ans[i][j] == 1) continue;
      bool ok = true;
      for (int u = 0; u < 4; u++) {
        for (int v = 0; v < 4; v++) {
          int x = i + dx[u];
          int y = j + dy[v];
          if (x < 0 || x >= 100 || y < 0 || y >= 100) continue;
          if (ans[x][y] == 1) ok = false;
        }
      }
      if (ok) {
        ans[i][j] = 1;
        b--;
      }
    }
  }
  cout << 100 << " " << 100 << endl;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      cout << (ans[i][j] ? '#' : '.');
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[][] cell = new long[n][2];
		for(int i = 0; i < n; i++) {
			cell[i][0] = sc.nextInt();
			cell[i][1] = sc.nextInt();
		}
		Arrays.sort(cell, (a, b) -> Long.compare(a[0], b[0]));
		long ans = 0;
		long cnt  = m;
		for(int i = 0; i < n; i++) {
			if(cnt >= cell[i][1]) {
				ans += cell[i][0] * cell[i][1];
				cnt -= cell[i][1];
			}else {
				ans += cell[i][0] * cnt;
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 94908
#include <iostream>

using namespace std;

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#!/user/bin/env ruby

N, M = gets.chomp.split.map(&:to_i)

a = []
while line = gets do
  a << line.chomp.split.map(&:to_i)
end
# p a

min = 0
max = N

a.each do |item|
  if min < item[0] then
    min = item[0]
  end

  if max > item[1] then
    max = item[1]
  end

end


if max < min then
  puts 0
else
  puts 1 + max - min
end



Measured memory_bytes: 9596
#include<stdio.h>
int main()
{
    int n, a, y, sum = 0, count = 0, i=1;

    scanf("%d %d", &n, &a);

    while(i<=n)
    {
        scanf("%d", &y);

        sum = sum + y;

        if(sum <= a)
        {
            count++;
        }
         i++;

    }
    printf("%d", count+1);

    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env ruby
# require 'pry'

# dpテンプレ

n = gets.chomp.to_i
a = gets.split(' ').map(&:to_i)
sum = 0
ruiseki = a.sum
(n-1).times do |i|
  ruiseki -= a[i]
  sum += a[i] * ruiseki
end

puts sum % (10**9 + 7)

Measured memory_bytes: 33844
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll INF = 1001001001001001001;
const double pi = acos(-1);

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> que;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        que.push(a);
    }
    vector<P> cb(m);
    for (int i = 0; i < m; i++)
    {
        int b, c;
        cin >> b >> c;
        cb.push_back({c, b});
    }
    sort(cb.begin(), cb.end());
    reverse(cb.begin(), cb.end());
    for (int i = 0; i < m; i++)
    {
        int x = cb[i].fi;
        int y = cb[i].se;
        while (y > 0)
        {
            if (que.top() < x)
            {
                que.pop();
                que.push(x);
                y--;
            }
            else
            {
                break;
            }
        }
    }
    ll ans = 0;
    while (!que.empty())
    {
        ll x = que.top();
        ans += x;
        que.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1000000007;

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

    ll dp[K.size()+1][D][2] = {};
    dp[0][0][0] = 1;
    // cerr << "start" << endl;
    for(int i=0;i<K.size();i++){
        // cerr << "i = " << i << endl;
        int t = K[i] -'0';
        for(int j=0;j<D;j++){
            // cerr <<"j=" << j <<endl;
            dp[i+1][(j+t)%D][0] += dp[i][j][0]; 
            dp[i+1][(j+t)%D][0] %= MOD;
            for(int d=0;d<10;d++){
                if(d <t){
                    dp[i+1][(j+d)%D][1] += dp[i][j][0];
                    dp[i+1][(j+d)%D][1] %= MOD;
                }
                dp[i+1][(j+d)%D][1] += dp[i][j][1];
                dp[i+1][(j+d)%D][1] %= MOD;
                // cerr <<"d= " << d << "val = " << dp[i+1][(j+d)%D][1] << endl;
            }
            // cerr << "i="  <<i << ", 0val =" << dp[i+1][0][0] << endl;
            // cerr << "i="  <<i << ", 1val =" << dp[i+1][0][1] << endl;
        }
    }
    cout << (dp[K.size()][0][1] +  dp[K.size()][0][0]-1 + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 15872