akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <string.h>
#include <time.h>
#include <algorithm>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n;
	scanf("%d", &n);

	vector<i64> arr(n);

	map<i64, int> pos;
	set<int> used;

	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &arr[i]);

		pos[arr[i]] = i;
	}

	i64 res = 0;

	for (int i = 1; i <= n; i++)
	{
		i64 k = pos[i];

		auto iter = used.upper_bound(k);

		i64 lo = 0, hi = n - 1;

		if (iter != used.end())
		{
			hi = *iter - 1;
		}

		if (iter != used.begin() && !used.empty())
		{
			lo = *(--iter) + 1;
		}

		res += (k - lo + 1) * (hi - k + 1) * i;

		used.insert(k);
	}

	printf("%lld", res);


	return 0;
}

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

using namespace std;

char s1[4],s2[4],i,ans;

int main()
{
	scanf("%s%s",&s1,&s2);
	for(i=0;i<3;i++)
		if(s1[i]==s2[i])
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int N, K, R, S, P, dp[100002][2], ans;
string moves;
vector<int> mymoves;
int main(){
    scanf("%d %d %d %d %d", &N, &K, &R, &S, &P);
    cin >> moves; moves = " "+moves;
    for (int i = 1; i <= N; i++) {
        if(i-K>=1) break;
        int j;
        for (j = i; j <= N; j+=K) {
            int curval = 0;
            if(moves[j]=='r') curval = P;
            else if(moves[j]=='s') curval = R;
            else curval = S;
             if(j<=K){
                 dp[j][0] = curval;
                 dp[j][1] = 0;
             } else{
                 if(moves[j]==moves[j-K]){
                     dp[j][0] = dp[j-K][1]+curval;
                     dp[j][1] = dp[j-K][0];
                 } else{
                     dp[j][0] = max(dp[j-K][1], dp[j-K][0])+curval;
                     dp[j][1] = max(dp[j-K][1], dp[j-K][0]);
                 }
             }
        }
        ans += max(dp[j-K][0], dp[j-K][1]);
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int f(int n)
{
    return ((n % 2 == 0) ? n / 2 : 3 * n + 1);
}

int main()
{
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7)
    {
        cout << "YES" << '\n';
    }
    else
    {
        cout << "NO" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3540
import java.util.*;

public class Main {
	String s;
	char[] a, b;
	int n;
	int id, pos;
	
	void A(){
		while(true){
			int start = pos;
			int t = id;
			int num = 1;
			int goal;
			while(Character.isDigit(a[id])==true) id++;
			if(id!=t) num = Integer.valueOf(s.substring(t,id));
			B();
			
			goal = pos;
			for(int i=0;i<num-1;i++){
				for(int j=start;j<goal;j++){
					if(pos>n || j>n){
						i = num;
						break;
					}
					b[pos] = b[j];
					pos++;
				}
			}
			if(id==a.length || a[id]==')') break;
		}
	}
	
	void B(){
		if(a[id]=='('){
			id++;
			A();
			id++;
		}else{
			int t = id;
			while(id<s.length() && Character.isUpperCase(a[id])==true) id++;
			if(id==a.length || a[id]==')' || Character.isDigit(a[id])==true){
				for(int i=t;i<id;i++){
					if(pos>n) break;
					b[pos] = a[i];
					pos++;
				}
			}
		}
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			s = sc.next();
			a = s.toCharArray();
			n = sc.nextInt();
			if(a[0]=='0' && n==0) break;
			b = new char[n+1];
			Arrays.fill(b,'0');
			id = 0;
			pos = 0;
			A();
			
			
			System.out.println(b[n]);
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

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

int main() {
  int N;
  bool P,W,G,Y;
  P = W = G = Y = 0;

  cin >> N;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s; 
    if (s == "P") {
      P++;
    } else if (s == "W") {
      W++;
    } else if (s == "G") {
      G++;
    } else{
      Y++;
    }
  }

  if(P && W && G && Y){
    cout << "Four" <<endl;
  }else{
    cout << "Three" <<endl;
  }
}

Measured memory_bytes: 256
N = int(input())
S = []
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for _ in range(N):
  S.append(input())
for i in S:
  if i == "AC":
    count_AC += 1  
  elif i == "WA":
    count_WA += 1    
  elif i == "TLE":
    count_TLE += 1
  elif i == "RE":
    count_RE += 1
  else:
    pass
a = "AC" + " " + "x" + " " + str(count_AC)
b = "WA" + " " + "x" + " " + str(count_WA)
c = "TLE" + " " + "x" + " " + str(count_TLE)
d = "RE" + " " + "x" + " " + str(count_RE)
print(a, b, c, d, sep="\n") 

Measured memory_bytes: 16140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		String s = scanner.next();
		String t = scanner.next();
		for (int i = 0; i < n; i++) {
			System.out.print(s.charAt(i));
			System.out.print(t.charAt(i));
		}
	}

}


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int a[5];
int b[5];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  REP(i, 5) {
    cin >> a[i];
    b[i] = (a[i] + 10 - 1) / 10 * 10;
  }
  int ans = INF;
  REP(i, 5) {
    int sum = a[i];
    REP(j, 5) if (j != i) {
      sum += b[j];
    }
    CHMIN(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n;
    cin >> n;
    set<int> st;
    rep(i, n) {
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
		int a = sc.nextInt();
		char op = sc.next().charAt(0);
		int b = sc.nextInt();
			if (op == '?') {
				break;
			}
			else if (op == '+') {
			System.out.println(a + b);
		} else if (op == '-') {
			System.out.println(a - b);
		} else if (op == '*') {
			System.out.println(a*b);
		} else if (op == '/') {
			System.out.println(a/b);
		}
		}
	}
}


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

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  int s = A1 + A2 + A3;
  if (s > 21)
    cout << "bust" << endl;
  else 
    cout << "win" << endl;
}

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

int main() {
  
  for(int n; cin >> n, n;) {
    int h, m, s;
    int data[86401] = {};
    for(int i=0; i<n; i++) {
      scanf("%d:%d:%d", &h, &m, &s);
      data[h*3600+m*60+s] ++;
      scanf("%d:%d:%d", &h, &m, &s);
      data[h*3600+m*60+s] --;
    }
    
    int res = 0;
    for(int i=0; i<=86400; i++) {
      data[i+1] += data[i];
      res = max(res, data[i]);
    }
    
    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1584
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'

using namespace std;

#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 

int main() {
    fast;
    int n,q,l,r;
    cin>>n>>q;
    Query queries[q];
    int a[n]={0};
    for(int i=0;i<n;i++)
    cin>>a[i];
    ll left=0,right=0;
    ll b[q]={0},c[q]={0};
    for(int i=0;i<q;i++)
    {
        cin>>left>>right;
        left--;
        right--;
        queries[i].l=left;
        queries[i].r=right;
        queries[i].idx=i;
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q);
    
}

Measured memory_bytes: 27272
N, M = [int(i) for i in input().split()]
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        for ii in range(M):
            for jj in range(M):
                if A[i+ii][j+jj] != B[ii][jj]:
                    break
            else:
                continue
            break
        else:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
    int m,d,ans=0;
    cin >> m >> d;
    rep(i,m){
        rep(j,d){
            int u=(j+1)%10,uu=(j+1)/10;
            if (u<=1 || uu<=1) continue;
            if (u*uu==i+1) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
res = 0

for i in range(K):
    a = i
    prev = ''
    while a < N:
        if prev == 'r' and T[a] == 's' or \
                prev == 's' and T[a] == 'p' or \
                prev == 'p' and T[a] == 'r':
            prev = ''
        else:
            if T[a] == 's':
                prev = 'r'
                res += R
            if T[a] == 'p':
                prev = 's'
                res += S
            if T[a] == 'r':
                prev = 'p'
                res += P
        a += K

print(res)


Measured memory_bytes: 3316
n,x = gets.strip.split.map(&:to_i)
num = gets.strip.split.map(&:to_i)
for i in 0..n-1
  num[i] = (num[i].to_i-x).abs
end
#配列の全ての最大公約数を求めるO(N)
h = num[0]
for i in 1..n-1
  h = num[i].gcd(h)
end
puts h

Measured memory_bytes: 21508
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int x,y;

main(){
	int a[5]={};
	rep(i,6){
		int t;
		cin>>t;
		a[t]++;
	}
	for(int i=1;i<=4;i++){
		if(a[i]==1)x++;
		else if(a[i]==2)y++;
		else{
			dump("NO");
			return 0;
		} 
	}
	if(x==2&&y==2)dump("YES");
	else dump("NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define lli long long int

int main() {
  int N; cin >> N;
  string cadena="";
  for(int i=0; i<N; i++)  cadena+=(char)(i+65);
  
  int aux;
  string cadena1="", cadena2="";
  for(int i=0; i<N; i++){
    cin >> aux;
    cadena1+=(char)(aux+64);
  }
  for(int i=0; i<N; i++){
    cin >> aux;
    cadena2+=(char)(aux+64);
  }
  string cad=cadena1;
  lli ind, ind1, ind2;
  bool f1=true, f2=true;
  do
  {
    if(f1){
      if(cadena==cadena1) {ind1=ind;f1=0;}
    }
    if(f2){
      if(cadena==cadena2) {ind2=ind; f2=0;}
    }
    ind++;
  } while (next_permutation(cadena.begin(), cadena.end()));
  cout << abs(ind1-ind2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;

ll pow2(ll a,int b){
  if(b==1){
    return a;
  }else{
    return pow2(a,b-1)*a;
  }
};


int main(){
  int n,q;
  cin>>n;
  map<int,ll> a;
  ll ans=0;
  rep(i,n){
    ll test;
    cin>>test;
    a[test]+=1;
    ans+=test;
  }
  cin>>q;
  rep(i,q){
    int b,c;
    cin>>b>>c;
    ans=ans-a[b]*b+a[b]*c;
    a[c]+=a[b];
    a[b]=0;
    cout<<ans<<endl;
  }

  

  
  

}


Measured memory_bytes: 9444
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll h[100005];
ll dp[100005];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i <= n; i++) {
		dp[i] = inf;
	}
	dp[0] = 0;
	
	for (int i = 1; i < n; i++) {
		for (int j = max(i - k, 0); j < i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

vector<int> PowerThree(long long n) {
    vector<int> res;
    while (n > 0) {
        if (n % 3 == 1) res.push_back(1), --n;
        else if (n % 3 == 2) res.push_back(-1), ++n;
        else res.push_back(0);
        n /= 3;
    }
    reverse(res.begin(), res.end());
    return res;
}

int main() {
    int w; cin >> w;
    auto res = PowerThree(w);
    for (int i = 0; i < res.size(); ++i) {
        if (res[i] == 1) cout << "+";
        else if (res[i] == -1) cout << "-";
        else cout << "0";
    }
    cout << endl;
}



Measured memory_bytes: 3144
while True:
  H, W = map(int, input().split())
  if W == 0 and H == 0:
    break
  for j in range(H):
    #偶数
    if j % 2 == 0:
      for i in range(W):
        if i % 2 == 0:  
          print("#", end="")
        else:
          print(".", end="")
      print()
    #奇数
    else:
      for i in range(W):
        if i % 2 == 0:  
          print(".", end="")
        else:
          print("#", end="")
      print()

  print()


Measured memory_bytes: 7004
s = int(input())

def collatz(n):
    return n//2 if n%2==0 else n*3+1

i = 1
a = set([s])
while True:
    i += 1
    t = collatz(s)
    if t in a:
        break
    a.add(t)
    s = t
print(i)

Measured memory_bytes: 2940
n=int(input())
m=[int(x) for x in input().split()]
m=sorted(m, reverse=True)
u=sorted(list(set(m)), reverse=True)
d={}
for i in m:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
for i in d:
  if i != u[0]:
    d[i]*=2
pos=0
c=u[pos]*(d[u[pos]]-1)
posm=d[u[pos]]
for i in range(posm, len(m)):
  c+=u[pos]
  d[u[pos]]-=1
  if d[u[pos]] == 0:
    pos+=1
print(c)

Measured memory_bytes: 39500
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int N = Integer.parseInt(line[0]);
        int K = Integer.parseInt(line[1]);
        int[] Question = new int[26];
        //Question[0]:the number of Qs which starts with 'A',[1]:'B'......
        for(int n=0;n<N;n++){
        	String Qname = br.readLine();
        	char firstLetter = Qname.charAt(0);
        	int firstLetterID = firstLetter - 'A';
        	Question[firstLetterID] ++;
        }
        int KUPCheld = 0;
        boolean KUPCend = false;
        while(!KUPCend){
        	Arrays.sort(Question);
        	for(int i=26-K;i<26;i++) {
        		if(Question[i]<=0) KUPCend = true;
        		else Question[i] --;
        	}
        	if(!KUPCend) KUPCheld++;
        }
        
        System.out.println(KUPCheld);
    }
}

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

score = 0
for i in range(N):
  score = score + B[A[i]-1]
  if i != 0 and A[i-1] == A[i] - 1:
    score = score + C[A[i-1]-1]
  
print(score)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

H,W= map(int,input().split()) 
S = []
S.append(['.']*(W+2))
for _ in range(H):
    S.append(['.']+list(input())+['.'])
S.append(['.']*(W+2))

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == "#":
            print("#", end='')
        else:
            Stmp = S[i-1][j-1]+S[i-1][j]+S[i-1][j+1]+S[i][j-1]+S[i][j+1]+S[i+1][j-1]+S[i+1][j]+S[i+1][j+1]
            print(Stmp.count("#"), end='')
    print()


Measured memory_bytes: 79684
#include<stdio.h>

int p,r;

int main(){
  
  int n,i,A[100000];
  int index;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  index = Partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==index) printf("[");
    printf("%d", A[i]);
    if(i==index) printf("]");
    if(i!=n-1)
    printf(" ");
  }
  printf("\n");
  return 0;

}

int Partition(int A[], int p, int r){

  int x,i,j;
  int Q,R;
  int k;

  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      Q=A[i];
      A[i]=A[j];
      A[j]=Q; 
    } 
  }

  R=A[i+1];
  A[i+1]=A[r];
  A[r]=R;
  return i+1;
}

Measured memory_bytes: 996
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;
    cin>>N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];
    H[0]--;
    rep(i,1,N){
        if(H[i]>H[i-1]) H[i]--;
        else if(H[i]==H[i-1]) continue;
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

bool isPrime(int i) 
{
	for(int j=2; j < sqrt(i); j++) {
		if(i % j == 0) {
			return false;
		}
	}
	return true;
}


int main() {
	long int x;
	cin >> x;
	
	long int temp = 1000004;
	for(long int i = x; i < temp; i++) {
		if(isPrime(i)) {
			cout << i;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let h = v[0];
	let w = v[1];
	let mut c:Vec<Vec<char>> = Vec::new();
	for i in 0..h {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let s = buf.trim().chars().collect::<Vec<char>>();
		c.push(s);
	}
	
	let mut pr:Vec<Vec<char>> = Vec::new();
	for i in 0..2*h {
		pr.push(Vec::new());
	}
	
	for i in 0..2*h {
		for j in 0..w {
			pr[i as usize].push(c[(i/2) as usize][j as usize]);
		}
	}
	for i in pr {
		for j in i {
			print!("{}", j);
		}
		println!("");
	}
}

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

#define MAX 100000
#define MAX_E 100000

typedef long long ll;
typedef pair<int,int> P;

int par[MAX],rank_[MAX];

void init(int N){
        for(int i=0;i<N;i++){
                par[i]=i;
                rank_[i]=0;
        }
}

int find(int x){
        if(par[x] == x){
                return x;
        }
        return 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]++;
        }
}

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

struct edge{ int u, v, cost;};

bool comp(const edge &e1, const edge &e2){
        return e1.cost < e2.cost;
}

int V,E;
edge es[MAX_E];

int kruskal(){
        sort(es,es+E,comp);
        init(V);
        int res=0;
        for(int i=0;i<E;i++){
                edge e=es[i];
                if(!same(e.u, e.v)){
                        unite(e.u, e.v);
                        res+=e.cost;
                }
        }
        return res;
}

int main(){
        int s,t,w;
        cin>>V>>E;
        for(int i=0;i<E;i++){
                cin>>s>>t>>w;
                es[i]=(edge){s, t, w};
        }
        cout<<kruskal()<<endl;
        return 0;
}



Measured memory_bytes: 4376
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	a := make([]int, M+1)

	for i := 0; i < N; i++ {
		k := readInt()
		for j := 0; j < k; j++ {
			x := readInt()
			a[x]++
		}
	}

	var count int
	for _, x := range a {
		if x == N {
			count++
		}
	}
	println(count)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 200005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

vector<int> adj[inp], par[inp], topo;
bool vis[inp];

void dfs(int s)
{
    vis[s] = 1;
    for(int i:adj[s])
    {
        if(!vis[i]) dfs(i);
    }
    topo.push_back(s);
}
signed main() 
{
    ssd
    int i,j,k,n,m;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>j>>k;
        adj[j].push_back(k);
        par[k].push_back(j);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i]) dfs(i);
    }
    reverse(all(topo));
    ll dp[n+5] = {};
    ll ans=0;
    for(i=0;i<n;i++)
    {
        for(int j: par[topo[i]])
        {
            dp[topo[i]] = max(dp[topo[i]], 1+dp[j]);
            ans = max(ans,dp[topo[i]]);
        }
    }
    cout<<ans;
    return 0;             
}

Measured memory_bytes: 21640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		Deque<String> stack = new ArrayDeque<>();

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("S")) {
				stack.push(str[i]);
			} else if (str[i].equals("T")) {
				if (stack.isEmpty()) {
					stack.push(str[i]);
				} else if (stack.peek().equals("T")) {
					stack.push(str[i]);
				} else {
					stack.pop();
				}
			}
		}

		System.out.println(stack.size());
	}
}


