akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m,k,a,i,j;
    cin>>n>>m;
    int hash[m+1]={0};
    for (i=0;i<n;i++)
    {
        cin>>k;
        for (j=0;j<k;j++)
        {
            cin>>a;
            hash[a]++;
        }
    }
    int ans=0;
    for (i=1;i<=m;i++)
    {
        if (hash[i]==n)
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  string s;cin>>s;
  if(s[1]=='B'){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
//#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

typedef long long ll;
typedef vector<string> vi;
typedef pair<int,int> pi;

      ll bigmod ( long long a, int p, int m )
{
    if ( p == 0 )return 1; // If power is 0 ( a ^ 0 ), return 1

    if ( p & 1 ) // If power is odd
    {
        return ( ( a % m ) * ( bigmod ( a, p - 1, m ) ) ) % m;
    }
    else
    {
        long long tmp = bigmod ( a, p / 2, m );
        return ( tmp * tmp ) % m;
    }
}

int main()
{
         //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
           int t=1,caseno = 0;

   // scanf("%d",&t);

     while(t--){
       string s;cin >> s;
       if(s=="BBB" || s=="AAA"){
        cout << "No" << endl;
       }
       else cout << "Yes" << endl;
    }

    return 0;
}



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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int dp[3030][3030];


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

	int N, T;
	cin >> N >> T;

	vector<Pii> items(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		items[i].first = a;
		items[i].second = b;
	}

	sort(items.begin(), items.end());

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= T - 1; ++j) {
			dp[i][j] = -I_INF;
		}
	}

	for (int i = 0; i <= N; ++i) {
		dp[i][0] = 0;
	}
	for (int i = 0; i <= T - 1; ++i) {
		dp[0][i] = 0;
	}


	int ans = 0;

	
	for (int i = 1; i <= N; ++i) {
		int ai, bi;
		tie(ai, bi) = items[i - 1];
		for (int j = 0; j <= T - 1; ++j) {
			if (j - ai >= 0) {
				dp[i][j] = max(dp[i - 1][j - ai] + bi, dp[i - 1][j]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
			if (j - 1 >= 0) {
				dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			}
		}
		ans = max(ans, dp[i - 1][T - 1] + bi);
	}


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(all(a));
    rep(i, n) {
        if(x < a[i]) {
            cout << i << endl;
            return 0;
        }
        x -= a[i];
    }

    if(x) cout << n-1 << endl;
    else cout << n << endl;

    return 0;
}

Measured memory_bytes: 3632
#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;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100001
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;



int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(7);
string s,h;
cin>>s>>h;
if(s[2]!=h[0] || s[1]!=h[1] || s[0]!=h[2])cout<<"NO";
else cout<<"YES";



  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var N = long.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            var B = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long sum=0;
            for(var i=0;i<N;i++){
                if(A[i]>=B[i]){
                    sum+=B[i];
                    A[i] -= B[i]; 
                }else{
                    sum+=A[i];
                    long temp = Math.Max(A[i+1] - (B[i] - A[i]),0);
                    A[i] = 0;
                    sum += A[i+1] -temp;
                    A[i+1] = temp;
                }
            }
            System.Console.WriteLine(sum);
        }
    }
}


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

using namespace std;

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

const ll INF=1e9+7;

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	string s;
	cin>>s;
	int c=-1;
	int f=-1;
	rep0(i,s.size()){
		if(s[i]=='C'&&c==-1){
			c=i;
		}
		if(s[i]=='F'){
			f=i;
		}
	}
	cout<<((c<f&&c!=-1&&f!=-1)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
abcd = input()
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, '=7', sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, '=7', sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, '=7', sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, '=7', sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, '=7', sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, '=7', sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, '=7', sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, '=7', sep='')


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

#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cout<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#define debug2(x, y) cout<<__LINE__<<": "<<#x<<" = "<<x<<\
                                     "  "<<#y<<" = "<<y<<endl;
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define UNIQUE(c) \
    sort(all(c)); \
    (c).resize(unique(all(c))-c.begin());

#define PI 3.1415926535897932384626433832795028841971

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;

const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;

inline int cmp(double x, double y = 0, double tol = EPS){
  return ((x <= y+tol) ? (x+tol < y) ? -1:0:1);
}

