akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int x,y,z;
    cin >> x>>y>>z;
    cout << z << " " << x << " "<< y << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
 
class Main{
    public static void main (String[ ] args) throws Exception{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        String str = br.readLine();
        int x = Integer.parseInt(str);
        int ans = x*x*x;
        System.out.println(ans);
    }
}

Measured memory_bytes: 24016
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int c[3][3],b[3],a[3];
	bool ans = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++)cin >> c[i][j];
	}
	a[0] = 0;
	for (int i = 0; i < 3; i++)b[i] = c[0][i];
	for (int i = 1; i < 3; i++)a[i] = c[i][0] - b[0];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (c[i][j] != a[i] + b[j]) {
				ans = false;
				break;
			}
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int H,W,h,w,k;
  for ( ; ; )
  {
    scanf("%d %d",&H,&W);
    if (H == 0 && W == 0)
    {
      break;
    }
    for (h = 1; h <= H; h++)
    {
      for (w = 1; w <= W; w++)
      {
        k = h + w;
        if (k % 2 == 0)
        {
          printf("#");
        }else{
          printf(".");
        }
        if (w == W)
        {
          printf("\n");
        }
      }
      if (h == H)
      {
        printf("\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int n, k, ans = 0;
  cin >> n >> k;
  vector<int> l(55, 0);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  rep(i, k)
  {
    ans += l[i];
  }
  c(ans);
}

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

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

	if(a.size() > b.size()){
		cout << "GREATER" << endl;
	}
	else if(a.size() < b.size()){
		cout << "LESS" << endl;
	}
	else if(a == b){
		cout << "EQUAL" << endl;
	}
	else if(a > b){
		cout << "GREATER" << endl;
	}
	else {
		cout << "LESS" << endl;
	}
}

Measured memory_bytes: 256
import numpy as np
import sys

def sum2d(i1,j1,i2,j2):
    A[i1][j1] += 1
    A[i1][j2] -= 1
    A[i2][j1] -= 1
    A[i2][j2] += 1

N,K = map(int,input().split())
XYC = [list(input().split()) for _ in range(N)]

A = [[0 for _ in range(K*2+1)] for _ in range(K*2+1)]

for x,y,c in XYC:
    i = (int(x) if c=="W" else int(x)+K) % (K*2)
    j = int(y) % (K*2)
    i0 = i%K
    j0 = j%K
    if (i<K and j<K) or (i>=K and j>=K):
        sum2d(0,0,i0,j0) # 左上
        sum2d(i0+K,0,K*2,j0) # 右上
        sum2d(i0,j0,i0+K,j0+K) # 真ん中
        sum2d(0,j0+K,i0,K*2) # 左下
        sum2d(i0+K,j0+K,K*2,K*2) # 右下
    else:
        sum2d(i0,0,i0+K,j0) # 上
        sum2d(0,j0,i0,j0+K) # 左
        sum2d(i0+K,j0,K*2,j0+K) # 右
        sum2d(i0,j0+K,i0+K,K*2) # 下

# 2次元累積和
AA = np.array(A)
for i in range(K*2):
    AA[i+1, :] += AA[i, :]
for j in range(K*2):
    AA[:, j+1] += AA[:, j]

print(AA.max())




Measured memory_bytes: 101884
# AOJ 1624 Income Inequality
# Python 2018.7.12 bal4u

while True:
	n = int(input())
	if n == 0: break
	a = list(map(int, input().split()))
	s = int(sum(a)//n)
	ans = 0
	for x in a:
		if x <= s: ans += 1
	print(ans)


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

int main() {
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<bool> H(h,false),W(w,false);
  rep(i,h)rep(j,w){
    if(a[i][j]=='#')H[i]=W[j]=true;
  }
  rep(i,h){
    if(H[i]){
      rep(j,w){
        if(W[j])cout<<a[i][j];
          if(j==w-1)cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define MAXN   1000001
using namespace std;

typedef long long ll;

int jawab[MAXN];

void sieve()
{
    jawab[1] = 1;
    for (int i=2; i<MAXN; i++)

        jawab[i] = i;

    for (int i=4; i<MAXN; i+=2)
        jawab[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {

        if (jawab[i] == i)
        {

            for (int j=i*i; j<MAXN; j+=i)


                if (jawab[j]==j)
                    jawab[j] = i;
        }
    }
}


int main(){
	ios::sync_with_stdio(false); cin.tie(0);
    sieve();
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    map<int,int> mp;
    int gcd=0;
    for(int i=0;i<n;i++){
        gcd=__gcd(gcd,arr[i]);
        int temp=arr[i];
        map<int,int> mp1;
        while(temp!=1){
            mp1[jawab[temp]]++;
            //cout<<temp<<endl;
            while(temp%jawab[temp]==0 && temp>1){
                temp/=jawab[temp];
                mp1[jawab[temp]]++;
            }

        }
        for(auto it: mp1)
            mp[it.first]++;
    }
    int flag=1;
    

    for(auto it: mp)
        if(it.second>1 && it.first!=1){
            flag=0;break;
        }
    if(flag && gcd==1){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    if(flag)
        cout<<"pairwise coprime"<<endl;
    else if(gcd==1)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;
}

Measured memory_bytes: 15096
N, M = map(int, input().split())
PS = [list(input().split()) for _ in range(M)]

AC = [0] * (N + 1)
WA = [0] * (N + 1)

for P, S in PS:
  P = int(P)
  if S == "AC":
    if AC[P] == 0:
      AC[P] = 1
  else:
    if AC[P] == 0:
      WA[P] += 1
      
answer_AC, answer_WA = 0, 0
for i in range(N+1):
  if AC[i]:
    answer_AC += 1
  if WA[i] and AC[i]:
    answer_WA += WA[i]

print(answer_AC, answer_WA)

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  string r;
  for(int i = 0; i < n / 2; i++){
     r += s.at(i);
  }
  if(r + r == s){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, x;
    cin >> n;
    for(int i=1; i<=n; i++){
        int x=i;
        if(x%3==0){
            cout << " " << i;
            continue;
        }
        while(x){
            if(x%10==3){
                cout << " " << i;
                break;
            }
            x/=10;
        }
    }
    cout << endl;
}



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

int n,m,sm = 10000000;
int w[100],v[100];
int DP[10001];

int rec(int j){
	if(DP[j]>=0)	return DP[j];
	if(j<sm)	return DP[j] = 0;

	int res = 0;
	for(int i=0;i<n;i++){
		if(w[i]<=j){
			int tmp = rec(j-w[i])+v[i];
			if(tmp > res){
				res = tmp;
			}
		}
	}
	return DP[j] = res;
}

int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> v[i] >> w[i];
		if(w[i]<sm){
			sm = w[i];
		}
	}
	
	for(int i=0;i<=m;i++){
		DP[i]=-1;
	}

	cout << rec(m) << endl;

	return 0;
}

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

int main() {
    vector<vector<int>> A(3,vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    int b;
    for (int i = 0; i < N; i++){
        cin >> b;
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if(b==A[i][j])A[i][j]=0;
            }
        }
    }
    for (int i = 0; i < 3; i++){
        if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
            cout << "Yes" << endl;
            return 0;
        }
        if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool check(int a,int b,int c){
 if((a+b>c)&&(b+c>a)&&(c+a>b)){return true;}
 return false;
}
int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,x;
  cin>>n;
  vector<int> d(n,0);
  for(int i=0; i<n; i++){
    cin>>d[i];
  }
  int ans=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
        for(int k=j+1; k<n; k++){
            if(d[i]!=d[j]&&d[j]!=d[k]&&d[k]!=d[i]){
                if(check(d[i],d[j],d[k])){ans++;}
            }
        }
    }
  }
  cout<<ans;


  return 0;
}

Measured memory_bytes: 3620
"use strict"
// input data
function main(input) {
    let k = Number(input.split('\n')[0].split(' ')[0]);
    let sum = 0;
    for (let i = 1; i <= k; i++) {
        for (let n = 1; n <= k; n++) {
            for (let j = 1; j <= k; j++) {
                sum += gcd(i, n, j);
            }  
        }
    }
    console.log(sum);
}

function gcd() {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = arguments[0]
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]); 
    }
    return ans 
}

// output
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a;
  cin >> n;
  cin >> a;
  int res = n % 500;
  if(res <= a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const ll inf=1ll<<60;

ll dp[3010][3010][5];
ll g[3010][3010];

int main(){
  int r,c,k; cin >> r >> c >> k;
  rep(i,k){
    int a,b,d;
    cin >> a >> b >> d;
    a--; b--;
    g[a][b]=d;
  }
  if(g[0][0]){
    dp[0][0][1]=g[0][0];
    dp[0][0][0]=-inf;
  }
  rep(i,r)rep(j,c)rep(k,4){
    if(i-1>=0){
      if(g[i][j]!=0) chmax(dp[i][j][1],dp[i-1][j][k]+g[i][j]);
      chmax(dp[i][j][0],dp[i-1][j][k]);
    }
    if(j-1>=0){
      if(g[i][j]!=0) chmax(dp[i][j][k+1],dp[i][j-1][k]+g[i][j]);
      chmax(dp[i][j][k],dp[i][j-1][k]);
    }
  }
  ll ans=-inf;
  rep(k,4){
    chmax(ans,dp[r-1][c-1][k]);
  }
  cout << ans << endl;
}

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

typedef struct{
  char mark;
  int n;
  int m;
}T;
T a[N];
int num;
int partition(int p, int r){
  int i,j;
  T sum,ch;
  sum = a[r];
  i = p-1;
  for (j =p;j<r;j++){
    if (a[j].n <= sum.n){
      i = i+1;
      ch=a[i];
      a[i]=a[j];
      a[j]=ch;
    }
  }
 
  ch=a[r];
  a[r]=a[i+1];
  a[i+1]=ch;
 
  return i+1;
}
 
void quickSort(int p,int r){
  int q;
 
  if( p < r){
     q = partition(p, r);
     quickSort(p, q-1);
     quickSort( q+1, r);
  }
}
int main(){
  int i,stable=1;
  char c[1];
 
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s%d",c,&a[i].n);
    a[i].mark=c[0];
    a[i].m=i;
  }
 
  quickSort(0,num-1);
 
  for(i=0;i<num;i++) 
      if(i>0 && a[i].n==a[i-1].n && a[i].m<a[i-1].m){
        printf("Not stable\n");
        break;
      }
      if(i==num)
      printf("Stable\n");
 
  for(i=0;i<num;i++)
    printf("%c %d\n",a[i].mark,a[i].n);
  return 0;
}



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

using namespace std;

vector<priority_queue<int> > que;

void f0()
{
    int p1,p2;
    cin>>p1>>p2;

    que[p1].push(p2);
}

void f1()
{
    int p;
    cin>>p;

    if(!que[p].empty())
        cout<<que[p].top()<<endl;
}

void f2()
{
    int p;
    cin>>p;

    if(!que[p].empty()) que[p].pop();
}

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

    cin>>n>>q;

    que.resize(n);

    while(q--)
    {
        int op;
        cin>>op;

        switch(op)
        {
            case 0:f0();break;
            case 1:f1();break;
            case 2:f2();break;
        }
    }


    return 0;
}




Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;