Measured memory_bytes: 62344
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
ostream &operator<<(ostream &os, const vector<lint> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
lint a[114514],b[114514];
map<int,vector<int> > de;
bool sumi[114514];
int n;
int main()
{
	int out=0;
	cin>>n;
	rep(i,n) cin>>a[i];rep(i,n) cin>>b[i];
	a[n]=b[n]=0;
	rep(i,n) a[n]^=a[i],b[n]^=b[i];
	vector<lint> x,y;
	rep(i,n+1) x.pb(a[i]),y.pb(b[i]);
	//cout<<x<<' '<<y<<endl;
	if(x==y){
		cout<<0<<endl;return 0;
	}
	sort(All(x));sort(All(y));
	if(x!=y){
		cout<<-1<<endl;return 0;
	}
	
	rep(i,n+1){
		if(i<n && a[i]==b[i]) continue;
		if(i<n) out++;
		de[a[i]].pb(i);de[b[i]].pb(i);
	}
	unionf uni(n+10);
	map<int,vector<int> >::iterator it=de.begin();
	while(it!=de.end()){
		vector<int> v=(*it).se;
		rep(i,(int)v.size()-1) uni.unions(v[i],v[i+1]);
		it++;
	}
	set<int> s;
	rep(i,n+1){
		if(i<n && a[i]==b[i]) continue;
		s.insert(uni.root(i));
	}
	cout<<out+s.size()-1<<endl;
}

Measured memory_bytes: 17004
import sys

sys.setrecursionlimit(10 ** 5)


def dfs(v):
    ans.append(v)
    if v > 1_000_000_000:
        return
    for d in range(10):
        if abs(d - v % 10) <= 1:
            nv = v * 10 + d
            dfs(nv)


K = int(input())
ans = []
[dfs(i) for i in range(1, 10)]
print(sorted(ans)[K - 1])


Measured memory_bytes: 21200
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
//      String[] nyu=sc.nextLine().split(" ");
     String nyu=sc.nextLine();


int num=Integer.parseInt(nyu);
//int numnext=Integer.parseInt(nyu[1]);





System.out.println(3*num*num);

//System.out.println(a/b);


	}
}

