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


int main(void){

    char tmp =0;
    int num1,num2,answer =0;
    
    scanf("%d%d", &num1, &num2);
    
    while(answer == 0){
        if(num2==num1)
        {
            answer = num1;
        }
        else if (num2>num1)
        {
            num2=num2%num1;
            if(num2==0)
            {
                answer = num1;
            }
        }
        else
        {
            num1=num1%num2;
            if(num1==0)
            {
                answer = num2;
            }
        }
    }
    printf("%d\n",answer);
    
    return 0;
}



Measured memory_bytes: 2040
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
s=[k for k in [a%10,b%10,c%10,d%10,e%10] if k>0]
if s==[]:
  t=0
else:
  t=min(s)
ans = (a//10+(a%10!=0))*10+(b//10+(b%10!=0))*10+(c//10+(c%10!=0))*10+(d//10+(d%10!=0))*10+(e//10+(e%10!=0))*10+(s!=[])*(-10+t)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll M = 1000000007;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll dp[k+1][2];
    for(int i=0;i<2;i++){
        for(int j=0;j<k+1;j++)dp[j][i]=0;
    }
    ll s = a[0];
    for(int i=0;i<=a[0];i++)dp[i][0]=1;
    for(int c = 1;c<n;c++){
        s+=a[c];
        for(int i=0;i<=k;i++){
            if(i == 0)dp[i][c%2]=1;
            else{
                if(i<=a[c]){
                    dp[i][c%2]=(dp[i][(c-1)%2]+dp[i-1][c%2])%M;
                }
                else dp[i][c%2] = (dp[i][(c-1)%2]+dp[i-1][c%2]-dp[i-a[c]-1][(c-1)%2])%M;
            }
            if(i>s)dp[i][c%2]=0;
            //cout<<dp[i][c%2]<<" ";
        }
       // cout<<endl;
    }
    dp[k][(n-1)%2] = ((dp[k][(n-1)%2]>=0)?dp[k][(n-1)%2]:(M+dp[k][(n-1)%2]));
    cout<<dp[k][(n-1)%2]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main(){
	string buf,tmp,out;
	bool f;
	getline(cin,buf);
	out = "";
	f = false;
	for(int i = 0;i < buf.size();++i){
		if(buf[i] == '.' || buf[i] == ',') buf[i] = ' ';
	}
	stringstream ss;
	ss << buf;
	while(ss >> tmp){
		if(2 < tmp.size() && tmp.size() < 7){
			if(f) out += ' ';
			out += tmp;
			f = true;
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 1216
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]
import math

X = read_int()
ans = 0
money = 100
while True:
    ans += 1
    money = math.floor(money * 1.01)
    if money >= X:
        print(ans)
        exit(0)

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

int main(){
    int K, S;
    cin >> K >> S;
    int ans=0;
    for (int x=0; x <= K; x++){
        for (int y=0; y <= K; y++){
                if (0 <= (S - x -y) && (S - x -y) <= K){
                    ans ++;
            }
        }
    }

    cout << ans ;
}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(a*180-360);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 int N , M , C;
 cin >> N >> M >> C;
  
 vector<int> B(M);
 for(int i=0; i<M; i++)
   cin >> B.at(i);
  
 vector<vector<int>> A(N, vector<int>(M));
  for (int i=0; i<N; i++){
   for (int j=0; j<M; j++)
     cin >> A.at(i).at(j);
  }
 
  int ans =0;
  for (int i=0; i<N; i++){
    int count = 0;
    for (int j=0; j<M; j++){
     count += A.at(i).at(j) * B.at(j);
    }
    if (count + C > 0){
     ans++; 
    }
    count =0;  
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

if 0 in a_list:
    print(0)
else:
    result = 1
    for a in a_list:
        result = result * a
        if result > 10 ** 18:
            print(-1)
            break
    else:
        print(result)


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

using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int i = 0, j = s.size()-1;
    while( i < j ){
        if( s[i] != s[j] )cnt++;
        i++;j--;
    }
    cout << cnt << "\n";
}


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

int main(){
  int N;
  cin>>N;
  int H[N];
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  int maxH;
  maxH=H[0];
  int count=1;
  for(int i=1;i<N;i++){
    if(H[i]>=maxH){
      count++;
      maxH=H[i]; 
  }
  }
  
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
vector<int> adj[100005];
bool visited[100005];
int in_degree[100005];
int dist[100005];
void dfs(int s){
	visited[s] = true;
	for(int u:adj[s]){
		dist[u] = max(dist[u],dist[s]+1);
		--in_degree[u];
		if(in_degree[u] == 0){
			dfs(u);
		}
	}
}
int main(){
	int n,m,v,u,ans = 0;
	cin>>n>>m;
	fr(i,m){
		cin>>u>>v;
		adj[u].pb(v);
		in_degree[v]++;
}
	fri(i,1,n){
		  if(!visited[i] && in_degree[i] == 0){
		  	dfs(i);
		  }
	}
	fri(i,1,n){
		ans = max(ans,dist[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 9728
#include<iostream>

using namespace std;

int main()
{
  int N,M,ans,i,N3,N2,N1,t,judge;
  cin>>N>>M;
  int s[M],c[M];
  
  for(i=0;i<M;i++)
  {
    cin>>s[i]>>c[i];
  }
  for(ans=0;ans<1000;ans++)
  {
    //桁数を出す
    if(N==3)//3桁
    {
      N1=ans/100;
      t=ans/10;
      N2=t%10;
      N3=ans%10;
      if(N1==0)
      {
        judge=-1;
      }
    }
    else if(N==2)//2桁
    {
      N1=ans/10;
      N2=ans%10;
      N3=0;
      if(N1==0)
      {
        judge=-1;
      }
    }
    else if(N==1)//1桁
    {
      N1=ans;
      N2=0;
      N3=0;
    }
    //M回判定
    for(i=0;i<M;i++)
    {     
      switch(s[i])
      {
        case 1:
          if(c[i]==N1)
          {
            judge++; 
            //cout<<"1";          
          }
          break;
        case 2:
          if(c[i]==N2)
          {
            judge++;
            //cout<<"2";
          }
          break;
        case 3:
          if(c[i]==N3)
          {
            judge++;
            //cout<<"3";
          }
          break;
      }
    }//Mの判定終わり
    
    /*if(judge>0)
    {
      cout<<judge<<" "<<ans<<""<<" "<<N1<<" "<<N2<<" "<<N3<<"\n";
    }*/
    if(judge==M)
    {
      cout<<ans;
      goto end;
    }
    judge=0;
  }//ansのLoop終わり
  cout<<"-1";  
  end:
  ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cctype>
using namespace std;
typedef long long LL;
LL i,j,k,n,m;
LL mod=1000000007;
string s;

int main() {
  cin >> s;
  int x=stoi(s.c_str());
  int ia = x/100;
  int ib = x%100;
  if(ia <=12 && ia >0) {
    if(ib <=12 && ib >0){
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    if(ib <=12 && ib >0) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
const int INF = 1e9;

int main() {
    int h, w; cin >> h >> w;
    vector<string> field(h);
    rep(i,h) cin >> field[i];

    vvl dists(h*w, vl(h*w, INF));
    rep(i,h*w) dists[i][i] = 0;
    rng(i,1,h) {
        if (field[i][0] == '#') continue;
        if (field[i-1][0] == '.') {
            dists[i*w][(i-1)*w] = 1;
            dists[(i-1)*w][i*w] = 1;
        }
    }
    rng(j,1,w) {
        if (field[0][j] == '#') continue;
        if (field[0][j-1] == '.') {
            dists[j][j-1] = 1;
            dists[j-1][j] = 1;
        }
    }
    rng(i,1,h) {
        rng(j,1,w) {
            if (field[i][j] == '#') continue;
            if (field[i][j-1] == '.') {
                dists[i*w+j][i*w+j-1] = 1;
                dists[i*w+j-1][i*w+j] = 1;
            }
            if (field[i-1][j] == '.') {
                dists[i*w+j][(i-1)*w+j] = 1;
                dists[(i-1)*w+j][i*w+j] = 1;
            }
        }
    }
    rep(k,h*w) rep(i,h*w) rep(j,h*w) {
        dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j]);
    }
    int mx = 0;
    rep(i,h*w) rep(j,h*w) {
        if (dists[i][j] == INF) continue;
        mx = max(ll(mx), dists[i][j]);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int n, sum;
int aaa(int t)
{
    if(t == 0) 
		return 0;
    return 
		t%10 + aaa(t / 10);
}
int main() {
    cin >> n;
    sum = aaa(n);
    if(n % sum) 
		cout << "No" << endl;
    else 
		cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;


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

	int cnt = 0;
	int x = n;
	do {
		x = x / k;
		cnt++;
	}while(x != 0);

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    LL n;
    LL x;
    cin >> n >> x;
    vector<LL> a(n);
    vector<LL> a_sum(n-1);
    LL ans=0;

    for(LL i=0; i<n; i++){
        cin >> a[i];
    }

    for(LL i=0; i<n; i++){
        if(a[i]>x){
            ans+=a[i]-x;
            a[i]=x;
        }
    }

    for(LL i=0; i<n-1; i++){
        a_sum[i]=a[i]+a[i+1];
    }

    for(LL i=0; i<n-1; i++){
        LL tmp;
        if(a_sum[i]>x && a_sum[i+1]>x){
            tmp=min(a_sum[i]-x, a_sum[i+1]-x);
            ans+=tmp;
            a_sum[i]-=tmp;
            a_sum[i+1]-=tmp;
        }
    }

    for(LL i=0; i<n-1; i++){
        if(a_sum[i]>x){
            ans+=a_sum[i]-x;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int dig_sum(int a)
{
    int sum=0;
    while(a)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}
int cheak_zero(int a)
{
    int count=0;
    while(a)
    {
        int b=a%10;
        a=a/10;
        if(b!=0)
            break;
        else
            count++;
    }
    return count;
}
void sort(int numbers[], int count)
{
    for(int i = 0; i < count - 1; i++)
    {
        int currentMin = numbers[i];
        int currentMinIndex = i;

        for(int j = i + 1; j < count; j++)
        {
            if(currentMin > numbers[j])
            {
                currentMin = numbers[j];
                currentMinIndex = j;
            }
        }

        if(currentMinIndex != i)
        {
            numbers[currentMinIndex] = numbers[i];
            numbers[i] = currentMin;

        }
    }
}


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

bool cheak1(char fi[],char se[],int n,int m,int x)
{
    for(int i=0;i<x;i++)
    {
        if(fi[i]!=se[i])
        {
            return false;
        }
        se[i]='.';
    }
    for(int i=n-1,j=m-1;i>x;i--,j--)
    {
        if(fi[i]!=se[j])
        {
            return false;
        }
    }
    return true;
}
int faw()
{

    int n,m;
    cin>>n>>m;
    char fi[n];
    char se[m];
    cin>>fi;
    cin>>se;
    int x;
    for(int i=0;i<n;i++)
    {
        if(fi[i]=='*')
        {
            x=i;
            break;
        }
    }
    /*if(x==0)
    {
        if(strcmp(fi,se)==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        else
            cout<<"NO"<<endl;
        return 0;
    }*/
    if(cheak1(fi,se,n,m,x)==true)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}

int many(int n)
{
    int count=0;
    for(int i=1;i<=n;i++)
    {
        if(n%i==0)
            count++;
    }
    return count;
}

int main()
{
    int a;
    cin>>a;
    int count=0;
    int ar[a];
    for(int i=1;i<=a;i+=2)
    {
        ar[i-1]=many(i);
        if(many(i)==8)
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}



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

int main()
{
  int n, k;
  cin >> n >> k;
  
  vector<long long> h(n);
  
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  
  sort(h.begin(), h.end());
  
  long long ans = 0;
  for(int i = 0; i < n - k; i++){
    ans += h.at(i);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int partition(int a[], int p, int r)
{
	int x, i, j, temp;

	x = a[r];
	i = p - 1;

	for (j = p; j < r ;j++) {
		if (a[j] <= x) {
			i++;
			temp = a[j];
			a[j] = a[i];
			a[i] = temp;
		}
	}
	temp = a[i + 1];
	a[i + 1] = a[r];
	a[r] = temp;

	return i + 1;
}


int main(void) {
	int n, r;
	int number[1000001];
	int i;

	scanf("%d", &n);

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

	r = partition(number, 0, n - 1);

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

	return 0;
}


Measured memory_bytes: 2076
v,e=map(int,input().split())
if e==0:print(0);exit()
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
edges=sorted([list(map(int,input().split())) for i in range(e)],key=lambda x:x[-1])
uf=UnionFind(v)
n,m,su=edges[0]
uf.unite(n,m)
for a,s,d in edges:
    if uf.same(a,s):continue
    uf.unite(a,s);su+=d
    if uf.size(n)==v:print(su);exit()


Measured memory_bytes: 28984
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi(x)  vector<int>vec(x)
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i<(b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 #define PI 3.14159265358979323846264338327950L
 const int N=1e5 +5;
 using namespace std;
 int32_t main()
 {
 ll a,b;
 cin>>a>>b;
 cout<<a*b;
 }

Measured memory_bytes: 3592
#include <stdio.h>
int main(void)
{
	int i, x;
	i = 1;

	scanf("%d", &x);
	if (x != 0)
	{
		printf("Case 1: %d\n", x);
	}
	
	while(x != 0)
	{
		scanf("%d", &x);
		if ((1 <= x) && (x <= 10000))
		{
			i = i + 1;
			printf("Case %d: %d\n", i, x);
		}
		else break;
	}
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target ("avx2,tune=native")
#include<bits/stdc++.h>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv1(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
template<typename a, typename b>
void minq(a& x, b y) {
	if (x > y)
		x = y;
}
template<typename a, typename b>
void maxq(a& x, b y) {
	if (x < y)
		x = y;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
//WHEN DOING MODULAR SUBTRACTION ALWAYS **ALWAYS** ADD MOD
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	doin();
	int n, cnt[20];
	memset(cnt, 0, sizeof cnt);
	vi a;
	cin >> n;
	getv(a, n);
	int i, j;
	i = j = 0;
	ll ans = 0;
	ll msk = (1<<20)-1;
	while(i < n) {
		while((msk&a[i]) != a[i]) {
			msk ^= a[j];
			j++;
		}
		msk ^= a[i];
		ans += (i-j+1);
		i++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
a = [int(i) for i in input().split()]
print(' '.join(map(str, a)))
for i in range(1, N):
    v = a[i]
    j = i - 1
    while j >= 0:
        if a[j] > v:
            a[j + 1], a[j] = a[j], a[j - 1]
            j -= 1
        else:
            break
    a[j + 1] = v
    print(' '.join(map(str, a)))



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int n1, n2, n4;
int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int cur;
        cin >> cur;
        if(cur % 4 == 0) {
            n4++;
        } else if(cur % 2 == 0) {
            n2++;
        } else {
            n1++;
        }
    }
    if(n2) {
        n -= n2 - 1;
    }
    bool ok = true;
    if(n & 1) {
        if(n4 * 2 + 1 < n) {
            ok = false;
        }
    } else {
        if(n4 * 2 < n) {
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    string S;
    ll K;
    cin>>K;
    cin>>S;
    if(S.size()<=K)cout<<S<<endl;
    else{
        rep(i,K){
            cout<<S.at(i);
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') count++;
		else count = 0;
		ans = max(ans, count);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 1e6 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n; cin >> n;
    vi a(n), cnt(N, 0);

    for(int& i : a) cin >> i, cnt[i]++;

    ll ans = 0;
    for(int& i : a)
    {
        int now = 0;
        for(int d = 1; d * d <= i; d++)
        {
            if(i % d == 0)
            {
                now += cnt[d];
                if(i / d != d) now += cnt[i / d];
            }
        }
        if(now == 1) ans++;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 7924
#import heapq
import itertools
#import math
#import numpy as np
import sys

N = int(input())
D = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()
P = list(itertools.combinations(list(range(N)),2))
ans = 0
for p in P :
    #print(p)
    a = D[p[0]] * D[p[1]]
    ans += a
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author david yepes buitrago
 * @date 02-08-2017
 * @time 0.000 ms
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader tec = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = tec.readLine()) != null;) {
			StringTokenizer st = new StringTokenizer(line);
			int n = Integer.parseInt(st.nextToken());
			int m = Integer.parseInt(st.nextToken());
			int[] arr = new int[n];
			Arrays.fill(arr, 1);
			int cont = 1;
			boolean[] pos = new boolean[n];
			pos[0] = true;
			for (int i = 0; i < m; i++) {
				st = new StringTokenizer(tec.readLine());
				int a = Integer.parseInt(st.nextToken()) - 1;
				int b = Integer.parseInt(st.nextToken()) - 1;
				arr[a]--;
				arr[b]++;
				if (pos[a]) {
					if (!pos[b])
						cont++;
					pos[b] = true;
				}
				if (arr[a] == 0) {
					if (pos[a])
						cont--;
					pos[a] = false;
				}
			}
			out.println(cont);
		}
		out.close();
	}
}


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

int main() {
  int k,s;
  cin>>k>>s;

  int count=0;
  
  for(int x=0;x<=k;x++){
    for(int y=0;y<=k;y++){
      if(s-x-y>=0 && s-x-y<=k){
        count++;
      }
    }
  }
  
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    switch (s) {
    case "A":
      System.out.println("T");
      break;
    case "T":
      System.out.println("A");
      break;
    case "G":
      System.out.println("C");
      break;
    case "C":
      System.out.println("G");
      break;
    }
  }
}

Measured memory_bytes: 21712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF (1<<28)

int n, p[100], t[100], dp[100][4];

void solve() {
    rep(i, 100) rep(j, 4) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n-1) rep(j, 4) {
        const int dt = t[i+1]-t[i];
        if((j+1)*p[i]+p[i+1]<=dt) {
            dp[i+1][1] = min(dp[i+1][1], dp[i][j]+p[i]+p[i+1]);
        }
        if(j<3 && (j+1)*abs(p[i]-p[i+1])<=dt) {
            dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j]+abs(p[i]-p[i+1]));
        }
    }
    rep(i, n) {
        bool ok = false;
        rep(j, 4) if(dp[i][j]<INF) ok = true;
        if(!ok) {
            printf("NG %d\n", i);
            return ;
        }
    }
    int ans = INF;
    rep(j, 4) ans = min(ans, dp[n-1][j]+p[n-1]);
    printf("OK %d\n", ans);
}

int main() {
    for(;;) {
        scanf("%d", &n);
        if(n==0) return 0;
        p[0] = t[0] = 0;
        rep(i, n) scanf("%d%d", p+i+1, t+i+1);
        n++;
        solve();
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(i64, n, k);
  outl(n % k == 0 ? 0 : 1);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Roc ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define NMAX 100010
using namespace std;

int n,m,x,y, sol;
vector <int> v[NMAX];
bool viz[NMAX];
int pd[NMAX];

int DFS(int nod)
{
    int ans = 0;
    if(!v[nod].size() )
        return 0;
    if(pd[nod] != -1)
        return pd[nod];
    viz[nod] = 1;
    for(int i = 0 ; i < v[nod].size(); ++i)
        {
            ans = max(ans,  DFS(v[nod][i]) + 1);
        }
    pd[nod] = ans;
    return pd[nod];
}

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
    }
    for(int i = 1; i <= n; ++i)
        pd[i] = -1;

    for(int i = 1; i <= n; ++i)
        if(pd[i] == -1)
            DFS(i);

    for(int i = 1; i <= n; ++i)
        sol = max(sol, pd[i]);
    cout << sol;
    return 0;
}


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

const int com = 1000000007;

int power(long long a, long long b) {
	int c = 1;
	while (b) {
		if (b & 1) c = c * a % com;
		a = a * a % com;
		b >>= 1;
	}
	return c;
}

int nCr(int a, int b) {
	long long x = 1, y = 1;
	for (int i = 0; i < b; i++) {
		x = x * (a - i) % com;
		y = y * (i + 1) % com;
	}
	return x * power(y, com - 2) % com;
}

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

	int ans = power(2, n) - 1 - nCr(n , a) - nCr(n , b);

	cout << (ans % com + com) % com;
	return 0;
}

Measured memory_bytes: 3628
s=input()
ans=0
res=0
w=0
l=0
for i in range(len(s)):
    if res==0:
        res+=1
        if s[i]=='p':
            l+=1
    else:
        if s[i]=='p':
            res-=1
        else:
            res-=1
            w+=1
print(w-l)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, L;
  std::cin >> N >> L;
  std::vector<ll> va(N, 0LL);

  for (ll i = 0; i < N; i++) {
    va[i] = L + i;
  }

  const ll sum = std::accumulate(va.begin(), va.end(), 0LL);
  ll min_value = 1e18;
  ll ans = sum;
  for (auto a : va) {
    if (min_value > std::fabs(a)) {
      min_value = std::fabs(a);
      ans = sum - a;
    }
  }

  print(ans);
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s == "Rainy") {
    cout << "Sunny" << "\n";
  }
  else if (s == "Sunny") {
    cout << "Cloudy" << "\n";
  }
  else {
    cout << "Rainy" << "\n";
  }
  return 0;
}

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

typedef long long ll;
const int mod = 1e9 + 7;
int n;

void add_self(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int mul(int a, int b) {
    return (ll)a * b % mod;
}

struct M {
    vector<vector<int>> a;
    M() {
        a.resize(n, vector<int>(n));
    }

    M operator*(const M &b) {
        M res;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    add_self(res.a[i][j], mul(a[i][k], b.a[k][j]));
                }
            }
        }

        return res;
    }
};

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll k;

    cin >> n >> k;
    
    M a;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            cin >> a.a[i][j];
    }

    M ans;
    for (int i = 0; i < n; ++i)
        ans.a[i][i] = 1;

    while (k) {
        if (k & 1) ans = ans * a;
        a = a * a;
        k >>= 1;
    }

    int total = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) 
            add_self(total, ans.a[i][j]);
    }

    cout << total << endl;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

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

    cout << (a == b ? 2 * a : max(a, b) + max(a, b) - 1) << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    ll X;
    cin >> X;
    ll ans = 0;
    for (int i = 1; i < 1000;i++)
    {
        for (int j = 2; j <= 1000;j++)
        {
            ll pre = pow(i, j);
 
            if (pre <= X)
            {
                ans = max(ans, pre);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4308
#include<stdio.h>
int main()
{
    int K,i;
    scanf("%d",&K);
    char S[100000],l[10000];
    scanf("%s",&S);
    int length;
    length=strlen(S);

    if(length>K)
    {

        for(i=0; i<K; i++)
        {

            l[i]=S[i];
        }
          printf("%s...",l);


    }

    else
    {
         for(i=0; i<K; i++)
        {

            l[i]=S[i];

        }
        printf("%s",l);

    }


    return 0;
}


Measured memory_bytes: 1688
#include <iostream>
#include <stdlib.h>
 
using namespace std;
 
class node{
public:
    int key;
    node *parent;
    node *right;
    node *left;
    node(){
        this->key = 0;
        this->parent = NULL;
        this->right = NULL;
        this->left = NULL;
    }
};

void maxHeapModiyfy(int i,int n,node H[]){

  int left = ((i)*2)+1;
  int right = (((i)*2)+1)+1;
  int large = 0;
  node temp;

  //cout << "left:" << left << " right:" << right << endl;

  if(left < n && H[left].key > H[i].key){
    large = left;
  }
  else {
    large = i;
  }

  if(right < n && H[right].key > H[large].key){
    large = right;
  }

  if(large != i){
    temp = H[i];
    H[i] = H[large];
    H[large] = temp;
    maxHeapModiyfy(large,n,H);
  }
}

void buildMaxHeap(int n,node H[]){

  int i;

  for(i = (n/2)-1;i >= 0;i--){
    maxHeapModiyfy(i,n,H);
  }
}

void printKey(int n,node H[]){

  int i;

  for(i = 0;i < n;i++){
    cout << ' ' << H[i].key;
  }
  cout << endl;
}

void print(int n,node H[]){
 
    int i;
 
    for(i = 0;i < n;i++){
        cout << "node " << i+1 << ": ";
        cout << "key = " << H[i].key << ", ";
        if(H[i].parent != NULL){
            cout << "parent key = " << H[i].parent->key << ", ";
        }
        if(H[i].left != NULL){
            cout << "left key = " << H[i].left->key << ", ";
        }
        if(H[i].right != NULL){
            cout << "right key = " << H[i].right->key << ", ";
        }
        cout << endl;
    }
}
 
int main(){
 
    int i;
    int n;
    node* H;
 
    cin >> n;
 
    H = new node[n];
 
    for(i = 0;i < n;i++){
        cin >> H[i].key;
        if(i != 0){
            H[i].parent = &H[((i+1)/2)-1];
        }
        if((i+1)*2 <= n){
            H[i].left = &H[((i+1)*2)-1];
        }
        if((i+1)*2+1 <= n){
            H[i].right = &H[(((i+1)*2)+1)-1];
        }
    }
 
    buildMaxHeap(n,H);

    printKey(n,H);
 
    delete[] H;
 
    return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a , b , c ;
    cin >> a >> b >> c ;
    (b - a == c - b ? YES : NO) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

/*
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/



//************** StrAnge.R *********************

#define ll              long long int
#define ull             unsigned long long
#define lll             __int128
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pii             pair<int,int>
#define piii            pair<int,pair<int,int> >
#define pll             pair<ll,ll>
#define vii             vector<pii>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)
#define intmx           INT_MAX

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)

template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}


//******************* my code starts here **********************************


int main(){

    ll a, b = 0; 
    string s;
    cin >> a >> s;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] != '.') b = ((b*10) + (s[i]-48));
    }
    a *= b;
    a /= 100;
    cout << a << "\n";

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;
 
#define mod 1000000007
long long modexpo(long long x, long long p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

int32_t main(){
    IOS
    string s,t;
    cin >> s >> t;

    int n = s.length();
    int m = t.length();
    int res = 1e18;
    for(int i = 0; i+m-1 < n; i++){
        int j = 0, flag = 0;
        for(j = 0; j < m; j++){
            if(s[i+j] != t[j]){
                flag++;
            }
        }
        res = min(res, flag);
    }
    cout << res << endl;
} 

Measured memory_bytes: 3632
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
S = list(sys.stdin.readline())

res = 0
for i in range(N - 1):
    s1 = set(S[:i + 1])
    s2 = set(S[i + 1:])
    res = max(res, len(s1 & s2))

print(res)

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin >>n;
 int a[n],b[n];
 for(int i=0;i<n;i++)
 {
     cin >>a[i];
 }
 int M,c=0;
 M=a[0];
 for(int i=1;i<n;i++)
 {
     if(M>=a[i]){c++;M=a[i];}
 }
 cout <<c+1<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 1e5 + 1;
const ll inf = 1e8;
typedef pair<ll,ll> LL;
LL a[3*N];
ll u,v,n,q,i,dp[1024][N];
ll gen(ll x,ll y){
    if (x < 1024) return dp[x][y];
    ll ans = gen(x/2,y);
    if (a[x].sc <= y) ans = max(ans,a[x].fs + gen(x/2,y - a[x].sc));
    return ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>n;
    for (i = 1;i <= n;i++) cin>>a[i].fs>>a[i].sc;
    for (i = 1;i < 1024;i++){
        for (ll j = 1;j < N;j++){
            dp[i][j] = dp[i/2][j];
            if (j >= a[i].sc) dp[i][j] = max(dp[i][j],a[i].fs + dp[i/2][j - a[i].sc]);
        }
    }
    cin>>q;
    while(q--){
        cin>>u>>v;
        cout<<gen(u,v); cout<<"\n";
    }
}


Measured memory_bytes: 806964