struct choice
{
    ll x, y, z;
    ll v;
    choice(ll _x, ll _y, ll _z, ll _v)
    {
        x = _x;
        y = _y;
        z = _z;
        v = _v;
    }
};

bool operator< (const choice& l, const choice& r)
{
    return l.v < r.v;
}

ll hash_choice(const choice& c)
{
    return c.x * 1000000 + c.y * 1000 + c.z;
}

int main()
{
    ll X, Y, Z, K;
    vector<ll> A, B, C;
    cin >> X >> Y >> Z >> K;
    ll temp;
    for (ll x = 0; x < X; x++) {
        cin >> temp;
        A.push_back(temp);
    }
    for (ll y = 0; y < Y; y++) {
        cin >> temp;
        B.push_back(temp);
    }
    for (ll z = 0; z < Z; z++) {
        cin >> temp;
        C.push_back(temp);
    }

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    priority_queue<choice> que;
    set<ll> mark;
    que.push(choice(0, 0, 0, A[0] + B[0] + C[0]));
    for (ll i = 0; i < K; i++) {
        choice c = que.top();
        cout << c.v << endl;
        que.pop();
        if (c.x < X - 1) {
            choice temp(c.x + 1, c.y, c.z, A[c.x + 1] + B[c.y] + C[c.z]);
            if (mark.find(hash_choice(temp)) == mark.end()) {
                que.push(temp);
                mark.insert(hash_choice(temp));
            }
        }
        if (c.y < Y - 1) {
            choice temp(c.x, c.y + 1, c.z, A[c.x] + B[c.y + 1] + C[c.z]);
            if (mark.find(hash_choice(temp)) == mark.end()) {
                que.push(temp);
                mark.insert(hash_choice(temp));
            }
        }
        if (c.z < Z - 1) {
            choice temp(c.x, c.y, c.z + 1, A[c.x] + B[c.y] + C[c.z + 1]);
            if (mark.find(hash_choice(temp)) == mark.end()) {
                que.push(temp);
                mark.insert(hash_choice(temp));
            }
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m;
    cin>>n>>m;
    bool T[m];
    rep(0,i,m)T[i]=true;
    rep(0,i,n){
        ll k;
        cin>>k;
        bool F[m];
        rep(0,i,m)F[i]=false;
        rep(0,j,k){
            ll a;
            cin>>a;
            F[a-1]=true;
        }
        rep(0,j,m){
            if(F[j]==false && T[j]==true)T[j]=false;
        }
    }
    ll ans=0;
    rep(0,i,m){
        if(T[i]==true)++ans;
        //cout<<T[i];
    }
    //cout<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {
  val prime = primes(1000000)
  loop()
  @tailrec def loop(): Unit = {
    val n = readInt()
    if (n == 0) return
    println((0 until upperBound(prime, n / 2)).count(p ⇒ binarySearch(prime, n - prime(p))))
    loop()
  }
  def upperBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length
    while(left < right) {
      val mid = (left + right) / 2
      if (array(mid) <= target) left = mid + 1
      else right = mid
    }
    right
  }
  def binarySearch(array: Array[Int], target: Int): Boolean = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (array(mid) < target) left = mid + 1
      else right = mid
    }
    right < array.length && array(right) == target
  }
  def primes(upperLimit: Int): Array[Int] = {
    val isPrime = Array.fill(upperLimit + 1){true}
    for (i ← 2 to math.sqrt(upperLimit).ceil.toInt if isPrime(i); j ← i * i to upperLimit by i) {
        isPrime(j) = false
    }
    (2 to upperLimit).filter(isPrime).toArray
  }
}


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


