akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    string S, T;
    cin >> S >> T;
    int size = S.size();
    bool flag = true;
    for (int i = 0; i < size; i++) {
        if (S[i] != T[i]) {
            flag = false;
            break;
        }
    }
    if (T.size() - 1 != size) {
        flag = false;
    }
    if (flag) {
        printf("Yes\n");

    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		
		for (int i = 0; i < n; i++) {
			s.nextInt();
		}
		
		int num = (n - 1) / (k - 1);
		if ((n - 1) % (k - 1) != 0) {
			num++;
		}
		System.out.println(num);
	}

}


Measured memory_bytes: 48944
#include<cstdio>
#include<algorithm>
using namespace std;
int a[4],x,ans;
int main()
{
	scanf("%d %d %d",&a[1],&a[2],&a[3]);
	scanf("%d",&x);
	for(int i=0;i<=a[1];i++)
		for(int j=0;j<=a[2];j++)
		{
			int k=(x-500*i-100*j)/50;
			if((x-500*i-100*j)%50==0&&(k<=a[3]&&k>=0))
				ans++;
		}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#include <atcoder/all>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string s = "";
    REP(i, 0, N) {
        s += "ACL";
    }
    cout << s << endl;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s, t;
    cin >> s >> t;
    for(int i=0; i<s.size(); i++){
        s[i] -= 'a';
    }
    for(int j=0; j<t.size(); j++){
        t[j] -= 'a';
    }
    
    // あるかどうか
    vector<vector<int>> where(26, vector<int>());

    for(int i=0; i<s.size(); i++){
        where[s[i]].push_back(i);
    }
    

    // あるかどうか
    for(int i=0; i<t.size(); i++){
        if(where[t[i]].size() == 0){
            cout << -1 << endl;
            return 0;
        }
    }


    // 最小
    int ans = -1;
    for(int i=0; i<t.size(); i++){
        auto itr = lower_bound(begin(where[t[i]]), end(where[t[i]]), (ans+1) % s.size());
        int idx = distance(begin(where[t[i]]), itr);
        if(idx == where[t[i]].size()){
            idx = 0;
            ans += s.size();
        }
        ans += where[t[i]][idx] - (ans+1) % s.size() + 1;
        // ans += last[t[i]][(ans+1) % s.size()] - (ans+1) % s.size() + 1;
    }

    cout << ans + 1 << endl;

    return 0;

}

Measured memory_bytes: 4660
n=int(input())
alist=[int(input()) for i in range(n)]
max_value=max(alist)
acount=alist.count(max_value)
if acount!=1:
	for i in range(n):
		print(max_value)
else:
	for i in range(n):
		if alist[i]!=max_value:
			print(max_value)
		else:
			blist=alist[:]
			del blist[i]
			print(max(blist))


