akhauriyash/Code-Regression huggingface dataset:
import numpy as np
N, M, Q = map(int, input().split())
X = np.zeros((N, N), dtype=int)
ends = np.zeros((M, 2), dtype=int)
queries = np.zeros((Q, 2), dtype=int)
for i in range(M):
    ends[i] = [int(item) for item in input().split()]
for i in range(Q):
    queries[i] = [int(item) for item in input().split()]
np.add.at(X, [ends[:,0] - 1, ends[:, 1] - 1], 1)
B = np.cumsum(X[::-1,:], axis = 0)[::-1,:]
C = np.cumsum(B, axis = 1)
for item in queries:
    print(C[item[0] - 1, item[1] - 1])


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

#define int long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define x first
#define y second

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

	string s,t;
	cin>>s>>t;
	int cnt=0;
	for (int i=0; i<s.size(); i++){
		if (s[i]!=t[i]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (l[i] < l[j] + l[k]) res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    H,W = map(int, input().split())
    grid = []
    for i in range(H):
        input_line = str(input())
        if '#' in input_line:
            grid.append(input_line)
    

    for j in range(W):
        del_flg = True
        for line in grid:
            if(line[j] == '#'):
                del_flg = False
                break
        if(del_flg):
            for i,line in enumerate(grid):
                line = line[:j] + '0' + line[j+1:]
                grid[i] = line
    
    for line in grid:
            print(line.replace('0',''))
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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 MOD = 1000000007;
ll INF =1<<30;

int main(){
    int n;cin >> n;
    string s;
    cin >> s;
    vector<int>black(n),white(n);
    int b = 0,w=0;
    rep(i,n){
        if(s[i]=='#') b++;
        black[i]=b;
        if(s[i]=='.') w++;
        white[i]=w;
    }
    if(b==0||w==0){
        cout << 0 <<endl;
        return 0;
    }
    int ans = min(b,w);
    rep(i,n){
        int cnt = 0;
        cnt +=black[i];
        cnt +=w-white[i];
        ans = min (ans,cnt);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 5248
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define ALL(T) T.begin(),T.end()

long long fact(long long n);

int main(){
	string S; cin >> S;
	map<char, int> chrs;

	for (char c = 'a'; c <= 'z'; c++) { chrs[c] = 0; }

	for (int i = 0; i < S.size(); i++) { chrs[S[i]]++; }

	int oddc = 0;
	int odd = 0;
	vector<int> hchrc;

	for (map<char, int>::iterator it = chrs.begin(); it != chrs.end(); it++) {
		if (it->second % 2) {
			odd = it->second;
			oddc++;
		} else {
			if (it->second) {
				hchrc.push_back((it->second)/2);
			}
		}
	}

	long long int res = 0;

	if (oddc < 2) {
		odd = (odd-1)/2;
		hchrc.push_back(odd);
		int sum = 0;
		for (int i = 0; i < hchrc.size(); i++) {
			sum += hchrc[i];
		}
		res = 1;
		res *= fact(sum);
		for (int i = 0; i < hchrc.size(); i++) {
			res /= fact(hchrc[i]);
		}
	}

	cout << res << endl;


	return 0;
}

long long fact(long long n){
	if (n <= 1) { return 1; }
	else { return n * fact(n-1); }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string T;
  cin >> T;
  rep(i, T.size()) if(T[i]=='?') T[i] = 'D';
  cout << T << newl;
  return 0;
}


Measured memory_bytes: 3744
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

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

  int x = 0;
  int ans = 0;
  rep(i,n)
  {
    if(s[i] == 'I')
      x++;
    else if(s[i] == 'D')
      x--;
    ans = max(ans,x);
  }

  cout << ans << endl;



  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
/*
[dp] F - LCS
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int M, N;
string s;
string t;

string solve() {
    vector<vector<int>> dp(M + 1, vector<int>(N + 1));
    vector<vector<int>> b(M + 1, vector<int>(N + 1));

    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= N; j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[(i - 1)][j - 1] + 1;
                b[i][j] = 2;
            } else if (dp[(i - 1)][j] > dp[i][j - 1]) {
                dp[i][j] = dp[(i - 1)][j];
                b[i][j] = 0;
            } else {
                dp[i][j] = dp[i][j - 1];
                b[i][j] = 1;
            }
        }
    }

    string ans;
    for (int i = M, j = N; i > 0 && j > 0;) {
        if (b[i][j] == 0) {
            i--;
        } else if (b[i][j] == 1) {
            j--;
        } else {
            ans.push_back(s[i - 1]);
            i--;
            j--;
        }
    }
    reverse(ans.begin(), ans.end());

    return ans;
}

int main() {
    cin >> s;
    cin >> t;
    M = s.length();
    N = t.length();

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = s.size()/2-1; i>0; i--) {
    if (s.substr(0,i) == s.substr(i,i)) {
      cout << i * 2 << endl;
      return 0;
    }
  }
}

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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}

//main code

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	string ans;
	for (auto c : s) {
		switch (c) {
			case '0':
				ans += '0';
				break;
			case '1':
				ans += '1';
				break;
			case 'B':
				if (!ans.empty()) {ans.pop_back();}
				break;
			default:
				break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ABC084C

#time秒にi駅に到着した場合の時間(引数2)
#を出す関数を再帰で求めればいい

def tt(time,i):
	if(i==n):
		return time
	if(time<=s[i]):
		return tt(s[i]+c[i],i+1)
	return tt((((time-s[i]-1)//f[i])+1)*f[i]+s[i]+c[i],i+1)

n = int(input())
c=[]
s=[]
f=[]
t=[]

c.append(0)
s.append(0)
f.append(0)
t.append(0)
for i in range(1,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	c.append(hoge[0])
	s.append(hoge[1])
	f.append(hoge[2])
	t.append(0)
c.append(0)
s.append(0)
f.append(1)
t.append(0)

#for i in range(0,n-1):
#	t[n-1-i]=s[n-1-i]+c[n-1-i]
#	print("{} {}".format(t[n-1-i],s[n-i]))
#	if(t[n-1-i]<=s[n-i]):
#		t[n-1-i]=t[n-i]
#	else:
#		t[n-1-i]-=s[n-i]
#		t[n-1-i]=((t[n-1-i]-1)//f[n-i]+1)*f[n-i]+t[n-i]

for i in range(1,n+1):
	print(tt(0,i))

#print(c)
#print(s)
#print(f)
#print(t)





Measured memory_bytes: 3444
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 200000+5;
int n;
int a[MX];
int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    int sm = 0;
    FOR(i,1,n) {
        cin >> a[i];
        sm ^= a[i];
    }

    FOR(i,1,n) {
        cout << (sm^a[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 4368
#include <stdio.h>

int main()
{
  int n,i,j,a[100006],x,d;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  x=a[n-1];
  j=0;
  for(i=0;i<n-1;i++){
    if(a[i]<=x){
      d=a[i];
      a[i]=a[j];
      a[j]=d;
      j++;
    }
  }
 d=a[n-1];
 a[n-1]=a[j];
 a[j]=d;


  for(i=0;i<n;i++){
    if(i==n-1)
      printf("%d\n",a[i]);
    else if(i==j)
      printf("[%d] ",a[i]);
    else
      printf("%d ",a[i]);
    
  }

  return 0;
}



Measured memory_bytes: 2128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    string str1, str2;
    std::cin >> str1 >> str2;
    string ans;
    for(int i=0;i<n;i++){
        ans = str1[i];
        cout << ans ;
        ans =str2[i];
        cout << ans ;
        }
return 0;}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  vi a(n);
  REP(i,n) cin>>a[i];

  int flag=0;
  REP(i,n) {
    if (a[i]%2==0){
      if (a[i]%3==0){
        flag++;
      }else{
        if (a[i]%5==0)flag++;
      }
      flag--;
    }
  }

  if (flag==0){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    long cap = a;

    if (cap > b) cap = b;
    if (cap > c) cap = c;
    if (cap > d) cap = d;
    if (cap > e) cap = e;

    cout << (long)((n + cap - 1)/cap + 4) << endl;
    
	return 0;
}

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

int main() {
	long long n,i,j,a,b,c,k,t,ans,res,cur;
	cin >> n >> a >> b >> c;
	vector<long long> l(n);
	
	k=1;
	for(i=0; i<n; i++){
		cin >> l[i];
		k*=4;
	}
	
	vector<long long> check(3);
	ans=10000000;
	for(i=0; i<k; i++){
		j=i;
		check={0,0,0};
		for(t=0; t<n; t++){
			res=j%4;
			if(res>0){
				check[res-1]+=l[t]+10000;
			}
			j/=4;
		}
		if(check[0]*check[1]*check[2]==0) continue;
		cur=((check[0]/10000)+(check[1]/10000)+(check[2]/10000)-3)*10;
		cur+=abs(check[0]%10000-a)+abs(check[1]%10000-b)+abs(check[2]%10000-c);
		ans=min(ans,cur);
		
		
	}
	cout << ans;
	
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> A(n+1);
    vector<ll> B(n);

    rep(i,n+1) cin >> A[i];
    rep(i,n) cin >> B[i];
    ll ans = 0;
    rep(i,n){
        if(A[i]>B[i]){
            ans+=B[i];
        } else {
            if(A[i+1]<=B[i]-A[i]){
                ans+=A[i]+A[i+1];
                A[i+1]=0;
            } else {
                ans+=B[i];
                A[i+1]-=B[i]-A[i];
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1920
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys
import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, D = map(int, readline().split())
X = [np.array(readline().split(), dtype=np.int64) for _ in range(N)]
ans = 0

for u, v in itertools.combinations(X, 2):
    d = ((u - v) * (u - v)).sum()
    dd = int(d ** .5)
    if d == dd * dd:
        ans += 1

print(ans)


Measured memory_bytes: 12624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

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

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から

int main(){
    string s; cin >> s;
    int ans = 0;
    if (s == "SUN") {
        ans = 7;
    } else if(s == "MON")  {
        ans = 6;
    } else if (s == "TUE") {
        ans = 5;
    } else if (s == "WED") {
        ans = 4;
    } else if (s == "THU") {
        ans = 3;
    } else if (s == "FRI") {
        ans = 2;
    } else if (s == "SAT") {
        ans = 1;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	q := nextInt(sc)
	ans := make([]int, 0)
	set := make(map[int]int, 0)
	for i := 0; i < q; i++ {
		op := nextInt(sc)
		x := nextInt(sc)
		if op == 0 {
			set[x]++
			ans = append(ans, len(set))
		} else if op == 1 {
			v := 0
			if set[x] > 0 {
				v = 1
			}
			ans = append(ans, v)
		} else if op == 2 {
			delete(set, x)
		}
	}
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}



Measured memory_bytes: 16052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

	string s, t; cin >> s >> t;
	
	//-1判定
	vei cnts(26,0); rep(i,s.size()) cnts[s[i]-'a']++;
	vei cntt(26, 0); rep(i,t.size()) cntt[t[i]-'a']++;
	rep(i,t.size()) if(cnts[t[i]-'a'] == 0) { cout << -1 << endl; return 0; }

	ve_vei point(26);
	rep(i,s.size()) point[s[i]-'a'].pub(i);
	rep(i,s.size()) point[s[i]-'a'].pub(i+s.size());

	ll ans = 0; int now = 0;
	rep(i,t.size()) {
		int c = t[i] - 'a';
		now = *lower_bound(all(point[c]), now) + 1;
		if(now >= s.size()) { now -= s.size(); ans += s.size(); }
	}
	ans += now;
	cout << ans << endl;
	return 0;

	
}

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

using namespace std;
typedef unsigned long long ull;
int main()

{
    ull a,b,k,s;
    cin>>a>>b;
    if(a>b) swap(a,b);
    s = b+a;
    if(s%2!=0){
        cout<<"IMPOSSIBLE";
    }
    else{
        cout<<s/2;
    }
    return 0;

}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
li = [x for x in li if x%2 ==0]

li2 = []
for i in range(len(li)):
    num = 0
    
    while li[i]%2 == 0:
        li[i] = li[i]/2
        
        num += 1
    li2.append(num)
print(sum(li2))

Measured memory_bytes: 4148
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        if (n % 2 == 1) {
            for (int i = 1; i <= m; i++) {
                System.out.println(i + " " + (n - i));
            }
            return;
            } else {
            for (int i = 1; i <= m; i++) {
                if (i <= n / 4) {
                System.out.println(i + " " + (n - i + 1));
                } else {
                System.out.println(i + " " + (n - i));
                }
            }
        }
    }
}


Measured memory_bytes: 53544
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll ak = min(k, a);
  a -= ak;
  k -= ak;
  b -= min(k, b);
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>

using namespace std;


int N;
int C;
int diff[31][31];
int maps[3][31]; // instead of reading in every element, read in the modulo and also the color. That's all we need, after all.
int ans = 1<<30;

int main() {
    for (int i=0; i<3; i++) {
        for (int j=0; j<31; j++) {
            maps[i][j] = 0;
        }
    }

	cin >> N;
	cin >> C;
	for (int i=1; i<=C; i++) {
	    for (int j=1; j<=C; j++) {
	        cin >> diff[i][j];
	    }
	}
	
	for (int i=1; i<=N; i++) {
	    for (int j=1; j<=N; j++) {
	        int sum = (i+j)%3;
	        int color;
	        cin >> color;
	        maps[sum][color]++; // add to existing value!
	    }
	}

	// now we need to check every combination.
	
	for (int i=1; i<=C; i++) { // n is just how big the map is, that's not what we want. We want to test all possible colors, C! And we don't want to do 30 because then that won't be a thing in our Diff array!
	    for (int j=1; j<=C; j++) {
	        for (int k=1; k<=C; k++) {
	            if (i!=j && i!=k && j!=k) {
	            int diffs = 0;
	            for (int a=1; a<=C; a++) { // for all of the colors.. Again, N has nothing to do with it, and 30 is way too much.
	                diffs += diff[a][i]*maps[0][a];
	            }
	            for (int b=1; b<=C; b++) {
	                diffs += diff[b][j]*maps[1][b];
	            }
	            for (int c=1; c<=C; c++) {
	                diffs += diff[c][k]*maps[2][c];
	            }
	            if (diffs < ans) {
	                ans = diffs;
	            }
	            }
	        }
	    }
	}

    cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.close();
        // a
        for (int i = 1; i < 3510; i++) {
            // b
            for (int j = 1; j < 3510; j++) {
                long si = n * i * j;
                long bo = 4 * i * j - n * j - n * i;
                if (bo <= 0) {
                    continue;
                }
                if (si % bo == 0) {
                    System.out.println(i + " " + j + " " + (si / bo));
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 23124
import sys

input = sys.stdin.readline
s = input()
cnt1 = 0
cnt2 = 0
flag = '0'
for i in s[:-1]:
    if flag == '0':
        if i == flag:
            flag = '1'
        else:
            cnt1 += 1
            flag = '1'
    else:
        if i == flag:
            flag = '0'
        else:
            cnt1 += 1
            flag = '0'
flag = '1'
for i in s[:-1]:
    if flag == '0':
        if i == flag:
            flag = '1'
        else:
            cnt2 += 1
            flag = '1'
    else:
        if i == flag:
            flag = '0'
        else:
            cnt2 += 1
            flag = '0'
print(min(cnt1,cnt2))


Measured memory_bytes: 3188
from collections import OrderedDict
N = int(input())
color_parents = [0] * N
tree = [[] for _ in range(N)]
color = OrderedDict()
for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  tree[a].append(b)
  color[(a, b)] = 0
for a in range(N):
  c_p = color_parents[a]
  c = 1
  for b in tree[a]:
    if c == c_p:
      c += 1
    color[(a, b)] = c
    color_parents[b] = c
    c += 1
print(max(color.values()))
for k in color.keys():
  print(color[k])


Measured memory_bytes: 54716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,k,n,m,c,d,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q,a,b;
    cin>>a>>b>>n;
    x=min(n,b-1);
    cout<<(a*x)/b<<endl;
    
    
   // cout<<"Yes"<<endl;
   // cout<<"No"<<endl;
    
    
    

    return 0;
}


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

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[][] island = new char[12][12];
            int[][] map = new int[12][12];
            for (int i = 0; i < 12; i++) {
                island[i] = sc.next().toCharArray();
                Arrays.fill(map[i], 999);
            }
            int count = 0;
            for (int i = 0; i < 12; i++) {
                for (int j = 0; j < 12; j++) {
                    if (island[i][j] != '0') {
                        if (i == 0 && j == 0) {
                            map[i][j] = count++;
                        } else {
                            if (i - 1 >= 0 && island[i][j] == island[i - 1][j]) {
                                    map[i][j] = Math.min(map[i][j], map[i - 1][j]);
                            } else if (j - 1 >= 0 && island[i][j] == island[i][j - 1]) {
                                map[i][j] = Math.min(map[i][j], map[i][j - 1]);
                            } else if (j + 1 < 12 && island[i][j] == island[i][j + 1]) {
                                for (int k = j; k < 11; k++) {
                                    if (i - 1 >= 0 && island[i][k] == island[i][k + 1] && island[i][k + 1] == '1' && island[i - 1][k + 1] == '1') {
                                        map[i][j] = map[i - 1][k + 1];
                                        count--;
                                        break;
                                    }
                                }
                                map[i][j] = count++;
                            } else {
                                map[i][j] = count++;
                            }
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}



Measured memory_bytes: 26184
#include <stdio.h>
#include <string.h>

int main(void){
    char s[101];
    char t[101];
    scanf("%s",s);
    scanf("%s",t);
    char min_s='z', max_t='a';
    int cnt_min_s = 0, cnt_max_t=0;
    
    for(int i = 0; i < strlen(s); i++){
        if(s[i] < min_s){
            min_s = s[i];
            cnt_min_s = 1;
        }else if(s[i] == min_s){
            cnt_min_s++;
        }
    }    
    
    for(int i = 0; i < strlen(t); i++){
        if(t[i] > max_t){
            max_t = t[i];
            cnt_max_t = 1;
        }else if(t[i] == max_t){
            cnt_max_t++;
        }
    }
    //printf("cnt_max_t=%d, cnt_min_s=%d",cnt_max_t,cnt_min_s);
    if(max_t < min_s || 
      (max_t == min_s && cnt_max_t <= cnt_min_s) ||
      (max_t == min_s && cnt_max_t > cnt_min_s && strlen(s) > cnt_min_s )) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;


public class  Main{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		long size=sc.nextLong();
		long blue=sc.nextLong();
		long red=sc.nextLong();
		long total=blue+red;
		long ans=0;
		long div=0;
		long mod=0;
		if(blue==0)
		{ans=0;}
		else if(size<total)
		{
			 if(size>=blue)
			{
				ans=blue;
			}
			else if(size<blue)
			{
				ans=size;
			}
		}
		else if(size>=total)
		{
			
			div=size/total;
			mod=size%total;
			if(mod>blue)
			{
				mod=blue;
			}
			ans=(div*blue)+mod;
		
		}
		System.out.println(ans);

		
	}



	}









Measured memory_bytes: 22740
import math
N=int(input())
X=list(map(int,input().split()))
Prange= range(math.floor(min(X))-1,math.ceil(max(X))+1)
summin=100000000000
for P in Prange:
    sum=0
    for x in X:
        sum+=(P-x)**2
    if summin > sum:
        summin=sum
print(summin)

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"


int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	int n, a, b;

	cin >> n >> a >> b;

	puts((b - a) % 2 == 0 ? "Alice" : "Borys");

	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N; cin >> N;
    V<int> a = V<int>(N+1); REP(i,1,N+1) cin >> a[i];

    int ans = 0;
    REP(i,1,N+1) {
        if(a[a[i]] == i) ans++;
    }
    cout << ans/2 << endl;

    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

struct data {
  llong place;
  llong cost;
  llong before;

  data() {};
  data(llong place, llong cost, llong before) :
    place(place),
    cost(cost),
    before(before)
  {}

  bool operator<(const data &ri) const {
    return cost < ri.cost;
  }
  bool operator<=(const data &ri) const {
    return cost <= ri.cost;
  }
  bool operator>(const data &ri) const {
    return cost > ri.cost;
  }
};

llong N, X, Y;
vector<vector<data> > edges;

vector<data> dijkstra(int start) {
  priority_queue<data, vector<data>, greater<data> > que;
  vector<data> dis(edges.size(), data(-1, inf<llong>, -1));
  dis[start] = data(start, 0, -1);

  que.push(dis[start]);
  while (que.size()) {
    data now = que.top();
    que.pop();
    if (dis[now.place] < now) continue;
    now = dis[now.place];

    for (auto &edge: edges[now.place]) {
      data next(edge.place, now.cost + edge.cost, now.place);
      if(dis[next.place] <= next) continue;
      dis[next.place] = next;
      que.push(next);
    }
  }

  return dis;
}

int main() {
  cin >> N >> X >> Y;
  edges.resize(N);
  for (int i = 1; i < N; ++i) {
    edges[i].push_back(data(i-1, 1, i-1));
    edges[i-1].push_back(data(i, 1, i));
  }
  edges[X-1].push_back(data(Y-1, 1, X-1));
  edges[Y-1].push_back(data(X-1, 1, X-1));

  vector<llong> ans(N+1, 0);
  for (int i = 0; i < N; ++i) {
    auto dis = dijkstra(i);
    for (int j = i; j < N; ++j) {
      ++ans[dis[j].cost];
    }
  }

  for (int i = 1; i < N; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	auto diff = (A + B) - (C + D);
	if (diff > 0)
	{
		cout << "Left" << endl;
	}
	else if (diff == 0)
	{
		cout << "Balanced" << endl;
	}
	else
	{
		cout << "Right" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/*
    考虑一个可以用 K ((n+1)/2 <= K < n)次染黑的方案，
	那么将操作前K次的机器从小到大排序，一定是:
	a1=1 < a2 < ...< ak=n-1
	并且 a[i+1]-a[i] <= 2
	
	转化模型，就是一个变量初始等于 1 ,每次操作可以 +1 或者 +2 ,
	k-1 次操作之后 = n-1 的方案数. 
	
	C(k-1 , n-k-1) * (k!) * ((n-k-1)!)
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int ha=1e9+7,N=1e6+5,mod=ha-1;
 
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}
 
inline int ksm(int x,int y){
    int an=1;
    for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
    return an;
}
 
int n,jc[N],ni[N],ans,f[N]; 
 
inline void init(){
    jc[0]=1;
    for(int i=1;i<=n;i++) jc[i]=jc[i-1]*(ll)i%ha;
    ni[n]=ksm(jc[n],ha-2);
    for(int i=n;i;i--) ni[i-1]=ni[i]*(ll)i%ha;
}

inline void solve(){
	for(int k=n+1>>1;k<n;k++) f[k]=jc[k]*(ll)jc[k-1]%ha*(ll)ni[2*k-n]%ha;
	for(int k=n+1>>1;k<n;k++) ADD(ans,add(f[k],ha-f[k-1])*(ll)k%ha);
}

int main(){
	scanf("%d",&n),init();
	solve(),printf("%d\n",ans);
	return 0;
}

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

namespace ConsoleApp43 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = st[0];
            int B = st[1];

            Console.WriteLine((A + B) % 24);
            
            
        }

    }
}


Measured memory_bytes: 13268
N = int(input())
nlist = list(map(int, input().split(' ')))

nSum = sum(nlist[0::2])-sum(nlist[1::2])

prev = nSum / 2
results = [str(int(nSum))]
for i in range(N-1):
    prev = nlist[i]-prev
    results.append(str(int(prev*2)))

print(' '.join(results))

Measured memory_bytes: 77916
x, y = map(int, input().split())
ans = []
for i in [x, y]:
    if i in [1, 3, 5, 7, 8, 10, 12]:
        ans.append(1)
    elif i in [4, 6, 9, 11]:
        ans.append(2)
    else:
        ans.append(3)
if ans[0] == ans[1]:
    print("Yes")
else:
    print("No")

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

int main() {
  int N,M;
  
  //N格納して各文字列のカウントを足す
  cin >> N;
  string s[N];
  map<string,int> dic;
  for(int i = 0; i < N; i++) {
    cin >> s[i];
    dic[s[i]] ++;
  }
  //M格納して各文字列のカウントを引く
  cin >> M;
  string t[M];
    for(int i = 0; i < M; i++) {
    cin >> t[i];
    dic[t[i]] --;
  }
  
  //辞書の値最大値を出力（－なら0）
  map<string, int>::iterator itr;
  int ans = 0;
  for (itr = dic.begin(); itr != dic.end(); itr++){
    if(itr->second > ans) ans = itr->second;
  }
  
  if (ans < 1) cout << 0;
  else cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  cout<<((int)pow(2,k)-1)*max({a,b,c})+a+b+c<<endl;



  return 0;

}


Measured memory_bytes: 512
n=int(input())

l=[1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]

#初期値：n回（n円は1円をn回引き出すことでも得られる）
dp=list(range(n+1))

for item in l:
  for i in range(item,n+1):
    #よりよい引き出し方に変えていく
    dp[i]=min(dp[i-item]+1, dp[i])

print(dp[-1])

Measured memory_bytes: 40048
#include <bits/stdc++.h>
 
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define fff(i,a,b) for(int (i)=(a);(i)<=(b);i++)
#define pb push_back
#define len(a) (a).length()
#define all(a) (a).begin(),(a).end()
#define sz(a) (a).size()
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long ,long long > pll;
typedef unsigned long long ull; 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		int t=0;
		int mx=0;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]=='R')
			{
				t++;
			}
			else
			{
				mx=max(t,mx);
				t=0;
			}
		}
		mx=max(t,mx);
		cout<<mx<<endl;
	}	
 	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,a,b,c,d,i;
    bool flag=false;
    string str;
    cin>>n>>a>>b>>c>>d;
    a--;b--;c--;d--;
    cin>>str;
    if(a<c && c<b)
    {
        for(i=a;i<c;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=b;i<d;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
    }
    else if(a<b && b<c && c<d)
    {
        for(i=b;i<d;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=a;i<c;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
    }
    else if(a<b && b<d && d<c)
    {
        for(i=a;i<c;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=b;i<d;i++)
        {
            if(str[i]=='#' && str[i+1]=='#')
            {
                cout<<"No";
                return 0;
            }
        }
        for(i=b-1;i<=d-1;i++)
        {
            if(str[i]=='.' && str[i+1]=='.' && str[i+2]=='.')
            {
                flag=true;
                cout<<"Yes";
                return 0;
            }
        }
        if(flag==false)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 592
import java.math.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

/*
https://ir5.hatenadiary.org/entry/20090928/1254203385
 */
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long max1;
    long min1;
    long max2;
    long min2;
    long max3;
    long min3;
    long max4;
    long min4;
    {
      long x = sc.nextLong();
      long y = sc.nextLong();
      long x1 = x + y;
      long x2 = x - y;
      long x3 = -x + y;
      long x4 = -x - y;
      max1 = x1;
      min1 = x1;
      max2 = x2;
      min2 = x2;
      max3 = x3;
      min3 = x3;
      max4 = x4;
      min4 = x4;
    }
    for (int i = 1; i < n; i++) {
      long x = sc.nextLong();
      long y = sc.nextLong();
      long x1 = x + y;
      long x2 = x - y;
      long x3 = -x + y;
      long x4 = -x - y;
      if (x1 > max1) {
        max1 = x1;
      } else if (x1 < min1) {
        min1 = x1;
      }
      if (x2 > max2) {
        max2 = x2;
      } else if (x2 < min2) {
        min2 = x2;
      }
      if (x3 > max3) {
        max3 = x3;
      } else if (x3 < min3) {
        min3 = x3;
      }
      if (x4 > max4) {
        max4 = x4;
      } else if (x4 < min4) {
        min4 = x4;
      }
    }
    System.out.println(Math.max(Math.max(Math.max(max1 - min1, max2 - min2), max3 - min3), max4 - min4));
  }
}


Measured memory_bytes: 48852
#include<string>
#include<iostream>
using namespace std;
 
 
 
int check_ACGT(int finded[], int l, int r){
	return finded[r] - finded[l];
}
 
 
int main(){
	int N,Q;
	string S;
	cin>>N>>Q;
	cin>>S;
	int l[Q];
	int r[Q];
	int ans[Q];
	int finded[N];
  	int j = 0;
	finded[0] = 0;
	for(int i = 0; i < N; i++){
		if(S[i] == 'A' && S[i + 1] == 'C'){
          j++;
			finded[i + 1] = j;
       
      }else{
          finded[i + 1] = j;
        }
		//cout<<finded[i]<<",";
	}
	finded[0] = 0;
	cout<<endl;
	//cout<<finded[]<<endl;
	for(int i = 0; i < Q; i++){
		cin>>l[i]>>r[i];
		
			cout<<check_ACGT(finded, l[i] - 1, r[i] - 1)<<endl;
			//cout<<r[i]<<","<<finded[r[i] - 1]<<","<<l[i]<<","<<finded[l[i] - 1]<<endl;
		
			
			//cout<<r[i]<<","<<finded[r[i] - 2]<<","<<l[i]<<","<<finded[0]<<endl;
		
		//cout<<check_ACGT(finded, l[i], r[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	string s, t;
	cin >> s >> t;

	const int size_s = s.size();
	const int size_t = t.size();

	vector<vector<int>> dp(size_s + 1, vector<int>(size_t + 1, 0));
	for (int i = 0; i < size_s; i++) {
		for (int j = 0; j < size_t; j++) {
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);

			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			}
		}
	}

	string ans = "";
	int si = size_s;
	int ti = size_t;
	while (si > 0 && ti > 0) {
		if (dp[si - 1][ti] == dp[si][ti])
			si--;
		else if (dp[si][ti - 1] == dp[si][ti])
			ti--;
		else {
			ans = s[si - 1] + ans;
			si--;
			ti--;
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 35584
# -*- coding: utf-8 -*-
import itertools
"""
def len(a):
    return len(set(a))
"""

n = int(input())
s = [input() for _ in range(n)]

ans = 0
name_count = [0 for _ in range(5)]
M = []
A = []
R = []
C = []
H = []
for i in range(n):
    if s[i][0] == 'M':
        name_count[0] += 1
        M.append(s[i])
    if s[i][0] == 'A':
        name_count[1] += 1
        A.append(s[i])
    if s[i][0] == 'R':
        name_count[2] += 1
        R.append(s[i])
    if s[i][0] == 'C':
        name_count[3] += 1
        C.append(s[i])
    if s[i][0] == 'H':
        name_count[4] += 1
        H.append(s[i])
#print(M, A, R, C, H)
len_M = len(set(M))
len_A = len(set(A))
len_R = len(set(R))
len_C = len(set(C))
len_H = len(set(H))
#print(len_M, len_A, len_R, len_C, len_H)
#ans = len_M * (len_A * len_R + len_A * len_C + len_A * len_H + len_R * len_C + len_R * len_H + len_C * len_H) + len_A * (len_R * len_C + len_R * len_H + len_C * len_H) + len_R * len_C + len_H
tmp = [i for i in range(5)]
tmp2 = [len_M, len_A, len_R, len_C, len_H]
combination = list(itertools.combinations(tmp, 3))
ans = 0
for i in range(len(combination)):
    ans += tmp2[combination[i][0]] * tmp2[combination[i][1]] * tmp2[combination[i][2]] 
print(ans)


Measured memory_bytes: 16824
N, K = map(int, input().split())
E = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)
counts = [False]*N
q = [0]
counts[0] = True
r = K
while len(q) > 0:
  i = q.pop(0)
  # get_nexts
  js = E[i]
  c = K-1 if i == 0 else K-2
  for j in js:
    if not(counts[j]):
      counts[j] = True
      r = (r*c)%1000000007
      c -= 1
      q.append(j)
print(r)


Measured memory_bytes: 25652
#include<stdio.h>
int main(void){
  int n, i, temp=0;
  scanf("%d", &n);
  char s[1000001];
  scanf("%s", s);
  for(i=1;i<n;i++){
    if(s[i]!=s[i-1]){
      temp++;
    }
  }
  printf("%d\n", temp+1);
  return 0;
}


Measured memory_bytes: 256
// Last Change: 05/25/2019 21:12:30.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  if (A >= 13) {
    cout << B << endl;
  } else if (A > 5) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256