akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define INF 0X3F3F3F3F

const int MAXS=1000000+5;

int n;
char str[MAXS];
int a[MAXS],sum[MAXS];
int sMin[MAXS];

inline int Solve(reg int Min){
	reg int base=0;
	static int tmp[MAXS];
	for(reg int i=1;i<=n;++i)
		if(str[i]=='?')
			if(sMin[i]-base-2>=Min){
				base+=2;
				tmp[i]=-1;
			}
			else
				tmp[i]=1;
		else
			tmp[i]=(str[i]=='0')?(-1):(1);
	int Max=0,sum=0;
	for(reg int i=1;i<=n;++i){
		sum+=tmp[i];
		Max=max(Max,sum);
	}
	return Max-Min;
}

int main(void){
	scanf("%s",str+1);
	n=strlen(str+1);
	for(reg int i=1;i<=n;++i)
		a[i]=(str[i]=='0')?(-1):(1);
	for(reg int i=1;i<=n;++i)
		sum[i]=sum[i-1]+a[i];
	sMin[n]=sum[n];
	for(reg int i=n-1;i>=0;--i)
		sMin[i]=min(sMin[i+1],sum[i]);
	printf("%d\n",min(Solve(sMin[0]),Solve(sMin[0]-1)));
	return 0;
}

Measured memory_bytes: 20400
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int Q;
vi qn, A, B;

int main() {
    cin >> Q;
    qn.resize(Q);
    A.resize(Q);
    B.resize(Q);
    rep(i, Q) {
        cin >> qn[i];
        if (qn[i] == 1) {
            cin >> A[i] >> B[i];
        }
    }

    priority_queue<int> a_left;
    priority_queue<int, vector<int>, greater<int>> a_right;
    ll x = 0;
    int cnt_left = 0, cnt_right = 0;
    ll sum_left = 0, sum_right = 0, sum_b = 0;
    bool first = true;

    for (int i = 0; i < Q; ++i) {
        if (first && qn[i] == 1) {
            x = A[i];
            sum_b = B[i];
            first = false;
        }
        else if (qn[i] == 1) {
            if ((cnt_left + cnt_right) % 2 == 1) {
                if (x <= A[i]) {
                    a_left.push(x); a_right.push(A[i]);
                    ll x_next = a_right.top(); a_right.pop();
                    sum_left += x;  sum_right += A[i] - x_next;
                    x = x_next;
                }
                else {
                    a_left.push(A[i]);
                    sum_left += A[i];
                }
                cnt_left++;
            }
            else if ((cnt_left + cnt_right) % 2 == 0) {
                if (A[i] < x) {
                    a_left.push(A[i]); a_right.push(x);
                    ll x_next = a_left.top(); a_left.pop();
                    sum_left += A[i] - x_next; sum_right += x;
                    x = x_next;
                }
                else {
                    a_right.push(A[i]);
                    sum_right += A[i];
                }
                cnt_right++;
            }
            sum_b += B[i];
        }
        else {
            ll y = (cnt_left * x - !!x * sum_left) + (!!x * sum_right - cnt_right * x) + sum_b;
            cout << x << " " << y << "\n";
        }
    }
}

Measured memory_bytes: 5884
bingo = []
card = [[0,0,0],[0,0,0],[0,0,0]]
ans = 0
for i in range(3):
    A = list(map(int,input().split()))
    bingo.append(A)
N = int(input())
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                card[i][j] += 1
if card[0][0]+card[0][1]+card[0][2] >= 3:
    ans += 1
if card[0][0]+card[1][0]+card[2][0] >= 3:
    ans += 1
if card[1][0]+card[1][1]+card[1][2] >= 3:
    ans += 1
if card[2][0]+card[2][1]+card[2][2] >= 3:
    ans += 1
if card[0][1]+card[1][1]+card[2][1] >= 3:
    ans += 1
if card[0][2]+card[1][2]+card[2][2] >= 3:
    ans += 1
if card[0][0]+card[1][1]+card[2][2] >= 3:
    ans += 1
if card[0][2]+card[1][1]+card[2][0] >= 3:
    ans += 1