Measured memory_bytes: 14076
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char **argv) {
  int i;
  int maxtime = 0, T;
  int ans = 0;

  for (int i = 0; i < 3; i++) {
    cin >> T;
    ans += T;
    maxtime = max(maxtime, T);
  }
  ans -= maxtime;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
// like a tree 
//when there is a tree their is dfs or bfs 
// 2^n-1 strings
int n;

void dfs(string s, char mx){
	if((int)s.size() == n) {
		cout<<s<<"\n";
		return;
	}
	for(char c = 'a'; c <= mx + 1 ; c++) {
		string t = s;
		t += c;
		dfs(t,max(mx,c));
	}
}

void test_case(){
	cin >> n;
	dfs("",'a'-1);
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3584
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h>
using namespace std;
int main(void){
   int N;
   cin >> N;
   int M;
   M = N;
   int count = 0;
   while(N > 0){
       count += N % 10;
       N /= 10;
   }
   if(M % count == 0){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
}


Measured memory_bytes: 256
/*
*	author:		richardjcy
*	created:	2020/09/26/08:40.30
*/

#include <bits/stdc++.h>
using namespace std;

struct DisjointSets
{
    vector<int> parent;
    vector<int> rank;
    int n;

    DisjointSets(int n)
    {
        this->n = n;
        parent.resize(n + 1);
        rank.resize(n + 1);

        for (int i = 0; i <= n; i++)
        {
            rank[i] = 0;
            parent[i] = i;
        }
    }

    int fi(int u)
    {
        if (u != parent[u])
        {
            parent[u] = fi(parent[u]);
        }
        return parent[u];
    }

    void uni(int x, int y)
    {
        x = fi(x), y =fi(y);
        if (rank[x] > rank[y])
        {
            parent[y] = x;
        }
        else parent[x] = y;

        if (rank[x] == rank[y]) ++rank[y];
    }
};

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

    int n, m;
    cin >> n >> m;
    DisjointSets dj(n);
    for (int i = 0; i < m; i++)
    {
        int x, y, w;
        cin >> x >> y >> w;
        --x; --y;
        int u = dj.fi(x);
        int v = dj.fi(y);
        if (u != v)
        {
            dj.uni(u, v);
        }
    }
    unordered_set<int> st;
    for (int i = 0; i < n; i++)
    {
        st.insert(dj.fi(i));
    }
    cout << (int)st.size() << endl;
    return 0;
}

Measured memory_bytes: 8048
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n,k;string s;
	cin>>n>>k>>s;
	s[k-1]+='a'-'A';
	dump(s);
}





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

cnt = 0
ans = -1

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

#print(h)
print(ans)


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m; cin >> n >> m;
  set<int> bad;
  rep(i, m) {
    int x; cin >> x;
    bad.insert(x);
  }
  vector<mint> dp(n+1, 0);
  dp[0] = 1;
  if(bad.find(1) == bad.end()) dp[1] = 1;
  for(int i = 2; i <= n; ++i) {
    if(bad.find(i) != bad.end()) continue;

    dp[i] = dp[i-1]+dp[i-2];
  }
  cout << dp[n].x << endl;
}


Measured memory_bytes: 8624
h, w = map(int, input().split())

m = list()
mv = list()
mh = list()

for i in range(h):
    mh.append([0] * w)
for i in range(h):
    mv.append([0] * w)

for i in range(h):
    m.append(input())

for i in range(h):
    c = 0
    for j in range(w):
        if m[i][j] == "#":
            mh[i][j] = 0
            for k in range(c):
                mh[i][j - k - 1] = c
            c = 0
        else:
            c += 1
    for k in range(c):
        mh[i][w - 1 - k] = c

for i in range(w):
    c = 0
    for j in range(h):
        if m[j][i] == "#":
            mv[j][i] = 0
            for k in range(c):
                mv[j - k - 1][i] = c
            c = 0
        else:
            c += 1
    for k in range(c):
        mv[h - 1 - k][i] = c

res = 0
for i in range (h):
    for j in range(w):
        res = max(res, mv[i][j] + mh[i][j])
print(res - 1)


Measured memory_bytes: 123740
n, k = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

cnt = [0 for _ in range(100)]
max_a = A[0]
k += 1
index_k = 0
index_a = 0

for i in range(100):
    tmp = 2 ** i

    if tmp > max_a:
        index_a = i - 1
        break

    for a in A:
        if a < tmp:
            break
        if (a >> i) & 1:
            cnt[i] += 1

for i in range(100):
    tmp = 2 ** i

    if tmp > k:
        index_k = i - 1
        break

best = [0, ]

for i, c in enumerate(cnt[: index_k + 1]):

    best.append(best[-1] + max(c, n - c) * 2 ** i)

initial = 0

if index_a > index_k:

    initial = sum(map(lambda x: 2 ** x[0] * x[1],
                      enumerate(cnt[index_k + 1 : index_a + 1], index_k + 1)))
                    

equal = [initial, ]

for i, c in enumerate(cnt[index_k::-1]):

    if k >> (index_k - i) & 1:
        equal.append(equal[-1] + (n - c) * 2 ** (index_k - i))
    else:
        equal.append(equal[-1] + c * 2 ** (index_k - i))

ans = 0

