akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <regex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code
int main(int argc, char const* argv[])
{
    int a,b,k;
    set<int> st;
    cin >> a >> b >> k;
    for (int i = a; i < a+k; i++) {
        if (i>b) {
            break;
        }
        st.insert(i);
    }
    for (int i = b-k+1; i < b+1; i++) {
        if (i < a) {
            continue;
        }
        st.insert(i);
    }
    for (auto&& var : st) {
        cout << var << endl;
    }
    return 0;
}


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

const int N = 100010;

int n, vis[N];
vector<int> g[N];

int main() {
	cin >> n;
	for(int i = 0; i <= n; i++) {
		vis[i] = -1;
	}
	for(int foo = 1; foo <= n; foo++) {
		int bar;
		cin >> bar;
		g[foo].push_back(bar);
	}
	queue<int> q;
	vis[1] = 0;
	q.push(1);
	while(! q.empty()) {
		int u = q.front(); q.pop();
		for(int v : g[u]) {
			if(vis[v] == -1) {
				vis[v] = vis[u] + 1;
				q.push(v);
			}
		}
	}
	cout << vis[2] << endl;
}

Measured memory_bytes: 6144
n = gets.to_i
s = gets.chomp

def flip c
	(c==?S) ? ?W : ?S
end

[?S, ?W].repeated_permutation(2).each{|t|
	(1...n).each{|i|
		if t[i]==?S
			if s[i]==?o
				t << t[i-1]
			else
				t << flip(t[i-1])
			end
		else
			if s[i]==?o
				t << flip(t[i-1])
			else
				t << t[i-1]
			end
		end
	}
	if t[-1]==t[0]
		if t[0]==?S
			if s[0]==?o
				if t[1]==t[-2]
					puts t[0...n].join
					exit
				end
			else
				if t[1]!=t[-2]
					puts t[0...n].join
					exit
				end
			end
		else
			if s[0]==?o
				if t[1]!=t[-2]
					puts t[0...n].join
					exit
				end
			else
				if t[1]==t[-2]
					puts t[0...n].join
					exit
				end
			end
		end
	end
}
puts -1

Measured memory_bytes: 10896
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //Look for adjacent outliers first
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] arr = new int[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
		}
		for (int i = 0; i < N-1; i++) {
			if (arr[i]==i+1&&arr[i+1]==i+2) {
				ans++;
				int tempA = arr[i];
				int tempB = arr[i+1];
				arr[i] = tempB;
				arr[i+1]=tempA;
			}
		}
		for (int i = 0; i < N; i++) {
			if (arr[i]==i+1) ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50756
S = str(input())

ans = 0

left_count = 0
right_count = 0

for i in range(len(S)):
  if S[i] == "<":
    left_count += 1
  elif S[i] == ">":
    right_count += 1
  if i != len(S)-1:
    if S[i] == ">" and S[i+1] == "<":
      ans += (left_count * (left_count -1))//2 + (right_count * (right_count -1))//2 + max(left_count , right_count)
      left_count = 0
      right_count = 0
  else:
    ans += (left_count * (left_count -1))//2 + (right_count * (right_count -1))//2 + max(left_count,right_count)

print(ans)


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

int main(){

  string S; cin >> S;
  
  int ans = 0;
  for(int i=0; i<S.size()/2; i++){
    
    if(S.at(i) != S.at(S.size()-1-i))
      ans++;
  
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC100_D___Patisserie_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0];
            var M = NM[1];
            var cakes = new long[N, 3];
            for (int i = 0; i < N; i++)
            {
                var xyz = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
                cakes[i, 0] = xyz[0];
                cakes[i, 1] = xyz[1];
                cakes[i, 2] = xyz[2];
            }

            long maxPoint = 0;
            for (int bit = 0; bit < (1 << 3); bit++)
            {
                var signX = (bit & (1 << 0)) > 0 ? -1 : 1;
                var signY = (bit & (1 << 1)) > 0 ? -1 : 1;
                var signZ = (bit & (1 << 2)) > 0 ? -1 : 1;

                var cakesTotal = new long[N];
                for (int i = 0; i < N; i++)
                    cakesTotal[i] = cakes[i, 0] * signX + cakes[i, 1] * signY + cakes[i, 2] * signZ;

                var totalPoint = cakesTotal.OrderByDescending(s => s).Take(M).Sum();
                maxPoint = Math.Max(maxPoint, totalPoint);
            }

            Console.WriteLine(maxPoint);
        }
    }
}