void solve()
{
   string s;
   cin>>s;
   ll ans=0;
   fo(i,s.length())
   ans+=(ll)(s[i]-'0');
   if(ans%9==0)
   cout<<"Yes";
   else
   cout<<"No";
   
   
    
    
    
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	    solve();
	}
 
	return 0;
}


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

using namespace std;

const int N=1e5+5;

typedef long long ll;

int u,p,d,n,tc,q,k,cnt;

char s[N];

ll ans;

vector<int> topping[N];

pair<int,int> a[N];

multiset <int> m,kind;

vector<pair<int,int> > v;

int main()
{
//	freopen("test.txt","r",stdin);
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d%d",&a[i].first,&a[i].second),topping[--a[i].first].push_back(a[i].second);
	ll del=0;
	for(int i=0;i<n;i++){
		if (topping[i].size()){
			sort(topping[i].begin(),topping[i].end(),greater<int>());
			v.push_back({topping[i][0],i});
		}
	}
	sort(v.begin(),v.end(),greater<pair<int,int > >());
	for(int ii=0;ii<v.size() && ii<k;ii++){
		int i=v[ii].second;
		del+=topping[i][0];
		if (m.size()+ii+1>k){
			del-=*m.begin();
			m.erase(m.begin());
		}
		for(int j=1;j<topping[i].size();j++){
			if ( ( ii+1 +(int)m.size() ) == k){
                if (!m.size())
                    break;
				if (topping[i][j] > *m.begin()){
					del-=*m.begin();
					m.erase(m.begin());
				}
				else
					break;
			}
			del+=topping[i][j];
			m.insert(topping[i][j]);
		}
		ll sz=ii+1;
		ans=max(ans,sz*sz+del);
	}
	printf("%lld\n",ans);

}




