akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  char A,B;
  cin>>A>>B;
  string a,b;
  REP(i,0,B-'0'){
    a.push_back(A);
  }
  REP(i,0,A-'0'){
    b.push_back(B);
  }
  cout<<min(a,b)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int a,i,t;

int main() {

 scanf("%d",&a); 

 int s[a];
 
 for(i=0;i<a;i++)
  {
   scanf("%d",&s[i]);
  }
  
 for(i=0;i<a;i++) 
  {
   if(s[i]%2==0)
   {
     if(s[i]%3==0)
      {
        s[i]=0;
      }
     else
     {
       if(s[i]%5==0)
       {
         s[i]=0;
       }  
       else
       {
         s[i]=1;
       }
     }
   }
   else
   {
     s[i]=0;
   }
  }
  
  for(i=0;i<a;i++) 
  {
    if(s[i]>t)
    {
       
     t=s[i];
       
    }
  }
 
  if(t==0)
  {
   printf("APPROVED");
  }
  if(t!=0)
  {
   printf("DENIED");
  }

  
  return 0;
}
  

Measured memory_bytes: 2152
#include <iostream>

using namespace std;

int main(){
  int m,f,r;

  while(1){
    cin >> m >> f >> r;

    if( m == -1 && f == -1 && r == -1) break;
    else if( m == -1 || f == -1) cout << "F" << endl;
    else if( m+f >= 80) cout << "A" << endl;
    else if( m+f >= 65 && m+f < 80 ) cout << "B" << endl;
    else if( m+f >= 50 && m+f < 65) cout << "C" << endl;
    else if( m+f >= 30 && m+f < 50 && r >= 50) cout << "C" << endl;
    else if( m+f >= 30 && m+f < 50 && r < 50) cout << "D" << endl;
    else if( m+f < 30) cout << "F" << endl;
  }
  return 0;
}

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector<int> fact;

int powm(int n, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) 
      res = (res * 1ll * n) % mod;
    p >>= 1;
    n = (n * 1ll * n) % mod;
  }
  return res;
}

int inv(int n) {
  return powm(n, mod - 2);
}

int binom(int n, int k) {
  return (fact[n] * 1ll * inv((fact[k] * 1ll * fact[n - k]) % mod)) % mod;
}

void solve() {
  fact.resize(1e6);
  fact[0] = 1;
  rep(i, 1, 1e6) {
    fact[i] = (fact[i - 1] * 1ll * i) % mod;
  }

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

  int l = n + m + k;
  int res = 0;
  int prev = 0;
  int row_sum = 1;
  rep(i, n, l) {
    int mid_sum = row_sum;
    if (i - n - k > 0) {
      int prev_left = max(0, i - 1 - n - k);
      prev += binom(i - 1 - n, prev_left);
      prev %= mod;
    }
    if (m < i - n) {
      int prev_right = min(i - 1 - n, m);
      prev += binom(i - 1 - n, prev_right);
      prev %= mod;
    }
    mid_sum = (mod + mid_sum) - prev;
    mid_sum %= mod;
    int temp = (mid_sum * 1ll * binom(i - 1, n - 1)) % mod;
    res += (temp * 1ll * powm(3, l - i)) % mod;
    res %= mod;
    row_sum = (row_sum * 1ll * 2) % mod;
    prev = (prev * 1ll * 2) % mod;
  }

  cout << res;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}


Measured memory_bytes: 7104
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
#define double long double
const int N = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1);
struct poi {
	int x, y;
	poi(int _x = 0, int _y = 0) {x = _x, y = _y;}
	inline bool operator < (const poi &a) const {
		return x == a.x ? y < a.y : x < a.x;
	}
} p[N];
int n, xs, ys, xt, yt, top, stk[N]; double ans;

inline int max(int a, int b) {return a > b ? a : b;}
inline int min(int a, int b) {return a < b ? a : b;}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void init() {
	in(xs), in(ys), in(xt), in(yt), in(n);
	for (int i = 1; i <= n; ++i) in(p[i].x), in(p[i].y);
	if (xs > xt) {
		xs = inf - xs, xt = inf - xt;
		for (int i = 1; i <= n; ++i) p[i].x = inf - p[i].x;
	}
	if (ys > yt) {
		ys = inf - ys, yt = inf - yt;
		for (int i = 1; i <= n; ++i) p[i].y = inf - p[i].y;
	}
	for (int i = n; i; -- i)
		if (p[i].x < xs || p[i].x > xt || p[i].y < ys || p[i].y > yt)
			p[i] = p[n--];
}