int main() {

  long long n, m;

  cin >> n >> m;

  ll rsp = 0;

  rsp = n * (n - 1)/2 + m*(m - 1)/2;

  cout << rsp << endl;

	return 0;
}


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

enum POSITION{ONLINE_BACK = -2, CCW = -1, ON_SEGMENT = 0,
              CW = 1, ONLINE_FRONT = 2};

struct Point{
    long x;
    long y;
    Point(long x, long y) : x(x), y(y) {}
    Point(){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(){}
};
typedef vector<Point> Polygon;

POSITION get_position(Segment s, Point p){
    double c = cross(s.p2 - s.p1, p - s.p1);
    if (c > 0) return CCW;
    if (c < 0) return CW;
    double d = dot(s.p2 - s.p1, p - s.p1);
    if (d < 0) return ONLINE_BACK;
    if (d > dot(s.p2 - s.p1, s.p2 - s.p1)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2){
    if (get_position(s1, s2.p1) * get_position(s1, s2.p2) != -1) {
        return false;
    }
    if (get_position(s2, s1.p1) * get_position(s2, s1.p2) != -1) {
        return false;
    }
    return true;
}

int determine_containment(Point p, Polygon poly){
    Segment s_right(p, Point(p.x + 1e5, p.y));
    int count = 0;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(Segment(poly[i], poly[(i+1)%n]), p) == ON_SEGMENT) {
            return 1;
        }
        if (intersect(s_right, Segment(poly[i], poly[(i+1)%n]))) {
            count++;
        }
        if (get_position(s_right, poly[i]) == ON_SEGMENT) {
            int i_pre = (i == 0 ? n - 1 : i - 1);
            while (get_position(s_right, poly[i_pre]) != CCW && get_position(s_right, poly[i_pre]) != CW) {
                i_pre = (i_pre == 0 ? n - 1 : i_pre - 1);
            }
            int i_aft = (i + 1) % n;
            while (get_position(s_right, poly[i_aft]) != CCW && get_position(s_right, poly[i_aft]) != CW) {
                i_aft = (i_aft + 1) % n;
            }
            if (get_position(s_right, poly[i_pre]) * get_position(s_right, poly[(i+1)%n]) == -1) {
                count++;
            }
        }
    }
    if (count % 2) return 2;
    return 0;
}
int main(){
    int q;
    cin >> q;
    Polygon poly(q);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        poly[i].x = x;
        poly[i].y = y;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cout << determine_containment(Point(x, y), poly) << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

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

   int n = s.size();
   for (int i = 0; i <= n; i++) {
      for (int j = i; j <= n; j++) {
         if (s.substr(0,i) + s.substr(j,n-j) == "keyence") {
            cout << "YES" << endl;
            return 0;
         }
      }
   }
   cout << "NO" << endl;

   return 0;
}


Measured memory_bytes: 256
var     r,g,b:longint;

procedure nhap;
begin
        readln(r,g,b);
end;

procedure xuli;
var kq:longint;
begin
        kq:=r*100+g*10+b;
        if kq mod 4=0 then writeln('YES') else writeln('NO');
end;

begin
       // assign(input,'at_01.inp');reset(input);
        //assign(output,'at_01.out');rewrite(output);
                nhap;
                xuli;
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
int main(){
  ll n;cin>>n;
  vector<ll> x(n),y(n);
  rep(i,n){
    cin>>x[i];
    y[i]=x[i];;
  }
  sort(y.begin(),y.end());
  ll j=x.size()/2;
  rep(i,n){
    ll k=x[i];
    if(k<y[j])cout<<y[j]<<endl;
    else cout<<y[j-1]<<endl;
  }

}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), x = scanner.nextInt(), t = scanner.nextInt();
			System.out.println((n + x - 1) / x * t);
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, int> P_;
int N, Q;
int c[500005];
int last[500005];
int a[500005];
vector<P_> p;

template <typename T>
struct bit{
    int n;
    vector<T> data;

    bit(int n_){
        n = 1;
        while(n < n_) n *= 2;
        data = vector<T>(n+1);
        for(int i = 0; i <= n; i++) data[i] = 0;
    }
    
    T sum(int i){
        T ret = 0;
        while(i > 0){
            ret += data[i];
            i -= i&-i;
        }
        return ret;
    }