Measured memory_bytes: 7672
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.length()) {
		if (s[i] != t[i]) {
			++ans;
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3884
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { b: char }
    let ans = match b {
        'A' => 'T',
        'T' => 'A',
        'C' => 'G',
        'G' => 'C',
        _ => 'n',
    };
    println!("{}", ans);
}


Measured memory_bytes: 2076
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();

    let ans = if (a < c && c < b) || (b < c && c < a) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
from itertools import accumulate
import numpy as np
N=int(input())
N-=1
L=[26**(i+1) for i in range(15)]
sL=list(accumulate(L))
result=[]
k=0
for i in range(15):
    if N+1<=sL[i] and N>=25:
        N-=sL[i-1]
        k=i
        break
for m in range(k):
    time=0
    while N>=L[k-m-1]:
        N-=L[k-m-1]
        time+=1
    result.append(chr(time+97))
result.append(chr(N+97))
print(''.join(result))

Measured memory_bytes: 27180
#include <iostream>

using namespace std;
int main(){
	int i,j;
	cin >> i;
	cin >> j;
	int power[13] = {13,1,2,3,4,5,6,7,8,9,10,11,12};

	
	if(power[i-1]-power[j-1]> 0)	cout << "Alice" << endl;
	else if(power[i-1]==power[j-1])	cout << "Draw" << endl;
	else		cout << "Bob" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll n;
  cin >> n;
  n--;
  ll ans = n * (n + 1) / 2;
  cout << ans << endl;
}


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

using namespace std;
#define ll  long long
#define ld long double
ll k;
ll dp[100005]={0};
ll a[100005]={0};
ll check(ll v) {
set<ll> b;
    for(ll i = 1;i<=k && i<v;i++) {
        b.insert(dp[v-i]+abs(a[v]-a[v-i]));
    }
  //  for(auto it = b.begin();it!=b.end();it++) {
  //      cout<<*it<<" ";
  //  }
  //  cout<<endl;
    return *b.begin();
}
int main()
{
 // freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
ll n;

    cin>>n>>k;
    for(ll i =1;i<=n;i++) {
        cin>>a[i];
    }
dp[0] = 0;
dp[1] = 0;

for(ll i =2;i<=n;i++) {
    dp[i] = check(i);
}
cout<<dp[n];

}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, tmp, count = 0;
  cin >> N;
  vector<int> arr(N);
  for(int i = 0; i < N; i++) cin >> arr.at(i);
  
  for(int i = 0; i < N; i++){
    if(arr.at(i) == 0){ count++; continue;}
    tmp = arr.at(i);
    for(int j = 0; j < N; j++){
      if(arr.at(j) == tmp) arr.at(j) = 0;
    }
  }
  
  cout << N - count << endl;
}

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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, M;
int A[MAX_N], B[MAX_N];

