akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;
 
namespace std{
  bool operator < (const P &a,const P &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};
 
double eps=1e-8;
double PI=acos(-1);
 
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
bool eq(P a,P b){return (abs(a-b)<eps);}
 
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}
 
//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}
 
bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}
 
//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}
 
double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}
 
double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}
 
int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;  
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;// on
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < eps )return 0;//out
  else  return 2;//in
}
 
typedef pair<double,P> Pair;
vec ConvexHull(vec t){
  vector<Pair> u;
  vec R;
  int N=t.size(),K=0,C=0;
  for(int i=1;i<N;i++)if(t[i]<t[K])K=i;
  for(int i=0;i<N;i++)u.push_back(Pair(arg(t[i]-t[K]),t[i]));
  R.push_back(t[K]),C++;
  sort(u.begin(),u.end());
  for(int i=0;i<N;i++){
    P p=u[i].second;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==0)continue;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==2)continue;
    while(2<=C&&ccw(R[C-2],R[C-1],p)!=1)R.pop_back(),C--;
    R.push_back(p),C++;    
  }
  return R;
}
 
vec cutConvex(vec &t,P a,P b){
  int N=t.size();
  vec res;
  for(int i=0;i<N;i++){
    P c=t[i],d=t[(i+1)%N];
    int C=ccw(a,b,c),D=ccw(a,b,d);
    if(C!=-1)res.push_back(c);
    if(C+D==0&&max(C,D)==1)res.push_back(intersect(a,b,c,d));
  }
  return res;
}
 
double maxDist(vec &t){
  vec u=t;//ConvexHull(t);
  int N=u.size(),K=0;
  double res=0;
  for(int i=0;i<N;i++){
    while(abs(u[i]-u[K])<abs(u[i]-u[(K+1)%N]))K=(K+1)%N;
    res=max(res,abs(u[i]-u[K]));
  }
  return res;
}
 
 
int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  printf("%.8f\n",maxDist(t));
  return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
#define endl "\n"
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;


ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

ll int modInverse(ll int a,ll int m) 
{ 
    ll int g = __gcd(a, m); 
   
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
        
       return      power(a, m-2, m); 
   
} 


int main()
{
  fastio();
ll int T;
T=1;

while(T--)
{
  ll int l,r,d;
  cin>>l>>r>>d;
  ll int ans=r/d-l/d;
  if(l%d==0)ans++;
  cout<<ans<<endl;


  }
    return 0;
}