    void add(int i, T x){
        while(i <= n){
            data[i] += x;
            i += i&-i;
        }
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> Q;
    for(int i = 1; i <=N; i++) {
        cin >> c[i]; c[i]--;
        last[c[i]] = -1;
    }
     for(int i = 0; i < Q; i++){
        int l, r; cin >> l >> r;
        p.push_back(P_(P(r, l), i));
    }
    sort(p.begin(), p.end());
    bit<int> bt(N);
    int pr = 0;
    for(auto q: p){
        int l = q.first.second;
        int r = q.first.first;
        int idx = q.second;
        for(int i = pr+1; i <= r; i++){
            if(last[c[i]] != -1){
                bt.add(last[c[i]], -1);
            }
            bt.add(i, 1);
            last[c[i]] = i;
        }
        a[idx] = bt.sum(r)-bt.sum(l-1);
        pr = r;
    }
    for(int i = 0; i < Q; i++) cout << a[i] << endl;
}

Measured memory_bytes: 17572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 998244353 //1000000007

ll N, Q;
vl x(200100), E[200100], ans(200100);

void dfs(ll root, ll now) {
    ans[now] += x[now] + ans[root];
    for(auto e:E[now]){
        if(e != root) dfs(now, e);
    }
    return;
}

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

    // solution comes here

    cin >> N >> Q;
    ll a, b, p, X;
    rep(_, N-1) {
        cin >> a >> b;
        E[a-1].PB(b-1);
        E[b-1].PB(a-1);//根の情報はdfsの引数で与えるから、辺だけを入力
    }
    rep(_, Q) {
        cin >> p >> X;
        x[p-1] += X;
    }

    dfs(0,0);

    rep(i, N) cout << ans[i] << " ";
    cout << nl;
}

Measured memory_bytes: 25856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
string s,t;
int main(){
	cin >> s >> t;
	if(t.size()!=s.size()+1)puts("No");
	else{
		for(int i=0;i<s.size();i++)
			if(s[i]!=t[i])return puts("No"),0;
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>

#include<algorithm>
#include<cstring>
using namespace std;

int p[201];
int main() {
    int x, n;
    cin >> x >> n;
    for (int i =0 ;i < n; i++) {
        int a; cin >> a;
        p[a] = 1;
    }
    pair<int, int> ans = make_pair(1000, -1);
    for (int i = 0; i <= 101; i++) {
        if (p[i]) continue;
        ans = min(ans, make_pair(abs(i-x), i));
    }
    cout << ans.second;
 //   system("pause");
}

Measured memory_bytes: 3200
def circularSentence?(string)
  firstSentence = string[0...string.size/2]
  secondSentence = string[string.size/2...string.size].reverse
  if string.size.odd?
    secondSentence = string[string.size/2+1...string.size].reverse
  end
  return firstSentence  == secondSentence ? true : false
end
s=gets.chomp
n=s.size 
puts s == s.reverse && circularSentence?(s[0...(n-1)/2]) && circularSentence?(s[(n+3)/2-1...n]) ? :Yes : :No

Measured memory_bytes: 3836
import java.text.ParseException;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) throws ParseException {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String line2 = sc.nextLine();
		String[] k = line.split(" ");
		int[] v = new int[k.length];
		for (int i = 0; i < k.length; i++) {
			v[i] = Integer.parseInt(k[i]);
		}
		Daice daice = new Daice(v[0], v[1], v[2], v[3], v[4], v[5]);
		for (int i = 0; i < line2.length(); i++) {
			if (line2.substring(i, i + 1).equals("S")) {
				daice.south();
			} else if (line2.substring(i, i + 1).equals("E")) {
				daice.east();
			} else if (line2.substring(i, i + 1).equals("W")) {
				daice.west();
			} else if (line2.substring(i, i + 1).equals("N")) {
				daice.nouth();
			}

		}
		System.out.println(daice.f1);
	}

	public static class Daice {

		int f1;
		int f2;
		int f3;
		int f4;
		int f5;
		int f6;

		public Daice(int f1, int f2, int f3, int f4, int f5, int f6) {
			super();
			this.f1 = f1;
			this.f2 = f2;
			this.f3 = f3;
			this.f4 = f4;
			this.f5 = f5;
			this.f6 = f6;
		}

		public void south() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f6 = fs[1];
			f2 = fs[0];
			f1 = fs[4];
			f5 = fs[5];

		}

		public void nouth() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f6 = fs[4];
			f2 = fs[5];
			f1 = fs[1];
			f5 = fs[0];
		}

		public void east() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f6 = fs[2];
			f3 = fs[0];
			f1 = fs[3];
			f4 = fs[5];
		}

		public void west() {
			int[] fs = new int[] { f1, f2, f3, f4, f5, f6 };
			f6 = fs[3];
			f3 = fs[5];
			f1 = fs[2];
			f4 = fs[0];

		}

	}
}

