akhauriyash/Code-Regression huggingface dataset:
#  --*-coding:utf-8-*--

def f(S):
    for i, c in enumerate(S):
        if i%2 == 0:
            if c == 'L':
                return False
        elif c == 'R':
            return False
            
    return True


def main():
    S = input()

    print('Yes' if f(S) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var (
		a int
	)
	fmt.Scan(&a)
	H := make([]int, a)
	for i := 0; i < a; i++ {
		fmt.Scan(&H[i])
	}
	j := 0
	k := 0
	for i := 0; i < a-1; i++ {
		if H[i] >= H[i+1] {
			j++
		} else {
			if k <= j {
				k = j
				j = 0
			}
			j = 0
		}
	}
	if k < j {
		fmt.Println(j)
	} else {
		fmt.Println(k)
	}
}


Measured memory_bytes: 5504
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    List<Integer> list = new ArrayList<>();
    int N = Integer.parseInt(sc.nextLine());
    int[] num = new int[N];
    String[] S = sc.nextLine().split(" ");
    
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(S[i]);
      list.add(num[i]);
    }
    Collections.sort(list);
    int a = list.get(N/2-1);
    int b = list.get(N/2);
    int ans = 0;
    for(int i = 0; i < N; i++){
      ans = num[i] <= a ? b : a;
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 84912
N = int(input())
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)],
            key=lambda x: x[1],
            reverse=True)
CD = sorted([[int(_) for _ in input().split()] for _ in range(N)])
 
count = 0
for i in range(N):
    for j in range(len(AB)):
        if AB[j][0] < CD[i][0] and AB[j][1] < CD[i][1]:
            del AB[j]
            count += 1
            break
print(count)

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

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

ll mypow(ll a, ll b){
  if(b == 0) return 1;
  if(b == 1) return a;
  if(b % 2 == 0){
    ll tmp = mypow(a, b / 2);
    return tmp * tmp;
  }
  return a * mypow(a, b - 1);
}

void Main(){
  string S; cin >> S;
  ll N = S.size();
  vector<ll> A(N);
  ll res = 0;
  rep(i, 0, N) A[i] = S[i] - '0';
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N - i; j++){
      if(i + j != N - 1) res += A[i] * mypow(2, N - 1 - (j + 1)) * mypow(10, j);
      else res += A[i] * mypow(2, N - 1 - j) * mypow(10, j);
    }
  }
  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>

#define ft first
#define sd second

using namespace std;

typedef pair<int,int> P;

map<int, P> mpp;

void preorder(int p)
{
  cout << " " << p;
  if(mpp[p].ft != -1) preorder(mpp[p].ft);
  if(mpp[p].sd != -1) preorder(mpp[p].sd);
}

void inorder(int p)
{
  if(mpp[p].ft != -1) inorder(mpp[p].ft);
  cout << " " << p;
  if(mpp[p].sd != -1) inorder(mpp[p].sd);
}

void postorder(int p)
{
  if(mpp[p].ft != -1) postorder(mpp[p].ft);
  if(mpp[p].sd != -1) postorder(mpp[p].sd);
  cout << " " << p;
}

int rootcheck(vector<int> vec)
{
  bool f;

  for(int i = 0; i < vec.size(); ++i){
    f = false;
    for(map<int, P>::iterator it = mpp.begin(); it != mpp.end() && !f; ++it)
      f = (it->sd.ft == vec[i] || it->sd.sd == vec[i]);
    if(!f) return vec[i];
  }

  return 0;
}