Measured memory_bytes: 3588
while True :
    a, op, b = input().split()
    if op == '?':
        break
    if   op == '+' : print(int(a) + int(b))
    elif op == '-' : print(int(a) - int(b))
    elif op == '*' : print(int(a) * int(b))
    else           : print(int(a) // int(b))

Measured memory_bytes: 7612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  if(str.at(0) == str.at(1) && str.at(0) == str.at(2) && str.at(1) == str.at(2)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
constexpr int inf=(1<<30)-1;
constexpr ll mod=1e9+7;



int main(){
      ll n;
      cin>>n;
      cout<<(n*(n-1))/2<<endl;
      return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long i,j,k,N,A,B,ans=0;
  
  scanf("%lld %lld %lld",&N,&A,&B);
  
  ans+=N/(A+B)*A;
  
  N%=(A+B);
  
  if(N<A)
    ans+=N;
  else
    ans+=A;
  
  printf("%lld\n",ans);
  return 0;
}

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

//#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 31;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<double> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	double sum = 0;
	for (int i = 0; i < k; i++) {
		sum += (a[i] + 1) / 2;
	}

	double ans = 0;
	for (int i = 0, j = k - 1; j < n; i++, j++) {
		ans = max(ans, sum);
		sum -= (a[i] + 1) / 2;
		if (j + 1 < n) sum += (a[j + 1] + 1) / 2;
	}
	cout << ans;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 1792
N,M=map(int, input().split())

mi = -1
ma = 100000000000
for i in range(M):
    l,r = map(int, input().split())
    mi = max(l, mi)
    ma = min(ma, r)

if ma >= mi:
    print(ma-mi+1)
else:
    print(0)


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int x, a, b;
  cin >> x >> a >> b;
  if(b-a > x) cout << "dangerous" << endl;
  else if(b-a > 0) cout << "safe" << endl;
  else cout << "delicious" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
 //   freopen("input.txt", "r", stdin);
    SPEED
    int n;
    cin >> n;
    vector<int> d(n);
    FOR(i, 0, n) {
        cin >> d[i];
    }
    int ans = 0;
    FOR(i, 0, n) {
        FOR(j, i + 1, n) {
            ans += d[i] * d[j];
        }
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
current = 0
count = 0
for i in 0..(n-1)
  if arr[i] == current + 1
    current = arr[i]
  else
    count += 1
  end
end
if current == 0
  puts -1
else
  puts count
end

Measured memory_bytes: 28624
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  string S;
  cin >> S;
  int zero =0, one=0;
  for(int i =0; i<S.length() ;i++){
    if(S[i]=='0'){
      zero ++;
    }
    else{
      one ++;
    }
  }
  cout << 2*min(zero,one) <<endl;



}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
int main(){
	std::vector<int> car,ans;
	int a;
	//int h=0;
	bool f=false;
	//std::vector<int>::iterator it=car.begin();
	while(std::cin>>a){
		if(a!=0&&!f){
			car.push_back(a);
			f=true;
		}else if(a!=0){
			//h++;
			//++it;
			car.push_back(a);
		}else{
			//ans.push_back(car[h]);
			//ans.push_back(n);
			ans.push_back(car.back());
			//it--;
			car.pop_back();
			//h--;
		}
	}
	for(int i=0;i<ans.size();i++){
		std::cout<<ans[i]<<std::endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int F;cin>>F;
    cout<<(F-30)/2<<endl;
}



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

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){


	int a,b;

	cin>>a;
	cin>>b;

	if(a>8||b>8){
		cout<<":("<<endl;
	}else{
		cout<<"Yay!"<<endl;
	}


	return 0;
}


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

const int INF = 1e8;

const int MAXN = 300;
int N;
vector<int> adjList[MAXN];
bool adj[MAXN][MAXN];

int dist[MAXN][MAXN];

int par[MAXN];
int getpar(int a) { return par[a] == a ? a : (par[a] = getpar(par[a])); }
bool merge(int a, int b) {
	a = getpar(a), b = getpar(b);
	if (a == b) {
		return false;
	}
	par[b] = a;
	return true;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		for (int j = 0; j < N; j++) {
			adj[i][j] = bool(s[j] - '0');
			if (adj[i][j]) {
				adjList[i].push_back(j);
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i==j) dist[i][j] = 0;
			else if (adj[i][j]) dist[i][j] = 1;
			else dist[i][j] = INF;
		}
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool visited = false;
		for (int j = 0; j < i; j++) {
			if (dist[i][j] != INF) {
				visited = true;
			}
		}
		if (visited) continue;

		vector<int> verts;
		for (int j = i; j < N; j++) {
			if (dist[i][j] == INF) continue;
			verts.push_back(j);
		}

		int best = -1;
		for (int st : verts) {
			int maxDist = 0;
			for (int a : verts) {
				maxDist = max(maxDist, dist[st][a]);
				for (int b : verts) {
					if (adj[a][b]) {
						if (abs(dist[st][a] - dist[st][b]) != 1) {
							goto notGood;
						}
					}
				}
			}
			best = max(best, maxDist + 1);

			notGood:
			;
		}
		if (best == -1) {
			cout << -1 << '\n';
			exit(0);
		}
		ans += best;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, D;
	cin >> N >> D;

	co((N + D * 2) / (D * 2 + 1));

	Would you please return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			//Input
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str;
			int num;
			long fact;

			while ((str = br.readLine()) != null) {
				num = Integer.parseInt(str);
				fact = 1;
				for (int i = 1; i <= num; i++) {
					fact = fact * i;
				}
				System.out.println(fact);
			}
			//Output
		} catch (Exception e) {
			System.out.println("error");
		}
	}

}

Measured memory_bytes: 24152
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int l=s.length();
   if(l<4)
   cout<<"No";
   else
   {
      string tp="YAKI";
      for(int i=0;i<4;i++)
     {
          if(s[i]!=tp[i])
          {
            cout<<"No";
            return 0;
           }
     }
     cout<<"Yes";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    }   

    else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    }   

    else {
        for (int i = 0; i < a.size(); i++) {
            if (a.at(i) > b.at(i)) {
                cout << "GREATER" << endl;
                return 0;
            }   
            else if(a.at(i) < b.at(i)) {
                cout << "LESS" << endl;
                return 0;
            }   
        }   
        cout << "EQUAL" << endl;
    }   
}