Measured memory_bytes: 26044
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

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

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long



signed main(){
  
    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

    vector<string> ans;



string s,t;
    cin>>s>>t;
 
    int k;
    int match;
    int ques;
    int hoge;
    int flag=false;
 
    for(int i=0;i<s.size()-t.size()+1;i++){
        string tmp=s.substr(i,t.size());
        // cout<<"tmp:"<<tmp<<endl;

        match=0;
        ques=0;
 
        for(int j=0;j<tmp.size();j++){
 
 
            // cout<<tmp[j]<<" "<<t[j]<<endl;
 
            if(tmp[j]==t[j])match++;
            if(tmp[j]=='?')ques++;
 
 
        }
        // cout<<match<<" "<<ques<<" "<<t.size()<<endl;
 
        if(match+ques==t.size()){
            hoge=i;
            flag=true;
        }

        string aaa;


        if(flag){
        	aaa=s;
        	for(int j=0;j<t.size();j++){
        		aaa[j+hoge]=t[j];
        	}

        	for(k=0;k<s.size();k++){
        		if(aaa[k]=='?')aaa[k]='a';
        	}

        	// cout<<"aaa:"<<aaa<<endl;
        	ans.pb(aaa);
        	flag=false;
        }
    }

    if(ans.size()==0){
        	cout<<"UNRESTORABLE"<<endl;
        	return 0;
        }
 

    sort(ans.begin(),ans.end());

    cout<<ans[0]<<endl;


      
    
 	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif


struct UnionFind {
  vector<ll> par, siz;
  UnionFind(ll n):par(n),siz(n,1) {
    for (ll i = 0; i < n; ++i) par[i] = i;
  }
  ll size() { return par.size(); };
  ll root(ll x) {
    assert(x < size());
    if (par[x] == x) return x;
    else return par[x] = root(par[x]);
  }
  void merge(ll x, ll y) {
    assert(x < size());
    assert(y < size());
    ll rx = root(x);
    ll ry = root(y);
    if (rx == ry) return;
    if (siz[rx] < siz[y]) std::swap(rx, ry);
    par[rx] = ry;
    siz[ry] += siz[rx];
  }
  bool same(ll x, ll y) { 
    assert(x < size());
    assert(y < size());
    return root(x) == root(y);
  }
  ll size(ll x) {
    assert(x < size());
    return siz[root(x)];
  }
};


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,m;
  cin >> n >> m;
  vector<P> a(m);
  rep(i,m) {
    cin >> a[i].second >> a[i].first; //P(b,a)
    a[i].first--; a[i].second--;
  }
  sort(all(a));
  UnionFind tree(n);
  int ind = 0;
  rep(i,n-1) {
    if (ind < m && a[ind].first == i+1) {
      bool same = false;
      while (ind < m && a[ind].first == i+1) {
        if (tree.same(i,a[ind].second)) {
          same = true;
        }
        if (a[ind].first == i+1) ind++;
        else break;
      }
      if (same) continue; //NG
    }
    tree.merge(i,i+1);
  }
  int ans = 0;
  rep(i,n) {
    if (tree.root(i) == i) ans++;
  }
  cout << ans-1 << endl;
  return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<math.h>

int main()
{
	while (1)
	{
		int n;
		scanf("%d", &n);
		if (n == 0) break;
		int i, score[1001];
		for (i = 0; i < n; i++)
		{
			scanf("%d", &score[i]);
		}
		int alltotal = 0;
		for (i = 0; i < n; i++)
		{
			alltotal += score[i];
		}
		double avrage = 1.0*alltotal / n;
		double bload[1001];
		for (i = 0; i < n; i++)
		{
			bload[i] = powl(score[i] - avrage, 2);
		}
		double allbload = 0.0;
		for (i = 0; i < n; i++)
		{
			allbload += bload[i];
		}
		double bunsan = allbload / n;
		printf("%lf\n", sqrt(bunsan));

	}
	return 0;
}

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


int main(void){
    ll n;
    cin >> n;
    vector<ll> a;
    ll ans = 0;
    rep(i,n){
        ll x;
        cin >> x;
        x--;
        ans += x;
    }
    
    cout << ans <<endl;
    
    return 0;
}























































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool used[100002];
main(){
	int n;
	cin>>n;
	int a[n],m1=1e9,m2=-1e9,i1,i2;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(m1>a[i]){
		  m1=min(m1,a[i]);
		  i2=i;
		}
		if(m2<a[i]){
		  m2=max(m2,a[i]);
		  i1=i;
		}
	}
	if(abs(m1)<abs(m2)){
		cout<<n*2<<endl;
		cout<<i1+1<<' '<<1<<endl;
		cout<<i1+1<<' '<<1<<endl;
		for(int i=0;i<n-1;i++){
			cout<<i+1<<' '<<i+2<<endl;
		    cout<<i+1<<' '<<i+2<<endl;
		}
	}
	else{
		cout<<n*2<<endl;
		cout<<i2+1<<' '<<n<<endl;
		cout<<i2+1<<' '<<n<<endl;
		for(int i=n-1;i>=1;i--){
			cout<<i+1<<' '<<i<<endl;
		    cout<<i+1<<' '<<i<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> as(n);
  vector<int> bs(n);
  vector<int> cs(n);
  
  for (int i = 0; i < n; i++) {
    cin >> as[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> bs[i];
  }
  for (int i = 0; i < n-1; i++) {
    cin >> cs[i];
  }
  
  int result = 0;
  int old_a = -100;
  for (int i = 0; i < n; i++) {
    int a = as[i];
    result += bs[a-1];
    
    if(old_a + 1 == a) {
      result += cs[old_a-1];
    }
    
    old_a = a;
  }
  
  cout << result << endl;
  
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace ITP1_4_B
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }



        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>();
            list_result = getinputdata ();

           double r = double.Parse(list_result[0][0]);
            double b = Math.Pow(r,2) * Math.PI;
            //double c= r*2*Math.PI;
            double c= r*2*Math.PI;

//           Console.WriteLine("{0:f5},{1:f5}",b,c);

            Console.WriteLine((decimal)b + " " +(decimal)c);

        }
    }
}

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