int main()
{
  int n, s, t, u, m;
  vector<int> vec;

  while(cin>>n && n){
    m = -1;
    while(n--){
      cin >> s >> t >> u;
      mpp[s] = P(t, u);
      vec.push_back(s);
    }
    m = rootcheck(vec);

    cout << "Preorder" << endl;
    preorder(m);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(m);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(m);
    cout << endl;

    mpp.clear();
  }

  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace beginner_contest047_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var whn = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();

            List<String> inputs = new List<string>();
            for(Int32 i = 0; i < whn[2]; ++i)
            {
                inputs.Add(Console.ReadLine());
            }

            var xya_list = inputs.Select(x => x.Split(' ').Select(s => Convert.ToInt32(s)).ToArray());
            var xy1 = xya_list.Where(x => x[2] == 1).Select(x => x[0]).ToArray();
            var xy2 = xya_list.Where(x => x[2] == 2).Select(x => x[0]).ToArray();
            var xy3 = xya_list.Where(x => x[2] == 3).Select(x => x[1]).ToArray();
            var xy4 = xya_list.Where(x => x[2] == 4).Select(x => x[1]).ToArray();

            var xy1v = xy1.Any() ? xy1.Max() : 0;
            var xy2v = xy2.Any() ? xy2.Min() : whn[0];
            var xy3v = xy3.Any() ? xy3.Max() : 0;
            var xy4v = xy4.Any() ? xy4.Min() : whn[1];

            var w = Math.Max(0, whn[0] - xy1v - (whn[0] - xy2v));
            var h = Math.Max(0, whn[1] - xy3v - (whn[1] - xy4v));

            Console.WriteLine(w * h);
            return;
        }
    }
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll a[200005];
int main() {
  IOS;
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++) {
    if (a[i] < a[i - 1])
      ans += a[i - 1] - a[i], a[i] = a[i - 1];
  }
  cout << ans << endl;
}


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

using namespace std;
using ll =long long;
using db = double;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	ll n;
	cin >> n;
	ll action[n][3];
	rep(i,n) cin >> action[i][0] >> action[i][1] >> action[i][2];
	ll dp[100100][3];
	rep(i,100100){
		rep(j,3){	 //dp[0]は0日目なので何もしていないから0
			dp[i][j] = 0;
		}
	}
	rep(i,n){
		rep(j,3){
			rep(k,3){
				if(j!=k){
					chmax(dp[i+1][j] , dp[i][k]+action[i][j] );
				}
			}
		}
	}
	ll ans = 0;
	rep(i,3){
		chmax(ans,dp[n][i]);
	}
	cout << ans << endl;


}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    pair<string,ll> a[n];
    string x;
    ll sum = 0;
    for(ll i = 0;i < n;i++){
        cin >> a[i].first >> a[i].second;
        sum += a[i].second;
    }
    cin >> x;
    ll ans = 0;
    for(ll i = 0;i < n;i++){
        ans += a[i].second;
        if(x == a[i].first){
            break;
        }
    }
    ans = sum-ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll MOD = 1000000007LL;
