akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void merge(int *, int, int, int);
void mergeSort(int *, int, int);

int count=0;


int main(){

  int n,i;
  int s[500000];

  scanf("%d",&n);

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

  mergeSort(s,0,n);

  for(i = 0 ; i < n ; i++){
    if(i==n-1) printf("%d\n",s[i]);
    else printf("%d ",s[i]);
  }

  printf("%d\n",count);

  return 0;

}


void mergeSort(int *s, int left, int right){
  
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(s,left,mid);
    mergeSort(s,mid,right);
    
    merge(s,left,mid,right);
  }
  
}

void merge(int *s, int left, int mid, int right){

  int n1,n2,i,k,j;

  n1 = mid - left;
  n2 = right - mid;

  int l[n1+1],r[n2+1];

  for(i = 0 ; i <= n1-1 ; i++) l[i] = s[left + i];

  for(i = 0 ; i <= n2-1 ; i++) r[i] = s[mid + i];

  l[n1] = 1000000000;
  r[n2] = 1000000000;

  i = 0;
  j = 0;

  for(k = left ; k <= right-1 ; k++){

    count++;

    if(l[i] <= r[j]){ 
      s[k] = l[i];
      i = i+1;
    }
    else{
      s[k] = r[j];
      j = j+1;
    }
    
  }
}
    

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 21;
const LL MOD = 1000000007;

int N;
bool adj[MAXN][MAXN];
LL pre[1 << MAXN], dp[1 << MAXN];
vector<int> store[MAXN+5];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < (1 << N); i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			cnt += i >> j & 1;
		}
		store[cnt].push_back(i);
	}
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> adj[i][j];
		}
	}
	
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		swap(dp, pre);
		fill(dp, dp + (1 << N), 0);
		for (int m : store[i + 1]) {
			for (int j = 0; j < N; j++) {
				if ((m >> j & 1) && adj[i][j]) {
					dp[m] += pre[m ^ (1 << j)];
				}
			}
			dp[m] %= MOD;
		}
	}
	
	cout << dp[(1 << N) - 1] << '\n';
}


Measured memory_bytes: 42428
import java.util.Scanner;