Measured memory_bytes: 256
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N, M;
vector<vector<Int> > S(11);
vector<bool> P;


void input() {
  cin >> N >> M;
  Int k, s;
  bool p;
  loop(m,0,M) {
    cin >> k;
    rep(k) {
      cin >> s;
      s--;
      S[m].push_back(s);
    }
  }
  rep(M) {
    cin >> p;
    P.push_back(p);
  }
}

Int bit(vector<bool> ss) {
  if (ss.size() == N) {
    bool ret = true;
    for (int m=0; m<M; m++) {
      Int count = 0;
      for (auto s: S.at(m)) count += ss.at(s);
      ret &= count % 2 == P.at(m);
    }
    return ret;
  }
  ss.push_back(false);
  Int ret = bit(ss);
  ss.at(ss.size()-1) = true;
  ret += bit(ss);
  return ret;
}

void solve() {
  vector<bool> ss;
  cout << bit(ss) << endl;
}

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


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int s,w;
  cin>>s>>w;
  if(w>=s)	cout<<"unsafe\n";
  else		cout<<"safe\n";
    return 0;
}



Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll M=1000000007;

ll power(ll m,ll n){
	ll tmp=1;
	if(n>0){
		if(n%2==0){
			tmp=(power(m,n/2)*power(m,n/2))%M;
		}else{
			tmp=(power(m,n-1)*m)%M;
		}
	}
	return tmp;
}