if ans > 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	//n = 200000; k = 199999;
	deque<int> dq;
	set<int> s;

	int mx = -1, mn = 1e9;
	//int mx_idx = -1, mn_idx = -1;
	int rn = 0, rnCnt = 0;
	int pre = 1e9;
	ll ans = n-k+1;
	REP(i, n) {
		bool f = false;
		int p;
		cin >> p;
		//p = i;
		dq.push_back(p);
		if (p > pre) {
			rn++;
			if (rn >= k-1) {
				rnCnt++;
				f = true;
			}
		}
		else {
			rn = 0;
		}
		pre = p;
		s.insert(p);
		if (i < k) {
			if (p > mx) {
				mx = p;
				//mx_idx = i;
			}
			if (p < mn) {
				mn = p;
				//mn_idx = i;
			}
			continue;
		}
		s.erase(dq.front());
		//mx_idx--; mn_idx--;
		if (dq.front() == mn) {
			//cout << "a" << endl;
			dq.pop_front();
			mn = *s.begin();
			if (p > mx) {
				if (!f)ans--;
				mx = p;
				//mx_idx = k - 1;
			}
		}
		else if (p > mx) {
			//cout << "b" << endl;
			dq.pop_front();
			mx = p;
			//mx_idx = k - 1;
		}
		else if (dq.front() == mx) {
			//cout << "c" << endl;
			dq.pop_front();
			mx = *(--s.end());
			if (p < mn) {
				mn = p;
				//mx_idx = k - 1;
			}
		}
		else if (p < mn) {
			//cout << "b" << endl;
			dq.pop_front();
			mn = p;
			//mx_idx = k - 1;
		}
		else {
			dq.pop_front();
		}
		//cout << mx << endl;
		//cout << "rn:" << rn << " rnCnt:" << rnCnt << endl;
		//cout << ans << endl;
	}
	ans -= max(rnCnt - 1,0);
	cout << ans << endl;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll scoring(ll D, vector<vector<ll>> s, vector<ll> t, vector<vector<ll>> last, vector<ll> c){
    ll sat = 0;
    ll cnt = 0;
    rep(i, D){
        sat += s.at(i).at(t.at(i));
        last.at(i).at(t.at(i)) = i;
        if(i != 0){
            rep(j, 26){
                if(j == t.at(i)){
                    continue;
                }
                last.at(i).at(j) = last.at(i-1).at(j);
            }
        }
        rep(j, 26){
            sat -= c.at(j) * (i - last.at(i).at(j));    
        }
    }
    return sat;
}

int main()
{
    ll D;
    cin >> D;
    vector<ll> c(26);
    rep(i, 26) cin >> c.at(i);
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(i, D){
        rep(j, 26){
            cin >> s.at(i).at(j);
        }
    }
    vector<ll> t(D, 0);
    ll sat = 0;
    vector<vector<ll>> last(D, vector<ll>(26, -1));
    rep(i, D){
        ll tmp = 0;
        rep(j, 26){
            ll now = t.at(i);
            t.at(i) = j;
            if(chmax(tmp, scoring(i+1, s, t, last, c))){
                continue;
            }
            else{
                t.at(i) = now;
            }
        }
//        cout << tmp << endl;
    }
    rep(i, D){
        cout << t.at(i)+1 << endl;
    }
}

Measured memory_bytes: 4000
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (a, b, q) = (line[0], line[1], line[2]);

    let mut s: Vec<i64> = Vec::new();
    for _ in 0..a{
        s.push(read_as_vec()[0]);
    }
    
    let mut t: Vec<i64> = Vec::new();
    for _ in 0..b{
        t.push(read_as_vec()[0]);
    }

    for _ in 0..q{
        let start: i64 = read_as_vec()[0];
        let bin_res = s.binary_search(&start);

        let west_s: Option<i64> = match bin_res{
            Ok(_) => Some(start),
            Err(index) => if 0 < index{
                Some(start -s[index-1])
            }else{
                None
            }
        };
        let east_s: Option<i64> = match bin_res{
            Ok(_) => Some(start),
            Err(index) => if index < a{
                Some(s[index] - start)
            }else{
                None
            }
        };
        
        let bin_res = t.binary_search(&start);
        let west_t: Option<i64> = match bin_res{
            Ok(_) => Some(start),
            Err(index) => if 0 < index{
                Some(start - t[index-1])
            }else{
                None
            }
        };

        let east_t: Option<i64> = match bin_res{
            Ok(_) => Some(start),
            Err(index) => if index < b{
                Some(t[index] -start)
            }else{
                None
            }
        };
        /*
        println!("west_s = {:?}", west_s);
        println!("east_s = {:?}", east_s);
        println!("west_t = {:?}", west_t);
        println!("east_t = {:?}", east_t);
        */
        
        let mut ww: i64 = 10000000000000;
        if west_s.is_some() && west_t.is_some(){
            ww = cmp::max(west_s.unwrap(), west_t.unwrap());
        }
        let mut ans = ww;
        
        let mut we: i64 = 10000000000000;
        if west_s.is_some() && east_t.is_some(){
            we = west_s.unwrap() + east_t.unwrap() + cmp::min(west_s.unwrap(), east_t.unwrap());
        }
        ans = cmp::min(ans, we);

        let mut ew: i64 = 10000000000000;
        if east_s.is_some() && west_t.is_some(){
            ew = east_s.unwrap() + west_t.unwrap() + cmp::min(east_s.unwrap(), west_t.unwrap());
        }

        ans = cmp::min(ans, ew);

        let mut ee: i64 = 1000000000000;
        if east_s.is_some() && east_t.is_some(){
            ee = cmp::max(east_s.unwrap(),east_t.unwrap());
        }

        ans = cmp::min(ans, ee);
        println!("{}", ans);
    }


 }