/**
 * Created by labuser on 2016/04/19.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {

        int W, H, x, y, r;

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        W = Integer.parseInt(input[0]);
        H = Integer.parseInt(input[1]);
        x = Integer.parseInt(input[2]);
        y = Integer.parseInt(input[3]);
        r = Integer.parseInt(input[4]);

        if (W >= (x + r) && 0 <= (x - r) && H >= (y + r) && 0 <= (y - r)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }


}

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

//maerd, remaerd, esare, resare
 
int main(){
  int n;
  cin >> n;
  int t[n];
  for(int i=0; i<n; i++) cin >> t[i];
  int m;
  cin >> m;
  for(int i=0; i<m; i++){
    int p, x;
    cin >> p >> x;
    p--;
    int ans = 0;
    for(int j=0; j<n; j++){
      if(j==p) ans+=x;
      else ans+=t[j];
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;





int main()
{
    int n;
    cin>>n;
    cout<<n/3;
    //system("pause");
    return 0;
} 

Measured memory_bytes: 256
cnt = Array.new(2, 0)
n, x = gets.split.map(&:to_i)
gets.split.map(&:to_i).each do |i|
    cnt[i % 2] += 1
end

f = Array.new(cnt[1] + 1)
f[0] = 1
1.upto(cnt[1]) do |i|
    f[i] = f[i - 1] * i
end

ans = 0
(cnt[1] + 1).times do |i|
    if i % 2 == x
        ans += f[cnt[1]] / f[i] / f[cnt[1] - i]
    end
end
ans *= (1 << cnt[0])
p ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
	int vacationDayCount, homeworkCount;
	cin >> vacationDayCount >> homeworkCount;

	vector<int> spends(homeworkCount);
	for (auto index = 0; index < homeworkCount; ++index) {
		cin >> spends.at(index);
	}

	const auto playableDayCount = vacationDayCount - accumulate(spends.begin(), spends.end(), 0);

	cout << ((playableDayCount >= 0) ? playableDayCount : -1);
	
	return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] point = { 0, 0 };

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		boolean isSuccess = true;
		int currentTime = 0;
		for (int i = 0; i < n; i++) {
			int t = Integer.parseInt(sc.next());
			int x = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());

			int move = Math.abs(x - point[0]) + Math.abs(y - point[1]);

			int diftime = t - currentTime;
			if (move > diftime || move % 2 != diftime % 2) {
				isSuccess = false;
				break;
			}
			currentTime = t;
			point[0] = x;
			point[1] = y;

		}

		if (isSuccess) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 63844
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sqr(x) (x) * (x)

using namespace std;
using namespace __gnu_pbds;

mt19937_64 gen(time(0));

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//const int mod = 1e9 + 7;
//const int inf = 2e9 + 6555;
const int maxn = 82;

ll a[maxn];
ll dp[maxn];

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    dp[0] = 1000;
    for(int i = 1; i < n; ++i)
    {
        dp[i] = max(dp[i - 1],
                    (dp[i - 1] % a[i - 1]) +  (dp[i - 1] / a[i - 1]) * a[i]);
    }
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 3608
import math
import fractions
import copy
import numpy as np
import heapq
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n = ip()
a = iprow()
s = 0
for i in range(n):
    s+=(1/a[i])
print(1/s)

Measured memory_bytes: 23172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    cout.precision(20);
    if (2 * x <= a * a * b) cout << atan(a*b*b/2/x) * 180.0 / M_PI << endl;
    else cout << atan(2/a*(b - x/(a*a))) * 180.0 / M_PI << endl;
}

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

int Abs(int n){
  return n < 0 ? -n : n;
}
int main(){
  int n;
  cin>>n;
  vector<int> dp(n,0);
  vector<int> h(n);
  for(int i = 0; i < n; i++)
    cin>>h[i];
  dp[1] = Abs(h[0]-h[1]);
  for(int i = 2; i < n; i++){
    dp[i] = min( dp[i-1]+Abs(h[i]-h[i-1]),
                 dp[i-2]+Abs(h[i]-h[i-2]) );
  }
  cout << dp[n-1] << "\n";
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

vector<set<int>> graph;

signed main(){
    int N, Q; cin >> N >> Q;
    graph = vector<set<int>>(N,set<int>());
    vector<int> counter(N,0);
    
    //make undirected graph
    rep(i,N-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].insert(b);
        graph[b].insert(a);
    }

    //add values to the counters
    rep(query,Q){
        int root, x;
        cin >> root >> x;
        counter[--root] += x;
    }
    
    //calc all by using BFS
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(int to: graph[now]){
            graph[to].erase(now); //cut reverse edge
            counter[to] += counter[now];
            q.push(to);
        }
    }
    
    //print all
    rep(i,N-1) cout << counter[i] << " ";
    cout << counter[N-1] << endl;
    return 0;
}

Measured memory_bytes: 33536
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int numofa = 0;
    ll ans = 0;
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            ans += numofa + 1;
            s[i+2] = 'A';
            i++;
        }else if(s[i] == 'A') numofa++;
        else numofa = 0;
    }
    cout << ans << endl;
}

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

int main(){
    int N,L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }
    sort(S.begin(),S.end());

    for (int i = 0; i < N; i++)
    {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String N = sc.next();
   long K = sc.nextLong();
   int tmp =0;
   char tmpchar = '1';
   
   while(101>tmp && K>tmp)
   {
     if(N.charAt(tmp)!='1')
     {
       tmpchar = N.charAt(tmp);
       break;
     }
     tmp++;
   }
   
   System.out.println(tmpchar);
 }
}

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

using namespace std;

int main() {
    int n;
    int A[100000], B[100000], C[100000];

    scanf("%d", &n);
    for (int i=0; i<n; i++) scanf("%d", &A[i]);
    for (int i=0; i<n; i++) scanf("%d", &B[i]);
    for (int i=0; i<n; i++) scanf("%d", &C[i]);

    sort(A, A+n); sort(B, B+n); sort(C, C+n);

    int tB[100000];
    for (int pa=0, pb=0; pb<n; pb++) {
        while (A[pa]<B[pb] && pa<n) pa++;
        tB[pb] = pa;
    }

    long long int res = 0, sum = 0;
    for (int pb=0, pc=0; pc<n; pc++) {
        while (B[pb]<C[pc] && pb<n) {
            sum += tB[pb];
            pb++;
        }
        res += sum;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

// 1indexed1dimention[l,r]
class imos1d{
  public:
  vector<ll>t, v;
  ll num;
  ll flg;
  imos1d(ll NUM = 0){
      flg = 0;
      num = NUM + 10;
      v = vector<ll>(num, 0);
      t = vector<ll>(num, 0);
  }
  void add(ll idx, ll x){
      flg = 0;
      t[idx] += x;
  }
  void make(){
      flg = 1;
      for(ll i = 1; i < num; i++)v[i] = v[i - 1] + t[i];
  }
  ll sum(ll l, ll r){
      if(!flg)make();
      return v[r] - v[l - 1];
  }
};

int main(){

	ll N;
	cin >> N;
	string s;
	cin >> s;
	s = "*" + s;
	imos1d M(1010101);
	rep1(i, N)if(s[i] == 'M')M.add(i, 1);
	ll Q;
	cin >> Q;
	rep(q, Q){
		ll k;
		cin >> k;
		ll ans = 0;
		vector<ll>D(1010101, 0);
		vector<ll>DM(1010101, 0);
		rep1(i, N){
			D[i] = D[i - 1];
			DM[i] = DM[i - 1];
			ll pre = i - k;
			if(pre >= 1 && s[pre] == 'D'){
				D[i]--;
				DM[i] -= M.sum(pre, i - 1);
			}
			if(s[i] == 'D')D[i]++;
			if(s[i] == 'M')DM[i] += D[i];
			if(s[i] == 'C')ans += DM[i];			
		}
		cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 34848
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,k;
	cin >> n >> k;
	int ans = 1;
	REP(i,n){
		if(2 * ans < ans + k) ans *= 2;
		else ans += k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

long long int N, A, B, X[112345];
long long int ans;

int main()
{
	scanf("%lld%lld%lld", &N, &A, &B);
	for (long long int i = 0; i < N; ++i) { scanf("%lld", &X[i]); }

	for (long long int i = 0; i < N - 1; ++i)
	{
		ans += std::min(A*(X[i + 1] - X[i]), B);
	}

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

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt n;
	std::cin >> n;
	lnt ans=0;
	for(lnt i=1;i<=n;i++) {
		lnt y=n/i;
		ans+=y*(y+1)*i/2;
	}
	print(ans);
}


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

int main(int argc, const char * argv[]) {
    int A, B, C;
    int X;
    
    cin >> A >> B >> C >> X;
    
    int count = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (((i * 500) + (j * 100) + (k * 50)) == X) {
                    count++;
                }
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
L=[["."]+list(input())+["."] for _ in range(H)]
l=[["." for i in range(W+2)]]
L=l+L+l
A=[-1,1,0,0]
B=[0,0,-1,1]
n=True
for i in range(1,H+1):
  for j in range(1,W+1):
    if L[i][j]=="#":
      if all(L[i+A[k]][j+B[k]]!="#" for k in range(4)):
        n=False
        break
  else:
    continue
  break
if n:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int upf(double num){
    if(num-(int)num>0)return (int)num+1;
    else return num;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    Chara taka,ao;
    std::cin>>taka.hp>>taka.sp>>ao.hp>>ao.sp;
    if(upf((double)taka.hp/(double)ao.sp)>=upf((double)ao.hp/(double)taka.sp))printm("Yes");
    else printm("No");
    return 0;
}


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

/*
BubbleSort(A)
1 for i = 0 to A.length-1
2     for j = A.length-1 downto i+1
3         if A[j] < A[j-1]
4             swap A[j] and A[j-1]
*/

