akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef list<int> li;
typedef list<li> lli;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x;
	ll cost;
};

int main(){

	int n,x,t;
	cin>>n>>x>>t;

	if(n%x>0)cout<<n/x*t+t<<endl;
	else cout<<n/x*t<<endl;

	return 0;
}


Measured memory_bytes: 3628
n = int(input())
s = []

for i in range(n):
    s.append(list(input()))

x = 0    

for i in range(n):
    for j in range(1,len(s[i])):
        if s[i][j-1]=="A" and s[i][j]=="B":
            x += 1

p = 0
q = 0
r = 0
for i in range(n):
    if s[i][0]=="B" and s[i][-1]!= "A":
        p += 1
    if s[i][0]!="B" and s[i][-1]=="A":
        q += 1
    if s[i][0]== "B" and s[i][-1]=="A":
        r +=1


if p==0 and q==0 and r!=0:
    print(x+r-1)
else:
    print(x+r+min(p,q))


Measured memory_bytes: 4596
var k,s,a:int64;
begin
read(k,s);
a:= (s+1)*(s+2) div 2;
if(s>=k+1)then a := a - (3*(s-k)*(s-k+1)) div 2;
if(s>=2*k+2)then a := a + (3*(s-2*k)*(s-2*k-1)) div 2;
writeln(a);
end.

Measured memory_bytes: 1388
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
as = Array.new(n + 1)
bs = Array.new(m + 1)
as[0] = bs[0] = 0
1.upto(n){|i| as[i] = as[i - 1] + a[i - 1]}
1.upto(m){|j| bs[j] = bs[j - 1] + b[j - 1]}
i = as.find_index{|v| v > k}
if i == nil
	i = n
else
	i -= 1
end
ans = 0
j = 0
while i >= 0
	while j <= m && as[i] + bs[j] <= k
		j += 1
	end
	j -= 1
	ans = i + j if ans < i + j
	break if j >= m
	i -= 1
end
puts ans

Measured memory_bytes: 44724
lst = [int(input())]
i = 0
while True:
    if lst[i]%2 == 0:
        num = lst[i]/2
    else:
        num = lst[i]*3+1
    
    if num in lst:
        print(i+2)
        break
    else:
        lst.append(num)
        i += 1

Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <ctime>
#include <set>
#include <sstream>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int i,a[5];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+1+3);
	printf("%d\n",a[1]+a[2]);
    return 0;
}



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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int A,B;
    cin >> A >> B;
    if(B==1){
        P(0);
    }
    else if(B<=A){
        P(1);
    }else{
        int i=1;
        while(B>(A+(A-1)*i)){
            i++;
        }
        P(1+i);
    }
}

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

long long dp[1000000];

int main()
{
    int n, w;
    cin >> n >> w;
    for (int i = 0; i != n; ++i)
    {
        int x, y;
        cin >> x >> y;
        
        for (int j = w; j >= x; --j)
            dp[j] = max(dp[j], dp[j - x] + y);
    }
    
    long long ans = 0;
    for (int i = 0; i <= w; ++i) ans = max(ans, dp[i]);
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const int mod=1000000007;
#define ll long long
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
int _,a,b,n,k,m;
int main() {
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        int count=0;
   		string s,s1;
   		cin>>s>>s1;
   		
   		rep(i,0,s.length()){
   			if(s[i]!=s1[i]){
   				count++;
   			}
   		}
   		cout<<count<<endl;
    }

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

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

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

  vector<vector<int>> g(2010);

  rep(i, n)
  {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }

  g[x].push_back(y);
  g[y].push_back(x);

  vector<int> ans(n);

  rep(sv, n)
  {
    vector<int> dist(n, 10000);
    queue<int> q;

    dist[sv] = 0;
    q.push(sv);

    while (!q.empty())
    {
      int v = q.front();
      q.pop();
      for (auto next_v : g[v])
      {
        if (dist[next_v] == INF)
        {
          dist[next_v] = dist[v] + 1;
          q.push(next_v);
        }
      }
    }

    rep(i, n) ans[dist[i]]++;
  }

  repi(i, 1, n)
  {
    cout << ans[i] / 2 << endl;
  }
  return 0;
}

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

    using namespace std;
    using ll = long long;
    using ull = unsigned long long;
    using pii = pair<int, int>;
    using pll = pair<ll, ll>;



    const int INF = 0x3f3f3f3f;
    const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
    const int NMAX = 1e7 + 5;
    const int MOD = 1e9 + 7;
    #define endl "\n"

    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        map<string,int> verdicts;
        int n;
        cin>>n;
        char verdict[5];
        while(n--){
            cin>>verdict;
            if(verdicts.count(verdict))
                 verdicts[verdict]++;
            else verdicts[verdict] = 1;
        }
        cout<<"AC x "<<verdicts["AC"]<<endl; 
        cout<<"WA x "<<verdicts["WA"]<<endl; 
        cout<<"TLE x "<<verdicts["TLE"]<<endl; 
        cout<<"RE x "<<verdicts["RE"]<<endl; 
        return 0;
    }


