akhauriyash/Code-Regression huggingface dataset:
<?php
define("MOD", 10**9+7);

$N = (int)trim(fgets(STDIN));
//$T = trim(fgets(STDIN));
//list($D,$T,$S) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$rsum=0;
for($i=0;$i<$N;$i++) {
  $rsum=addm($rsum,$A[$i]);
}
$sum=0;
for($i=0;$i<$N;$i++) {
  $rsum -= $A[$i];
  if ($rsum < 0) $rsum+=MOD;
  $r = $A[$i]*$rsum;
  $sum = addm($sum,$r);
}
printf("%d\n",$sum);


//https://atcoder.jp/contests/abc145/submissions/8474723


//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//引き算
function subm($a, $b){
    return ($a + MOD - $b) % MOD;
}
//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//割り算
function divm($a, $b){
    return mulm($a, powerm($b, MOD - 2));
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}
//階乗
function factorialm($a){
    if($a == 0)return 1;
    return factorialm($a - 1) * $a % MOD;
}
//順列
function nPm($n, $m){
    if($m == 0)return 1;
    return nPm($n, $m - 1) * ($n - $m + 1) % MOD;
}
//組み合わせ
function nCm($n, $m){
    $m = min($m, $n-$m);
    return divm(nPm($n, $m), factorialm($m));
}

//解説のcombinationを移植
Class combinationsnk {
  private $fact;
  private $ifact;
  public function __construct(int $n) {
    $this->fact[0]=1;
    for($i=1;$i<=$n;$i++) $this->fact[$i]=mulm($this->fact[$i-1],$i);
    $this->ifact[$n]=powerm($this->fact[$n],MOD-2);
    for ($i = $n; $i >= 1; --$i) $this->ifact[$i-1] = mulm($this->ifact[$i],$i);
  }
  public function calc(int $n,int $k)
  {
    if ($k < 0 || $k > $n) return 0;
    return mulm(mulm($this->fact[$n],$this->ifact[$k]),$this->ifact[$n-$k]);
  }
}



Measured memory_bytes: 38092
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        if (a >= 1 && a <= 13 && b >= 1 && b <= 13 && c >= 1 && c <= 13) {
            if ((a + b + c) >= 22) {
                System.out.println("bust");
            } else {
                System.out.println("win");
            }
        }
    }
}


Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val (_, k) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val sum = mutableListOf(0)
    for (a in aa) {
        sum.add(((sum.last() + a) % k + k - 1) % k)
    }
    var indices = mutableMapOf<Int, MutableList<Int>>()
    for (i in 0 until sum.size) {
        if (!indices.containsKey(sum[i])) {
            indices[sum[i]] = mutableListOf()
        }
        indices[sum[i]]!!.add(i)
    }
    var ret = 0L
    for (l in indices.values) {
        var s = 0
        var e = 0
        while (s < l.size) {
            while (e < l.size) {
                if (l[e] - l[s] >= k) {
                    break
                }
                e += 1
            }
            ret += e - s - 1
            s += 1
        }
    }
    println(ret)
}


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

int main()
{
    int N;
    scanf("%d", &N);
    char S[N + 10];
    scanf("%s", S);
    int cnt = 1;
    char cur = S[0];
    for(int i = 1; i < N; ++i) {
        char tmp = S[i];
        if(tmp != cur) ++cnt, cur = tmp;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 384
#include <bits/extc++.h>

struct dsu {
  dsu() {}
  explicit dsu(int n) : _cc(n), dat(n, -1) {}

  int size() const { return std::size(dat); }
  int root(int v) {
    assert(0 <= v), assert(v < size());
    return dat[v] < 0 ? v : dat[v] = root(dat[v]);
  }
  std::pair<int, int> unite(int u, int v) {
    assert(0 <= u), assert(u < size());
    assert(0 <= v), assert(v < size());
    u = root(u), v = root(v);
    if (u == v) return {u, -1};
    --_cc;
    if (-dat[u] < -dat[v]) std::swap(u, v);
    dat[u] += dat[v];
    dat[v] = u;
    return {u, v};
  }
  bool same(int u, int v) {
    assert(0 <= u), assert(u < size());
    assert(0 <= v), assert(v < size());
    return root(u) == root(v);
  }
  int size(int v) {
    assert(0 <= v), assert(v < size());
    return -dat[root(v)];
  }
  int cc() const { return _cc; }

 private:
  int _cc;
  std::vector<int> dat;
};

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  dsu d(n);
  while (m--) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    d.unite(a, b);
  }
  cout << d.cc() - 1 << '\n';
}


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