Measured memory_bytes: 24276
#include<stdio.h>
main(){
int n,m;
scanf("%d",&n);printf("\n");
int flag=0;
if(((n-7)%10)==0) flag=1;else if
((((n/10)-7)%10)==0) flag=1;else if
((((n/100)-7)%10)==0) flag=1;
if(flag==0) printf("No");

if(flag==1) printf("Yes");
}


Measured memory_bytes: 1728
#include <stdio.h>
#include <stdlib.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


SINT32 main() {

    
    SINT8 s[200001] = {'0'};
    scanf("%s",s);

    switch(s[0]) {
        case 'A':
        printf("T");
        break;
        case 'T':
        printf("A");
        break;
        case 'G':
        printf("C");
        break;
        case 'C':
        printf("G");
        break;

    }


	return 0;
}

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

int main() {
  int n, min_count;
  cin >> n;
  min_count = 200;
  
  for (int i=0; i<n; i++) {
    int a, count = 0;
    cin >> a;
    
    if (a % 2 == 1) {
      min_count = 0;
      break;
    }
    
    while (a % 2 == 0) {
      a /= 2;
      count += 1;
    }
    if (min_count > count)
      min_count = count;
  }
  
  cout << min_count << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b;
    if(a+b<10)cout << a+b << endl;
    else cout << "error" << endl;return 0;
}


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

