akhauriyash/Code-Regression huggingface dataset:
import numpy as np
card = np.array([list(map(int,input().split())) for i in range(3)])
N = int(input())
nums = np.array([int(input()) for i in range(N)])

res = np.ones((3, 3), dtype=int)
for y in range(3):
    for x in range(3):
        if card[y, x] in nums:
            res[y, x] = 0

lis = [\
    np.multiply.reduce(res.sum(axis=0)), \
    np.multiply.reduce(res.sum(axis=1)), \
    np.trace(res),\
    np.trace(np.rot90(res.T))]
print("Yes" if 0 in lis else "No")

Measured memory_bytes: 21572
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
char str[205][205];
int dist[205];
int main(){
	scanf("%d",&n);
	rep(i,n) scanf("%s",&str[i]);
	int ans = 0;
	rep(i,n){
		fill(dist,dist+205,INF);
		dist[i] = 0;
		priority_queue<P,vector<P>,greater<P>>que;
		que.push(mp(0,i));
		while(!que.empty()){
			P p = que.top(); que.pop();
			if(dist[p.sc] != p.fi) continue;
			rep(j,n){
				if(str[p.sc][j] == '1' && dist[j] > p.fi+1){
					dist[j] = p.fi+1;
					que.push(mp(dist[j],j));
				}
			}
		}
		
		rep(j,n) rep(k,n){
			if(str[j][k] == '0') continue;
			if(dist[j]%2 == dist[k]%2){
				puts("-1");
				return 0;
			}
		}
		rep(i,n) ans = max(ans,dist[i]);
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(30):
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] = a[i]//2
            if i == n-1:
                ans += 1
        else:
            break
        
print(ans)

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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

map<long, long> d;

long pot2(long n)
{
    if (d.count(n)) return d[n];
    if (n == 0) return 1;
    if (n == 1) return 2;
    d[n] = ((pot2(n/2) % MOD) * (pot2((n+1) / 2) % MOD)) % MOD;
    return d[n];
}

long inv(long x)
{
    long k = MOD - 2;
    long pot = x;
    long y = 1;
    while (k > 0) {
        if (k & 1) y = (y * pot) % MOD;
        pot = (pot * pot) % MOD;
        k >>= 1;
    }
    return y;
}

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n, a, b;
        cin >> n >> a >> b;

        long ans = pot2(n) - 1;
        long aux = 1;
        for (long i = n-a+1; i <= n; i++) {
            aux = (aux * i) % MOD;
        }
        for (long i = 1; i <= a; i++) {
            aux = (aux * inv(i)) % MOD;
        }
        ans = (ans - aux) % MOD;
        aux = 1;
        for (long i = n-b+1; i <= n; i++) {
            aux = (aux * i) % MOD;
        }
        for (long i = 1; i <= b; i++) {
            aux = (aux * inv(i)) % MOD;
        }
        ans = (ans - aux) % MOD;
        if (ans < 0) ans = (ans + MOD) % MOD;
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int n;
	vector<ll> l = { 2, 1 };
	cin >> n;
	rep(i, n - 1) {
		l.push_back(l[i] + l[i + 1]);
	}
	cout << l[n] << endl;
}

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


common = make_divisors(N)
summer = 0
for i in common:
    cd = N // i - 1
    if cd != 0:
        if N % cd == N // cd:
            summer += cd

print(summer)


Measured memory_bytes: 3268
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

#define ll long long
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());

    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,i,j;
cin>>n;
ll dp[n][3]={0},arr[n][3];
for(i=0;i<n;i++)
cin>>arr[i][0]>>arr[i][1]>>arr[i][2];


dp[0][0]=arr[0][0];dp[0][1]=arr[0][1];dp[0][2]=arr[0][2];
for(i=1;i<n;i++)
{
dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);


dp[i][1]=max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);


dp[i][2]=max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);

}
//for(i=0;i<n;i++)
//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;

  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
A = [input() for i in range(H)]
count = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            count +=1