int BubblueSort(int dat[],int n){
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(dat[j]<dat[j-1]){
                int tmp=dat[j];
				dat[j]=dat[j-1];
                dat[j-1]=tmp;
				cnt++;
			}
		}
	}
	for(int i=0;i<n-1;i++)
	      cout<<dat[i]<<" ";
	cout<<dat[n-1]<<endl;
	cout<<cnt<<endl;
}

int main(){
	int n;
	int dat[100];
	cin>>n;
	for(int i=0;i<n;i++)
	      cin>>dat[i];

	 
	 BubblueSort(dat,n);
	
	
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using usize = std::size_t;
using u32 = std::uint32_t;

template <class T> void chmin(T &a, const T &b) {
  if (b < a)
    a = b;
}

int main() {

  usize n;
  std::cin >> n;

  std::vector<u32> r(n);
  for (auto &e : r) {
    std::cin >> e;
  }

  std::vector<u32> s(n), p(n), c(n);
  for (usize i = 0; i != n; ++i) {
    std::cin >> s[i] >> p[i] >> c[i];
  }

  const auto get_rank = [&]() {
    std::vector<u32> pts(n, 0);
    for (const auto e_ : {&s, &p, &c}) {
      const auto &e = *e_;
      auto v = e;
      std::sort(v.begin(), v.end(), std::greater<>());
      std::map<u32, usize> rank;
      for (usize i = n; i != 0;) {
        --i;
        rank[v[i]] = i;
      }
      for (usize i = 0; i != n; ++i) {
        pts[i] += r[rank[e[i]]];
      }
    }
    auto v = pts;
    std::sort(v.begin(), v.end(), std::greater<>());
    std::map<u32, usize> rank;
    for (usize i = n; i != 0;) {
      --i;
      rank[v[i]] = i;
    }
    return rank[pts[0]];
  };

  static constexpr u32 inf = std::numeric_limits<u32>::max();
  u32 ans = inf;

  for (const auto e_ : {&s, &p, &c}) {
    auto &e = *e_;

    const u32 prev = e[0];
    for (u32 i = 1; i != 110; ++i) {
      e[0] += 1;
      if (get_rank() < 8) {
        chmin(ans, i);
        break;
      }
    }
    e[0] = prev;
  }

  if (ans != inf) {
    std::cout << ans << std::endl;
  } else {
    std::cout << "Saiko" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3164
def get_root(nodes, x: int) -> int:
    if nodes[x] < 0:
        return x
    else:
        nodes[x] = get_root(nodes, nodes[x])
        return nodes[x]


def unite(nodes, x: int, y: int) -> None:
    root_x, root_y = get_root(nodes, x), get_root(nodes, y)
    if root_x != root_y:
        bigroot, smallroot = \
            (root_x, root_y) if nodes[root_x] < nodes[root_y] else (root_y, root_x)
        nodes[bigroot] += nodes[smallroot]
        nodes[smallroot] = bigroot


if __name__ == "__main__":
    import sys
    N, Q = map(int, input().split())
    nodes = [-1]*N
    result = []
    append = result.append

    for p, a, b in (map(int, l.split()) for l in sys.stdin):
        if not p:
            unite(nodes, a, b)
        else:
            append(1 if get_root(nodes, a) == get_root(nodes, b) else 0)

    print(*result, sep="\n")


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

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

  int a = y / 10000;
  int b = y / 5000;
  int c = y / 1000;
  for (int i = 0; i <= a; i ++) {
    for (int j = 0; j <= b; j ++) {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y && n - i - j >= 0) {
        cout << i << " " << j << " " << n - i - j << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
import sys
from heapq import *
input = sys.stdin.readline

class Bellman_Ford:
    def __init__(self, v=None, e=None, lis=None, start=None, end=None, inf=pow(10, 18)):
        self.V = v
        self.E = e
        self.lis = lis
        self.start = start if start else 0
        self.end = end if end else self.V-1
        self.inf = inf
        self.close_minus = False#負の閉路の有無
        self.count = self.V*2-1
        self.negative = [False]*self.V
        self.judge = False

    """
    リストは各要素が(始点、終点、重み)となる有向辺の集合とする(無向なら両方作る必要あり)
    Vは頂点数、Eは辺の数（これは今の所使われない）
    close_minusがTrueなら、負の閉路が存在してしまうので、注意する
    """

    def getlist(self, lis):
        self.lis = lis
    
    def def_start(self, s):
        self.start = s
    
    def def_end(self, e):
        self.end = e

    def def_inf(self, inf):
        self.inf = inf
    
    def def_vertice(self, v):
        self.V = v
    
    def def_edge(self, e):
        self.E = e
    
    def prepare(self):
        self.cost = [self.inf]*self.V # 各頂点への最小コスト
        self.cost[self.start] = 0 # 自身への距離は0

    def search(self):
        for i in range(self.V):
            update = False # 更新が行われたか
            for x, y, z in self.lis:
                if self.cost[y] > self.cost[x] + z:
                    self.cost[y] = self.cost[x] + z
                    update = True
                    if self.count <= self.V:
                        self.negative[y] = True
                    self.count -= 1
                if self.count == self.V:
                    self.judge = True
                if self.count == 0:
                    break
            if not update or not self.count:
                break
            # 負閉路が存在
            if i == self.V - 1:
                self.close_minus = True
                return False
        return True

    def main(self):#これを実行すれば良い
        self.prepare()
        self.search()
    
    def cost_all(self):
        return self.cost

def main():
    n, m = map(int,input().split())
    arrange = [None]*m

    for i in range(m):
        a, b, c = map(int, input().split())
        arrange[i] = (a-1, b-1, -c)

    bf = Bellman_Ford(v=n, e=m, lis=arrange)
    bf.main()

    for a, b, c in arrange:
        if bf.negative[a]:
            bf.negative[b] = True

    if bf.negative[n-1]:
        print("inf")
    else:
        print(-bf.cost[-1]) 


if __name__ == "__main__":
    main()

Measured memory_bytes: 73952
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #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
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


  int dp[101][101];

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


   


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

    set<int> s;   

    for(int i = 1; i <= m; i++)
    {
      int x;
      cin >> x;

      s.insert(x);

    }

    int ans1 = 0, ans2 = 0;

    for(int i = x-1; i >= 0; i--)
    {
      if(s.count(i))ans1++;
    }

    for(int i = x+1; i <= n; i++)
    {
      if(s.count(i))ans2++;
    }

    cout << min(ans1,ans2);



    return 0;   
}


Measured memory_bytes: 3632
#include <stdio.h>
#define MAX 100000
int A[MAX];
int partition(int,int);
int main(){
  int i,n,q;
  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);

    for(i=0;i < n;i++){
    if(i)printf(" ");
    if(i == q)printf("[");
    printf("%d",A[i]);
    if(i == q)printf("]");
  }
  printf("\n");
  return 0;
}
int partition(int p,int r){
  int x = A[r];
  int i = p-1,j;
  int y;
  for (j = p;j < r;j++){
    if (A[j] <= x){
      i = i+1;
      y=A[j];
      A[j]=A[i];
      A[i]=y;
    }
  }
  A[r]=A[i+1];
  A[i+1]=x;
  return i+1;
}


Measured memory_bytes: 2132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int sum5 = 0;
		int sum7 = 0;
		
		if(A == 5) {
			sum5++;
		} else if(A == 7) {
			sum7++;
		}
		if(B == 5) {
			sum5++;
		} else if(B == 7) {
			sum7++;
		}
		if(C == 5) {
			sum5++;
		} else if(C == 7) {
			sum7++;
		}
		
		if(sum5 == 2 && sum7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
		scan.close();
	}

}


Measured memory_bytes: 23636
#include<stdio.h>
int x[100005];
int main()
{
	int k,i;long long max=2,min=2;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d",&x[i]);
	}
	for(i=k-1;i>=0;i--)
	{
		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];
		max=max/x[i]*x[i]+x[i]-1;
		if(max<min)break;
	}
	if(max>=min) printf("%lld %lld\n",min,max);
	else printf("-1\n");
}

