akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll xx = 0) : x(xx % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        mint r = 1;
        mint a = *this;
        while (true)
        {
            if (t & 1)
            {
                r *= a;
            }
            t >>= 1;
            if (t == 0)
                break;
            a *= a;
        }

        return r;
    }

    mint inv() const
    {
        return pow(p - 2);
    }

    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};
istream &operator>>(istream &is, mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

using vmint = vector<mint>;

int main()
{
    int n, k;
    cin >> n >> k;
    vmint as(n + 2), bs(n + 2);
    rep(i, n + 1) as[i + 1] = as[i] + (i);
    rep(i, n + 1) bs[i + 1] = bs[i] + (n - i);

    mint ans = 0;
    for (int i = k; i < n + 2; i++)
    {
        ans += bs[i] - as[i] + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6340
#include <cstdio>
#include <string>
using namespace std;

int main(){
  int n, k, i;
  double ans=0.0;
  scanf("%d %d",&n, &k);
  for(i=1; i<=n; i++){
    double tmp = 1.0;
    for(int j=i; j<k; j*=2){
      tmp *= 0.5;
    }
    ans += tmp;
  }
  ans /= (1.0*n);
  printf("%.10lf\n", ans);
  return 0;
}


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

int main() {
  int N, K, x, sum1=0, sum2=0, min=0;
  cin >> N >> K;
  int i=0;
  while(i<N){
    cin >> x;
    sum1=2*x;
    if(K>x)
      sum2=(K-x)*2;
    else
      sum2=(x-K)*2;
    if(sum1>=sum2)
      min+=sum2;
    else
      min+=sum1;
    i++;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


 
int main(){
    ll n,m; cin >> n >> m;
    vl kagi(m);
    vl kagicost(m);
    rep(i,m){
        ll a,b; cin >> a >> b;
        rep(j,b){
            ll c; cin >> c; c--;
            kagi[i] += 1<<c;
        }
        kagicost[i] = a;
    }
    vl dp(1<<(n+1),INF);
    dp[0] = 0;
    for(ll bit=0; bit<(1<<n); bit++){
        rep(i,m){
            ll s = kagi[i];
            dp[bit|s] = min(dp[bit|s], dp[bit] + kagicost[i]);
        }
    }
    if(dp[(1<<n)-1] != INF) cout << dp[(1<<n)-1] << endl;
    else puts("-1");
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_N 105
int vx [4]= {1,0,-1,0};
int vy [4]= {0,1,0,-1};
long long  dp[MAX_N][21]={};//dp[iテァツ閉ェテァツ崢ョテ」ツ?セテ」ツ?ァテ」ツ?ォ][テ・ツ?、]テッツシツ敕・ツ?凝ヲツ閉ー
int V[MAX_N],W[MAX_N];
int data[MAX_N],B[MAX_N];
int K ,N,a[MAX_N];
using namespace std;
void init(){

  /*cin >> N;
  cin >> a[1];
    dp[1][a[1]]=1;
  for(int l= 2;l<=N-1;l++){
    cin >> a[l];
    for(int i= 0;i<=20;i++){
      if(i-a[l]>=0&&i-a[l]<=20) dp[l][i] += dp[l-1][i-a[l]];
      if(i+a[l]>=0&&i+a[l]<=20) dp[l][i] += dp[l-1][i+a[l]];
    }
      //REP(i,21)cout<<l<<':'<< i<<' '<<dp[l-1][i]<<endl;
  }
  //REP(i,21)cout<< i<<' '<<dp[N-1][i]<<endl;
  cin >> a[N];
  cout << dp[N-1][a[N]]<<endl;
  */
}
void solve(){
  init();

}
int main(){
  REP(i,9)REP(j,9)cout << i+1<<'x'<<j+1<<'='<<(i+1)*(j+1)<<endl;
    solve();
}

Measured memory_bytes: 1124
n = int(input())

a = []
a = list(map(int, input().split()))

b = sorted(a, reverse=True) # reverse = Trueは降順
# print(b)
# print(b[0])

alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += b[i]
    else:
        bob += b[i]
dif = alice - bob
print(dif)


Measured memory_bytes: 3060
import math
import cmath
def cross_product(a,b):
    return (a.conjugate()*b).imag
L = []
n = int(input())
for i in range(n):
    x,y = map(int,input().split())
    L.append(complex(x,y))
S = 0
for i in range(1,n-1):
    a,b,c = L[0],L[i],L[i+1]
    S += cross_product(b-a,c-a)/2
print(S)


Measured memory_bytes: 5724
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, d[51];
    int usedNum[15] = {0};
    V v;

    int res = 0;

    cin >> n;
    REP(i, n)
    {
        cin >> d[i];

        if (usedNum[d[i]] == 0)
            v.push_back(d[i]);
        usedNum[d[i]]++;

        if (usedNum[d[i]] >= 3 - (d[i] == 12) - 2 * (d[i] == 0))
        {
            res = -1;
        }
    }

    if (res == -1)
    {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < (1 << v.size()); i++)
    {
        int r = INT_MAX;
        V c;

        c.push_back(0);

        REP(j, v.size())
        {
            if (usedNum[v[j]] == 2)
            {
                c.push_back(v[j]);
                c.push_back(24 - v[j]);
            }
            else
            {
                if (i & (1 << j))
                    c.push_back(v[j]);
                else
                    c.push_back(24 - v[j]);
            }
        }

        SORT(c);

        REP(j, c.size() - 1)
        {
            r = min(r, c[j + 1] - c[j]);
        }

        r = min(r, 24 - c[c.size() - 1]);

        res = max(r, res);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <math.h>
int main(void){
	int n,result = 0;
	double xa,ya,ra,xb,yb,rb,d;
	
	scanf("%d",&n);
	for(;n > 0;n--){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		d = sqrt(pow(xa-xb,2)+pow(ya-yb,2));
		if(ra+rb >= d){
			result = 1;
			if(ra+d < rb)result = -2;
		    if(rb+d < ra)result = 2;
		}
		else if(ra+rb < d)result = 0;

		printf("%d\n",result);
	}
	return 0;
}

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

int main(){
	int r,g,b;
  	cin >> r >> g >> b;
  
  	int judge = r * 100 + g * 10 + b;
  
  	if(judge % 4 == 0){
    	cout << "YES" << endl;
    }else{
    	cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import sys

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N=int(input())

if N==1:
    print(0)
    sys.exit()

A=factorization(N)

numlist=range(2,50)
sinsa=1
ans=0
for i in range(len(A)):
    beki=A[i][1]
    sosu=A[i][0]
    sinsa=1
    for j in range(1,beki+1):
        N=N/(sosu**j)
        ans+=1
        sinsa=sinsa+j+1
        if sinsa>beki:
            sinsa=1
            break
print(ans)

Measured memory_bytes: 9528
N,K=gets.split.map &:to_i
# 期待値の前計算
p=gets.split.map{|i|(i.to_f+1)*0.5}
# しゃくとり法・隣接するK項の和の計算
r=s=p[0..K-1].inject(:+)
(N-K).times do |i|
  r+=p[i+K]-p[i]
  s=[s,r].max
end
puts s


Measured memory_bytes: 18692
n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())
a.sort()
ans_array = [0 for i in range(n)]
#p0 <= p1 >= p2...
coef_1 = [0 for i in range(n)]
coef_1[0] = -1
#p0 >= p1 <= p2 ...
coef_2 = [0 for i in range(n)]
coef_2[0] = 1
index = 0
ans = 0
if n % 2 == 1:
    coef_1[-1] = -1
    coef_2[-1] = 1
else:
    coef_1[-1] = 1
    coef_2[-1] = -1
for i in range(1,n-1):
    if i % 2 == 1:
        coef_1[i] = 2
        coef_2[i] = -2
    else:
        coef_1[i] = -2
        coef_2[i] = 2
coef_2.sort()
coef_1.sort()
ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += coef_1[i]*a[i]
    ans2 += coef_2[i]*a[i]
print(max(ans1,ans2))

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

int main() {
	ios_base::sync_with_stdio( false );

	int64_t N, M;
	cin >> N >> M;

	int64_t result;
	if( N > M/2 ) {
		result = M/2;
	}
	else {
		result = N;
		M -= 2*N;

		result += M/4;
	}

	cout << result << endl;
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define pp pop_back
#define scan(t) scanf("%d",&t)
#define sscan(t) scanf("%lld",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define LL long long
#define ull unsigned long long
#define rock(cont) cont.begin(), cont.end()
#define roll(a,n) arr,arr+n
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define repp(i, n) for(int i=1 ; i<=n ; i++)
#define print(t) printf("%d",t)
#define pprint(t) printf("%lld",t)
#define co(x) cout<<x
#define nl printf("\n")
#define el cout<<endl
#define INF (int)1e9

const int RT = 10000000;

vector<int>prime;
vector<LL>factor;
bitset<10000003> status;



int gcd(LL a,LL b){ return b==0 ? a: gcd(b,a%b);}
int lcm(LL a,LL b) { return a* (b/gcd(a,b));}

vector<int> Divisors(int n)
{
    vector<int> v;
    int limit=sqrt(n);
    for (int i=1; i<=limit; i++)
    {
        if (n%i==0)
        {
            if (n/i == i)
                v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}

void sieve()
{
    int rt = sqrt(RT);
    //for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;

    prime.push_back(2);

    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

LL primefac(LL n)
{
    int pf_idx=0,pf=prime[pf_idx],SIZE=prime.size();
    LL ANS=1,step=0;
    while(pf*pf<=n&&pf<SIZE)
    {
        if(n%pf==0)
        {
            while(n%pf==0) {n/=pf;}
            ANS=pf;
            step++;
        }
        pf=prime[++pf_idx];
        //cout<<pf<<" "<<n<<" "<<ANS<<endl;
    }
    if(n!=1) { ANS=max(ANS,n); step++; }
    if(step>1)
    {
      return ANS;
    }
    else
    {
        return -1;
    }
}

int main()
{
    int n,num,sum=0;
    scan(n);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {

            for(int k=1;k<=n;k++)
            {
               num=__gcd(__gcd(i,j),k);
               //cout<<"i : "<<i<<" j : "<<j<<" k : "<<k<<endl;
               //cout<<"num : "<<num<<endl;
               sum+=num;
            }
        }
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cout << #x << " " << x << "\n"; cout.flush();
#define debugtwo(x) cout << #x << "-------------" << "\n";for(auto &it: x) cout << it << " ";cout << "\n"; cout.flush();
#define debugthree(x, i, j) cout << #x << "------------" << "\n";cout << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cout << x[k] << " ";cout << "\n"; cout.flush();



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
		
	int n;
	cin >> n;
	int cnt = 0;
	int maxi = -1;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		maxi = max(maxi, x);
		if(x == maxi){
			cnt++;
		}
	}

	cout << cnt << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final long MODVAL = 1000000007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(!isKaibun(S)) {
            System.out.println("No");
            return;
        }
        if(!isKaibun(S.substring(0, (S.length()-1)/2))) {
            System.out.println("No");
            return;
        }
        if(!isKaibun(S.substring((S.length()+3)/2 - 1, S.length()))) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
     }

     static boolean isKaibun(String S) {
//        System.out.println(S);
        for(int i=0; i<S.length(); i++) {
            if(S.charAt(i) != S.charAt(S.length()-1-i)) return false;
         }
        return true;
     }
}


Measured memory_bytes: 22868
function Main(input) {
  input = input.split("\n");
  const length = parseInt(input[0]);
  const str = input[1];
  if (length % 2 != 0) { 
    console.log('No');
    return
  }
  const isSame = str.substring(0, length / 2) === str.substring(length / 2);
  if (isSame) {
    console.log('Yes');
    return
  } else {
    console.log('No');
    return
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
N = int(input())

A = list(map(int, input().split()))

L = {0: 1}
Ans = 0
cnt = 0
for i in A:
  cnt += i
  if cnt in L:
    Ans += L[cnt]
    L[cnt] += 1
  else:
    L[cnt] = 1

print(Ans)

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

int main(){
  ll n;cin >> n;
  for(ll i=1;i<=n;++i){
    if( i*(i+1)/2 >= n ){//1〜iまでの和がn以上となる最初のi
      ll k = i*(i+1)/2 - n;//その和とnの差k
      for(ll j=1;j<=i;++j){
        if( j == k ) continue;
        cout << j << endl;
      }
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
N,Q=map(int,input().split())
S=input()

lis = [0] * len(S)
for i in range(len(S)):

  if i>0:
    lis[i] += lis[i-1]
  if i < len(S)-1 and S[i] == 'A' and S[i+1] == 'C':
    lis[i+1] += 1


for _ in range(Q):
  L = tuple(map(int, input().split()))

  c = 0
  print(lis[L[1]-1]-lis[L[0]-1])

Measured memory_bytes: 9772
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>
#include <bitset>

int main() {
	int n, max_weight; std::cin >> n >> max_weight;
	std::vector<std::vector<long long int>> memo(n + 1, std::vector<long long int>(3 * n + 1, LLONG_MIN));
	int w, v; std::cin >> w >> v;
	const long long initial = w;
	memo[0][0] = 0;
	memo[1][0] = v;
	for (auto i = 2; i <= n; ++i) {
		std::cin >> w >> v;
		w -= initial;
		for (auto j = i; j > 0; --j) {
			for (auto wi = 0; wi + w < memo[j].size(); ++wi) {
				if (memo[j - 1][wi] != LLONG_MIN && memo[j][wi + w] < memo[j - 1][wi] + v) {
					memo[j][wi + w] = memo[j - 1][wi] + v;
				}
			}
		}
	}
	long long int max = 0;
	for (auto i = 0; i < memo.size(); ++i) {
		for (auto j = 0; j < std::min(max_weight + 1 - initial * i, static_cast<long long int>(memo[i].size())); ++j) {
			if (max < memo[i][j]) max = memo[i][j];
		}
	}
	std::cout << max << std::endl;

}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
// #define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    cout.setf(ios::fixed); cout.precision(9);    
    solve();   
    return 0;
} 

void solve() {
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
}

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

int main(){
  string s,alpha = "abcdefghijklmnopqrstuvwxyz";
  int K;

  cin>>s>>K;


  for(int i=0;i<s.length();i++){
    if(26-(s[i]-'a')<=K){
      K-=(26-(s[i]-'a'))%26;
      s[i]='a';
    }else{
      continue;
    }
  }
  s[s.length()-1]=alpha[(s[s.length()-1]-'a'+K)%26];

  cout<<s<<endl;

  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int c[3][3];

int main() {
	inc(i, 3) {
	inc(j, 3) {
		cin >> c[i][j];
	}
	}
	
	bool f = true;
	inc(i, 2) {
	inc(j, 2) {
		if(c[i][j] + c[i + 1][j + 1] != c[i][j + 1] + c[i + 1][j]) { f = false; }
	}
	}
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
two_ad = 0
four_ad = 0
other = 0
for a in A:
  if a % 4 == 0:
    four_ad += 1
  elif a % 2 == 0:
    two_ad += 1
  else:
    other += 1

ans = "No"
if four_ad >= other:
  ans = "Yes"
elif four_ad == other - 1 and not two_ad:
  ans = "Yes"
print(ans)

Measured memory_bytes: 15020
def main():
    S=input()
    T=input()
    X=[]
    Y=[]
    flag=True
    for i in range(len(S)):
        al=False
        if T[i] in Y:
            al=True
            if X[Y.index(T[i])]!=S[i]:
                flag=False
                break
        if S[i] in X:
            al=True
            if Y[X.index(S[i])]!=T[i]:
                flag=False
                break
        if al==False:
            X.append(S[i])
            Y.append(T[i])
    if flag:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)

ll s;
map<ll,ll> mp;

int main(){

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

cin>>s;

ll a=s;
ll m=1;
mp[a]++;
while(1){
	if(a%2){
		a=3*a+1;
	}else{
		a=a/2;
	}
	m++;
	if(mp[a]) break;
	mp[a]++;
}

cout<<m<<endl;


}
	


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

int main() {
  
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  
  if(n > k) cout << k*x + (n-k) * y << endl;
  else cout << n*x << endl;
  
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int k, x; cin >> k >> x;
    for (int i = x - k +1; i <= x + k -1; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3560
#include<stdio.h>
 
int main(void){
  int A[5];
  scanf("%d %d %d %d %d",&A[0],&A[1],&A[2],&A[3],&A[4]);
  for(int i=0;i<5;i++){
    if(A[i]==0){
      printf("%d",i+1);
       break;
    }
  }
  
  return 0;
}

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

typedef long in; 

in dp[105][100005];

int main() 
{
    in n,c;
    cin>>n>>c;
    
    in v[n+1],w[n+1];
    
    for(in i=1;i<=n;i++)
    cin>>w[i]>>v[i];
    
    for(in i=1;i<=n;i++)
    {
        for(in j=0;j<=c;++j)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=w[i])
            {
                dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
            }
        }
    }
    
    cout<<dp[n][c];
		
	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    int cnt = 1;
    vector<int> c(n);
    int p = 0;
    c[a[0]]++;
    for (int i = 1; i < n; i++) {
        if (a[i-1] != a[i]) {
            p = i;
            c[a[p]]++;
            cnt++;
        } else {
            c[a[p]]++;
        }
    }
    if (cnt <= k) cout << 0 << endl;
    else {
        sort(c.begin(), c.end());
        int t = 0, count = 0;
        for (int i = n-1; i >= 0; i--) {
            if (count == k) break;
            t += c[i];
            count++;
        }
        cout << n-t << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - (K - 1); i <= X + (K - 1); i++) {
    cout << i << ' ';
  }
  cout << endl;
}

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

int selectionSort(int A[], int N){
  int number = 0;
  for(int i = 0; i < N; i++){
    int minj = i;
    for (int j = i+1; j < N; j++){
      if(A[j] < A[minj]) minj = j;
    }
    if (i!= minj){
      swap(A[i], A[minj]);
      number++;
    }
  }

  return number;
}

int main(){
  int A[100], N, number;

  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];

  number = selectionSort(A, N);
  
  for(int i = 0; i < N; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << number << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b;
  cin>>a>>b;
  if(a>=13) cout<<b<<endl;
  else if(a>=6) cout<<b/2<<endl;
  else cout<<0<<endl;
}



Measured memory_bytes: 256
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cstdio>
using namespace std;

template<typename T> class union_find{
	unordered_map<T,T> parent;
public:
	T root(T a){
		if(parent.find(a)==parent.end())parent[a]=a;
		return parent[a]==a?a:(parent[a]=root(parent[a]));
	}
	int same(T a,T b){return root(a)==root(b);}
	int unite(T a,T b){
		T x=root(a),y=root(b);if(x==y)return 0;
		parent[x]=y;
		return 1;
	}
	int size(){
		unordered_set<T>se;
		for(auto &e:parent)se.insert(root(e.first));
		return se.size();
	}
};

int main(){
	int n,i;
	vector<pair<int,int> >v(6);
	union_find<int>uf;
	unordered_map<int,int>cnt;
	int f=0;
	for(i=0;i<6;i++){
		scanf("%d%d",&v[i].first,&v[i].second);
		if(v[i].first>v[i].second)swap(v[i].first,v[i].second);
		uf.unite(v[i].first,v[i].second);
		cnt[v[i].first]++;
		cnt[v[i].second]++;
	}
	sort(v.begin(),v.end());
	puts(all_of(cnt.begin(),cnt.end(),[](auto &a){return a.second%4==0;}) && uf.size()==1 && v[0]==v[1] && v[2]==v[3] && v[4]==v[5] ? "yes" : "no");
}

Measured memory_bytes: 2696
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;
ll p[1010];
int main(){
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        cin>>p[i];
    }
    sort(p,p+N);
    ll sum=0;
    for(ll i=0;i<K;i++){
        sum+=p[i];
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R;
  cin >> R;
  if ( R < 1200)
  {
    cout << "ABC" << endl;
  }
  else if ( R >= 1200  && R < 2800) {  
    cout << "ARC" << endl;
  }
  else  { 
    cout << "AGC" << endl;
}
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;
typedef pair<int, int> P;

int h, w, n;
P goal[10];
char map[1000][1000];
int dis[1000][1000];
const int vx[4] = { 1,0,-1,0 };
const int vy[4] = { 0,1,0,-1 };

int bfs(P start, P goal) {
	int ans = 0;
	queue<P> q;
	q.push(start);
	while (q.size()) {
		P tmp = q.front();
		q.pop();
		if (tmp == goal) {
			ans = dis[tmp.first][tmp.second];
			break;
		}
		for (int i = 0; i < 4; i++) {
			int fx = tmp.first + vx[i], fy = tmp.second + vy[i];
			if (fx < 0 || fy < 0 || fx >= h || fy >= w)continue;
			if (!dis[fx][fy] && start != make_pair(fx, fy) && map[fx][fy] != 'X') {
				dis[fx][fy] = dis[tmp.first][tmp.second] + 1;
				q.push(make_pair(fx, fy));
			}
		}
	}
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)dis[i][j] = 0;
	return ans;
}

int main() {
	cin >> h >> w >> n;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> map[i][j];
			if (map[i][j] == 'S')goal[0] = make_pair(i, j);
			if (map[i][j] > '0' & map[i][j] <= '9') {
				goal[map[i][j] - '0'] = make_pair(i, j);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += bfs(goal[i], goal[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7956
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define N 300010
#define ls (x << 1)
#define rs (x << 1 | 1)
using namespace std;

int x[N], y[N], list[N * 3], cnt;
int w, h, n, ans;

struct node {
	int val, lab;
}tr[N << 4];

inline void update(int x) {
	tr[x].val = max(tr[ls].val, tr[rs].val);
}

void build(int x, int l, int r) {
	tr[x].val = tr[x].lab = 0;
	if (l == r) {
		tr[x].val = -list[l - 1];
		return;
	}
	int mid = l + r >> 1;
	build(ls, l, mid);
	build(rs, mid + 1, r);
	update(x);
}

inline void push_down(int x) {
	if (!tr[x].lab) return;
	tr[ls].lab += tr[x].lab;
	tr[ls].val += tr[x].lab;
	tr[rs].lab += tr[x].lab;
	tr[rs].val += tr[x].lab;
	tr[x].lab = 0;
}

void modify(int x, int l, int r, int a, int b, int ad) {
	if (a <= l && r <= b) {
		tr[x].lab += ad;
		tr[x].val += ad;
		return;
	}
	push_down(x);
	int mid = l + r >> 1;
	if (a <= mid) modify(ls, l, mid, a, b, ad);
	if (b > mid) modify(rs, mid + 1, r, a, b, ad);
	update(x);
}

inline int queryMax() {
	return tr[1].val;
}

int s[2][N * 3], top[2];
int bound[N * 3][2];
void solve(int mid) {
//cout << endl;
	cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (0 < y[i] && y[i] < h) list[++cnt] = y[i];
		if (1 < y[i] && y[i] < h + 1) list[++cnt] = y[i] - 1;
		if (-1 < y[i] && y[i] < h - 1) list[++cnt] = y[i] + 1;
	}
	list[++cnt] = 1;
	list[++cnt] = h - 1;
	sort(list + 1, list + cnt + 1);
	cnt = unique(list + 1, list + cnt + 1) - list - 1;
	
	build(1, 1, cnt);
	
	for (int i = 1; i <= cnt; ++i) {
		bound[i][0] = mid;
		bound[i][1] = w - mid;
	}
	
	for (int i = 1; i <= n; ++i) {
		if (0 < y[i] && y[i] < h) {
			int p = lower_bound(list + 1, list + cnt + 1, y[i]) - list;
			if (x[i] <= mid) bound[p][0] = min(bound[p][0], mid - x[i]);
			else bound[p][1] = min(bound[p][1], x[i] - mid);
		}
	}
	
	top[0] = top[1] = 0;
	for (int i = 1; i <= cnt; ++i) {
//cout << "-------------" << endl;
//cout << list[i] << ' ' << bound[i][0] << ' ' << bound[i][1] << endl;		
		for (int k = 0; k < 2; ++k) {
			modify(1, 1, cnt, i, i, bound[i][k]);
			while (top[k] && bound[s[k][top[k]]][k] > bound[i][k]) {
				int l = s[k][top[k] - 1] + 1;
				int r = s[k][top[k]];
				modify(1, 1, cnt, l, r, bound[i][k] - bound[s[k][top[k]]][k]);
				top[k]--;
			}
			s[k][++top[k]] = i;
		}
		ans = max(ans, (queryMax() + list[i] + 1) * 2);
	}
}

int main() {
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &x[i], &y[i]);
	}
	if (w == 1 || h == 1) {
		printf("%d\n", (w + h) * 2);
		return 0;
	}
	solve(w / 2);
	for (int i = 1; i <= n; ++i) {
		swap(x[i], y[i]);
	}
	swap(w, h);
	solve(w / 2);
	printf("%d\n", max(ans, max(w, h) * 2 + 2));
	return 0;
}

Measured memory_bytes: 35200
n,m=map(int,input().split())
way=[[] for i in range(n)]
H = list(map(int,input().split()))
for i in range(m):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
ans=0
for i in range(n):
    high=True
    for j in way[i]:
        if H[i]<=H[j]:
            high=0
            break
    if high:
        ans+=1
print(ans)

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

ll findRoot(ll N) {
    ll root = pow(N, 0.5) + 1;
    return root;
}

int main() {
    ll N;
    cin >> N;
    // Nを二因数分解，そのパターン数総当たりする。
    // 横をi，縦をjとして，i^2+j^2が最小となるような分解パターンを見つける
    // (i-1)+(j-1)を出力

    ll rootN = findRoot(N);
    ll MIN = 1LL << 40;
    
    for (ll i = 1; i <= rootN; i++) {
        if (N % i == 0) {
            ll j = N/i;
            ll dist = i+j-2;
            if (dist < MIN) {
                MIN = dist;
            }
        }
    }

    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s: String = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (k, n) = {
        let mut ws = s.split_whitespace();
        let a: i64 = ws.next().unwrap().parse().unwrap();
        let b: i64 = ws.next().unwrap().parse().unwrap();
        (a, b)
    };
    let s: String = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let a_vec = {
        let mut ws = s.split_whitespace();
        let mut result = vec![];
        for _ in 0..n {
            let a: i64 = ws.next().unwrap().parse().unwrap();
            result.push(a);
        }
        result
    };

    let mut diff_vec = vec![];
    for index in 0..n as usize {
        if index != (n - 1) as usize {
            diff_vec.push((a_vec.get(index).unwrap() - a_vec.get(index + 1).unwrap()).abs());
        } else {
            diff_vec.push((a_vec.get(index).unwrap() - (a_vec.get(0).unwrap() + k)).abs());
        }
    }
    let max_v = diff_vec.iter().max().unwrap();
    println!("{}", k - max_v);
}


Measured memory_bytes: 13560
D,G = map( int,input().split() )
PC = [ list(map(int,input().split())) for i in range(D) ]
ans = 10**7

for i in range(D):
  score=0
  l=0
  for j in range(PC[i][0]-1):
    score += 100*(i+1)
    l += 1
    if score>=G and ans>l:
      ans=l

for i in range(1,2**D):
  score = 0
  l = 0
  for j,flag in enumerate( list(format(i,"b").zfill(D))[::-1] ):
    if flag=="1":
      score += PC[j][0]*100*(j+1) + PC[j][1]
      l += PC[j][0]
    else:
      k=j
    
  j=0
  while score<G and j<PC[k][0]-1:
    score+=100*(k+1)
    l+=1
    j+=1
  if score>=G and ans>l:
    ans=l
  
print(ans)

Measured memory_bytes: 42224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
//gcd O(log(min(a, b)))
long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
ll MOD = 1e9 + 7;
int main() {
    int n, m;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll s,p;
    s = gcd(a[0], a[1]);
    bool isS, isP;
    isS = false;
    isP = true;
    for (int i = 2; i < n; i++) {
        s = gcd(s, a[i]);
    }
    vector<ll>x(1e6 + 1, 0);
    rep(i, n) x[a[i]]++;
    for (ll i = 2; i <= 1e6; i++) {
        ll cnt = 0;
        for (ll j = i; j <= 1e6; j += i) {
            cnt += x[j];
        }
        if (cnt > 1) {
            isP = false;
            break;
        }
    }
    if (s == 1) {
        if (isP) {
            cout << "pairwise coprime" << endl;
        }else{
            cout << "setwise coprime" << endl;
        }
    }else{
        cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 18836
// Devarshi

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

bool cmp(pii a,pii b){
    return a.se>b.se;
}

int main(){

sync

/*
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
*/
    int n;
    cin>>n;
    int a[n];
    map<int,int> m;
    forn(i,n) cin>>a[i], m[a[i]]++;
    if(m.size()==1){
         cout<<n/2;
        return 0;
    }
    m.clear();
    map<int,int> m1;
    int tot1,tot2=n/2;
    if(n%2) tot1=n/2+1;
    else tot1=n/2;
    for(int i=0;i<n;i+=2){
        m[a[i]]++;
    }
    for(int i=1;i<n;i+=2){
        m1[a[i]]++;
    }
    int a1=0,b=0;
    int d1,d2;
    vpi v1,v2;
    for(auto it: m){
        v1.pb(mp(it.fi,it.se));
        if(a1<it.se){
            d1=it.fi;
        }
        a1=max(a1,it.se);
    }
    for(auto it:m1){
        v2.pb(mp(it.fi,it.se));
        if(b<it.se){
            d2=it.fi;
        }
        b=max(b,it.se);
    }
    sort(all(v1),cmp);
    sort(all(v2),cmp);
    //cout<<a<<" "<<b<<endl;
   // cout<<a1<<" "<<b<<endl;
   // cout<<d1<<endl<<d2<<endl;
    if(d1!=d2)
    cout<<tot1-a1+tot2-b;
    else{
      //  cout<<1<<endl;
        int ans1=tot1-a1+tot2-v2[1].se,ans2=tot1-v1[1].se+tot2-b;
        cout<<min(ans1,ans2);
    }
return 0;
}


Measured memory_bytes: 7672
import numpy as np

H, W = map(int, input().split())
a = [list(input()) for i in range(H)]
arr = np.array(a)

for i in reversed(range(arr.shape[0])):
    if not '#' in arr[i]:
        arr = np.delete(arr, i, 0)
        
for i in reversed(range(arr.shape[1])):
    if not '#' in arr[:,i]:
        arr = np.delete(arr, i, 1)

a = arr.tolist()

for i in range(len(a)):
    print(''.join(a[i]))

Measured memory_bytes: 12540
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
vector<int> es[114514];
 P fi[1145140];
signed main(){
    string s;cin>>s;
    rep(i,0,s.size()-1){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }if(s[i]==s[i+2]&&i<s.size()-2){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct Unionfind{
    vector<int> parent;
    void init(int forestSize){
        parent.resize(forestSize);
        for(int i=0;i<forestSize;i++){parent.at(i)=i;}
    }
    int root(int v){
        if(parent.at(v)==v){return v;}
        else{return parent.at(v)=root(parent.at(v));}
    }
    bool belong(int x,int y){
        if(root(x)==root(y)){return true;}
        else{return false;}
    }
    void unite(int x,int y){
        if(parent.at(x)!=parent.at(y)){parent.at(root(y))=root(x);}
    }
    /*
    Unionfind<int> rock;
    rock.init(N);
    */
};
int main(){
  int N,Q;
  cin>>N>>Q;
  Unionfind<int> rock;
  rock.init(N);
  for(int i=0;i<Q;i++){
    int a,x,y;
    cin>>a>>x>>y;
    if(a==0){
      rock.unite(x,y);
    }
    else{
      if(rock.belong(x,y)){cout<<1<<endl;}
      else{cout<<0<<endl;}
    }
  }
}

Measured memory_bytes: 3812
package main

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

func main() {
	sc := NewScanner()

	k := sc.ReadInt()

	modAppeared := make([]bool, k)

	pos := 1
	cur := 0
	var found bool
	for {
		cur = (cur*10 + 7) % k
		if cur == 0 {
			found = true
			break
		} else if modAppeared[cur] {
			found = false
			break
		}

		modAppeared[cur] = true
		pos++
	}

	if found {
		fmt.Println(pos)
	} else {
		fmt.Println(-1)
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 2804
# Node
class Node
  attr_accessor :id, :parent, :left, :right
 
  def initialize(id, parent = nil, left = nil, right = nil)
    @id, @parent, @left, @right = id, parent, left, right
  end
end
 
# BinaryTree
class BinaryTree
  attr_accessor :nodes
 
  def initialize(data)
    @nodes = data.each_with_object({}) do |(key, value), hash|
      hash[key] = Node.new(key, value[:parent], value[:left], value[:right])
    end
  end
 
  def depth(id)
    node = @nodes[id]
    unless node.parent.nil?
      return depth(node.parent) + 1
    else
      return 0
    end
  end
 
  def root?(id)
    node = @nodes[id]
    node.parent.nil?
  end
 
  def leaf?(id)
    children(id).empty?
  end
 
  def sibling(id)
    parent = @nodes[id].parent
    unless parent.nil?
      s = children(parent).select { |child| id != child }
      return s.any? ? s.shift : -1
    end
    -1
  end
 
  def degree(id)
    children(id).length
  end
 
  def height(id)
    c = children(id)
    unless c.empty?
      heights = []
      c.each do |child|
        heights << height(child) + 1
      end
      return heights.max
    else
      return 0
    end
  end
 
  private
 
  def children(id)
    node = @nodes[id]
    [node.left, node.right].select { |i| i != -1 }
  end
end
 
data = {}
parent = {}
 
n = gets.chop.to_i
 
n.times do
  id, left, right = gets.chop.split.map(&:to_i)
  data[id] = { :left => left, :right => right }
  parent[left] = parent[right] = id
end
 
data.each do |key, value|
  value[:parent] = parent[key]
end
 
data = Hash[data.sort]
 
t = BinaryTree.new(data)
 
t.nodes.each do |id, node|
  out = []
  out << "node #{id}: parent = " + (!node.parent.nil? ? node.parent : -1).to_s
  out << "sibling = " + t.sibling(id).to_s
  out << "degree = " + t.degree(id).to_s
  out << "depth = " + t.depth(id).to_s
  out << "height = " + t.height(id).to_s
  out << (t.root?(id) ? "root" : t.leaf?(id) ? "leaf" : "internal node").to_s
  puts out.join(', ')
end

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

using namespace std;

int N, W, w[100], v[100];
long long dp[110][100010];

int main(){
	cin >> N >> W;
	for(int i = 0; i < N; ++i) cin >> w[i] >> v[i];

	for(int i = 0; i < N; ++i){
		for(int j = 0; j <= W; ++j){
			if(j + w[i] <= W) dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
		}
	}

	cout << dp[N][W] << endl;
}

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

#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define int long long int
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define INF 200001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  (n >= 30) ? cout << "Yes\n" : cout << "No\n";
  return 0;
}

Measured memory_bytes: 3648