akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < n; i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }
ll cntd(ll n){
    ll an=0;
    while(n){
        an+=(n%10);
        n/=10;
    }
    return an;
}
mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<m.size();i++)prv(m[i]);
}

ll n, k, m, l, r, x, y, ans=0;
ll t, t1, t2;

ll i, j;
// ll a, b;
ll mod = 1000000007;

void solve()
{
    cin>>n;
    n=n%1000;
    n==0?ans=0:ans=1000-n;
    prn(ans);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main() {
	int n;
	cin >> n;
	string S1, S2;
	cin >> S1 >> S2;
	vector<int > Vec;
	for (int i = 0; i != n; ++i) {
		if (S1[i] == S2[i])Vec.push_back(1);
		else {
			Vec.push_back(0);
			++i;
		}
	}
	long long result;
	if (Vec[0] == 1)result = 3;
	else result = 6;
	for (int i = 1; i != Vec.size(); ++i) {
		if (Vec[i] == 0 && Vec[i - 1] == 0) {
			result *= 3;
			result %= mod;
		}
		if (Vec[i] == 1 && Vec[i - 1] == 1) {
			result *= 2;
			result %= mod;
		}
		if (Vec[i] == 0 && Vec[i - 1] == 1) {
			result *= 2;
			result %= mod;
		}
	}
	result %= mod;
	cout << result << endl;


	
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define reps(i,s,t) for(int i=(s); i <= (int)(t); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; ostringstream _oss;
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class T>   string toString(const T &x){ _oss.str(""); _oss << x; return _oss.str(); }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    _oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)_oss << sp; _oss << *i; }
    return _oss.str();
  }
  // }}}

constexpr int MX = ten(5) + 10;

void Xx_main_xX(const vector<char*> &args)
{
  int N, K;
  int a[MX];

  cin >> N >> K;
  rep(i, N) {
    cin >> a[i];
  }

  sort(a, a+N);
  int l = 0;
  int r = K-1;

  int ans = INF;
  while(r < N) {
    chmin(ans, abs(a[l] - a[r]));
    ++l;
    ++r;
  }

  outl(ans);
}

} // {{{
signed main(signed argc, char *argv[]) {
#ifndef DEBUG
  ios::sync_with_stdio(false); cin.tie(nullptr);
#endif
  cout << fixed << setprecision(9); Xx_main_xX(vector<char*>(argv, argv+argc)); return 0;
} // }}}



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