Measured memory_bytes: 640
import collections
def solve():
  s = input()
  c = collections.Counter(s)
  query = 'abcdefghijklmnopqrstuvwxyz'
  ans = 10**10
  for i in range(len(query)):
    target = query[i]
    if c[target] == 0:
      continue
    else:
      s_copy = s
      ct = 0
      while len(set(s_copy)) > 1:
        n = len(s_copy)
        for j in range(n-1):
          if s_copy[j+1] == target:
            s_copy = s_copy[:j] + target + s_copy[j+1:]
        s_copy = s_copy[0:n-1]
        ct += 1
    ans = min(ans,ct)
  print(ans)
solve()

Measured memory_bytes: 3316
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>

#define LENGTH 100005

typedef struct pp
{
	char name[100];
	int time;
}Process;

Process Q[LENGTH];
int head, tail, n;

void enqueue(Process x)
{
	Q[tail] = x;
	tail = (tail + 1) % LENGTH;
}

Process dequeue()
{
	Process x = Q[head];
	head = (head + 1) % LENGTH;
	return x;
}

int main()
{
	using namespace std;

	int elaps = 0, c;
	int q;
	Process u;
	scanf("%d %d", &n, &q);

	for (int i = 1; i <= n; i++)
	{
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}
	head = 1;
	tail = n + 1;

	while (head != tail)
	{
		u = dequeue();
		c = min(q, u.time);
		u.time -= c;
		elaps += c;
		if (u.time > 0) enqueue(u);
		else
		{
			printf("%s %d\n", u.name, elaps);
		}
	}
}