Measured memory_bytes: 3668
#pragma GCC optimize("O3") 
#include<bits/stdc++.h>
#define ll      				long long int
#define vi      				vector<int>
#define ii      				pair<int,int>
#define iii     				pair<ii,int>
#define iiii    				pair<ii,ii>
#define fi      				first
#define se      				second
#define unord_map				unordered_map
#define nxt_pmt					next_permutation
#define clr					clear()
#define ALL(x) 					x.begin(),x.end()


#define pb      				push_back
#define pob     				pop_back

#define all(x)  				x.begin(), x.end()
#define len     				length()

#define db(x)					  cout << "!!!!!! " << #x << " => " << x << "\n"

#define fori(i, s, N)     for (int i = s; i <= N; i++)
#define ford(i, s, N)     for (int i = s; i >= N; i--)
using namespace std;

void init(int precision){
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

int t;
void cjam(int z){
	cout<<"Case #"<<z<<": ";
	
}

int main(){
//	init(10);
	cin>>t;
	if(t >= 30) cout<<"Yes\n";
	else cout<<"No\n";
//	for(int z = 1;z<=t;z++){
//		cjam(z);
//		
//	}
	return 0;
}

Measured memory_bytes: 3540
#include <cstdio>
 
int main(){
	int n,m,k;
	bool flag=false;
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			if((i*m+j*n-2*i*j)==k) flag=true;
	if(flag) printf("Yes");
	else printf("No");
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1000000007
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, p;
    cin >> n >> p;
    int even = 0;
    rep(i, n){
        int tmp; cin >> tmp;
        if(!(tmp%2)) even++;
    }

    if(even == n){
        if(!p) ppp(powMod(2, n, LLONG_MAX));
        else ppp(0);
    }
    else{
        ppp(powMod(2, n-1, LLONG_MAX));
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int m = 0;
  int x = 0;
  rep(i, S.size())
  {
    if (S.at(i) == 'I') {
      x++;
    } else {
      x--;
    }
    if (m < x)
      m = x;
  }
  cout << m << endl;
}

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

ll INF = 1LL << 60;
using G = vector<map<int, int>>;

void
dfs(int node, ll count, G &arr, vector<bool> seen, vector<long> &to_K)
{
  seen[node] = true;
  for(auto child: arr[node]){
    if(seen[child.first]) continue;
    to_K[child.first] = count + child.second;
    dfs(child.first, count + child.second, arr, seen, to_K);
  }
}

int 
main() {
  int N; cin >> N;
  G arr(N + 1);
  rep(i, 0, N - 1){
    int a, b, c; cin >> a >> b >> c;
    arr[a][b] = c;
    arr[b][a] = c;
  }
  vector<long> to_K(N + 1);

  int Q, K; cin >> Q >> K;
  vector<pair<int, int>> q(Q);
  rep(i, 0, Q){
    cin >> q[i].first;
    cin >> q[i].second;
  }

  vector<bool> seen(N + 1, false);
  //dfs(K, 0, arr, seen, to_K);

  queue<int> que;
  que.push(K);
  seen[K] = true;
  to_K[K] = 0;
  while(!que.empty()){
    int node = que.front();
    que.pop();
    for(auto child : arr[node]){
      if(seen[child.first]) continue;
      to_K[child.first] = arr[node][child.first] + to_K[node];
      seen[child.first] = true;
      que.push(child.first);
    }
  }


  rep(i, 0, Q){
    cout << to_K[q[i].first] + to_K[q[i].second] << endl;
  }

}

Measured memory_bytes: 19336
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int n,m;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s.at(i);
  }
  cin >> m;
  vector<string> t(m);
  rep(i,m){
    cin >> t.at(i);
  }
  map<string, int> time;
  for(string x: s){
    if(time.count(x)){
      time.at(x)++;
    }
    else{
      time[x]=1;
    }
  }
  for(string x:t){
    if(time.count(x)){
      time.at(x)--;
    }
    else{
      time[x]=-1;
    }
  }
  int mx=0;
  for(string x:s){
    mx= max(mx,time.at(x));
  }
   cout << mx << endl;     
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    x,y,z = MII()
    print((x-z)//(y+z))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <algorithm>
#include <cstring>
#include<queue>
#include <stack>
#include<map>
#include<vector>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define ll long long
#define inf 999999999

int main(){
    ll n;
    ll r;
    cin>>n>>r;
    ll x;
    if(n>=10){
        cout<<r<<endl;
    }else{
        x=r+100*(10-n);
        cout<<x<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector <string> VS;
typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <double> VD;
template <class T> T gcd( T a, T b ) { return !b ? a : gcd( b, a % b ); }
template <class T> T lcm( T a, T b ){ return a / gcd( a, b ) * b; }
template <class T> string print_v( vector<T> v ) { OSS oss; for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++ it_i ) { oss << *it_i << ", "; } return oss.str(); }

int main() {
    VD list;
    double height;
    while ( cin >> height ) list.push_back( height );
    cout << *max_element( list.begin(), list.end() ) - *min_element( list.begin(), list.end() ) << endl;
    return 0;
}

Measured memory_bytes: 0
import bisect
ai = [[] for i in range(26)]
s = list(input())
t = list(input())
n = len(s)
for i in range(n):
    ai[int(ord(s[i])-97)].append(i)
n2 = len(t)
count = 0
if len(ai[int(ord(t[0]))-97]) > 0:
    now = ai[int(ord(t[0]))-97][0]
    for i in range(1,n2):
        nex = int(ord(t[i]))-97
        n3 = len(ai[nex])
        if n3 == 0:
            count = 0
            now = -2
            break
        else:
            ni = bisect.bisect_right(ai[nex],now)
            #print(ni,count,now)
            if ni == n3:
                ni = 0
            if ai[nex][ni] > now:
                now = ai[nex][ni]
            else:
                count += 1
                now = ai[nex][ni]
    print(count*n+now+1)
else:
    print(-1)

Measured memory_bytes: 9056
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int K = int.Parse(Console.ReadLine());
    int[] ball = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int sum=0;
    for(int i=0;i<ball.Length;i++)
    {
      if(K<=2*ball[i])sum+=((K-ball[i])*2);
      else sum+=(ball[i]*2);
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13268
import java.util.*;

class Main
{

    //------------stack-------------
    static int[] stack = new int[100];
    static int head=0;

    static void en(int n)
    {
	stack[head]=n;
	head++;
    }

    static int de()
    {
	head--;
	int i=stack[head];
	return i;
    }

    //-----------Main---------------
    public static void main(String args[])
    {
	Scanner sc = new Scanner(System.in);
	String s;
	int x, y;
	int i, j, k;

	i=0;
	while(sc.hasNext())
	    {
		//Read number
		if(sc.hasNextInt()==true)
		    {
			en(sc.nextInt());
		    }
		//Read operand
		else
		    {
			s=sc.next();
			//+
			if(s.equals("+")==true)
			    {
				x=de();
				y=de();
				en(y+x);
			    }
		
			//-
			else if(s.equals("-")==true)
			    {
				x=de();
				y=de();
				en(y-x);
			    }
			//*
			else if(s.equals("*")==true)
			    {				
				x=de();
				y=de();
				en(y*x);
			    }
			//else if(s.equals(null)==true)break;
		    }
	    }
    
    
	//print
	System.out.println(stack[0]);
	sc.close();
    
    }

}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

int h, w;
vvi field(500, vi(500)), A(500, vi(500)), B(500, vi(500));

void solve() {
	Loop(i, h) {
		A[i][0] = 1;
		B[i][w - 1] = 1;
		Loop1(j, w - 2) {
			if (i % 2 == 0) A[i][j] = 1;
			else B[i][j] = 1;
		}
	}
	Loop(i, h) {
		Loop(j, w) {
			if (field[i][j] == 1) {
				A[i][j] = 1;
				B[i][j] = 1;
			}
		}
	}
	Loop(i, h) {
		Loop(j, w) {
			if (A[i][j] == 1) cout << '#';
			else cout << ".";
		}
		cout << endl;
	}
	Loop(i, h) {
		Loop(j, w) {
			if (B[i][j] == 1) cout << '#';
			else cout << ".";
		}
		cout << endl;
	}
}

int main() {
	cin >> h >> w;
	Loop(i, h) {
		Loop(j, w) {
			char c;
			cin >> c;
			if (c == '#') field[i][j] = 1;
		}
	}

	solve();
	return 0;
}

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

int gcd(int x,int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y, x % y);
}

int main(){
    using namespace std;
    int MAX_A = 1000000;
    vector<int> lp(MAX_A + 1,0);//最小の素因数をいれる(2以上をみていけばいい)
    vector<int> pr;//MAX_A以下の素数の集合
    int cnt=0;
    vector<int> count(MAX_A + 1,0);
    for(int i = 2; i <= MAX_A; i++){//線形時間で処理してくれる
        if(lp[i] == 0){
            lp[i] = i;
            pr.push_back(i);
        }
        for(int j = 0; j < pr.size()&& pr[j] <= lp[i]&& i * pr[j] <= MAX_A; j++){
            lp[i * pr[j]] = pr[j];//i * pr[j] == C(const)としてありえるi, jの組は高々一通りになるので、これは線形時間で処理される
        }
    }
    int N;
    cin >> N;
    vector<int> A(N);
    int GCD = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        GCD = gcd(GCD, A[i]);
        while(A[i]>1){
            int div = lp[A[i]];
            count[div]++;
            while(A[i] % div == 0){
                A[i] /= div;
            }
        }
    }
    if(GCD != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    for(int i = 2; i < MAX_A; i++){
        if(count[i] >= 2){
            cout << "setwise coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
}


Measured memory_bytes: 15420
n,m=map(int,input().split())
C=list(map(int,input().split()))
dp=[0]*(n+1)
dp[0]=1

for i in range(m):
    for j in range(n+1):
        if dp[j]!=0:
            if j+C[i]<=n:
                if dp[j+C[i]]==0:
                    dp[j+C[i]]=dp[j]+1
                else:
                    dp[j+C[i]]=min(dp[j]+1,dp[j+C[i]])
    #print(dp)
print(dp[n]-1)


Measured memory_bytes: 7520
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  set<string> gacha;
  int n;  cin >> n;
  REP(i, n){
    string s; cin >> s;
    gacha.insert(s);
  }
  cout << SZ(gacha) << endl;
  return 0;
}


Measured memory_bytes: 19228
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from math import *
import random

def readln():
    return list(map(int,(input().split(" "))))

n = readln()[0]
r = [0 for i in range(0,n)]
b = [0 for i in range(0,n)]

for i in range(0,n):
    r[i] = readln()


for i in range(0,n):
    b[i] = readln()

r = sorted(r)
b = sorted(b)

ans = 0
for blue in b:
    y = -1
    for red in r:
        if red[0] > blue[0]:
            break
        if red[1] < blue[1] and red[1] > y:
            y = red[1]
    if y > -1:
        ans = ans + 1
        for i in range(0,n):
            if r[i][0] < blue[0] and r[i][1] == y:
                r[i][1] = 10000000000
                break

print(ans)


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

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

    int n; cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];

    deque<int> dq;
    for (int i = 0; i < n; i++){
        if (i & 1){
            dq.push_front(arr[i]);
        } else {
            dq.push_back(arr[i]);
        }
    }
    if (n & 1){
        reverse(dq.begin(), dq.end());
    }
    for (int i = 0; i < n; i++){
        cout << dq[i] << " ";
    }
    cout << endl;

}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int N,h[50],ans,mx;
int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>h[i];
		if(h[i]>=mx){ans++;mx=h[i];}
	}
	cout<<ans;
}