using namespace std;
int main()
{
  int n,j=0,s=0,i;
  scanf("%d",&n);
  int v[n+1],c[n+1];
  for(i=1;i<=n;i++)
  {
      scanf("%d",&v[i]);}for(i=1;i<=n;i++)
      {scanf("%d",&c[i]);}for(i=1;i<=n;i++)
      {j=v[i]-c[i];
      if(j>0)
      {
          s=s+j;
      }else
      {
          continue;
      }
  }
  printf("%d",s);
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MultiWayIf #-}

import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace (traceShow, traceShowM)

import qualified Data.ByteString.Char8 as B
import Text.Printf (printf)
import Control.Monad.ST
import Data.Array.ST
import Data.Array
import qualified Data.IntMap.Strict as M

readi b | Just (n, _) <- B.readInt b = n

f1 xs = [(j, k, i) | (i, (j, k)) <- zip [1..] xs]

solve :: Int -> Int -> [(Int, Int)] -> IO ()
solve n m pys = forM_ pys $ \(i, j) -> do
    let m = ary ! i
    let a = m M.! j
    printf "%06d%06d\n" i (a :: Int)
  where
    ps = groupBy (\a b -> fst a == fst b) $ sort pys
    ary = runSTArray $ do
        a <- newArray (1, n) M.empty
        let qs = fmap f1 ps
        forM_ qs $ \gs -> do
            forM_ gs $ \(i, j, k) -> do
                m <- readArray a i
                writeArray a i (M.insert j k m)
        return a

main :: IO ()
main = do
    [n, m] <- fmap readi . B.words <$> B.getLine :: IO [Int]
    pys <- replicateM m $ do
        [p, y] <- fmap readi . B.words <$> B.getLine
        return (p, y) :: IO (Int, Int)
    solve n m pys

Measured memory_bytes: 65020
#include <bits/stdc++.h>
//#include<iostream>
using namespace std;
#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

vector<int> P;
vector<bool> primes;
void make_primes(int n)
{
	

	primes.resize(n + 1, true);
	primes[0] = primes[1] = false;
	rep(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++)
		primes[i * (j + 2)] = false;

	rep(i, 2, n + 1) if (primes[i]) P.push_back(i);
}
int n,a[100010],cnt=0;
signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n;
    make_primes(1e8+1);
    rep(i,0,n){
        cin>>a[i];
        if(primes[a[i]])cnt++;
    }
    
    
    cout<<cnt<<endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 80868
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 3e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
unordered_map<ll,bool> hap;
vector<ll> Q;
ll t1,t2,t3,x,tmp;
void init(){
    queue<ll> q;
    rep(i,1,9) q.push(i),Q.push_back(i);
    while(q.size()){
        x = q.front();
        q.pop();
        if(x/mod) continue;
        tmp = x % 10;
        if(tmp==0){
            t1 = x * 10;
            t2 = t1 + 1;
            if(hap.count(t1)==0) hap[t1] = 1,q.push(t1),Q.push_back(t1);
            if(hap.count(t2)==0) hap[t2] = 1, q.push(t2),Q.push_back(t2);
        }
        else if(tmp==9){
            t1 = x*10+8;
            t2 = t1 + 1;
            if(hap.count(t1)==0) hap[t1] = 1,q.push(t1),Q.push_back(t1);
            if(hap.count(t2)==0) hap[t2] = 1, q.push(t2),Q.push_back(t2);
        }
        else{
            t1 = x*10+tmp-1;
            t2 = t1 + 1;
            t3 = t2 + 1;
            if(hap.count(t1)==0) hap[t1] = 1,q.push(t1),Q.push_back(t1);
            if(hap.count(t2)==0) hap[t2] = 1, q.push(t2),Q.push_back(t2);
            if(hap.count(t3)==0) hap[t3] = 1, q.push(t3),Q.push_back(t3);
        }
    }
}
int main(){
    int k = read();
    init();
    sort(Q.begin(),Q.end());
    cout<<Q[k-1];
}

Measured memory_bytes: 19944
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  string ans="";
  if(n==0) ans='0';
  
  while(n){
    if(n%(-2)!=0){
      n--;
      ans='1'+ans;
    }
    else{
      ans='0'+ans;
    }
    n/=(-2);
  }
  
  COUT(ans);
}


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

using namespace std;

#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007 