Measured memory_bytes: 12728
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
LL n,x,m,s[N],a[N];
int pos[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>x>>m;
  pos[x]=1;s[1]=x;a[1]=x;
  for(int i=2;i<=n;i++){
    a[i]=(a[i-1]*a[i-1])%m;
    if(pos[a[i]]){
      LL last=n-i+1;
      LL duan=i-pos[a[i]];
      cout<<s[i-1]+(last/duan)*(s[i-1]-s[pos[a[i]]-1])+(-s[pos[a[i]]-1]+s[pos[a[i]]-1+(last%duan)])<<'\n';
      return 0;
    }else{
      pos[a[i]]=i;
    }
    s[i]=s[i-1]+a[i];
  }
  cout<<s[n]<<'\n';
  return 0;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; scanf("%d", &N);
    for(int i=0; i<N; ++i)
    {
        char c; scanf(" %c", &c);
        if(c=='Y')
        {
            puts("Four");
            return 0;
        }
    }
    puts("Three");
}

Measured memory_bytes: 256
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

//         a / b
li ceil(li a, li b) {
  if (a / b < 0) return a / b;
  else return a % b ? a / b + 1 : a / b;
}

void _main(int tc) {
  int n;
  cin >> n;
  li sumt = 0, suma = 0;
  rep(i, n) {
    li t, a;
    cin >> t >> a;
    if (i == 0) sumt = t, suma = a;
    else {
      li m1 = ceil(sumt, t);
      li m2 = ceil(suma , a);
      li multi = max(m1, m2);
      sumt = t * multi, suma = a * multi;
    }
  }

  cout << sumt + suma << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
 double R1,R2;
  cin>>R1>>R2;
  cout<<fixed<<setprecision(8);
  cout<<double(R1*R2)/(R1+R2)<<endl;
  
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr ll BIG = 1000000000000L;

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

    ll sum = 0;
    ll cnt = 0;
    int M;
    cin >> M;

    vll D(M);
    vll C(M);

    for (int i=0;i<M;i++) cin >> D[i] >> C[i];

    for (int i=0;i<M;i++){
        sum += C[i]*D[i];
        cnt += C[i];
    } 

    ll ans = (cnt - 1) + (sum - 1)/9;
    cout << ans << endl;

    return 0;
}

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