Measured memory_bytes: 256
n = STDIN.gets.to_i
v = STDIN.gets.split(/\s+/).map{|x| x.to_i}
c = STDIN.gets.split(/\s+/).map{|x| x.to_i}
total = 0
v.zip(c).each do |v, c|
  total += v - c if v > c
end
puts total



Measured memory_bytes: 1916
/**
**/
#include<bits/stdc++.h>
#define lsb(i) (i&(-i))
#define maxN 200005
using namespace std;
long long n,AIB[maxN],k,pos[maxN];
long long v[maxN],sp[maxN],sol;
pair<long long,int> x[maxN];
inline void Update(int pos)
{
    for(int i=pos;i<=n;i+=lsb(i))
        AIB[i]++;
}
inline int Query(int pos)
{
    int q=0;
    for(int i=pos;i>=1;i-=lsb(i))
        q+=AIB[i];
    return q;
}
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        //scanf("%d",&v[i]);
        cin>>v[i];
        sp[i]=sp[i-1]+v[i];
    }
    for(int i=1;i<=n;i++)
    {
        sp[i]=sp[i]-k*(1LL*i);
    }
    for(int i=1;i<=n;i++)
    {
        x[i]={sp[i],i};
        if(sp[i]>=0) sol+=1LL;
    }
    sort(x+1,x+n+1);
    for(int i=1;i<=n;i++)
    {
        if(i==1 || x[i-1].first!=x[i].first) pos[x[i].second]=i;
            else pos[x[i].second]=pos[x[i-1].second];
    }
    for(int i=1;i<=n;i++)
    {
        int y=Query(pos[i]);
        sol=sol+1LL*y;
        Update(pos[i]);
    }
    cout<<sol<<'\n';
    return 0;
}