using namespace std;

int main()
{
   int x,n;
   cin >> x >> n;
   if(n == 0) 
   {
       cout << x << endl;
       return 0;
   }
   vector<int>p(n);
   for(int i = 0;i < n; i++)
   {
       cin >> p[i];
   }
   sort(p.begin(),p.end());
   int i = 0;
   while(1)
   {
       if(find(p.begin(),p.end(),x-i) == p.end()) 
       {
           cout << x - i << endl;
           break;
       }
       if(find(p.begin(),p.end(),x+i) == p.end())
       {
           cout << x + i << endl;
           break;
       }
       i++;
   }
   return 0;
   
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int h, w, a, b; cin >> h >> w >> a >> b;
    vector<vector<int>> grid(h, vector<int>(w));
    rep(i, h) {
        rep(j, w) {
            if (i < b && j < a) grid[i][j] = 0;
            if (i < b && j >= a) grid[i][j] = 1;
            if (i >= b && j < a) grid[i][j] = 1;
            if (i >= b && j >= a) grid[i][j] = 0; 
        }
    }
    rep(i, h)rep(j, w) {
        cout << grid[i][j];
        if (j == w-1) cout << endl;
    }
}

Measured memory_bytes: 5120
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    vll p(3);
    rep(i,3)cin>>p[i];
    sort(all(p));
    int judge=p[2]*2-p[0]-p[1];
    if(judge%2==1){cout<<judge/2+2<<endl;return 0;}
    else cout<<judge/2<<endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<iostream>

#define FOR(i,m,n) for (int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define DEBUG(a) std::cout << a << std::endl;

using namespace std;