/*メモ XOR問題のまとめ
性質 1「交換則、結合則が成り立つ」
　　 2「a xor a = 0」
　　 3「ある数xのb番目のビットが1である <=> x mod 2^(b+1) ≧ 2^b」
　　 4「0≦aのとき、4a, 4a+1, 4a+2, 4a+3のxor和は0」
方針 
!!!!!1「xor計算は各ビットで独立なので別々に計算」
　　 2「trieを使ったxorの最大最小探索がある解説」
・しゃくとり法は[ｌ,r)で考えるとわかりやすいよ！
*/
int main(){
    int n,u,v;
    std::cin >> n>>u>>v;
    Graph g(n);
    rep(i,n-1){
        int a,b;
        std::cin >> a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
   // std::cout << 123 << std::endl;
    std::vector<int> aoki(n,-1);
    std::queue<int> aq;
    aoki[v-1]=0;
    aq.push(v-1);
    while(!aq.empty()){
        int p=aq.front();
        aq.pop();
        erep(i,g[p]){
            if(aoki[i]!=-1)continue;
            aoki[i]=aoki[p]+1;
            aq.push(i);
        }
    }
    
    std::vector<int> taka(n,-1);
    taka[u-1]=0;
    //std::cout << 123 << std::endl;
    aq.push(u-1);
    while(!aq.empty()){
        int p=aq.front();
        aq.pop();
        erep(i,g[p]){
            if(taka[i]!=-1)continue;
            taka[i]=taka[p]+1;
            aq.push(i);
        }
    }
    int ans=0;
    rep(i,n){
        if(aoki[i]>taka[i])ans=max(ans,aoki[i]);
    }
    std::cout << ans-1 << std::endl;
}

Measured memory_bytes: 6656
/*
	答案不会超过 2 logn
	答案具有单调性, 把答案弄进状态里面就可以 dp 了 
	设 f[i][l][r][step] 表示矩形上边界为 i, 左右边界为 l, r时, 用 step 步往下可以拓展的最长长度 
	设 g[i][l][r][step] 表示矩形左边界为 i, 上下边界为 l, r是, 用 step 步往右可以拓展的最长长度 
	转移分两类考虑, 切横的, 切竖的 
*/
#include <bits/stdc++.h>
#define N 188

using namespace std;

int n, m;
int f[N][N][N], g[N][N][N];
bool ma[N][N];

inline void cmax(int &u, int v) { if(u < v) u = v; }

void pre() {
	for(int j = 1; j <= m; ++j)
		for(int i = n; i >= 1; --i)
			f[i][j][j] = (ma[i][j] == ma[i + 1][j] ? f[i + 1][j][j] : 0) + 1;
	for(int i = 1; i <= n; ++i)
		for(int j = m; j >= 1; --j)
			g[j][i][i] = (ma[i][j] == ma[i][j + 1] ? g[j + 1][i][i] : 0) + 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			for(int k = j + 1; k <= m; ++k)
				f[i][j][k] = min(f[i][j][k - 1], 
				ma[i][k] == ma[i][k - 1] ? f[i][k][k] : 0);
	for(int i = 1; i <= m; ++i)
		for(int j = 1; j <= n; ++j)
			for(int k = j + 1; k <= n; ++k)
				g[i][j][k] = min(g[i][j][k - 1],
				ma[k][i] == ma[k - 1][i] ? g[i][k][k] : 0);
}

int tf[N][N][N], tg[N][N][N];

void trans() {
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			for(int k = j; k <= m; ++k)
				if(i + tf[i][j][k] <= n)
					f[i][j][k] += f[i + f[i][j][k]][j][k];
	for(int i = 1; i <= m; ++i)
		for(int j = 1; j <= n; ++j)
			for(int k = j; k <= n; ++k)
				if(i + g[i][j][k] <= m)
					g[i][j][k] += g[i + g[i][j][k]][j][k];
	
	memcpy(tf, f, sizeof tf);
	memcpy(tg, g, sizeof tg);
	
	for(int i = 1; i <= m; ++i)
		for(int j = 1; j <= n; ++j)
			for(int k = n, r = i - 1; k >= 1; --k)
				while(r < i + tg[i][j][k] - 1) {
					++r;
					cmax(f[j][i][r], k - j + 1);
				}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			for(int k = m, r = i - 1; k >= 1; --k)
				while(r < i + tf[i][j][k] - 1) {
					++r;
					cmax(g[j][i][r], k - j + 1);
				}
}

int main() {
//	freopen("land.in", "r", stdin);
//	freopen("land.out", "w", stdout);
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) {
			char ch = getchar();
			while(ch != '.' && ch != '#') ch = getchar();
			ma[i][j] = (ch == '#');
		}
	
	pre();
	
	int ans = 0;
	while(f[1][1][m] < n) {
		trans();
		++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 103936
import math

a, b, x = map(int, input().split())

s = x / a
if s > a * b / 2:
    h = (a*b - s) * 2 / a
    rad = math.atan2(h, a)
else:
    w = s * 2 / b
    rad = math.atan2(b, w)

print(math.degrees(rad))

Measured memory_bytes: 3060
#include <stdio.h>
#define SIZE 6

int bi1[SIZE], bi2[SIZE];
const int disit[SIZE + 1] = {1, 2, 4, 8, 16, 32, 64};

void de_bi1(int de){
  int i;
  for(i = SIZE-1; i >= 0; i--){
    bi1[i] = de / disit[i];
    de %= disit[i];
  }
  return;
}

void de_bi2(int de){
  int i;
  for(i = SIZE-1; i >= 0; i--){
    bi2[i] = de / disit[i];
    de %= disit[i];
  }
  return;
}

int main(void){
  int row, col, n, sum = 0, ans = 0, i, j, k, l;
  char bw[SIZE][SIZE];
  scanf("%d %d %d", &row, &col, &n);
  
  for(i = 0; i < row; i++){
    for(j = 0; j < col; j++){
      scanf(" %c", &bw[i][j]);
    }
  }
  
  for(i = 0; i < disit[row]; i++){
    de_bi1(i);
    for(j = 0; j < disit[col]; j++){
      de_bi2(j);
      for(k = 0; k < row; k++){
        if(bi1[k] == 1){
          for(l = 0; l < col; l++){
            if(bi2[l] == 1){
              if(bw[k][l] == '#')
                sum++;
            }
          }
        }
      }
      if(sum == n)ans++;
      sum = 0;
    }
  }
  
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    
   string s;
   cin>>s;
   
   for(int i=0;i<3;++i)
   {
       if(s[i]=='1')
          s[i]='9';
          
          else
          s[i]='1';
   }
   cout<<s;
   
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int a, b, c;
        String flag;
        Scanner s = new Scanner(System.in);
        a = s.nextInt();
        b = s.nextInt();
        c = s.nextInt();
        
        if ((a < b) && (b < c)){
            flag = "Yes";
        }else{
            flag = "No";
        }
        System.out.println(flag);
    }
}


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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s.substr(i, 3) == "ABC") ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))
profits = [v - c for v, c in zip(values, costs)]
res = 0
for value, cost in zip(values, costs):
    x = value - cost
    if x > 0:
        res += x