Measured memory_bytes: 9600
def examA():
    S = SI()
    ans = S[:3]
    print(ans)
    return

def examB():
    A, V = LI()
    B, W = LI()
    T = I()
    L = abs(A-B)
    v = V-W
    if v*T>=L:
        ans = "YES"
    else:
        ans = "NO"
    print(ans)
    return

def examC():
    N, K = LI()
    A = LI()
    for _ in range(min(60,K)):
        cur = N
        L = [0] * (N + 1)
        R = [0] * (N + 1)
        for i in range(N):
            a = A[i]
            if 0<i-a:
                L[i-a] += 1
            else:
                L[0] += 1
            if N>i+a+1:
                R[i+a+1] += 1
            else:
                R[N] += 1
            if cur>a:
                cur = a
        if cur==N:
            break
        A[0] = L[0]
        for i in range(1,N):
            A[i] = A[i-1]+L[i]-R[i]


    print(" ".join(map(str,A)))
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 175564
K,N = map(int,input().split())
A = list(map(int,input().split()))
# print(K,N)
# print(A)
B = [A[0]+K-A[-1]]
for i in range(N-1):
    B.append(A[i+1]-A[i])
# print(B)
print(K-max(B))

Measured memory_bytes: 26444
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    int n;
    char s[200005];
    scanf("%d", &n);
    scanf("%s", s);
    int slen = strlen(s);
    int ans1 = 0, ans2 = 0, ans3 = 99999999;
    int a[200005][2] = {0}, tmp = 0;
    for(int i = 0; i < slen; ++i)
    {
        if(s[i] != '.')
        {
            ans2++;
            a[i][0] = tmp;
        }
        if(s[i] != '#')
        {
            ans1++;
            tmp++;
            a[i][0] = tmp;
        }
    }
    tmp = 0;
    for(int i = slen - 1; i >= 0; --i)
    {
        if(s[i] == '#')
        {
            tmp++;
            a[i][1] = tmp;
        }
        else
            a[i][1] = tmp;
    }
    for(int i = 0; i < slen; ++i)
    {
        ans3 = min(ans3, i+1 - a[i][0] + slen - i - 1 - a[i][1]);
    }
    printf("%d\n", min(ans1, min(ans2, ans3)));
    return 0;
}