inline void work() {
	int l, r, mid;
	sort(p + 1, p + n + 1);
	for (int i = 1; i <= n; ++i) {
		for (l = 1, r = top + 1; l < r;) {
			mid = l + r >> 1;
			if (stk[mid] > p[i].y) r = mid;
			else l = mid + 1;
		}
		stk[l] = p[i].y, top = max(top, l);
	}
	ans = ((double)xt - xs + yt - ys) * 100.0 + top * (5 * pi - 20);
	if (top == min(xt - xs, yt - ys) + 1) ans += 5 * pi;
	printf("%.15Lf\n", ans);
}

int main() {init(), work(); return 0;}

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;

int n, m;
int fn[101][101];
int ans;

void dfs(int idx, vector<int> rab)
{
  if(rab.size() > 1) {
    int sum = 0;
    for(int a : rab) {
      int mn = inf;
      for(int b : rab) {
	if(a == b) continue;
	mn = min(mn, fn[a][b]);
      }
      sum += mn;
    }
    ans = max(ans, sum);
  }
  reps(a, idx, n) {
    bool flag = true;
    for(int b : rab) {
      if(fn[a][b] == 0) {
	flag = false; break;
      }
    }
    if(flag) {
      auto nrab = rab;
      nrab.push_back(a);
      dfs(a+1, nrab);
    }
  }
  
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> n >> m;
  memset(fn, 0, sizeof(fn));
  rep(i, m) {
    int u, v, f;
    cin >> u >> v >> f; u--, v--;
    fn[u][v] = fn[v][u] = f;
  }

  ans = 0;
  dfs(0, vector<int>());

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

Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define mem(a, i) memset(a, i, sizeof(a))
using namespace std;
const int maxn = 200005;
int n, k;
int cnt[maxn];
vector<int> vec;
int main() {
    while(~scanf("%d%d", &n, &k)) {
        mem(cnt, 0);
        vec.clear();
        for(int i = 1; i <= n; ++i) {
            int val;
            scanf("%d", &val);
            cnt[val]++;
        }
        for(int i = 1; i <= 200000; ++i) {
            if(cnt[i]) vec.push_back(cnt[i]);
        }
        sort(vec.begin(), vec.end());
        int len = vec.size();
        int ans = 0;
        if(len > k) {
            for(int i = 0; i < len - k; ++i) {
                ans += vec[i];
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2168
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  cout << fixed << setprecision(15);
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  double wmax=(double)f*100/(100+e);
  double smax=(double)f*e/(100+e);
  double pmax=-1;
  int ans1=0,ans2=0;
  for(int i=0;i<=f;i+=a*100){
    for(int j=0;i+j<=f;j+=b*100){
      if(i+j==0) continue;
      for(int k=0;i+j+k<=f;k+=c){
        for(int l=0;i+j+k+l<=f;l+=d){
          if((double)(k+l)/(i+j)>(double)e/100) continue;
          if((double)(k+l)*100/(i+j+k+l)>pmax){
            //cout << i << " " <<  j << " " << k << " " << l << " " << pmax << endl;
            pmax=(double)(k+l)*100/(i+j+k+l);
            ans1=i+j+k+l;
            ans2=k+l;
          }
        }
      }
    }
  }
  //cout << wmax << " " << smax << endl;
  cout << ans1 << " " << ans2 << endl;
}


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

int main()
{
    int l, r, n;
    cin >> l >> r >> n;

    int ans = 0;
    for (int i = l; i <= r; i++)
        if (i % n == 0)
            ans++;

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


Measured memory_bytes: 3632
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s = line.trim();
    if s == "RRR" {
        println!("3");
    } else if (&s[0..2] == "RR") || (&s[1..3] == "RR") {
        println!("2");
    } else if (&s[0..1] == "R") || (&s[1..2] == "R") || (&s[2..3] == "R") {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL s,k;
int main()
{
	int *p=new int;
	srand(*p);
	scanf("%lld",&s);
	k=ceil(sqrt(s));
	LL c=k*k-s;
	if(c==0)
	{
		printf("%lld %lld %lld %lld %lld %lld\n",0,0,k,0,0,k);
		return 0;
	}
	LL x=0;
	while(true)
	{
		LL d=sqrt(c);
		while(c%d!=0)d--;
		if(c==0)
		{
			printf("%lld %lld %lld %lld %lld %lld\n",0,0,k,0,0,k-x);
			return 0;
		}
		if(c/d<=1e9)
		{
			printf("%lld %lld %lld %lld %lld %lld\n",0,0,k-x,d,c/d,k);
			return 0;
		}
		x++;
		while(k*(k-x)<s)k++;
		c=k*(k-x)-s; 
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int n,x[200005],y[200005],pos[200005],dsu[200005],mi[200005],siz[200005],u;
map<int,int>mp;
map<int,int>::iterator it;
int getf(int p){return dsu[p]==p?p:dsu[p]=getf(dsu[p]);}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]),pos[x[i]]=i;
	//for(int i=1;i<=n;i++)scanf("%d",&y[i]);
	for(int i=1;i<=n;i++)dsu[i]=i,mi[i]=y[pos[i]],siz[i]=1;
	for(int i=1;i<=n;i++)
	{
		u=y[pos[i]];
		//printf("%d\n",u);
		while(!mp.empty()&&u>mp.begin()->first)
		{
			it=mp.begin();
			dsu[it->second]=i;
			//printf("#%d %d %d %d\n",it->second,i,it->first,u);
			siz[i]+=siz[it->second];
			mi[i]=min(mi[i],it->first);
			mp.erase(it);
		}
		mp[mi[i]]=i;
		//printf("@%d\n",mp[4]);
	}
	for(int i=1;i<=n;i++)printf("%d\n",siz[getf(x[i])]);
	//printf("\n");
	return 0;
}

Measured memory_bytes: 12576
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0;i < n; i++) {
            h[i] = sc.nextInt();
        }

        int[] a = new int[n];
        a[0] = 0;
        int max = 0;
        for (int i = 1;i < n; i++) {
            if (h[i] <= h[i-1]) {
                a[i] = a[i - 1] + 1;
                max  = Math.max(max, a[i]);
            } else {
                a[i] = 0;
            }
        }

        System.out.println(max);

    }
}


Measured memory_bytes: 50884
#include <iostream>
#include <algorithm>
using namespace std;
int C[8],c1,c2;
int n,a;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<3200)C[a/400]++;
        else c2++;
    }
    for(int i=0;i<8;i++)if(C[i])c1++;
    cout<<max(c1,1)<<" "<<c1+c2;
}