int32_t main()
{
	string ch;
	
	cin >> ch;
	if(ch[0] >= 'a' && ch[0] <= 'z') cout << "a\n";
	else cout << "A\n";
	return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>

int main () {
    int n, d;
    std::cin >> n >> d;

    int ans = n / (2 * d + 1);
    double ansd = 1.0*n / (2 * d + 1);

    if(ans != ansd) {
        ans++;
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int max (int x, int y)
{
    return x > y ? x : y;
}

int main (void)
{
    int N, x[100], y[100], h[100];
    int Cx, Cy, H = 0;
    int i, j, k;
    int ref;

    scanf("%d", &N);

    for (i = 0; i < N; i++) {
        scanf("%d %d %d", &x[i], &y[i], &h[i]);
        if (h[i] > 0) ref = i;
    }

    for (Cx = 0; Cx <= 100; Cx++) {
        for (Cy = 0; Cy <= 100; Cy++) {
            H = h[ref] + abs(x[ref] - Cx) + abs(y[ref] - Cy);
            for (k = 0; k < N; k++) {
                if (h[k] != max(H - abs(x[k] - Cx) - abs(y[k] - Cy), 0)) break;
            }
            if (k == N) {
                printf("%d %d %d\n", Cx, Cy, H);
                return 0;
            }
        }
    }

    return 0;
}


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

int N, A, B;
vector<int> arr;

bool check_t(int t) {
    LL spread = t * B;
    
    LL sum_t = 0;
    
    for(int &a : arr) {
        if (a > spread) {
            sum_t += ceil((a - spread) / (1.0 * (A - B)));
        }
        if (sum_t > t) {
            return false;
        }
    }
    return true;
}

int main() {

    cin >> N >> A >> B;
    
    int num, max_h = 0;
    for(int i = 0; i < N; i++) {
        cin >> num;
        arr.push_back(num);
        max_h = max(max_h, num);
    }
    
    int l = 0, r = ceil(max_h / (B * 1.0)) + 1;
    
    while(l < r) {
        int mid = l + ((r-l) / 2);
        
        if (check_t(mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    
    cout << l << endl;
    
    return 0;
}


Measured memory_bytes: 892
import math
import itertools

N = int(input())
c = []
for _ in range(N):
    x, y = map(int, input().split())
    c.append((x, y))

P = itertools.permutations(range(N))
ans = []
for p in P:
    s = 0
    for i in range(len(p) - 1):
        s += math.sqrt(
            math.pow(c[p[i]][0] - c[p[i + 1]][0], 2)
            + math.pow(c[p[i]][1] - c[p[i + 1]][1], 2)
        )
    ans.append(s)

print(sum(ans) / len(ans))


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
long long n,x[10005],y[10005],xx[10005],yy[10005],top,i,j,k,book[10005],ans,min1;
int main(){	
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>x[i]>>y[i];
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++){
			top++;
			xx[top]=x[j]-x[i];
			yy[top]=y[j]-y[i];
		}
	min1=100000;
	for(i=1;i<=top;i++){
		for(j=1;j<=n;j++)
			for(k=1;k<=n;k++)
				if(j!=k)
					if(y[k]-y[j]==yy[i]&&x[k]-x[j]==xx[i])
						book[k]=i;
		ans=n;
		for(j=1;j<=n;j++)
			if(book[j]==i)
				ans--;
		min1=min(min1,ans);
	}
	cout<<min1<<endl;
    return 0;
}

Measured memory_bytes: 384
import sys

mod = 10 ** 9 + 7
N, K = map(int,input().split())
A = list(map(int,input().split()))
if all([a < 0 for a in A]):
    if K % 2 == 0:
        A.sort()
        ans = 1
        for i in range(K):
            ans *= A[i]
            ans %= mod
        print(ans)
        sys.exit()
    else:
        A.sort(reverse = True)
        ans = 1
        for i in range(K):
            ans *= A[i]
            ans %= mod
        print(ans)
        sys.exit()

A.sort()
l = 0
r = N - 1
ans = 1

if K % 2 == 1:
    ans *= A[r]
    ans %= mod
    r -= 1

for _ in range(K // 2):
    if A[l] * A[l+1] >= A[r] * A[r-1]:
        ans *= A[l] * A[l+1]
        ans %= mod
        l += 2
    else:
        ans *= A[r] * A[r-1]
        ans %= mod
        r -= 2

print(ans)

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

using namespace std;

typedef long long ll;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};



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

	int n;
	cin >> n;
	
	string s;
	cin >> s;

	SegmentTree<int> seg(n, [](int a, int b) { return a | b; }, 0);

	rep(i, n){
		seg.update(i, 1 << (s[i] - 'a'));
	}

	int q;
	cin >> q;

	rep(i, q){
		int t;
		cin >> t;
		if(t == 1){
			int x;
			char c;
			cin >> x >> c;
			x--;

			if(s[x] != c) {
				seg.update(x, 1 << (c - 'a'));
				s[x] = c;
			}
		}else{
			int l, r;
			cin >> l >> r;
			l--;
			r--;

			int ans = __builtin_popcount(seg.query(l, r+1));
			cout << ans << endl;
		}
	}
	

}


Measured memory_bytes: 5020
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Nmax = 60;

vector<vector<ll>> C(Nmax, vector<ll>(Nmax));

void PascalTriangle() {

    rep(i, Nmax) {
        C[i][0] = C[i][i] = 1;
    }
    
    for(int i = 2; i < Nmax; i++) {
        for(int j = 1; j < i; j++) {
            C[i][j] = C[i-1][j] + C[i-1][j-1];
        }
    }
}

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

    vector<ll> v(n);
    rep(i, n) {
        cin >> v[i];
    } 
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    ll sum = 0;
    rep(i, a) {
        sum += v[i];
    }
    double avg = (double)sum/a;
    printf("%.7f\n", avg);

    PascalTriangle();

    ll ans = 0;
    if(v[0] != v[a-1]) {

        int x = 0, y = 0;
        rep(i, n) {
            if(v[i] == v[a-1]) {
                x++;
            }
        }
        rep(i, a) {
            if(v[i] == v[a-1]) {
                y++;
            }
        }

        ans = C[x][y];
    }
    else if(v[0] == v[a-1]) {

        int x = 0;
        rep(i, n) {
            if(v[i] == v[0]) {
                x++;
            }
        }

        for(int i = a; i <= min(b, x); i++) {
            ans += C[x][i];
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300005;
const ll inf=0x3f3f3f3f3f3f3f3fll;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,cnt,b[N],deg[N],h[N];
vector<int> e[N];
int work(int x,int fa){
	if (h[x]) return h[x];
	for (auto y : e[x])
	if (y!=fa) return work(y,x);
	assert(0);return 0;
}
int main(){
	n=read();m=read();
	for (int i=1;i<=m;i++){
		int u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
		deg[u]++;deg[v]++;
	}
	int fl=0;
	for (int i=1;i<=n;i++)
	if (deg[i]&1){puts("No");return 0;}
	else if (deg[i]>4) fl=1;
	else if (deg[i]==4) b[++cnt]=i;
	if (fl||(cnt>2)) {puts("Yes");return 0;}
	else if (cnt<2) {puts("No");return 0;}
	h[b[1]]=1;h[b[2]]=2;
	for (auto y : e[b[1]])
	if (work(y,b[1])==1) {puts("Yes");return 0;}
	puts("No");
	return 0;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  1000LL
#define tmod            998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=0,g,counter=0,u,v,d,e,w,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    string s1;
    cin >> s1;
    n = s1.size();
    for(i=0;i<n;i++)
    {
        if(i%2==0 and s1[i]=='L') {cout << "No";flag=0;break;}
        if(i%2==1 and s1[i]=='R') {cout << "No"; flag=0;break;}
    }
    if(flag)
    cout << "Yes";
    }
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (a < b&&a < c) {

		if (b < c) 
			cout << "Yes" << endl;

		else
			cout << "No" << endl;

	}

	else
		cout << "No" << endl;
	
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    bool c = false, f = false;
    string s;
    cin >> s;
    for (auto &v : s)
    {
        if (v == 'C' && !c && !f)
            c = true;
        if (v == 'F' && c && !f)
            f = true;
    }
    cout << (c && f ? "Yes" : "No") << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin >> n;
	vector<ll> v;
	rep(i, 0, n) {
		ll a;
		cin >> a;
		v.pb(a);
	}
	vector<ll> v1;
	vector<ll> v2;
	rep(i, 1, n + 1) {
		v1.pb(20001*i);
	}
	v2 = v1;
	reverse(all(v2));
	rep(i, 0, v.sz) {
		v1[v[i] - 1] += i;
	}
	rep(i, 0, v1.sz) {
		cout << v1[i];
		if (v1.sz - 1 != i) {
			cout << " ";
		}
	}
	cout << endl;
	rep(i, 0, v2.sz) {
		cout << v2[i];
		if (v2.sz - 1 != i) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <string>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
    int a, b, c, k; cin >> a >> b >> c >> k;
    while(b<=a && k>0){
        b *= 2; k--;
    }
    while((c<=b || c<=a) && k>0){
        c *= 2; k--;
    }
    if(a<b && b<c && k>=0){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 3636
n, m, l = [int(i) for i in input().split()]
A = [[int(j) for j in input().split()] for i in range(n)]
B = [[int(j) for j in input().split()] for i in range(m)]
C = [[0 for j in range(l)] for i in range(n)]

for i in range(n):
    for j in range(m):
        for k in range(l):
            C[i][k] += A[i][j] * B[j][k]
    sto = [str(s) for s in C[i]]
    print(' '.join(sto))




Measured memory_bytes: 6824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1e9,MOD=1e9+7;

int main(){
	int n,k; cin>>n>>k;
	long long cnt1=0,cnt2=0;
	if(k%2==0){
		for(int i=1;i<=n;i++){
			if(i%k==k/2) cnt1++;
			if(i%k==0) cnt2++;
		}
		long long a=pow(cnt1,3);
		long long b=pow(cnt2,3);
		cout<<a+b<<endl;
	}else{
		for(int i=1;i<=n;i++){
			if(i%k==0) cnt2++;
		}
		long long b=pow(cnt2,3);
		cout<<b<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    string o,e;cin >> o >> e ;

    for(int i = 0 ; i < o.size()-1 ; i++){
        cout << o.substr(i,1)+e.substr(i,1);
    }
    if(o.size()==e.size()) cout << o.substr(o.size()-1,1)+e.substr(o.size()-1,1) << endl;
    else cout << o.substr(o.size()-1,1) << endl;
}

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

#define is_uruu leapyear
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,a) for(int i=0;i<(a);++i)



int main(){
 
	int N, T, ans, t[200005];
	cin >> N >> T;
	FOR(i, 0, N) cin >> t[i];
	
	ans = T;
	FOR(i, 1, N){
		ans += min(T, t[i]-t[i-1]);
	}
	
	cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3010

char c[SIZE][SIZE];

set<pair<int,int>> ss;

int main(){
  int H, W;

  scanf("%d%d", &H, &W);

  for (int i=0; i<H; i++) {
    scanf("%s", c[i]);

    int l = INF, r = -1;
    for (int j=0; j<W; j++) {
      if (c[i][j] == 'B') {
        l = min(l, j);
        r = max(r, j);
      }
    }

    if (l != INF) {
      ss.insert({i, l});
      ss.insert({i, r});
    }
  }

  for (int j=0; j<W; j++) {
    int u = INF, d = -1;
    for (int i=0; i<H; i++) {
      if (c[i][j] == 'B') {
        u = min(u, i);
        d = max(d, i);
      }
    }
    if (u != INF) {
      ss.insert({u, j});
      ss.insert({u, j});
    }
  }

  int ans = 0;

  for (auto p1 : ss) {
    for (auto p2 : ss) {
      ans = max(ans, abs(p1.first-p2.first) + abs(p1.second-p2.second));
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3292
//program luogu.AT22263
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define LL long long

LL a,b,ans;

int main() {
	scanf("%lld %lld",&a,&b);
	if( a == b ) {
		printf("0\n");
		return 0;
	}
	if( a == 0 || b == 0 ) {
		if( a > b )
			ans = a - b + 1;
		else
			ans = b - a;
	}
	else if( ( a > 0 && b < 0 ) || ( a < 0 && b > 0 ) )
		ans = abs( abs( a ) - abs( b ) ) + 1;
	else {
		if( a < b )
			ans = b - a;
		else
			ans = a - b + 2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 6e2 + 10;
vector<int> v[N];
double ans[N];
double dp[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	for (int i = 1; i <= n; i++)
	{
		dp[i] = 1;
		for (int j = i - 1; j > 0; j--)
		{
			dp[j] = 0;
			for (auto& y : v[j])
				dp[j] += dp[y];
			dp[j] /= v[j].size();
		}
		ans[i] = dp[1];
	}
	MEM(dp, 0);
	dp[n] = 0;
	for (int i = n - 1; i > 0; i--)
	{
		dp[i] = 0;
		for (auto& x : v[i])
			dp[i] += dp[x];
		dp[i] = dp[i] / v[i].size();
		dp[i] += 1;
	}
	double res = dp[1];
	for (int i = 1; i < n; i++)
	{
		if (v[i].size() == 1) continue;
		for (auto& x : v[i])
		{
			double tmp = 0;
			for (auto& y : v[i])
			{
				if (y == x) continue;
				tmp += dp[y];
			}
			tmp /= (v[i].size() - 1);
			tmp += 1;
			tmp = dp[i] - tmp;
			double rest = dp[1] - tmp * ans[i];
			if (rest < 1e-8) continue;
			res = min(res, rest);
		}
	}
	printf("%.15f\n", res);
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    ll sum=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }
    
    ll x0 = sum;
    for(int i=1;i<N;i+=2){
        x0 -= 2*A[i];
    }
    cout << x0 << " ";
    for(int i=1;i<N;i++){
        cout << 2*A[i-1]-x0 << " ";
        x0 = 2*A[i-1]-x0;
    }
    cout << "\n";
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int n;
    cin >> n;

    for (int i = 0; i < 25; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if ((7 * j + 4 * (i - j)) == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

ll n, a, b;

int main() {
    scanf("%lld%lld%lld",&n,&a,&b);
    if (a*b<n||a+b>n+1) {
        printf("-1\n");
        return 0;
    }
    if (a==1) {
        for (int i=n;i;i--) printf("%d ",i);
        printf("\n"); return 0;
    }
    ll m = (n-1-b)/(a-1);
    ll p = (n+1-b)-(a-1)*m;
    for (int i=0;i<m;i++) {
        for (int j=n+1-i*a-a;j<=n-i*a;j++) printf("%d ",j);
    }
    for (int j=n+1-m*a-p;j<=n-m*a;j++) printf("%d ",j);
    for (int j=n-m*a-p;j;j--) printf("%d ",j);
    printf("\n");

    return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	auto rec = [&s, &n](auto rec, int b, int c, long long int sum) -> long long int {
		if(c == n){
			return sum + stoll(s.substr(b, c - b));
		}
		long long int ret = rec(rec, b, c + 1, sum);
		sum += stoll(s.substr(b, c - b));
		ret += rec(rec, c, c + 1, sum);
		return ret;
	};
	cout << rec(rec, 0, 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
function main(lines) {
  const N = +lines.shift();
  
  const stat = {
    AC: 0,
    WA: 0,
    TLE: 0,
    RE: 0,
  };
  
  lines.forEach(res => {
    stat[res]++;
  });
  const res = `AC x ${stat.AC}
WA x ${stat.WA}
TLE x ${stat.TLE}
RE x ${stat.RE}`;
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}


Measured memory_bytes: 36340
sx, sy, tx, ty = list(map(int, input().split()))

out = []
dx = tx - sx
dy = ty - sy
out.append('R' * dx)
out.append('U' * dy)
out.append('L' * dx)
out.append('D' * dy)
out.append('D')
out.append('R' * (dx + 1))
out.append('U' * (dy + 1))
out.append('L')
out.append('U')
out.append('L' * (dx + 1))
out.append('D' * (dy + 1))
out.append('R' * 1)
print(''.join(out))


Measured memory_bytes: 9148
#include <stdio.h>
#include <string.h>
 
int main()
{
  char S[1003] = "";
  char T[1003] = "";
  int i, j, equal, s_len, t_len, max_eq;
  
  if (fgets(S, 1002, stdin) == NULL) {
    return 1;
  }
  if (fgets(T, 1002, stdin) == NULL) {
    return 1;
  }
  
  s_len = strlen(S);
  t_len = strlen(T);
  if (S[s_len - 1] == '\n') {
      S[--s_len] = '\0';
  }
  if (T[t_len - 1] == '\n') {
      T[--t_len] = '\0';
  }
//  printf("%s %s\n", S, T);
//  printf("%d %d\n", s_len, t_len);
  
  max_eq = 0;
  for (i = 0; i <= (s_len- t_len); i++) {
    equal = 0;
    for (j = 0; j < t_len; j++) {
      if (S[i+j] == T[j]) {
        equal++;
      }
    }
    if (equal > max_eq) {
      max_eq = equal;
    }
  }
  printf("%d", t_len - max_eq);
  return 0;
}

Measured memory_bytes: 1600
import sys
input=sys.stdin.readline
n,t=map(int,input().split())
AB=[]
for i in range(n):
  a,b=map(int,input().split())
  AB.append((a,b))
AB.sort(key=lambda x:x[0])
ans=0
dp=[[0]*(t) for _ in range(n+1)]
for i in range(n-1):
  a,b=AB[i]
  for j in range(t):
    if j>=a:
      dp[i+1][j]=max(dp[i][j-a]+b,dp[i][j],dp[i+1][j-1])
    else:
      dp[i+1][j]=max(dp[i][j],dp[i+1][j-1])
  ans=max(ans,dp[i+1][t-1]+AB[i+1][1])

print(ans)


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

using namespace std;

typedef long long ll;

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

    long long n; cin >> n;
    long long weight; cin >> weight;
    
    vector<ll> w(n), v(n);
    for(long long i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    long long max_value = 0;
    vector<long long> dp(100001, -1); // -1 implies value can't be made
    dp[0] = 0;
    for(long long i = 0; i < n; i++) { //take a value
        long long curr_value = v[i];
        long long curr_weight = w[i];
        for(long long target_value = 100000; target_value >= curr_value; target_value--) {
            if (dp[target_value - curr_value] == -1) {
                continue;
            }
            if (dp[target_value] == -1) {
                dp[target_value] = dp[target_value - curr_value] + curr_weight;
            } else {
                dp[target_value] = min (dp[target_value], dp[target_value - curr_value] + curr_weight);
            }

            if (dp[target_value] <= weight) {
                max_value = max(max_value, target_value);
            }
        }
    }

    cout << max_value << '\n';
}

Measured memory_bytes: 1024
while(n,m=gets.split.map &:to_i)[0]>0
r=0..n-1
t=r.map{gets.split.map &:to_f}
d=r.map{[1]*n}
(m-1).times{d.map!{|i|r.map{|j|x=0;r.map{|k|y=i[k]*t[k][j];x<y&&x=y};x}}}
puts"%.2f"%[d.flatten.max]
end

Measured memory_bytes: 9408
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,m,k;
ll a[N],b[N];
int main()
{
    int a;cin>>a;int b=a/1000*1000;if(b<a) b+=1000;printf("%d\n",b-a);
}


Measured memory_bytes: 3760
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long T;

long long N[1005];
long long D[1005];



int main(){
	cin >> T;
	long origin = 127;
	for(int i = 0; i < T; i++){
		cin >> N[i] >> D[i];
	}

	for(int i = 0; i < T; i++){
		N[i]--;
		if(N[i]%2 == 1){
			cout << 127 * N[i] + (127 ^ D[i]) << endl;
		}else{
			cout << 127 * N[i] + D[i] << endl;
		}
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

_n = int(input())

said = []
for i in range(_n):
    ai = int(input())
    said.append([list(map(int, input().split())) for _ in range(ai)])

ans = 0
for i in range(2 ** _n):
    ynflg = 1
    flg = format(i, 'b').zfill(_n)
    for sy, tag in zip(said, flg):
        if tag == '0':
            continue

        for s in sy:
            if flg[s[0] - 1] != str(s[1]):
                ynflg = 0
                break

        if ynflg == 0:
            break

    if ynflg == 1:
        ans = max(ans, flg.count('1'))

print(ans)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES////////////////////////////////////////
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

int uplg(int n) { return 32-__builtin_clz(n); }
int uplg(ll n)  { return 64-__builtin_clzll(n); }

constexpr ll MULT = 200131;
constexpr ll MOD1 = 1e9+7;
constexpr ll MOD2 = 1e9+9;

using Pll = pair<ll, ll>;
using Hash = pair<Pll, Pll>;

vector<Hash> tree;
int len;

Pll comb(Pll l, Pll r, ll m) {
	ll a = l.x*r.y + r.x;
	ll b = l.y*r.y;
	return {a%m, b%m};
}

Hash comb(Hash l, Hash r) {
	return {comb(l.x, r.x, MOD1), comb(l.y, r.y, MOD2)};
}

void upd(int i, Hash val) {
	tree[i+=len] = val;
	while (i /= 2) {
		tree[i] = comb(tree[i*2], tree[i*2+1]);
	}
}

void run() {
	int n, k; cin >> n >> k;
	Vi elems(n);
	each(e, elems) {
		cin >> e;
		e++;
	}

	Hash none = { {0,1}, {0,1} };
	for (len = 1; len <= n; len *= 2);
	tree.resize(len*2, none);

	auto single = [&](int e) { return Hash{ {e, MULT}, {e, MULT} }; };

	vector<Hash> prefHash = {none};
	each(e, elems) {
		prefHash.pb(comb(prefHash.back(), single(e)));
	}

	vector<Hash> sufHash(n+1, none);
	for (int i = n-1; i >= 0; i--) {
		sufHash[i] = comb(single(elems[i]), sufHash[i+1]);
	}

	vector<Pll> seen;

	rep(i, 0, k) {
		upd(elems[i]-1, single(elems[i]));
	}

	rep(i, 0, n-k+1) {
		Hash h = prefHash[i];
		h = comb(h, tree[1]);
		h = comb(h, sufHash[i+k]);
		seen.pb({h.x.x, h.y.x});

		if (i+k < n) {
			upd(elems[i]-1, none);
			upd(elems[i+k]-1, single(elems[i+k]));
		}
	}

	sort(all(seen));
	seen.erase(unique(all(seen)), seen.end());
	cout << sz(seen) << endl;
}


Measured memory_bytes: 39144
#include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <sstream>
    #include <queue>
    #include <deque>
    #include <bitset>
    #include <iterator>
    #include <list>
    #include <stack>
    #include <map>
    #include <unordered_map>
    #include <set>
    #include <unordered_set>
    #include <functional>
    #include <numeric>
    #include <utility>
    #include <limits>
    #include <time.h>
    #include <math.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <assert.h>
     
    using namespace std;
     
    #define FOR(i,n) for(int i = 0; i < n; i++)
    #define FORa(i,a,b) for(int i = a; i < b; i++)
    #define pb(x) push_back(x)
    #define mp(a, b) make_pair(a, b)
    #define F first
    #define S second
    #define SORT(a,n) sort(begin(a), begin(a) + n)
    #define VSORT(v) sort(v.begin(), v.end())
    #define MAX 1000000
    #define ll long long
    #define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
    #define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)
     
    //-------------------------------------------------------//
     
    int main() {
    	ll n, m, k, ans = 0;
    	cin >> n >> m >> k;
    	
    	vector<ll> a(n+1); a[0] = 0;
    	vector<ll> b(m+1); b[0] = 0;
    	
    	for(ll i = 1; i <= n; i++) {
    		cin >> a[i];
    		a[i] += a[i-1];
    	}
    	
    	for(ll i = 1; i <= m; i++) {
    		cin >> b[i];
    		b[i] += b[i-1];
    	}
    	
    	for(ll i = 0, j = m; i <= n; i++) {
    		if(k - a[i] < 0) break;
    		while(a[i] + b[j] > k) j--;
    		
    		ans = max(ans, i + j);
    	}
    	
    	cout << ans << endl;
    	
    	return 0;
    }


Measured memory_bytes: 6356
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            if self.same_check(x, y) != True:
                self.size[y] += self.size[x]
                self.size[x] = 0
            self.par[x] = y
        else:
            if self.same_check(x, y) != True:
               self.size[x] += self.size[y]
               self.size[y] = 0
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
               self.rank[x] += 1

    def siz(self, x):
        x = self.find(x)
        return self.size[x]


N, M = list(map(int, input().split()))
p = list(map(int, input().split()))

uf = UnionFind(N)
for i in range(M):
    x, y = list(map(int, input().split()))
    uf.union(x, y)

c = 0
for i in range(N):
    if uf.find(p[i]) == uf.find(i + 1):
        c += 1

print(c)



Measured memory_bytes: 13812
N = int(input())
S = str(input())

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N):
    for j in range(i+1,N):
        k = 2*j - i
        if k>=N:
            break
        if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
            ans -=1

print(ans)

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

int main(){
    int N,M,C,count=0,kekka;
    cin >> N >> M >> C;
    vector<int> B(M);
    
    for(int i = 0;i < M;i++)
        cin >> B.at(i);
    
    vector<vector<int>> A(N,vector<int>(M));

    for(int i = 0;i < N;i++)
        for(int j = 0;j < M;j++){
            cin >>  A.at(i).at(j);
        }

    for(int i = 0;i < N;i++){
        kekka = 0;
        for(int j = 0;j < M;j++){
            kekka += A.at(i).at(j) * B.at(j);
        }
        kekka += C;
        if(kekka > 0)
            count++;
    }

    cout << count << endl;
}   

Measured memory_bytes: 256
def try_dfs_fill_distance(graph, starting_node, distance_cache):
    found_conflicts = False
    traverse_stack = []
    traverse_stack.append((starting_node, 0))

    while traverse_stack:
        node, node_dist_from_origin = traverse_stack.pop()
        if distance_cache[node] == None:
            distance_cache[node] = node_dist_from_origin
            for neighbor_data in graph[node]:
                neighbor_id, neighbor_diff = neighbor_data
                traverse_stack.append((neighbor_id, node_dist_from_origin + neighbor_diff))

        elif distance_cache[node] != node_dist_from_origin:
            found_conflicts = True
            break

    return found_conflicts

if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    graph = [[] for _ in range(n + 1)]
    for _ in range(m):
        l, r, d = list(map(int, input().split()))
        graph[l].append((r, d))
        graph[r].append((l, -d))

    distance_cache = [None for _ in range(n + 1)]
    has_conflict = False
    for i in range(1, len(distance_cache)):
        if distance_cache[i] == None:
            has_conflict = try_dfs_fill_distance(graph, i, distance_cache)
            if has_conflict:
                break

    print("No" if has_conflict else "Yes")

Measured memory_bytes: 83432
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: OakenSh1eld
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	if(n%2) {cout<<"No"; return 0;}
	for(int i = 0; i<n/2; ++i) if(s[i] != s[i+n/2]){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int k;
    vector<int> an(5);
    rep(i,5) cin >> an[i];
    cin >>k;
    sort(an.begin(),an.end());
    if(abs(an[0]-an[4]) > k){
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,k,r,x=0,y=0,z=0;
    cin>>a>>b>>c>>k;
    x=min(k,a);
    k-=x;
    if(k>0)
    {
        y=min(b,k);
        k-=y;
    }
    if(k>0)
    {
        z=min(c,k);
        k-=z;
    }
    r=x-z;
    cout<<r;
}



Measured memory_bytes: 3636