akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = a[0];
            var M = a[1];
            var sum = new int[M];

            for(var i=0; i<N; ++i)
            {
                var b = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var K = b[0];

                for (var j=0; j<K; ++j)
                {
                    sum[b[j + 1] - 1]++;
                }
            }

            var count = 0;
            for (var i = 0; i < M; ++i)
            {
                if (sum[i] == N)
                    count++;
            }

            Console.WriteLine(count);
        }
        
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(b%a==0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n, a, b = list(map(int, input().split()))
    x = list(map(int, input().split()))
    quantty = 0
    # ans = []
    for i in range(len(x)):
        if i == len(x) - 1:
            break
        quantty += min(a*(x[i+1] - x[i]), b)
        # ans.append(quantty)
    print(quantty)



if __name__ == '__main__':
    main()

Measured memory_bytes: 20116
from heapq import heappop, heappush
n, m = map(int, input().split())
d = []
for _ in range(n):
    a, b = map(int, input().split())
    d.append((m - a, b))
d.sort()
ans = 0
q = []
for i in range(m - 1, -1, -1):
    while d and d[-1][0] == i:
        heappush(q, -d.pop()[1])
    if q:
        ans -= heappop(q)
print(ans)


Measured memory_bytes: 17192
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    a += b;
    int c = stoi(a);
    for (int i = 1; i < 10000; i++) if (i * i == c) {cout << "Yes"; return 0;}
    cout << "No";
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r = read::<usize>();

    println!("{}", if r < 1200 { "ABC" } else if r < 2800 { "ARC" } else { "AGC" }.to_string());
}

Measured memory_bytes: 4352
#include <stdio.h>
         
        int main(void){
            int n;
            int a;
            int b;
         
           do{
                scanf("%d",&n);
           }while(n < 1 || n > 20);
         
           do{
               scanf("%d",&a);
           }while(a < 1 || a > 50);
         
           do{
               scanf("%d",&b);
           }while(b < 1 || b > 50);
         
           if((a*n) > b){
                printf("%d",b);
          		
           }else{
                printf("%d",a*n);
          		
           }
        }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;


int main() {
  ll n;
  cin >> n;
  vec a(n);
  ll s=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    s+=a[i];
  }
  ll cnt=0;
  ll d=n*(n+1)/2;
  if(s%d) {
    cout << "NO" << endl;
    return 0;
  }
  else {
    cnt=s/d;
  }
  vec b(n);
  for(ll i=0;i<n;i++) {
    b[(i+1)%n]=a[(i+1)%n]-a[i];
  }
  for(ll i=0;i<n;i++) {
    b[i]-=cnt;
  }
  ll f=0;
  for(ll i=0;i<n;i++) {
    if(b[i]%n||b[i]>0) {
      cout << "NO" << endl;
      return 0;
    }
    f-=b[i]/n;
  }
  if(f==cnt) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 4848
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    string s; cin >> s;

    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }

    int n = s.size();
    vector<bool> tukatta(26);
    for(int i = 0;i < n;i ++){
        tukatta.at(s.at(i)-'a') = true;
    }

    if(n < 26){
        int x = 0;
        for(;;x ++){
            if(tukatta.at(x) == false) break;
        }

        char t = 'a' + x;
        cout << s + t << endl;
        return 0;
    }

    vector<bool> tukatta2(26,false);
    tukatta2.at(s.at(25) - 'a') = true;

    for(int i = 24;i >= 0;i --){
        tukatta2.at(s.at(i) - 'a') = true;
        s.pop_back();
        for(int j = s.at(i) - 'a' + 1;j < 26;j ++){
            if(tukatta2.at(j) == true){
                s.pop_back();
                s.push_back('a' + j);

                cout << s << endl;
                return 0;

            }
        }
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CBigArray solver = new CBigArray();
        solver.solve(1, in, out);
        out.close();
    }

    static class CBigArray {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long k = in.nextLong();
            CBigArray.Pair[] pairs = new CBigArray.Pair[n];
            for (int i = 0; i < n; i++) {
                pairs[i] = new CBigArray.Pair(in.nextInt(), in.nextInt());
            }
            Arrays.sort(pairs);
            for (CBigArray.Pair p : pairs) {
                k -= p.b;
                if (k <= 0) {
                    out.println(p.a);
                    return;
                }
            }
        }

        private static class Pair implements Comparable<CBigArray.Pair> {
            int a;
            int b;

            public Pair(int a, int b) {
                this.a = a;
                this.b = b;
            }

            public int compareTo(CBigArray.Pair o) {
                return Integer.compare(this.a, o.a);
            }

        }

    }
}