Measured memory_bytes: 13364
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int dp[5000][1100];
int a[1100];
int b;
int c[1100];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < 5000; i++) {
		for (int j = 0; j < 1100; j++) {
			dp[i][j] = 1000000007;
		}
	}
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b;
		bitset<13> bit;
		for (int j = 0; j < b; j++) {
			int d;
			cin >> d;
			d--;
			bit[d] = 1;
		}
		c[i] = bit.to_ulong();
	}
	dp[0][0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			dp[(j | c[i])][i] = min(dp[(j | c[i])][i], dp[j][i - 1] + a[i]);
			dp[j][i] = min(dp[j][i], dp[j][i - 1]);
		}
	}
	if (dp[(1 << n) - 1][m] == 1000000007) {
		cout << "-1" << endl;
		return 0;
	}
	cout << dp[(1 << n) - 1][m] << endl;
}

Measured memory_bytes: 25108
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t<d)
    cout<<"No"<<"\n";
    else
    {
        cout<<"Yes"<<"\n";
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    string s;
    cin >> s;
    int n;
    n = SZ(s);
    if(s[0] == '0' || s[n-1] == '1')
    {
        cout << -1 << endl;
        return 0;
    }
    bool ng = 0;
    FOR(i,1,n/2 + 1)
    {
        if(s[i] != s[n-2-i])
        {
            ng = 1;
            break;
        }
    }
    if(ng)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << "1 2" << endl;
    int parent = 2;

    FOR(i,1,n-1)
    {
        if(s[i] == '1')
        {
            cout << parent << " " << i+2 << endl;
            parent = i+2;
        }
        else
        {
            cout << parent << " " << i+2 << endl;

        }

    }

}


Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <map>
using namespace std;

const int M = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% M + M) % M) {};
	void pow(long long n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % M;
			xx = xx * xx % M;
			n >>= 1;
		}
	}

};

int main() {
	int N;
	cin >> N;
	map<int, int> Nums;
	int isOK = true;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 2 != N % 2) {
			Nums[a]++;
			if (Nums[a] > 2 || Nums[0] > 1) isOK = false;
		}
		else isOK = false;
	}
	if (!isOK) cout << 0 << endl;
	else {
		mll ans = 2;
		ans.pow(N / 2);
		cout << ans.x << endl;
	}
}

Measured memory_bytes: 2560
def split(word):
    return [char for char in word]
N=int(input())
S=input()
Slist=split(S)
Rcounter=0
Bcounter=0
Gcounter=0
for i in range(0,N):
    if Slist[i]=='R':
        Rcounter=Rcounter+1
    if Slist[i]=='B':
        Bcounter=Bcounter+1
    if Slist[i]=='G':
        Gcounter=Gcounter+1
ans=Rcounter*Gcounter*Bcounter
for i in range(0,N):
    for j in range(i+1,N):
        if 2*j-i>N-1:
            break
        if (Slist[i]==Slist[j]) or (Slist[i]==Slist[2*j-i]) or (Slist[j]==Slist[2*j-i]):
            continue
        ans=ans-1