int main()
{
  int n;

  scanf("%d", &n);
  int p[n];
  for(int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
  }

  int c = 0;
  FOR(i,1,n-1) {

    int min = 99999;
    //if (i == 7) {
    //printf("%d %d %d\n", p[i-1], p[i], p[i+1]);
    // pi is the smallest
    {
      min = MIN(p[i-1],p[i+1]);
//      printf("%d %d %d\n", min, p[i-1], p[i+1]);
      min = MIN(min,p[i]);
      if (min == p[i])
        continue;
    }
    // pi is the smallest
    int max = -1;
    {
      max = MAX(p[i-1],p[i+1]);
      max = MAX(max,p[i]);
      if (max == p[i])
        continue;
    }
//    DEBUG(p[i]);
    c++;
    //}
  }

  DEBUG(c);

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

min = min(A, B, C, D, E)

ans = 4 + int(N/min)
if N % min != 0:
    ans = ans + 1
print(ans)


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

#define ll long long
#define mod 1000000007
#define IO_fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
    IO_fast
    int n;
    cin >> n;
    if(n>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VVVVI vector<vector<vector<vector<int>>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VVVVL vector<vector<vector<vector<LL>>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    while (true) {
        int N, M;
        cin >> N;
        if (N == 0) { break; }

        vector<pair<int, int>> v;
        FOR(i, 0, N) {
            int h, r;
            cin >> h >> r;
            v.emplace_back(make_pair(h, r));
        }
        cin >> M;
        FOR(i, 0, M) {
            int h, r;
            cin >> h >> r;
            v.emplace_back(make_pair(h, r));
        }
        sort(ALL(v));

        VVI dp(v.size() + 1, VI(v.size(), -1));
        dp[0][0] = 1;

        FOR(i, 0, v.size()) {
            int h1 = v[i].first, r1 = v[i].second;

            FOR(j, 0, dp[0].size()) {
                if (dp[i][j] != -1) {

                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

                    int h2 = v[j].first, r2 = v[j].second;
                    if (h2 < h1 and r2 < r1) {
                        dp[i + 1][i] = max(dp[i + 1][i], dp[i][j] + 1);
                    }
                }
            }
        }

        print(MAX(dp[v.size()]));
    }

    return 0;
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
#define for_each(it,a) for(__typeof a.begin() it = a.begin();it!=a.end();it++)
template<class T> inline void chmin(T& a, T b) { if( b < a ) a = b; }

int n, m;
struct edge{
  int pos, dang;
  vector < int >  value;
  edge( int pos, int dang): pos(pos), dang(dang), value( (n + 1) / 2 + 1, INF){};
};
int main(){

  while( cin >> n >> m , n){
    vector< vector < edge > > info(n);

    for(int i = 0; i < n; i++){
      int k;
      cin >> k;
      for(int j = 0; j < k; j++){
        int t, d;
        cin >> t >> d;
        info[i].push_back( edge( t, d));
      }
    }
    for_each( it, info[0]) it -> value[m] = 0;
    for_each( it, info[1]) it -> value[m - 1] = 0;
    int ret = INF;
    for( int i = 0; i < n; i++){
      for_each( now, info[i]){
        for(int j = m; j >= 0; j--){ //ジャンプできる残り回数
          int& cost = now -> value[j], dang = now -> dang, pos = now -> pos;
          if( cost == INF) continue;
          if(j > 0){ //ジャンプしてみる
            if(i + 2 >= n) chmin( ret, cost);
            else for_each( next, info[i + 2])
                   chmin( next -> value[j - 1], cost + (dang + next -> dang) * abs( pos - next -> pos));
          }
          if(i + 1 >= n) chmin( ret, cost);
          else for_each( next, info[i + 1])
                 chmin( next -> value[j], cost + (dang + next -> dang) * abs( pos - next -> pos));
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int T, D, L;
    cin >> T >> D >> L;
    if (T == 0) return false;

    int prev = -D - 1, ans = 0;
    for (int t = 0; t < T; ++t) {
        if (t - prev <= D) ++ans;

        int x;
        cin >> x;
        if (x >= L) prev = t;
    }

    cout << ans << endl;
    return true;
}

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



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x; cin >> x;
  bool flag = false;
  if(x>=30) flag = true;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

const double PI=3.14159265358979323846;

int main(void){
	int A, B, H, M;
	cin >> A >> B >> H >> M;
  double angle_M = PI*M/30;
	double angle_H = PI*H/6 + PI*M/360;

	double cos_phi = cos(abs(angle_H - angle_M));
	double d = A*A + B*B - 2*A*B*cos_phi;
	d = sqrt(d);
	cout << setprecision(11) << d << endl;

return 0;
}


Measured memory_bytes: 3544
#include<stdio.h>
int main(void){
  char s[100000];
  scanf("%s",s);
  int i,count=0;
  if(s[0]=='0'){
      for(i=1;i<100000;i++){
          if(s[i]==NULL) break;
          if(i%2==1&&s[i]=='0')
             count++;
          if(i%2==0&&s[i]=='1')
            count++;
      }
  }
  if(s[0]=='1'){
      for(i=1;i<100000;i++){
          if(s[i]==NULL) break;
          if(i%2==1&&s[i]=='1')
             count++;
          if(i%2==0&&s[i]=='0')
            count++;
      }
  }
    printf("%d",count);
  return 0;
  }
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll W, H;
string S[55];
int dh[2] = {1, 0};
int dw[2] = {0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    for(int i = 0; i < H; i++) cin >> S[i];
    int s = H * W;
    int t = s + 1;
    atcoder::mcf_graph<ll, ll> g(t + 1);
    ll ans = 0;
    ll num = 0;
    for(int h = 0; h < H; h++) {
        for(int w = 0; w < W; w++) {
            if(S[h][w] == '#') continue;
            if(S[h][w] == 'o') {
                g.add_edge(s, h*W+w, 1, 0);
                ans += (H-1-h) + (W-1-w);
                num++;
            }
            g.add_edge(h*W+w, t, 1, (H-1-h) + (W-1-w));
            for(int k = 0; k < 2; k++) {
                int newh = h + dh[k];
                int neww = w + dw[k];
                if(newh >= H) continue;
                if(neww >= W) continue;
                if(S[newh][neww] == '#') continue;
                g.add_edge(h*W+w, newh*W+neww, 100, 0);
            }
        }
    }
    auto tmp = g.flow(s, t, num);
    assert(tmp.first == num);
    ans -= tmp.second;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
// #define int long long
const int inf = 1e7;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T vals) {if (a > vals) a = vals;}template<class T> void smax(T& a, T vals) {if (a < vals) a = vals;}
const int N = 13;
const int X = 1e3 + 10;

int n, m;
int cost[X], b[X];
bitset<N> c[X];
unordered_map<bitset<N>, int> M;

int solve(bitset<N> mask){
   bool good = 1;

   for (int i = 0; i < n; ++i)
   {
      good &= mask[i] == 1;
   }

   if(good){
      return 0;
   }
 
   if(M.count(mask))
      return M[mask];

   int &ans = M[mask];

   ans = inf; 
   for (int i = 0; i < m; ++i)
   {
/*      if((mask | c[i]) == mask)
         continue;
*/     
      bitset<N> nmask = mask | c[i];
      smin(ans, cost[i] + solve(nmask));
   }
 
   return ans;
}
 
int32_t main(){_
 
   cin>>n>>m;

   bitset<N> T;
   for (int i = 0; i < m; ++i)
   {
      int tot;
      cin >> cost[i] >> tot;
      for (int j = 0; j < tot; ++j)
      {
         int x;
         cin >> x;
         --x;
         T.set(x, 1);
         c[i].set(x, 1);
      }
   }

   // cout<<T<<endl;

   for (int i = 0; i < n; ++i)
   {
      if(T[i] == 0){
         cout<<-1;
         exit(0);
      }      
   }

   bitset<N> yy;
   for (int i = 0; i < n; ++i)
   {
      yy[i] = 0;
   }

   cout<<solve(yy);
 
   return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int n = in.nextInt();
    int m = in.nextInt();
    int[] a = new int[n];
    double sum = 0;
    for (int i = 0; i < n; ++i) {
      a[i] = in.nextInt();
      sum += a[i];
    }
    Arrays.sort(a);
    double threshold = sum / (4 * (double)m);
    int idx = n - m;
    if ((double)a[idx] < threshold) System.out.println("No");
    else System.out.println("Yes");
  }
}


Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long ll;
const int MOD = (int)1e9 + 7;
int add(int x, int y)
{
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y)
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y)
{
	return ((ll)x * y) % MOD;
}

const int N = 5002;
int C[N][N];
int n;
int a, b, c;
int A[N], B[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d%d%d", &n, &a, &b, &c);

	if (b & 1)
	{
		printf("0\n");
		return 0;
	}
	b /= 2;

	for (int i = 0; i < N; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 1; i < N; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);

	if (b == 0)
	{
		A[0] = 1;
	}
	else
	{
		for (int i = 0; i <= c; i++)
			A[i] = C[b - 1 + i][i];
	}
	
	int ans = 0;
	for (int i = 0; i <= c; i++)
	{
		if (A[i] == 0) continue;
		for (int j = 0; j <= c && j <= a; j++)
		{
			if (i + j > c || (c - i - j) % 3 != 0) continue;
			int val = mult(A[i], C[b + a][a]);
			val = mult(val, C[a][j]);
			val = mult(val, C[a + b + (c - i - j) / 3][a + b]);
			ans = add(ans, val);
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 67200
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	map<int, int> mp;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		mp[a]++;
	}

	int startI = mp.begin()->first;
	int endI = (--mp.end())->first;
	int maxCount = 0;
	for (int i = startI; i < endI + 1; ++i) {
		int count = mp[i] + mp[i - 1] + mp[i + 1];
		maxCount = max(count, maxCount);
	}

	cout << maxCount << endl;
	return 0;
}


Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  long long N, x, y, z;
  cin >> N;
  x = 2;
  y = 1;
  z = 0;
    
    if(N == 1){
        z = 1;
      }
    else{
      for(int i = 0; i < N-1; i++){
          z = x + y;
          x = y;
          y = z;
      }
    }
    cout << z << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define dans(ans) cout << std::fixed << std::setprecision(10) << ans << endl;
main()
{
    double a,b,c,add,v;
    cin>>v;

    v=v/3;
    dans(v*v*v)
}
/// check long long
/// check array size()


Measured memory_bytes: 3764
# 入力
H,W=map(int,input().split())
 
l=[]
for i in range(H):
  x=input()
  # 白いマスのみからなる場合は追加しない
  if x!='.'*W:
    l.append(x)
 
rm=[]
for i in range(W):
  # フラグ
  f=True
  for j in range(len(l)):
    if l[j][i]=='#':
      f=False
 
  # 取り除く列の添字を保存しておく
  if f:
    rm.append(i)
 
a=[]
for x in l:
  for i in rm[::-1]:
    x=x[:i]+x[i+1:]
  a.append(''.join(x))
 
# 出力
for i in range(len(a)):
  print(''.join(a[i]))

Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		int[] distances = new int[totalVertex];
		for (int i=0;i<totalVertex;i++) {
			distances[i] = Integer.MAX_VALUE;
		}
		
		//set source dist to 0
		distances[s] = 0;
		
		int curr = getUnsettledNearest(distances);

		while (curr != -1) {
			LinkedList<Integer> neighbors = getUnsettledNeighbors(curr);
			ifSettled[curr] = true;
			for(Integer n : neighbors) {
				distances[n] = Math.min(distances[n], distances[curr]  + getWeight(curr, n));
			}
			curr = getUnsettledNearest(distances);
		}
		
		return distances;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}


Measured memory_bytes: 40176
def minimumNumOfCandies(candies,atmostValue):
  candiesToEat = 0
  for i in range( 0 , len ( candies ) - 1 ) :
    if( candies[i] > atmostValue ) :
      candiesToEat = candiesToEat + ( candies[i] - atmostValue)
      candies[i] = candies[i] - ( candies[i] - atmostValue )
    if( candies[i] + candies[i + 1] > atmostValue ):
      candiesToEat = candiesToEat + ( (candies[i + 1] + candies[i]) - atmostValue )
      candies[i + 1] = candies[i + 1] - ( (candies[i + 1] + candies[i])- atmostValue)
  return candiesToEat
n = list(int(i) for i in input().split())
candies = list( int (i) for i in input().split())
print(minimumNumOfCandies(candies,n[1]))

Measured memory_bytes: 14436