print(res)

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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0; i<n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    int ans=0;
    for (int i=0; i<n-2; i++) {
        for (int k=i+1; k<n-1; k++) {
            if (l[i]>=l[k]+l[k+1])
                continue;
            int mn=l[i]-l[k]+1;
            int ub=n;
            int lb=k+1;
            while (ub-lb>1) {
                int mid=(lb+ub)/2;
                if (l[mid]<mn)
                    ub=mid;
                else
                    lb=mid;
            }
            ans+=lb-k;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(100000)

def ii(): return int(input())
def iis(): return input().split()
def imi(): return map(int,iis())
def iil(): return list(imi())

n, k = imi()
p = iil()
li = [0]
for i in range(n):
    li.append(li[i]+(1+p[i])/2)
ans = 0
for i in range(n-k+1):
    ans = max(ans, li[i+k]-li[i])
print(ans)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const ll MOD = (ll)(1e9 + 7);
struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  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*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // 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;}
};

const int MAX_N = 212345;
int N;
vector<int> g[MAX_N];
vector<int> cs[MAX_N];

int dfs(int cur, int prev) {
  int res = 1;
  for (int next : g[cur]) if (next != prev) {
    int sub = dfs(next, cur);
    res += sub;
    cs[cur].push_back(sub);
  }
  if (res != N) cs[cur].push_back(N - res);
  return res;
}

mint inv2[MAX_N];

int main2() {
  REP(i, MAX_N) g[i].clear();
  REP(i, MAX_N) cs[i].clear();

  N = nextInt();
  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0, -1);
  mint ans = 0;
  REP(i, N) {
    mint val = mint(1) - inv2[N-1];
    for (int j : cs[i]) {
      val -= inv2[N-1-j] * (mint(1) - inv2[j]);
    }
    val /= 2;
    ans += val;
  }
  cout << ans.x << endl;
  return 0;
}

