akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        ArrayList<Integer> d = new ArrayList<>(n);
        for (int i = 0; i < n; ++i) {
            int t = scanner.nextInt();
            d.add(t);
        }
        d.sort(Comparator.naturalOrder());
        writer.println(d.get(n / 2) - d.get(n / 2 - 1));

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int n;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> n;
    int d[n + 1];
    FOR(i, 1, n)
    {
        cin >> d[i];
    }
    ll res = 0;
    FOR(i, 1, n)
        FOR(j, i + 1, n)
            res += d[i] * d[j];
    cout << res;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[]args){
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=(a-b)*100+1900*b;
		System.out.println((int)Math.pow(2, b)*c);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        String ss=s+s;
        String p=sc.next();
        
        if (ss.contains(p)){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26244
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

int main(){


   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   ll n;

   cin>>n;
   ll t =n;
   ll sum =0 ;
   while(n){
    sum += n%10;
    n/=10;

   }
   if(t%sum == 0)cout<<"Yes";
   else
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int N; cin >> N ;

vector<int> X(N); rep(i,N) cin>>X[i];

ll ans=100000000000000;

numrep(i,1,100){
  ll temp=0;

  rep(j,N) temp+=((ll)(i-X[j])*(i-X[j]));

  ans=min(ans,temp);
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli D[10] = {};

int main(void) {

	lli N, K;
	cin >> N >> K;

	//N以上で制約を満たす最も小さい数
	for (int i = 0; i < K; i++) {
		lli t;
		cin >> t;
		D[t] = 1;
	}

	for (lli i = N; i <= 20 * N; i++) {
		lli t = i;
		bool f = true;
		while (t != 0) {
			if (D[t % 10]) {
				f = false;
				break;
			}
			t /= 10;
		}
		if (!f)
			continue;
		COUT(i);
		return 0;
	}



	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
	int num;
	int dist;
}pp;

int main(void){
	while(1){
		int n, i, x, y;
		pp a[10000];
	
		scanf("%d", &n);
		if(n==0) break;
		
		for(i=0; i<n; i++){
			scanf(" %d %d %d", &a[i].num, &x, &y);
			a[i].dist=x+y;
		}
		
		pp max = a[0];
		for(i=1; i<n; i++){
			if(max.dist < a[i].dist)
				max = a[i];
		}
		
		printf("%d %d\n", max.num, max.dist);
	
	}

	return 0;
}

Measured memory_bytes: 676
n=int(input())
cnt=1
List=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    List.append([s,p,cnt])
    cnt+=1
List.sort()
for i in range(len(List)):
    for j in range(i+1,len(List)):
        if List[i][0]==List[j][0] and List[j][1]>=List[i][1]:
            List[i],List[j]=List[j],List[i]
for i in range(len(List)):
    print(List[i][2])

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

int main () {
  vector<int> x(5);
  int ans;
  rep(i, 5) {
    cin >> x[i];
    if (x[i] == 0) ans = i + 1;
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


const ll inf=1LL<<60;

struct SegmentTree{
private:
    int n; // セグ木の葉の数, つまり２冪になっており,　全体の要素数は2*n-1
    vector<ll> node;

public:
    SegmentTree(vector<ll> v){
        int sz = (int)v.size();
        n = 1; while(n < sz) n*= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; ++i) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; --i) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    // k番目(0-indexed)をvalに変更
    void update(int x, ll val){
        x += (n-1);
        node[x] = val;
        while(x > 0){
            x = (x-1)/2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }

    // [a,b)の最小値を求める
    // kは接点の番号、l、rはその接点が[l, r)に対応していることを表す
    // 外からはgetmin(a, b, 0, 0, n)と呼ぶ
    ll getmax(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        // [a, b)と[l, r)が交差していなければinfを返す
        if(r <= a || b <= l) return 0;
        // [a,b) ⊃ [l, r)ならば、この接点の値
        if(a <= l && r <= b) return node[k];
        // そうでなければ二つの子の最小値
        ll vl = getmax(a, b, k*2+1, l, (l+r)/2);
        ll vr = getmax(a, b, k*2+2, (l+r)/2, r);
        return max(vl, vr);
    }
};

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

    int n; cin >> n;
    vector<ll> h(n), a(n);
    rep(i, n) cin >> h[i];
    rep(i, n) cin >> a[i];

    SegmentTree seg(vector<ll>(n+1, 0));
    
    rep(i, n){
        ll tmp=seg.getmax(0, h[i]);
        seg.update(h[i], tmp+a[i]);
    }
    cout << seg.getmax(0, n+1) << endl;

    return 0;
}


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

int main() {
  long sum = 0;
  int N,tmp;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int max = A.at(0);
  for(int i = 1; i < N; i++) {
    if(max < A.at(i)) {
      max = A.at(i);
    } else {
      tmp = max - A.at(i);
      sum += tmp;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4048
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::fixed;
using std::setprecision;
using std::setw;

using ll = long long int;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 373;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    a--;
    b--;

    bool ans;
    while (1) {
        // alice
        if (a + 1 != b) {
            a++;
        } else if (a - 1 >= 0) {
            a--;
        } else {
            ans = true;
            break;
        }

        // borys
        if (a != b - 1) {
            b--;
        } else if (b + 1 < n) {
            b++;
        } else {
            ans = false;
            break;
        }
    }

    cout << (!ans ? "Alice" : "Borys") << endl;

    return 0;
}



Measured memory_bytes: 888
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const shokou = rule[0];
  const kouhi = rule[1];

  console.log(shokou * kouhi);
});


Measured memory_bytes: 30084
#include <iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.size(), MOD = 1000000007;
 
    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 6860
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n, k;
string s;

int main(int argc, char *argv[]){
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] + 0x20;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    string s;
    int a;
    cin >> a;
    cin >> s;
    if(a < 3200)
        cout << "red";
    else 
        cout << s;
}

    

	


Measured memory_bytes: 256
import sys


N, M = map(int, input().split())
H = list(map(int, input().split()))
edge = [set() for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(int, s.split())
    a -= 1; b -= 1
    edge[a].add(b)
    edge[b].add(a)

done = [0] * N
for i in range(N):
    if done[i] == 0:
        h = H[i]
        for e in edge[i]:
            h1 = H[e]
            if h1 < h:
                done[e] = -1
            else:
                done[i] = -1
                break
        else:
            done[i] = 1

print(done.count(1))


Measured memory_bytes: 116140
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	char a[11],b1[11],c[11];
	int i,j;
	cin>>a>>b1>>c;
	//cout<<a<<b1<<c<<endl;
	char b[10];
	b[0]=a[strlen(a)-1];
	b[1]=b1[0];
	b[2]=b1[strlen(b1)-1];
	b[3]=c[0];
	/*for(i=0;i<4;i++){
		cout<<b[i]<<endl;
	}*/
	//char ans;
	if(b[0]==b[1]&&b[2]==b[3]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,W; cin>>H>>W;
    vector<vector<char>> image(2*H,vector<char>(W));
    rep(h,0,H)rep(w,0,W){
        char c; cin>>c;
        image.at(2*h).at(w)=image.at(2*h+1).at(w)=c;
    }

    rep(h,0,2*H){
        rep(w,0,W) cout<<image.at(h).at(w);
        cout<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())
i = 1
while i <= n:
    x = i
    if (x % 3 == 0 or x % 10 == 3):
        print('', i, end='')
    else:
        x = int(x / 10)
        while x > 0:
            if (x % 10 == 3):
                print('', i, end='')
                break
            x = int(x / 10)
    i += 1
print()

Measured memory_bytes: 8112
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
p_a = -1
for now_a in a:
    s += b[now_a-1]
    if now_a - p_a == 1:
        s += c[p_a-1]

    p_a = now_a

print(s)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
ll n;

int f(ll x){
	int ans = 0;
	while (x){ ans++; x /= 10; }
	return ans;
}

int main(){
	ll num = 0;
	cin >> n;
	for (ll i = 1; i*i <= n; ++i)
	if (n%i == 0){
		num = i;
	}
	cout << f(n / num) << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>

using namespace std;
int main()
{
    int n,i;

    cin>>n;

    stringstream ss;

    ss<<n;

    string s;

    ss>>s;

    int len=s.length();

    for(i=0;i<len;i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes";
            return 0;
        }
    }

    cout<<"No";

    return 0;
}


Measured memory_bytes: 3176
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] array = new int[n];
        string[] s = Console.ReadLine().Split(' ');
        for(int i =0;i<n;i++)
        {
            array[i] = int.Parse(s[i]);
        }
        Array.Reverse(array);
        for (int i = 0; i < n; i++)
        {
            if (i == 0)
                Console.Write(array[i]);
            else
            {
                Console.Write(" ");
                Console.Write(array[i]);

            }
        }
        Console.WriteLine("");
    }
}

Measured memory_bytes: 9196
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N, M;
    is >> N >> M;
    if(!is) return;
    map<int, vector<ll>> ab;
    for (int i = 0; i < N; ++i) {
        ll A, B; is >> A >> B;
        ab[A].push_back(B);
    } // end i
    max_queue<ll> pq;

    ll ans = 0;
    ll remdays = 0;
    while(remdays < M){
        remdays++;
        for (auto &&sc : ab[remdays]) {
            pq.push(sc);
        } // end sc
        if(!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_D.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                9000000000000000000
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};

int main(){
    FIO;
    string s,t; cin >> s >> t;
    ll ans = 0;
    forn(i,0,s.size()){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3780
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,p[10],q[10],ans,ans2;
vector <int> v;

int main()
{
  cin>>n;
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  repn(i,n) v.pb(i);
  int now=0;
  do
  {
    now++;
    bool ok=true;
    rep(i,n) if(p[i]!=v[i]) ok=false;
    if(ok) ans=now;
    ok=true;
    rep(i,n) if(q[i]!=v[i]) ok=false;
    if(ok) ans2=now;
  }
  while(next_permutation(v.begin(),v.end()));
  cout<<abs(ans2-ans)<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

point = 0
set = list(set(s))
for i in range(len(set)):
    tmp = s.count(set[i]) - t.count(set[i])
    if tmp > point:
        point = tmp
print(point)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 10000000000000000;

bool comp(const P &a, const P &b){
    if(a.first - b.first != b.second - a.second) return a.first - b.first < b.second - a.second;
    return a.first < b.first;
}

ll dp[5002][5002];

int main()
{
    int n;
    cin >> n;
    P q[5003];
    for(int i = 0; i < n; i++){
        ll h, p;
        cin >> h >> p;
        q[i] = P(p, h);
    }
    sort(q, q + n, comp);
    for(int j = 1; j <= n; j++) dp[0][j] = INF;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= n; j++) dp[i][j] = dp[i - 1][j];
        for(int j = 1; j <= n; j++){
            if(dp[i - 1][j - 1] <= q[i - 1].second) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + q[i - 1].first);
        }
    }
    for(int j = n; j >= 0; j--){
        if(dp[n][j] != INF){
            cout << j << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 195840
#include<stdio.h>
int MAX(int a){return a<0?0:a;}
int main(){
  int h,m,a,b;
  scanf("%d %d",&h,&m);
  a=h*60+m;
  scanf("%d %d",&h,&m);
  b=h*60+m;
  scanf("%d",&m);
  printf("%d\n",MAX(b-a-m));
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
    ll n;
    cin>>n;
    vector<ll> a;
    rep(i,n){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    ll ans=0;
    while(true){
        sort(a.begin(),a.end());
       // rep(i,a.size()){cout<<a[i];}cout<<endl;
        if(a[a.size()-1]==1){cout<<1<<endl;return 0;}
        else if(a[a.size()-2]==0){cout<<a[a.size()-1]<<endl;return 0;}
        else{
             sort(a.rbegin(),a.rend());
            //rep(i,a.size()){cout<<a[i];}cout<<endl;
            ll j=a.size()-1;ll aa=0;
            while(true){if(a[j]==0){j--;}else{aa=a[j];break;}}
           // cout<<aa<<endl;
            for(ll i=a.size()-2;i>=0;i--){
                if(a[i]!=0&&i!=j){
                a[i]=a[i]%aa;
                }
            }
            
        }
    }
   
    cout<<ans<<endl;
    
    
    

return 0;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << "Christmas";
  switch (n) {
    case 22:
      cout << " Eve";
    case 23:
      cout << " Eve";
    case 24:
      cout << " Eve";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    ans1 = a
    c = b - ans1
    ans1 += (c - 1) // 2

    ans2 = n-b+1
    c = a + ans2
    ans2 += (n - c) // 2
    print(min(ans1, ans2))


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

int main(){
  int a,b,c=1001,d=0,N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a;
    c = min(a,c);
    d = max(a,d);
  }
  cout << d-c <<endl;
}


Measured memory_bytes: 256
/**
 *   created: 16 November 2019  10:01:14
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int a,b;
		cin>>a>>b;
		cout<<max(0, a-2*b);
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    allxor = A[0]
    for i in range(1,N):
        allxor ^= A[i]
    ans = [0] * N
    for i in range(N):
        ans[i] = allxor ^ A[i]
    print(*ans)

    
main()

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

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            int sum = int.Parse(a[0]) + int.Parse(a[1]) + int.Parse(a[2]);
            if (sum > 21)
            {
                Console.WriteLine("bust");
            }
            else
            {
                Console.WriteLine("win");
            }
        }
    }
}


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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = 0, keeper;
    for(int i = 0; i < n; i++){
        keeper = 0;
        for(int j = 0; j < m; j++){
            keeper += b[j]*a[i][j];
        }
        keeper += c;
        if(keeper > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	P := make([]int, N)
	Q := make([]int, N)
	var n int
	for i := 0; i < N; i++ {
		fmt.Scan(&n)
		P[i] = n
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&n)
		Q[i] = n
	}
	p := resolv(P)
	q := resolv(Q)
	res := p - q
	if p < q {
		res = q - p
	}
	fmt.Println(res)

}

func resolv(n []int) int {
	list := []int{}
	for i := 1; i <= len(n); i++ {
		list = append(list, i)
	}
	res := 1
	for i := 0; i < len(n); i++ {
		char := n[i]
		for j := 0; j < len(list); j++ {
			if char == list[j] {
				res += sum(len(list)) * j / len(list)
				list = remove(list, char)
				break
			}
		}

	}
	// for i := 0; i < len(n); i++ {
	// 	char := n[i]
	// 	for j := 0; j < len(list); j++ {
	// 		if char == list[j] {
	// 			res = res * (j + 1) / len(list)
	//
	// 			fmt.Println(res)
	// 			break
	// 		}
	// 	}
	// }

	return res
}

func sum(n int) int {
	res := 1
	for i := n; i > 1; i-- {
		res *= i
	}
	return res
}

func remove(ints []int, search int) []int {
	result := []int{}
	for _, v := range ints {
		if v != search {
			result = append(result, v)
		}
	}
	return result
}


Measured memory_bytes: 512
import sys
from bisect import bisect_left, bisect

def solve():
    S = input()
    N = len(S)
    RL = []
    B = [0] * N
    for i in range(N):
        if S[i] == "R":
            if i < N - 1 and S[i + 1] == "L": RL.append(i)
    for i in range(N):
        j = bisect_left(RL, i)
        if S[i] == "R":
            if (RL[j] - i) % 2 == 0: B[RL[j]] += 1
            else: B[RL[j] + 1] += 1
        else:
            if (i - RL[j - 1]) % 2 == 0: B[RL[j - 1]] += 1
            else: B[RL[j - 1] + 1] += 1
    print(" ".join(map(str, B)))

    return 0
if __name__ == "__main__":
    solve()

Measured memory_bytes: 54748
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

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

ull memo[51][51];
bool mvalid[51][51];


ull nCk(int n, int k){
    if(n < k) return 0;
    if(n < k*2) k = n - k;
    if(k == 0) return 1;
    ull x, y;
    x = (mvalid[n-1][k]) ? memo[n-1][k] : nCk(n-1,k);
    y = (mvalid[n-1][k-1]) ? memo[n-1][k-1] : nCk(n-1,k-1);
    memo[n-1][k] = x;
    memo[n-1][k-1] = y;
    mvalid[n-1][k] = true;
    mvalid[n-1][k-1] = true;

    return  x+y;
}

ll C[51][51];
void comb_table(int N){
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0 || j == i)
                C[i][j] = 1LL;
            else
                C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
}

ull V[51];
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    REP(i,N){
        ull v;
        cin >> v;
        V[i] = v;
    }
    sort(V,V+N, greater<ull>());
    double max_ave = 0;
    vector<int> index;
    for(int i = A; i <= B; i++){
        ull sum = 0;
        REP(k,i) sum += V[k];
        long double ave = (long double)sum / i;
        //double ave = sum / i;
        //printf("ave:%lf\tsum:%lld\ti:%d\n", ave, sum, i);
        if(ave > max_ave){
            max_ave = ave;
            index.clear();
            index.push_back(i);
        //}else if(ave == max_ave){
        }else if((0 <= max_ave-ave && max_ave-ave < 1e-30) || (0 <= ave-max_ave && ave-max_ave < 1e-30)){
            index.push_back(i);
        }
    }

    ull ans = 0;
    sort(V,V+N);
    comb_table(N);
    for(int i = 0; i < index.size(); i++){
        int idx = index[i];
        ull base = V[N-idx-1];
        int n = upper_bound(V, V+N, base) - lower_bound(V, V+N, base);
        int k = idx - ((V+N) - upper_bound(V, V+N, base));
        //ans += nCk(n,k);
        ans += C[n][k];
    }
    printf("%lf\n", max_ave);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] c = new String[h+1];

		for (int i = 0; i <= h; i++) {
			c[i] = sc.nextLine();
		}

		for (int i = 0; i <= h; i++) {
			System.out.println(c[i]);
			System.out.println(c[i]);
		}

		sc.close();
	}
}


Measured memory_bytes: 22996
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
using namespace std;
const int inf=1e7;
int dist[1005][1005];
int solve()
{
	int h,w;
	cin>>h>>w;
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	string s[h];
	for(int i=0;i<h;i++){
		cin>>s[i];
	}	
	for(int i=0;i<1003;i++){
		for(int j=0;j<1003;j++){
			dist[i][j]=inf;
		}
	}
	--ch,--cw,--dh,--dw;
	dist[ch][cw]=0;
	deque<pair<int,int> > q;
	q.push_back(mkp(ch,cw));
	bool ans=false;
	while(!q.empty()){
		pair<int,int> v=q.front();
		q.pop_front();
		int row=v.first;
		int col=v.second;
		if(row==dh && col==dw){
			ans=true;
			break;
		}
		for(int dx=-2;dx<=2;dx++){
			for(int dy=-2;dy<=2;dy++){
				int nrow=row+dx;
				int ncol=col+dy;
				if(nrow==row && ncol==col)
					continue;
				if(nrow>=h || ncol>=w || nrow<0 || ncol<0)
					continue;
				if(s[nrow][ncol]=='#')
					continue;
				int w=1;
				if((abs(row-nrow)==1 && abs(col-ncol)==0) || (abs(nrow-row)==0 && abs(ncol-col)==1) )
					w=0;
				if(dist[nrow][ncol]>dist[row][col]+w){
					dist[nrow][ncol]=dist[row][col]+w;
					if(w==1)
						q.push_back({nrow,ncol});
					else
						q.push_front({nrow,ncol});
				}
			}
		}
	}
	if(ans){
		cout<<dist[dh][dw]<<endl;
	}
	else
		cout<<"-1"<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



Measured memory_bytes: 12708
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
const int maxn = 100100;
ll dp[maxn], h[maxn], n,k;

int main() {
	cin>>n>>k;
	cin>>h[1];
	for(int i=2;i<=n;i++) {
		cin>>h[i];
		
		dp[i] = LLONG_MAX;
		for(int j=i-1;j>=max(1LL,i-k);j--) {
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}
	cout<<dp[n]<<"\n";
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int x=sc.nextInt();
		if(a<=x&&x<=a+b-1) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}

Measured memory_bytes: 21844
#include <cmath>
#include <cstdio>
#include <complex>
#include <algorithm>
#define Point complex<long double>
#define px real()
#define py imag()
using namespace std;
// ------ Classes ------ //
class Segment {
public:
	Point p1, p2;
	Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_) {};
	Segment(long double p1x, long double p1y, long double p2x, long double p2y) : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)) {};
	friend bool operator==(const Segment& s1, const Segment& s2) { return (s1.p1 == s2.p1 && s1.p2 == s2.p2) || (s1.p1 == s2.p2 && s1.p2 == s2.p1); }
	friend bool operator!=(const Segment& s1, const Segment& s2) { return !(s1 == s2); }
};
class Line {
public:
	Point p1, p2;
	Line(Point p1_, Point p2_) : p1(p1_), p2(p2_) {};
	Line(long double p1x, long double p1y, long double p2x, long double p2y) : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)) {};
	friend bool operator==(const Line& s1, const Line& s2) { return (s1.p1 == s2.p1 && s1.p2 == s2.p2) || (s1.p1 == s2.p2 && s1.p2 == s2.p1); }
	friend bool operator!=(const Line& s1, const Line& s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
Point prj(const Segment& a, const Point& b) {
	Point c = a.p2 - a.p1;
	return a.p1 + c * dot(b - a.p1, c) / norm(c);
}
Point rfl(const Segment& a, const Point& b) {
	return b + (prj(a, b) - b) * 2.0L;
}
long double xa, ya, xb, yb, xc, yc;
int main() {
	while(~scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", &xa, &ya, &xb, &yb, &xc, &yc)) {
		Point p = rfl(Segment(xa, ya, xb, yb), Point(xc, yc));
		printf("%.9Lf %.9Lf\n", p.px, p.py);
	}
	return 0;
}

Measured memory_bytes: 2796
#include <iostream>
using namespace std;
int prime[250000];
int n,cnt;



int main(){
	prime[1]=0;
	for(int i=2;i<250000;i++){
		prime[i]=1;
	}
	for(int i=2;i<=500;i++){
		if(prime[i]==0)continue;
		int k=i*i;
		while(k<250000){
			prime[k]=0;
			k+=i;
		}
	}

	while(1){
		cin >>n;
		if(n==0)break;
		cnt=0;
		for(int i=n+1;i<=2*n;i++){
			cnt+=prime[i];
		}
		cout <<cnt<<endl;
	}
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }

    ll q = a[0] * 2;
    FOR(i, 1, n) {
        q = a[i] * 2 - q;
    }
    q /= 2;
    cout << q << endl;
    REP(i, n - 1) {
        q = a[i] * 2 - q;
        cout << q << endl;
    }
}


Measured memory_bytes: 2048
//10/05/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
class NumberTheory{
public:
    ll n;
    bool chk[99999995];
    ll GetMod(ll x,ll m);
    ll BigMod (ll b,ll p,ll m){if (p == 0) return 1;if (p%2 == 0){ll s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
    ll ModInv (ll b,ll m){return BigMod(b,m-2,m);}
    ll gcd(ll a,ll b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
    ll lcm(ll a,ll b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
    void sieve(ll x);
    bool IsPrime(ll x);
    bool IsPrime1(ll x){return !chk[x];}
};

/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;


int main(){
    _fastio
    string s,t;
    cin>>s>>t;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cout<<"No"<<en;
            return 0;
        }
    }
    cout<<"Yes"<<en;




    return 0;
}

void NumberTheory::sieve(ll x){
    for(ll i=2;i*i<=x;){
        if(chk[i]==0){
            for(ll j=i*i;j<=x;j+=i){
                chk[j]=1;
            }
        }
        if(i==2) i++;
        else i+=2;
    }
}
bool NumberTheory::IsPrime(ll x){
    bool f=true;
    for(ll i=2;i*i<=x;i++){
        if(!x%i){
            f=false;break;
        }
    }
}
ll GetMod(ll x,ll m){
    if(x>=0) return x%m;
    else{
        ll y=abs(x)/m;x+=(y*m+m+m);
        return x%m;
    }
}


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

int main() {
  int N;
  cin >> N ;
  vector<string>blue(N);
  
  for(int i = 0 ; i < N ; i++){
  	cin >> blue.at(i);
	}
  
  int M;
  cin >> M ;
  vector<string>red(M);
  
  for(int i = 0 ; i < M ; i++){
  		cin >> red.at(i);
	}  
  
  vector<int> point_count(N);
  int max_count = 0;
  
  for(int i = 0 ; i < N ; i++){
// int i = 0;
      point_count.at(i) = 0;
    for(int k = 0 ; k < N ; k++){
    	if(blue.at(i)==blue.at(k)){
        	point_count.at(i)++;
        }
      }
    for(int j = 0 ; j < M ; j++){
    	if(blue.at(i)==red.at(j)){
        	point_count.at(i)--;
        }
      }
    if(point_count.at(i)>max_count){
    	max_count = point_count.at(i);			  
    }
  }
        cout << max_count << endl;   
}


Measured memory_bytes: 256
s = input()
t = input()

def valid(s1,s2):
	for i in range(len(s2)):
		if s1[i] != s2[i] and s1[i] != '?':
			return False
	return True


for i in range(len(s))[::-1]:
	ss = s[i:i+len(t)]
	if len(ss) != len(t):
		continue
	if not valid(ss,t):
		continue

	ans = s[0:i] + t + s[i+len(t):]
	ansans = ""
	for c in ans:
		if c == '?':
			ansans += 'a'
		else:
			ansans += c
	print(ansans)
	exit(0)

print("UNRESTORABLE")


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

point = []

for i in range(len(A)):
    ryori = A[i]
    point.append(B[ryori - 1])
    if i > 0:
        if ryori - A[i - 1] == 1:
            point.append(C[ryori - 2])

print(sum(point))

Measured memory_bytes: 3064
import sys
def main():

    cnt = {}
    for i in range(ord('a'),ord('z')+1):
        cnt[chr(i)] = 0

    for passages in sys.stdin:
        for psg in passages:
            psglower = psg.lower()
            for s in psglower:
                if s.isalpha():
                    cnt[s] += 1

    for i in range(ord('a'),ord('z')+1):
        s = chr(i)
        print(s, ':', cnt[s])

if __name__ == '__main__':
    main()


Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

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

    int dp[n+1][13];
    REP(j,n+1) REP(i,13) dp[j][i] = 0;
    dp[0][0] = 1;
    int beki = 1;
    FOR(i,1,n+1){
        if(s[n-i] != '?'){
            int tmp = s[n-i] - '0';
            //debug(tmp);
            tmp *= beki;
            tmp %= 13;
            REP(j,13){
                dp[i][ (j + tmp) % 13] += dp[i-1][j] ;
                dp[i][ (j + tmp) % 13] %= MOD;
            }
        }
        else{
            REP(k,10){
                int tmp = int(k);
                tmp *= beki;
                tmp %= 13;
                REP(j,13){
                    dp[i][ (j + tmp) % 13] += dp[i-1][j] ;
                    dp[i][ (j + tmp) % 13] %= MOD;
                }
            }

        }
        beki *= 10;
        beki %= 13;

    }


    cout << dp[n][5] << endl;

}

Measured memory_bytes: 10624