bool isDeletedEdge(int u, int v, int edgeId)
{
  return (A[edgeId] == u && B[edgeId] == v) ||
         (A[edgeId] == v && B[edgeId] == u);
}

bool isConnected(int deletedEdge, vector<vector<int>> G)
{
  vector<bool> visited(G.size(), false);
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    visited[u] = true;
    for (auto v : G[u]) {
      if (isDeletedEdge(u, v, deletedEdge)) continue;
      if (visited[v]) continue;
      q.push(v);
    }
  }
  REP(i, G.size()) if (!visited[i]) return false;
  return true;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  vector<vector<int>> G(N);
  REP(i, M)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    A[i] = a, B[i] = b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int cnt = 0;
  for (int i = 0; i < M; i++) {
    if (!isConnected(i, G)) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# from typing import *
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def solve(N, A):
    for i in range(N):
        if A[i] == 0:
            print(0)
            return
    ans =1
    for i in range(N):
        if A[i] > math.pow(10,18):
            print(-1)
            return
        ans *= A[i]
        if ans > math.pow(10,18):
            print(-1)
            return
    print(ans)



def main():
    import sys
    tokens = iter(sys.stdin.read().split())
    N = int(next(tokens))
    A = [None for _ in range(N)]
    for i in range(N):
        A[i] = int(next(tokens))
    assert next(tokens, None) is None
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22452
#!/usr/bin/env python3

import sys
from collections import deque

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def read_str():
    return sys.stdin.readline().rstrip()
    
def read_str_list(sep = " "):
    return [s for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    d = deque(list(read_str()))
    q = read_int()

    reversed_ = False
    for _ in range(0, q):
        query = read_str_list()
        if query[0] == "1":
            reversed_ = not reversed_
            continue
        # query[0] == "2"
        f, c = query[1:]
        if (f == "1" and not reversed_) or (f == "2" and reversed_):  # insert to the left
            d.appendleft(c)
        else:
            d.append(c)
    if reversed_:
        print("".join(reversed(list(d))))
    else:
        print("".join(list(d)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 10076
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int r;
    private void solve() {
        r = nextInt();
        out.println(3 * r * r);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
map<long long int,int> co;
vector<int> v[100001];
long long cc[100001];
int m=0;
void dfs(int f,int p,int u){
	if(f!=-1){
	co[f*100000+p]=u;
	co[p*100000+f]=u;	
	}
	//if(v[p].size()==1)return;
	int t=1;
	for(int i=0;i<v[p].size();i++){
		if(v[p][i]==f)continue;
		if(t==u)t++;
		dfs(p,v[p][i],t);
		t++;
	}
	return;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x,mm;
	cin>>x;
	for(int i=0;i<x-1;i++){
		int a,b;
		cin>>a>>b;
		cc[i]=a*100000+b;
		v[a].push_back(b);
		v[b].push_back(a);
		if(v[a].size()>m)m=v[a].size(),mm=a;
		if(v[b].size()>m)m=v[b].size(),mm=b;
	}
	cout<<m<<endl;
	dfs(-1,mm,0);
	for(int i=0;i<x-1;i++)cout<<co[cc[i]]<<endl;
	return 0;
}


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

int H,W;
char fid[20][20];
char cop[20][20];
bool used[20];

bool same(char A[],char B[])
{
    for(int i = 0; i < W; i++)if(A[i] != B[i])return false;
    return true;
}

int main()
{
    scanf("%d%d",&H,&W);
    for(int i = 0; i < H; i++)for(int j = 0; j < W; j++)scanf(" %c",&fid[i][j]);

    for(int i = 0; i < H; i++)for(int j = 0; j < W; j++)cop[i][j] = fid[i][j];
    for(int i = 0; i < H; i++)sort(cop[i],cop[i] + W);
    memset(used,false,sizeof(used));
    for(int i = 0; i < H; i++)if(!used[i])
    {
        for(int j = 0; j < H; j++)if(!used[j] && i != j)
        {
            if(same(cop[i],cop[j]))
            {
                used[i] = used[j] = true;
                break;
            }
        }
    }
    if(H % 2)
    {
        for(int i = 0; i < H; i++)if(!used[i])
        {
            used[i] = true;
            break;
        }
    }
    for(int i = 0; i < H; i++)if(!used[i])
    {
        printf("NO\n");
        return 0;
    }

    memset(cop,0,sizeof(cop));
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            cop[j][i] = fid[i][j];
        }
    }
    swap(H,W);
    if (5 < W && W < 9 && 7 <= H) {
        printf("NO\n");
        return 0;
    }
    for(int i = 0; i < H; i++)sort(cop[i],cop[i] + W);
    memset(used,false,sizeof(used));
    for(int i = 0; i < H; i++)if(!used[i])
    {
        for(int j = 0; j < H; j++)if(!used[j] && i != j)
        {
            if(same(cop[i],cop[j]))
            {
                used[i] = used[j] = true;
                break;
            }
        }
    }
    if(H % 2)
    {
        for(int i = 0; i < H; i++)if(!used[i])
        {
            used[i] = true;
            break;
        }
    }
    for(int i = 0; i < H; i++)if(!used[i])
    {
        printf("NO\n");
        return 0;
    }

    printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let s: Vec<char> = input::<String>().chars().collect();

    let mut group = vec![];
    if s[0] == '0' {
        group.push(('1', 0));
    }
    let mut i = 0;
    while i < n {
        let cur = s[i];
        let mut cnt = 0;
        while i < n && s[i] == cur {
            i += 1;
            cnt += 1;
        }
        group.push((cur, cnt));
    }

    let z = group.iter().filter(|&&(c, _)| c == '0').count();
    if z <= k {
        println!("{}", n);
        return;
    }

    let mut gn = group.len();
    if group[group.len() - 1].0 == '0' {
        group.push(('1', 0));
        gn += 1;
    }

    let mut sum = vec![0; group.len() + 1];
    for i in 0..gn {
        sum[i + 1] = sum[i] + group[i].1;
    }

    let mut ans = 0;
    for i in 0..gn - (2 * k + 1) + 1 {
        if i & 1 == 1 {
            continue;
        }
        let temp = sum[i + 2 * k + 1] - sum[i];
        ans = std::cmp::max(ans, temp);
    }
    println!("{}", ans);
}


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


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vii  = vector<ii>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)
#define Time()	cerr <<'\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define SZ(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define ar array

// no change 

//const int MxN = 1e9+5;
void solve(){
	for(int i =1;i<=5;i++){
		int x;
		cin >> x;
		if(x ==0)cout << i;
	}
}
int main() {
	FASTER;
	int T=1;
	//cin >> T;
	while(T--)solve();	
	#ifdef LOCAL
	Time();
	#endif
}


Measured memory_bytes: 3132
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D, X = lr()
choco = 0
for _ in range(N):
    a = ir()
    choco += 1 + (D-1) // a

answer = X + choco
print(answer)


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;
int main() {
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == ',')
            s[i] = ' ';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n, i;
struct str{
    int ind, p;
    char s[15];
};
str v[105];
int comp(char a[15], char b[15]){
    int n = strlen(a + 1), m = strlen(b + 1);
    for(int i = 1; i <= min(n, m); i++){
        if(a[i] != b[i]){
            if(a[i] < b[i]){
                return -1;
            }
            return 1;
        }
    }
    if(n == m){
        return 0;
    }
    if(n < m){
        return -1;
    }
    return 1;
}
int cmp(str a, str b){
    if(comp(a.s, b.s) == 0){
        return a.p > b.p;
    }
    return comp(a.s, b.s) < 0;
}
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        cin>> v[i].s + 1;
        cin>> v[i].p;
        v[i].ind = i;
    }
    sort(v + 1, v + n + 1, cmp);
    for(i = 1; i <= n; i++){
        cout<< v[i].ind <<"\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
#define SIZE 1000000000
 
int main(){
    int n, s, e, count_ = 0;
    unsigned int a;
    vector<unsigned long int> num;
    vector<unsigned long int>::iterator itr;
    cin >> n;
    num.resize(n);
    for(itr = num.begin(); itr < num.end(); itr++) cin >> *itr;
    sort(num.begin(), num.end());
    itr = num.begin();
    while(itr < num.end()){
        if(*itr == *(itr + 1)) 
            itr += 2;
        else{
            count_++;
            itr++;
        }
    }
    cout << count_ << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import heapq
N,K = map(int,input().split())
Alist = list(map(int,input().split()))
Ball = dict()
for i in Alist:
    if i not in Ball:
        Ball[i] = 1
    else:
        Ball[i] += 1
Balllist = []
for key, value in Ball.items():
    Balllist.append(value)
heapq.heapify(Balllist)
size = len(Balllist)
Answer = 0
for _ in range(10**7):
    if size <= K:
        break
    Answer += heapq.heappop(Balllist)
    size -= 1
print(Answer)

Measured memory_bytes: 35080
#include<stdio.h>

main(){
	int a[101][101], b[101], c[101], n, m, i, j;
	
	for(i=0;i<101;i++){
		for(j=0;j<100;j++){
			a[i][j]=0;
		}
	}
	for(i=0;i<101;i++){
		b[i]=0;
	}
	for(i=0;i<101;i++){
		c[i]=0;
	}
	
	scanf("%d%d",&n,&m);
	
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=1;i<=m;i++){
		scanf("%d",&b[i]);
	}
	
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			c[i]+=a[i][j]*b[j];
		}
		printf("%d\n",c[i]);
	}
	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
class Edge1{
    int u;
    int v;
    double cost;
    public Edge1(int u, int v, double cost){
        this.u = u;
        this.v = v;
        this.cost = cost;
    }
}
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        Edge1[] edges = new Edge1[m];
        for(int i=0; i<n; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        double res = 0;
        for(int i=0; i<m; i++){
            int u = sc.nextInt()-1;
            int v = sc.nextInt()-1;
            double dis = Math.sqrt(Math.pow(x[u]-x[v], 2)+Math.pow(y[u]-y[v], 2));
            res += dis;
            edges[i] = new Edge1(u, v, dis);
        }
        Arrays.sort(edges, new Comparator<Edge1>() {
            @Override
            public int compare(Edge1 o1, Edge1 o2) {
                if(o2.cost>o1.cost) return 1;
                else if(o2.cost<o1.cost) return -1;
                return 0;
            }
        });
        int[] parent = new int[n];
        int[] rank = new int[n];
        for(int i=0; i<n; i++) {
            parent[i] = i;
            rank[i] = 1;
        }
        double cur_res = 0;
        for(int i=0; i<m; i++){
            Edge1 e = edges[i];
            if(!same(e.u, e.v, parent)){
                unite(e.u, e.v, parent, rank);
                cur_res += e.cost;
            }
        }
        System.out.println(res-cur_res);
    }
    public static boolean same(int u, int v, int[] parent){
        int pu = find(u, parent);
        int pv = find(v, parent);
        if(pu == pv)return true;
        return false;
    }
    public static int find(int v, int[] parent){
        if(parent[v] == v) return v;
        return parent[v] = find(parent[v], parent);
    }
    public static void unite(int u, int v, int[] parent, int[] rank){
        int pu = find(u, parent);
        int pv = find(v, parent);
        if(pu==pv) return;
        if(rank[pu]<rank[pv]){
            parent[pu] = pv;
        }
        else{
            parent[pv] = pu;
            if(rank[pu] == rank[pv]) rank[pu]++;
        }
    }
}