using namespace std;
const int N = 2e4 + 10;
int a[N], b[N];
int main()
{
    int n; cin >> n;
    for (int i = 1; i <= n; i++) a[i] = i * n, b[i] = (n - i + 1) * n;
    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        a[x] += i - 1;
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << "\n";
    for (int i = 1; i <= n; i++) cout << b[i] << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int dp[105][4][2]; // dp[i][j][k]: 0~i-1までのi文字をきめたときの総数

int main () {
  string s;
  int K;
  cin >> s >> K;
  int n = sz(s);

  dp[0][0][0] = 1;
  rep(i,n)rep(j,K+1)rep(k,2) {
    int nd = s[i]-'0';
    rep(d,10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }

  cout << dp[n][K][0] + dp[n][K][1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int, int> pll;
bool visited[100005];
const int max_N = 1e5 + 10;

int A;
int B;
int C;
char S[100005];
int l[100005];
int r[100005];

int main(void) {
	cin >> A >> B >> C;



	if (A == B && A == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int N, M;
int s, t;
int x, y;
vi G[111111];
int ds[111111];
int dt[111111];
ll ns[111111];
ll nt[111111];

int main(int argc, char *argv[])
{
  cin >> N >> M;
  cin >> s >> t;
  s -= 1;
  t -= 1;
  rep(i, M){
    cin >> x >> y;
    G[x - 1].pb(y - 1);
    G[y - 1].pb(x - 1);
  }

  rep(i, N) ds[i] = -1;
  ds[s] = 0;
  queue<int> ques;
  ques.push(s);
  while(!ques.empty()){
    int v = ques.front();  ques.pop();
    vrep(w, G[v]) if(ds[*w] < 0){
      ds[*w] = ds[v] + 1;
      ques.push(*w);
    }
  }

  rep(i, N) dt[i] = -1;
  dt[t] = 0;
  queue<int> quet;
  quet.push(t);
  while(!quet.empty()){
    int v = quet.front();  quet.pop();
    vrep(w, G[v]) if(dt[*w] < 0){
      dt[*w] = dt[v] + 1;
      quet.push(*w);
    }
  }

  ll res = 0LL;
  rep(i, N) ns[ds[i]] += 1;
  rep(i, N) nt[dt[i]] += 1;
  rep(i, ds[t] - 1) res += ns[i] * nt[ds[t] - i - 2];
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 8784
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  double N;
  cin >> N;

  double n = ceil(N / 1.08);
  if (floor(n * 1.08) != N) {
    cout << ":(" << endl;
    return 0;
  }
  cout << ll(n) << endl;

  return 0;
}


Measured memory_bytes: 256
import re
a,b =[int(i) for i in input().split()]
content = input()

pattern = '[0-9]{' +str(a)+ '}-[0-9]{' +str(b)+ '}'

search_result = re.search(pattern, content)

if not(search_result) :
  print("No")
elif search_result.group() == content:
  print('Yes')
else:
  print("No")

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;
int dis(pair<int, int> a, pair<int ,int> b){
	return abs(a.first-b.first)+abs(a.second-b.second);
}

signed main(){
	int n,m; cin >> n >> m;
	vector<pair<int, int> > a(n),c(m);
	for(auto &e : a)cin >> e.first >> e.second;
	for(auto &e : c)cin >> e.first >> e.second;
	vector<pair<int, int> > s(n,{(int)1e9,0});
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m;j++){
			s[i] = min(s[i], {dis(c[j],a[i]),(j+1)});
		}
	}
	for(auto e : s){
		cout << e.second << endl;
	}

	return 0;
}



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

int main() {
	int N;
	double x[8];
	double y[8];

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
	}

	double res = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (j == i) {
				continue;
			}

			res += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}

	cout << setprecision(16) << res / N;

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int x,y;
    //int ka = 4,tu = 2;
    scanf("%d %d",&x,&y);
    /*if(x < 1 || x > 100 || y < 1 || y > 100){
        goto end;
    }*/
    int k,t,flag = 0;
    for(k = 0;k <= x;k++){
        for(t = 0;t <= x;t++){
            if(k + t != x){
                continue;
            }
            if(k * 4 + t * 2 == y){
                flag++;
                goto end;
            }
        }
    }
end:
    if(flag == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))

odd, even = 0, 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

d, m = divmod(odd, 2)
even += d
odd = m

if odd == 0:
    ans = "YES"
else:
    ans = "YES" if even == 0 else "NO"

print(ans)


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector <ll> A(X);
    vector <ll> B(Y);
    vector <ll> C(Z);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    vector <ll> S;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            S.push_back(A[i] + B[j]);
        }
    }
    sort(S.begin(), S.end(), greater<ll>());
    vector <int> N(Z);
    for (int i = 0; i < Z; i++) {
        N[i] = 0;
    }
    for (int phase = 0; phase < K; phase++) {
        ll Max = 0;
        ll Num = -1;
        for (int i = 0; i < Z; i++) {
            if (N[i] == X * Y) {
                continue;
            }
            ll New = C[i] + S[N[i]];
            if (New > Max) {
                Max = New;
                Num = i;
            }
        }
        N[Num]++;
        cout << Max << '\n';
    }
    return 0;
}



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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    // ?????????x??§?¨???¨y??§?¨????????§???¢????????????????????¢??????
    if ( W < x || H < y) {
        cout << "No" << endl;
        return 0;
    }
    if ( x < 0 || y < 0) {
        cout << "No" << endl;
        return 0;
    }
    
    // ???????????§?¨???¨????????????????¶?????????????????????????????????¢??????
    if ( x + r > W || y + r > H) {
        cout << "No" << endl;
        return 0;
    }

    // ???????????§?¨???¨????????????????¶?????????????????????????????????¢??????
    if ( x + r < 0 || y + r < 0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  int N, K;
  cin >> N >> K;

  vi xm, xp;

  REP(i, N) {
    int x;
    cin >> x;
    if (x < 0)
      xm.push_back(x);
    else
      xp.push_back(x);
  }

  sort(xm.begin(), xm.end(), greater<>());

  if (xm.size() == 0) {
    cout << xp[K - 1] << endl;
    return 0;
  }

  if (xp.size() == 0) {
    cout << -xm[K - 1] << endl;
    return 0;
  }

  ll ans = (1LL << 50);
  REP(i, xm.size()) {
    ll t = 0;
    t += (ll)xm[i] * (-2LL);
    if (K - i - 2 < xp.size()) {
      t += (ll)xp[K - i - 2];
      ans = min(ans, t);
    }
    if (i == K - 1) {
      ans = min(ans, -(ll)xm[K - 1]);
    }
  }

  REP(i, xp.size()) {
    ll t = 0;
    t += (ll)xp[i] * 2LL;
    if (K - i - 2 < xm.size()) {
      t += -(ll)xm[K - i - 2];
      ans = min(ans, t);
    }
    if (i == K - 1) {
      ans = min(ans, (ll)xp[K - 1]);
    }
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

inline ll read(){
	char ch=getchar();ll x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int s[101010];

map<int,int> fr;

ll ans;

int main(){
	ll n=read(),m=read();
	for(int i=1;i<=n;i++){
		ll d=read();
		s[i]=s[i-1]+d;
		s[i]%=m;
		ans+=1ll*fr[s[i]];
		if(s[i]==0) ans++;
		fr[s[i]]++;
	}
	cout<<ans;
	return 0;
}


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

int main(void){
    int N,Y;
    cin >> N >> Y;
    
    for(int i = 0 ; i <= N ; i++){
        for(int j = 0 ; j <= N ; j++){
            if(i+j <= N){
                int k = N-i-j;
                if(10000*i + 5000*j + 1000*k == Y){
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    int h,n;
    cin>>h>>n;
    vector<pair<ll,ll>> ab(n);
    for(int i=0; i<n; i++){
        int a,b;
        cin>>a>>b;
        ab[i].first=a;
        ab[i].second=b;
    }
    sort(ab.begin(),ab.end());
    vector<ll> dp(h+1,1e9);
    dp[h]=0;
    for(int i=h; i>=0; i--){
        if(dp[i]==1e9) continue;
        for(int j=0; j<n; j++){
            if(i-ab[j].first<0){
                dp[0]=min(dp[0],dp[i]+ab[j].second);
                continue;
            }
            dp[i-ab[j].first]=min(dp[i-ab[j].first],dp[i]+ab[j].second);
        }
    }
    cout<<dp[0]<<endl;

}


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

int main(){
  int H, W;
  cin >> H >> W;
  char C[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> C[i][j];
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << C[i][j];
    }
    cout << ' ' << endl;
    for(int j=0; j<W; j++){
      cout << C[i][j];
    }
    cout << ' ' << endl;
  }
}

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

signed main() {

    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double x = 30.0 * h  + 0.5 * m;
    double y = 6.0 * m ;

    if(x < y){
        swap(x, y);
    }
    double dig = 0;
    // if(x - y > 180){
    //     dig = (x - y) - 180;
    // }
    // else{
        dig = x - y;
    // }


    double rad = dig * M_PI / 180;

    cout << fixed << setprecision(20) << sqrt(b * b + a * a - 2 * b * a * cos(rad)) << endl;

    return 0;
}


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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << h2*60+m2-h1*60-m1-k;
    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a[101],i=0,j,k=0,t[101]={0};
	while(~scanf("%d",&a[i])){
		i++;}
	for(j=0;j<i;j++)t[a[j]]++;
	for(j=1;j<101;j++)if(k<t[j])k=t[j];
	for(j=1;j<101;j++)if(k==t[j])printf("%d\n",j);
	return 0;}


Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


#define N 2000004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return po(mod(mod(i)*mod(i)),p/2);
    else  return mod(mod(i)*po(i,p-1));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    else if(n==0)return 1;
    else return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return po(n,i_5);
}



 
int main(){fastio
    
    calc();
    
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;return 0;
    }
    ll n=(x+y)/3;
    x-=n;
    y-=n;
    if(x<0||y<0){
        cout<<0<<endl;return 0;
    }
    cout<<comb(x+y,x)<<endl;
    
    
    return 0;
}




Measured memory_bytes: 31488
//abc146_b.cpp
//Sat Nov 30 19:04:08 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	for (int i=0;i<s.length();i++){
		char temp = s[i] + n;
		if ((int)temp > 90){
			temp = temp - 26;
		}
		cout << temp;
	}
	printf("\n");

}

Measured memory_bytes: 256
# ABC150 C
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
permutation = itertools.permutations(range(1, n+1))

cnt_p = 0
cnt_q = 0
finish_p = False
finish_q = False
for per in permutation:
    if per == p:
        finish_p = True
        cnt_p += 1
    if per == q:
        finish_q = True
        cnt_q += 1

    if finish_p and finish_q:
        break
    cnt_p += 1 if not finish_p else 0
    cnt_q += 1 if not finish_q else 0
print(max(cnt_p-cnt_q, cnt_q-cnt_p))

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

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

int main(){
    string s,c;
    int t,f;
    int rev=0;

    cin>>s;
    cin>>t;
    list<string> li;
    li.push_front(s);
    while(cin>>t){
        if(t==1){
            rev=1-rev;
        }else{
            cin>>f>>c;
            if(f==1){
                if(rev){
                    reverse(c.begin(),c.end());
                    li.push_back(c);
                }else{
                    li.push_front(c);
                }
            }else{
                if(rev){
                    reverse(c.begin(),c.end());
                    li.push_front(c);
                }else{
                    li.push_back(c);
                }
            }
        }
    }
    if(rev){
        s="";
        for(auto i=li.rbegin();i!=li.rend();++i){
            reverse(i->begin(),i->end());
            cout<<*i;
        } 
    }else{
        for(auto i=li.begin();i!=li.end();++i){
            cout<<*i;
        }
    }
    return 0;
}

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

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

    string s, t;
    cin >> s >> t;
    
    s += s;

    if((int)s.find(t) >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  ll n,w[110];
  cin>>n;
  for(int i=0;i<n;i++)cin>>w[i];
  ll ans=1e17;
  for(int i=0;i<n;i++){
      ll l=0,r=0;
      for(int j=0;j<=i;j++)l+=w[j];
      for(int j=i+1;j<n;j++)r+=w[j];
      ans=min(ans,abs(l-r));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	x := A - 1
	a := x - x/C - x/D + x/lcm(C, D)
	b := B - B/C - B/D + B/lcm(C, D)

	fmt.Println(b - a)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define N 105
#define INF 1e9
int n,m,dp[N][N];char a[N][N];
int min(int x,int y) {return x<y?x:y;}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",a[i]+1);dp[1][1]=a[1][1]=='#';
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) if(i>1 || j>1)
	{
		dp[i][j]=INF;if(i>1) dp[i][j]=dp[i-1][j]+(a[i][j]=='#' && a[i-1][j]=='.');
		if(j>1) dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j]=='#' && a[i][j-1]=='.'));
	}printf("%d\n",dp[n][m]);return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    vector <pair<int,int> > a(n),b(m);
    for(int i=0;i<n;i++)
        cin>>a[i].first>>a[i].second;
    for(int i=0;i<m;i++)
        cin>>b[i].first>>b[i].second;
    vector <int> test;
    test.resize(n,0);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            if(abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second)<abs(a[i].first-b[test[i]].first)+abs(a[i].second-b[test[i]].second))
                test[i]=j;

        }
    for(auto i:test)
        cout<<i+1<<endl;
    
    
    
    return 0;   
}




 
 


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<P> vec(M);
    REP(i, M) {
        ll s, c;
        cin >> s >> c;
        vec[i] = P(s, c);
    }

    if (N == 1) {
        string tmp = to_string(0);
        bool flag = false;
        for(P p : vec) {
            if(tmp[p.first-1] - '0' != p.second) {
                flag = true;
            }
        }
        if (!flag) {
            PRINT(0);
            return 0;
        }
    }

    FOR(i, pow(10, N-1), pow(10, N)) {
        string tmp = to_string(i);
        bool flag = false;
        for(P p : vec) {
            if(tmp[p.first-1] - '0' != p.second) {
                flag = true;
            }
        }
        if (!flag) {
            PRINT(i);
            return 0;
        }
    }
    PRINT(-1);
    return 0;
} 

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n,m;
    string s, t;
    cin >> n;


    if(n >= 30) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }

//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3668
import numpy as np
n, m = map(int,input().split())
A = []
B = []
for i in range(n):
    a = list(input())
    A.append(a)
for i in range(m):
    b = list(input())
    B.append(b)
A_arr = np.array(A)
B_arr = np.array(B)

for h in range(n-m+1):
    for w in range(n-m+1):
        if np.all(A_arr[h:h+m, w:w+m] == B_arr):
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
int solve(int n) {
	int cnt = 0 ;
	cnt += (n / 10) ; n /= 10 ;
	while(n) {
		cnt += (n / 5) ;
		n /= 5 ;
	}
	return cnt ;
}
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	int n = read() ;
	if(n & 1) print(0) ;
	else print(solve(n)) ;
	return 0 ;
}

Measured memory_bytes: 256
S = input()
last = 'i'

if len(S) == 1:
    print("No")
    exit()

for c in S:
    if (last == 'i' and c != 'h') or (last == 'h' and c != 'i'):
        print("No")
        exit()
    last = c
if last != "i":
    print("No")
    exit()
print("Yes")
exit()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int temp[3]={1,5,10};

using namespace std;

int main() {
    int n;
    cin>>n;
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        if(a<b)cout<<a<<endl;
        else {
            if(a%b!=0)cout<<a%b<<endl;
            else cout<<b<<endl;
        }
    }
    return 0;
}



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