Measured memory_bytes: 256
def main():
    n, k = [int(x) for x in input().split()]
    h = [int(x) for x in input().split()]
    nk = n-k
    if nk < 0:
        nk = 0
    at = sorted(h)[:nk]
    print(sum(at))

if __name__ == '__main__':
    main()

Measured memory_bytes: 90572
#include <stdio.h>

int main(void)
{
	int a[3];
	int cunt = 0;
	scanf("%d %d %d", a, a+1, a+2);
	for (int i = 0; i < 2; i++)
		for (int j = i + 1; j < 3; j++)
		{
			if (a[i] > a[j])
			{
				int temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	for (int i = 1; i < 3; i++)
	{
		cunt += (a[i] - a[i - 1]);
	}
	printf("%d", cunt);
	return 0;
}

Measured memory_bytes: 128
<?php
//http://abc045.contest.atcoder.jp/tasks/arc061_a
fscanf(STDIN,"%d",$s);
$len = strlen($s);
$n = pow(2,$len-1);
$ans = 0;
for($i = 0 ; $i < $n ; ++$i){
    //2進数0左詰め
    //str_pad(decbin($i),$n,"0",STR_PAD_LEFT);
    //sprintf("%'0".$len."b",$i);
    $bin = array();
    $bin = str_split(sprintf("%'0".$len."b",$i));
    $formula = "";
    for($j = 0; $j < $len ; ++$j ){
        if(intval($bin[$j])===1){
            $formula .= "+";
        }
        $formula .= strval($s)[$j];
    }
    $arrval = array();
    $arrval = explode("+",$formula);
    $ans += array_sum($arrval);
}
echo $ans,PHP_EOL;

Measured memory_bytes: 3704
N = gets.to_i

alp = ["z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y"]

current_n = N
ans = ""
while current_n > 0 do
  i = current_n % 26
  ans = alp[i] + ans
  if i != 0 then
    current_n = (current_n - i) / 26
  else
    current_n = (current_n - 26) / 26
  end
end

print ans

Measured memory_bytes: 14316
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
char X,Y;
int M,N;
int main() {
    cin>>X>>Y;
    if(X=='A')M=10;
    if(Y=='A')N=10;
    if(X=='B')M=11;
    if(Y=='B')N=11;
    if(X=='C')M=12;
    if(Y=='C')N=12;
    if(X=='D')M=13;
    if(Y=='D')N=13;
    if(X=='E')M=14;
    if(Y=='E')N=14;
    if(X=='F')M=15;
    if(Y=='F')N=15;

    if(M<N)cout<<"<"<<endl;
    if(M==N)cout<<"="<<endl;
    if(M>N)cout<<">"<<endl;
    return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=True)
l=-1
r=a[-1]*f[0]

while r>l+1:
    cnt=0
    mid=(l+r)//2
    for i in range(n):
        cost=a[i]*f[i]
        if cost>mid:
            cnt+=a[i]-math.floor(mid/f[i])
    if cnt<=k:
        r=mid
    else:
        l=mid
print(r)

Measured memory_bytes: 113588
N = int(input())#100
AB = [0] * N
for i in range(N):
  AB[i] = list(map(int, input().split()))
AB = sorted(AB)
CD = [0] * N
for i in range(N):
  CD[i] = list(map(int, input().split()))
CD = sorted(CD)
#print(AB, CD)

ans = 0

used = [0] * N
for i in range(N):
  now_x, now_y = CD[i][0], CD[i][1]
  max_y = -1
  nn = -1
  for j in range(N):
    if (now_x > AB[j][0]) and (used[j] == 0):
      if now_y > AB[j][1]:
        if max_y < AB[j][1]:
          max_y = AB[j][1]
          nn = j
  if max_y != -1:
    ans += 1
    used[nn] = 1
    
print(ans)    
    
    
  
  
  
  
  
  

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

ll powmod(ll a, ll k, ll m) {
  if (k == 0) return 1;
  ll t = powmod(a, k / 2, m);
  t = (t * t) % m;
  if (k % 2 == 1) t = (t * a) % m;
  return t;
}

const int fnum = (uint)2e6 + 2;
ll fact[fnum];
ll inv[fnum];
ll finv[fnum];

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  fact[0] = fact[1] = 1;
  inv[1] = 1;
  finv[0] = finv[1] = 1;
  for (int i = 2; i <= k + n; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    inv[i] = mod - (mod / i * inv[mod % i]) % mod;
    finv[i] = (finv[i - 1] * inv[i]) % mod;
  }
  ll sum = 0;
  //n文字目がi番目にある
  for (int i = n; i <= k + n; i++) {
    ll prod = ((ll)fact[i - 1] * (finv[n - 1] * finv[i - n] % mod)) % mod;
    prod = (prod * powmod(25, i - n, mod)) % mod;
    prod = (prod * powmod(26, n + k - i, mod)) % mod;
    sum = (sum + prod) % mod;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 51132
#include<stdio.h>
 #include<iostream>
#include<vector>
#include<algorithm>
 using namespace std ; 
 vector<int> v  ;

 int main() {
   int n;
   cin >> n ; 
    int ans=0  ; 
    int a ; 
    for (int i = 0; i <n; ++i)
     {
     	cin >> a ; 
     	a-- ; 
     	ans+=a ; 
     }
     cout << ans ; 
 return 0 ; 
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
    int n,ans = 0;
    cin >> n;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n){
        bool flag = true;
        for(int j = 0; j < i ; ++j){
            if(h[i]<h[j]) flag = false;
        }
        if(flag) ++ans;
    }
    cout << ans << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

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


public class Main{ 

	public static void main(String args[]){
		
		Scanner scan = new Scanner(System.in);
		DiceExtend d = new DiceExtend(scan.nextLine());
		int qnum = scan.nextInt();
		for(int i=0; i< qnum;i++){
			d.rollSet(scan.nextInt(),scan.nextInt());
		}

	}

}
class DiceExtend extends Dice{
	public DiceExtend(String line){
		super(line);
	}
	public void printTop(){
		System.out.println(this.top);
	}
	public void rollSet(int t, int b){
		if(!frontRoll(t)){
			while(top!=t)
				roll('W');
		}
		while(back!=b)
				rotate();
		System.out.println(this.right);
	}
	boolean frontRoll(int t){
		for(int i=0;i<4;i++){
			roll('N');
			if(top==t)
				return true;
		}
		return false;
	}	
	
}
class Dice{
	int top;
	int back;
	int right;
	int left;
	int front;
	int bottom;
	public Dice(String line){
		String[] face = line.split(" ");
		top = Integer.parseInt(face[0]);
		back = Integer.parseInt(face[1]);
		right = Integer.parseInt(face[2]);		
		left = Integer.parseInt(face[3]);
		front = Integer.parseInt(face[4]);
		bottom = Integer.parseInt(face[5]);
	}
	void rotate(){
		int tmp = front;
		front = right;
		right=back;
		back = left;
		left = tmp;
	}
	public void roll(char c){
		int tmp = top;
		switch(c){
			case 'N':
				top = back;
				back=bottom;
				bottom = front;
				front = tmp;
				break;
			case 'E':
				top = left;
				left = bottom;
				bottom = right;
				right = tmp;
				break;
			case 'S':
				top = front;
				front = bottom;
				bottom = back;
				back = tmp;
				break;
			case 'W':
				top = right;
				right = bottom;
				bottom = left;
				left = tmp;
				break;
		}
	}


}

Measured memory_bytes: 17232
#include <stdio.h>
#define MAX 100000
#define INFTY 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n ,int left,int mid,int right){
	int n1 = mid - left;
	int n2 = right -mid;
	
	for( int i = 0; i < n1; i++) L[i] = A[left+i];
	for( int i = 0; i < n2; i++) R[i] = A[mid+i];
	L[n1].value = R[n2].value = INFTY;
	
	int i = 0 , j = 0;
	
	for( int k = left; k < right; k++){
		if(L[i].value <= R[j].value){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[] , int n , int left , int right){
	if(left + 1 < right){
		int mid = (left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int partition(struct Card A[] , int n , int p , int r){
	struct Card x = A[r];
	struct Card copy;
	int i = p-1,j;
	for( j = p; j < r; j++){
		if(A[j].value <= x.value){
			i++;
			copy = A[i];
			A[i] = A[j];
			A[j] = copy;
		}
	}
	
	copy = A[i+1];
	A[i+1] = A[r];
	A[r] = copy;
	return i+1;
	
}

void quickSort(struct Card A[], int n , int p , int r){
	int q;
	if(p < r){
		q = partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main(void){
	int n,i,v;
	struct Card A[MAX],B[MAX];
	char S[10];
	int stable = 1;
	scanf("%d",&n);
	for( i = 0; i < n; i++){
		scanf("%s %d",S,&v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	
	for( i = 0; i<n; i++){
		if(A[i].suit != B[i].suit) stable = 0;
	}
	
	if(stable == 1){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	
	for( i = 0; i < n; i++){
		printf("%c %d\n",B[i].suit,B[i].value);
	}
	return 0;
}




Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int s,w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe";
    }
    else cout << "safe";
    
    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    char a; cin >> a;

    if ('a' <= a && a <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
char mp[4]={'R','G','Y','B'};
int n,m,d,cx,cy;
int main()
{
    scanf("%d%d%d",&n,&m,&d);
    for(register int i=1;i<=n;puts(""),++i)
    for(register int j=1;j<=m;++j)
    cx=i+j+500,cy=i-j+500,printf("%c",mp[cx/d%2+(cy/d%2<<1)]);
    return 0;
}

Measured memory_bytes: 512
import re

if __name__ == "__main__":
    word = input()
    s = re.compile("[a-z]+")
    ans = "Yes"
    if s.fullmatch(word) is not None:
        unique_w = list(set(word))
        for w in unique_w:
            if word.count(w) % 2 != 0:
                ans = "No"
        

    print(ans) 

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 300005;

/* ...o(^-^)o... */

int main(){
    lint S; cin >> S;

    lint ng = 0, ok = 1e9;
    while(ok-ng>1){
        lint mid = (ng+ok)/2;
        if(S <= mid*mid) ok = mid;
        else ng = mid;
    }
    lint n = ok;

    lint r = S - n*(n-2);
    vector<lint> ans;
    if(r<=n) ans = {n-2,n,n-1,0,0,n-r};
    else ans = {n-1,n,n,0,0,2*n-r};
    rep(i,6) outs(ans[i]); out("");
}

Measured memory_bytes: 256
import queue
x=int(input())
avail=list(range(100,106))
ok=[False]*max(x+1,106)
q=queue.Queue()
for i in avail:
    ok[i]=True
    q.put(i)
while not q.empty():
    f=q.get()
    for i in range(100,106):
        if(i+f<=x and not ok[i+f]):
            ok[i+f]=True
            q.put(i+f)
print(1 if ok[x] else 0)

Measured memory_bytes: 4720
//2020 2.16 挿入ソート

#include <stdio.h>
#define MAX 100 

void insertionSort(int *,int);
void Print(int *,int);

int main()
{
    int a;
    int i;
    int A[MAX];

    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&A[i]);
    }
    Print(A,a);
    insertionSort(A,a);

    return 0;
}

void insertionSort(int *A,int N)
{
    int i,j;
    int temp;

    for(i=1;i<N;i++)
    {
        temp=A[i];  //比較値temp
        j = i;
        while(j>0 && A[j-1]>temp)
        {
            A[j] = A[j-1];
            A[j-1] = temp;
            j--;
        }
        Print(A,N);
    }
    return;
}

void Print(int *A,int N)
{
    for(int i=0;i<N;i++)
    {
        if(i==0) printf("%d",A[i]);
        else printf(" %d",A[i]);
    }
    printf("\n");
    return;
}


Measured memory_bytes: 2080
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I') {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100010;
int n;
int a[MAXN];
int f1[MAXN],f2[MAXN];
int maxx(int x,int y){
	return x>y?x:y;
}
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		i%2==1?f1[a[i]]++:f2[a[i]]++;
	}
	int max1=0,max2=0;
	for(int i=1;i<=100000;i++){
		if(f1[i]>f1[max1])max1=i;
		if(f2[i+1]>f2[max2])max2=i+1;
	}
	if(max1!=max2){
		cout << n-f1[max1]-f2[max2] << endl;
	}
	else{
		int max3=0,max4=0;
		for(int i=1;i<=100000;i++)
		if(f1[i]>f1[max3]&&i!=max1)max3=i;
		for(int i=2;i<=100000;i++)
		if(f2[i]>f2[max4]&&i!=max2)max4=i;
		int ma=maxx(f1[max1]+f2[max4],f2[max2]+f1[max3]);
		cout << n-ma << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};


fn solve(n: u64) -> bool {
    let f = format!("{}", n)
        .as_bytes()
        .into_iter()
        .cloned()
        .map(|d| d - b'0')
        .sum::<u8>() as u64;
    n % f == 0
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", if solve(sc.next()) { "Yes" } else { "No" });
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}


trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
#D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, m = LI()
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

check = [True]*n
ans = [None]*n
que = deque()
que.append((0,-1))
while que:
    v, p = que.popleft()
    if not check[v]:
        continue
    check[v] = False
    for u in edges[v]:
        if u == p:
            continue
        que.append((u,v))
        if ans[u] == None:
            ans[u] = v+1

for i in range(1,n):
    if ans[i] == None:
        print('No')
        break
else:
    print('Yes')
    for i in ans[1:]:
        print(i)

Measured memory_bytes: 101964
from collections import defaultdict

n = int(input())
a = [int(i) for i in input().split()]

a_l = defaultdict(int)
a_r = defaultdict(int)

for i in range(n):
    a_l[i+a[i]] += 1
    a_r[i-a[i]] += 1

cnt = 0
for k in set(a_l.keys()) & set(a_r.keys()):
    cnt += a_l[k] * a_r[k]

print(cnt)

Measured memory_bytes: 74776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  
  rep(i,s.length()){
      s[i] += n;
    if(s[i]>90)s[i] -= 26;
  }
  
  
  cout << s << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int G[N] = {0};

void init() {
    int i;
    for (i = 0; i < N ;++i) G[i] = i;
}

int find(int x) {
    if (x == G[x]) return x;
    return G[x] = find(G[x]);
}

int eq(int a, int b) {
    if(find(a) == find(b)) return 1;
    else return 0;
}

void cone(int a, int b) {
    a = find(a);
    b = find(b);

    if(a == b) return;
    G[b] = a;
}

int main() {
    int i, j, m, v, k, s;
    init();
    scanf("%d %d\n", &s, &m);

    for(i = 0; i < m; ++i) {
        scanf("%d %d\n", &j, &v);
        cone(j, v);
    }
    scanf("%d\n", &k);
    
    for(i = 0; i < k; i++) {
		scanf("%d %d\n", &j, &v);
        if(eq(j, v))    printf("yes\n");
        else    printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 2128
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))

cnt=0
for i in range(n):
    if x>0:
        x-=a[i]
        cnt+=1
        
if x>0:
    cnt-=1
if x<0:
    cnt-=1
print(cnt)


Measured memory_bytes: 3060
#include<iostream>
#include<list>
#include<algorithm>
using namespace std;
int main(){
	//declairring
	int n,q,c=0,tmp;
	list<int> S,T;
	//inputting
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> tmp;
		S.push_back(tmp);
	}
	cin >> q;
	for(int i=0;i<n;i++){
		cin >> tmp;
		T.push_back(tmp);
	}
	//searching &counting
	for(;!T.empty();){
		if(count(S.begin(),S.end(),T.front())>0)
			c++;
		T.remove(T.front());
	}
	//outputting
	cout<< c << endl;
	return 0;
}

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

int main(void)
{
  int n;
  int ice_creams[10];
  int ice_index;
  while (true)
  {
    cin >> n;
    if (n == 0) break;
    fill_n(ice_creams, 10, 0);
    for (int i = 0; i < n; ++i)
    {
      cin >> ice_index;
      ++ice_creams[ice_index];
    }

    for (int i = 0; i < 10; ++i)
    {
      if (ice_creams[i] == 0)
      {
        cout << '-' << endl;
      }
      else
      {
        for (int j = 0; j < ice_creams[i]; ++j)
        {
          cout << '*';
        }
        cout << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
int main(void){
int n;
int a[1000];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(int i=n-1;i>0;i--){
printf("%d ",a[i]);
}
printf("%d\n",a[0]);
return 0;
}

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

int main() {
 set<UL> S;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL c,x; scanf("%u%u",&c,&x);
  if(c==0){
   S.insert(x);
   printf("%u\n",S.size());
  }
  if(c==1){
   printf("%u\n",S.count(x));
  }
 }
 return 0;
}




Measured memory_bytes: 12528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  
  cin >> a >> b;
  if((a+b) % 2 == 0){
    cout << (a + b) / 2 << endl;
  } else {
    cout << (a + b) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main() {
	int n, *a;
	int ans, sum;
	while (1) {
		cin >> n;
		if (n == 0)
			break;
		a = new int[n];
		for (int i = 0; i < n; i++)
			cin >> a[i];
		ans = a[0];
		for (int i = 0; i < n; i++) {
			sum = a[i];
			ans = max(ans, sum);
			for (int j = i + 1; j < n; j++) {
				sum += a[j];
				ans = max(ans, sum);
			}
		}
		cout << ans << endl;
		delete[] a;
	}
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
const int N=15;
char s[N][10000];
int cnt[N];
int h,w,K,ans=0x3f3f3f3f;
int main()
{
	scanf("%d %d %d",&h,&w,&K);
	for(int i=0;i<h;i++) cin>>s[i];
	for(int i=0;i<1<<h-1;i++) //枚举横切 
	{
		memset(cnt,0,sizeof cnt); //记录每一块区域1的个数 
		bool f=0;
		int now=0;//记录总共的切数 
		for(int j=0;j<h-1;j++) if(i>>j&1) now++;
		for(int j=0;j<w;j++)//枚举竖切 
		{
			int id=0;
			bool flag=0;
			for(int k=0;k<h;k++) //遍历横切和竖切所包围的区域1的个数 
			{
				cnt[id]+=(s[k][j]=='1');
				if(cnt[id]>K)  flag=1; //这个说明需要竖切 
				if(i>>k&1) id++; //跳到下个区域中 
			}
			if(flag==1) 
			{
				now++;//总切数+1 
		
				memset(cnt,0,sizeof cnt); //把之前的切数置0，但是后面的不需要，因为后面的还是满足条件的 
				id=0;
				for(int k=0;k<h;k++)
				{
					cnt[id]+=(s[k][j]=='1');
					if(cnt[id]>K)  f=1; //这边不满足的意思和上面的那个不满足意义不一样。这次不满足说明了我需要横切了 
					if(i>>k&1) id++;
				}
			}
		}
		if(!f&&now<ans) 
		{
			ans=now;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  n, m = map(int, input().split())
  ps = [1e+9] * (2 ** n)
  ps[0] = 0

  for _ in range(m):
    p, _ = map(int, input().split())
    k = 0

    for i in map(int, input().split()):
      k |= 1 << (i - 1)

    for i in range(len(ps)):
      s = k | i
      ps[s] = min(ps[i] + p, ps[s])

  if ps[-1] == 1e+9:
    ps[-1] = -1

  print(ps[-1])


if __name__ == '__main__':
  main()


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

long long n,d,x,y,ans=0;

int main()
{
    scanf("%lld%lld",&n,&d);
    for(int i=1;i<=n;++i) {
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;

    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    rep(i,s.size()){
        cout<<'x';
    }

    cout<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	char a[100][100],b[100][100];
	int c=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)cin>>a[i][j];
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++)cin>>b[i][j];
	}
	for(int i=0;i<=n-m;i++){
		for(int j=0;j<=n-m;j++){
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l])c=1;
				}
			}
			if(c==0){cout<<"Yes"<<endl;return 0;}
			c=0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
g = [[] for i in range(n + 1)]

for i in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    g[a].append((b, c))
    g[b].append((a, c))

q, k = [int(x) for x in input().split()]

d = [-1] * (n + 1)
d[k] = 0
pq = deque()
pq.append(k)
while len(pq):
    u = pq.popleft()
    for v, w in g[u]:
        if d[v] != -1: continue
        d[v] = d[u] + w
        pq.append(v)

for i in range(q):
    u, v = [int(x) for x in input().split()]
    print(d[u] + d[v])


Measured memory_bytes: 44456
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n,k; cin >> n >> k;
  vi x(n); rep(i, n) cin >> x[i];
  int ans = 1e9;
  
  rep(i, n-k+1){
    chmin(ans,abs(x[i]) + x[i+k-1]-x[i]);
    chmin(ans,abs(x[i+k-1]) + x[i+k-1]-x[i]);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var list = new List<string>();
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var p = ReadInts();
                Array.Sort(p);
                var s = string.Join("", p);
                if (list.Contains(s))
                {
                    ans++;
                }
                else
                {

                    list.Add(s);
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 19964
#include<bits/stdc++.h>
using namespace std;
char s[105];
int cs;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s;
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='C'){
			cs=1;
		}else if(s[i]=='F'&&cs==1){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}



Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

A = a * x + b * y
if x <= y: B = c * x * 2 + b * (y-x)
else: B = c * y * 2 + a * (x-y)
C = c * max(x, y) * 2

print(min(A, B, C))

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    char s[3];
    int a=700;
    scanf("%s",s);
    if(s[0]=='o'){a+=100;}
    if(s[1]=='o'){a+=100;}
    if(s[2]=='o'){a+=100;}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*
1...................100000000
   10..............10000
        100..100

n = 2のときは ((b0 - a0 + 1) * (b1 - a1 + 1)) - (同じ区間の個数)

n >= 3のとき
一番小さな値と一番大きな値は無視できる
10.............10000
10.............10000
      100.100

なんか二分探索な気がする
中央値を二倍すれば整数
2 <= ans <= 2e9
で、たぶん連続

あるansが答えになりうるかを判定する

いや、もっと単純かも
連続ならば、最小値と最大値を求めるだけでいけるのでは
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (n % 2) cout << b[n / 2] - a[n / 2] + 1 << endl;
	else cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
	return (0);
}


Measured memory_bytes: 4828
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long div = pow(n, 0.5), i = div;
    while(n % i != 0) i--;
    long long ans = i + (n / i) - 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll x; cin >> x;
  ll bank = 100;
  for (int year = 1; ; ++year) {
    bank += bank / 100;
    if (bank >= x) {
      cout << year << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 3648