queue = [(0, 0, 1)]
depth = 0
while queue:
    q = queue.pop(0)
    depth = max(depth, q[2])
    if A[q[0]][q[1]] == ".":
        continue
    if (q[0], q[1]) == (H-1, W-1):
        break
    if(q[0]+1 < H):
        queue.append((q[0]+1, q[1], q[2]+1))
    if(q[1]+1 < W):
        queue.append((q[0], q[1]+1, q[2]+1))

print("Possible" if depth==count else "Impossible")
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

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

int N, M; cin >> N >> M;
VI a(M), c2(M, 0); //i 番目の鍵で　0bc2[i] の宝箱が開く
rep(i, 0, M){
    int b;
    cin >> a[i] >> b;
    rep(j, 0, b){
        int c; cin >> c;
        c2[i] |= (1 << (c-1));
    } 
}

// cost[key][opend] = key 個目までの鍵で、0b(opend)を開ける最小コスト
// opend は2進数N桁
VVI cost(M+1, VI(1LL<<N, INF));
rep(i, 0, M){
    cost[i][0] = 0;
    rep(j, 0, 1LL<<N){
        cost[i+1][j | c2[i]] = min(cost[i+1][j | c2[i]], cost[i][j] + a[i]);
        cost[i+1][j] = min(cost[i+1][j], cost[i][j]);
    }
}

if (cost[M][(1LL<<N)-1] < INF)
    cout << cost[M][(1LL<<N)-1] <<"\n";
