akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int main () {
	int n; 
	cin >> n;
	int cnt = 0;
	int look_for = 1;
	for(int i = 0; i < n; i++) {
		int cur; 
		cin >> cur;
		if(cur == look_for) {
			cnt += 1;
			look_for += 1;
		}
	}
	if(cnt == 0) cout << "-1" << "\n";
	else cout << (n - cnt) << "\n";
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

ll solve(ll H){
  if(H==1){
    return 1;
  } else { 
    return 1 + solve(H/2) * 2;
  }
}

int main(){
  cout << setprecision(10);
  ll H;
  cin >> H;
  cout << solve(H) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>

using namespace std;

int main()
{
	long int n, m;
	scanf("%d",&n);
	m=sqrt(n);
	printf("%d\n",m*m);
	return 0;
}

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

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

H, W = get_ints
h, w = get_ints

puts H * W - (h * W + w * H - h * w)


Measured memory_bytes: 14416
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#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 << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  cin >> n >> k;

  double ans = 0;
  FOR(i,1,n+1){
    double now = (D)1/n;
    int tmp = i;
    while(tmp < k){
      tmp *= 2;
      now /= 2;
     // debug(now);
    }
    ans += now;
  }

  cout << setprecision(12) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [- i for i in A]
heapify(A)
for i in range(M):
  s = - heappop(A)
  heappush(A, - (s // 2))
print(-sum(A))

Measured memory_bytes: 14180
S = list(input())
len(S)
ans1 = 0
ans2 = 1
cnt1 = 0
cnt2 = 0
for i in range(len(S)):
  if not ans1 == int(S[i]):
    cnt1 = cnt1 + 1
  if ans1 == 0:
    ans1 = 1
  else:
    ans1 = 0

for i in range(len(S)):
  if not ans2 == int(S[i]):
    cnt2 = cnt2 + 1
  if ans2 == 0:
    ans2 = 1
  else:
    ans2 = 0

if cnt1 > cnt2:
  cnt1 = cnt2
  
print(cnt1)


Measured memory_bytes: 3956
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};

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

    int N;
    cin >> N;
    vector<int> W(N);
    int total = 0;
    REP(i, N){
        cin >> W[i];
        total += W[i];
    }
    int tmp = 0;
    int ans = INF;
    REP(i, N){
        tmp += W[i];
        if(abs(total - 2*tmp) < ans){
            ans = abs(total - 2*tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
import bisect
ans = 0
for i in range(n):
    abis = bisect.bisect_left(a, b[i])
    cbis = bisect.bisect_right(c, b[i])
    ans += abis*(n-cbis)
print(ans)




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

using namespace std;
#define DIM  3000
#define DIM2 507
#define INF 10E16
#define MAXN 107
#define LG 18
#define MODULO 1000000007
typedef long long  ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pll parr[DIM];
typedef ll table[DIM][DIM2];
struct pp {
	ll a, b;
	bool operator <(const pp& V)const {
		if (a == V.a)return b < V.b;
		return a < V.a;
	}
	bool operator ==(const pp& V)const {
		if (a == V.a && b == V.b)return 1;
		return 0;
	}
};
ll n;
ld A[DIM],D[DIM][DIM],P[DIM];

int main()

{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	P[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
		P[i] = P[i - 1] * A[i];
	}
	
	D[1][1] = A[1];
	D[1][0] = 1 - A[1];
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			if (j)D[i][j] = D[i - 1][j-1] * A[i];
			if (i > j)D[i][j] += D[i - 1][j] * (1 - A[i]);
			//if (i == j)D[i][j] = P[i];
		}
		//cout << endl;
	}
	ld res = 0;
	for (int i = (n/2)+1; i <= n; i++)res += D[n][i];
	cout << fixed << setprecision(9) << res << endl;
}


Measured memory_bytes: 139136
n=int(input())
h=list(map(int,input().split()))
h.append(0)
ans=0
for i in range(max(h)):
    cnt=0
    for j in range(n+1):
        if h[j]>=i+1:
            cnt+=1
        else:
            if cnt>=1:
                ans+=1
            cnt=0
print(ans)

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define int long long

const int N = 6e5 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;

typedef pair<int, int> ii;

int n;
int a[N];
pair<int, int> dp[(1 << 18) + 10];
bool cmp(int x, int y)	{
	return a[x] < a[y];
}
void upd(ii &x, ii y)	{
	ii res = ii(0, 0);
	vector<int> tmp; tmp.pb(x.fi); tmp.pb(x.se); tmp.pb(y.fi); tmp.pb(y.se);
	sort(tmp.begin(), tmp.end(), cmp);
	res.fi = tmp.back();
	for(int i = 2; i >= 0; --i)	{
		if(tmp[i] != tmp.back())	{
			res.se = tmp[i];
			break;
		}
	}
	x = res;
}

void upd2(ii &x, ii y)	{
	if(a[x.first ]+ a[x.second] < a[y.fi]+ a[y.second] ) x = y;
}

signed main()
{
	//freopen("test.inp", "r", stdin);
	//freopen("test.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n; 
	FOR(i, 0, (1 << n) - 1) cin >> a[i];
	a[(1 << n) + 1] = 0;

	dp[0] = ii(0, (1 << n) + 1);
	FOR(i, 1, (1 << n) - 1)	{
		dp[i] = ii(i, (1 << n) + 1);
		FOR(j, 0, n - 1) if(i & (1 << j)) 
			upd(dp[i], dp[i - (1 << j)]);
	}
	int ans = 0ll;
	FOR(i, 1, (1 << n) - 1)	{
		ans = max(ans, a[ dp[i].fi ] + a[ dp[i].se ]);
		cout << ans << '\n';
	}
}
/*
7
861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125660016 650287940 839296263 462224593 492601449 384836991 191890310 576823355 782177068 404011431 818008580 954291757 160449218 155374934 840594328 164163676 797829355 138996221 501899080 353195922 545531545 910748511 350034067 913575467 470338674 824284691 533206504 180999835 31262034 138344965 677959980 131381221 846045895 208032501 346948152 973708325 506147731 893229302 816248153 298309896 37119022 455797489 215208399 190870607 189766466 554374432 137831502 694053968 47628333 469187475 409233792 810900084 888987010 799979694 87027328 575207354 421624712 666538409 871216480 597902643 509928121 727751951 14723492 265804420 569328197 234828607 807497925 360472167 537560717 613363438 889089200 741106986 846216104 325976483 76823620 279509806 242790881 9676858 792345559 322056553 632488502 444723554 70422962 27172325 26697435 40309279 992120464 751627327 499482549 277429832 736386595 471708200 940778720 417787658 306890639 248789992 1849130 203226467 672298989 938207958 331602581 313746600 206347466
*/

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int pat[16][3] = {{1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, {5, 5, 5}, {6, 6, 6}, {7, 7, 7}, {8, 8, 8}, {9, 9, 9}, {1, 2, 3}, {2, 3, 4}, {3, 4, 5}, {4, 5, 6}, {5, 6, 7}, {6, 7, 8}, {7, 8, 9}};

int main(){
	
	int T;
	cin >> T;
	
	for(int loop = 0; loop < T; loop++){
		
		int count[9][3];
		int sum[9][3];
		int number[9];
		int color[9];
		
		for(int i = 0; i < 9; i++){
			cin >> number[i];
		}
		
		for(int i = 0; i < 9; i++){
			string str;
			cin >> str;
			if(str[0] == 'R'){
				color[i] = 0;
			}else if(str[0] == 'G'){
				color[i] = 1;
			}else{
				color[i] = 2;
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 3; j++){
				count[i][j] = 0;
			}
		}
		
		for(int i = 0; i < 9; i++){
			count[number[i]][color[i]]++;
		}
		
		bool flag = false;
		
		for(int i = 0; i < 48; i++){
			for(int j = i; j < 48; j++){
				for(int k = j; k < 48; k++){
					int index11 = i % 16;
					int index12 = i / 16;
					int index21 = j % 16;
					int index22 = j / 16;
					int index31 = k % 16;
					int index32 = k / 16;
					for(int l = 0; l < 9; l++){
						for(int m = 0; m < 3; m++){
							sum[l][m] = 0;
						}
					}
					for(int l = 0; l < 3; l++){
						sum[pat[index11][l]][index12]++;
						sum[pat[index21][l]][index22]++;
						sum[pat[index31][l]][index32]++;
					}
					bool flag2 = true;
					for(int l = 0; l < 9; l++){
						for(int m = 0; m < 3; m++){
							if(sum[l][m] != count[l][m]){
								flag2 = false;
							}
						}
					}
					if(flag2){
						flag = true;
					}
				}
			}
		}
		
		cout << flag << endl;
		
	}
	
	return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL a[2100];
int main()
{
    string s;
    cin>>s;
    LL val=0,cur=1;
    a[0]=1;
    LL ans=0;
    for(int i=s.size()-1; i>=0; i--)
    {
        val+=(cur)*(s[i]-'0');
        val=val%2019;
        cur=cur*10;
        cur=cur%2019;
        ans+=a[val];
        a[val]++;

    }
    cout<<ans;

}


Measured memory_bytes: 3632
a, b, c = map(int, input().split())
k = int(input())
from itertools import permutations, product
comb_lst = list(product([0,1,2], repeat = k))
flag = False
for comb in comb_lst:
    abc_lst = [a, b, c]
    for num in comb:
        abc_lst[num] *= 2
    if abc_lst[0] < abc_lst[1] and abc_lst[1] < abc_lst[2]:
        flag = True

print('Yes' if flag == True else 'No')

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    int a[n];
    int sum=0;
    unordered_map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
        m[a[i]]++;
    }
    
    int q;
    cin>>q;
    
    while(q--)
    {
        int x,y;
        cin>>x>>y;
        sum=sum-m[x]*x+m[x]*y;
        m[y]=m[y]+m[x];
        m[x]=0;
        cout<<sum<<"\n";
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int A, B, T; cin >> A >> B >> T;
  cout << (int)((T+0.5)/(double)A) * B << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using namespace std;
const int N = 2001;
const long long mod = 1000000007ll;
int n, k;
long long fact[N], inv[N], inv_fact[N];
long long w[N], s = 0;
long long C(int a, int b) {
	if (a < b)return 0;
	else return (fact[a] * ((inv_fact[b] * inv_fact[a - b]) % mod)) % mod;
}
long long qpow(long long a, int m) {
	long long ret = 1;
	while (m) {
		if (m & 1)ret = (ret * a) % mod;
		a = (a * a) % mod, m >>= 1;
	}
	return ret;
}
long long S(int a, int b) {
	long long total = 0;
	if (a < b)return 0;
	for (int i = 0; i <= b; i++) {
		long long delta = 0;
		delta = C(b, i);
		if ((b - i) & 1)delta = (mod - delta) % mod;
		total = (total + delta * qpow(1ll * i, a)) % mod;
	}
	auto x= (total * inv_fact[b]) % mod;
	return x;
}
int main() {
	int N,M,T;cin>>N>>M>>T;
	vector<int>as(1,-M);
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		as.push_back(a);
	}
	int ans=0;
	as.push_back(T+M);
	for (int i = 0; i < as.size()-1; ++i) {
		ans+=max(as[i+1]-as[i]-2*M,0);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 3168
def C2():
    N = int(input())
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        AB.append([a + b, a, b])
    AB.sort()
    AB = AB[::-1]
    i = 0
    ans = 0
    while i < N:
        ans += AB[i][1]
        i += 1
        if i >= N:
            break
        ans -= AB[i][2]
        i += 1
    print(ans)
C2()

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


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

  ll ans = 0;
  int n;
  cin >> n;

  for(ll i = 1; i <= n; i++){
    ans += i * (i+1)/2;
  }

  rep(i, n-1){
    ll u, v;
    cin >> u >> v;
    if(u > v){
      swap(u, v);
    }

    ans -= u * (n-v+1);

  }

  cout << ans << endl;

  return 0;
}


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

const int maxn=1e5+9;
int len[maxn],a[maxn];

bool cmp(const int &a,const int &b){return a>b;};

int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",a+i);
	}
	len[1]=a[1];cnt=1;
	for(int i=2;i<=n;++i) {
		if(a[i]<=len[cnt]) len[++cnt]=a[i];
		else *upper_bound(len+1,len+cnt+1,a[i],cmp)=a[i];
	}
	printf("%d",cnt);
}
/*
7
4 3 1 2 3 4 3
*/

Measured memory_bytes: 1024
#define scanf_s scanf
#include<stdio.h>
int main(void) {
	while (1) {
		int N, k, cou = 0;
		bool flag = false;
		scanf_s("%d", &N);
		if (N == 0) break;
		for (int i = 0; i < N; ++i) {
			scanf_s("%d", &k);
			if (k >= 2) flag = true;
			if (k >= 1) ++cou;
		}
		if (flag == false)
			printf("NA\n");
		else
			printf("%d\n", cou + 1);
	}
}

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

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    vector<double> H(n);
    rep(i, n) {
        cin >> H[i];
        H[i] = abs(a - (t - H[i]*0.006));
    }
    double min = H[0];
    int idx = 0;
    rep(i, n) {
        if (min > H[i]) {
            min = H[i];
            idx = i;
        }
    }
    cout << idx + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n, t = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

max_list = []
tmp = A[0]
max_tmp = -1011100011
for num in A[1:]:
	diff = num - tmp
	max_tmp = max(diff, max_tmp)
	tmp = min(num, tmp)
	max_list.append(diff)

max_val = max(max_list)
c = max_list.count(max_val)
print(c)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int leftSeconds = Integer.parseInt(sc.nextLine());
        int hour = 60 * 60;
        int hours = leftSeconds/ hour;
        leftSeconds = leftSeconds % hour;
        int minute = 60;
        int minutes = leftSeconds / minute;
        leftSeconds = leftSeconds % minute;
        System.out.println(hours + ":" + minutes + ":" + leftSeconds);
    }
}


Measured memory_bytes: 26064
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] s = S.toCharArray();
        Arrays.sort(s);
        if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int k, n, arr[200005], mini;
int main()
{
    cin>>k>>n;
    for(int i = 0; i<n; ++i)
        cin>>arr[i];
    mini = arr[n-1]-arr[0];
    for(int i = 1; i<n; ++i)
    {
        int tmp;
        tmp = k-arr[i]+arr[i-1];
        mini = min(mini, tmp);
    }
    cout<<mini<<"\n";
}

Measured memory_bytes: 1024
S = gets.chomp.reverse
T = ['dream', 'dreamer', 'erase', 'eraser'].map(&:reverse)

c = 0
until S.empty? do
  T.each do |t|
    if S[0, t.size]  == t
      S.sub!(/#{t}/, '') 
      c = 0
    else
      c += 1
    end
  end
  break if c >= T.count
end

puts S.empty? ? 'YES' : 'NO'

Measured memory_bytes: 89860
/* AtCoder Regular Contest 078. Problem , by Abreto<m@abreto.net>. */
#include <stdio.h>

#define MAXN    200001
typedef long long int ll;

ll llabs(ll x){return (x<0)?(-x):x;}

int N;
ll A[MAXN];
ll sum[MAXN];
ll tot;
ll mind;

int main(void)
{
    int i = 0;
    ll t = 0;

    scanf("%d", &N);
    for(i = 1;i <= N;++i)
    {
        scanf("%lld", A+i);
        sum[i] = A[i] + sum[i-1];
        tot += A[i];
    }
    mind = llabs(sum[1]*2-tot);
    for(i = 1;i < N;++i)
    {
        if( (t=llabs(sum[i]*2-tot)) < mind )
            mind = t;
    }

    printf("%lld\n", mind);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i = 0;i < n;i++)cin >> A[i];
    int cnt = 0,flag = 0;
    while(1){
        flag = 0;
        for(int i = 0;i < n;i++){
            if(A[i] % 2 == 0)A[i] /= 2;
            else flag = 1;
        }
        if(flag == 1)break;
        else cnt++; 
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;

    int cnt = 0;
    int N;
    void solve()
    {
        N = cin.nextint;
        var A = cin.scanint;
        bool flag = false;

        dfs(0, 1, A);
        WriteLine(cnt);


        //for (int i = 0; i < N; i++)
        //{
        //    if (A[i] % 2 == 1)
        //    {
        //        cnt++;
        //    }

        //}


        
    }
    void dfs(int idx, long sum, int[] A)
    {
        if (idx == N)
        {
            if (sum % 2 == 0)
            {
                cnt++;
            }
            return;
        }
        for (int i = -1; i <= 1; i++)
        {
            dfs(idx + 1, sum * (A[idx] + i), A);
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()

    if (n == 1) {
        println("Hello World")
        return
    }

    val a = nextInt()
    val b = nextInt()
    println(a+b)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll f[300000],ift[300000];
ll modexp(ll b,ll e){
    b%=mod;
    ll ans=1;
    while(e>0){
        if(e&1)
            ans=(ans*b)%mod;
        e>>=1;
        b=(b*b)%mod;
    }
    return ans;
}
void fct(){
    f[0]=ift[0]=1;
    for(ll i=1;i<300000;i++)
        f[i]=(i*f[i-1])%mod;
    ift[299999]=modexp(f[299999],mod-2);
    for(ll i=299999;i>0;i--)
        ift[i-1]=(i*ift[i])%mod;
}
ll ncr(ll n,ll r){
    if(n<r)
        return 0;
    return (f[n]*((ift[r]*ift[n-r])%mod))%mod;
}
ll way(pair<ll,ll> p1,pair<ll,ll> p2){
    if((p1.first>p2.first)||(p1.second>p2.second))
        return 0;
    return ncr(p2.first+p2.second-p1.first-p1.second,p2.first-p1.first);

}
int main(){
    ll h,w,n;
    fct();
    cin>>h>>w>>n;
    vector< pair<ll,ll> > p(n);
    for(pair<ll,ll> &pr:p)
        cin>>pr.first>>pr.second;
    p.push_back(make_pair(h,w));
    sort(p.begin(),p.end());
    pair<ll,ll> st=make_pair(1,1);
    ll dp[n+1];
    for(ll i=0;i<=n;i++)
        dp[i]=way(st,p[i]);
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<i;j++)
            dp[i]=(dp[i]+mod-(way(p[j],p[i])*dp[j])%mod)%mod;
    }
    cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 5120
from collections import deque
import sys

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

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

for _ in range(m):
	u, v = list(map(int, input().split()))
	edges[u].append(v)

s, t = list(map(int, input().split()))
visited = [[] for _ in range(n + 1)]

q = deque()
q.append((s, 0))

while q:
	node, cnt = q.popleft()

	if cnt % 3 in visited[node]:
		continue
	
	if node == t and cnt % 3 == 0:
		print(cnt // 3)
		sys.exit()
	
	else:
		visited[node].append(cnt % 3)
		for e in edges[node]:
			q.append((e, cnt + 1))
	
print(-1)


Measured memory_bytes: 69792
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
main()
{
    int n,a,b,d[105];
    int i,maa[105],mab[105],mac[105],la,lb,lc,sum;
    la=lb=lc=sum=0;
    scanf("%d%d%d",&n,&a,&b);
    for(i=0;i<n;i++)
    {
        scanf("%d",&d[i]);
        if(d[i]>a&&d[i]<=b) {mab[lb++]=d[i];}
        else if(d[i]<=a) maa[la++]=d[i];
        else if(d[i]>b) mac[lc++]=d[i];
    }
    printf("%d\n",min(min(la,lb),lc));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

#define N 105
ll n,m;
struct edge{
    ll a,b,c;
};
vector<edge>e;

int main(){
    cin>>n>>m;
    ll dp[n][n];rep(i,0,n-1)rep(j,0,n-1)dp[i][j]=inf;
    rep(i,0,n-1)dp[i][i]=0;
    rep(i,0,m-1){
        ll a,b,c;cin>>a>>b>>c;a--;b--;
        edge ed;ed.a=a;ed.b=b;ed.c=c;
        e.pb(ed);
        dp[a][b]=c;dp[b][a]=c;
    }
    ll ans=0;
    
    rep(k,0,n-1){
        rep(i,0,n-1){
            rep(j,0,n-1){
                Min(&dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    /*rep(i,0,n-1){
        rep(j,0,n-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    for(auto x:e){
        if(dp[x.a][x.b]<x.c)ans++;
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int kotaisuu = a[0];
        int honsuu = a[1];
        string kotae = "No";

        for (int i = 0; i < kotaisuu + 1; i++)
        {
            if (i * 2 + (kotaisuu-i)*4 == honsuu)
            {
                kotae = "Yes";
                break;
            }
        }
        Console.WriteLine(kotae);
    }
}

Measured memory_bytes: 28232
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
/*long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}*/
/*void set_levels(int cur, int dont){
	level[cur] = level[dont] + 1;
	parent[cur] = dont;
	for(int i = 0; i < vec[cur].size(); i++){
		if(vec[cur][i] != dont) set_levels(vec[cur][i], cur);
	}
}*/
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	vector<int> vec(n);
	for(auto& x: vec) cin>>x;
	ll res = 0;
	ll tmp = 0;
	for(int i = 0; i < n; i++){
		tmp += vec[i] + 1;
		if(i == k-1)res = tmp;
		if(i >= k){
			tmp -= vec[i-k] + 1;
			res = max(res, tmp);
		}
	}
	printf("%.7lf", (double)res/2);
}


Measured memory_bytes: 1024
X = int(input())

M = 21148

ns = [i**5 for i in range(M)]
n5s = {i**5:i for i in range(M)}

result = None
for i in range(M):
    b = ns[i]
    if b + X in n5s:
        result = n5s[b + X], i
    if X - b in n5s:
        result = i, -n5s[X - b]

print(*result)


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  
  sort(p.begin(),p.end());
  int sum=0;
  
  for(int i=0;i<K;i++){
    sum = sum + p.at(i);
  }
  cout << sum << endl;
 
}




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

const int maxn = 100005;
int sex[maxn], n, l, r, mid;
char s[maxn];

void ask(int x) {	
	printf("%d\n", x);
	fflush(stdout);
	scanf("%s", s);
	if (s[0] == 'V') exit(0);
	if (s[0] == 'M') sex[x] = 1;
	else sex[x] = 0;
}

bool check(int l, int m, int r) {
	ask(m);
	if (((m - l) & 1) ^ sex[l] ^ sex[m]) return 1;
	if (((r - m) & 1) ^ sex[r] ^ sex[m]) return 0;
	return 1;
}

int main() {
	scanf("%d", &n);
	ask(l = 0); ask(r = n - 1);
	while (l + 1 < r) {
		mid = (l + r) >> 1;
		if (check(l, mid, r)) r = mid;
		else l = mid;
	}
	return 0;
}

Measured memory_bytes: 852
#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;
const long long INF = 1LL << 60;
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(){
    ll n,k;cin>>n>>k;
    ll x =0;
    if(n<k){
        x=n;
    }
    else x =n%k;

    ll y = abs(x-k);
    ll ans =min(x,y);
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////

ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}
#define N 300
int main(){fastio
    ll bun[N];
    rep(i,1,N-1)bun[i]=bunbo(i);
    ll n,x;cin>>n>>x;
    ll s[n];rep(i,0,n-1)cin>>s[i];
    sort(s,s+n);
    reverse(s,s+n);
    ll dp[x+1][n+1];memset(dp,0,sizeof(dp));
    ll kai=1;rep(i,1,n)kai=mod(kai*i);
    dp[x][0]=kai;
    rep(i,0,n-1){
        rep(j,0,x){
            ll c=mod(dp[j][i]*bun[n-i]);
            if(c==0)continue;
            Add(dp[j][i+1],c*(n-i-1));
            Add(dp[j%s[i]][i+1],c);
        }
    }
    /*
    rep(i,0,x){
        rep(j,0,n){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll ans=0;
    rep(i,0,x){
        Add(ans,i*dp[i][n]);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 157312
#include<stdio.h>
int main(){
  int i;
  double a,b,c[100],sum=0,ok=0;
  scanf("%lf%lf\n",&a,&b);
  for(i=0;i<a;i++){
    scanf("%lf",&c[i]);
    sum+=c[i];
    }
  for(i=0;i<a;i++){
    if(c[i]/sum>=1/(4*b))
      ok++;
    }
  if(b<=ok)
    printf("Yes");
  else printf("No");
  return 0;
  }

Measured memory_bytes: 128
from random import randrange

def score(c,s,t):
    ans = 0
    scorelast = [-1] * 26
    for i in range(365):
        ans += s[i][t[i]]
        scorelast[t[i]] = i
        for j in range(26):
            ans -= c[j] * (i - scorelast[j])
    return ans

D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D): s.append(list(map(int,input().split())))
t = []
last = [-1] * 26
for i in range(D):
    maximum = 0
    maxs = 0
    for j in range(26):
        if maximum < s[i][j] + c[j] * (i - last[j]):
            maxs = j
            maximum = s[i][j] + c[j] * (i - last[j])
    last[maxs] = i
    t.append(maxs)
point = score(c,s,t)
for i in range(1000):
    d = randrange(D)
    q = randrange(26)
    old = t[d]
    t[d] = q
    if point > score(c,s,t): t[d] = old
for i in t: print(i + 1)


Measured memory_bytes: 78424
import bisect
import sys

N, K = map(int, raw_input().split())
x = map(int, raw_input().split())
res = [sys.maxint] * N

pos = 0
f_pos = bisect.bisect_left(x, 0)
x.insert(f_pos, 0)
result = sys.maxint
for i in range(N + 1):
	if i - K >= 0:
		result = min(result, abs(x[i]) + abs(x[i - K]) + min(abs(x[i]), abs(x[i - K])))
print result
	



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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

vector<bool>prime;

void era(int N){
   prime.resize(N+1,true);
   prime[0] = false;
   prime[1] = false;
   for(int i=2;i<=N;i++){
      if(prime[i]){
         for(int j=i*2;j<=N;j+=i)prime[j]=false;
      }
   }
   return;
}

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

   int Q;
   cin>>Q;
   vector<int>l(Q),r(Q);
   for(int i=0;i<Q;i++)cin>>l[i]>>r[i];

   era(100000);

   vector<int>a;
   for(int i=0;i<=100000;i++){
      if(i%2==0&&prime[i/2]){
         if(prime[i-1])a.push_back(i-1);
      }
   }

   vector<int>ans(Q,0);
   for(int i=0;i<Q;i++){
      for(auto it :a){
         if(l[i]<=it&&it<=r[i])ans[i]++;
      }
   }

   for(int i=0;i<Q;i++)cout<<ans[i]<<endl;
   return 0; 
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int>dp(W + 1, 0);
	vector<int> v(N), w(N); rep(i, 0, N) { cin >> v[i] >> w[i]; }
	rep(i, 0, N)rep(j, w[i], W + 1)chmax(dp[j], dp[j - w[i]] + v[i]);
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3196
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

ll gcd(ll a,ll b){
	ll p;

	if (b > a){
		p = a;
		a = b;
		b = p;
	}

	while(b != 0){
		p = a % b;
		a = b;
		b = p;
	}
	return a;
}

int main(){
	ll N,K;
	cin >> N >> K;
	ll left[N] = {0};
	ll right[N] = {0};

	ll lN = 0;
	ll rN = 0;

	REP(i,N){
		ll tmp;
		cin >> tmp;
		if(tmp < 0) {
			left[lN] = tmp;
			lN++;
		}else if(tmp > 0){
			right[rN] = tmp;
			rN++;
		}else{
			K--;
		}
	}

	ll ret = 10000000001;

	if (K > 0){
		ll start = min(K,lN);
		for(ll i = start;i>=0;i--){
			ll ltmp = i;
			ll rtmp = K - i;
			ll tmp = 0;
			if(rtmp > rN) break;
			if(ltmp == 0){
				tmp = right[rtmp-1];
			}else if(rtmp == 0){
				tmp = (-1)*left[lN-ltmp];
			}else{
				tmp = 2 * min(right[rtmp-1],(-1)*left[lN-ltmp]) + max(right[rtmp-1],(-1)*left[lN-ltmp]);
			}
			if(ret > tmp) ret = tmp;
		}
	}else{
		ret = 0;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
    int n,i,a;
    char b[556],c[556],d[556];
    a=0;
    scanf("%s%d",b,&n);
    for(i=0;i<n;i++){
        scanf("%s",c);
        strcpy(d,c);
        strcat(c,d);
        if(strstr(c,b)!=0){
            a++;
        }
    }
    printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>

int main() {
	
		int n, i, j, minj, temp, cnt = 0;
		int a[100] = {0};

		scanf("%d", &n);

		for (i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}

		for (i = 0; i < n; i++) {
			minj = i;
			for (j = i; j < n; j++) {
				if (a[j] < a[minj]) {
					minj = j;
				}
			}
			if (a[i] > a[minj]) {
				temp = a[i];
				a[i] = a[minj];
				a[minj] = temp;
				cnt++;
			}
		}

		for (i = 0; i < n; i++) {
			if (i == 0) {
				printf("%d", a[i]);
			}
			else {
				printf(" %d", a[i]);
			}
		}
		putchar('\n');
		printf("%d\n", cnt);

	return 0;
}

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

class Program {
    static void Main(string[] args) {
        string s = Cin.Next();
        HashSet<char> set = new HashSet<char>();
        foreach (var item in s) {
            if (set.Contains(item)) {
                Console.WriteLine("no");
                return;
            }
            set.Add(item);
        }
        Console.WriteLine("yes");
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


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


int main() { 
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int x_diff = tx - sx, y_diff = ty - sy;
    string LR1(x_diff, 'R'); 
    string LR2(x_diff+1, 'R'); 
    string LR3 = "L";
    string LR1_inv(x_diff, 'L'); 
    string LR2_inv(x_diff+1, 'L'); 
    string LR3_inv = "R";
    string UD1(y_diff, 'U'); 
    string UD2(y_diff+1, 'U'); 
    string UD3 = "D";
    string UD1_inv(y_diff, 'D'); 
    string UD2_inv(y_diff+1, 'D'); 
    string UD3_inv = "U";


    cout << UD1 << LR1 << UD1_inv << LR1_inv << LR3 << UD2 << LR2 << UD3 << LR3_inv << UD2_inv << LR2_inv << UD3_inv << '\n';

}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=1e5+1e2;
const int inf=0x7fffffff;
int n,m,p=-1;
int Ans=inf;
int a[maxn];

inline void file() {
	freopen("ARC101C.in","r",stdin);
	freopen("ARC101C.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

int main() {
//	file();
	n=read(); m=read();
	For (i,1,n) {
		a[i]=read();
		if (a[i]==0) p=i;
	}
	if (p==-1) {
		if (a[1]>0) {
			Forr (i,n,1) a[i+1]=a[i]; a[1]=0; p=1;
		}
		else if (a[n]<0) {
			a[n+1]=0; p=n+1;
		}
		else {
			For (i,1,n)
				if (a[i]<0 && a[i+1]>0) {
					Forr (j,n,i+1) a[j+1]=a[j]; a[i+1]=0; p=i+1;
				}
		}
		++n; ++m;
	}
//	cout << n << " " << m << " " << p << endl;
//	For (i,1,n) cout << a[i] << " " ; cout << endl;
	For (i,max(1,p-m+1),p) {
		int r=i+m-1;
		if (r>n) continue;
//		cout << i << " " << r << endl;
		if (r==p) chkmin(Ans,abs(a[i]));
		else if (i==p) chkmin(Ans,abs(a[r]));
		else {
			chkmin(Ans,2*abs(a[i])+abs(a[r]));
			chkmin(Ans,2*abs(a[r])+abs(a[i]));
		}
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

int main() {
    long long MOD = 1000000007;
    long long H, W, K;
    long long num[101][10];
    long long hor_f[10];

    scanf("%lld %lld %lld", &H, &W, &K);

    hor_f[0] = 1; hor_f[1] = 1; 
    for(int i=2;i<10;i++){
        hor_f[i] = hor_f[i-1] + hor_f[i-2];
    }

    num[0][1] = 1;
    for(int i=2;i<W+1;i++){
        num[0][i] = 0;
    }

    for(int h=1;h<=H;h++){
        num[h][1] = (hor_f[W-1] * num[h-1][1] + hor_f[W-2] * num[h-1][2]) % MOD;
        num[h][W] = (hor_f[W-2] * num[h-1][W-1] + hor_f[W-1] * num[h-1][W]) % MOD;
        for(int a=2;a<W; a++){
            num[h][a] = (hor_f[a-2] * hor_f[W-a] * num[h-1][a-1] + hor_f[a-1] * hor_f[W-a] * num[h-1][a] + hor_f[a-1] * hor_f[W-a-1] * num[h-1][a+1]) % MOD;
        }
    }

    printf("%lld\n", num[H][K]);

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr long long MOD = 1000000007;

int main()
{
  int N, Q;
  std::cin >> N >> Q;
  std::string S;
  std::cin >> S;
  std::vector<int> memo(N, 0);
  for (int i = 1; i < N; ++i)
  {
    if (S[i - 1] == 'A' &&
        S[i] == 'C')
      memo[i] = memo[i - 1] + 1;
    else
      memo[i] = memo[i - 1];
  }
  while (Q--)
  {
    int l, r;
    std::cin >> l >> r;
    std::cout << memo[r - 1] - memo[l - 1] << "\n";
  }
  std::cout << std::flush;
  return 0;
}



Measured memory_bytes: 1408
n,W=map(int,input().split())
dp=[0]*(W+1)
for i in range(n):
	w,v=map(int,input().split())
	for j in range(W,-1,-1):
		cw=j+w
		cv=dp[j]+v
		if cw <=W and dp[cw]<cv:
			dp[cw]=cv
print(dp[W])

Measured memory_bytes: 69112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, a = 0, b = 0, c = 0, d = 0, counter = 0;
  cin >> x;
  
  a = x / 1000;
  b = (x % 1000) / 100;
  c = ((x % 1000) % 100) / 10;
  d = ((x % 1000) % 100) % 10;
 
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	int ans = 0;
	for(int i=0; i<S.size(); i++){
		if(i<S.size() - 1 && S[i+1] != S[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    //input
    int N;
    cin >> N;
    vector<pair<int,int> > red;
    vector<pair<int,int> > blue;
    int i,j;
    int rx,ry,bx,by;
    for(i=0; i<N; i++){
        cin >> rx >> ry;
        red.push_back(make_pair(ry,rx));
    }
    for(i=0; i<N; i++){
        cin >> bx >> by;
        blue.push_back(make_pair(bx,by));
    }

    //calc
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    int counta=0;
    for(i=0; i<N; i++){
        bx=blue[i].first;
        by=blue[i].second;
        for(j=red.size()-1; j>=0; j--){
            rx=red[j].second;
            ry=red[j].first;
            if(rx<bx && ry<by){
                counta++;
                red.erase(red.begin()+j);
                break;
            }
        }
    }

    //answer
    cout << counta << endl;
    system("pause");
    return 0;
}

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


int main()
{
	int a, b;
	cin >> a >> b;
	int num, times;
	if (a > b) {
		num = b;
		times = a;
	} else {
		num = a;
		times = b;
	}

	for (int i = 0; i < times; i++) {
		cout << num;
	}
	cout << endl;
}


Measured memory_bytes: 256