print(ans)


Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 998244353;
inline void upd(int &a,int b)
{
	a += b;
	if(a >= mod) a -= mod;
}
int N,M;
int fac[2000005],inq[2000005];
int qpow(int x,int y)
{
	int ans = 1;
	while(y)
	{
		if(y&1) ans = 1ll*ans*x%mod;
		x = 1ll*x*x%mod;y >>= 1;
	}
	return ans;
}
void init()
{
	fac[0] = 1;
	for(int i = 1;i <= 2000000;i ++)
		fac[i] = 1ll*i*fac[i-1]%mod;
	inq[2000000] = qpow(fac[2000000],mod-2);
	for(int i = 1999999;i >= 0;i --)
		inq[i] = 1ll*inq[i+1]*(i+1)%mod;
}
inline int C(int x,int y) { return 1ll*fac[x]*inq[x-y]%mod*inq[y]%mod; }
int solve(int sm)
{
	if(sm < 0)
		return 0;
	//sum = sm, atmost M odd
	int r = min(min(N,M),sm);
	int ans = 0;
	for(int i = sm&1;i <= r;i += 2)
		ans = (ans+1ll*C(N,i)*C(N+((sm-i)>>1)-1,N-1))%mod;
	return ans;
}
signed main()
{
	init();
	scanf("%lld%lld",&N,&M);
	printf("%lld\n",(solve(3*M)-1ll*solve(M-1)*N%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 31488
n=int(input())
from decimal import Decimal as D
# A=[]
excel=[[0]*20 for i in range(50)]
query=[]
for i in range(n):
    q=input()
    q=D(q)
    q=int(q*10**9)
    num2=0 ;num5=0
    k=q
    for i in range(50):
        if k%2==0:
            k//=2
            num2+=1
        else:break
    k=q
    for i in range(20):
        if k%5==0:
            k//=5
            num5+=1
        else:break
    excel[num2][num5]+=1
    query.append([max(0,18-num2),max(0,18-num5)])

A=[[0] * 20 for i in range(50)] #累積和
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i==49 and j==19:
            A[i][j]=excel[i][j]
        elif i==49:
            A[i][j]=A[i][j+1]+excel[i][j]
        elif j==19:
            A[i][j]=A[i+1][j] + excel[i][j]
        else:
            A[i][j]=excel[i][j]+ A[i+1][j]+A[i][j+1]-A[i+1][j+1]

ans=0
for l in query:
    num2,num5=l
    if num2<=9 and num5<=9:
        ans+=A[num2][num5]-1
    else:
        ans+=A[num2][num5]

#for i in range(50):
 #   print(excel[:][i] , A[:][i])
print(ans//2)


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int l, r;
    cin >> l >> r;
    ll ans = 1e9;
    for (int i = l; i <= min(r, l + 2020); ++i)  {
        for (int j = i + 1; j <= min(r, i + 2020); ++j) {
            ans = min(ans, 1LL * i * j % 2019);
        }
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())

ans_wat = 0
ans_sug = 0
ans_rate = 0

for i in range(31):
    for j in range(31):
        water = (i * a + j * b) * 100
        if (water <= f and water):
            nsug = min(water * e // 100, f - water)
            for k in range(nsug//c+1):
                l = (nsug - k*c)//d
                suger = k * c + l * d
                rate = 100 * suger / (suger + water)
                if(ans_rate <= rate):
                    ans_rate = rate
                    ans_sug = suger
                    ans_wat = water

print(ans_wat+ans_sug,ans_sug)

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

int main() {
    const int limit = 1e6 + 5;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> v(limit), primes;
    fill(v.begin(), v.end(), 1);
    v[0] = v[1] = 0;
    for (int i = 2; i <= limit; i++) {
        if (!v[i]) continue;
        primes.push_back(i);
        for (int j = 2 * i; j < n; j += i) {
            v[j] = 0;
        }
    }
    vector<int> mark(limit);
    bool pairwise = true;
    for (int x : a) {
        int t = x;
        for (int p : primes) {
            if (p * p > t) break;
            if (t % p == 0) {
                if (mark[p]) {
                    pairwise = false;
                    break;
                }
                mark[p] = 1;
                while (t % p == 0)
                    t /= p;
            }
        }
        if (v[t]) {
            if (mark[t])
                pairwise = false;
            mark[t] = 1;
        }
        if (!pairwise)
            break;
    }
    if (pairwise) {
        cout << "pairwise coprime\n";
        return 0;
    }
    int g = a[0];
    for (int x : a) {
        g = __gcd(g, x);
    }
    if (g == 1)
        cout << "setwise coprime\n";
    else
        cout << "not coprime\n";
}


Measured memory_bytes: 15196
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 3010
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) fixed<<setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

double p[mx], dp[mx][mx];
ll n;

double coin(ll h, ll i){

	if( i== n){

		if(!h)
		return 1.0;

		return 0.0;
	}

	if(!h)
	return dp[h][i]= (1 - p[i])* coin(h, i+1);

	if(dp[h][i] != -1.0)
	return dp[h][i];

	return dp[h][i] = p[i]*coin(h-1, i+1) + (1- p[i])*coin(h, i+1) ;
}
void bta_de_yarr(){

	ll i, j, fl=0, m;

	cin>>n;

	double ans= 0;

	rep(i, 0, n)
	{
		cin>>p[i];
	}

	rep(i, 0, n+5)
	{
		rep(j, 0, n+5)
		dp[i][j]= -1.0;
	}

	rep(i, (n+1)/2, n+1){

		ans+= coin(i, 0);
	}
	
	// sp(10);
	cout<<sp(10)<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 71168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c[200005];
	string m1,m2;
	scanf("%s",c);
	int len=strlen(c);
	int cnt=1;
	m1=c[0];
	for(int i=1;i<len;i++){
		m2+=c[i];
		if(m1!=m2){
			//cout << m1 << endl;
			m1=m2;
			//cout << m2 << endl;
			m2.clear();
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 9223372036854775807
#define LONG_LONG_MIN -9223372036854775808
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const int maxn = 110;
int n, a[maxn];

double solve() {
    double res = 0;
    double down = 0;
    rep(i, n) {
        double temp = 1.0 / a[i];
        down += temp;
    }
    res = 1 / down;
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    scanf("%d", &n);
    rep(i, n) {
        scanf("%d", &a[i]);
    }
    double ans = solve();
    printf("%.8f\n", ans);
    return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;



int main(){
  ll q,l,r;
  l=r=0;
  cin >> q;
  rep(i,q){
    ll p,n; char c;
    cin >> p >> c >> n;
    if(c=='(') l += n;
    else r += n;
    cout << (l==r?"Yes\n":"No\n");
  }

  return 0;
}

Measured memory_bytes: 1124
n = int(input())
h = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(n-1):
    
    if h[i] >= h[i+1]: cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
const int MX=50000;
ll f[MX+1],g[MX+1],inv[MX+1];
void precalc(){
	f[0]=1;
	rep1(i,MX) f[i]=f[i-1]*i%mod;
	inv[1]=1;
	for(int i=2;i<=MX;i++) inv[i]=mod-mod/i*inv[mod%i]%mod;
	g[0]=1;
	rep1(i,MX) g[i]=g[i-1]*inv[i]%mod;
}
ll C4(int a,int b,int c,int d){
	return f[a+b+c+d]*g[a]%mod*g[b]%mod*g[c]%mod*g[d]%mod;
}
ll C2(int a,int b){
	if(b==0) return 1;
	if(a<b) return 0;
	return f[a]*g[b]%mod*g[a-b]%mod;
}
int main(){
	precalc();
	int N,A,B,C;
	cin>>N>>A>>B>>C;
	if(B%2==1){
		puts("0");
		return 0;
	}
	ll ans=0;
	rep(i,A+1){
		rep(j,C/3+1){
			int l=C-(A-i)-3*j;
			if(l<0) break;
			ll tmp=C4(i,A-i,j,B/2);
			tmp*=C2(l+B/2-1,l);
			tmp%=mod;
			ans+=tmp;
			ans%=mod;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class CColoringColorfully {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		in >> s;
		// 0 fst
		int cnt0, cnt1;
		cnt0 = cnt1 = 0;
		for(int i = 0; i < s.size(); i++){
		    if (i % 2 == 0){
		        if (s[i] == '1')
		            cnt0++;
		    }
		    else{
		        if (s[i] == '0')
		            cnt0++;
		    }
		}

        for(int i = 0; i < s.size(); i++){
            if (i % 2 == 0){
                if (s[i] == '0')
                    cnt1++;
            }
            else{
                if (s[i] == '1')
                    cnt1++;
            }
        }
        out << min(cnt0, cnt1);

	}
};

int main() {
	CColoringColorfully solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int x, y;
        x = int.Parse(str[0]);
        y = int.Parse(str[1]);
        int[] g1 = { 1, 3, 5, 7, 8, 10, 12 };
        int[] g2 = { 4, 6, 9, 11 };
        int[] g3 = { 2 };
        bool f = (g1.Contains(x) && g1.Contains(y)) || (g2.Contains(x) && g2.Contains(y)) || (g3.Contains(x) && g3.Contains(y));
        Console.WriteLine(f ? "Yes" : "No");
    }
}

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

int main(){
    int height[1100];
    height[1] = 1;
    for (int i=2; i<=999; i++){
        height[i] = height[i-1] + i;
    }

    int a, b;
    cin >> a >> b;
    int pos = b-a;
    cout << height[pos]-b << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int H, W, A, B; cin >> H >> W >> A >> B;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(j < A){
                if(i < B)   cout << 1;
                else    cout << 0;
            }else{
                if(i < B)   cout << 0;
                else    cout << 1;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3620
#coding: utf-8
from collections import defaultdict, deque

N, M = [int(x) for x in input().split()]

G = defaultdict(set)
for i in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    G[a].add(b)
    G[b].add(a)

grp = [-1] * N

for i in range(N):
    q = deque()
    q.append((i,i))

    while(len(q) != 0):
        node, color = q.popleft()
        if grp[node] != -1:
            continue
        grp[node] = color
        for n in G[node]:
            if grp[n] == -1:
                q.append((n, color))

n = defaultdict(int)
for i in range(N):
    n[grp[i]] += 1

ret = 0
for r in n:
    ret = max(ret, n[r])
print(ret)


Measured memory_bytes: 91944
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
    int n,m;
    cin >> n >> m;
    typedef pair<long,int> pair;
    vector <pair> vec(1000000);
    for (int i=0;i<n;i++){
        long a;
        cin >> a ;
        vec.at(i)=make_pair(a,1);
    }
    
    for(int i=0;i<m;i++){
    int b;
    long c;
    cin >>b;
    cin >> c;
        vec.at(i+n)=make_pair(c,b);
    }
    sort(vec.begin(), vec.end(), greater<pair>() );
    long ans=0;
    
    for (int i=0;n>0;i++){
        long a=vec.at(i).second;
        if (n>=a) {
            ans+=a*vec.at(i).first;
            n-=a;
        }
        else {
            ans+=n*vec.at(i).first;
            n=0;
        }
    }
    cout << ans << endl;
}



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

public class Main
{
    public static void main(String[] args) throws IOException
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=br.readLine())!=null){
			int[] nums = new int[5];
			for(int i=0;i<5;i++)
					nums[i] = Integer.parseInt(s.split(" ")[i]);
			Arrays.sort(nums);
			for(int i=4; i>0; i--)
				System.out.print(nums[i]+" ");
			System.out.println(nums[0]);
		}
    }
}

Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
int cnt[3];
int main() {
	int a[5],b[5];
	for(int i=0;i<3;i++){
		cin>>a[i]>>b[i];
		cnt[a[i]]++;
		cnt[b[i]]++;
	}
	if(cnt[1]==3||cnt[2]==3||cnt[3]==3||cnt[4]==3){
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	ll n,k;cin>>n>>k;
	if(k==1){
		cout<<n*n*n<<endl;
		return 0;
	}
	ll cnt=0;
	for(int i=0;i<k;i++){
		if((i*2)%k)continue;
		if(n<i)continue;
		ll a=(n-i)/k;
		if(i)a++;
		cnt+=a*a*a;
	}
	cout<<cnt<<endl;
}

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

int main(){
  int N,M=0,MN=0,cnt=0;
  cin >> N;
  vector<int> vec(N);
  vector<int> vec2(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
    vec2[i]=vec[i];
    if(vec[i]>M){
      MN=i;
      M=vec[i];
    }
  }
  sort(vec2.begin(),vec2.end());
  for(int j=0;j<N;j++){
    if(vec[j]==M)
      cnt++;
  }
  if(cnt>1){
    for(int k=0;k<N;k++){
      cout << M << endl;
    }
  }
  else{
    for(int l=0;l<N;l++){
      if(l==MN)
        cout << vec2[N-2] << endl;
      else
        cout << M << endl;
    }
  }
}

Measured memory_bytes: 3200
import math

A,B,H,M = map(int,input().split())

hour_r = (0.5*H*60) + M*0.5

minu_r = 6*M

if hour_r > minu_r:
    k = hour_r - minu_r
else:
    k = minu_r - hour_r
k = min (k,360-k)
#print(k)

ans_2 = (A**2+B**2)-2*A*B*(math.cos(math.radians(k)))
print(ans_2**0.5)

Measured memory_bytes: 9532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  int M=sqrt(N);
  vii dp(K+1,vi(M+1)),cp(K+1,vi(M+1));
  REP(i,1,M) dp[1][i]=i;
  REP(i,1,M) cp[1][i]=N/i;
  REP(i,2,K){
    REP(j,1,M){
      dp[i][j]=(dp[i][j-1]+cp[i-1][j])%MOD;
    }
    cp[i][M]=(dp[i][M]+dp[i-1][M]*(max(M,N/M)-min(N/M,M)))%MOD;
    rep(j,1,M){
      cp[i][M-j]=(cp[i][M-j+1]+dp[i-1][M-j]*(N/(M-j)-N/(M-j+1)))%MOD;
    }
  }
  int ans=cp[K][1];
  cout<<ans<<endl;
  }



Measured memory_bytes: 50440
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
cp = 0
cm = 0
for i in range(N):
    if A[i]>B[i]:
        cm += A[i]-B[i]
    elif B[i]>A[i]:
        cp += (B[i]-A[i])//2
if cp>=cm:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 73920
x = int(input())
if x == 2 or x == 3:
   print(x)
   exit()
while True:
      n = 0
      for i in range(2, int(-(-x**0.5//1))+1):
          if x % i == 0:
             break
          else:
              n = n + 1
      if n == int(-(-x**0.5//1))-1 :
          print(x)
          exit()
      else:
          x = x + 1

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

int main(){
  string s;
  cin >> s;
  int pointer = 0;
  int del = 0;
  rep(i,s.size()){
    if(s[i] == 'S') pointer++;
    else if(pointer > 0) pointer--, del++;
  }
  cout << s.size() - 2 * del << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
	svec hoge;
	map<string,int> ma;
	int n;cin>>n;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		string s;cin>>s;
		ma[s]++;
		ans=max(ans,ma[s]);
	}
	map<string,int>::iterator p;    
    	for(p=ma.begin(); p!=ma.end(); p++)
	{
		if(p->second == ans)hoge.push_back(p->first);
	}	
	sort(hoge.begin(),hoge.end());
	for(int i=0;i<hoge.size();i++)cout<<hoge[i]<<"\n";
	return 0;
}

Measured memory_bytes: 26868
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n, _ := strconv.Atoi(input())
	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i], _ = strconv.Atoi(input())
	}
	sort.Ints(x)

	minv := x[0]
	maxv := x[n-1]
	ans := 100 * 100 * 100
	for p := minv; p <= maxv; p++ {
		sum := 0
		for i := 0; i < n; i++ {
			sum += (x[i] - p) * (x[i] - p)
		}
		ans = min(ans, sum)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
//2010
#include<iostream>
using namespace std;
int main(void){
	int i,n,k,a[1000],b[1000];//a=x,b=y;
	cin>>n;
	cin>>k;
	for(i=0;i<k;i++){
		cin>>a[i]>>b[i];//a=x,b=y;
		if(a[i]>n/2){
			a[i]=n-a[i]+1;
		}
		if(b[i]>n/2){
			b[i]=n-b[i]+1;
		}
	}
	
	for(i=0;i<k;i++){
		if(b[i]>=a[i]){
			if(a[i]%3==0){
				cout<<3<<endl;
			}
			else if(a[i]%3==1){
				cout<<1<<endl;
			}
			else{
				cout<<2<<endl;
			}
		}
		else{
			if(b[i]%3==0){
				cout<<3<<endl;
			}
			else if(b[i]%3==1){
				cout<<1<<endl;
			}
			else{
				cout<<2<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		long K=sc.nextLong();
		long A=sc.nextLong();
		long B=sc.nextLong();
		if(A>=B) {
			System.out.println(K+1);return;
		}
		//a回お金ふやしてb回ビスケットに変えてc回たたく
		//お金は使い切ったほうがいいのでa==bが理想
		long score=0;

		if(B<A+2)score=K+1;
		else {
			long change=(K+1-A)/2;
			System.err.println(change);
			score=change*(B-A)+K-change*2+1;
		}
		System.out.println(score);

	}

}


Measured memory_bytes: 21844
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k;
		// n=s.length();
		// ll a[n];
		c=1;
		m=1;
		while(n>=m)
		{
			c++;
			m*=k;
		}
		if(c==1) c=2;
		cout<<c-1;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
// No sorceries shall prevail. //           
import java.util.*;
import java.io.*;
public class Main {
	
	static long gcd(long a, long b) { 
	      if (b == 0) 
	        return a; 
	      return gcd(b, a % b);  
	    }
	static int gcd(int a, int b) { 
	      if (b == 0) 
	        return a; 
	      return gcd(b, a % b);  
	    }
	
	static long mod = 1000000007;
	public static void main(String args[]) {
		Scanner inp=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		
		long k=inp.nextLong();
		int n=inp.nextInt();
		long a[]=new long[n];
		for(int i=0;i<n;i++)
			a[i]=inp.nextLong();
		long max=k+a[0]-a[n-1];
		for(int i=1;i<n;i++) {
			max=Math.max(a[i]-a[i-1], max);
		}
		out.println(k-max);
		
		out.close();
		inp.close();
	}
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef vector<int> vi; 
typedef pair<int,int> pii; 
#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

// ----------------------------------------------------------------------------	-------------- 

void solve(){
  int a,b;  cin>>a>>b;  
  cout<<1+2+3-a-b<<endl; 
}

int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


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

Measured memory_bytes: 256
a,b = map(int,input().split())
s = input()
ans = ["0","1","2","3","4","5","6","7","8","9"]
ch1 = list(map(str,s[:a]))
if a > b:
    ch2 = list(map(str,s[a+b:]))
else:
    ch2 = list(map(str,s[a+1:]))
count = 0
for i in range(len(ch1)):
    if ch1[i] not in ans:
        count +=1
for j in range(len(ch2)):
    if ch2[j] not in ans:
        count += 1
if count == 0 and s[a] == "-":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<pii, pii> ii_ii;
typedef pair<int, long> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pli> vpli;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;
 
const int MOD = 1e9 + 7;
const int MAXN = 2e5;
const int MAXM = 3e3;
 
int fac[MAXN + 1], inv[MAXN + 1];
int dp[MAXM + 1];
pii a[MAXM + 1];
 
void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
 
int modpow(int x, int y, int mod) {
	int ans = 1;
	x %= mod;
	while(y) {
		if(y & 1) ans = (1LL * ans * x) % mod;
		x = (1LL * x * x) % mod;
		y >>= 1;
	}
	return ans % mod;
}
 
void init() {
	fac[0] = 1, inv[0] = modpow(fac[0], MOD - 2, MOD);
	for(int i = 1; i <= MAXN; i++) {
		fac[i] = (1LL * i * fac[i - 1]) % MOD;
		inv[i] = modpow(fac[i], MOD - 2, MOD);
	}
}
 
int nCr(int n, int r) {
	return (1LL * fac[n] * inv[r] % MOD * inv[n - r] % MOD) % MOD;
}
 
int sub(int a, int b) {
	a = (a - b) % MOD;
	while(a < 0) a += MOD;
	if(a >= MOD ) a-= MOD;
	return a; 
}
 
int main() {
	fast_io();
//	freopen("input/559C.txt", "r", stdin);
	
	int h, w, n, mul;
	cin >> h >> w >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i].fi >> a[i].se;
		a[i].fi--, a[i].se--;
	}
	sort(a, a + n);
	
	init();
	for(int i = 0; i < n; i++) {
		dp[i] = nCr(a[i].fi + a[i].se, a[i].fi);
		for(int j = 0; j < i; j++) {
			if(a[i].fi - a[j].fi < 0 or a[i].se - a[j].se < 0) continue;
			mul = (1LL * dp[j] * nCr(a[i].fi - a[j].fi + a[i].se - a[j].se, a[i].se - a[j].se)) % MOD;
			dp[i] = sub(dp[i], mul);
		}
	}
	
	h--, w--;
	ll ans = nCr(h + w, w);
	for(int i = 0; i < n; i++) {
		mul = (1LL * dp[i] * nCr(h - a[i].fi + w - a[i].se, w - a[i].se)) % MOD;
		ans = sub(ans, mul) % MOD;
	}
	cout << ans << '\n';
	
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

#define forn(i, n) for(int i=0; i<n; i++)
#define mp makepair
#define pb push_back


int N,M,u,v;
vector<vector<int>> adj;
stack<int> s;
vector<int> visited;


void dfs(int u) {
    visited[u] = 1;
    for(int i=0;i<adj[u].size();i++){
        if (!visited[adj[u][i]])
            dfs(adj[u][i]);
    }
    s.push(u);
}

int main(){
    scanf("%d%d",&N, &M);
    visited = vector<int>(N,0);
    adj = vector<vector<int> >(N);
    for(int i=0;i<M;i++){
        scanf("%d%d", &u, &v);
        adj[u-1].push_back(v-1);
    }
    for(int i=0;i<N;i++)
        if (!visited[i])
            dfs(i);

    vector<int> dist(N,0);

    int ans = 0;
    while(!s.empty()) {
        int u = s.top();
        s.pop();
        for(int i=0;i<adj[u].size();i++) {
            int v = adj[u][i];
            dist[v] = max(dist[u]+1, dist[v]);
            ans = max(ans, dist[v]);
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 8960
N = input()
A, B, C, D = N[0], N[1], N[2], N[3]

ops = ['+','-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      if(eval(A + op1 + B + op2 + C + op3 + D) == 7):
        print(A + op1 + B + op2 + C + op3 + D + "=7")
        exit()

Measured memory_bytes: 3060
import sys

stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

a = rri()
b = rri()
c = rri()
d = rri()
e = rri()
k = rri()

lst = [a,b,c,d,e]
while True:
    for i, ant in enumerate(lst[:4]):
        for j, ant2 in enumerate(lst[i:]):
            if ant2 - ant > k:
                print(':(')
                quit()

    print('Yay!')
    quit()

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

int main() {

	long long x;
	cin >> x;

	if (x < 7)
		cout << "1" << endl;
	else if (x < 12)
		cout << "2" << endl;
	else
	{

		long long ans = (x / 11) * 2;
		int r = 0;
		if (x - (x / 11) * 11 == 0)
			;
		else if (x - (x / 11) * 11 < 7)
			r = 1;
		else
			r = 2;
		cout << ans + r << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
a = [int(i) for i in input().split()] 
s = stdin.readline().rstrip()
if s.find('-') != a[0]:
 ans = 'No'
else:
  if s.rfind('-') != a[0]:
   ans = 'No'
  else:
   ans = 'Yes'
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>

std::vector<int> findChar(const std::string &str, const char search_c){
	std::vector<int> res;
	for(int pos=0;pos=str.find(search_c, pos), pos!=std::string::npos;){
		res.push_back(pos);
		pos++;
	}
	return res;
}

bool create(const std::string &name, const std::string &plate){
	std::vector<int> first_p = findChar(plate, name[0]), second_p = findChar(plate, name[1]);

	for(int i=0;i<first_p.size();i++){
		for(int j=0;j<second_p.size();j++){
			int padding = second_p[j] - first_p[i];
			if(padding < 0)continue;
			
			if([&](){
					for(int k=2;k<name.size();k++){
						int pos = first_p[i] + padding * k;
						if(pos >= plate.size() || plate[pos] != name[k])return false;
					}
					return true;
				}())
			{
				return true;
			}
		}
	}
	
	return false;
}

int main(){
	int n;
	std::string name, plate;
	std::cin >> n;
	std::cin >> name;

	int result = 0;
	for(int i=0;i<n;i++){
		std::cin >> plate;
		if(create(name, plate)){
			result++;
		}
	}
	std::cout << result << std::endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}

int main()
{
    string s , t;
    cin >> s >> t;
    vector < vector<int> > mat(s.size() + 1 , vector<int>(t.size() +1 , 0));
    for(int i = 1; i <= s.size() ; i++){
        for(int j = 1 ; j <= t.size() ; j++){
            if(s[i-1] == t[j-1]) mat[i][j] = mat[i-1][j-1] +1;
            else mat[i][j] = max(mat[i][j-1] , mat[i-1][j]);
        }
    }
    string ans = "";
    int i = s.size() , j = t.size();
    while(i != 0 && j != 0){
        if(s[i-1] == t[j-1]) {ans = s[i-1] + ans; i--;j--;}
        else if(mat[i][j] == mat[i][j-1]) j--;
        else i--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int a[10050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int sum = 0;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            sum += a[i];
        }
        int ans = 0;
        for(int i = 1; i <= n; i++) {
            if(a[i] * n <= sum) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define MAX 10000007
vector<lli>spf(MAX);
void SPF()
{
	lli i,j;
	for(i=0;i<MAX;i++){
		spf[i]=i;
	}
	for(i=2;i<MAX;i++){
		if(spf[i]==i){
			for(j=i+i;j<MAX;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
}
lli fac(lli n){
	map<lli,lli>ma;
	while(n>1){
		ma[spf[n]]++;
		n/=spf[n];
	}
	if(n!=1){
		ma[n]++;
	}
	map<lli,lli>::iterator it;
	lli c=1,b;
	for(it=ma.begin();it!=ma.end();it++){
		b=it->second;
		c=c*(b+1);
	}
	return c;
}
int main()
{
	SPF();
	lli n,i,t=0,a,ans=0;
	cin >> n;
	for(i=1;i<=n;i++){
		a=fac(i);
		a=a*i;
		ans+=a;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 81208
#include<bits/stdc++.h>
using namespace std;
long long a[4];
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 cin>>a[0]>>a[1]>>a[2];
 sort(a,a+3);
 cout<<a[0]+a[1];
 return 0;
}


Measured memory_bytes: 256