else 
    cout << "-1\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  VI cnt(40), v(40);
  REP(i, n) {
    int b = a[i], idx = 0;
    bool first = true;
    while(b) {
      if(b%2) {
        cnt[idx]++;
        if(first) {
          v[idx]++;
          first = false;
        }
      }
      b/=2, idx++;
    }
  }

  int ret = 0;
  for(int i=39; i>=0; --i) {
    if((cnt[i]+ret)%2) {
      if(v[i]) ret++;
      else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>

using namespace std;

typedef long long ll;

const ll INF=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;}

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    int N,M,C,count=0;
    cin >>N>>M>>C;
    int B[M];
    int A[N][M];
    for(int i=0;i<M;i++){
        cin>>B[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    rep(i,N){
        int sum=C;
        rep(j,M){
            sum+=A[i][j]*B[j];
        }
        if(sum>0) count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    string str;
    for (int i = 0; i < n; i++){
        str += s.at(i);
        str += t.at(i);
    }

    cout << str << endl;
}

Measured memory_bytes: 256
class KochCurve
  def solve
    n = gets.chomp.to_i
    ans = koch(Point.new(0.0,0.0), Point.new(100.0,0.0), n)
    ans.map! do |x|
      x.to_s
    end
    return ans
  end
  def koch(pl, pr, n)
    if n == 0
      [pl, pr]
    else
      p1 = Point.new((2 * pl.x + pr.x) / 3.0, (2 * pl.y + pr.y) / 3.0)
      p2 = Point.new((pl.x + 2 * pr.x) / 3.0, (pl.y + 2 * pr.y) / 3.0)
      p3 = Point.new((pl.x + pr.x) / 2.0 - Math.sqrt(3) * (pr.y - pl.y) / 6.0 ,(pl.y + pr.y) / 2.0 + Math.sqrt(3) * (pr.x - pl.x) / 6.0)

      a1 = koch(pl, p1, n - 1)
      a2 = koch(p1, p3, n - 1)
      a3 = koch(p3, p2, n - 1)
      a4 = koch(p2, pr, n - 1)
      a1.pop
      a2.pop
      a3.pop
      a1 + a2 + a3 + a4
    end
  end
end

class Point
  attr_accessor :x, :y
  def initialize(x=0, y=0)
    @x = x
    @y = y
  end
  def to_s
    return "#{@x} #{@y}"
  end
end
if $0 == __FILE__
  puts KochCurve.new.solve
end

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

void solve(){

	int a,b,c ;
	cin>>a>>b>>c ;

	priority_queue<int,vector<int>,greater<int>> q ;

	q.push(a) ;
	q.push(b) ;
	q.push(c) ;

	int prod=1 ;

	for(int i=0;i<2;i++){

		prod*=q.top() ;
		q.pop() ;

	}

	cout<<prod/2 ;

}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3608
#include<stdio.h>
int main() {

	int n, i, j, x, count = 0;

	scanf("%d", &n);

	if (n % 2 == 0)
		x = n / 2 - 1;
	else
		x = n / 2;


	for (i = 2; i <= x; i++) {
		for (j = 2; i * j < n; j++) {
			count++;
		}
	}

	count += (n - 1) * 2 - 1;

	printf("%d", count);

	return 0;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  int p[50];
  REP(i, n)
  {
    cin >> p[i];
  }

  int c = 0;
  REP(i, n)
  {
    if (i + 1 != p[i])
    {
      c++;
    }
  }
  if (c <= 2)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n,m,c;
int a[100][100];
int b[100];

int main(){
  cin >> n >> m >>c;
  rep(i,0,m)cin >> b[i];
  int ans =0;
  rep(i,0,n){
    int temp = 0;
    rep(j,0,m){
      cin >> a[i][j];
      temp += a[i][j]*b[j];
    }
    if(temp+c > 0)ans++;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;
int solve(int e)
{
    int minsum=10000000;
    for(int z=0;z*z*z<=e;z++)
    {
        for(int y=0,lim=e-z*z*z;y*y<=lim;y++)
        {
            int x=e-y*y-z*z*z;
            if(minsum>x+y+z)
            {
                minsum=x+y+z;
            }
        }
    }
    return minsum;
}
int main(void)
{
    int e;
    while(scanf("%d",&e)==1 && e)
    {
        printf("%d\n",solve(e));
    }
    return 0;
}

Measured memory_bytes: 1028
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        String t = scanner.next();
        for (int i = 0; i < s.length(); i++) {
            s = s.charAt(s.length() - 1) + s.substring(0, s.length() - 1);
            if (s.equals(t)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    set<ll> st;
    rep(i,3){
        ll s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y;
  y = x->p;
  while(y !=NIL && x == y->right){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->p = y->p;

  if(y->p == NIL) root = x;
  else if(y == y->p->left) y->p->left = x;
  else y->p->right = x;

  if(y != z) z->key = y->key;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u)
{
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  else return;
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
  else return;
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20484
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

// UnionFind
struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
 
    bool unite(int x, int y) {//要素xとyの各々の木を併合（もともと同じ木ならfalse）
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {//要素kが属する木の根を得る
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {//要素kが属する木の要素数
        return (-data[find(k)]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

};

int main(){
    int N,M;
    cin>>N>>M;
    vector<vector<int>> vec(M);
    UnionFind tree(N);

    REP(i,N){
        int K;
        cin>>K;
        REP(j,K){
            int L;
            cin>>L;
            L--;
            vec[L].push_back(i);
        }
    }

    
    REP(i,M){
        REP(j,vec[i].size()){
            tree.unite(vec[i][0],vec[i][j]);
        }
    }

    int ne=tree.find(0);
    bool ok=true;
    REP(i,N){
        if(tree.find(i)!=ne) ok=false;
    }

    if(ok){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main() {

  int N;
  cin >> N;

  vector<int> A(N), B(N), C(N - 1);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  for (int i = 0; i < N - 1; i++) cin >> C.at(i);

  int ans = 0;

  for (int i = 0; i < N; i++) {
    ans += B.at(i);
  }

  for (int i = 1; i < N; i++) {
    if (A.at(i) - A.at(i - 1) == 1) {
      ans += C.at(A.at(i) - 2);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  for(int l=0; l<W+2 ;l++){cout << "#";}
  cout << endl;
  
  for(int i=0; i<H ; i++){
    vector <string> vec(H);
    cin >> vec.at(i);
    cout << "#"<< vec.at(i) << "#" <<endl;}
  
  for(int p=0; p<W+2 ;p++){cout << "#";}
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())

anslist=[]

for i in range(0,2*max(X,Y)+1,2):
    ans=C*i
    if X>i//2:
        ans=ans+A*(X-i//2)
    if Y>i//2:
        ans=ans+B*(Y-i//2)
    anslist.append(ans)
print(min(anslist))
    

Measured memory_bytes: 12708
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

double dp[3004][3004];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<double>v;
    v.push_back(0);
    for(int i=1;i<=n;i++){
        double s;
        cin>>s;
        v.push_back(s);
    }
    dp[1][0]=v[1];
    dp[1][1]=1-v[1];
    for(int i=2;i<=n;i++){
        for(int j=0;j<=n/2;j++){
            if(j==0)dp[i][j]=dp[i-1][j]*v[i];
            else if(j>=i+1)break;
            else{dp[i][j]=dp[i-1][j]*v[i]+dp[i-1][j-1]*(1-v[i]);}
        }
    }
    double res=0;
    cout.precision(20);
    for(int j=0;j<=n/2;j++){
        res+=dp[n][j];
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 68736
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    vector<pair<double, string> >data(n);
    for(int i = 0; i < n; i++){
        cin >> data.at(i).first >> data.at(i).second;
    }
    double ans = 0;
    for(int i = 0; i < n; i++){
        if(data.at(i).second == "JPY"){
            ans += data.at(i).first;
        }
        else{
            ans += (data.at(i).first * 380000);
        }
    }
    cout << ans << endl;
    solve();
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] count = new int[N + 1];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            count[A[i]]++;
        }
        long sum = 0;
        for (int i = 0; i <= N; i++)
            sum += (long)count[i] * (count[i]-1) / 2;
        for (int i = 0; i < N; i++)
            System.out.println(sum - count[A[i]] + 1);
    }
}


Measured memory_bytes: 93784
S = input()

def paint(str_num, S):
    cnt = 0
    temp = int(str_num)
    for i in range(len(S)):
        if int(S[-1-i]) == temp:
            temp = (temp+1)%2
        else:
            cnt += 1
            temp = (temp+1)%2
    return cnt
            
print(min(paint("0", S),paint("1", S)))

Measured memory_bytes: 3188
function Main(input) {
  // inputにはすべての入力の文字列が与えられるので必要に応じて input.split("\n") などで分割する。
  const data = input.split("\n");
  const fLine = data[0].split(" ");
  const sLine = data[1].split(' ');

  const sum = sLine.map(v => parseInt(v)).reduce((acc, cur) => acc + cur, 0);
  if(sum >= fLine[0]){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 200005
ll ar[N];
map<ll,ll> f1,f2;
int main(){
	FIO;
	int n;
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> ar[i];
        f1[i-ar[i]]++;
        f2[ar[i]+i]++;
    }
    ll ans = 0;
    for(auto v : f1){
        ans += 1ll*v.second*f2[v.first];
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39500
#include <string>
#include <iostream>
#include <stdio.h>

using namespace std;

int main ( int argc, const char * argv[] )
{
    int n;
    int num_candy = 0;
    cin >> n;
    if (n > 100 || n < 1){
        cout << 0 << "\n";
        return 1;}
    int i;
    for (i = 1; i <= n; i++)
    {
        num_candy += i;
    }
    cout << num_candy << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define NIL -1

using namespace std;

typedef struct {int parent,left,right;} Node;

Node T[25];

void prewalk(int id){
    if(id == NIL) return;
    cout << " " << id;
    prewalk(T[id].left);
    prewalk(T[id].right);
}

void inwalk(int id){
    if(id == NIL) return;
    inwalk(T[id].left);
    cout << " " << id;
    inwalk(T[id].right);
}

void postwalk(int id){
    if(id == NIL) return;
    postwalk(T[id].left);
    postwalk(T[id].right);
    cout << " " << id;
}

int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }
    for (int i = 0; i < N; i++) {
        int p,l,r;
        cin >> p >> l >> r;
        T[p].left = l;
        T[p].right = r;
        
        if (l != NIL) T[l].parent = p;
        if (r != NIL) T[r].parent = p;
    }
    int root=0;
    while (T[root].parent != NIL) {
        root = T[root].parent;
    }
    
    cout << "Preorder\n";
    prewalk(root);
    cout << endl;
    cout << "Inorder\n";
    inwalk(root);
    cout << endl;
    cout << "Postorder\n";
    postwalk(root);
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

int f(string s, int num){
    int ret = 0;
    int n = s.size();
    int t = 0;
    rep(i,n){
        if(isdigit(s[i])){
            t *= 10;
            t += s[i]-'0';
        }else if(s[i] == '('){
            int tmp = 0;
            int nxt;
            loop(j,i,n){
                if(s[j] == '(')tmp++;
                if(s[j] == ')'){
                    tmp--;
                    if(tmp == 0){
                        nxt = j;
                        break;
                    }
                }
            }
            int c = f(s.substr(i+1,nxt-i-1),num-ret);
            if(c >= 0)return c;
            c *= -1;
            if(num-ret <= c*t) return f(s.substr(i+1,nxt-i-1), (num-ret-1)%c+1);
            ret += c*t;
            t = 0;
            i = nxt;
        }else if(s[i] >= 'A' && s[i] <= 'Z'){
            if(t == 0)t++;
            ret += t;
            if(num <= ret)return s[i]-'A';
            t = 0;
        }
    }
    return -ret;
}

signed main(void) {
    string s;
    int n;
    while(cin >> s >> n, s != "0"){
        int ret = f(s,n+1);
        if(ret < 0)cout << 0 << endl;
        else cout << char('A'+ret) << endl;
    }
}



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

int trump[4][13];
int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        char ch;
        int x;
        cin >> ch >> x;
        if (ch == 'S') trump[0][x - 1]++;
        else if (ch == 'H') trump[1][x - 1]++;
        else if (ch == 'C') trump[2][x - 1]++;
        else trump[3][x - 1]++;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (!trump[i][j]) {
                if (i == 0) cout << "S " << j + 1 << endl;
                else if (i == 1) cout << "H " << j + 1 << endl;
                else if (i == 2) cout << "C " << j + 1 << endl;
                else cout << "D " << j + 1 << endl;
            }
        }
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    vector<long long> a(5);
    cin >> N;
    long long tmp = 1e18, index;
    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
        if (a[i] < tmp) {
            tmp = a[i];
            index = i;
        }
    }
    long long ans = (N + tmp - 1) / tmp + 4;
    cout << ans;
    return 0;
}



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

n = int(input())
a = []
b = []
b2 = []
c = []
count = 0
max = 0

for i in range(n):
    x,y = list(map(int,input().split()))
    a.append([x,y,x+y])

a.sort(key=lambda x: x[2])

for i in a:
    if max != 0 and i[0]-i[1] < max:
        count += 1
    else:
        max = i[2]
    
print(n - count)

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

int main() {
  int sum = 0;
  int count = 0;
  vector<pair<int, int>> v(5);
  for(int i=0; i<5; i++) {
    int a;
    cin >> a;
    sum += a;
    if(a%10 == 0) count++;
    v[i] = make_pair(a%10, a);
  }
  sort(v.rbegin(), v.rend());
  
  for(int i=0; i<4-count; i++) {
    int x;
    tie(x, ignore) = v[i];
    sum += 10-x;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    map<int,int> cnt;
    REP(i,N){
        int a; cin>>a;
        cnt[a]++;
    }
    
    int ans=0;
    for(auto p:cnt){
        int x=p.first,num=p.second;
        if(num<x) ans+=num;
        else ans+=num-x;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 6272
/**
 * Author RDP
 * 
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#define endl '\n'
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0);
typedef long long ll;
using namespace std;

void test_case()
{
    FAST_IO
    double r;
    cin >> r;
    cout <<6.28318 * r <<endl;
    return ;
}
int main()
{
    FAST_IO
    test_case();
    return 0;
}

Measured memory_bytes: 3800
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            h[i] = sc.nextInt();
        }
        int[] dp = new int[n + 1];
        dp[0] = 1000000000;
        for (int i = 2; i <= n; i++) {
            dp[i] = Math.min(dp[i - 1] + Math.abs(h[i - 1] - h[i]), dp[i - 2] + Math.abs(h[i - 2] - h[i]));
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 51200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(long double, L);
  printf("%.12Lf", (L / 3) * (L / 3) * (L / 3));
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const ll M = 1000000000000000000;
int main()
{
    string s, t;
    cin >> s >> t;
    int size = s.size();

    int ans = 0;
    rep(i, size)
    {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3844
class Node:
    def __init__(self):
        self.par = self
        self.rank = 1

class Utree:
    def __init__(self, n):
        self.nodes = [Node() for i in range(n)]

    def root(self, x):
        if x.par is x:
            return x
        else:
            r = self.root(x.par)
            x.par = r
            return r

    def unite(self, x, y):
        xr = self.root(self.nodes[x])
        yr = self.root(self.nodes[y])
        if xr.rank < yr.rank:
            xr.par = yr
            yr.rank += xr.rank
        else:
            yr.par = xr
            xr.rank += yr.rank


    def same(self, x, y):
        return self.root(self.nodes[x]) is self.root(self.nodes[y])



(n, q) = map(int, input().split())
ut = Utree(n)
for i in range(q):
    (c, x, y) = map(int, input().split())
    if c==0:
        ut.unite(x, y)
    else:
        print(1 if ut.same(x, y) else 0)

Measured memory_bytes: 9468
#include<iostream>
using namespace std;
int main(){
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  bool flag = false;
  if(x+x==w && y+y==h)flag=true;
  cout << (double)w * h * 0.5 << " " <<  (flag?"1":"0") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, m, q;
vector<int> a(q), b(q), c(q), d(q);
int ans;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  const ll answer = (K % 2 == 0) ? A - B : B - A;
  if (abs(answer) > 1'000'000'000'000'000'000ll) {
    cout << "Unfair" << endl;
  } else {
    cout << answer << endl;
  }
  return 0;
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();
		
		int A, I;
		if (H < W) {
			A = W;
			I = H;
		}else {
			A = H;
			I = W;
		}
		
			
		for(int i = 1; i<=I;i++) {
			int B = i*A;
			if (B >= N) {
				System.out.print(i);
				break;
			}
		} 
		sc.close();
 
	}
}

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

int main(){
    string s, t;
    cin >> s >> t;
    size_t n = s.size();
    ll cnt = 0;
    rep(i,n){
        if(s[i]!=t[i]) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3844
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]

def check(m):
    tmp=0
    for i in range(n):
        if (h[i]-b*m)/(a-b)>0:
            tmp+=math.ceil((h[i]-b*m)/(a-b))
    if tmp<=m:
        return True
    else:
        return False

low=0
high=max(h)
while high-low>1:
    mid=(low+high)//2
    if check(mid):
        high=mid
    else:
        low=mid
    # print(low)
    # print(high)
print(high)

Measured memory_bytes: 44252
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a) for (int i = 0; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 300;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    vs s(n);
    in(s);

    vii dp(n, vi(m, 0));
    dp[0][0] = 1;

    for (int j = 1; j < n; ++j) {
        if (s[j][0] == '#') break;
        dp[j][0] = 1;
    }

    for (int j = 1; j < m; ++j) {
        if (s[0][j] == '#') break;
        dp[0][j] = 1;
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            if (s[i][j] == '#') continue;

            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n - 1][m - 1];
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    string s, t;
    int cnt=0;
    cin >> s >> t;
    for(int i=0; i < s.length(); i++)
    {
        if(s[i] == t[i])
            cnt++;
    }
    cout << cnt;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by oka on 2018/06/10.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] temp = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
        List<Integer> list = new ArrayList<Integer>();
        ConcurrentHashMap map = new ConcurrentHashMap();
        for (int i = 0; i < 12; i++) {
            if (temp[i] <= n) {
                if (n == temp[i]) {
                    System.out.println(1);
                    return;
                }
                list.add(temp[i]);
                map.put(temp[i], true);
            }
        }

        int retCounter = 1;
        while (true) {
            retCounter++;
            List<Integer> tmp = new ArrayList<Integer>();
            synchronized (map) {
                for (Iterator<Integer> i = map.keySet().iterator(); i.hasNext(); ) {
                    tmp.add(i.next());
                }
                for (int key: tmp) {
                    map.remove(key);
                    for (int j = 0; j < list.size(); j++) {
                        int newKey = key + list.get(j);
                        if (newKey == n) {
                            System.out.println(retCounter);
                            return;
                        }
                        map.put(newKey, true);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 128300
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn main() {
    //println!("Hello, world!");
    
    let n: i32 = read(); //i32
    //println!("n = {}", n);

    let mut s = String::new();
    for _ in 0..n {
        s.push_str("ACL");
    }

    println!("{}", s);

}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    sort(all(s));
    if(s == "abc")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

no_flag = True

for i in range((N//4)+1):
    if no_flag == False:
        break
    for j in range((N//7)+1):
        if no_flag == False:
            break
        if (4*i+7*j) == N:
            print("Yes")
            no_flag = False
            
if no_flag == True:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int  mod = 1e9 + 7;
int main() {
	int n, m;
	cin >> n >> m; ll res = 0;
	vector<int>v(m); int f = 0;
	for (int i = 0; i < m; ++i) {
		int val; cin >> val; v[i] = val;
		res += val;
	}
	if (res > n)cout << -1;
	else {
		for (int ele : v) {
			n -= ele;
		}
		cout << n;
	}
	return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>

#define N 100
#define WHITE 0
#define BLACK 2
#define GRAY 1

int A[N][N],S[N],d[N],f[N],color[N];
int top=0,time,n;

void visit(int u){
  int i;
  
  color[u]=GRAY;
  d[u]=++time;
  for(i=0;i<n;i++){
    if(A[u][i]==0) continue;
    if(color[i]==WHITE) visit(i);
  }

  color[u]=BLACK;
  f[u]=++time;
}


int main(){
  int u,v,k,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }
  
  /*dfs*/
  for(i=0;i<n;i++){
    color[i]=WHITE;
  }

  time=0;

  for(i=0;i<n;i++){
    if(color[i]==WHITE) visit(i);
  }

  /*表示*/

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }

  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,now;
	string s,ans,res;
	cin>>n;
	rep(p,n){
		if(p==0)cin.ignore();
		getline(cin,s);
		ans=s[0];
		now=0;
		for(int i=1;i<s.size();i+=3){
			res=s[i];
			res+=s[i+1];
			if(res=="->"){
				if(now==ans.size()-1){
					ans+=s[i+2];
					now++;
				}else now++;
			}else{
				if(now==0){
					ans=s[i+2]+ans;
				}else now--;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


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

    int a,b;
    cin >> a >> b;
    if (a<=8 && b<=8) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;

}


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

ll N, x;
vector<ll> a;

int main() {
    cin >> N >> x; a.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &a[i]);

    ll ans = 0;
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }
    for (int i = 1; i < N; i++) {
        ll tempsum = a[i]+a[i-1];
        if (tempsum > x) {
            ans += tempsum - x;
            a[i] -= tempsum - x;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/*
    CCBESTGIRL
*/

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n , m;
    cin>>n>>m;
    int arr[n];
    int sum = 0;
    for(int i = 0 ; i<n ; i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    double val = (double)sum/(4 *m);
    int cnt = 0;
    for(int i = 0 ; i<n ; i++){
        if(arr[i]>=val){
            cnt++;
        }
    }
    if(cnt>=m){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }



    return 0;
}


Measured memory_bytes: 256