int main()
{
    int n;
    string a = "ACL";
    string ans;

    cin >> n;

    for (int i = 0; i < n; i++) {
        ans += a;
    }

    cout << ans << endl;

    return 0;
  
}

Measured memory_bytes: 3620
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int X, Y;
    in2(X, Y);

    repse(i, 0, X)
    {
        int c = i;
        int t = X - c;

        if (c * 2 + t * 4 == Y)
        {
            outl("Yes");
            return 0;
        }
    }

    outl("No");
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    long long a,b,k;
    long long i=0;
    scanf("%lld %lld %lld",&a,&b,&k);

    if(a>=k)
    {
        printf("%lld %lld",a-k,b);
    }
    else if(a<=k && (a+b)>=k)
    {
        printf("0 %lld",b-(k-a));
    }
    else {printf("0 0");}
}


Measured memory_bytes: 1716
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(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 modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>a>>b;
float a1=0.08;
float a2=0.1;
for(int i=1;i<=100000;i++)
{
    ll temp1=(float)i*a1;
    ll temp2=(float)i*a2;
    if(temp1==a && temp2==b)
    {cout<<i;return;}
}
cout<<-1;





return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n,n;){
		vvi ds(n);
		rep(i,n){
			int f; cin>>f;
			ds[i].resize(f);
			rep(j,f){
				cin>>ds[i][j];
				ds[i][j]--;
			}
		}
		
		vector<ll> meet(30);
		rep(i,n) rep(j,ds[i].size())
			meet[ds[i][j]]|=1ll<<i;
		
		vector<ll> canhave(n);
		rep(i,n) canhave[i]|=1ll<<i;
		
		bool ok=false;
		rep(d,30){
			ll maps=0;
			rep(i,n) if(meet[d]>>i&1)
				maps|=canhave[i];
			rep(i,n){
				if(meet[d]>>i&1)
					canhave[i]|=maps;
				if(canhave[i]==(1ll<<n)-1){
					cout<<d+1<<endl;
					ok=true;
					goto end;
				}
			}
		}
		end:
		if(!ok) cout<<-1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,num) FOR(i,0,num) {ll x; scanf("%lld",&x); a.pb(x); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> SET;
typedef map<ll, ll> MAP;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> n;
  vll a;
  FOR(i, 0, n) {
	cin >> tmp;
	a.pb(tmp);
  }

  ll i;
  for (i = n - 1;i >= 0;i -= 2) {
	cout << a[i] << " ";
  }

  if (i % 2 == 0) {
	i = 1;
  }
  else {
	i = 0;
  }
  for (;i < n;i += 2) {
	cout << a[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    if((A>8 || B>8) && A+B>8 ){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    return 0;
}


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

class Dice_c{

private:
  int me[4];
  int back;
  int front;

public:
  void Input();
  void RollVerch();
  void RollHorizon();
  void RollLeft();
  void RollRight();
  int GetMe(int num);

};

bool Check(Dice_c a,Dice_c b){
  for(int i=1; i<7; i++){
    if(a.GetMe(i) != b.GetMe(i))
      return false;
  }

  return true;
}

int main(){

  Dice_c dice[100];
  bool flg=false;
  int n;

  cin >> n;

  for(int i=0; i<n; i++)
    dice[i].Input();

for(int q=0; q<n-1; q++){
    for(int p=q+1; p<n; p++){



      for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
          dice[p].RollHorizon();
          if(Check(dice[q],dice[p])){
            flg=true;
            goto End;
          }
        }
        dice[p].RollVerch();
      }

    dice[p].RollLeft();
    for(int i=0; i<4; i++){
      dice[p].RollHorizon();
      if(Check(dice[q],dice[p])){
        flg=true;
        goto End;
      }
    }
    dice[p].RollRight();
    dice[p].RollRight();
    for(int i=0; i<4; i++){
      dice[p].RollHorizon();
      if(Check(dice[q],dice[p])){
        flg=true;
        goto End;
      }
    }
    dice[p].RollLeft();



  }
  }

  End:;

  if(!flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


///////////////////////////////////////////////////////////////////////////
void Dice_c::Input(){

  cin >> me[1] >> front >> me[2] >> me[0] >> back >> me[3];
  getchar();

}

/////////////////////////////////////////////////////////////////////////
void Dice_c::RollVerch(){

  int tmp;

  tmp=front;
  front = me[1];
  me[1]=back;
  back=me[3];
  me[3]=tmp;

}
////////////////////////////////////////////////////////////////////////////

void Dice_c::RollHorizon(){

  int tmp;

  tmp=back;
  back=me[0];
  me[0]=front;
  front=me[2];
  me[2]=tmp;

}

/////////////////////////////////////////////////////////////////////////////

void Dice_c::RollLeft(){

  int tmp;

  tmp = me[0];
  me[0]=me[1];
  me[1]=me[2];
  me[2]=me[3];
  me[3]=tmp;

}
//////////////////////////////////////////////////////////////////////////////

void Dice_c::RollRight(){

  int tmp;

  tmp=me[3];
  me[3]=me[2];
  me[2]=me[1];
  me[1]=me[0];
  me[0]=tmp;

}
/////////////////////////////////////////////////////////////////////////////

int Dice_c::GetMe(int num){

  switch (num) {
    case 1:
      return me[1];
    case 2:
      return front;
    case 3:
      return me[2];
    case 4:
      return me[0];
    case 5:
      return back;
    default:
      return me[3];
  }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i < n; i++)
int main() {
  int x;
  cin >> x;
  if (x <= 599) cout << 8;
  else if (x <= 799) cout << 7;
  else if (x <= 999) cout << 6;
  else if (x <= 1199) cout << 5;
  else if (x <= 1399) cout << 4;
  else if (x <= 1599) cout << 3;
  else if (x <= 1799) cout << 2;
  else if (x <= 1999) cout << 1;
}
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,M,Q;
    cin>>N>>M>>Q;
    vector<vector<ll>> v(N,vector<ll> (N,0));
    vector<vector<ll>> s(N+1,vector<ll> (N+1,0));
    for(ll i=0;i<M;i++){
        ll l,r;
        cin>>l>>r;
        v[l-1][r-1]++;
    }
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++){
            s[i+1][j+1]=s[i+1][j]+s[i][j+1]-s[i][j]+v[i][j];
        }
    }
    for(ll i=0;i<Q;i++){
        ll p,q,ans;
        cin>>p>>q;
        ans=s[q][q]-s[p-1][q]-s[q][p-1]+s[p-1][p-1];
        cout<<ans<<endl;
    }
}


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

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

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT32_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)


int main() {
    int n,ans = 0;
    cin >> n;
    REP(i,n){
        int l,r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(void)
{
    int a,b,c,d,e,f;
    double x,y;
    
    cout << fixed << setprecision(3);
    while (cin >> a >> b >> c >> d >> e >> f) {
        if (a == 0) {
            y = (double)c / (double)b;
            x = ((double)f - (double)e * y) / (double)d;
        } else {
            y = (double)(a * f - c * d) / (double)(a * e - b * d);
            x = ((double)c - (double)b * y) / (double)a;
        }
        cout << x << " " << y << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1236