akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void ABC051D()
{
	int N, M;
	cin >> N >> M;
	struct Edge {
		Edge(int t, int d) : to(t), dist(d) {}
		int to;
		int dist;
	};
	vector<vector<Edge>> vtx(N);
	for (int i = 0; i < M; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		vtx[a - 1].push_back(Edge(b - 1, c));
		vtx[b - 1].push_back(Edge(a - 1, c));
	}

	set<pair<int, int> > unusedEdge;
	priority_queue<pair<int, int> > qu;
	for (int i = 0; i < N; ++i)
	{
		qu.push(make_pair(0, i));

		map<int, int> neighbor;
		for (auto& x : vtx[i])
			neighbor[x.to] = x.dist;
		vector<int> distance(N, 100000000);
		distance[i] = 0;
		while (!qu.empty())
		{
			auto p = qu.top();
			qu.pop();
			for (auto& x : vtx[p.second])
			{
				int v = x.to;
				int dist = p.first + x.dist;
				if (dist < distance[v])
				{
					distance[v] = dist;
					qu.push(make_pair(dist, v));
					auto pN = neighbor.find(v);
					if (pN != neighbor.cend() && pN->second > dist)
					{
						int s = min(i, v);
						int e = max(i, v);
						unusedEdge.insert(make_pair(s, e));
					}
				}
			}
		}
	}
	cout << unusedEdge.size() << endl;
}