for i in range(index_k + 1):

    if (k >> i) & 1:
        ans = max(ans, best[i] + cnt[i] * 2 ** i + equal[-(i + 2)])

print(ans)


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

int main(){
   int N, M;
   cin >> N >> M;
   vector<int> H(N);
   for (int i=0; i<N; i++){
      cin >> H.at(i);
   }

   map<int, vector<int>> AB;
   vector<int> v;
   for (int i=0; i<M; i++){
      int key, val;
      cin >> key >> val;
      AB[key].push_back(val);
      AB[val].push_back(key);
   }
   int cnt = 0;
   for (auto x: AB){
      int key = x.first;
      for (int s: x.second){
         if (H.at(key-1) <= H.at(s-1)){
            cnt++;
            break;
         }
      }
   }
   cout << N-cnt << endl;
}



Measured memory_bytes: 13264
#include <iostream>

using namespace std;

int main()
{
    int no_of_operations, A, B;
    cin >> no_of_operations >> A >> B;

    long long max_biscuits = 0;

    if(B <= A + 2)
    {
        max_biscuits = no_of_operations + 1;
    }
    else if(B > A)
    {
        if(no_of_operations <= A)
        {
            max_biscuits = no_of_operations + 1;
        }
        else
        {
            max_biscuits = B;
            no_of_operations -= (A + 1);

            int no_of_cycles = no_of_operations/2;
            long long gain = B - A;

            max_biscuits += no_of_cycles*gain;

            no_of_operations %= 2;

            while(no_of_operations > 0)
            {
                max_biscuits++;

                no_of_operations--;
            }
        }
    }

    cout << max_biscuits;
    return 0;
}