int main() {
    std::string S;
    cin >> S;

    if(S=="AAA" || S=="BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
# AtCoder Beginner Contest 126
# https://atcoder.jp/contests/abc126
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    M, K = i2nn()
    # K = 0 のとき、a[i] == a[i+1] と連続で並べれば a[i] ^ a[i+1] == 0 より構築可能
    if K == 0:
        for i in range(2**M):
            print(i, end=' ')
            print(i, end=' ')
        print()
        return
    # a < 2^M より、K >= 2^M の場合は無理
    if K >= 2**M:
        print(-1)
        return

    B = [i for i in range(0, 2**M) if i != K]
    C = [i for i in range(0, 2**M) if i != K]
    C.reverse()
    # A = B + C とすると、K以外の任意の2つの i について 0 となる（昇順と降順で打ち消しあうため）
    # A = B + [K] + C とすると、K以外の任意の2つの i について K となる
    # A = B + [K] + C + [K] とすると、Kについて sumxor(C) となる
    # あとは sumxor(C) = K となるか否か
    n = 0
    for c in C:
        n ^= c
    if n != K:
        print(-1)
        return
    
    for b in B:
        print(b, end=' ')
    print(K, end=' ')
    for c in C:
        print(c, end=' ')
    print(K)

main()


Measured memory_bytes: 56704
s = input()
n = 0
ans = 10**10
for k in 'qwertyuiopasdfghjklzxcvbnm':
    l = [i if i == k else 0 for i in s]
    a = 0
    while l.count(k)!=len(l):
        for i in range(len(l)-1):
            if l[i]==k or l[i+1]==k:
                l[i] = k
        a += 1
        l.pop(-1)
    ans = min(ans,a)
    n += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  LLI r;
  while(cin >> r){
    LLI ans = 3*r*r;

    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
line = $stdin
lines = line.readlines
line.close

Vertex = Struct.new("Vertex", :x, :y)

def subv(a, b)
	return Vertex.new((b.x - a.x), (b.y - a.y))
end

def cross(a, b)
	return (a.x * b.y - a.y * b.x)
end

lines.each do |l|
	arr = l.split(",")
	va = Vertex.new(arr[0].to_f, arr[1].to_f)
	vb = Vertex.new(arr[2].to_f, arr[3].to_f)
	vc = Vertex.new(arr[4].to_f, arr[5].to_f)
	vd = Vertex.new(arr[6].to_f, arr[7].to_f)
	vAC = subv(va, vc)
	vAB = subv(va, vb)
	vAD = subv(va, vd)
	vBD = subv(vb, vd)
	vBA = subv(vb, va)
	vBC = subv(vb, vc)
	if (cross(vAC, vAB) * cross(vAC, vAD) < 0) &&
		(cross(vBD, vBA) * cross(vBD, vBC) < 0) then
		puts "YES"
	else
		puts "NO"
	end
end

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int n=sz(s);

	VI kg, ty;
	rep(i, n-1){
		if(s[i]=='L' && s[i+1]=='R') kg.push_back(i+1);
		if(s[i]=='R' && s[i+1]=='L') ty.push_back(i);
	}
	kg.push_back(n);
	VI ans(n);
	int st =0;
	rep(i, sz(kg)){
		rep2(j, st, kg[i]){
			if(j%2 == ty[i]%2) ans[ty[i]]++;
			else ans[ty[i] +1]++;
		}
		st = kg[i];
	}
	
	for(auto x :ans) printf("%d ",x); puts("");
	return 0;
}


Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int t;
	cin>>t;
	cout<<((t)*(t-1LL))/2LL;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF = 1000000000000;

std::vector<int> elt(){
    std::vector<bool> a(56555,true);
    std::vector<int> prime;
    for(int i = 2; i <= 55555; i++){
        if(a[i]){
            prime.push_back(i);
            for(int j = i; j <= 55555; j += i)a[j] = false;
        }
    }
    return prime;
}



int main()
{
    int n;
    std::cin >> n;
    std::vector<int> prime = elt(), ans;
    for(int i = 0; i <= (int)prime.size(); i++){
        if(prime[i] % 10 == 1)ans.push_back(prime[i]);
    }
    for(int i = 0; i < n; i++)std::cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  char s[10];
  int i=0;
  scanf("%s",s);
 
  
    if(s[2]==s[3]&&s[4]==s[5])
      printf("Yes\n");
      else 
     printf("No\n");
   
  
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
    
    int n, k, x, y;;
    scanf("%d%d%d%d", &n, &k, &x, &y);

    int ans = 0;
    for (int i=0; i<n; i++){
        if (i < k){
            ans += x;
        }else{
            ans += y;
        }
        
    }
    
    printf("%d\n", ans);
    
    return 0;

}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a, b, c, x, y;
	int sum1, sum2, sum3, result;
	int i;

	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

	sum1 = (a * x) + (b * y);
	sum2 = c * x * 2;
	if (x < y)
	{
		i = y - x;
		while (0 < i)
		{
			sum2 += b;
			i--;
		}
	}
	sum3 = c * y * 2;
	if (y < x)
	{
		i = x -y;
		while (0 < i)
		{
			sum3 += a;
			i--;
		}
	}

	if (sum1 < sum2)
	{
		result = sum1;

		if (sum3 < sum1)
		{
			result = sum3;
		}
	}
	else
	{
		result = sum2;
		if (sum3 < sum2)
		{
			result = sum3;
		}
	}

	printf("%d", result);

	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
a = Array.new(7,0)
n.times do
  x = gets.to_f
  if x<165.0
    a[1] = a[1] + 1
  elsif x<170.0
    a[2] = a[2] + 1 
  elsif x<175.0
    a[3] = a[3] + 1
  elsif x<180.0
    a[4] = a[4] + 1
  elsif x<185.0
    a[5] = a[5] + 1
  else
    a[6] = a[6] + 1
  end
end
for i in 1..6
  print(i,":","*"*a[i],"\n")
end


Measured memory_bytes: 6108
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
const double PI=4*atan(1);
using namespace std;
#define MAX 1000001

long findmin(long a,long b) {
    return a<b?a:b;
}
long findmax(long a,long b) {
    return a>b?a:b;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
    cout.flush();
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a == b + c || b == a + c)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#i!/usr/bin/env python
# coding: utf-8

from collections import Counter
import sys
input = sys.stdin.readline

def divisors(n):
    ret = {}
    tmp = n
    for p in [2, 3, 5, 7]:
        d = 0
        while tmp % p == 0:
            tmp /= p
            d += 1
        if d > 0:
            ret[p] = d
    if tmp > 1:
        ret[int(tmp)] = 1
    return ret


def main():
    patterns = [(5, 5, 3), (15, 5), (25, 3), (75)]
    N = int(input())
    divs = Counter()
    for n in range(1, N+1):
        divs.update(divisors(n))
    l = [0] * 5
    for i, p75 in enumerate([75, 25, 15, 5, 3]):
        for p, cnt in divs.most_common():
            if cnt >= p75-1:
                l[i] += 1
    ret = 0
    ret += l[0] # 75
    ret += l[1] * (l[4]-1) # 25 * 3
    ret += l[2] * (l[3]-1) # 15 * 5
    ret += (l[3] * (l[3]-1) / 2) * (l[4]-2) # 5 * 5 * 3
    print(int(ret))


if __name__ == '__main__':
    main()


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

int main(){
    string s;
    cin>>s;
    vector<string> ans={"AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA","AKIHBRA","AKIHABR","KIHABRA","KIHABAR","AKIHBAR","AKIHBR","KIHABR","KIHBAR","KIHBRA","KIHBR"};
    for(int i=0;i<16;i++){
        for(int j=i+1;j<16;j++){
            if(ans[i]==ans[j]){
                cerr<<i<<" "<<j;
            }
        }
    }
    cerr<<ans.size();
    for(int i=0;i<16;i++){
        if(s==ans[i]){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO";

    
}

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

#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=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;

	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println(new SocialGame(scanner.nextInt(), scanner.nextInt(), scanner.nextInt()).calcDays_to_earn_goal_coins());
        scanner.close();
    }
}

class SocialGame {
    private int daily_coin = 0;
    private int weekly_coin = 0;
    private int goal_coin = 0;

    public SocialGame(int daily_coin, int weekly_coin, int goal_coin) {
        this.daily_coin = daily_coin;
        this.weekly_coin = weekly_coin;
        this.goal_coin = goal_coin;
    }

    public int calcDays_to_earn_goal_coins() {
        int remain_coin = goal_coin;
        int passed_days = 0;
        while(true) {
            passed_days += 1;
            remain_coin -= daily_coin;

            if(passed_days % 7 == 0) {
                remain_coin -= weekly_coin;
            }

            if(remain_coin <= 0) {
                return passed_days;
            }
        }
    }
}


Measured memory_bytes: 26416
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;

int main() {

	int n;
	cin >> n;
	set<int> s;
	int cnt8 = 0;
	for (int i = 0; i < n;i++) {
		int a;
		cin >> a;

		int num = a / 400;
		if (num >=8) {
			cnt8++;
		}
		else {
			s.insert(num);
		}
	}
	
	int cnt = s.size();

	int mi = max(cnt, 1);
	int ma = cnt + cnt8;
	
	cout << mi << " " << ma << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
cnt = 0

for i in range(n-2):
  if (p[i+1] > p[i] or p[i+1] > p[i+2]) and (p[i+1] < p[i] or p[i+1] < p[i+2]):
    cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int N=100050,inf=1e9;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
inline int gc(){
  char ch=getchar();
  while(ch!='S'&&ch!='o'&&ch!='.'&&ch!='T') ch=getchar();
  if (ch=='.') return 0;
  if (ch=='o') return 1;
  if (ch=='S') return 2;
  return 3;
}
int S,T,nn[N<<1][3],head[N],cnt=1,tot,vis[N],st[N];
inline void link(int u,int v,int w){
  nn[++cnt][1]=v,nn[cnt][0]=head[u],head[u]=cnt,nn[cnt][2]=w;
  nn[++cnt][1]=u,nn[cnt][0]=head[v],head[v]=cnt,nn[cnt][2]=0;
  return;
}
inline int bfs(){
  for (int i=1; i<=T; ++i)
    vis[i]=0;
  int l=0,r=1,s,t;
  st[1]=S,vis[S]=1;
  while(l<r){
    s=st[++l];
    for (int i=head[s]; i; i=nn[i][0])
      if (nn[i][2]&&!vis[t=nn[i][1]])
	vis[t]=vis[s]+1,st[++r]=t;
    if (vis[T]) return 1;
  }
  return 0;
}
inline int Min(int a,int b){
  return a<b?a:b;
}
int dinic(int x,int flow){
  if (x==T) return flow;
  int tmp,s=0,t;
  for (int i=head[x]; i; i=nn[i][0])
    if (nn[i][2]&&vis[t=nn[i][1]]==vis[x]+1){
      tmp=dinic(t,Min(flow,nn[i][2]));
      s+=tmp,nn[i][2]-=tmp,nn[i^1][2]+=tmp,flow-=tmp;
      if (!flow) break;
    }
  if (!s) vis[x]=0;
  return s;
}
int main(){
  int h=gi(),w=gi(),s; tot=h+w+2;
  S=tot-1,T=tot;
  for (int i=1; i<=h; ++i)
    for (int j=1; j<=w; ++j){
      s=gc();
      if (!s) continue;
      if (s==1) link(i,j+h,1),link(j+h,i,1);
      if (s==2) link(S,i,inf),link(S,j+h,inf),link(i,j+h,inf),link(j+h,i,inf);
      if (s==3) link(j+h,T,inf),link(i,T,inf),link(i,j+h,inf),link(j+h,i,inf);
    }
  int ans=0;
  while(bfs()) ans+=dinic(S,inf);
  if (ans>=inf) puts("-1");
  else printf("%d",ans);
  return 0;
}

Measured memory_bytes: 768