int main()
{
	ABC051D();
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    string s;
    cin >> s;

    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

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

int main()
{
  int num1, num2, cookies;
  //cookies = 0;

  cin >> num1 >> num2;
  cookies = num1 + num2;

  if(cookies % 3 == 0)
    cout << "Possible" << endl;
  else if(num1 % 3 == 0)
    cout << "Possible" << endl;
  else if(num2 % 3 == 0)
    cout << "Possible" << endl;
  else
  cout << "Impossible" << endl;



}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<3000;tm++)
	{
		while(true)
		{
			int d=rng()%D,q=rng()%26;
			int ret=change(d,q);
			if(rng()%2000>tm||ret>=0)
			{
				now+=ret;
				t[d]=q;
				break;
			}
		}
		for(int k=0;k<3000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else if(rng()%2000<tm)
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}

Measured memory_bytes: 3680
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B,C=get_i
if A==B
    puts C
elsif B==C
    puts A
else
    puts B
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int odd_cnt;
  for (int i; i < n; i++) {
    int a;
    cin >> a;
    if (a%2 == 1) {
      odd_cnt += 1;
    }
  }
  if (odd_cnt % 2 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import bisect, collections
 
 
 
def solution():
    h, w = [int(x) for x in input().strip().split(" ")]
    b, dp = [], []
    for _ in range(h):
        b.append(input().strip())
        dp.append([0]*w)

    if b[0][0] == "#":
        dp[0][0] = 1
    for j in range(1, w):
        dp[0][j] = dp[0][j-1] + (1 if b[0][j] == "#" and b[0][j-1] == "." else 0)
    for i in range(1, h):
        dp[i][0] = dp[i-1][0] + (1 if b[i][0] == "#" and b[i-1][0] == "." else 0)
    for i in range(1, h):
        for j in range(1, w):
            if b[i][j] == "#":
                dp[i][j] = min(dp[i-1][j]+(1 if b[i-1][j] == "." else 0), dp[i][j-1]+(1 if b[i][j-1] == "." else 0))
            else:
                dp[i][j] = min(dp[i-1][j], dp[i][j-1])
    print(dp[-1][-1])
                

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()

if __name__ == "__main__":
    main()

Measured memory_bytes: 40944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll 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;
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;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(c<=a+b+1){
        cout<<c+b<<endl;
    }else{
        cout<<(a+b+1)+b<<endl;
    }
    
    
    return 0;
}






Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
ans,d=-1,10**9
H=list(map(int,input().split()))
for i in range(N):
    x=T-H[i]*0.006
    if abs(A-x)<=d:
        ans=i
        d=abs(A-x)
print(ans+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <array>
#include <string>
#include <map>
#include <cmath>
//#include <iomainp>
using namespace std;

#define DB(x)
#define rep(i, n) for(int i = 0;i < n;i++)


int getIntSp(){
    string str;
    getline(cin,str,' ');
    return stoi(str);
}

int getIntLF(){
    string str;
    getline(cin,str);
    return stoi(str);
}



int main()
{
    int A,B;
    cin >> A >> B;
    
    int big,small;
    if( A > B ){
        big = A;
        small = B;
    }else{
        big = B;
        small = A;
    }
    
    uint64_t result = big;
    while(1){
        if(result%small == 0 ){
            cout << result << endl;
            return 0;
        }
        result += big;
    }
    
    return 0;
}


Measured memory_bytes: 256
n, m =list(map(int, input().split()))
h_list = list(map(int, input().split()))
m_list = []
for i in range(m):
  m_list.append(list(map(int, input().split())))

n_list = [True for i in range(n)]

for m in m_list:
  a = m[0] - 1
  b = m[1] - 1
  if h_list[a] > h_list[b]:
    n_list[b] = False
  elif h_list[a] == h_list[b]:
    n_list[a] = False
    n_list[b] = False
  else:
    n_list[a] = False

count = 0
for n in n_list:
  count += 1 if n else 0

print(count)

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

using namespace std;
char I[4];

vector<char> result;

bool go(int p, vector<char> &a) {
    if(p == 3) {
        int res = I[0] - '0';

        for(int i = 1 ; i <= 3; ++i) {
            if(a[i-1] == '+') {
                res += I[i] - '0';
            } else {
                res -= I[i] - '0';
            }
        }

        if(res == 7) {
            result = a;
            return true;
        } else return false;
    } else {
        a[p] = '+';
        if(go(p+1, a)) {
            return true;
        }
        a[p] = '-';
        return go(p+1, a);
    }
}

int main() {


    scanf("%4c", I);

    vector<char> a(4);
    go(0,a);

    for(int i = 0 ; i < 3; ++i) {
        printf("%c%c", I[i], result[i]);
    }

    printf("%c=7\n", I[3]);

    return 0;

}

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

using namespace std;

int main(){
  vector<int> weightarray;
  int weight;
  while(cin>>weight){
    weightarray.push_back(weight);
  }
  for(auto weight:weightarray){
    bool first=true;
    for(int i=0;i<sizeof(weight)*8;i++){
      int bit=1<<i;
      if(weight&bit){
        if(!first)cout<<" ";
        first=false;
        cout<<bit;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1212
#include <stdio.h>

int main(void) {
	unsigned short K, A, B, i;
	char buf[11];
	scanf("%hu%*c", &K);
	scanf("%hu %hu%*c", &A, &B);
	for (i = A; i <= B; i++) {
		if (!(i % K)) {
			printf("OK\n");
			break;
		}
	}
	if (B < i) {
		printf("NG\n");
	}
	return 0;
}


Measured memory_bytes: 1664
fileprivate struct Scanner {
    private var elements = [String]()
    private var index = 0
    
    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }
    
    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }
    
    mutating func nextInt() -> Int {
        return Int(next())!
    }
    
    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

func main() {
    var scanner = Scanner()
    let A = scanner.nextInt()
    var B = scanner.nextInt()
    var C = scanner.nextInt()
    let K = scanner.nextInt()
    
    var need = 0
    
    while A >= B {
        B *= 2
        need += 1
    }
    while B >= C {
        C *= 2
        need += 1
    }
    
    if need <= K {
        print("Yes")
    } else {
        print("No")
    }
}

main()


Measured memory_bytes: 7768
#include <iostream>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a == b + c || b == a + c || c == a + b) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <string>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end()

int a[200000 + 1];
unordered_set<int> res;

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

	rep(i, N) {
		cin >> a[i];
	}

	repr(i, N) {
		if ((i + 1) * 2 > N) {
			if (a[i]) res.insert(i + 1);
			continue;
		}
		//printf("check %d\n", i + 1);
		int n = 0;
		for (int x = i + 1; x <= N; x += i + 1) {
			//printf("  how about %d\n", x);
			n += res.find(x) != res.end();
		}
		//for (auto& e : res) {
		//	if (e % (i + 1) == 0) {
		//		n++;
		//		//printf("   ok %d\n", e);
		//	}
		//}
		//printf("result %d = %d\n", i + 1, n);
		if (n % 2 != a[i]) res.insert(i + 1);
	}
	printf("%d\n", res.size());
	for (auto& e : res) {
		printf("%d ", e);
	}
	puts("");

	return 0;
}


Measured memory_bytes: 7844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  cout << (s < t ? "Yes" : "No") << endl;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll K, A, B;

    cin >> K >> A >> B;
    for(int i = A; i <= B; i++ ){
        if (i%K == 0 ){
            cout << "OK" << endl;
            return 0 ;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        string s;
        cin >> s;
        if (s == "AAA" || s == "BBB") {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 256
n,k,q=map(int,input().split())
A=[]
A=[int(input()) for i in range(q)]
#print(A)
B=[]
for i in range(n):
    B.append(-q+k)
#print(B)
for i in A:
    B[i-1]+=1
for i in range(n):
    if B[i]<=0:
        B[i]='No'
    else:
        B[i]='Yes'
C="\n".join(B)
print(C)

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

c = [[0 for i in range(10)] for j in range(10)]
for k in range(1, n+1):
    str_k = str(k)
    i = int(str_k[0])
    j = int(str_k[-1])
    c[i][j] += 1

answer = 0
for i in range(10):
    for j in range(10):
        answer += c[i][j] * c[j][i]

print(answer)


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

int getDigit();
string getVal(int);

int main(){
	int dig = getDigit();
	string val = getVal(dig);
	long long ans=0;
	for(int i=0;i<dig;i++) ans=ans*10 + (val[i]-'0');
	cout<<"! "<<(ans+1)<<endl<<flush;
	return 0;
}

int getDigit(){
	int r=10, l=0;
	while(r-l > 1){
		int mid = (l+r)>>1;
		cout<<"? 1";
		for(int i=0;i<mid;i++) cout<<0;
		cout<<endl<<flush;
		char c;cin>>c;
		if(c=='Y') l=mid;
		else r=mid;
	}
	return l+1;
}

string getVal(int len){
	string ss="1000000000";
	for(int i=0;i<len;i++){
		int l=0, r=10;
		while(r-l>1){
			int mid=(l+r)>>1;
			ss[i]='0'+mid;
			cout<<"? "<<ss<<endl<<flush;
			char c;cin>>c;
			if(c=='Y') r=mid;
			else l=mid;
		}
		ss[i]='0'+l;
	}
	return ss;
}

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

using namespace std;
typedef long long int ll;

int main()
{
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll sum = 0;
    ll x,y;
    for(ll i = 0; i <= max(2*X,2*Y);i++)
    {
        x = X - i / 2;
        y = Y - i / 2;
        if(X - i / 2 <= 0)
        {
            x = 0;
        }
        if(Y - i / 2 <= 0)
        {
            y = 0;
        }
        if(sum == 0)
        {
            sum = x*A + y*B + i*C;
            continue;
        }
        sum = min(sum, x*A + y*B + i*C);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N,L;
    cin >>N>>L;
    vector<int> T(N+1);
    int a = 0;
    int ans = 987654321;
    int sum = 0;
    for(int i =1;i < N+1;i++){
        T[i] = L + i - 1;
        sum += T[i];
        if(ans > abs(T[i])){
            a = i;
            ans = abs(T[i]);
        }
    }
    cout << sum - T[a] << endl;

}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

    int count = 0;
    for(int i = 0;i < n-2; i++){
        if(s.substr(i,3) == "ABC")count++;
    }
    cout<< count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m; cin >> n >> m;

	multiset<int64_t> as;
	FOR_LT(i, 0, n) {
		int64_t a; cin >> a;
		as.insert(a);
	}

	FOR_LT(i, 0, m) {
		auto mait = as.end();
		mait--;

		int64_t ma = *mait;
		ma /= 2;

		as.erase(mait);
		as.insert(ma);
	}

	int64_t ans = 0;
	{
		auto it = as.begin();
		while (it != as.end()) {
			ans += *it;
			it++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
fun main(args: Array<String>) {
  val t = readLine()!!.toInt()
  repeat(t) {
    solveCase()
  }
}

fun gcd(x: Long, y: Long): Long {
  if (x < y) return gcd(y, x)
  val r = x % y
  if (r == 0L) return y
  else return gcd(y, r)
}

fun solveCase() {
  val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }
  if (a < b) {
    println("No")
    return
  }
  if (b > d) {
    println("No")
    return
  }
  if (c + 1 >= b) {
    println("Yes")
    return
  }

  val x = gcd(b, d)
  var y = a % x
  y += (c - y) / x * x
  while (y <= c) y += x
  // y >= c + 1
  if (y < b) {
    println("No")
  } else {
    println("Yes")
  }
}

Measured memory_bytes: 38400
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] eratos;
    int i, j, pcount;

    pcount = 0;
    eratos = new int[250000];
    eratos[0] = pcount;
    for(i = 2;i < 1001;i++){
      if(eratos[i - 1] == 0){
        pcount++;
        for(j = i * i;j < 250001;j+=i){
          eratos[j - 1] = -1;
        }
      }
      eratos[i - 1] = pcount;
    }
    for(;i < 250001;i++){
      if(eratos[i - 1] == 0)pcount++;
      eratos[i - 1] = pcount;
    }

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      else if(n == 1)out.println("1");
      else out.println(eratos[2 * (n - 1)] - eratos[n - 1]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 23516
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	ic_a;
	cout << LCM(2, a) << rt;

	please AC;
}

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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            nums = Console.ReadLine().Select(val => int.Parse(val.ToString())).ToArray();
            //foreach (var n in nums) Console.WriteLine(n);
            while (true)
            {
                char[] rec = new char[4];
                if (dfs(nums[0],1, rec))
                {
                    Console.WriteLine(nums[0] + rec[0].ToString() + nums[1] + rec[1].ToString() + nums[2] + rec[2].ToString() + nums[3] + "=7");
                    return;
                }
            }
            
        }

        int[] nums;

        bool dfs(int sum,int num,char[] rec)
        {
            if (num == 4) return sum == 7;

            else
            {
                if (dfs(sum + nums[num],num+1, rec)) { rec[num-1] = '+'; return true; }
                if (dfs(sum - nums[num], num+1,rec)) { rec[num-1] = '-'; return true;}
                return false;
            }
        }

    }
    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


Measured memory_bytes: 13396
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
int A[MAXN];

void solve() {
	cin >> n;
	rep( i , 1 , n ) printf("ACL"); 
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 3700
//#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
const int MX = 2001;
int ans,k,m,n,u,v;
vector<int> g[MX];
void dfs(int now,int pre,int dep) {
    m++;
    if (dep==0) return ;
    for (auto i:g[now])
        if (i!=pre) dfs(i,now,dep-1);
}
int main() {
    scanf("%d%d",&n,&k);
    for (int i=1; i<n; ++i) {
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if (k&1) {
        for (int i=1; i<=n; ++i)
            for (auto p : g[i])
                 {
                    m=0;
                    dfs(i,p,k/2);
                    dfs(p,i,k/2);
                    if (m>ans) ans=m;
                    if (ans==n) break;
                }
    } else {
        for (int i=1; i<=n; ++i) {
            m=0;
            dfs(i,0,k/2);
            if (m>ans) ans=m;
            if (ans==n) break;
        }
    }
    printf("%d\n",n-ans);
    return 0;
}


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

int a,b;

int main() {
    while(1){
        cin>>a>>b;
        if(a==0 && b==0) break;
        rep(i,a){
            rep(j,b){
                if((i%2 == j%2)) cout << "#";
                else cout <<".";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
    
   
}



Measured memory_bytes: 3100
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{

    class Program
    {
        public static (long m, long s)[,] dp;

        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                //var vals = Console.ReadLine().Split(' ').
                //    Select(x => long.Parse(x)).ToList();

                var S = Console.ReadLine();
                //var N = vals[0];
                //var X = vals[1];
                //var T = vals[2];
                int mod = 0;
                foreach(var c in S)
                {
                    mod = (mod + (c - '0'))%9;
                }


                var ans = (mod == 0) ? "Yes" : "No";


                Console.WriteLine(ans);

                Console.Out.Flush();
            }




        }
    }

}




Measured memory_bytes: 26572
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

//int dx[] = {-1, 0, 1, 0},                  dy[] = {0, 1, 0, -1};                  // 4 Direction
//int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1},    dy[] = {0, 1, 0, -1, -1, 1, -1, 1};    // 8 Direction

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}
inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}

const ll INF = 1e15;


int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    ll n;
    cin >> n;
    if (n & 1){
        return cout << 0 << endl, 0;
    }
    ll res = 0;
    ll d = 10;
    while (n >= d){
        res += n / d;
        d *= 5;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 768
#include <array>
#include <complex>
#include <iostream>
using namespace std;

const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

/* 点
 *
 * x 座標は p.real()
 * y 座標は p.imag()
 * 足し算，引き算，スカラー倍は定義済み
 */
typedef complex<double> point;
namespace std {
	bool operator<(const point& a, const point& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

/*
 * 直線・線分
 *
 * 辞書順の比較演算子が定義済み
 * 端点を for で走れる
 * {{x, y}} で初期化
 */
typedef array<point, 2> line;

double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}


bool is_parallel(const line& s, const line& t) {
	return eq(cross(s[0] - s[1], t[0] - t[1]), 0.0);
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		line s, t;
		for (auto& p : s) {
			double x, y; cin >> x >> y;
			p = point(x, y);
		}
		for (auto& p : t) {
			double x, y; cin >> x >> y;
			p = point(x, y);
		}
		cout << (is_parallel(s, t)?"YES":"NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<vector<ll>> big;//a, index
  big.push_back({0, -1});
  ll temp = 0;
  for (ll i = 0; i < N; ++i) {
    if (temp < A.at(i)) {
      temp = A.at(i);
      big.push_back({A.at(i), i});
    }
  }
  A.push_back(0);
  sort(A.begin(), A.end());
  sort(big.begin(), big.end());
  ll sum = 0;
  vector<ll> ans(N, 0);
  ll index = 1;
  for (ll i = 0; i < N; ++i) {
    if (index == big.size()) {
      break;
    }
    if (A.at(i) < big.at(index).at(0)) {
      ans.at(big.at(index).at(1)) += A.at(i) - big.at(index - 1).at(0);
    }
    else {
      index += 1;
    }
  }
  for (ll i = 0; i < big.size() - 1; ++i) {
    ans.at(big.at(i + 1).at(1)) += (big.at(i + 1).at(0) - big.at(i).at(0)) * (A.end() - lower_bound(A.begin(), A.end(), big.at(i + 1).at(0)));
  }
  for (ll i = 0; i < ans.size(); ++i) {
    cout << ans.at(i) << "\n";
  }
  // ans.at(big.at(big.size() - 1).at(1)) += sum;
}


Measured memory_bytes: 10320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i) ;
    }
    vector<int> B(N,0);
    B.at(0) = 0;
    long long total =0;
    for(int i=0;i<(N-1);i++){
        int b = ((A.at(i) - A.at(i+1)) + B.at(i));
        if(b < 0){
             b=0;
        } 
        B.at(i+1) = b;
        total = total + B.at(i+1);
    }
    cout  << total << endl;
}

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

int main()
{
  int N, W; cin >> N >> W;

  vector<long long> dp(N * 1e3 + 1, INT_MAX / 2);
  dp[0] = 0;

  for (int i = 0; i < N; i++)
  {
    int w, v; cin >> w >> v;
    vector<long long> nextdp(dp);

    for (int j = 0; j < dp.size(); j++)
    {
      if (j + v < dp.size()) {
        nextdp[j + v] = min(dp[j + v], dp[j] + w);
      }
    }

    dp = nextdp;
  }

  int ans;
  for (int i = 0; i < dp.size(); i++) {
    if (dp[i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1800
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cstring>


using namespace std;
#define int long long

int dp[2501][50][50];
int x[10010];
int N, A;

int rec(int sum, int a, int b) // a = 何番目か, b = 何枚選んだか
{
	if (dp[sum][a][b] != -1) return dp[sum][a][b];
	int res = 0;

	for (int i = a; i < N; ++i) {
		res += (sum + x[i]) == A * b;
		res += rec(sum + x[i], i + 1, b + 1);
	}
	
	return dp[sum][a][b] = res;
}

signed main()
{
	//ifstream cin("./Text.txt");
	memset(dp, -1, sizeof dp);
	cin >> N >> A;
	for (int i = 0; i < N; ++i) cin >> x[i];

	int sum = rec(0, 0, 1);
	cout << sum << endl;
}

Measured memory_bytes: 49152
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define N 100005
using namespace std;

int n, m, cnt, pr[N];
vector<int> gr[N];
queue<int> qu;

int main() {
	int i, t, t1, t2;
	cin >> n >> m;
	while(m--) {
		scanf("%d%d", &t1, &t2);
		gr[t1].push_back(t2);
		gr[t2].push_back(t1);
	}
	qu.push(1);
	pr[1] = -1;
	while(!qu.empty()) {
		t = qu.front(); qu.pop();
		for(auto x:gr[t]) {
			if(!pr[x]) {
				pr[x] = t;
				cnt++;
				qu.push(x);
			}
		}
	}
	if(cnt < n-1) puts("No");
	else {
		puts("Yes");
		for(i=2; i<=n; i++) printf("%d\n", pr[i]);
	}
	return 0;
}


Measured memory_bytes: 10680
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    string S;
    cin >> S;
    int len = SIZE(S);

    ll b = 0;
    ll w = 0;
    ll ans = 0;
    for(auto ch: S) {
        if (ch == 'B') {
            ++b;
        }
        else {
            ++w;
            ans += b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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

vector<vector<pair<int, ll>>> g;
vector<ll> cost;

void dfs(int d, int p){
    for(auto v : g[d]){
        if (v.first == p) continue;
        cost[v.first] = cost[d] + v.second;
        dfs(v.first, d);
    }
}

int main(){
    int n;
    cin >> n;
    g.resize(n);
    cost.resize(n);
    rep(i,n-1){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
    }

    int q, k;
    cin >> q >> k;
    k--;
    dfs(k, -1);
    rep(i, q){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << cost[x] + cost[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 15560
#include<stdio.h>
#define N 100001

typedef struct{
  char pattern;
  int num;
  int k;
}Card;
Card A[N];
void quicksort(int,int);
int partition(int,int);

int main(){
  int n,i,flag=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",&A[i].pattern,&A[i].num);
    A[i].k=i;
  }
  quicksort(0,n-1);

  for(i=0;i<n-1;i++){
    if(A[i].num == A[i+1].num && A[i].k > A[i+1].k){
      flag=1;
      break;
    }
  }
  if(flag == 0){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].pattern,A[i].num);
  }
  return 0;
}
void quicksort(int p,int r){
  int q;
  if(p<r){
    q=partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
}
int partition(int p,int r){
  int i,j,x;
  Card tmp;
  x=A[r].num;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].num<=x){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

Measured memory_bytes: 1784
#include <stdio.h>

int main(void) {
    int a1, a2, a3, a4, b1, b2, b3, b4, S, T;

    scanf ("%d %d %d %d\n", &a1, &a2, &a3, &a4);    
    scanf ("%d %d %d %d\n", &b1, &b2, &b3, &b4);

    S = a1 + a2 + a3 + a4;
    T = b1 + b2 + b3 + b4;

    if (S > T) {
        printf ("%d\n", S);
    }
    else {
        printf ("%d\n", T);
    }

    return 0;
}

Measured memory_bytes: 1028
N = int(input())
t = int(N/1.08)
if(t*1.08 == N):
    print(t)
elif(int((t+1)*1.08) == N):
    print(t+1)
elif(int((t-1)*1.08) == N):
    print(t-1)
else:
    print(':(')

Measured memory_bytes: 9020
def main():
    n = 10**18
    a = 10**18
    b = 10**18
    n, a, b = map(int, input().split())

    if (b - a) % 2 == 1:
        print((b-a)//2 + (b-a) % 2 + min(a-1, n-b))
    else:
        print((b - a) // 2)


if __name__ == '__main__':
    main()


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

void solve() {
    string ss; cin >> ss;
    int n = 0,s = 0,e = 0,w = 0;
    rep(i,ss.size()){
        if(ss[i] == 'N') n++;
        else if(ss[i] == 'S') s++;
        else if(ss[i] == 'E') e++;
        else w++;
    }
    if(n == 0 && s > 0 || n > 0 && s == 0) cout << "No" << endl;
    else if(e == 0 && w > 0 || e > 0 && w == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdint>
#include <limits>
#include <utility>
#include <vector>

template <typename T> class RadixHeap32 {
public:
	using uint32 = std::uint_fast32_t;
	using value_type = std::pair<uint32, T>;
	using reference = value_type &;
	using const_reference = const value_type &;
	using size_type = std::uint_fast32_t;

private:
	size_type bsr(const uint32 x) {
		if (!x)
			return 0;
#ifdef __GNUC__
		return 32 - __builtin_clz(x);
#else
		uint32 t = 16;
		for (uint32 i = 3; ~i; --i) {
			if (x & ~(((uint32)1 << t) - 1))
				t += (uint32)1 << i;
			else
				t -= (uint32)1 << i;
		}
		if (x & ~(((uint32)1 << t) - 1))
			++t;
		return t;
#endif
	}
	std::vector<value_type> v[33];
	uint32 last;
	size_type size_;

public:
	RadixHeap32() : last(0), size_(0) {}
	value_type pop() {
		assert(size_);
		--size_;
		if (v[0].empty()) {
			uint32 i = 1;
			while (v[i].empty())
				++i;
			last = std::numeric_limits<uint32>::max();
			for (const auto &d : v[i])
				last = std::min(last, d.first);
			for (const auto &d : v[i])
				v[bsr(last ^ d.first)].push_back(d);
			v[i].clear();
		}
		value_type ret = v[0].back();
		v[0].pop_back();
		return ret;
	}
	void push(const_reference x) {
		assert(last <= x.first);
		++size_;
		v[bsr(x.first ^ last)].push_back(x);
	}
	bool empty() const { return !size_; }
	size_type size() const { return size_; }
};
struct edge {
	int to;
	int cost;
};
#include<iostream>
#include<vector>
#include<limits>
#include<tuple>
int main(void) {
	int k;
	std::cin >> k;
	std::vector<std::vector<edge>> G(k);
	for (int i = 0;i < k;++i) {
		G[i].push_back({ i * 10 % k,0 });
		G[i].push_back({ (i + 1) % k,1 });
	}
	RadixHeap32<int> Q;
	static constexpr int INF = std::numeric_limits<int>::max();
	std::vector<int> d(k, INF);
	Q.push({ 1,1 });
	d[1] = 1;
	int v, c;
	while (!Q.empty()) {
		std::tie(c, v) = Q.pop();
		if (d[v] < c) continue;
		for (const auto &e : G[v]) {
			if (c + e.cost < d[e.to]) {
				d[e.to] = c + e.cost;
				Q.push({ d[e.to],e.to });
			}
		}
	}
	std::cout << d[0] << std::endl;
	return 0;
}

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.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 ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> a(n), b(n); rep(i, n) cin >> a[i] >> b[i];
    vector<ll> c(m), d(m); rep(i, m) cin >> c[i] >> d[i];
    rep(i, n) {
        ll ans = 0, dis = INF;
        rep(j, m) if(chmin(dis, abs(a[i]-c[j])+abs(b[i]-d[j]))) ans = j;
        cout << ans + 1 << endl;
    }
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;

    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));

    cout << (s < t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q5(){
	int n;
	cin>>n;
	if(n<10 || n&1){
		cout<<"0\n";
		return ;
	}
	int ans=0;
	int num=10;
	int xp=num;
	while(num<=n){
		ans+=n/num;
		num*=5;
	}
	cout<<ans<<endl;
}
void solve(){
	int a,b;
	cin>>a>>b;
	int g=__gcd(a,b);
	a*=b;a/=g;
	cout<<a;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;//cin>>t;
	t=1;
	while(t--)//
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  //vector<int> a(n);  rep(i, 0, n) cin >> a.at(i);
  
  cout << (n+2-1)/2 << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

vector<int> adj[100005];

int grundy(int node, int parent){
	int x = 0;
	for(int to : adj[node]){
		if(to == parent)
			continue;
		x ^= grundy(to, node);
	}
	return x+1;
}

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

	int N;
	cin >> N;
	rep(i,0,N-1){
		int x, y;
		cin >> x >> y;
		--x;--y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	if(grundy(0, -1) == 1)
		cout << "Bob" << endl;
	else
		cout << "Alice" << endl;
}

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

using namespace std;

int h, w;
char c[10005][10005];

int main () {
	cin >> h >> w;
	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}
	for(int i = 0; i <= h + 1; i++) {
		for(int j = 0; j <= w + 1; j++) {
			if(i == 0 || i == h + 1 || j == 0 || j == w + 1) {
				cout << "#";
			}
			else {
				cout << c[i][j];
			}
		}
		cout << "\n";
	}
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> ld;
  ld.push_back(1);
  for (int i = 0; i < n; ++i) {
    int a; cin >> a; a *= -1;
    int j = upper_bound(ld.begin(), ld.end(), a)-ld.begin();
    if (j >= ld.size()) { ld.push_back(a); }
    else { ld[j] = a; }
  }
  cout << ld.size() << endl;
  // for (int d: ld) { cerr << d << endl; }
}



Measured memory_bytes: 892
import sys, math
input = sys.stdin.readline

S = list(input().replace('\n',''))
S = list(map(int, S))
prev = S[0]
ans = 0
for i in range(1, len(S)):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
#     if i == 1:
#       if cur ^ S[i+1] == 1:
#         prev = cur
#       else:
#         prev = 2 + ~cur
#     else:
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)

Measured memory_bytes: 49776
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
tailrec fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}
fun main(args: Array<String>) {
    val (n, x) = intList()
    val xList = intList()

    val sorted = (xList + x).sorted()
    var prev = -1
    sorted.forEachIndexed { i, v ->
        if (i > 0) {
            val distance = v - sorted[i - 1]
            if (prev > -1) {
                prev = gcd(prev, distance)
            } else {
                prev = distance
            }
        }
    }

    println(prev.toString())
}


Measured memory_bytes: 54528
#include <bits/stdc++.h>
#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)

                    
using ll = long long;
using ull = unsigned long long;
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; }
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;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%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; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int N, M;
    cin >> N >> M;
    if (N == M) cout <<"Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608