Measured memory_bytes: 256
/*    *** Bismillahir Rahmanir Rahim***
          *A S M Masud Parvez*
             *18ICTCSE035*
           *SHIICT(BSMRSTU)*
*/
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        nl "\n"
#define        End return 0
#define        gt greater<int>()
#define        ll long long int
#define        mp make_pair
#define        pb push_back
#define        mod 1000000007
#define        ull unsigned long long int
int            Max = INT_MIN;
int            Min = INT_MAX;
#define        pi acos(-1)
int i,j,f=0,x,y,z,S=0,len,n,m,r;
bool isprime(int n)
{
  if(n<2)return false;
  if(n<4)return true;
  if(n%2==0)return false;
  for(i=3;i*i<=n;i++)
  {
    if(n%i==0)
    return false;
  }
  return true;
}
int main()
{
MP;

cin>>n;
set<string>se;
while(n--)
{string s;
  cin>>s;
  se.insert(s);
}
cout<<se.size();

End;   
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int tab[10];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    for (int i = 1 ; i <= 5 ; i++)
    {
        int ta;
        cin >> ta;
        if (ta == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
typedef long long ll;
ll mod_pow(ll x,ll n,ll p)
{
	ll res = 1;
	while(n>0){
		if (n & 1) res = res*x  % p;
		x = x * x % p;
		n = n >> 1;
	}
	return res;
}
 
ll C(int n,int a)
{
    ll c1 = 1,c2 = 1;
    for (int i = 1;i<=a;i++)
    {
        c1 = (c1 * (n - i + 1)) % mod;
        c2 = c2 * i % mod;
    }
    return c1 * mod_pow(c2,mod-2,mod) % mod;
}
 
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    ll ans = (mod_pow(2,n,mod) - 1 + mod) % mod;
    ans = (ans - C(n,a) + mod) % mod;
    ans = (ans - C(n,b) + mod) % mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int dig=10;
vector<vector<int>> dp(dig,vector<int>(12,0));

int main(){
    int K;
    cin >> K;
    
    queue<ll> v;
    int cnt=0;
    ll ans=0;
    rep2(i,1,10){
        v.push(i);
        cnt++;
        if(cnt==K) ans=i;
    }
    while(ans==0){
        ll val = v.front();
        v.pop();
        int n=val%10;
        if(val%10!=0){
            v.push(val*10+(n-1));
            cnt++;
            if(cnt==K) ans=val*10+(n-1);
        }

        v.push(val*10+n);
        cnt++;
        if(cnt==K) ans=val*10+n;

        if(val%10!=9){
            v.push(val*10+(n+1));
            cnt++;
            if(cnt==K) ans=val*10+(n+1);
        }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 768
# Vol0004.
import sys

def main():
    data = []
    lines = sys.stdin.readlines()

    for line in lines:
        data.append(line.split())  # スペース区切りで放り込む
    # ax + by = c, dx + ey = fの解は、
    # x = (ce - bf) / (ae - bd), y = (af - cd) / (ae - bd).
    # これをround(float, 3)すれば答えが出る。
    N = len(data)
    for i in range(N):
        for k in range(6):
            data[i][k] = int(data[i][k])
        det = data[i][0] * data[i][4] - data[i][1] * data[i][3]
        gx = data[i][2] * data[i][4] - data[i][1] * data[i][5]
        gy = data[i][0] * data[i][5] - data[i][2] * data[i][3]
        if det < 0:
            det = -det;
            if gx != 0: gx = -gx
            if gy != 0: gy = -gy
        print("{0:.3f}".format(gx / det) + " " + "{0:.3f}".format(gy / det))

if __name__ == "__main__":
    main()

# 補足、0.1とか0.22でも3桁目まで表示しないとWrongになる。
# 表示するにはprint("{0:.nf}".format(数))ってやる(nのところは桁数)。
# さらに、0を負の数で割ると表示が-0.000になってしまうのでそこの処理も重要。


Measured memory_bytes: 5616
h, w = list(int(i) for i in input().split())
s = [list(input()) for _ in range(h)]

f = True
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def is_exits(row, col):

    for i in range(len(dx)):
        n_row = dy[i] + row
        n_col = dx[i] + col
        if (n_row >= 0 and n_row <= h-1) and (n_col >= 0 and n_col <= w-1):
            if s[n_row][n_col] == "#":

                return True
        else:
            continue
    return False


for row in range(h):
    # print(s[row])
    for col in range(w):

        if s[row][col] == "#":
            if is_exits(row, col):
                continue
            else:
                f = False
                break


if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b;
    char op;
    
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        
        if(op=='?') break;
        
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}



Measured memory_bytes: 2048
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	static final long MOD = (long)(1e9 + 7);
	
	void solve() {
		int H = sc.nextInt()-1;
		int W = sc.nextInt()-1;
		int A = sc.nextInt()-1;
		int B = sc.nextInt()-1;
		long ans = f(H, W);
		for (int a = 0; a <= A; a++) {
			long k = f(a, W - B - 1) * f(B, H - a) % MOD;
			ans = (ans - k + MOD) % MOD;
		}
		out.println(ans);
		
	}
	
	static final long[] fact = new long[1000000 + 10];
	static final long[] fact_inv = new long[1000000 + 10];
	static {
	    long[] inv = new long[1000000 + 10];
	    inv[1] = fact[0] = fact_inv[0] = 1;
	    for (int i = 2; i < inv.length; i++) inv[i] = inv[(int)(MOD % i)] * (MOD - MOD / i) % MOD;
	    for (int i = 1; i < fact.length; i++) fact[i] = (fact[i-1] * i) % MOD;
	    for (int i = 1; i < fact_inv.length; i++) fact_inv[i] = (fact_inv[i-1] * inv[i]) % MOD;
	}
	long f(long A, long B) {
		long res = fact[(int)(A + B)];
		res = (res * fact_inv[(int)(A)]) % MOD;
		res = (res * fact_inv[(int)(B)]) % MOD;
		return res;
	}
	long C(long n, long k) {
	    if ( n < 0 || k < 0 || n < k) return 0;
	    return fact[(int)n] * fact_inv[(int)(n - k)] % MOD * fact_inv[(int)k] % MOD;
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 32084
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;


int main(){
	string s, t;
	int i;
	int l;
	cin >> s;
	cin >> t;
	string s_(s);
	l = (int)s.size();
	for(i=0;i<l&&s_!=t;i++){
		if(i!=l)s_ = s.substr(i+1, s.size()-i) + s.substr(0, i+1);
	}
	if(i == l) cout << "No" << endl;
	else cout << "Yes" << endl;
		
	
	return 0;
}


Measured memory_bytes: 256
/////////////////////////tmw_orz tmw_is_god worship_tmw _/\_////////////////////////////
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result%mod*x%mod)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

string s,t;
vector<ll> v[300];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s >> t;
	for(ll i=0; i<s.size(); i++){
		v[s[i]].push_back(i);
	}
	ll cur=-1;
	ll ans=0;
	for(auto c: t){
		if(v[c].empty()){
			cout << -1;
			return 0;
		}
		auto it=upper_bound(all(v[c]),cur);
		if(it==v[c].end()){
			ans++;
			it=v[c].begin();
		}
		cur=*it;
	}
	cout << s.size()*ans+cur+1;
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int n,p[20],sum=0;
    cin >> n;
    rep(i,n) cin >> p[i];

    for(int i=1;i<n-1;i++){
        if(p[i]<p[i+1]&&p[i]>p[i-1]) sum += 1;
        else if(p[i]>p[i+1]&&p[i]<p[i-1]) sum += 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
w = list(input())
t = w.copy()
t = set(t)
t = list(t)

flg = True

for i in range(len(t)):
    if w.count(t[i]) % 2 == 0:
        pass
    else:
        flg = False
        break

if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right

N,M=map(int, sys.stdin.readline().split())
P=[ [] for _ in range(N+1) ]  #Prefecture 県
Q=[]    #クエリー

for _ in range(M):
    p,y=map(int, sys.stdin.readline().split())
    P[p].append(y)
    Q.append((p,y))

for i in range(1,N+1):
    P[i].sort()

for p,y in Q:
    print str(p).zfill(6)+str(bisect_left(P[p],y)+1).zfill(6)

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

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

const long long INF = 1LL << 60;

typedef long long ll;

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

int main(){
    int n ;
    cin >> n ;
    vector<ll> money;
    money.push_back(1);
    ll i = 1;
    while(true){
        i *= 6;
        if ( i > n) break;
        money.push_back(i);
    }
    i = 1;
    while(true){
        i *= 9;
        if ( i > n) break;
        money.push_back(i);
    }
    sort(money.begin(),money.end(),greater<ll>());
    ll dp[1000100];
    rep(i,1000100) dp[i] = INF;
    dp[0] = 0;
    rep(add, money.size()){
        rep(i,n){
            if ( i + money[add] < n );
            chmin(dp[i+money[add]],ll(dp[i]+1));
        }
    }
    cout << dp[n] << endl;

    return 0;
}


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

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

	vector<int> a(n);
	for (int i=0;i<n;++i)
	{
		cin >> a[i];
	}

	sort(a.begin(),a.end());
	int64_t sum=0;
	int pos=a.size()-1;
	int count2=1;
	for (int i=2;i<=n;++i)
	{
		sum+=a[pos];
		if (++count2>=2)
		{
			--pos;
			count2=0;
		}
	}
	cout << sum << endl;

}




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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)

typedef long long ll;

using namespace std;

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

    int m, d;
    cin >> m >> d;

    int count = 0;
    REP(int, m_, 1, m+1) {
        REP(int, d_, 1, d+1) {
            int d_1 = d_ % 10;
            int d_10 = d_ / 10;
            if(d_1<2 || d_10<2) continue;
            if(d_1*d_10 == m_) {
                if(DEBUG) cout << m_ << "," << d_ << endl;
                count ++;
            }
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
s = int(input())
data = []
data.append(0)
data.append(s)
i = 0
while True:
    i += 1
    if data[i] % 2 == 0:
        data.append(data[i] // 2)
    else:
        data.append((3 * data[i]) + 1)
    if data[i + 1] in data[:i]:
        print(i + 1)
        exit()


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

int solve(int p, int q, int a, int n, int i, int num, double s, int m) {
  if (n < num || a < m)
    return 0;
  if (fabs(p/(double)q - s) < 1e-7)
    return 1;
  if (p/(double)q < s)
    return 0;
  if (a < m * i || a == m || a <= i || n == num)
    return 0;
  return solve(p, q, a, n, i, num+1, s+(1/(double)i), m*i) + solve(p, q, a, n, i+1, num, s, m);
}

int main(void) {
  int p, q, a, n;
  while (cin >> p >> q >> a >> n, p && q && a && n)
    cout << solve(p, q, a, n, 1, 0, 0, 1) << endl;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A,B;
ll i, j;
int main(){
    scanf("%lld%lld",&A,&B);
    ll a=min(A,B);
    ll b = max(A, B);
    fornum(i,0,b){
        printf("%lld", a);
    }
    return 0;
}

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

using namespace std;

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

  int H,W; cin>>H>>W;
  vector<string> map(H);
  for (auto& s : map) cin>>s;

  auto bfs = [&](int s) {
    vector<int> d(H*W, numeric_limits<int>::max());
    queue<pair<int, int>> qs;
    d[s] = 0;
    qs.emplace(s, 0);
    while (not qs.empty()) {
      auto q = qs.front(); qs.pop();
      auto s = q.first;
      auto dist = q.second;
      auto go = [&](int t) {
        if (map[t/W][t%W] == '.' and d[t] > dist+1) {
          d[t] = dist+1;
          qs.emplace(t, dist+1);
        }
      };
      // -1
      if (s % W > 0) {
        go(s-1);
      }
      // 1
      if (s%W != W-1) {
        go(s+1);
      }
      // -W
      if (s/W > 0) {
        go(s-W);
      }
      // W
      if (s/W != H-1) {
        go(s+W);
      }
    }
    auto res = 0;
    for (auto v : d) {
      if (v == numeric_limits<int>::max())
        continue;
      res = max(res, v);
    }
    return res;
  };
  auto ans = 0;
  for (int i = 0; i < H*W; i++) {
    if (map[i/W][i%W] == '#')
      continue;
    ans = max(ans, bfs(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int n,m,a[110],num,ans=1;
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++){
  	num+=a[i];
  	if(num>m)
  	  break;
  	ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
num_li = [0]*n
for i in range(n):
    num_li[i] = (p[i]+1)/2

num = sum(num_li[:k])
ans = num
for j in range(n-k):
    num = num - num_li[j] + num_li[j+k]
    ans = max(num,ans)

print(ans)

Measured memory_bytes: 73224
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int f[N+1];

int longestPath(vector<vector<int>>& adj, int n, int i){
    if(adj[i].empty()){
        f[i] = 0;
        return 0;
    }
    if(f[i] != -1) return f[i];

    int mx = 0;
    for(int j = 0; j < (int)adj[i].size(); j++){
        mx = max(mx,longestPath(adj,n,adj[i][j])+1);
    }
    f[i] = mx;
    return f[i];
}

int main(){
	int n, m, u, v;
	cin >> n >> m;
	
	vector<vector<int>> adj(n);
	memset(f,-1,sizeof f);
	
	for(int i = 0; i < m; i++){
	    cin >> u >> v;
	    adj[v-1].push_back(u-1);
	}
	int pathlength = 0;
	
	for(int i = 0; i < n; i++)
	pathlength = max(pathlength,longestPath(adj,n,i));
	
	cout << pathlength;
}

Measured memory_bytes: 14884
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            int[] n = io.r<int>(' ');
            if ((n[0] == n[1]) && (n[0] == 0)) { break; }
            Array.Sort(n);
            io.w(n[0].ToString() + " " + n[1].ToString());
        }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10492
#include <iostream>
#include <iomanip>
using namespace std;
 
#define MAXN 310
 
typedef long double ld;
 
ld dp[MAXN][MAXN][MAXN];
int N;
int sushi[MAXN];
 
int main() {
	cin >> N;
  	for (int i = 0; i < N; i++) {
      cin >> sushi[i];
    }
  	for (int k = 0; k <= N; k++) {
		for (int j = 0; j <= N; j++) {
          for (int i = 0; i <= N; i++) {
            if (i + j + k <= N) {
              if ((i == 0 && j == 0) && (k == 0)) {
                dp[i][j][k] = (ld)0;
              } else {
                ld temp = (i!=0?(ld)i*dp[i-1][j][k]:0) + (j!=0?(ld)j*dp[i+1][j-1][k]:0) + (k!=0?(ld)k*dp[i][j+1][k-1]:0) + (ld)N;
                dp[i][j][k] = temp/((ld)(i+j+k));
              }
            }
          }
        }
    }
  	int c1 = 0, c2 = 0, c3 = 0;
    for (int i = 0; i < N; i++) {
      if (sushi[i] == 1) {
        c1++;
      } else if (sushi[i] == 2) {
        c2++;
      } else {
        c3++;
      }
    }
  	cout << setprecision(10);
    cout << dp[c1][c2][c3] << endl;
}

Measured memory_bytes: 450688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int t = sc.nextInt();
		sc.close();
		
		if(X < t)
			System.out.println("0");
		else
			System.out.println((X - t));
	}
}


Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
      Scanner in = new Scanner(System.in);
      String S = in.nextLine();
      String T = in.nextLine();
      int lenS = S.length();
      int lenT = T.length();
      int[][] dp = new int[lenS+1][lenT+1];
      for (int i = 1; i <= lenS; i++) {
        for(int j = 1; j <= lenT; j++){
          if(S.charAt(i-1) == T.charAt(j-1))
            dp[i][j] = dp[i-1][j-1] + 1;
          else
            dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
        }
      }
     
      int index = dp[lenS][lenT];
      char[] lcs = new char[index];
      int i = lenS;
      int j = lenT;
      while(i>0 && j>0){
        if(S.charAt(i-1) == T.charAt(j-1)){
          lcs[index-1] = S.charAt(i-1);
          i--;
          j--;
          index--;
        }else if(dp[i-1][j] > dp[i][j-1])
          i--;
        else
          j--;
      }
      for(int k=0;k<lcs.length;k++){
        System.out.print(lcs[k]);
      }
	}
}


Measured memory_bytes: 81100
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define S second
#define MOD 1000000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 100008
#define MAXI 100000000007

signed main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int h, n, hh, c, i;
    cin>>h>>n;
    int a[n+1], b[n+1];
    for(i=1;i<=n;i++){
    	cin>>a[i]>>b[i];
    }
    int dp[20000];
    for(i=0;i<20000;i++){
    	dp[i] = MAXI;
    }
    //dp[0] = 0;
    for(hh=1;hh<=h;hh++){
    	for(c=1;c<=n;c++){
    		if(hh-a[c]<=0){
    			dp[hh] = min(dp[hh], b[c]);
    			continue;
    		}
    		dp[hh] = min(dp[hh-a[c]]+b[c], dp[hh]);
    		//cout<<hh<<" "<<dp[hh]<<endl;
    	}
    }
    //cout<<hh<<" ";
    cout<<dp[h]<<endl;
}

Measured memory_bytes: 384
from itertools import permutations 

n = int(input())
seq1 = tuple((int(x) for x in input().split()))
seq2 = tuple((int(x) for x in input().split()))

a = 0
b = 0
for i, combo in enumerate(permutations(range(1,n+1))):
  if combo == seq1:
    a = i
  if combo == seq2:
    b = i
    
print(abs(a-b))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin>>s;
    vector <int> x(30);
    for(int i=0;i<4;i++){
        x[s[i]-'A']++;
    }
    int ok=0;
    for(int i=0;i<30;i++){
        if(x[i] == 2) ok++;
    }
    if(ok==2)
    cout<<"Yes"<<endl;
    else 
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------




int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    ll ans = 0;
    int r = 0;
    ll sum = 0;
    ll x = 0;
    for(int l=0; l<N; l++){
        while(r < N and sum+A[r] == (x^A[r])){
            sum += A[r];
            x ^= A[r];
            r++;
        }
        ans += r-l;
        sum -= A[l];
        x ^= A[l];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

#define NUM 51

int main(){
	char s[NUM], t[NUM];
	int idx = -1;
	int tsize = 0;
	int i, j;
	scanf("%s\n", s);
	scanf("%s\n", t);
	for(i=0 ; t[i]; i++) tsize++;
	for(i=0 ; s[i + tsize - 1]; i++){
		for(j = 0; t[j]; j++){
			if(s[i+j] != t[j] && s[i+j] != '?') break;
		}
		if(t[j] == '\0') idx = i;
	}
	if(idx == -1) {
		printf("UNRESTORABLE\n");
		return 0;
	}
	j = 0;
	for(i=0; s[i]; i++){
		if(i >= idx && i < idx + tsize) {
			printf("%c", t[j++]);
		} else if(s[i] == '?'){
			printf("a");
		}else {
			printf("%c", s[i]);
		}
	}
	return 0;
}




Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> bs(n - 1);
    for (auto& b : bs)
    {
        cin >> b;
    }
    vector<int> ans(n, 0);
    ans[0] = ans[1] = bs[0];
    for (int i = 1; i < n - 1; i++)
    {
        ans[i] = min(ans[i], bs[i]);
        ans[i + 1] = bs[i];
    }
    int64_t sum = 0;
    for (auto& b : ans)
    {
        sum += b;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  string s,t;
  cin>>s>>t;
  ll x=t.size();
  if(t.substr(0,x-1)==s)
    cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
}

int main()       
{
  fastio
  ll tt=1;
  while(tt--)
    solve();
  return 0;
}

Measured memory_bytes: 3656
import sys,collections
sys.setrecursionlimit(10000)

INF = float("inf")

V,E = map(int,sys.stdin.readline().split())
uvc = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param
#uvc = [[0,1,1],[0,2,3],[1,2,1],[2,3,2]]
G = {i:{} for i in range(V)}
mG = {i:{} for i in range(V)}
for u,v,c in uvc:
    G[u][v] = c
    G[v][u] = 0
    mG[u][v] = 0
    mG[v][u] = 0
#print(G)
def dfs(current,flow):
    #print(current)
    if current == V-1:
        return flow
    visited.add(current)
    if not G[current]:
        return 0
    for nex,nex_c in G[current].items():
        if not nex in visited and nex_c != 0:
            f = dfs(nex,min(flow,nex_c))
            if f != 0:
                #print(current,nex,nex_c,f)
                mG[current][nex] = mG[current][nex] + f
                G[current][nex] = G[current][nex] - f
                G[nex][current] = G[nex][current] + f
                return f
    return 0

visited = set()
while dfs(0,INF) != 0:
    visited = set()
    #print("mG:",mG)
    #print("G:",G)
    pass
print(sum(mG[0].values()))


Measured memory_bytes: 6332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    bool ok=false;
    rep(i,n){
        int a;
        cin>>a;
        if(a%2==1) ok=true;
    }

    if(ok) cout<<"first"<<endl;
    else cout<<"second"<<endl;
}



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

int main() {
  int N,K;
  cin >> N >> K;

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int64_t sum_tmp= 0;
  int64_t sum_max= 0;
  for(int i=0; i<K; i++){
    sum_tmp+= data.at(i);
    sum_max+= data.at(i);
  }
  for(int i=K; i<N; i++){
    sum_tmp+= data.at(i)- data.at(i-K);
    sum_max= max(sum_tmp, sum_max);
  }

  cout << fixed;
  cout << setprecision(6) << 0.5*(K+sum_max) << endl;
}

Measured memory_bytes: 1792
import numpy as np
tmp = str(input())

H = []
for i in range(len(tmp)):
    H.append(int(tmp[i]))

#print(H)
H = np.array(H, int)

#print(H)
x = []
y = []
for i in range(len(H)):
    x.append(i%2)
    y.append((i+1)%2)
#print(H == np.array(x))
#print(H == np.array(y))
a = sum(H == np.array(x))
b = sum(H == np.array(y))

if(a>=b):
    print(len(H)-a)
else:
    print(len(H)-b)

Measured memory_bytes: 18252