Measured memory_bytes: 88312
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
using ll=long long;

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin>>N;
  ll A[N+1];
  memset(A,0,sizeof(A));
  for (int i=1; i<=N; i++) {
    cin>>A[i];
    A[i]+=A[i-1];
  }
  sort(A,A+N+1);
  ll ans=0;
  for (int i=0; i<=N; i++) {
    ll cnt=0;
    int I=i;
    for (int j=I; j<=N&&A[I]==A[j]; j++) {
      cnt++;
      i=j;
    }
    ans+=cnt*(cnt-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
N,*ABC = gets.split.map(&:to_i)
L = $<.map(&:to_i)

Mp = lambda{|abc|
	return Float::INFINITY if abc.any?{|x| x[1]<0 }
	return (0..2).inject(0){|a,i|
		a + (abc[i][0]-ABC[i]).abs + abc[i][1]*10
	}
}
min = Float::INFINITY
Join = lambda{|abc,i|
	abc.each_with_index{|x,j|
		x[0] += L[i]
		x[1] += 1
		mp = Mp[abc]
		min = mp if mp < min
		Join[abc,i+1] if i+1 < N
		x[0] -= L[i]
		x[1] -= 1
	}
	Join[abc,i+1] if i+1 < N
}

Join.call([[0,-1],[0,-1],[0,-1]], 0)
p min


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

int main()
{
    int a,b;
    cin >> a >> b;
    int num;
    int ans;
    num = b - a;

    for(int i =1; i < num; i++){
        ans += i;
    }
    
    cout << ans - a << endl;
    return 0;
}

Measured memory_bytes: 256
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    double d, t, s;
    cin >> d >> t >> s;
    double v = d / s;
    if(v<=t)
        cout << "Yes";
    else
        cout << "No";

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int h,w; cin>>h>>w;
  vector<string> s(h);
  for (int i=0; i<h; i++) {
    cin>>s[i];
  }
  vector<vector<int>> dl(h, vector<int>(w, 0));
  vector<vector<int>> dr(h, vector<int>(w, 0));
  vector<vector<int>> du(h, vector<int>(w, 0));
  vector<vector<int>> dd(h, vector<int>(w, 0));
  for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
    if (s[i][j] == '#') continue;
    if (j==0) dl[i][j] = 1;
    else dl[i][j] += dl[i][j-1]+1;
  }
  for (int i=0; i<h; i++) for (int j=w-1; j>=0; j--) {
    if (s[i][j] == '#') continue;
    if (j==w-1) dr[i][j] = 1;
    else dr[i][j] += dr[i][j+1]+1;
  }
  for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
    if (s[i][j] == '#') continue;
    if (i==0) du[i][j] = 1;
    else du[i][j] += du[i-1][j]+1;

  }
  for (int i=h-1; i>=0; i--) for (int j=0; j<w; j++) {
    if (s[i][j] == '#') continue;
    if (i==h-1) dd[i][j] = 1;
    else dd[i][j] += dd[i+1][j]+1;
  }
  int ans = 0;
  for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
    ans = max(ans, dl[i][j]+dr[i][j]+du[i][j]+dd[i][j]-3);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 69248
def min(a, b)
  a < b ? a : b
end

N, W = gets.chomp.split.map(&:to_i)
w = [] * N
v = [] * N
N.times do
  wi, vi = gets.chomp.split.map(&:to_i)
  w << wi
  v << vi
end

MAX_VALUE = v.inject(&:+) + 1
dp = Array.new(MAX_VALUE) { 0xffffffff }
dp[0] = 0

v.each.with_index do |vi, i|
  (MAX_VALUE-vi).downto(0) do |j|
    next if dp[j] == 0xffffffff

    dp[j + vi] = min(dp[j + vi], dp[j] + w[i])
  end
