akhauriyash/Code-Regression huggingface dataset:
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	int N;
	cin >> N;
	char S[N];
	for (int i = 0; i < N; ++i) cin >> S[i];
 
	// 解法
	string ans = "Three";
	
	for (int i = 0; i < N; ++i){
		if (S[i]=='Y'){
			ans = "Four";
			break;
		}
	}
	//出力
	cout << ans << endl;
}
 


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

using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    int n;
    string s;
    while(cin>>n>>s)
    {
        int l=s.length();
        int ans=0,t=0;
        for(int i=0;i<l;i++)
        {
            if(s[i]=='D')
                t--;
            else
                t++;
            ans=max(ans,t);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static bool Calc(int a, int b) {
        return new[] { a, b, a + b }.Where(e => e % 3 == 0).Any();
    }

    static void Main() {
        var ab = ReadInts();
        int a = ab[0], b = ab[1];
        Console.WriteLine(Calc(a, b) ? "Possible" : "Impossible");
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>

int main(void)
{
    int N;
    std::cin >> N;
    std::string ans;

    if (N == 0)
        ans = "0";

    while (N != 0)
    {
        ans = std::to_string(N % 2 != 0) + ans;
        if (N > 0)
        {
            N = - (N - N%2) / 2;
        }
        else
        {
            N = - (N + N%2) / 2;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;



bool solve(){
	vector<int> a(1);
	int n;
	cin>> a[0]>> n;
	if(a[0]==0 && n==0) return false;
	
	int ans1 = 0 , ans2 = 0, ans3 = 0;
	while(ans3 == 0){
		int a_crr = a[a.size()-1];
		vector<int> b;
		for(int i=0;i<n;i++){
			b.push_back(a_crr % 10);
			a_crr /= 10;
		}
		sort(b.begin(), b.end());
		int l=0, h=0;
		int k = 1;
		for(int i=0;i<n;i++){
			h += b[i] * k;
			l += b[n-1-i] * k;
			k *= 10;
		}
		int a_nex = h - l;
		for(int i=0;i<a.size();i++){
			if(a[i] == a_nex){
				ans1 = i;
				ans2 = a_nex;
				ans3 = a.size() - i;
			}
		}
		a.push_back(a_nex);
	}
	
	cout<< ans1<<" "<< ans2<<" "<< ans3<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n; cin >> n;
	vector<vi> a(n, vi(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	vi dp(1 << n);
	
	dp[(1 << n) - 1] = 1;
	/*
	rep(k, n) rep(i, 1 << n) if(dp[i]) rep(j, n) if((i >> j & 1) && a[k][j]){
		dp[i ^ 1 << j] += dp[i];
		if(dp[i ^ 1 << j] >= mod) dp[i ^ 1 << j] -= mod;
	}
	*/
	for(int i = (1 << n) - 1; i >= 0; i--) rep(j, n) if(i >> j & 1){
		int k = n - __builtin_popcount(i);
		if(!a[k][j]) continue;
		
		dp[i ^ 1 << j] += dp[i];
		if(dp[i ^ 1 << j] >= mod) dp[i ^ 1 << j] -= mod;
	}
	cout << dp[0] << endl;
	
	return 0;
}

Measured memory_bytes: 8448
a, b = $<.map(&:chomp).drop(1).map(&:split)
c = a.zip(b).map{|e|e.map(&:to_f).reduce(:-).abs}
1.upto(3){|i|p c.map{|e|e ** i}.reduce(:+) ** (1.0 / i)}
p c.max

Measured memory_bytes: 8852
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
string s;
int ansn;
int main(){
	cin>>s;
	for (int i=0;i<s.length();i++)if (s[i]=='o') ansn++;
	ansn+=15-s.length();
	if (ansn>7)puts("YES");else puts("NO");
	return 0;
}

Measured memory_bytes: 256
(defun strings-with-the-same-length ()
  (let ((n (read))
        (str (read-line))
        (x))
    (setf x (search " "  str))
    (dotimes (i n)
      (princ (subseq str i (1+ i)))
      (princ (subseq str (+ x 1 i) (+ 2 x i))))
    (terpri)))
  
(strings-with-the-same-length)

Measured memory_bytes: 11752
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, c, k, t[110000];

ll func(ll x, ll y){
    if (x == n) {
        return 0;
    } else if (y - x + 1 > c || t[y] - t[x] > k || y == n) {
        return func(y, y) + 1;
    } else {
        return func(x, y + 1);
    }
}

int main(void){
    // Your code here!
    cin >> n >> c >> k;
    for (ll i = 0; i < n; i++) cin >> t[i];
    sort(t, t + n);
    cout << func(0, 0) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;

struct edge {
    int to, cost;
};
using Graph = vector<vector<edge>>;
Graph G;
bool ok = true;

bool visit[200001];
int dist[100005];

void dfs(int v, int d){
    visit[v] = true;
    dist[v] = d;
    for(auto e: G[v]){
        if(!visit[e.to]) dfs(e.to, d + e.cost);
        else if(dist[e.to] != d + e.cost) ok = false;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    G.assign(n, vector<edge>());

    rep(i, m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back({r, d});
        G[r].push_back({l, -1*d});
    }

    rep(i, n){
        if(!visit[i] && G[i].size() != 0) dfs(i, 0);
        if(!ok){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 11136
/*
Author : N_o_o_B
Created : April 22 2020 22:24:39 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int a,b,k;
    cin >> a >> b >> k;
    set<int> s;
    rep(i,a,min(a+k-1,b)){
        s.insert(i);
        cout << i << endl;
    }
    rep(i,max(b-k+1,a),b){
        if(s.count(i)==0){
            cout << i << endl;
        }
    }



    time_taken();
    return 0;
}

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

template < typename T > inline void chmax(T &a, T b) { a = max(a, b); }

void solve()
{
    string S, T;
    cin >> S >> T;
    
    vector < vector < int > > dp(S.size() + 1, vector < int >(T.size() + 1, 0));

    for ( int i = 0; i <= S.size(); i++ ) {
        for ( int j = 0; j <= T.size(); j++ ) {
            if ( i < S.size() ) chmax(dp[i + 1][j], dp[i][j]);
            if ( j < T.size() ) chmax(dp[i][j + 1], dp[i][j]);
            if ( i < S.size() && j < T.size() && S[i] == T[j] ) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
        }
    }
    cout << dp[S.size()][T.size()] << endl;
}

int main()
{
    int Q;
    cin >> Q;
    while ( Q-- ) solve();
    return ( 0 );
}



Measured memory_bytes: 6856
import sys
input = sys.stdin.readline
N,M = [int(i) for i in input().split()]
nes = [0] * (N+1)
for i in range(1,N+1) :
    nes[i] = []
for i in range(M) :
    a,b = [int(i) for i in input().split()]
    nes[a].append(b)
    nes[b].append(a)
ans = "IMPOSSIBLE"
for i in nes[1] :
    for j in nes[i] :
        if j == N :
            ans = "POSSIBLE"
            break
print(ans)

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

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int c1 = 0, c2 = 0, c3 = 0;
	for (int i = 0; i < N; i++) {
		int P;
		cin >> P;
		if (P <= A) {
			++c1;
		}
		else if (P <= B) {
			++c2;
		}
		else {
			++c3;
		}
	}
	cout << min(min(c1, c2), c3) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    if (a > b) {
        swap(a, b);
    }
    for (int i = 0; i < n; i++) {
        if (b - a >= -d * i + c * (n - 1 - i) && b - a <= -c * i + d * (n - 1 - i)) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    
    int a_sum, b_sum, sum;   //各桁の和
    int sum_min=9*5*2;
    
    for(int i=1; i<n; i++){
        int a = i;
        int b = n-i;
    
        a_sum = (a/10000) + (a%10000)/1000 + (a%1000)/100 + (a%100)/10 + (a%10)/1;
        b_sum = (b/10000) + (b%10000)/1000 + (b%1000)/100 + (b%100)/10 + (b%10)/1;
        sum = a_sum + b_sum;
        
        if(sum_min>sum){
            sum_min = sum;
        }
    }
    cout<<sum_min<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#include<map>
#include<deque>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)

#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PIPII pair<int, pair<int, int> >
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
int main(){
    int T, D;
    cin >> T >> D;
    double ta, tb;
    cin >> ta >> tb;
    int da, db;
    cin >> da >> db;
    double ans = INF;
    REP(i, D / da + 1){
        REP(j, D / db + 1){
            int va = i * da;
            int vb = j * db;
            if(va + vb > D)continue;
            if(va + vb == 0)continue;
            double d = T - (ta * va + tb * vb) / (va + vb);
            if(d < 0)d = -d;
            ans = min(ans, d);
        }
    }
    printf("%.9f\n", ans);
    return 0;
}



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

int main(){
  string s;
  int cnt = 0;
  cin >> s;
  if( s[0] == '1' ) cnt++;
  if( s[1] == '1' ) cnt++;
  if( s[2] == '1' ) cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
int main()
{
	int number,numberTemp=0;
	scanf("%d",&number);
	int temp = number;
	while(number!=0)
	{
		numberTemp = (numberTemp*10) + number%10;
		number /=10;
	}
	if(temp==numberTemp)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

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

using ul=unsigned long long;
int s[500],t[500],tmp[500][500],S[500],T[500],n,bit=-1,IN;
ul ans[500][500],u[500],v[500];
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

struct P{int va,idx,ve,ne,al;};
bool operator <(const P &a,const P &b){return a.va<b.va;};
priority_queue<P> que;

#define REP(i,n) for(int i=0;i<n;i++)
#define F(va,ne) {\
  if((tmp[i][j]^va)==1&&ne)fin(-1);\
  if(!~tmp[i][j]){\
    ans[i][j]+=((ul)1<<bit)*(tmp[i][j]=va);\
    S[i]++,T[j]++;\
    if(IN){\
      if(S[i]<n)que.push({S[i],i,'S',s[i],1});\
      if(T[j]<n)que.push({T[j],j,'T',t[j],1});\
    }\
  }\
}
void AL(){
  bool KO=1;
  while(KO){
    KO=0;
    REP(i,n){
      if(s[i]&&((u[i]>>bit)&1)){
        bool f=0;
        REP(j,n)f|=tmp[i][j]==1;
        if(f)REP(j,n){KO|=tmp[i][j]<0;F(0,0);}
      }
      if(!s[i]&&!((u[i]>>bit)&1)){
        bool f=0;
        REP(j,n)f|=tmp[i][j]==0;
        if(f)REP(j,n){KO|=tmp[i][j]<0;F(1,0);}
      }
    }
    REP(j,n){
      if(t[j]&&((v[j]>>bit)&1)){
        bool f=0;
        REP(i,n)f|=tmp[i][j]==1;
        if(f)REP(i,n){KO|=tmp[i][j]<0;F(0,0);}
      }
      if(!t[j]&&!((v[j]>>bit)&1)){
        bool f=0;
        REP(i,n)f|=tmp[i][j]==0;
        if(f)REP(i,n){KO|=tmp[i][j]<0;F(1,0);}
      }
    }
  }
}

int main(){
  cin>>n;
  REP(i,n)cin>>s[i];
  REP(i,n)cin>>t[i];
  REP(i,n)cin>>u[i];
  REP(i,n)cin>>v[i];
  while(++bit<64){
    memset(tmp,-1,sizeof(tmp));
    memset(S,0,sizeof(S));
    memset(T,0,sizeof(T));
    IN=0;
    REP(i,n){//s側で確定マス
      if(s[i]&&!((u[i]>>bit)&1))REP(j,n)F(0,1);
      if(!s[i]&&(u[i]>>bit)&1)REP(j,n)F(1,1);
    }
    REP(j,n){//t側で確定マス
      if(t[j]&&!((v[j]>>bit)&1))REP(i,n)F(0,1);
      if(!t[j]&&(v[j]>>bit)&1)REP(i,n)F(1,1);
    }
    REP(i,n){//両側で欲しいものが一致
      REP(j,n){
        if((s[i]&&(u[i]>>bit)&1)&&(t[j]&&(v[j]>>bit)&1))F(1,0);
        if((!s[i]&&!((u[i]>>bit)&1))&&(!t[j]&&!((v[j]>>bit)&1)))F(0,0);
      }
    }
    AL();
    IN=1;
    REP(i,n)if(S[i]<n)que.push({S[i],i,'S',s[i],1});
    REP(j,n)if(T[j]<n)que.push({T[j],j,'T',t[j],1});
    while(que.size()){
      P p=que.top();que.pop();
      if(p.ve=='S'){
        int i=p.idx;
        if(p.va!=S[i])continue;
        REP(j,n){
          if(~tmp[i][j])continue;
          F(p.ne,0);
          p.ne^=p.al;p.al=0;
        }
        AL();
      }
      else{
        int j=p.idx;
        if(p.va!=T[j])continue;
        REP(i,n){
          if(~tmp[i][j])continue;
          F(p.ne,0);
          p.ne^=p.al;p.al=0;
        }
        AL();
      }
    }
  }

  REP(i,n){
    ul A=ans[i][0];
    REP(j,n)
      if(s[i])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=u[i])fin(-1);
  }
  REP(j,n){
    ul A=ans[0][j];
    REP(i,n)
      if(t[j])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=v[j])fin(-1);
  }

  REP(i,n){
    REP(j,n)cout<<ans[i][j]<<" ";cout<<endl;
  }


}


Measured memory_bytes: 18304
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll d, c[30] = {}, s[370][30] = {}, last[30] = {}, ans[370] = {};

int main() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d) {
		rep(j, 26)cin >> s[i][j];
	}
	rep(i, 26)last[i] = -1;
	rep(i, d) {
		ll satisfaction = -1000000, contest = 0;
		rep(j, 26) {
			if (satisfaction < s[i][j] + c[j] * (i - last[j])) {
				satisfaction = s[i][j] + c[j] * (i - last[j]);
				contest = j;
			}
			ans[i] = contest;
			last[contest] = i;
		}
	}
	rep(i, d)cout << ans[i] + 1 << endl;
	return 0;
}

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

int main(){
    int arr[5];

    for(int i=0; i<5; i++){
        cin >> arr[i];
    }

    for(int i=0; i<4; i++){
        for(int j=i+1; j<5; j++){
            if(arr[i]<arr[j]){
                int temp;
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }

    for(int i=0; i<4; i++){
        cout << arr[i] << ' ';
    }
    cout << arr[4] << endl;
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a == 1){
        if(b!=1) cout << "Alice" << endl;
        else cout << "Draw" << endl;
    }
    else if(b == 1){
        if(a!=1) cout << "Bob" << endl;
        else cout << "Draw" << endl;
    }
    else if(a < b){
        cout << "Bob" << endl;
    }
    else if(b < a){
        cout << "Alice" << endl;
    }
    else cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        BigDecimal A_big = new BigDecimal(st.nextToken());
        BigDecimal B_big = new BigDecimal(st.nextToken());

        BigDecimal ans = (A_big.multiply(B_big)).setScale(0, RoundingMode.DOWN);
        // BigDecimal ans_d = (A_big.multiply(B_big));

        pw.println(ans.toPlainString());
        // pw.println(ans_d.toPlainString());
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 33348
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

struct UnionFind{
  private:
    vector<ll> child, tree;
    vector<vector<ll>> list;

  public:
    UnionFind(ll v) { 
      tree.resize(v);
      list.resize(v);
      for(ll i = 0; i < v; i++) {
        tree[i] = i;
        list[i].push_back(i);
      }
    }

    //木の根を求める
    ll root(ll x){
      if(x == tree[x]){
        for(ll i = 0; i < child.size(); i++){
          tree[child[i]] = x;
        }
        child.clear();
        return x;
      } else {
        child.push_back(x);
        return x = root(tree[x]);
      }
    }

    ll size(ll x) { 
      return list[root(x)].size(); 
    }

    vector<ll> nodes(ll no) { 
      return list[root(no)]; 
    }

    bool unit(ll x, ll y){
      x = root(x);
      y = root(y);
      if(x == y){
        return false;
      }
      if(list[x].size() < list[y].size()){
        swap(x, y);
      }
      for(int no : list[y]){
        list[x].emplace_back(no);
      }
      tree[y] = x;
      return true;
    }

    bool isUnit(ll x, ll y) { 
      return root(x) == root(y); 
    }
};


int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(m), b(m);
  vector<int> c(k), d(k);
  
  UnionFind UF(n);

  vector<int> direct(n, 0);

  for(int i=0; i<m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    UF.unit(a[i], b[i]);
    direct[a[i]]++;
    direct[b[i]]++;
  }
  for(int i = 0; i < k; i++){
    cin >> c[i] >> d[i];
    c[i]--;
    d[i]--;
  }

  vector<ll> ans(n, 0);

  for(int i = 0; i < n; i++){
    ans[i] = UF.size(i) - direct[i];
  }

  for(int i = 0; i < k; i++){
    if(UF.isUnit(c[i], d[i])){
      ans[c[i]]--;
      ans[d[i]]--;
    }
  }

  for(int i=0; i<n; i++){
    cout << ans[i] - 1 << " ";
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 11892
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    vector<int> a(3,0);
    for(int i=0; i<3; i++) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[2]-a[0]<<endl;
}


Measured memory_bytes: 384
import * as fs from 'fs';

namespace AtCoder.abc139 {

    export class Program {
        /**
         * in
         * 4 10
         * out
         * 3
         */
        static main(inp: string): void {

            const [a, b]: number[] = inp.split(' ').map(Number);

            if (b === 1) {
                console.log(0);
                return;
            }
            
            let k: number = 0;
            let tap: number = 0;
            k = a;
            tap = 1;
            while (k < b) {
                k += (a - 1);
                tap++;
            }

            console.log(tap);

        }
    }
}

AtCoder.abc139.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int K, N;
long long a[15];

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

  long long b[15];
  long long cost;
  long long ans = 100000000000;

  for(int bit = 0; bit < (1<<N); bit++) {
    int count = 1;
    cost = 0;
    for(int i = 0; i < N; i++) {
      b[i] = a[i];
    }
    long long compare = a[0];

    for(int i = 1; i < N; i++) {
      if(bit & (1<<i)) {
        count++;
        if(a[i] <= compare) {
          b[i] = compare + 1;
          cost += compare + 1 - a[i];
        }
        compare = b[i];
      } else {
        if(a[i] > compare) {
          count++;
          compare = a[i];
        }

      }
    }
    if(count >= K) ans = min(cost, ans);
  }

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    ll a2 = 0;
    ll b2 = 0;
    rep(i, a) { b2 = b2 * 10 + b; }
    rep(i, b) { a2 = a2 * 10 + a; }

    ll ans = b2;
    if (a < b) {
        ans = a2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i)-1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
#ここまで入力
manzoku = 0
for i in range(n):
    manzoku += b[a[i]]
    if i ==0:
        continue
    if a[i] == a[i-1]+1:
        manzoku += c[a[i]-1]
print(manzoku)

Measured memory_bytes: 38256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main{
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		FastScanner sc=new FastScanner();
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		long K=sc.nextLong();
		long ans=Math.min(K, A);
		K-=Math.min(K, A);
		K-=Math.min(K, B);
		ans-=K;
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}


Measured memory_bytes: 32496
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
        int l=sc.nextInt(),r=sc.nextInt(),d=sc.nextInt();
        int count=0;
        for(int i=l;i<=r;i++){
            if(i%d==0)count++;
        }
        
        System.out.print(count);
    }
} 

 


Measured memory_bytes: 35712
n = int(input())
b_i = input().split()
ans = 0
ans += int(b_i[0])
for i in range(1, n-1):
  if int(b_i[i-1]) < int(b_i[i]):
    ans += int(b_i[i-1])
  else:
    ans += int(b_i[i])
ans += int(b_i[n-2])
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
int r, c, i, j, a[102][102] = {{0}};

scanf("%d %d",&r,&c);

for(i = 1; i <= r; i++){
for(j = 1; j <= c; j++){
scanf("%d",&a[i][j]);
}
}

for(i = 1; i <= r; i++){
for(j = 1; j <= c; j++){
a[i][c + 1] += a[i][j];
}
}

for(i = 1; i <= c; i++){
for(j = 1; j <= r; j++){
a[r + 1][i] += a[j][i];
}
}

for(i = 1; i <= r; i++)
a[r + 1][c + 1]  += a[i][c + 1];




for(i = 1; i <= r + 1; i++){
for(j = 1; j <= c + 1; j++){
printf("%d",a[i][j]);
if(j != c + 1)
printf(" ");
}
printf("\n");
}

return 0;
}

Measured memory_bytes: 652
# Sum Difference
from collections import defaultdict
N, X, D = map(int, input().split())
if D < 0:
    X, D = -X, -D

if D == 0:
    Sets = set()
    for i in range(N+1):
        Sets.add(i*X)
    print(len(Sets))
    exit()

# D>0
ans = 0
Mode = defaultdict(list)
for i in range(N+1):
    L = (i*X+D*i*(i-1)//2-i*X % D)//D
    R = (i*X+D*i*(2*N-1-i)//2-i*X % D)//D
    Mode[i*X % D].append((L, 1))
    Mode[i*X % D].append((R+1, -1))
Data = []
for key in Mode.keys():
    Mode[key].sort()
    cnt = 1
    sums = Mode[key][0][0]
    for num, which in Mode[key][1:]:
        Data.append((sums, num, cnt))
        cnt += which
        sums = num
ans = 0
for l, r, v in Data:
    if v > 0:
        ans += r-l
print(ans)

Measured memory_bytes: 100792
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll dp[3001];
int main(){
    ll N,S; cin>>N>>S;
    vec d(N);
    rep(i,N) cin>>d.at(i);
    dp[0]=1;
    //ll ans=0;
    rep(i,N){
        ll x=d.at(i);
        if(x<=S){
            for(ll j=S-x;j>=0;j--){
                ll K=1;
                if(j==S-x) K=(K*(N-i))%MOD;
                if(j==0) K=(K*(i+1))%MOD;
                dp[j+x]=(dp[j]*K+dp[j+x])%MOD;
            }
        }
    }
    
    cout<<dp[S]<<endl;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  string s[N];
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  sort(s, s + N);
  for (int i = 0; i < N; i++) {
    cout << s[i];   
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define input(array) \
	repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	ll n;

	cin >> n;
	ll cnt;
	int tmp = 0;
	int ans = 20;
	for (ll i = 1; i <= sqrt(n); i++) {
		if (n % i) continue;
		cnt = n / i;
		tmp = 0;
		while (cnt != 0LL) {
			tmp++;
			cnt /= 10LL;
		}
		chmin(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;
 
const int Inf = 100000;
const int mod = 1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
 
int n;
char s[25];
 
void Solve()
{
	cin >> s;
	if(s[2] == s[3] and s[4] == s[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}
 
signed main()
{
	Solve();
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, M = map(int, input().split(" "))
	N += 1
	
	DP = [-1 for i in range(N)]
	DP[0] = 1
	DP[1] = 1
	
	for i in range(M):
		tmp = int(input())
		DP[tmp] = 0

	for i in range(2, N):
		if DP[i] == 0:
			continue
		else:
			DP[i] = (DP[i-1] + DP[i-2]) % 1000000007
		
	print(DP[-1])
	
	
if __name__ == "__main__":
	main()


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


int main(){
  int n,x;
  cin>>n>>x;
  vector<int>A(n),B(n+1);
  B[0]=0;
  int cnt=0;
  for(int i=0;i<n;i++){
  cin>>A[i];
  B[i+1]=B[i]+A[i];
  if(B[i+1]<=x) 
  cnt++;
  }
  cout<<cnt+1;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main() {
	int n, d, x;
	int a[110];
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		int j = 0;
		while (j * a[i] + 1 <= d) {
			x++;
			j++;
		}
	}
	cout << x << endl;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  
  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
	"sync"
)

func main() {
	n := SingleInt()
	str := SingleStr()
	strs := strings.Split(str, "")

	r := make([]int, 0, n)
	l := make([]int, 0, n)
	var nw, wc, ec int

	var max int

	for _, v := range strs {
		nw = wc

		if v == "W" {
			wc++
		} else {
			ec++
			max = ec
		}

		if nw != wc {
			l = append(l, wc-1)
		} else {
			l = append(l, wc)
		}

		r = append(r, ec)
	}

	var min int
	var once sync.Once
	for i := 0; i < n; i++ {
		var re int
		re = max - r[i] + l[i]
		once.Do(func() {
			min = re
		})
		if min > re {
			min = re
		}
	}

	fmt.Printf("%#v\n", min)
}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}


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

int main(){
	ll x;
	scanf("%lld", &x);
	ll ans = x/11;
	ans *= 2;
	x %= 11;
	if (x >= 7) ans += 2;
	else if (x != 0) ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K; cin >> N >> K; 
	bool snuke[110] = {}; 
	for(int d = 0; d < K; d++){
		int t; cin >> t; 
		for(int i = 0; i < t; i++){
			int a; cin >> a; snuke[a] = true; 
		}
	}
	int ans = 0; 
	for(int i = 1; i <= N; i++){
		if(!snuke[i]) ans ++; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	static int H, W;
	static char[][] s;

	static boolean check(int i, int j) {
		if(i + 1 < H && s[i + 1][j] == '#') return true;
		if(j + 1 < W  && s[i][j + 1] == '#') return true;
		if(0 <= i - 1 && s[i - 1][j] == '#') return true;
		if(0 <= j - 1&& s[i][j - 1] == '#') return true;

		return false;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		s = new char[H][W];
		for (int i = 0; i < H; i++) {
			s[i] = sc.next().toCharArray();
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if(s[i][j] == '.') continue;
				if(s[i][j] == '#') {
					if(!check(i, j)) {
						System.out.println("No");
						return;
					}
				}
			}
		}

		System.out.println("Yes");
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#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(void){
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int count = 0;
  int i = 0;
  for(int v : vec){
    i++;
    if(v % 2 == 1 && i%2 == 1){
      count++;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
s = [input() for i in range(n)]

r_dict = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for i in s:
    r_dict[i] += 1

for k, v in r_dict.items():
    print(k +' x ' +str(v))

Measured memory_bytes: 16348
#include <iostream>

using namespace std;

int main()
{
	int R;
	cin >> R;

	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}






Measured memory_bytes: 256
#include <cstdio>
int n, m, q, l, r, d[505][505];
int main() {
	int i, j;
	scanf("%d%d%d", &n, &m, &q);
	while(m--) scanf("%d%d", &l, &r), d[l][r]++;
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) d[i][j] += d[i-1][j] + d[i][j-1] - d[i-1][j-1];
	while(q--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", d[r][r] - d[l-1][r] - d[r][l-1] + d[l-1][l-1]);
	}
	return 0;
}

Measured memory_bytes: 1792
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;  

void test_case()
{  
    ll n,i,j;
    cin >> n;
    vector<ll> v(n);
    ll x = 0;
    f(i,0,n)
    {
        cin >> v[i];
        x ^= v[i];
    }
    f(i,0,n)
    {
        cout << (x ^ v[i]) << ' ';
    }

}
 
int32_t main()
{
    IOS(); 
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<vector>
#include<queue>

typedef std::pair<int, int> P;

int main(){

	int n, q;
	std::cin >> n >> q;

	std::vector<int>v(n, 0);

	std::priority_queue<P>que;

	for (int i = 0; i < q; i++){

		int a, b;
		std::cin >> a >> b;
		a--;

		v[a] += b;

		que.push(P(v[a], -a));

		while (!que.empty()){
			P res = que.top();

			if (res.first == v[-res.second]){
				std::cout << -res.second + 1 << " " << res.first << std::endl;
				break;
			}
			que.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 6012
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  cin >> n;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  sort(begin(a), end(a));
  int64 ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int high = a[i] + a[j];
      int low = a[j] - a[i];
      auto left = upper_bound(begin(a) + j + 1, end(a), low);
      auto right = lower_bound(begin(a) + j + 1, end(a), high);
      ans += right - left;
    }
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var H = cin.NextInt();
			var W = cin.NextInt();
			var h = cin.NextInt();
			var w = cin.NextInt();
			var a = new int[H, W];
			var minus = -h*w;
			for (var i = 0; i < H; i++)
			{
				for (var j = 0; j < W; j++)
				{
					a[i, j] = 1;
					if (j%w == 0 && i%h == 0)
					{
						a[i, j] = 1000;
					}
					if ((j + 1)%w == 0 && (i + 1)%h == 0)
					{
						a[i, j] = minus - 999;
					}
				}
			}
			var sum = 0L;
			var sb = new StringBuilder();
			for (var i = 0; i < H; i++)
			{
				if (i > 0)
				{
					sb.AppendLine();
				}
				for (var j = 0; j < W; j++)
				{
					if (j > 0)
					{
						sb.Append(' ');
					}
					sum += a[i, j];
					sb.Append(a[i, j]);
				}
			}
			if (sum <= 0)
			{
				Console.WriteLine("No");
				return;
			}
			Console.WriteLine("Yes");
			var res = sb.ToString();
			Console.WriteLine(res);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
			new Template().Solve();
			Console.ReadLine();
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}

Measured memory_bytes: 25564
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
constexpr long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

vector<long> a[26];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    REP(i,n) a[s[i]-'a'].push_back(i);
    REP(i,n) a[s[i]-'a'].push_back(i + n);
    REP(i,m) {
        if(a[t[i]-'a'].empty()){
            cout << -1 << endl;
            return 0;
        }
    }


    long ans = 0, pos = 0;
    for(int i = 0; i < m; ++i) {
        int idx = t[i]-'a';
        pos = *lower_bound(a[idx].begin(), a[idx].end(), pos) + 1;
        if(pos >= n) {
            ans += n;
            pos -= n;
        }
    }

    cout << ans + pos << endl;

    return 0;
}


Measured memory_bytes: 3780