Measured memory_bytes: 69224
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int age = inint();
		if (age == 7 || age == 5 || age == 3) out.println("YES");
		else out.println("NO");
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		int ans = N * 100;
		ans /= 108;
		for (; N > (int) Math.floor(ans * 1.08); ans++) {
		}
		if (N == (int) Math.floor(ans * 1.08))
			System.out.println(ans);
		else
			System.out.println(":(");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	int n;
	while (cin>>n,n) {
		vector<int>as(n);
		for (int i = 0; i < n; i++) {
			cin >> as[i];
		}
		sort(as.begin(), as.end());
		vector<int>sas(n - 1);
		for (int i = 0; i < n - 1; i++) {
			sas[i] = abs(as[i + 1] - as[i]);
		}
		sort(sas.begin(), sas.end());
		cout << sas[0] << endl;
	}
}


Measured memory_bytes: 3160
H = int(input())
keys = list(map(int, input().split()))
for i in range(1, H+1):
    out = f'node {i}: key = {keys[i-1]}, '
    if i > 1:
        out += f'parent key = {keys[i // 2 - 1]}, '
    if 2 * i <= H:
        out += f'left key = {keys[2 * i - 1]}, '
    if 2 * i + 1 <= H:
        out += f'right key = {keys[2 * i]}, '
    print(out)