end

ans = 0
dp.each.with_index do |dpi, i|
  next if dpi > W
  ans = i
end

puts ans

Measured memory_bytes: 2556
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N,M;
  cin >> N >> M;
  vector<ll> a(M);
  vector<ll> key(M);
  REP(i,M){
    ll bi;
    cin >> a[i] >> bi;
    REP(j,bi){
      ll cj;
      cin >> cj;
      key[i] |= 1<<(cj-1);
    }
  }

  vector<vector<ll>> dp(M+1, vector<ll>(1<<N,INF));
  dp[0][0] = 0;
  REP(i,M){
    REP(j,1<<N){
      dp[i+1][j] =  dp[i][j];
    }
    REP(j,1<<N){
      dp[i+1][j|key[i]] = min(dp[i][j]+a[i], dp[i+1][j|key[i]]);
    }
  }
  
  ll ans = (dp[M][(1<<N)-1] < INF) ? dp[M][(1<<N)-1] : -1;
  cout << ans <<  "\n";
  return 0;
}


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

 
int main(void)
{
    int i,ans;
    string a,b;
    ans = 0;

    cin >> a >> b;

    for(i=0;i<a.size();i++){
        if(a[i] != b[i])ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3908
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

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



	public void exec() throws Exception{
		final int a = sc.nextInt();
		final int b = sc.nextInt();

		if(a < b) {
			for(int i=0;i<b;i++) {
				out.print(a);
			}
		}else {
			for(int i=0;i<a;i++) {
				out.print(b);
			}

		}
		out.println();
	}
}


Measured memory_bytes: 21972
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/18/20 00:15:08
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

class union_find {
 private:
  vector<int> par_;
  vector<int> sz_;

 public:
  explicit union_find(size_t size) : par_(size), sz_(size, 1) {
    iota(par_.begin(), par_.end(), 0);
  }

  int root(int u) {
    if (u == par_[u])
      return u;
    return par_[u] = root(par_[u]);
  }

  bool are_union(int u, int v) {
    return root(u) == root(v);
  }

  void unite(int u, int v) {
    if (sz_[root(u)] < sz_[root(v)])
      swap(u,v);
    sz_[root(u)] += sz_[root(v)];
    par_[root(v)] = root(u);
  }

  int sz(int u) { return sz_[root(u)]; }

};

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

  int n,m; cin>>n>>m;
  vector<pair<int,int>> AB(m);
  for (int i = 0; i < m; i++) {
    int a,b; cin>>a>>b;
    a--; b--;
    AB[i] = {a,b};
  }
  ll val = (long long)n*(n-1)/2;
  union_find uf(n);
  vector<ll> ans(m);
  for (int i = m-1; i >= 0; i--) {
    auto a = AB[i].first;
    auto b = AB[i].second;
    ans[i] = val;
    if (!uf.are_union(a,b)) {
      val -= (long long)uf.sz(a)*uf.sz(b);
      uf.unite(a,b);
    }
  }
  for (auto v:ans)
    cout<<v<<endl;

  return 0;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return; 
        par[rx] = ry; 
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
	int n,m,k,i,j,cur,res;
	cin >> n >> m;
	
	vector<vector<int>> l(n,vector<int> (0));
	vector<vector<int>> p(m,vector<int> (0));
	for(i=0; i<n; i++){
		cin >> k;
		for(j=0; j<k; j++){
			cin >> cur;
			cur--;
			l[i].push_back(cur);
			p[cur].push_back(i);
		}
	}
	
	UnionFind tree(n);
	for(j=0; j<m; j++){
		for(k=1; k<p[j].size(); k++){
			tree.unite(p[j][0],p[j][k]);
		}
	}
	
	cur=tree.root(0);
	for(i=1; i<n; i++){
		if(tree.root(i)!=cur){
			cout << "NO" << endl; return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    int start,end;

    if(B>D){
        end = D;
    }else{
        end = B;
    }

    if(A>C){
        start = A;
    }else{
        start = C;
    }

    if(start >= end){
        cout << 0 << endl;
        return 0;
    }else{
        cout << end-start << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = [list(map(int, input().split())) for _ in range(n)]

lis.sort(key=lambda x:x[1])

flag = 1
total = 0

for i in lis:
    total += i[0]
    if total > i[1]:
        flag = 0
        break

if flag:
    print('Yes')
else:
    print('No')


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;

    bool r = false;
    FOR(i, a, c + 1) {
        if (s[i] == '#') {
            if (r) {
                cout << "No" << endl;
                return 0;
            }
            r = true;
        } else {
            r = false;
        }
    }
    r = false;
    FOR(i, b, d + 1) {
        if (s[i] == '#') {
            if (r) {
                cout << "No" << endl;
                return 0;
            }
            r = true;
        } else {
            r = false;
        }
    }

    if (b > c || c < d) {
        cout << "Yes" << endl;
        return 0;
    }

    int t = 0;
    FOR(i, b - 1, d + 2) {
        if (s[i] == '.') {
            t++;
            if (t == 3) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            t = 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 640
#全て0以上なら順に足していける
#全て0以下または0より大きくすればいいんじゃね？
#絶対値が最も大きいもの考えてその方向で足せば、
#全て0以下または0より大きくに統一できる(最大n-1回)
#全て0以下の場合は右から左に足す(最大n-1回)
#全て0以上の場合は左から右にたす(最大n-1回)
n=int(input())
a=list(map(int,input().split()))
c,d=min(a),max(a)
ans=[]
if abs(c)>abs(d):
    c_=a.index(c)
    for i in range(n):
        if i!=c_ and a[i]>0:
            ans.append(str(c_+1)+" "+str(i+1))
    for i in range(n-1,0,-1):
        ans.append(str(i+1)+" "+str(i))
else:
    d_=a.index(d)
    for i in range(n):
        if i!=d_ and a[i]<0:
            ans.append(str(d_+1)+" "+str(i+1))
    for i in range(n-1):
        ans.append(str(i+1)+" "+str(i+2))
l=len(ans)
print(l)
for i in range(l):
    print(ans[i])

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,s,t,id,i,j;
  double h,b,r;
  while(1){
    r=1000000.0;
    scanf("%d",&n);
    if(n==0)break;
    for(j=0;j<n;j++){
      scanf("%d %d %d",&id,&s,&t);
      h=s/100.0;
      b=t/(h*h);
      if((fabs(22.0-r))>(fabs(22.0-b))){
	r=b;
	i=id;
      }
    }
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
        print(ans)
    else:
        print(0)
    return

#D
def D():
    n = II()
    a = LI()
    a = a + [a[0]]
    ans = [0] * n
    x = 0
    for i in range(1, n, 2):
        x = x + a[i + 1] - a[i]
    ans[1] = a[0] - x
    ans[0] = ans[1] + 2 * x
    for i in range(2, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(" ".join(map(str, ans)))

    return

#E
def E():
    n, k = LI()
    ab = LIR_(n - 1)
    edg = [[] for i in range(n)]
    for a,b in ab:
        edg[a].append(b)
        edg[b].append(a)
    check = defaultdict(int)
    chb = defaultdict(lambda: True)
    ans = k
    q = deque()
    for i in edg[0]:
        check[i] = 1
        q.append(i)
    check[0] = 1
    chb[0] = False
    while q:
        i = q.pop()
        chb[i] = False
        b = 0
        x = 0
        for e in edg[i]:
            b += check[e]
            check[e] += 1
            if chb[e]:
                q.appendleft(e)
            else:
                x += 1
        check[i] = x + 1
        ans *= (k - b)
        ans %= mod
    print(ans)
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 97244
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

N, M, K = map(int,input().split())
uf = UnionFind(N)
F = [set() for k in range(N)]
for k in range(M):
    A, B = map(int,input().split())
    uf.union(A-1,B-1)
    F[A-1].add(B-1)
    F[B-1].add(A-1)

T = [0 for k in range(N)]
for k in range(K):
    C, D = map(int,input().split())
    if uf.same(C-1,D-1) == True:
        T[C-1] -= 1
        T[D-1] -= 1
A = []
for k in range(N):
    A.append(uf.size(k)-len(F[k])+T[k]-1)
print(*A)


Measured memory_bytes: 47684
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    int N,M;
    cin>>N>>M;
        const int max_factor=floor(sqrt(M));
    vector<int> F(max_factor+1,0);
    int prime_flag=0;
    REPi(i,2,max_factor+1){
        while(M%i==0){
            M/=i;
            F[i]+=1;
            prime_flag=1;
        }
    }
    if(prime_flag==0){
        if(M==1){
            cout<<1<<endl;
            return 0;
        }
        cout<<N<<endl;
        return 0;
    }else{
        ll ans=1;
        REP(i,max_factor+1){
            if(F[i]!=0){
                ans*=COM(F[i]+N-1,F[i]);
                ans%=MOD;
            }
        }
        if(M!=1){
            ans*=N;
            ans%=MOD;
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define MAX 2000010

bool e[MAX];

void erato(){
    fill(e, e+MAX, true);
    e[0] = e[1] = false;

    for(int i=0; i < MAX; i++){
        if(!e[i]) continue;
        for(int j=i+i; j < MAX; j += i){
            e[j] = false;
        }
    }
}

int main(){
    erato();
    int n;
    while(cin >> n, n){
        int ret = 0;
        if(e[n]){cout << 0 << endl; continue;}
        while(!e[n]) n--;
        for(int i=n+1; !e[i]; i++)ret++;
        cout << ret+1 << endl;
    }
}

Measured memory_bytes: 3112
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<vector<char>> masu(h,vector<char>(w));
  vector<bool> h_b(h);
  vector<bool> w_b(w);
  REP(i,h) REP(j,w) cin >> masu[i][j];
  REP(i,h) {
    bool flag = false;
    REP(j,w) {
      if(masu[i][j] == '#') flag = true;
    }
    h_b[i] = flag;
  }
  REP(j,w) {
    bool flag = false;
    REP(i,h) {
      if(masu[i][j] == '#') flag = true;
    }
    w_b[j] = flag;
  }
  REP(i,h) {
    REP(j,w) {
      if(h_b[i] && w_b[j]) cout << masu[i][j];
    }
    if(h_b[i]) cout << endl;
  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,a,b,c,d,e,f,g;
	for(i=0;i<3;++i)scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),g=((d-a)*60+e-b)*60+f-c,printf("%d %d %d\n",g/3600,g/60%60,g%60);
	return 0;
}

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

N = N % 10

if N == 2 or N== 5 or N == 4 or N == 7 or  N == 9:
  print("hon")
elif N == 0 or N == 1 or N == 6 or N == 8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9176
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

long long gcd(long long a, long long b) {
	if (b > a) swap(a, b);
	long long tmp;
	while (b != 0) {
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

int N;
LL p[20];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> p[i];
	int ans = 0;
	for (int i = 1; i < (1 << N); i++) {
		LL lcm = 1;
		for (int j = 0; j < N; j++) {
			if (((i >> j) & 1) == 1) {
				lcm = lcm * p[j] / gcd(lcm, p[j]);
			}
		}
		bool flg = true;
		for (int j = 0; j < N; j++) {
			if (((i >> j) & 1) == 0) {
				if (lcm%p[j] == 0) flg = false;
			}
		}
		if(flg) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T> void read(T &x){
	char c=getchar();int f=1;x=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}x*=f;
}
const int N=1e5+7;
long long z,n,k,a[N],r,ans;
int main(){
	read(n);read(k);ans=1e18;
	for(int i=1;i<=n;i++)read(a[i]);sort(a+1,a+n+1);
	for(int l=1;l<=n-k+1;l++){
		r=l+k-1;z=a[l];z*=a[r];
		if(z>0)ans=min(ans,max(abs(a[l]),abs(a[r])));
		else{
			int x=a[l],y=a[r];
			if(abs(x)>abs(y))swap(x,y);
			ans=min(ans,(ll)abs(x)*2+abs(y));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1e3;
const int mxM = 2e3;
const int lgN = 10;
const int P = 1e9+7;
struct AEdge {int u,v; llong w; bool operator <(const AEdge &arg) const {return w<arg.w;}} ae[mxM+3];
struct Edge {int v,nxt,w;} e[mxM*2+3]; int fe[mxN+3];
int fa[mxN+3][lgN+3],maxi[mxN+3][lgN+3];
int dep[mxN+3];
int uf[mxN+3];
llong f[mxM+3];
int n,m,en; llong lim;

int findfa(int u) {return u==uf[u]?u:uf[u]=findfa(uf[u]);}

void addedge(int u,int v,int w)
{
	en++; e[en].v = v,e[en].w = w;
	e[en].nxt = fe[u]; fe[u] = en;
}

void dfs1(int u)
{
	for(int i=1; i<lgN; i++) {fa[u][i] = fa[fa[u][i-1]][i-1],maxi[u][i] = max(maxi[u][i-1],maxi[fa[u][i-1]][i-1]);}
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v; if(v==fa[u][0]) continue; fa[v][0] = u,maxi[v][0] = e[i].w;
		dep[v] = dep[u]+1;
		dfs1(v);
	}
}
int query(int u,int v)
{
	int ret = 0; if(dep[u]<dep[v]) swap(u,v);
	int dif = dep[u]-dep[v];
	for(int i=0; i<lgN; i++) if(dif&(1<<i)) {ret = max(ret,maxi[u][i]),u = fa[u][i];}
	if(u==v) {return ret;}
	for(int i=lgN-1; i>=0; i--)
	{
		if(fa[u][i]!=fa[v][i])
		{
			ret = max(ret,max(maxi[u][i],maxi[v][i]));
			u = fa[u][i],v = fa[v][i];
		}
	}
	ret = max(ret,max(maxi[u][0],maxi[v][0]));
	return ret;
}

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}

int main()
{
	n = read(),m = read(); scanf("%lld",&lim);
	for(int i=1; i<=m; i++)
	{
		ae[i].u = read(),ae[i].v = read(),ae[i].w = read();
	}
	for(int i=1; i<=n; i++) uf[i] = i;
	sort(ae+1,ae+m+1);
	llong tot = 0ll;
	for(int i=1; i<=m; i++)
	{
		int u = ae[i].u,v = ae[i].v,uu = findfa(u),vv = findfa(v);
		if(uu!=vv)
		{
			uf[uu] = vv;
			tot += ae[i].w;
			addedge(u,v,ae[i].w),addedge(v,u,ae[i].w);
		}
	}
	dfs1(1);
	int cnt1 = 1,cnt2 = 1;
	for(int i=1; i<=m; i++)
	{
		f[i] = tot-query(ae[i].u,ae[i].v)+ae[i].w;
		if(f[i]>=lim) {cnt1++;} if(f[i]>lim) {cnt2++;}
	}
	cnt1 = min(cnt1,m),cnt2 = min(cnt2,m);
	printf("%lld\n",(quickpow(2ll,cnt1)-quickpow(2ll,cnt2)+P)%P);
	return 0;
}

Measured memory_bytes: 4036
#include <iostream>
             
int main() { 
    int n = 0;
    std::cin >> n;
             
    for(int i = 3; i <= n; i++) {
        if((i % 3) == 0) {
            std::cout << " " << i;
            continue;
        }    
        else if(i > 10) {
            int x = i;
            while(x > 0) {
                if((x % 10) == 3) {
                    std::cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }    
    }        
    std::cout << std::endl;
             
    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();
        final int x = sc.nextInt();

        final int[] m = new int[n];
        for (int i = 0; i < n; i++) {
            m[i] = sc.nextInt();
        }

        final int used = IntStream.of(m).sum();
        final int min = IntStream.of(m).min().getAsInt();
        final int ans = m.length + (x - used) / min;

        System.out.println(ans);
    }
}


Measured memory_bytes: 27604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

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

using namespace std;

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

signed main() {
	int N;
	cin >> N;

	vector<int> x(N), y(N);
	rep(i, N) cin >> x[i] >> y[i];

	rep(i, N) {
		if ((x[i] + y[i] + 11234567890) % 2 != (x[0] + y[0] + 11234567890) % 2) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<int> d;
	rep(i, 39) {
		d.push_back(1LL << i);
	}
	reverse(all(d));

	bool even = false;
	if ((x[0] + y[0]) % 2 == 0) {
		d.push_back(1);
		even = true;
	}

	cout << d.size() << endl;
	for (int num : d) cout << num << " ";
	cout << endl;

	rep(i, N) {
		int tx = even;
		int ty = 0;
		rep(j, 39) {
			int dx = x[i] - tx;
			int dy = y[i] - ty;
			if (abs(dx) > abs(dy)) {
				if (dx > 0) {
					cout << 'R';
					tx += d[j];
				} else {
					cout << 'L';
					tx -= d[j];
				}
			} else {
				if (dy > 0) {
					cout << 'U';
					ty += d[j];
				} else {
					cout << 'D';
					ty -= d[j];
				}
			}
		}
		if (even) cout << 'R';
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{int x, y;
cin >> x;
	if (x <= 100 && x >= 1)
	{
		for (int i = 1; i < 10;i++)
		{
			for (int j = 1; j < 10; j++)
			{
				if (i * j == x)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
	    }
		cout << "No" << endl;
	}
    
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
max_n = 0
count = 0
for i in range(N):
  if i > 0:
    if before >= H[i]:
      count += 1
    else:
      count = 0
  max_n = max(count,max_n)
  before = H[i]
print(max_n)



Measured memory_bytes: 14252
# import sys
N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split())) + [10**13]
B = [0] + list(map(int, input().split())) + [10**13]
sum_t = 0
cumsumA = [0]
cumsumB = [0]
ansA = N
ansB = 0
tmp = 0
for i in range(1, N+1):
    tmp = tmp + A[i]
    if tmp > K:
        ansA = i-1
        break
    cumsumA += [tmp]
tmp = 0
for i in range(1, M+1):
    tmp = tmp + B[i]
    if tmp > K:
        break
    cumsumB += [tmp]
j = 0
ans = 0
for i in range(ansA, -1, -1):
    t = cumsumA[i] + cumsumB[j]
    while True:
        tmp = B[j+1]
        if tmp + t <= K:
            t += tmp
            j += 1
        else:
            break
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 119968
a1, a2, a3 = 3.times.map{gets.split.map(&:to_i)}
b1, b2, b3 = [a1[0], a2[0], a3[0]], [a1[1], a2[1], a3[1]], [a1[2], a2[2], a3[2]]
c1, c2 = [a1[0], a2[1], a3[2]], [a1[2], a2[1], a3[0]]

arr = [a1, a2, a3, b1, b2, b3, c1, c2]
n = gets.to_i
b = n.times.map{gets.to_i}

arr.each do |a|
  if a.all? {|j| b.include?(j)}
    puts 'Yes'
    exit
  end
end
puts 'No'

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long long H;
    cin >> H;
    long long t = 1;
    long long ans = 0;
    while(true){
        if(H < 1) break;
        H /= 2;
        ans += t;
        t *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    switchs = []
    for i in range(M):
        tmp = [int(x) for x in input().split()]
        switchs.append(tmp[1:])

    p = [int(x) for x in input().split()]

    pattern = 0
    for i in range(2 ** N):
        on_state = [0] * N
        for j in range(N):
            if ((i >> j) & 1):
                on_state[(N-1) -j] = 1

        light_on = False
        for k_ in range(M):
            on_light_cnt = 0
            for switch in switchs[k_]:
                if on_state[switch-1] == 1:
                    on_light_cnt += 1

            if on_light_cnt % 2 != p[k_]:
                light_on = False
                break

            light_on = True

        if light_on == True and k_ == M-1:
            pattern += 1

    print(pattern)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int a, b, c, d, e, f;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    cout << a+b+c+d+e+f-min({a, b, c, d})-min({e, f}) << "\n";
    return 0;
}



Measured memory_bytes: 3232
#https://atcoder.jp/contests/abc084/tasks/abc084_c
N = int(input())
CSF = [list(map(int,input().split())) for _ in range(N-1)]
for i in range(1,N+1):
    if i == N:
        print(0)
        break
    time = 0
    for j in range(i,N):
        if time == 0:
            time += CSF[j-1][1]  #はじめはS[j]秒経過  
        else:
            if time < CSF[j-1][1]:
                time = CSF[j-1][1]
           # lv = CSF[j-1][1]
            while time % CSF[j-1][2] != 0:  #timeがS[j]+F[j]またはS[j]より小さいなら
                time +=1   #F[j]経過
        time += CSF[j-1][0]  #その後C[j]秒経過
    print(time)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define lli long long
#define endl '\n'
#define mod 1000000007
#define spc " "
#define no "NO"
#define yes "YES"
#define ff "First"
#define ss "Second"
#define idiot "Friendship"
lli fact(int n) {
	if (n == 1)return 1;
	if (n == 0)return 1;
	else return n * fact(n - 1);
}
int prime(int g) {
	for (int i = 2; i * i  <= g; ++i)
	{
		if (g % i == 0)return false;
	} return true;

}
int fibo(int n) {
	int x = 1002;
	int arr[x]; arr[0] = 0; arr[1] = 1; arr[2] = 1;
	for (int i = 2; i < x; ++i)
	{
		arr[i] = arr[i - 1] + arr[i - 2];
	}
	for (int i = 1; i < x; ++i)
	{
		/* code */if (arr[i] == n)return true;
	}
	return false;
}
int fit (int x) {
	int n = 10;
	char arr[n] = {'a', 'i', 'o', 'u', 'e', '1', '3', '5', '7', '9'};
	for (int i = 0; i < n; ++i)
	{
		/* code */if (x == arr[i])return true;
	} return false;
}
string str(int n) {
	string l = "", r = "";

	/* code */while (n > 0) {
		l += (n % 10 + '0');
		n /= 10;

	}
	reverse(l.begin(), l.end());
	return l;

}
int coprime(int a, int g, int n) {
	for (int i = 2; i < n; ++i)
	{
		/* code */if (a % i == 0 && g % i == 0)return 0;
	}
	return 1;
}

void astronomia() {
	std::vector<int> v;
	lli n, i , j , k = 0, count = 0;
	set <int> se;
	lli m, l , r , a = 0, b = INT_MAX, c, d;
	map<char, char> mp; char c1, c2;
	string s;
	cin >> n >> a >> b;
	if (n <= a * b)cout << "Yes";
	else cout << "No";
	return;
}

/*ifstream in("input.txt");
ofstream ou("output.txt");*/


int main() {
	// ios_base::sync_with_stdio(0);
	// cin.tie(0); cout.tie(0);
	lli t;
	t = 1;
	// cin >> t;

	while (t--) {
		astronomia();

		cout << endl;
	}

}

Measured memory_bytes: 3632
#include <iostream>	
#include <stdio.h>	
#include <bits/stdc++.h>	
#include <math.h>	
using namespace std;	

int main(){
    long a,b,x;
    cin>>a>>b>>x;
    
    double p=a*a*b;
    double q=a*a*a;
    if (x*2>=p){
        p-=x;
        
        double c=p/q;
    
        c*=2;
            
        double d=atan(c)*180/3.14159265359;
        cout << fixed << setprecision(15) << d << endl;
    }
    else{
        double s=a*b*b;
        double c=x/s;
        
        c*=2;
        
        double d=atan(c)*180/3.14159265359;
        cout << fixed << setprecision(15) << 90-d << endl;
    }
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, b, e) for (auto i = b; i < e; ++i)

int n, k;

vector<vector<int>> graph;
vector<int> par;

int ans;

int dfs(int node) {
    if (graph[node].empty()) {
        ans++;
        return 0;
    }

    int ret = n + 1;

    for (int to : graph[node]) {
        ret = min(ret, dfs(to) + 1);
    }

    if (ret < k || par[node] == -1) {
        ans++;
    }

    return ret;
}

int main() {
    cin >> n >> k;

    graph.assign(n, {});
    par.assign(n, -1);
    REP(i, 0, n) {
        int x;
        cin >> x;
        x--;
        if (x == -1) {
            continue;
        }
        graph[x].push_back(i);
        par[i] = x;
    }

    REP(i, 0, n) {
        if (par[i] == -1) {
            dfs(i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 13388