int main(void){
	ll m,n;
	cin>>m>>n;
	cout<<power(m,n)<<endl;
	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

int cnt;
ll num[60000],memo[60000];
ll a[3],d;

int uniquell(ll*a,ll*ans,int cnt){
	sortup(a,cnt);
	int c=0;
	ans[0]=a[0];
	rep(i,1,cnt)if(a[i]!=ans[c])ans[++c]=a[i];
	return c+1;
}

int bs(ll x){
	int l=0,r=cnt;
	while(r-l>1){
		int m=(l+r)/2;
		if(num[m]<=x)l=m;
		else r=m;
	}
	return l;
}

#define chmin(x,y)(x>y?x=y:0)
ll f(ll x){
	if(x==0)return 0;
	if(x==1)return d;

	int idx=bs(x);
	if(memo[idx])return memo[idx]-1;
	
	ll ans=1e12;
	if(x<1e12/d)ans=x*d;
	
	ll t;
	int div[]={2,3,5};
	rep(i,0,3){
		int m=div[i];
		if(x%m<=(m-1)/2){
			t=f(x/m);
			chmin(ans,t+a[i]+d*(x%m));
		}else{
			t=f(x/m+1);
			chmin(ans,t+a[i]+d*(m-x%m));
		}
	}

	memo[idx]=ans+1;
	return ans;
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		ll n;
		scanf("%lld%lld%lld%lld%lld",&n,a,a+1,a+2,&d);
		cnt=0;
		for(ll temp0=n;temp0;temp0/=2){
			for(ll temp1=temp0;temp1;temp1/=3){
				for(ll temp2=temp1;temp2;temp2/=5){
					num[cnt++]=temp2;
					num[cnt++]=temp2+1;
				}
			}
		}
		cnt=uniquell(num,num,cnt);
		rep(i,0,cnt)memo[i]=0;
		printf("%lld\n",f(n));
	}
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
using data = pair<char,int>;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
void print(const data& a) { cout << a.first << " " << a.second << '\n'; }
void solve(int n) {
    vector<char> a(n);
    for (auto& e : a) cin >> e;
    
    vector<int> vote(30, 0);
    data nax = make_pair('#', 0), bax = nax;
    
    auto judge = [&] (int i) {
        return bax.second + (n-i-1) < nax.second;
    };
    
    data ans;
    bool fin = false;
    for (int i = 0; i < n; i++) {
        int id = a[i] - 'A';
        vote[id]++;
        
        if (nax.first == a[i]) nax.second++;
        else if (bax.first == a[i]) {
            if (++bax.second > nax.second) swap(nax, bax);
        } else if (nax.second < vote[id]) {
            bax = nax; nax = make_pair(a[i], vote[id]);
        } else if (bax.second < vote[id]) {
            bax = make_pair(a[i], vote[id]);
        }
        
        if (judge(i)) {
            ans = make_pair(nax.first, i+1);
            fin = true;
            break;
        }
    }
    
    if (fin) print(ans);
    else cout << "TIE" << '\n';
}

int main() {
    int n;
    while (cin >> n) if (n) solve(n);
    return 0;
}


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

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

    int x;
    cin >> x;
    int ans = 1;
    for (int i = 2; i * i <= x; i++) {
        int tmp = i * i;
        while (tmp <= x) {
            ans = max(ans, tmp);
            tmp *= i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <boost/math/common_factor_rt.hpp>

#define ll long long

using namespace std;

int main() {
	int a[4];
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++)
	{
		a[i] = s[i] - '0';
	}

	for (int x = 0; x < (1 << 4); x++)
	{
		int sum = a[0];
		string s;
		s += (char)('0' + a[0]);
		for (int i = 0; i < 3; i++)
		{
			if (x & (1 << i)) {
				sum += a[i + 1];
				s += '+';
				s += (char)('0' + a[i + 1]);
			}
			else {
				sum -= a[i + 1];
				s += '-';
				s += (char)('0' + a[i + 1]);
			}
		}

		if (sum == 7) {
			cout << s << "=7" << endl;
			return 0;
		}
	}

	
}

int dsum(ll a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

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

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int n,k,d,a;
	bool f[M]={};
	cin>>n>>k;
	rep(i,0,k){
		cin>>d;
		rep(j,0,d){
			cin>>a;
			f[a]=true;
		}
	}
	int ans=0;
	rep(i,1,n+1){
		if(f[i]==false)ans++;
	}
	print(ans);



}

Measured memory_bytes: 3920
"""Minimum cost Sort."""

def min_cost_sort(A):
    """Sort list A in ascending order.
 
    And return the switching cost in sorting.
    """
    B = list(A)
    B.sort()
    cost = 0
    min_w = B[0]
    for i, b in enumerate(B):
        tmp_cost = 0
        bi = A.index(b)
        n = 1
        while bi != i:
            n += 1
            st = B[bi]
            si = A.index(st)
            tmp_cost += b + st
            A[bi], A[si] = st, b
            bi = si
        dec = (n - 1) * (b - min_w)
        inc = 2 * (min_w + b)
        if dec < inc:
            cost += tmp_cost
        else:
            cost += tmp_cost - dec + inc
    return cost


n = input()

A = list(map(int, input().split()))

ans = min_cost_sort(A)

print(ans)

Measured memory_bytes: 7800
#include <iostream>
#include <vector>
#define MAX 5010
using namespace std ;

int dp[MAX][MAX];
char c[MAX];
int n;

int calDP(int i, int j){
    if(dp[i][j]==0 && c[i]==c[j]){
        if(j<n-1){
            if(i+dp[i+1][j+1]<j) dp[i][j]=dp[i+1][j+1]+1;
            else dp[i][j]=dp[i+1][j+1];
        }
        else dp[i][j]=1;
    }
    return dp[i][j];
}

int main(){
    cin>>n>>c;
    vector< vector<int> > same(n);
    for(int j=n-1;j>=1;j--){
        for(int i=j-1;i>=0;i--){
            dp[i][j]=0;
        }
    }
    for(int i=n-1;i>=1;i--){
        for(int j=i-1;j>=0;j--){
            if(c[i]==c[j]) same[i].push_back(j);
        }
    }
    int ans=0;
    for(int j=n-1;j>=1;j--){
        for(int i:same[j]){
            ans=max(ans, calDP(i, j));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 158336
#include <iostream>

using namespace std;

int kin[] = { 10, 50, 100, 500 };

int main( void )
{
	int money;
	long long cnt = 0;
	while(cin >> money, money) {
		if(cnt++) cout << endl;
		int num[4];
		int sum = 0;
		for(int i=0; i < 4; ++i) {
			cin >> num[i];
			sum += (num[i] * kin[i]);
		}
		sum -= money;
		int ans[4];
		for(int i=3; i >= 0; --i) {
			ans[i] = (sum / kin[i]);
			sum %= kin[i];
			if(num[i] >= ans[i])
				ans[i] = num[i] - ans[i];
			else
				ans[i] = 0;
		}
		for(int i=0; i < 4; ++i) {
			if(ans[i] > 0) cout << kin[i] << ' ' << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string a[101];int n,i;
int main(){
    scanf("%d%*d",&n);
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int G[N][N];

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

  scanf("%d", &n);

  for(i=0;i<n;i++)
    {
      scanf("%d%d", &u, &k);
      for(j=0;j<k;j++)
	{
	  scanf("%d", &v);
	  G[u-1][v-1]=1;
	}
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  printf("%d", G[i][j]);
	  if(j+1<n)printf(" ");
	}
      printf("\n");
    }
  
  return 0;
}

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

typedef long long int ll;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k, a, b;
    cin >> k >> a >> b;
    
    ll ans;
    
    ll u = k - (a - 1);
    
    if(b-a > 2){
        ans = a + (b-a) * (u/2) + (u%2);
    }else{
        ans = 1 + k;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int n;
    cin >> n;
    vector<int> v(n);
    frr(i,n) cin >> v[i];
    int ans = 0,cnt = 0,menor = inf+inf;
    for(int i=0;i<n;i++){
        if(v[i] < 0){
            cnt++;
        }
        menor = min(menor,abs(v[i]));
        ans+=abs(v[i]);
    }
    if(cnt%2){
        cout << ans - 2*menor << endl;
        return 0;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 1024
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
even = a.select { |x| x.even? }
divide_3or5 = even.select { |x| x % 3 == 0 || x % 5 == 0 }
if even == divide_3or5
  puts "APPROVED"
else
  puts "DENIED"
end

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g(N + 1);
	deque<int> res;
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
		
		if (i == 0) {
			res.push_front(a);
			res.push_back(b);
		}
	}

	vector<bool> passed(N + 1, false);
	passed[res.front()] = true;
	passed[res.back()] = true;
	int cnt = 0;
	while (cnt++ < N) {
		bool ok = true;
		int s = res.front();
		int t = res.back();

		for (int i = 0; i < g[s].size(); ++i) {
			if (!passed[g[s][i]]) {
				passed[g[s][i]] = true;
				res.push_front(g[s][i]);
				ok = false;
				break;
			}
		}
		for (int i = 0; i < g[t].size(); ++i) {
			if (!passed[g[t][i]]) {
				passed[g[t][i]] = true;
				res.push_back(g[t][i]);
				ok = false;
				break;
			}
		}

		if (ok) {
			cout << res.size() << endl;
			while (!res.empty()) {
				cout << res.front() << " ";
				res.pop_front();
			}
			cout << endl;
			break;
		}
	}

	return 0;
}


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

#define PI  3.14159265

typedef struct {
  double x,y;
}XY;

void kock ( int , XY ,XY);

int main(){
  int n;
  XY p1 = {0.0,0.0} ,p2 = {100.0 , 0.0};
  scanf("%d", &n);

     printf("%f %f\n",p1.x,p1.y);
  kock( n , p1 , p2);
    printf("%f %f\n",p2.x,p2.y);
  return 0;
}
void kock ( int n , XY p1,XY  p2){
  if ( n == 0){ return;}
  XY s,t,u;
  s.x = (2 * p1.x + p2.x)/3.0;
  s.y = (2 * p1.y + p2.y)/3.0;
  t.x = ( p1.x + 2 *p2.x)/3.0;
  t.y = ( p1.y +2* p2.y)/3.0;
  u.x = (t.x -s.x) * cos ( PI /3.0 ) - (t.y -s.y) * sin ( PI /3.0) + s.x;
       u.y = (t.x -s.x) * sin ( PI /3.0 ) + (t.y -s.y) * cos ( PI /3.0) + s.y;  
  kock (n-1 ,p1 ,s );
  printf("%f %f\n",s.x,s.y);
  kock (n-1 ,s,u );
  printf("%f %f\n",u.x,u.y);
  kock (n-1 ,u,t );
  printf("%f %f\n",t.x,t.y);
  kock (n-1 ,t,p2 );

}



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

int main(){

    string n;
    cin>>n;

    if(n[0]==n[1] && n[1]==n[2]||n[1]==n[2] && n[2]==n[3]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}

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

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;

    for (int i = 0; i < dx; i++) cout << 'R';
    for (int i = 0; i < dy; i++) cout << 'U';
    for (int i = 0; i < dx; i++) cout << 'L';
    for (int i = 0; i < dy; i++) cout << 'D';
    
    cout << 'D';
    for (int i = 0; i < dx+1; i++) cout << 'R';
    for (int i = 0; i < dy+1; i++) cout << 'U';
    cout << 'L';

    cout << 'U';
    for (int i = 0; i < dx+1; i++) cout << 'L';
    for (int i = 0; i < dy+1; i++) cout << 'D';
    cout << 'R';

}

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

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}

double power(double vol, double k, int b){
       //double ans1 = 1.0;
       for(int i = 0; i < b; i++){
           vol -= vol*k;
       }
       return vol;
}

double pi = 3.14;

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin.sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector <ll> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    ll ans = vec[0];
    for(int i = 1; i < n; i++){
        ll g = gcd(ans, vec[i]);
        ans *= (vec[i]/g);
    }
    cout << ans;
    return 0;


}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define SWAP(a,b) do{int t=a; a=b; b=t;}while(0)
int main(void){
  int n,o,s,b[4];
  char i[10];
  scanf("%d",&n);
  while(n--){
    o=s=b[0]=b[1]=b[2]=b[3]=0;
    while(o<3){
      scanf("%s",i);
      if(strcmp(i,"HIT")==0){
	SWAP(b[2],b[3]);
	SWAP(b[1],b[2]);
	SWAP(b[0],b[1]);
	b[0]=1;
	if(b[3])s++;
	b[3]=0;
      }
      else if(strcmp(i,"HOMERUN")==0){
	int j;
	for(j=0;j<3;j++){
	  s+=b[j];
	  b[j]=0;
	}
	s+=1;
      }
      else if(strcmp(i,"OUT")==0)
	o++;
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 596
from heapq import heapify, heapreplace


n = int(input())
a = list(map(int, input().split()))

qa = a[:n]
qb = [-x for x in a[2*n:]]
heapify(qa)
heapify(qb)

sa = [0] * (n + 1)
sb = [0] * (n + 1)
sa[0] = sum(qa)
sb[n] = -sum(qb)

for i in range(n):
    x = qa[0]
    sa[i+1] = sa[i]
    if x < a[n+i]:
        sa[i+1] += a[n+i] - x
        heapreplace(qa, a[n+i])

    x = -qb[0]
    sb[-i-2] = sb[-i-1]
    if x > a[-n-1-i]:
        sb[-i-2] += a[-n-1-i] - x
        heapreplace(qb, -a[-n-1-i])

max_val = sa[0] - sb[n]
for i in range(n+1):
    max_val = max(max_val, sa[i] - sb[i])
print(max_val)


Measured memory_bytes: 117268
fn main() {
    let r = std::io::stdin();
    let mut sc = Scanner::new(r.lock());
    let v = sc.read_line();

    let mut h : i32 = v[0].parse().unwrap();
    let n : usize = v[1].parse().unwrap();

    let v = sc.read_line();

    for i in 0..n {
        let a : i32 = v[i].parse().unwrap();
        h -= a;
    }

    if h <= 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct Scanner<R: std::io::Read> (std::io::BufReader<R>);

impl<R: std::io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner (std::io::BufReader::new(r))
    }

    pub fn read_line(&mut self) -> Vec<String> {
        use std::io::BufRead;
        let mut line = String::new();
        self.0
            .read_line(&mut line)
            .unwrap();

        line.split_whitespace()
            .map(|b| b.to_string())
            .collect::<Vec<String>>()
    }
}

Measured memory_bytes: 10492
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int max, min, n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i == 0) min = max = a;
        else {
            if (min > a) min = a;
            if (max < a) max = a;
        }
    }
    cout << max - min << endl;
}


Measured memory_bytes: 256
s = input()
t = ""
ans = 0
prev = 2
i = 0
while i < len(s):
    if prev == 2:
        ans += 1
        prev = 1
        i += 1
    elif s[i-1] != s[i]:
        ans += 1
        prev = 1
        i += 1
    elif (i+1) == len(s):
        break
    else:
        ans += 1
        prev = 2
        i += 2
            

print(ans)

Measured memory_bytes: 3500
n=int(input())
a=list(map(int, input().split()))
cnt=[0]*((10**6)+1)
unique=[]

for num in a:
    cnt[num]+=1

for i in range(10**6 +1):
    if cnt[i]==1:
        unique.append(i)

table=[0]*((10**6)+1)
a=list(set(a))

for elem in a:
    for i in range(2*elem, 10**6 +1, elem):
        table[i]=1

ans=0

for elem in unique:
    if table[elem]==0:
        ans+=1

print(ans)

Measured memory_bytes: 143808
N = gets.to_i
A = gets.split.map(&:to_i)
Q = gets.to_i
B = Array.new Q
C = Array.new Q
Q.times do |i|
  B[i], C[i] = gets.split.map(&:to_i)
end

counts = {}
sum = 0
A.each do |a|
  counts[a] ||= 0
  counts[a] += 1
  sum += a
end

Q.times do |i|
  b = B[i]
  c = C[i]
  if cnt = counts[b]
    sum += (c - b) * cnt
    counts[c] ||= 0
    counts[c] += cnt
    counts.delete(b)
    puts sum
  else
    puts sum
  end
end

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

#define PI 3.141592653589793238462;

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ak = (h+m/60)*30;
    double bk = 6*m;
    double k = abs(ak-bk)>180?360-abs(ak-bk):abs(ak-bk);
    k= k/180*PI;
    double ans = a*a + b*b - 2*a*b*cos(k);
    ans = abs(ans);
    ans = pow(ans,0.50);
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    n, k, q = rli()
    solve = [0 for _ in range(n+1)]
    for i in range(q):
        a = ri()
        solve[a] += 1
    for i in range(n):
        if k-q+solve[i+1] > 0:
            print("Yes")
        else:
            print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 4732
n = input()
op_cnt = len(n) - 1  
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break


Measured memory_bytes: 3060
N = int(input())
B = list(map(int, input().split()))
A = [B[0],B[0]]

for i in range(N-2):
    if B[i] <= B[i+1]:
        A.append(B[i+1])
    else:
        A[i+1] = B[i+1]
        A.append(B[i+1])

print(sum(A))

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

int data[400000],datb[400000];
void add(int a,int b,int x,int k,int l,int r){
	if(a<=l&&r<=b)data[k]+=x;
	else if(l<b&&a<r){
		datb[k]+=(min(b,r)-max(a,l))*x;
		add(a,b,x,k*2+1,l,(l+r)/2);
		add(a,b,x,k*2+2,(l+r)/2,r);
	}
}
int sum(int a,int b,int k,int l,int r){
	if(b<=l||r<=a)return 0;
	else if(a<=l&&r<=b)return data[k]*(r-l)+datb[k];
	else{
		int res=(min(b,r)-max(a,l))*data[k];
		res+=sum(a,b,k*2+1,l,(l+r)/2);
		res+=sum(a,b,k*2+2,(l+r)/2,r);
		return res;
	}
}
signed main() {
	int n,q;scanf("%lld%lld",&n,&q);
	rep(i,q){
		int k;scanf("%lld",&k);
		if(k==0){
			int s,t,x;scanf("%lld%lld%lld",&s,&t,&x);s--;
			add(s,t,x,0,0,n);
		}
		else{
			int s,t;scanf("%lld%lld",&s,&t);s--;
			printf("%lld\n",sum(s,t,0,0,n));
		}
	}
}

Measured memory_bytes: 6272
def main():
    N = int(input())
    A = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append((b,a))

    A.sort()
    time = 0
    for b, a in A:
        time += a
        if time > b:
            print('No')
            exit()

    print('Yes')    



if __name__ == "__main__":
    main()

Measured memory_bytes: 65368
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> P;
int n,c[26];
string t[105];
int main(){
	while(1){
		cin >> n; if(n==0) return 0;
		memset(c,0,sizeof(c));
		for(int i=1;i<=n;i++) cin >> t[i];
		for(int i=1;i<=n;i++){
			string s=t[i]; c[s[0]-'A']++;
			vector<int>vi;
			for(int j=0;j<26;j++){
				vi.pb(c[j]);
			}
			sort(vi.begin(),vi.end());
			if(vi[25] > vi[24]+n-i){
				char ch;
				for(int j=0;j<26;j++)if(vi[25]==c[j])ch='A'+j;
				printf("%c %d\n",ch,i); goto nxt;
			}
		}
	  puts("TIE"); nxt:;
  }
}
		

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[602], ok[602];
double exx[602];
bool vis[602];
int n;
double dp(int x)
{
    if(x==n)return exx[x]= 0.0;
    if(vis[x])return exx[x];
    vis[x]= 1;
    exx[x]= 0.0;
    bool f= 0;
    for(int i=0; i<adj[x].size(); i++)
    {
        int y= adj[x][i];
        if(ok[x][i]==-1)
        {
            f= 1;
            continue;
        }
        exx[x]+= (1.0+dp(y));
    }
    exx[x]/= (double)(adj[x].size()-f);
    return exx[x];
}
double stat[602];
int main()
{
    int m, x, y;
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++)exx[i]= 0.0;
    while(m--)
    {
        scanf("%d %d", &x, &y);
        adj[x].push_back(y);
        ok[x].push_back(0);
    }
    double res= dp(1);
    for(int i=1; i<=n; i++)stat[i]= exx[i];
    for(int i=1; i<n; i++)
    {
        memset(vis, 0, sizeof vis);
        int ind= 0;
        for(int j=1; j<adj[i].size(); j++)
        if(stat[ adj[i][j] ]>stat[ adj[i][ind] ])ind= j;
        ok[i][ind]= -1;
        double r= dp(1);
        if(r!=0.00000000000)res= min(res, r);
        ok[i][ind]= 0;
    }
    printf("%.10lf\n", res);
    return 0;
}


Measured memory_bytes: 2432
from time import time
start = time()

import random


def solve(c_list, days, now):
    r = sum(c_list[i]*(now-days[i]) for i in range(26))
    return r


d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _i in range(d)]


last_days = [-1 for _i in range(26)]
result = []
score = 0
for today in range(d):
    checker = [c[j]*(today-last_days[j]) for j in range(26)]
    y = sum(checker)

    finder = [s[today][j]-(y-checker[j]) for j in range(26)]
    x = finder.index(max(finder))

    last_days[x] = today
    result.append(x+1)
    score += s[today][x] - solve(c, last_days, today)


def change(problems, days):
    last_days = [-1 for _i in range(26)]
    score = 0
    for i in range(d):
        score += s[i][problems[i]-1]
        last_days[problems[i]-1] = i
        score -= sum([c[j]*(i-last_days[j]) for j in range(26)])
    return score

change_list = result.copy()
hantei = True
coun = 0
while hantei:
    if random.randrange(2)<1:
        x, y = random.randrange(0, d), random.randrange(0, d)
        while x == y:
            y = random.randrange(0, d)
        change_list[x], change_list[y] = change_list[y], change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            score = next_score
            result[x], result[y] = result[y], result[x]
        elif random.randrange(100)==5:
            score = next_score
            result[x], result[y] = result[y], result[x]
        else:
            change_list[x], change_list[y] = change_list[y], change_list[x]
    else:
        x = random.randrange(0, d)
        y = random.randrange(1, 27)
        while change_list[x] == y:
            x = random.randrange(0, d)
            y = random.randrange(1, 27)    
        change_list[x], z = y, change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            score = next_score
            result[x] = y
        else:
            change_list[x] = z
    coun += 1
    if coun ==100:
        coun = 0
        if time()-start >= 1.8:
            hantei = False

for i in result:
    print(i)

Measured memory_bytes: 94520
#include <stdio.h>

int N,M,R;
int r[8];
int d[205][205];
int ans;
int per[8];
int used[8];

int min(int a,int b){
	if(a<b){return a;}
	else{return b;}
}

void warshall_floyd(){
	int i,j,k;

	for(k=1;k<=N;k++){
		for(i=1;i<=N;i++){
			for(j=1;j<=N;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}

}

void dfs(int depth){

	int i;

	if(depth==R){


		int cost=0;

		for(i=0;i<R-1;i++){
			int from=r[per[i]-1];
			int to=r[per[i+1]-1];
			cost+=d[from][to];
		}

		if(ans>cost){ans=cost;}

		return ;
	}

	for(i=0;i<R;i++){

	if(used[i]==0){
		per[depth]=i+1;
		used[i]=1;
		dfs(depth+1);
		used[i]=0;
		}
	}
}

int main(){

	scanf("%d %d %d",&N,&M,&R);

	int i,j;

	for(i=1;i<=N;i++){
		for(j=1;j<=N;j++){
			if(i==j){d[i][j]=0;}
			else{d[i][j]=1<<25;}
		}
	}


	for(i=0;i<R;i++){
		scanf(" %d",&r[i]);
	}
	for(i=0;i<M;i++){
		int A,B,C;
		scanf("%d %d %d",&A,&B,&C);
		d[A][B]=C;
		d[B][A]=C;
	}

	warshall_floyd();

	ans=1<<30;

	dfs(0);

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 384