Measured memory_bytes: 5624
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
long long solve()
{
	long long n;cin>>n;
	std::vector<std::vector<bool>> inp;
	inp.resize(n,std::vector<bool>(n,0));
	REP(i,0,n-1){REP(j,0,n-1){bool tmp;cin>>tmp;inp[i][j]=tmp;}}
	long long lim=(1<<n);
	std::vector<std::vector<long long>> dp(n,std::vector<long long>(lim,0));
	REP(i,0,n-1)
	{
		if(inp[0][i])
		{
			dp[0][1<<i]=1;
		}
	}
	for (long long i = 1; i < n; ++i)
	{
		REP(mask,0,lim-1)
		{
			if(__builtin_popcount(mask)==(i+1))
			{
				REP(ix,0,n-1)
				{
					if((mask&(1<<ix))&&inp[i][ix]==1)
					{
						dp[i][mask]=((dp[i][mask]+dp[i-1][mask^(1<<ix)])%N);
					}
				}
			}
		}
	}
	cout<<dp[n-1][lim-1]<<"\n";
}
signed main(){
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 360832
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[105];

ll dp[105][4][2];

void solve()
{
    scanf("%s", str);
    int n=strlen(str);
    int K;
    scanf("%d", &K);

    dp[0][0][0]=1;
    int i,j,k;
    for(i=0; i<n; i++) {
        int tmp=str[i]-'0';
        for(j=0; j<=K; j++) {
            for(k=0; k<2; k++) {
                if(dp[i][j][k]) {
                    if(k==0) {
                        int j2=j+(tmp==0? 0: 1);
                        if(j2<=K) dp[i+1][j2][k]+=dp[i][j][k];

                        if(tmp>0) {
                            if(j+1<=K) dp[i+1][j+1][1]+=(tmp-1)*dp[i][j][k];
                            dp[i+1][j][1]+=dp[i][j][k];
                        }
                    }
                    else {
                        if(j+1<=K) dp[i+1][j+1][k]+=9*dp[i][j][k];
                        dp[i+1][j][k]+=dp[i][j][k];
                    }
                }
            }
        }
    }
    ll ans=0;
    for(k=0; k<2; k++) {
        ans+=dp[n][K][k];
    }
    //printf("%lld\n", ans/729);
    printf("%lld\n",ans);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128