int main() {

  inv2[0] = 1;
  inv2[1] = mint(1) / mint(2);
  for (int i = 2; i < MAX_N; i++) {
    inv2[i] = inv2[i-1] * inv2[1];
  }

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int H,W,K; cin >> H >> W >> K;

    vector<vector<int>> M_origin(H, vector<int>(W));


    int b_count = 0;
    REP(i,H){
        string S; cin >> S;
        REP(j,W){
            if(S[j] == '.'){
                M_origin[i][j] = 0;
            }else if(S[j] == '#'){
                M_origin[i][j] = 1;
                b_count ++;
            }
        }
    }

    

    int ans = 0;

    REP(bit_h,1<<H){
        vector<int> h;
        REP(x,H){
            if(bit_h & 1<<x){
                h.push_back(x);
            }
        }
        REP(bit_w, 1<<W){
            vector<int> w;
            REP(y,W){
                if(bit_w & 1<<y){
                    w.push_back(y);
                }
            }

            //ここに処理
            vector<vector<int>> M(M_origin);
            
            for(auto hh: h){
                REP(j,W){
                    M[hh][j] = 0;
                }
            }
            for(auto ww: w){
                REP(j,H){
                    M[j][ww] = 0;
                }
            }

            int count = 0;
            REP(i,H){
                REP(j,W){
                    if(M[i][j] == 1)count ++;
                }
            }


            if(count == K) {
                ans ++;
                // REP(i,H){
                //     REP(j,W){
                //         cout << M[i][j];
                //     }
                //     cout << endl;
                // }
                // cout << endl;

            }

        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  int k;
  cin>>k;
  vector<string> v;
  REP(i,s.size()) {
    FOR(j,1,k+1) {
      if (i+j > s.size()) continue;
      v.push_back(s.substr(i, j));
    }
  }
  sort(ALL(v));
  unique(ALL(v));
  cout << v[k-1] << endl;
  return 0;
}


Measured memory_bytes: 1660
import math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
p=1
M=10**18
f=0
if 0 in l:
	print(0)
else:	
	for i in range(n):
		p*=l[i]
		if p>M:
			print(-1)
			f=1
			break
	if f==0:
		print(p)




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

const int MOD = 1000000007;
const long long INF = 1LL << 60;

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


// 入力
int N;
long long a[410];
long long b[410];
long long dp[410][410];
bool ischecked[410][410] = {false};

void ruiseki(){
    b[0] = a[0];
    for(int i=1;i<N;++i) b[i] = b[i-1] + a[i];
}

long long sum(int L, int R){
    return b[R] - b[L-1];
}


long long rec(int L, int R){
    if(L==R) return 0;
    if(ischecked[L][R]) return dp[L][R];
    ischecked[L][R] = true;
    long long ret = INF;
    for(int i=L;i<R;++i) chmin(ret,rec(L,i) + rec(i+1,R) + sum(L,R));
    return dp[L][R] = ret;
}

int main() {
    cin >> N;
    for(int i=0;i<N;++i) cin >> a[i];
    ruiseki();


    cout << rec(0,N-1) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll X,Y,A,sum;

ll min(ll a, ll b){
    if(a<b)return a;
    else return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    else return b;
}

ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[1010100], rf[1010100];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    repi(i, 1, 1010100) f[i] = (f[i - 1] * i) % mod;
    repi(i, 0, 1010100) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    init();
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

int main(){
    cin>>X>>Y;
    if((X+Y)%3!=0){
        out(0);
        return 0;
    }
    if(min(X,Y)*2<max(X,Y)){
        out(0);
        return 0;
    }
    sum=(X+Y)/3;
    A=min(X,Y)-sum;
    out(C(sum,A));

    

}


Measured memory_bytes: 16000
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let mut ys = xs.clone();
  ys.sort();
  let mid = ys.len() / 2;
  if ys[mid] == ys[mid-1] {
    for _ in 0..n {
      println!("{}", ys[mid]);
    }
  } else {
    for x in xs {
      if x < ys[mid] {
        println!("{}", ys[mid]);
      } else {
        println!("{}", ys[mid-1]);
      }
    }
  }
}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] S = br.readLine().split("");
        String[] T = br.readLine().split("");

        int count = 0;
        for (int i = 0; i < S.length; i++) {
            if(S[i].equals(T[i])) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=300,MAX_M=300;
const  ll MOD=998244353;
int N,M;
typedef vector<int> vec;
typedef vector<vec> mat;
mat mt;
ll mpw(ll n,ll m){
	ll ret=1;
	while(m){
		if(m&1){
			ret*=n;
			ret%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return ret;
}
int main(){
	cin>>N>>M;
	mt.resize(N);
	REP(i,N){
		mt[i].resize(M);
	}
	REP(i,N){
		REP(j,M){
			cin>>mt[i][j];
		}
	}
	int c=0,i=0;
	while(i<N && c<M){
		int pvt=i;
		FOR(j,i+1,N){
			if(mt[j][c]>mt[pvt][c])pvt=j;
		}
		swap(mt[i],mt[pvt]);
		if(mt[i][c]==0){
			c++;
			continue;
		}
		FOR(j,i+1,N){
			if(mt[j][c]==1){
				FOR(k,c,M){
					mt[j][k]-=mt[i][k];
					mt[j][k]+=2;
					mt[j][k]%=2;
				}
			}
		}
		i++;
	}
	int r=-1;
	REP(i,N)REP(j,M){
		if(mt[i][j]==1)
			r=i;
	}
	r++;
	cout<<mpw(2,N-r)*(mpw(2,r)+MOD-1)%MOD*mpw(2,M-1)%MOD<<endl;
}

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

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;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Pair{
	int a;
	int b;
	int c;
	int d;
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		FastScanner fs = new FastScanner();
		Long A = fs.nextLong();
		Long B = fs.nextLong();
		Long N = fs.nextLong();

		if( N < B) {
			System.out.println((int)(Math.floor((A*N)/B)));
		}else {
			N = B -1;
			System.out.println((int)(Math.floor((A*N)/B)));
		}

	}



}


Measured memory_bytes: 25340
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	REP(i, k){
		if (i % 2 == 0){
			if (a % 2){
				a--;
			}
			b += a/2;
			a /= 2;
		}
		else {
			if (b % 2){
				b--;
			}
			a += b/2;
			b /= 2;
		}
	}

	cout << a << " " << b << endl;

}


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


int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> r(n,vector<int>(n));
    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) r[i][j]=0;
    }
    int a,b;
    for (int i=0;i<m;i++) {
        cin >> a >> b;
        r[a-1][b-1]=1;
        r[b-1][a-1]=1;
    }
    vector<vector<int>> t(n,vector<int>(1<<n));
    t[0][1]=1;
    for (int bit=2;bit<(1<<n);bit++) {
        for (int i=0;i<n;i++) {
            int c=0;
            if (bit & (1<<i)) {
                for (int j=0;j<n;j++) {
                    if (r[i][j]==1 && (bit & (1<<j)) && i!=j) c+=t[j][bit-(1<<i)];
                }
            }
            t[i][bit]=c;
        }    
    }
    ll ans=0;
    for (int i=0;i<n;i++) {
        ans+=t[i][(1<<n)-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():

    w = input()
    d = dict()
    for c in w:
        d[c] = d.get(c, 0) + 1
    for c in d:
        if d[c] % 2 != 0:
            return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    long long n;
    cin >> n;

    vector<vector<long long>> v(10, vector<long long>(10, 0));

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i == j && i <= n) {
                v[i][j]++;
            }

            string t = to_string(i) + to_string(j);

            if (stoll(t) <= n) {
                v[i][j]++;
            }

            for (int k = 0; k < 10; k++) {
                string temp = to_string(i) + to_string(k) + to_string(j);
                if (stoll(temp) <= n) {
                    v[i][j]++;
                } else {
                    break;
                }
            }
            for (int k = 0; k < 100; k++) {
                ostringstream ss;
                ss << setw(2) << setfill('0') << k;

                string temp = to_string(i) + ss.str() + to_string(j);
                if (stoll(temp) <= n) {
                    v[i][j]++;
                } else {
                    break;
                }
            }

            for (int k = 0; k < 1000; k++) {
                ostringstream ss;
                ss << setw(3) << setfill('0') << k;

                string temp = to_string(i) + ss.str() + to_string(j);
                if (stoll(temp) <= n) {
                    v[i][j]++;
                } else {
                    break;
                }
            }
            for (int k = 0; k < 10000; k++) {
                ostringstream ss;
                ss << setw(4) << setfill('0') << k;

                string temp = to_string(i) + ss.str() + to_string(j);
                if (stoll(temp) <= n) {
                    v[i][j]++;
                } else {
                    break;
                }
            }
        }
    }

    long long cnt = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            cnt += v[i][j] * v[j][i];
        }
    }

    cout << cnt << endl;
}

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