int main(){
  int l, r, min=2018;
  cin >> l >> r;
  
  for(int i=l; i <= r-1; i++){
    for(int j=r; j >= l+1; j--){
      if(min == 0) break;
      int left=i, right=j;
      left %= 2019;
      right %= 2019;
      if(left*right%2019 < min) min = left*right%2019;
    }
  if(min == 0) break;
  }
  cout << min << endl;
}


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



using namespace std;



using ll = long long;



int main(){

  ll n;

  cin >> n;

  cin.ignore();

  vector <ll> a;

  ll tmp = 0;

  bool allzero = true;

  for (ll i = 0; i < n; i++){

    cin >> tmp;

    if(tmp != 0){

      allzero = false;

    }

    a.push_back(tmp);

  }

  ll b[n] = {0};

  for(ll i = 0; i < n/2; i++){

    b[i] = 0;

  }

  for(ll i = n/2; i < n; i++){

    b[i] = a[i];

  }



  if(allzero == true){

    cout << 0 << endl;

    return 0;

  }



  // 後ろからあてはめていく

  ll sufi, sufj;

  ll sum;

  for (ll i = n/2; i >= 1; i--){

    sufi = i - 1;

    sum = 0;

    for(ll j = i * 2; j <= n; j += i){

      sufj = j - 1;

      sum += b[sufj];

    }

    sum = sum % 2;

    if(a[sufi] != sum){

      //cout << i << endl;

      b[sufi] =  1;

    } else {

      b[sufi] = 0;

    }

  }



  // ここから変数の意味が変わる

  sum = 0;

  for (ll i = 0; i < n; i++){

    if(b[i] == 1) ++sum;

  }



  cout << sum << endl;

  

  for (ll i = 0; i < n; i++){

    if(b[i] == 1){

      cout << (i + 1) << " " << flush;

    }

  }

  cout << endl;

  return 0;

}

      



  