Measured memory_bytes: 2048
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<cassert>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define debug(x) cerr << #x << ": " << x << endl
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

class UnionFind {
    public:
    int n;
    vector<int> par, rank;

    UnionFind(int n) {
        rep(n) {
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int find(int x) {
        return ((par[x] == x) ? x : par[x] = find(par[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        return;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> p(n);
    rep(n){
        cin >> p[i];
        p[i]--;
    }

    UnionFind uf = UnionFind(n);
    int x,y;
    rep(m){
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    map<int, set<int> > mp;
    rep(n){
        mp[uf.find(i)].insert(p[i]);
    }

    int ans = 0;
    rep(n){
        if(mp[uf.find(i)].find(i) != mp[uf.find(i)].end()) ans++;
    }
    cout << ans << endl;

}


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

using namespace std;

#define int unsigned long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    double a;
    double b;
    cin >> a >> b;

    //int b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    int b100 = 100 * b + 0.1;

    print((int)a * (b100) / 100);
}


Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

vector<vector<int> > graph;
vector<bool> used;
vector<int> topology;

void dfs (int start) {
    if (used[start]) return;
    used[start] = true;
    for (int i : graph[start]) {
        if (!used[i]) {
            dfs(i);
        }
    }
    topology.push_back(start);
    used[start] = true;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    used.resize(n);
    graph.resize(n);
    rep (i, m) {
        int x, y; cin >> x >> y; x--; y--;
        graph[x].push_back(y);
    }

    rep (i, n) dfs(i);
    reverse(all(topology));
    for (int i : topology) eprintf("%d ", i); eprintf("\n");

    vector<int> dp(n);
    for (int i : topology) {
        for (int j : graph[i]) {
            chmax(dp[j], dp[i] + 1);
        }
    }
    int ans = 0;
    rep (i, n) chmax(ans, dp[i]);
    cout << ans << "\n";
    return 0;
}

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

int main(){
    string str;cin >> str;
    char c = str.c_str()[0];
    for (int i = 1; i < 3; i++) {
        if (c != str.c_str()[i]) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a < 1){
    printf("エラー\n");
    return 1;
  }else if(c > 100){
    printf("エラー\n");
    return 1;
  }
  
  if(b/a >= c){
    printf("%d\n",c);
  }else{
    printf("%d\n",b/a);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int gcd(int a, int b){
  if(a < b) return gcd(b, a);
  int r = a%b;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

  int sum = 0;
  for(int i=1; i<K+1; i++){
    for(int j=1; j<K+1; j++){
      for(int k=1; k<K+1; k++){
        int f1 = gcd(i, j);
        int f2 = gcd(k, f1);
        sum += f2;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3624
# -*- coding:utf-8 -*-
N=int(input())
p=list(map(int,input().split()))
count=0
origin=[j+1 for j in range(N)]
for i in range(N):
    if p[i]!=origin[i]:
        count=count+1
if count>=3:
    print("NO")
else:
    print("YES")

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

using namespace std;

int main(void)
{
	int a, b;
	cin >> a >> b;
	if((a*b) % 2 == 0){
		cout << "Even" << endl;
	}else{
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n= int(input())
x = list(map(int,input().split()))
ans = 10**10
tmp = 0
for i in range(min(x),max(x)+1):
         for j in range(len(x)):
                  tmp+=(x[j]-i)**2
         if ans > tmp:
                  ans = tmp
         tmp = 0
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, c, k;
	cin >> n>> c >> k;
	vi t(n);
	rep(i, n) cin >> t[i];
	sort(all(t));
	int ans = 0, idx = 0;
	while(idx < n) {
		int tmp = t[idx++];
		int num = 1;
		while(idx < n && num < c && t[idx] <= k + tmp) idx++, num++; 
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
import time
t1 = time.time()

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res

D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

T2 = [0]*D
L = [0]*26
for i in range(D):
    p = -10**15
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T2[i] = idx

p1 = calc(T)
p2 = calc(T2)
if p2 > p1:
    T = T2
    p = p2
else:
    p = p1

i = D-1
next = -1
while time.time()-t1 < 1.9:
    temp = T[i]
    for j in range(1, 27):
        T[i] = j
        newp = calc(T)
        if p < newp:
            p = newp
            temp = j
    T[i] = temp
            
    i += next
    if i == -1:
        i = 1
        next = 1
    elif i == D:
        i = D-2
        next = -1

for t in T:
    print(t)

Measured memory_bytes: 70888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int ravel[] = new int[6];
		for(int i = 0; i < 6; i++){
			ravel[i] = scan.nextInt();
		}
		scan.nextLine();
		String order = scan.nextLine();
		scan.close();
		Dice dice = new Dice(ravel);
		dice.Move(order);
		System.out.println(dice.ravel[0]);
	}

	static class Dice{
		public int ravel[] = new int[6];

		public Dice(int[] _ravel) {
			ravel = _ravel;
		}

		public void Move(String order){
			char ch[] = order.toCharArray();
			for(int i = 0; i < ch.length; i++){
				MoveExec(ch[i]);
			}
		}

		private void MoveExec(char chOrder){
			int[] oldRavel = ravel.clone();
			switch(chOrder){
			case 'E':
				ravel[0] = oldRavel[3];
				ravel[3] = oldRavel[5];
				ravel[5] = oldRavel[2];
				ravel[2] = oldRavel[0];
				break;
			case 'N':
				ravel[0] = oldRavel[1];
				ravel[1] = oldRavel[5];
				ravel[5] = oldRavel[4];
				ravel[4] = oldRavel[0];
				break;
			case 'S':
				ravel[0] = oldRavel[4];
				ravel[4] = oldRavel[5];
				ravel[5] = oldRavel[1];
				ravel[1] = oldRavel[0];
				break;
			case 'W':
				ravel[0] = oldRavel[2];
				ravel[2] = oldRavel[5];
				ravel[5] = oldRavel[3];
				ravel[3] = oldRavel[0];
				break;
			}
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  if(n < 10){
    cout << n << endl;
    return 0;
  }
  else if(n < 100){
    cout << 9 << endl;
    return 0;
  }
  else if(n < 1000){
    cout << n-100+1+9 << endl;
  }
  else if(n < 10000){
    cout << 999-100+1+9 << endl;
  }
  else if(n < 100000){
    cout << n-10000+1+999-100+1+9 << endl;
    return 0;
  }
  else{
    cout << 90909 << endl;
    return 0;
  }
}


Measured memory_bytes: 256
k,n=map(int,input().split())
a=[int(i) for i in input().split()]
array=[]
result=a[n-1]-a[0]
array.append(result)
for i in range(1,n):
    result=k+a[i-1]-a[i]
    array.append(result)
#print(min(array))

###################################
len_array=[]
for i in range(n):
    if i==n-1:
        length=a[0]-a[i]+k
    else:
        length=a[i+1]-a[i]
    len_array.append(length)  
# len_array.index(max(len_array))
print(sum(len_array)-max(len_array))
###################################

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            long input = long.Parse(Console.ReadLine());
            long yokin = 100;
            long count = 0;
            func(input, yokin, count);

        }

        static void func(long input, long yokin, long count)
        {
            if(input <= yokin)
            {
                Console.WriteLine(count);
            }
            else
            {
                yokin += yokin / 100;
                count += 1;
                func(input, yokin, count);
            }
        }
    }
}


Measured memory_bytes: 27580
#include <stdio.h>
#define M 500001
#define NIL -1

void maxHeapify(int);
void buildMaxHeap(void);
int A[M],limit;
int left(int );
int right (int );

int main(void){
    int i;
    scanf("%d",&limit);
    for(i=1;i<M;i++){
        A[i]=NIL;
    }
    for(i=1;i<=limit;i++){
        scanf("%d",&A[i]);
    }
    buildMaxHeap();
    for(i=1;i<=limit;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
}

void buildMaxHeap(){
    int i;
    for(i=limit/2;i>=1;i--){
        maxHeapify(i);
    }
}

void maxHeapify(int i){
    int l,r,largest,ch;
    l=left(i);
    r = right(i);
    if(l<=limit && A[l]>A[i]){
        largest = l;
    }
    else largest = i;
    if(r <= limit && A[r] > A[largest]){
        largest = r;
    }
    if(largest != i){
        ch = A[i];
        A[i] = A[largest];
        A[largest] = ch;
        maxHeapify(largest);
    }
}

int left(int i){
    return 2 * i;
}

int right (int i){
    return 2 * i + 1;
}




Measured memory_bytes: 3688
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define fr(i,x) for(int i=0;i<x;i++)
#define MAX 10000005
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}

ll a[MAX];
void sieve(){
    for (int i = 1; i < MAX; i++)
    {
        for (int j = i; j <= MAX; j+=i)
        {
            a[j]++;
        }
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    

    ll n,x,m,r,cnt = 0,k,y;
    
    cin >> n;
    
    if(n>=30)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    
    
    
    
    
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n,m;
    cin>>n>>m;
    vector<pair<pair<int,int>,int>> pr(m);
    rep(i,0,m){
        int p,y;
        cin>>p>>y;
        pr[i]={{p,y},i};
    }
    sort(pr.begin(),pr.end());
    
    vector<pair<int,int>> ans(m);
    int eval=pr[0].first.first,a=1;
    rep(i,0,pr.size()){
        if(pr[i].first.first!=eval){
            a=1;
            eval=pr[i].first.first;
        }
        ans[pr[i].second]={pr[i].first.first,a};
        a++;
    }

    for(auto i:ans) printf("%06d%06d\n",i.first,i.second);

    return 0;
}

Measured memory_bytes: 5116
#include <iostream>

using namespace std;

int main(){
	int n,a,b,c;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b >> c;
		if((a*a+b*b==c*c) || (a*a+c*c==b*b) || (c*c+b*b==a*a)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 0
n,a,b = map(int, input().split(' '))
s = input()

n_ab = 0
n_b = 0

for c in s:
    if c == 'a':
        if n_ab < a+b:
            print('Yes')
            n_ab += 1
        else:
            print('No')
    elif c == 'b':
        if n_ab < a+b and n_b < b:
            print('Yes')
            n_ab += 1
            n_b += 1
        else:
            print('No')
    else:
        print('No') 

Measured memory_bytes: 4116
my_a = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_b = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_c = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
my_d = [[0 for i in range(1, 11)], [0 for i in range(1, 11)], [
    0 for i in range(1, 11)]]
buildings = [my_a, my_b, my_c, my_d]

n=int(input())


for i in range(n):
    val1=input().split(" ")
    b,f,r,v=[int(n) for n in val1]
    buildings[b-1][f-1][r-1] += int(v)



for j in range(4):
    for k in range(3):
        for l in range(10):
            print(" ",end="")
            print(buildings[j][k][l], end="")
            
        print()
    if j < 3:
        for m in range(20):
            print("#",end="")
        print()


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

string a;

int main(){
    int left,right;
    cin>>a;
    for(int i=0;i<a.length();i++)
        if(a[i]=='A'){
            left=i;
            break;
        }
    for(int i=a.length()-1;i>=0;i--)
        if(a[i]=='Z'){
            right=i;
            break;
        }
    cout<<right-left+1<<endl;
    return 0; 
} 

Measured memory_bytes: 640
def main():
    N, M = map(int, input().split())
    S = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = 0
        for c in C:
            c -= 1
            s |= (1 << c)
        S.append((a,s))

    dp = [float('inf')] * (1 << N)
    dp[0] = 0
    for i in range(1 << N):
        for j in range(M):
            t = i | S[j][1]
            dp[t] = min(dp[t], dp[i] + S[j][0])

    if dp[(1<<N)-1] == float('inf'):
        print(-1)
    else:
        print(dp[(1<<N)-1])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 46168
N = int(input())
S = list(input())
T = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(S)):
  idx = T.index(S[i])
  idx += N
  if idx > len(T)-1:
    idx = idx-len(T)
    S[i] = T[idx]
  else:
    S[i] = T[idx]
print(''.join(S))
  

Measured memory_bytes: 3188
# Your code here!
h, w = gets.split(' ').map(&:to_i)
table = Array.new(h){Array.new(w)}
table.map! { |row|
    row = gets.chomp.split('')
}
checker = Array.new(4)
can_draw = true
for row in 0...h do
    for col in 0...w do
        if table[row][col] == "#" then
            checker[0] = table[row - 1][col] if row > 0
            checker[1] = table[row + 1][col] if row < h - 1
            checker[2] = table[row][col - 1] if col > 0
            checker[3] = table[row][col + 1] if col < w - 1
            can_draw = false if checker.count("#") == 0
        end
    end
end
puts can_draw ? "Yes" : "No"

Measured memory_bytes: 1916
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<w+2;i++)sb.append('#');
        sb.append('\n');
        for(int i=0;i<h;i++)sb.append('#').
                append(sc.next().toCharArray()).append("#\n");
        for(int i=0;i<w+2;i++)sb.append('#');
        System.out.println(sb);
    }
}


Measured memory_bytes: 21844
fn factor(mut n: usize) -> Vec<(usize, usize)> {
    let mut ret = vec![];
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut cnt = 0;
        while n % i == 0 {
            cnt += 1;
            n /= i;
        }
        if cnt != 0 {
            ret.push((i, cnt));
        }
    }
    if n != 1 {
        ret.push((n, 1));
    }
    ret
}

fn main() {
    proconio::input! {
        a: usize,
        b: usize,
    }
    let afactors = factor(a);
    let bfactors = factor(b);
    let mut h = std::collections::HashMap::<usize, usize>::new();
    for (num, _count) in afactors {
        *h.entry(num).or_insert(0) += 1;
    }
    for (num, _count) in bfactors {
        *h.entry(num).or_insert(0) += 1;
    }
    let ans = h.iter().filter(|(_key, count)| **count >= 2).count() + 1;
    println!("{}", ans);
}


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

using namespace std;

const double PI = acos(-1);

int main() {
	long long a, b, x;
	scanf("%lld%lld%lld", &a, &b, &x);
	
	double len = x * 2.0 / a / b;
	
	if (len <= a) {
		double angle = atan2(b, len) * 180.0 / PI;
		printf("%.12lf\n", angle);
	}
	else {
		x = a * a * b - x;
		len = x * 2.0 / a / a;
		double angle = atan2(len, a) * 180.0 / PI;
		printf("%.12lf\n", angle);
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int max(int a,int b){
	if(a<b)
	return b;
	else
	{
		return a;
	}
	
}
int main(){
	int k,n;
	scanf("%d%d",&k,&n);
	int a[n+1];
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int b[n+1];// distance bw each house
	int big=0;
	for(int i=1;i<n;i++){
		b[i]=a[i+1]-a[i];
		big=max(b[i],big);
	}
	b[n]=k-a[n]+a[1];
	big=max(big,b[n]);
	/*for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(b[i]>b[j]){
				int temp=b[j];
				b[j]=b[i];
				b[i]=temp;
			}
		}
	}*/
	printf("%d",k-big);

}

Measured memory_bytes: 3284