Measured memory_bytes: 7420
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,L,R) for(auto i=R-1;i>=L;i--)
#define show(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

string a,b;
vector<vl> dp(3001,vl(3001,0));//lena,lenb


int main() 
{
	cin>>ws;
	cin>>a>>ws>>b;
	int lena = a.length();
	int lenb = b.length();
	
    F(i,1,lena+1)
    {
        F(j,1,lenb+1)
        {
            if(a[i-1]==b[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    int i=lena,j=lenb;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            ans.PB(a[i-1]);
            i--;j--;
        }
        else if(dp[i][j]==dp[i-1][j])
            i--;
        else
            j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";

}




Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll A,B;
  cin>>A>>B;
  
  if(B*2>=A){
    cout<<0<<endl;
  }
else{
  cout<<A-B*2<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;


int main() {

    int N;
    cin >> N;
    int X;
    cin >> X;
    vector<int> v;
    for (int i = 0; i < N; i++) {
        int m;
        cin >> m;
        v.push_back(m);
    }

    int numOfDonut = N;

    int minD = min(v[0], v[1]);
    X = X - v[0] - v[1];
    for (int i = 2; i < N; i++) {
        X = X - v[i];
        minD = min(minD, v[i]);
    }

    numOfDonut += (X / minD);

    cout << numOfDonut << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

  string ans = "bust";
  if (A + B + C <= 21)
    ans = "win";
  cout << ans << endl;
}

Measured memory_bytes: 256
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[200017];
void solve(){
	ll n,x,i;
	cin>>n;
	take(a,n);
	x=0;
	for(i=0;i<n;i++){
		x=x^a[i];
	}
	for(i=0;i<n;i++){
		a[i]=x^a[i];
		cout<<a[i]<<" ";
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 5200
import java.util.*;

@SuppressWarnings("unchecked")
class Main{

    char[] in;
    boolean[][] checked;
    HashSet[][] memo;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            String s = sc.next();
            if(s.equals("#")) break;

            in = s.toCharArray();
            int n = in.length+1;
            checked = new boolean[n][n];
            memo = new HashSet[n][n];
            System.out.println(expr(0, in.length).size());
        }
    }

    HashSet<Integer> expr(int l, int r){
        if(checked[l][r]) return memo[l][r];

        boolean kakko_num = true;
        int depth = 0;
        HashSet<Integer> res = new HashSet<Integer>();
        for(int i=l; i<r; i++){
            if(in[i]=='(') depth++;
            if(in[i]==')') depth--;
            if((in[i]=='*' || in[i]=='/' || in[i]=='+' || in[i]=='-') && depth==0){
                kakko_num = false;
                HashSet<Integer> left = expr(l, i);
                HashSet<Integer> right = expr(i+1, r);

                for(Iterator j=left.iterator(); j.hasNext();){
                    int a = (int)(Integer)j.next();
                    for(Iterator k=right.iterator(); k.hasNext();){
                        int b = (int)(Integer)k.next();
                        if(in[i]=='*') res.add(new Integer(a * b));
                        if(in[i]=='/' && b!=0) res.add(new Integer(a / b));
                        if(in[i]=='+') res.add(new Integer(a + b));
                        if(in[i]=='-') res.add(new Integer(a - b));
                    }
                }
            }
        }

        if(kakko_num){
            if(Character.isDigit(in[l])) res.add(new Integer(digit(l, r)));
            else res = expr(l+1, r-1);
        }

        checked[l][r] = true;
        return memo[l][r] = res;
    }

    int digit(int l, int r){
        int res = 0;
        int ten = r-l-1;
        for(int i=l; i<r; i++){
            if(i>l) res *= 10; 
            res += in[i]-'0';
        }
        return res;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 27424
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
    int n, m, x;
    cin >> n >> m >> x;

    vector<vector<int>>a(n,vector<int>(m));
    vector<int> c(n);

    rep(i,n){
        cin >> c[i];
        for(int j = 0; j<m; j++)cin >> a[i][j];
    }
    int ans = 12345678;
    int all = 1<<n;
    for(int mask = 0; mask < all ; mask++){
        vector<int> level(m);
        int cost =0;
        for(int i = 0; i< n; i++){
            if((mask >> i)&1){
                cost += c[i];
                for(int j = 0; j<m; j++){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int j =0; j< m; j++){
            if(level[j] < x)ok = false;
        }
        if(ok)ans = min(ans,cost);
    }
    if(ans == 12345678)cout << -1 << endl;
    else cout << ans << endl;

}



Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static boolean canCreateNumFromLike(int r, int[] like) {
        int rDigitNum = String.valueOf(r).length();
        int[] rArray = new int[rDigitNum];
        for (int i = 0; i < rDigitNum; i++) {
            rArray[i] = String.valueOf(r).charAt(i) - '0';
        }

        for (int i = rDigitNum - 1; i >= 0; i--) {
            boolean matched = false;
            for (int j = 0; j < like.length; j++) {
                if (rArray[i] == like[j]) {
                    matched = true;
                    break;
                }
            }
            if (!matched) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Integer[] d = new Integer[k];
        for (int i = 0; i < k; i++) {
            d[i] = sc.nextInt();
        }
        int[] like = new int[10 - k];
        int likeIdx = 0;
        List<Integer> dList = Arrays.asList(d);
        for (int i = 0; i < 10; i++) {
            if (!dList.contains(Integer.valueOf(i))) {
                like[likeIdx] = i;
                likeIdx++;
            }
        }

        int result = n;
        while (true) {
            if (!canCreateNumFromLike(result, like)) {
                result++;
                continue;
            }
            break;
        }
        System.out.println(result);
    }

}


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

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

void solve() {
  int N = 1e6+5;
  int n; cin >> n;
  vector<int> count(N);
  int all = 0;
  for(int i=0; i<n; ++i) {
    int a; cin >> a;
    count.at(a)++;
    all = gcd(all, a);
  }
  bool ok = true;
  for(int i=2; i<N && ok; ++i) {
    int sum = 0;
    for(int j=i; j<N; j+=i) sum += count[j];
    if(sum > 1) ok = false;
  }
  cout << (ok ? "pairwise coprime" : all == 1 ? "setwise coprime" : "not coprime") << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 7140
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int A, B; cin >> A >> B;
    FOR(i, 1, 10000) {
        if ((i * 8) / 100 == A && (i * 10) / 100 == B) {
            cout << i << endl; return 0;
        }
    }
    cout << -1 << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
n=int(input())
p=1
if n<=1000:
    for i in range(1,n+1):
        p*=i
        p=p%(10**9+7)
    print(p)
else:
    p=641419708
    for i in range(1001,n+1):
        p*=i
        p=p%(10**9+7)
    print(p)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

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

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n;
	static ll a[100010],b[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%lld%lld",&a[i],&b[i]);
	
	static ll ret = 0;
	static vector<ll> vec;
	rep(i,n){
		ret += a[i]-b[i];
		vec.pb(a[i]+b[i]);
	}
	sor(vec);
	rep(i,n){
		if((i^n)&1)ret += vec[i];
		else ret -= vec[i];
	}
	cout << ret/2 << endl;
}



Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    double x,ans=0;
    string u;
    //for(int i=0;i<n;i++) cin >> x >> u;
    
    for(int i=0;i<n;i++){
        cin >> x >> u;
        if(u =="BTC"){
            ans += x*380000;
        } else {
            ans +=x;
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
N = input()
K = int(input())

digit = len(N)
dp = [[[0]*(K+1) for _ in range(2)] for _ in range(digit)]

di = int(N[0])
dp[0][0][0] = 0
dp[0][0][1] = 1
dp[0][1][0] = 1
dp[0][1][1] = di-1

for i in range(1, digit):
    dp[i][1][0] = 1
    for k in range(1, K+1):
        di = int(N[i])
        if di == 0:
            dp[i][0][k] = dp[i-1][0][k]
            dp[i][1][k] = dp[i-1][1][k] + dp[i-1][1][k-1]*9
        else:
            dp[i][0][k] = dp[i - 1][0][k - 1]
            dp[i][1][k] = dp[i-1][0][k-1]*(di-1)+dp[i-1][0][k]\
                      +dp[i-1][1][k]+dp[i-1][1][k-1]*9


print(dp[-1][0][K]+dp[-1][1][K])

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

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

fn main() {
    let n = read::<usize>();
    let k = read::<i64>();

    let mut a = vec![0; n];
    for i in 0..n {
        a[i] = read::<i64>();
    }
    let min = *a.iter().min().unwrap();
    let mut min_idx = vec![];

    for i in 0..n {
        if min != a[i] {
            min_idx.push(i);
        }
    }

    println!("{:?}", (min_idx.len() as i64 + (k-2)) / (k-1));
}

Measured memory_bytes: 6396
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn=1000010;
char a;
int ans;

int main(){
	while(1){
		a=getchar();
		if(a=='\n') break;
		else{
			if(a=='C'&&ans==0) ans++;
			if(a=='F'&&ans==1) ans++;
			if(ans==2) break;
		}
	}
	if(ans==2) cout<<"Yes"<<'\n';
	else cout<<"No"<<'\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);

        String[] s = new String[stdIn.nextInt() + 1];
        for(int i = 0 ; i < s.length ; i++){
            s[i] = stdIn.nextLine();
        }
        int[] c = {0 , 0 , 0 , 0};
        for(int i = 0 ; i < s.length ; i++){
            if(s[i].equals("AC")){
                c[0] += 1;
            }else if(s[i].equals("WA")){
                c[1] += 1;
            }else if(s[i].equals("TLE")){
                c[2] += 1;
            }else if(s[i].equals("RE")) {
                c[3] += 1;
            }
        }
        System.out.println("AC x " + c[0]);
        System.out.println("WA x " + c[1]);
        System.out.println("TLE x " + c[2]);
        System.out.println("RE x " + c[3]);
    }
}


Measured memory_bytes: 66468
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

typedef tuple<ll, ll, ll> P;

/*
10 + 1
20 + 5 -> 10 
i = 0
t = 25
j = 1
c = 1, s = 10 ,f = 10

*/
int main() {
  int n; cin >> n;
  n--;
  vector<P> A;
  loop(i,0,n) {
    int a, b, c; cin >> a >> b >> c;
    A.emplace_back(a, b, c);
  }
  vector<ll> ans;
  for (int i=n-1; i>=0; i--) {
    ll t = get<1>(A[i]) + get<0>(A[i]);
    for (int j=i+1;j<n; j++) {
      ll c, s, f; tie(c, s, f) = A[j];
      if (t <= s) t = s + c;
      else {
        while (t > s) s += f;
        t = s + c;
      }
    }
    ans.push_back(t);
  }
  reverse(ans.begin(), ans.end());
  for (auto &&a: ans) cout << a << endl;
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main()
{
	char x,y,c;
	while(~scanf("%c %c%c",&x,&y,&c))
	{
			x = x-55;
			y = y-55;
			if(x==y)
			{
				printf("=\n");
				}
				else if(x<y)
				{
					printf("<\n");
					}
					else if(x>y)
					{
						printf(">\n");
					}	
		}
		return 0;
	}


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

int main() {
  int N ,A;
  cin >> N >> A;
  
  if(N % 500 == 0){
     cout << "Yes" << endl;
  }  
  else if (N % 500 < A) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  } 
}


Measured memory_bytes: 3604
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,x,y=parseMap(split(readline()))
    println(min(a+b,c*2)*min(x,y)+min(a,c*2)*(x-min(x,y))+min(b,c*2)*(y-min(x,y)))
end
main()

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

int main() {
	ios_base::sync_with_stdio( false );

	string S, T;
	cin >> S >> T;

	int n = (int)S.size();
	bool result = true;

	for( int i = 0; i < n; ++i ) {
		result = true;

		for( int j = 0; j < n; ++j ) {
			if( S[(n-i+j) % n] != T[j] ) {
				result = false;
				break;
			}
		}

		if( result ) {
			break;
		}
	}

	cout << (result ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

bool win(vector<int> X) {
    int sum = 0;
    int n = X.size();
    int od = 0;
    int one = 0;
    for (int i = 0;i < n;i++) {
        if (X[i] % 2) od++;
        if (X[i] == 1) one++;
        sum += (X[i] - 1);
        sum %= 2;
    }
    // win directly.
    if (sum) return 1;
    if (one) return 0;
    if (od == 1) {
        // I tried!
        int g = (X[0] / 2) * 2;
        for (int i = 1;i < n;i++) g = gcd(g, (X[i] / 2) * 2);
        for (int i = 0;i < n;i++) X[i] /= g;
        return !win(X);
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> X(n);
    for (int i = 0;i < n;i++) cin >> X[i];
    if (win(X)) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 10112
#include <algorithm>
#include <cstdio>
#define MOD 1000000007
#define C(n, m) (fact[n] * inv[m] % MOD * inv[(n) - (m)] % MOD)
typedef long long ll; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
int seq[75], n, k;
char str[75]; 
ll ans, fact[305], inv[305]; 
inline void work(int len, int sum)
{
	int one = 0, two = 0, need = 0, rem = 0; 
	for (int i = 0; i < k; i++)
	{
		if (str[i] == 'r' && one < len)
			need += seq[one++] != 1; 
		else if (str[i] == 'b' && need)
		{
			need--; 
			rem += seq[two++] - 2; 
		}
		else
			rem -= !!rem; 
	}
	if (one < len || need || rem)
		return; 
	ll res = fact[len], cnt = len + 1; 
	for (int i = 0, j = 0; i < len; i = j)
	{
		while (j < len && seq[i] == seq[j])
			j++; 
		res = res * inv[j - i] % MOD; 
		cnt += (j - i) * (seq[i] * 2 - 1); 
	}
	(ans += res * C(n - sum + cnt - 1, cnt - 1)) %= MOD; 
}
void dfs(int mx, int len, int cur)
{
	if (cur > n)
		return; 
	work(len, cur); 
	for (int i = mx; i; i--)
	{
		seq[len] = i; 
		dfs(i, len + 1, cur + std::max(i * 2 - 3, 1) + !!len); 
	}
}
int main()
{
	// freopen("ARC089-F.in", "r", stdin); 
	fact[0] = inv[0] = 1; 
	for (int i = 1; i < 305; i++)
	{
		fact[i] = fact[i - 1] * i % MOD; 
		inv[i] = quick_pow(fact[i], MOD - 2); 
	}
	scanf("%d%d%s", &n, &k, str);
	dfs(70, 0, 0); 
	printf("%lld\n", ans);
	return 0; 
}


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

using ll = int64_t;
const int MAX = 2e5;

#define     getbit(n, i) (((n) & (1LL << i)) != 0)
#define     setbit0(n, i) ((n) & (~(1LL << i)))
#define     setbit1(n, i) ((n) | (1LL << i))
#define     kbits(n, k) ((n) & ((1LL << k) - 1))
#define     LSB(n) ((n) & (-(n)))
#define     MSB(n) (1LL << (int)log2(n))
#define     isPowOf2(n) ((n > 0) && (((n) & (n-1)) == 0))

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int H, W, K; cin >> H >> W >> K;
    string s[H];
    for (int i = 0; i < H; i++) cin >> s[i];
    
    ll ans = 0;
    for (int row = 0; row < setbit1(1, H)-1; row++) {
        for (int col = 0; col < setbit1(1, W)-1; col++) {
            int black = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (getbit(row, i) == 0 && getbit(col, j) == 0 && s[i][j] == '#') black++;
                }
            }
            if (black == K) ans++;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int N, Z, W, a[2020];

int dp1[2020], dp2[2020];

int main() {
    cin >> N >> Z >> W;
    for (int j = 0; j < N; ++j) cin >> a[j];

    for (int j = N-2; j >= 0; --j) {
        int s1 = abs(a[j] - a[N-1]), s2 = abs(a[j] - a[N-1]);
        for (int k = j+1; k < N-1; ++k) {
            if (s1 < dp1[k]) {
                s1 = dp1[k];
            }
            if (s2 > dp2[k]) {
                s2 = dp2[k];
            }
        }
        dp1[j] = s2;
        dp2[j] = s1;
    }

    int ans = abs(a[N-1] - W);
    for (int j = 0; j < N-1; ++j) {
        ans = max(ans, dp1[j]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char> > out(h + 2, vector<char>(w + 2));
    for (int i = 0; i <= h + 1; i++){
        for (int j = 0; j <= w + 1; j++)
        {
            if (i == 0 || j == 0|| i == h + 1 || j == w + 1){
                out.at(i).at(j) = '#';
                cout << out.at(i).at(j);
            }
            else
            {
                cin >> out.at(i).at(j);
                cout << out.at(i).at(j);
            }
        }
        cout << endl;
    }
}

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

int main() {
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2-y2+y1 << " " << y2+x2-x1 << " " << x1-y2+y1 << " " << y1+x2-x1 << endl;
}

Measured memory_bytes: 256
S = list(input())
T = list(input())
check = [[] for i in range(26)]
for i in range(len(T)):
    check[ord(T[i]) - 97].append(i)
ans = 1
for i in check:
    for j in range(1, len(i)):
        if S[i[j]] != S[i[j - 1]]:
            ans = -1
            break
        
check = [[] for i in range(26)]
for i in range(len(S)):
    check[ord(S[i]) - 97].append(i)
for i in check:
    for j in range(1, len(i)):
        if T[i[j]] != T[i[j - 1]]:
            ans = -1
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15504
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

const int MAX_V = 100000;
int par[MAX_V];
int depth[MAX_V];
int num[MAX_V];

void init(int n) {
    for(int i = 0; i < n; i++) {
        par[i] = i;
        depth[i] = 0;
        num[i] = 1;
    }
}

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

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    num[x] += num[y];
    num[y] = num[x];

    if (depth[x] < depth[y]) par[x] = y;
    else {
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

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

int get_num(int x) {
    return num[root(x)];
}

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

    init(n);
    vector<int> done_x(100001, -1), done_y(100001, -1);
    rep(i, n) {
        if (done_x[x[i]] != -1) unite(i, done_x[x[i]]);
        else done_x[x[i]] = i;

        if (done_y[y[i]] != -1) unite(i, done_y[y[i]]);
        else done_y[y[i]] = i;
    }

    vector<set<int>> x_sets(n), y_sets(n);
    rep(i, n) {
        x_sets[root(i)].insert(x[i]);
        y_sets[root(i)].insert(y[i]);
    }

    ll ans = 0;
    vector<bool> done(n);
    rep(i, n) {
        if (!done[root(i)]) ans += (ll)x_sets[root(i)].size() * (ll)y_sets[root(i)].size() - get_num(i);
        done[root(i)] = true;
    }
    cout << ans << endl;
}

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

#define int long long
#define ll unsigned long long
#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second
/*----------------------------------------*/


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
    T=1;
//    cin>>T;

while(T--){
    
    int n;
    cin>>n;
    int t;
    t=n%10;
    string ans;
    if(t==2 || t==4){
        ans="hon";
    }
    else if(t==5 || t==7){
        ans="hon";
    }
    else if(t==9) ans="hon";
    else if(t==0 || t==1) ans="pon";
    else if(t==6 || t==8) ans="pon";
    else if(t==3) ans="bon";
    cout<<ans;
 //   cout<<t;
}
    
    return 0;
}

Measured memory_bytes: 3652
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))

ans = True
a1=0
b=[]
for i in range(3):
    b.append(c1[i]-a1)

a2=c2[0]-b[0]
a3=c3[0]-b[0]

for i in range(1,3):
    if a2+b[i] != c2[i] or a3+b[i] != c3[i]:
        ans = False
        break

if ans==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main()
  {int X, Y, A, B, C, r; cin >> X >> Y >> A >> B >> C;
  vector<int> P(A), Q(B), xs; for (int &p : P) cin >> p; for (int &q : Q) cin >> q; sort(rbegin(P), rend(P)); sort(rbegin(Q), rend(Q));
  for (int i{}; i < X; ++i) xs.push_back(P[i]); for (int i{}; i < Y; ++i) xs.push_back(Q[i]);
  while (C--) {cin >> r; xs.push_back(r);} sort(rbegin(xs), rend(xs));
  cout << accumulate(begin(xs), begin(xs) + X + Y, 0LL);}

Measured memory_bytes: 6040
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt=1;
    char prev=s[0];
    vector<int> c;
    if (s[0]=='0') c.push_back(0);
    repr(i,1,n) {
        if (s[i]!=prev) {
            c.push_back(cnt);
            cnt=1;
        } else ++cnt;
        prev=s[i];
    }
    c.push_back(cnt);
    if (s[n-1]=='0') c.push_back(0);
    int m=c.size();
    if (m<2*k+1) cout << n << endl;
    else {
        vector<int> d;
        cnt=0;
        rep(i,2*k+1) cnt+=c[i];
        d.push_back(cnt);
        rep(i,m-(2*k+1)) {
            cnt+=c[i+2*k+1]-c[i];
            d.push_back(cnt);
        }
        int ma=0;
        rep(i,(d.size()+1)/2) {
            ma=max(ma,d[i*2]);
        }
        cout << ma << endl;
    }

    return 0;
}


Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
int main(){
    double N;
    cin>>N;
    cout.precision(10);
    if(((int)N)%2==0){
        double temp=0.5;
        cout<<temp<<endl;
    }else{
        double ans=((N-1)/2)+1;
        ans=ans/N;
        cout<<ans<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
  return b == 0 ? a : gcd(b, a % b);
}
int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  auto n = [&](ll m) {
    return b / m - (a - 1) / m;
  };

  cout << (b - a + 1) - (n(c) + n(d) - n(c * d / gcd(c, d))) << endl;
  return 0;
}


Measured memory_bytes: 256
#-----UnionFind-----(0-indexed)
import sys;sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
    self.siz=n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
    self.siz-=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
  def size(self):
    return self.siz

from collections import defaultdict
n,x,y=map(int,input().split())
mod=10**9+7
f=[1]
for i in range(1,n+7):f.append(f[-1]*i%mod)
cw=[list(map(int,input().split()))for _ in range(n)]
if n==1:exit(print(1))
if len(set(c for c,w in cw))==1:exit(print(1))
for i in range(n):cw[i][0]-=1
miw=[10**10]*n
miwi=[0]*n
for i in range(n):
  c,w=cw[i]
  if miw[c]>w:
    miw[c]=w
    miwi[c]=i
mminc=miw.index(min(miw))
temp=10**10
for i in range(n):
  if i!=mminc:temp=min(temp,miw[i])
sminc=miw.index(temp)
u=UnionFind(n)
for i in range(n):
  c,w=cw[i]
  if c==mminc:tc=sminc
  else:tc=mminc
  if miw[c]+w<=x:u.unite(miwi[c],i)
  if miw[tc]+w<=y:u.unite(miwi[tc],i)
d=[0]*n
for i in range(n):
  if i==u.find_root(i):d[i]=defaultdict(int)
for i in range(n):
  c,w=cw[i]
  d[u.find_root(i)][c]+=1
ans=1
for i in range(n):
  if i==u.find_root(i):
    anss=1
    co=0
    for j in d[i]:
      anss*=pow(f[d[i][j]],mod-2,mod)
      anss%=mod
      co+=d[i][j]
    anss*=f[co]
    ans=(ans*anss)%mod
print(ans)

Measured memory_bytes: 150288
#include <stdio.h>
#include <string.h>

int main(void){
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4,ax,ay,bx,by;

	scanf("%d",&n);
	for(1;n>0;n--){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		ax=(x2-x1);ay=(y2-y1);bx=(x4-x3);by=(y4-y3);
		if(ax*by-ay*bx==0.0)printf("YES\n"); else printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 620
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)      ((int)(n).size())
#define all(n)     (n).begin(), (n).end()
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     

    
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
          
        int l, r, d;
        cin >> l >> r >> d;
        int ans = 0;
        for(int i = l; i <= r; i++){
              if(i%d == 0) ans++;
        }
        cout << ans;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



     

Measured memory_bytes: 3648
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int main(void){
	unsigned long  i,j,X;
	scanf("%lu",&X);

	i=X/500;
	X-=(500*i);
	j=X/5;
	X-=(5*j);
	X=i*1000+j*5;
	printf("%lu",X);

	return 0;
}

Measured memory_bytes: 128
// AOJ 2536: Median Tree
// 2017.11.30 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1002

/* UNION-FIND library */
int p[MAX], rank[MAX];

void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

typedef struct { int s, t, c; } T;
T e[10002]; 

char buf[30], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(T *a, T *b) { return a->c - b->c; }

int Kruskal(int n, int m) 
{ 
	int i, c;
	T *ep;

	for (i = 1; i <= n; i++) make_set(i);
	qsort(e, m, sizeof(T), cmp);
	c = 1+(n-1)/2;
	for (ep = e; m--; ep++) {
		if (find_set(ep->s) != find_set(ep->t)) { 
			union_set(ep->s, ep->t); 
			if (--c == 0) return ep->c; 
		} 
	}
	return 0;
} 

int main()
{
	int n, m, i;

	while (fgets(bp=buf, 30, stdin) && *bp != '0') {
		n = getint(), bp++, m = getint();
		for (i = 0; i < m; i++) {
			fgets(bp=buf, 30, stdin);
			e[i].s = getint(), bp++, e[i].t = getint(), bp++, e[i].c = getint();
		}
		printf("%d\n", Kruskal(n, m));
	}
	return 0;
}

Measured memory_bytes: 2024
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll d;
  vector<bool> has(N, false);
  for (ll i = 0; i < K; ++i) {
    cin >> d;
    for (ll j = 0; j < d; ++j) {
      ll a;
      cin >> a;
      has.at(a - 1) = true;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    if (!has.at(i)) {
      ans += 1;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int a;
cin>>a;
int b=a%10;
int c=(a%100)/10;
int d=(a%1000)/100;
int e=a/1000;
if((b==c&&c==d)||(c==d&&d==e))
	cout<<"Yes";
else
	cout<<"No";
}

Measured memory_bytes: 256