Measured memory_bytes: 4080
def read_int():
    return int(input().strip())


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


def solve():
    """
    dp[lower][i][j] - if number of ways such that one of the digit is lower and contains j non-zero digits
    """
    N = input()
    length = len(N)
    K = read_int()
    dp = [
        [[0 for _ in range(K+1)] for _ in range(length+1)]
        for _ in range(2)
    ]
    dp[False][0][0] = 1
    for i in range(1, length+1):
        dp[True][i][0] = 1
        for j in range(1, K+1):
            dp[True][i][j] = 9*dp[True][i-1][j-1]+dp[True][i-1][j]
            if int(N[i-1]) > 0:
                dp[True][i][j] += dp[False][i-1][j-1]*(int(N[i-1])-1)+dp[False][i-1][j]
                dp[False][i][j] = dp[False][i-1][j-1]
            else:
                dp[False][i][j] = dp[False][i-1][j]
    return dp[True][length][K]+dp[False][length][K]


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 62280
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  string S;
  cin >> S;
  S.insert(S.begin(), '0');
  i64 N = S.size();
  reverse(all(S));
  auto dp = ndvec(N + 1, 2, (i64)1e18);
  dp[0][0] = 0;
  rep(i,0,N) {
    rep(over, 0, 2) {
      i64 n = S[i] - '0';
      rep(next,0,10) {
        if(over && next <= n) {
          dp[i + 1][1] = std::min(dp[i + 1][1], dp[i][1] + next + (9 + next) - n);
        }
        if(over && next > n) {
          dp[i + 1][0] = std::min(dp[i + 1][0], dp[i][1] + next + (next - 1) - n);
        }
        if(!over && next < n) {
          dp[i + 1][1] = std::min(dp[i + 1][1], dp[i][0] + next + (10 + next) - n);
        }
        if(!over && next >= n) {
          dp[i + 1][0] = std::min(dp[i + 1][0], dp[i][0] + next + next - n);
        }
      }
    }
  }
  cout << dp[N][0] << endl;
}


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