int main()
{
	int64_t n;
	string s;
	cin >> n >> s;

	int64_t ans = 0;

	int64_t r = count(s.begin(), s.end(), 'R');
	for (int64_t i = 0; i < r; i++)
	{
		if (s[i] != 'R')
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3736
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素xが属するグループのサイズ（要素数）を返す
    def size(self, x):
        return -self.parents[self.find(x)]

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    # すべての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を返す
    def group_count(self):
        return len(self.roots())

    # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    # print()での表示用 ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int, input().split())
l = []
for i in range(M):
    array = list(map(int, input().split()))
    l.append(array)

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i!=j:
            uf.union(l[j][0]-1,l[j][1]-1)
    if uf.group_count() == 2:
        ans+=1
    
print(ans)

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;

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

  cin >> N;
  vector< int > p(N);
  REP(i, N) {
    CIN(tmp); tmp--;
    p[i] = i - tmp;
  }

  int last = -1;
  int ans = INF;
  int tmp = 0;
  REP(i, N - 1) {
    if (p[i] == 0 && p[i + 1] == 0) {
      tmp++;
      p[i]++;
      p[i + 1]--;
    }
    // debug(i);
    // debug(tmp);
  }

  REP(i, N) {
    if (p[i] == 0) {
      if (last == -1) last = i;
      else {
	tmp += min(i - last, 2);
	last = -1;
      }
    }
    // debug(i);
    // debug(tmp);
  }
  

  if (last != -1) {
    tmp++;
  }

  ans = min(ans, tmp);
  cout << ans << endl;

  /*
  EACH(pi, p)
    debug(pi);
  */
  
  return 0;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  char a;
  cin>>a;
  if(a=='A')
    cout<<"T"<<endl;
  else if(a=='T')
    cout<<"A"<<endl;
  else if(a=='C')
    cout<<"G"<<endl;
  else if(a=='G')
    cout<<"C"<<endl;
}

Measured memory_bytes: 256
#import bisect,collections,copy,heapq,itertools,math,numpy,string
#from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N,M = LI()
H = LI()
AB = [LI() for _ in range(M)]
path = [[] for _ in range(N+1)]
chk = [True] * (N+1)
nice = 0

for ab in AB:
	a = ab[0]
	b = ab[1]
	path[a].append(b)
	path[b].append(a)

for i in range(1,N+1):
	if chk[i]:
		chk[i] = False
		if not path[i]:
			#print(i)
			nice+=1
		else:
			flg = 0
			for j in path[i]:
				if H[i-1] > H[j-1]:
					chk[j] = False
				else:
					flg = 1
			if flg == 0:
				#print(i)
				nice+=1
print(nice)

Measured memory_bytes: 42044
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
bool ok=true;
V<int> d;
V<int> g[200005];
void dfs(int cur,int c){
    d[cur]=c;
    for(int v:g[cur]){
        if(d[v]==c)ok=false;
        if(d[v]==-1){
           dfs(v,c^1);
        }
    }
}
int main(){
    ll n,m;
    cin>>n>>m;
    d.assign(n,-1);
    for(int i=0;i<m;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    dfs(0,0);
    ll cnt=0;
    for(int i=0;i<n;i++)if(d[i])cnt++;
    if(ok)cout<<cnt*(n-cnt)-m<<"\n";
    else cout<<n*(n-1)/2-m<<"\n";
}

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

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

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

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

  ll max_cnt = ceil(log2(k));
  ll bunbo = n;
  rep(i, max_cnt) {
    bunbo *= 2;
  }

  ll bunshi = 0;
  for(int i = 1; i <= n; i++) {
    int val = 1;
    ll cnt = ceil(log2(k/(ld)i));
    ll diff_cnt;
    if (cnt <= 0) {
      diff_cnt = max_cnt;
    } else {
      diff_cnt = max_cnt - cnt;
    } 
    rep(j, diff_cnt) {
      val *= 2;
    }
    // cout << "val: " << val << endl;
    bunshi += val;
  }

  // cout << "bunshi: " << bunshi << endl;
  // cout << "bunbo: " << bunbo << endl;
  ld result = (ld)bunshi / (ld)bunbo;
  cout << std::setprecision(15) << result << endl;

  return 0;
}

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

using   namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define  all(v)       (v).begin(),(v).end()
#define  rall(v)      (v).rbegin(),(v).rend()
#define  pb           push_back  
#define  eb           emplace_back
#define  mp           make_pair
#define  ff           first
#define  ss           second
#define  pf           push_front
#define  bs           binary_search
#define  lb           lower_bound
#define  ub           upper_bound
#define  umap         unordered_map
#define  uset         unordered_set
#define  dec(x)       fixed<<setprecision(x)
#define  lcm(a,b)    (a*b/__gcd(a,b))

typedef  priority_queue<ll>  pq;
typedef  priority_queue<ll,vector<ll>,greater<ll>> pqmn;
typedef  pair<ll,ll> pll;

const    ll inf=LLONG_MAX;
const    ll mod=1e9+7;
const    ld pi=acos(-1);
                    
void solution(){

    ll n;
    cin>>n;
    vector<pll>vp;
    while(n--){
        ll a,b;
        cin>>a>>b;
        vp.pb({a,b});
    }
    for(int i=0;i<vp.size()-2;i++){
        if((vp[i].ff==vp[i].ss)&&(vp[i+1].ff==vp[i+1].ss)&&(vp[i+2].ff==vp[i+2].ss)){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solution();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <functional>


using namespace std;

int main()
{
char a[11];
int i,max=0,count=0,flag=0;

for(i=0;i<11;i++)a[i]='B';

cin>>a;
for(i=0;i<10;i++){
	if((a[i]=='A')||(a[i]=='C')||(a[i]=='G')||(a[i]=='T')){
		if((a[i+1]=='A')||(a[i+1]=='C')||(a[i+1]=='G')||(a[i+1]=='T')){
			count += 1;
		}else{
			count += 1;
			
			if(max<count)max = count;
			count = 0;
		}
	}else{
		count =0;
	}
}
cout<<max<<endl;

}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    // 入力受け取り, 入次数も管理する
string s;
    cin >> s;

if(s.size()%2==1){
int te=s.size()/2;
int res=0;
for(int i=0;i<te;i++){
if(s[i]!=s[s.size()-1-i])res++;
}
cout << res;
}else{
int te=s.size()/2;
int res=0;
for(int i=0;i<te;i++){
if(s[i]!=s[s.size()-1-i])res++;
}
cout << res;


}

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int H=gi();
	    int N=gi();
	    int[] A=new int[N];
	    int s=0;
	    for(int i=0; i<N;i++) {
	    	A[i]=gi();
	    	s+=A[i];
	    }	    
	    
       // System.out.print(sb.toString());

        if (s>=H) {
    	    System.out.print("Yes");
        }else{
    	    System.out.print("No");
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 58352
N=int(input())
if N>=400 and N<=599:
    print(8)
if N>=600 and N<=799:
    print(7)
if N>=800 and N<=999:
    print(6)
if N>=1000 and N<=1199:
    print(5)
if N>=1200 and N<=1399:
    print(4)
if N>=1400 and N<=1599:
    print(3)
if N>=1600 and N<=1799:
    print(2)
if N>=1800 and N<=1999:
    print(1)

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

int main() {
    string s;
    while (getline(cin, s)) {
        if (s == "END OF INPUT") break;
        int count = 0;
        char before;
        string ans;
        for (string::iterator si = s.begin(); si != s.end(); si++) {
            switch (*si) {
                case ' ':
                    if (before == ' ') {
                        ans.push_back(count+'0');
                        count = 0;
                        continue;
                    } else {
                        ans.push_back(count+'0');
                        count = 0;
                    }
                    break;
                default:
                    before = *si;
                    count++;
                    break;
            }
        }
        ans.push_back(count+'0');
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  long long  h,w;
  cin>>h>>w;
  if (h ==1 || w ==1){
    cout << 1 <<endl;
  } else if((h*w)%2== 0){
    cout<<(h*w)/2<<endl;
  }else{
    cout<<((h*w)/2)+1<<endl;
  }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vll L(K+1), R(K+1);

    ll rest = 0, cntk = 0;
    rep(i, N) {
        if(cntk >= K) break;
        if(S[i] == 'o' && rest <= 0) cntk++, L[cntk] = i, rest = C;
        else rest--;
    }

    rest = 0, cntk = 0;
    for(ll i = N-1; i >= 0; i--) {
        if(cntk >= K) break;
        if(S[i] == 'o' && rest <= 0) cntk++, R[K+1-cntk] = i, rest = C;
        else rest--;
    }

    vll ans;
    for(ll i = 1; i <= K; i++) {
        if(L[i] == R[i]) ans.push_back(L[i]+1);
    }

    for(auto x : ans) cout << x << endl;
}


Measured memory_bytes: 6516
#!/usr/bin/env python3
from collections import Counter

n, *d = map(int, open(0).read().split())
c = Counter(d[1:])
c = [(0, 1)] + sorted(c.items())
ans = d[0] == 0
for i in range(1, len(c)):
    if i != c[i][0]:
        ans = 0
        break
    ans *= pow(c[i - 1][1],c[i][1], 998244353)
print(ans%998244353)


Measured memory_bytes: 26248