int N, Q;
string S;
vector<int> vec(1000000,0), vec2(1000000,0);
int l,r;

int main() {
  cin >> N>>Q >>S;
  bool flag = false;
  for(int i = 0; i < N; i++) {
    if(S.at(i) == 'A') {
	  flag = true;
	  continue;
	}
	if(S.at(i) == 'C' && flag) {
	  vec.at(i) = 1;
      flag = false;
	  continue;
	}
	flag = false;
  }
  
  for(int i = 1; i < N; i++) {
    vec2.at(i) = vec.at(i) + vec2.at(i-1);
    //cout << vec2.at(i) << endl;
  }
  
 for(int i = 0; i < Q; i++) {
    cin >> l >> r;
	if(l == 1 ) {
	  cout << vec2.at(r-1) << endl;
	  continue;
	}
	cout << vec2.at(r-1) - vec2.at(l-2) - vec.at(l-1) << endl;
  }
}

Measured memory_bytes: 8832
// B.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int x;
	cin >> x;
	int ans = 1;
	for (int i = 2; i <= x; ++i) {
		for (int j = i * i; j <= x; j *= i) {
			ans = max(ans, j);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    # sum[0:i+1]
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    # add x to i
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def inv(X):
    B = Bit(2000+1)
    inv = 0
    for i in range(len(X)):
        inv += i - B.sum(X[i])
        B.add(X[i], 1)
    return inv

A_inv = inv(A) % MOD
A2_inv = inv(A*2) % MOD

print((K*A_inv + ((K*(K-1))//2) * (A2_inv - 2*A_inv)) % MOD)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    ll N;
    cin >> N;
    vector<char> ans;
    // resolve
    while(N) {
        int shift = N % 26 -1;
        if (shift <0) {
            shift= 25;
            N-=1;
        }
        ans.push_back('a'+shift);
        N /= 26;
    }

    // output
    reverse(ans.begin(),ans.end());
    for (auto c: ans) cout << c;
    cout << endl;

    return 0;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	vector<int> a(n + n);
	for (auto& i : a) cin >> i;
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n + n; i += 2) ans += a[i];
	cout << ans;
	return 0;
}

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

int H,A[MAX+1];

void maxHeapify(int i){
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if(l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	if(r <= H && A[r] > A[largest]) largest = r;

	if(largest != i){
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int main(){
	cin >> H;

	for(int i=1;i<=H;i++) cin >> A[i];

	for(int i=H/2;i>=1;i--) maxHeapify(i);

	for(int i=1;i<=H;i++){
		cout << " " << A[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4924
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='a'||s[0]=='e'||s[0]=='o'||s[0]=='i'||s[0]=='u')
	cout<<"vowel\n";
	else
	cout<<"consonant\n";
	return 0;
}

Measured memory_bytes: 256
n, x = map(int,input().split())
l = list(map(int,input().split()))
d = [0] * (n + 1)
for i in range(1,n+1):
    d[i] = d[i-1]  + l[i-1]
ans = sum(d[i] <= x for i in range(n+1))
print(ans)


Measured memory_bytes: 9184
#include<stdio.h>
#include<string.h>
int main()
{
	int i,j;
	char s[101];
	scanf("%s",&s);
	for(i=0;i<strlen(s);i++)
	{
		if(s[i]=='C')
		{
			for(j=i;j<strlen(s);j++)
			{
				if(s[j]=='F')
				{
					printf("Yes\n");
					break;
				}
				else if(j==strlen(s)-1)
				printf("No\n");
			}
			break;
		}
		else if(i==strlen(s)-1)
		printf("No\n");
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll l, r;
    cin >> l >> r;
    if (r - l + 1 >= 2019) {
        cout << 0 << endl;
    } else {
        ll res = Inf;
        FOR (i, l, r + 1) {
            FOR (j, i + 1, r + 1) {
                res = min(res, (ll)((i % 2019) * (j % 2019)) % 2019);
            }
        }
        cout << res << endl;
    }
    
    return 0;
}

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

using namespace std;

string rep[] = {"", "Female", "Male"};
int main(){
	int n;
	cin >> n;
	int l = 0, r = n - 1;
	string v;
	int s1, sn;
	cout << 0 << "\n";
	fflush(stdout);
	cin >> v;
	if(v == "Vacant"){
		exit(0);
	}
	for(int i = 1; i <= 2; i++){
		if(v == rep[i])
			s1 = i;
	}
	cout << n - 1 << "\n";
	fflush(stdout);
	cin >> v;
	if(v == "Vacant"){
		exit(0);
	}
	for(int i = 1; i <= 2; i++){
		if(v == rep[i])
			sn = i;
	}
	while(l != r){
		int mid = (l + r) / 2;
		cout << mid << "\n";
		fflush(stdout);
		cin >> v;
		if(v == "Vacant"){
			exit(0);
		}
		for(int i = 1; i <= 2; i++){
			if(v == rep[i]){
				if((n - mid) % 2 == (sn - i + 2) % 2 || (mid - 1) % 2 != (i - s1 + 2) % 2){
					l = mid + 1;
				}
				else r = mid;
			}
		}
	}
	cout << l;
	fflush(stdout);
	exit(0);
}

Measured memory_bytes: 852
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define mod 1000000007


int main()
{
    int temp,i,N,M;
    ll sum=0;
    int res;
    priority_queue<int> pq;
    while(scanf("%d%d",&N,&M)!=EOF)
    {
        sum=0;
        for(i=0;i<N;i++)
        {
            scanf("%d",&temp);
            pq.push(temp);
        }
        for(i=0;i<M;i++)
        {
            res=pq.top();
            pq.pop();
            pq.push(res/2);
        }
        while(!pq.empty())
        {
            sum+=pq.top();
            pq.pop();
        }
        printf("%lld\n",sum);
    }
    return 0;
}



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

//

int main() {
    int N, M;
    cin >> N >> M;
    string a[N];
    string b[M];
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> b[i];

    rep(ax, N - M + 1) {
        rep(ay, N - M + 1) {
            bool match = true;
            rep(bx, M) {
                rep(by, M) {
                    if (a[ay + by][ax + bx] != b[by][bx]) {
                        bx = 10000;
                        match = false;
                        break;
                    }
                }
            }
            if (match) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    bool A[105][105];
    for(int i=0; i<105; i++){
        for(int j=0; j<105; j++){
            A[i][j] = 0;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        int u;
        int k;
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            int v;
            cin >> v;
            v--;
            A[u][v] = 1;
        }
        
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n-1; j++){
            cout << A[i][j] << " ";
        }
        cout << A[i][n-1] << endl;
    }
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	cin >> a;
	VL x(n);
	x[0] = a[0];
	for (int i = 1; i < n; i++) {
		x[i] = a[i-1] - x[i-1];
	}
	LL aa = x[n-1] + x[0] - a[n-1];
	aa /= 2;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			cout << abs(x[i]-aa)*2 << " ";
		}
		else {
			cout << abs(x[i]+aa)*2 << " ";
		}

	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
bool comp(string x,string y){
	return (x<y);
}
int main(){
	int n,l;
	cin>>n>>l;
	vector<string>v(n);
	for(int i=0;i<n;i++)
	cin>>v[i];
	sort(v.begin(),v.end(),comp);
	for(auto x:v)
	cout<<x;
	return 0;
}


Measured memory_bytes: 256