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

using namespace std;

string s;
vector<int>poz[26];
int  nr, n, viz[200002], aib[200002];
long long ans;

void update (int poz, int val) {
  for(; poz <= n; poz += poz&-poz)
    aib[poz] += val;
}
int query (int poz) {
  int s = 0;
  for (; poz > 0; poz -= poz&-poz)
    s += aib[poz];
  return s;
}

int main()
{
  cin >> s;
  n = s.size();
  s = '#' + s;
  for (int i = 1; i <= n; i++) {
    poz[s[i] - 'a'].push_back(i);
  }
  int r = 0;
  for (int i = 0; i < 26; i++) {
    if (poz[i].size() % 2 == 1)
      nr++;
  }
  if (nr > 1) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    update(i, 1);
  for (int i = 1; i <= n; i++) {
    if (viz[i])
      continue;
    int c = s[i] - 'a';
    int p = poz[c].back();
    poz[c].pop_back();
    if (i == p) {
      ans += (query(n) - query(i)) / 2;
    }
    else
      ans += query(n) - query(p);
    update(i, -1);
    update(p, -1);
    viz[i] = viz[p] = 1;
  }
  cout << ans;
  return 0;
}


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

typedef long long ll;
#define f first 
#define s second 
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> Pii;
typedef vector<Pii> vpii;
#define rep(i,n) for(int i = 0; i < (n); ++i)

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int n;
const int maxn = 110;
vi E[maxn];
bool vis[maxn];
int dfs1(int x)
{
	vis[x] = true;
	int r = 0;
	for(int y : E[x])
		if(vis[y] == false)
			maxi(r, dfs1(y) + 1);
	return r;
}

vpii Edges;
void cl()
{
	rep(i,n)
		vis[i] = false;
}
int table[maxn];
void cl2()
{
	rep(i,n)
		table[i] = 0;
}
void dfs2(int x, int d)
{
	vis[x] = true;
	int ile = 0;
	for(int y : E[x])
		if(!vis[y])
		{
			++ile;
			dfs2(y, d + 1);
		}
	maxi(table[d], ile);
}
typedef pair<ll, ll> Pll;
Pll siepaj(int x)
{
	cl();
	
	ll od = dfs1(x);
	cl();
	cl2();
	dfs2(x, 0);
	ll res = 1;
	rep(i,n)
		if(table[i] != 0)
			res *= table[i];
	//printf("%d %lld\n", od + 1, res);
	return {od + 1, res};
}
Pll siepaj(int a, int b)
{
	cl2();
	cl();
	vis[b] = true;
	ll od = dfs1(a);
	cl();
	vis[a] = true;
	maxi(od, 1ll *dfs1(b));
	cl();
	vis[a] = true;
	dfs2(b,0);
	cl();
	vis[b] = true;
	dfs2(a,0);
	
	ll res = 2;
	rep(i,n)
		if(table[i] != 0)
			res *= table[i];
	return {od + 1, res};
}
int main()
{
	scanf("%d", &n);
	rep(i,n-1)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		--a; --b;
		E[a].pb(b);
		E[b].pb(a);
		Edges.pb({a,b});
	}
	vi cand;
	
	Pll wynik = {100000, 100000};
	rep(i,n)
		mini(wynik, siepaj(i));
	for(Pii p : Edges)
		mini(wynik, siepaj(p.f, p.s));
	
	printf("%lld %lld\n", wynik.f, wynik.s);
}



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

d = {4: 0, 2: 0, 1: 0}

for a in A:
    if a % 4 == 0:
        d[4] += 1
    elif a % 2 == 0:
        d[2] += 1
    else:
        d[1] += 1

if d[2] == 0:
    if d[4] - d[1] >= -1:
        print("Yes")
    else:
        print("No")
else:
    if d[4] - d[1] >= 0:
        print("Yes")
    else:
        print("No")


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

int main() {


//long long a,b;
//int *num=new int[4];
//char *s=new char[3];
string s;
cin >> s;

//if (s.find("AC") != std::string::npos) {

int n=(int)(s.length());

for(int i=0;i<n-8;i++){
cout << s[i];

}
cout << "\n";



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;

const int N = 1e5 + 7;
const int inf = 1e9 + 7;

vector <pair <int, int> > g[N];

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
gp_hash_table<int, int, chash> d[N];
gp_hash_table<int, int, chash> mn;

map <int, vector <int> > rg[N];

bool used[N];

struct triple {
    int v, c, d;
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
        d[a][c] = inf;
        d[b][c] = inf;
        mn[a] = inf;
        mn[b] = inf;
        rg[a][c].push_back(b);
        rg[b][c].push_back(a);
    }
    queue <triple> q, go;
    d[0][0] = 0;
    mn[0] = 0;
    q.push({0, 0, 0});
    while (!q.empty() || !go.empty()) {
        if (q.empty()) {
            swap(q, go);
        }
        auto cur = q.front();
        int v = cur.v;
        int cur_c = cur.c;
        int cur_d = cur.d;
        q.pop();
        if (cur_d > d[v][cur_c] || cur_d > mn[v]) {
            continue;
        }
        if (used[v]) {
            for (auto to : rg[v][cur_c]) {
                int u = to;
                if (d[u][cur_c] > d[v][cur_c]) {
                    d[u][cur_c] = d[v][cur_c];
                    q.push({u, cur_c, d[u][cur_c]});    
                    mn[u] = min(mn[u], d[u][cur_c]);
                }
            }
            continue;
        }
        used[v] = true;
        for (auto to : g[v]) {
            int u = to.first;
            int go_c = to.second;
            if (d[u][go_c] > d[v][cur_c] + (cur_c != go_c)) {
                d[u][go_c] = d[v][cur_c] + (cur_c != go_c);
                int f = (cur_c != go_c);
                if (f) {
                    go.push({u, go_c, d[u][go_c]});
                } else {
                    q.push({u, go_c, d[u][go_c]});    
                }
                mn[u] = min(mn[u], d[u][go_c]);
            }
        }
    }
    int ans = inf;
    for (auto to : d[n - 1]) {
        ans = min(ans, to.second);
    }
    cout << (ans == inf ? -1 : ans) << '\n';
    return 0;
} 


Measured memory_bytes: 90680
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int ans = 10000000;
        for (int i = 0 ; i < s.length() - 2; i++) {
            String b = s.substring(i, i + 3);
            int c = Integer.valueOf(b);
            ans = Math.min(ans, Math.abs(c - 753));
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 23636
N = int(input())
S1 = input()
S2 = input()
ans = 3

for n in range(1,N):
  if S1[n-1]==S2[n-1] or n==1:
    ans*=2
  elif S1[n-1]!=S1[n] and S1[n]!=S2[n]:
    ans*=3

print(ans%(10**9+7))

Measured memory_bytes: 9200
#include<stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

/* ソート関数 */
int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}
int main(){
  int P[1010];
  int N,K;
  int sum =0;
  scanf("%d %d", &N, &K);
    rep(i, N){
      scanf("%d", &P[i]);
    }
   

qsort(P, N, sizeof(int), int_sort);


rep(j,K){
     sum += P[j];
}

printf("%d\n", sum);
return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double n,m,d,ans;
    cin >> n >> m >> d;
    
    if(d == 0){
        ans = 1.0/n;
    }
    else{
        ans = 2*(n-d)/(n*n);
    }
    ans *= (m-1);
    cout << setprecision(7) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split()); i = 0
if a == b and b == c and a%2 == 0: print(-1)
else:
    while a%2 == 0 and b%2 == 0 and c%2 == 0:
        a, b, c = (b+c)//2, (c+a)//2, (a+b)//2; i += 1
    print(i)

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c,n;
  cin>>a>>b>>c>>n;

  int res=0;
  rep(i,n/a+1){
    rep(j,n/b+1){
      int k=n-i*a-j*b;
      if(k%c!=0||k<0)continue;
      else res++;
    }
  }
  out(res);

  
  return 0;
}



Measured memory_bytes: 256
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 100005
using namespace std;
int n,A,B,C;
int ans=5000;
int arr[3];
void sol(vector<int> v, int acum){
    bool visited[v.size()];
    ms(visited,false);
    int aux=5000;
    sort(v.begin(),v.end());
    int m=v.size();
    for(int i=0;i<m;i++)
        for(int j=i+1;j<m;j++)
            for(int k=j+1;k<m;k++)
                aux=min(aux,abs(v[i]-arr[0])+abs(v[j]-arr[1])+abs(v[k]-arr[2]));
    ans=min(ans,aux+acum);
    if(v.size()==3){
        return  ;
    }
    for(int i=0;i<m;i++){
        for(int j=i+1;j<m;j++){
            vector<int> s1;
            s1.push_back(v[i]+v[j]);
            for(int k=0;k<m;k++){
                if(k!=i && k!=j ){
                    s1.push_back(v[k]);
                }
            }
            sol(s1,acum+10);
        }
    }
}
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d %d %d %d",&n,&arr[0],&arr[1],&arr[2]);
    sort(arr,arr+3);

    vector<int> v;

    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        v.push_back(a);
    }
    sol(v,0);
    cout<<ans<<endl;
	return 0;
}



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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

lint a, b, n;

lint f(lint x){
	return ((x*a)/b) - a*(x/b);
}

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

	cin>>a>>b>>n;
	lint ans = (b<=n ? f(b-1) : f(n));
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	ll a, b;
	cin >> n;
	vi v(1000010);
	v[0] = 0;
	REP(i, n)
	{
		cin >> a >> b;
		--a;
		v[a]++;
		v[b]--;
	}
	REP(i, 100001)
	{
		v[i + 1] += v[i];
	}
	REP(i, n + 1)
	{
		if (v[i] >= i)
			k = max(k, i);
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 10752
ref = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
while 1:
    N,M,Q = map(int,raw_input().split())
    if N == 0: break

    corr = [set(range(N)) for _ in range(M)]
    s = ["0"]*N
    for loop in xrange(Q):
        S,B = raw_input().split()
        for i in range(N):
            if S[i] == "1": s[i] = {"0":"1","1":"0"}[s[i]]
        on  = set([i for i in range(N) if s[i] == "1"])
        off = set(range(N))-on
        for i in range(M):
            if B[i] == "1": corr[i] &= on
            else:           corr[i] &= off
    ans = [ref[list(i)[0]] if len(i) == 1 else "?" for i in corr]
    print "".join(ans)

Measured memory_bytes: 6764
package main

import "fmt"

func main(){
	var p string
	fmt.Scanf("%s", &p)

	fmt.Printf("%d\n", kaibun(p))
}

func kaibun(p string) int {
	var c []rune
	var ret int

	for _, v := range p {
		c = append(c, v)
	}

	index := len(c) - 1
	for k, v := range c {
		if v != c[index - k] {
			ret++
		}
	}
	return ret / 2
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli n,r,g,b,ans=0;
    lli i,j;
    cin>>r>>g>>b>>n;
    rrep(i,n/r,-1){
        rrep(j,n/g,-1){
            if((floor(((double)n-((double)i*(double)r+(double)j*(double)g))/(double)b)==((double)n-((double)i*(double)r+(double)j*(double)g))/(double)b)&&((((double)n-((double)i*(double)r+(double)j*(double)g))/(double)b)>=0)){
//                cout<<"Rの箱は"<<i<<"　Gの箱は"<<j<<"　Bの箱は"<<(n-(i*r+j*g))/b<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int n,c;
long long int res;
int main(){
	scanf("%d",&n);
	c=1;
	res=0;
	for(int i=0; i<n; i++){
		int x;
		scanf("%d",&x);
		if(x == c)
			c++;
		else{
			int now = x/c, lef = x%c;
			if(lef == 0){
				lef = 1;
				now --;
				if(c == 1)c++;
			}
			res += now;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	var aAndB = strings.Split(sc.Text(), " ")
	var a, err1 = strconv.Atoi(aAndB[0])
	if err1 != nil {
		fmt.Println(err1)
		return
	}
	var b, err2 = strconv.Atoi(aAndB[1])
	if err2 != nil {
		fmt.Println(err2)
		return
	}
	if a > 1000 || a < -1000 || b > 1000 || b < -1000 {
		fmt.Println("Invalid parameter.")
		return
	}
	if a > b {
		fmt.Println("a > b")
	}
	if a == b {
		fmt.Println("a == b")
	}
	if a < b {
        fmt.Println("a < b")
	}
}



Measured memory_bytes: 1132
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (ll i=a;i<=(ll)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e3 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int sp[33][33] = { }, store[3][33] = { };
vi v[4];
inline int replace(int idx, int col) {
	int ans = 0;
	for (auto u : v[idx])
		ans += sp[u][col];
	return ans;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, c;
	cin >> n >> c;
	lp(i,1,c)
	{
		lp(j,1,c)
		{
			cin >> sp[i][j];
		}
	}
//	lp(k,1,c)
//		lp(i,1,c)
//			lp(j,1,c)
//				sp[i][j] = min(sp[i][j], sp[i][k] + sp[k][j]);
	lp(i,1,n)
		lp(j,1,n)
		{
			int x;
			cin >> x;
			v[(i + j) % 3].pb(x);
		}
	lp(i,1,c)
		lp(j,0,2)
			store[j][i] = replace(j, i);
	int fans = mod;
	lp(i,1,c)
	{
		lp(j,1,c)
		{
			lp(k,1,c)
			{
				if (k == i || k == j || i == j)
					continue;
				int sum = store[0][i] + store[1][j] + store[2][k];
				fans = min(fans, sum);
			}
		}
	}
	f(fans);
	return 0;
}

Measured memory_bytes: 1520
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX 200000
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
typedef long long ll;

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    if(x<=a*a*b/2){
        double c=x*2/b/a;
        cout<<setprecision(8)<<atan(b/c)*180/M_PI<<endl;
    }
    else{
        double c=x/a;
        cout<<setprecision(8)<<atan((a*b-c)*2/a/a)*180/M_PI<<endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int h, w;
  char s[52][52] = {0};
  scanf("%d%d", &h, &w);
  for(int i = 1;i <= h;i++) {
    scanf("%s", &s[i][1]);
  }
  for(int i = 1;i <= h;i++) {
    for(int j = 1;j <= w;j++) {
      if(s[i][j] == '.') s[i][j] = '0';
    }
  }

  for(int i = 1;i <= h;i++) {
    for(int j = 1;j <= w;j++) {
      if(s[i][j] == '#') continue;
      if(s[i-1][j-1] == '#') s[i][j]++;
      if(s[i-1][j  ] == '#') s[i][j]++;
      if(s[i-1][j+1] == '#') s[i][j]++;
      if(s[i  ][j-1] == '#') s[i][j]++;
      if(s[i  ][j+1] == '#') s[i][j]++;
      if(s[i+1][j-1] == '#') s[i][j]++;
      if(s[i+1][j  ] == '#') s[i][j]++;
      if(s[i+1][j+1] == '#') s[i][j]++;
    }
  }
  for(int i = 1;i <= h;i++) {
    printf("%s\n", &s[i][1]);
  }
  return 0;
}
    

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

int main(void){
    int n,a,b,c,d;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    a--,b--,c--,d--;
    bool ans=true;
    for(int i=a;i<c;i++){
        if(s[i]=='#'&&s[i+1]=='#') ans=false;
    }
    for(int i=b;i<d;i++){
        if(s[i]=='#'&&s[i+1]=='#') ans=false;
    }
    if(c>d){
        bool kari=false;
        for(int i=b-1;i<d;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') kari=true;
        }
        if(kari==false) ans=false;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
int a[1005],k,n;
main(){
	while(~getII(n,k)){
		F(i,0,n) getI(a[i]);
		sort(a,a+n);
		int sum=0;
		F(i,0,k) sum+=a[i];
		printf("%d\n",sum);
	}
}


Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a<=b && c<=d){
        printf("%d\n",a+c);
    }
    else if(b<=a && c<=d){
        printf("%d\n",b+c);
    }
    else if(a<=b && d<=c){
        printf("%d\n",a+d);
    }
    else
        printf("%d\n",b+d);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
    int a[51]={0};
    int n,m,hehe,haha;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&hehe,&haha);
        a[hehe]++;
        a[haha]++;
    }
    for(int i=1;i<=n;i++) printf("%d\n",a[i]);
    return 0;
}


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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define sort(vec) std::sort(all(vec))
#define rev(vec) std::reverse(all(vec))

void calculate(){

}

int main(int,char**){
    int N;
    input(N);
    std::vector<long long> A(N);
    inputVector(A);
    long long min = 1LL << 60,max = 0;
    rep(i,N){
        min = std::min(min,A[i]);
        max = std::max(max,A[i]);
    }
    std::cout << max - min << '\n';
}


void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

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

using namespace std;

const int N = 1e5 + 10;

void solve() {
    int n, m; cin >> n >> m;
    int sm = (n - 1) / 2;
    for (int l = 1, r = sm + 1; m && l < r; l++, r--) {
        cout << l << " " << r << endl;
        m--;
    }
    if (n % 2 == 1) {
        for (int l = sm + 2, r = n; m && l < r; l++, r--) {
            cout << l << " " << r << endl;
            m--;
        }
    }
    else {
        for (int l = sm + 2, r = n - 1; m && l < r; l++, r--) {
            cout << l << " " << r << endl;
            m--;
        }
    }
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,m,k,pen=0,ac=0;
    string a;
    cin>>n>>m;
    unordered_map<int,string>mp;
    unordered_map<int,int>wa;

    rep0(i,m)
    {
        cin>>k>>a;
        if(a=="AC")
        {
            if(mp[k]!="AC")
            {
                mp[k]="AC";
                pen+=wa[k];
                wa[k]=0;
                ac++;
            }
        }
        else
        {
            wa[k]++;
        }
    }
    cout<<ac<<" "<<pen;
}


Measured memory_bytes: 13128
#include <bits/stdc++.h>
using namespace std;
#define                MXX 1000006
#define                FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define                exit() return 0
#define                mpii map<int, int>
#define                mpit map<int, int>::iterator it
#define                si set<int>
#define                sit set<int>::iterator it;
#define                ll long long int
//#define                endl "\n";
const                  ll INF = 2000000000000000000LL;
const                  int MOD = 10000007;

int a[MXX];
int main()
{
    FAST_IO;
    int N;
    cin>>N;
    for(int i = 0; i<N; i++) cin>>a[i];
    sort(a, a + N);
    ll sum = 0;
    for(int i = 0; i<N-1; i++)
    {
        sum+=a[i];
    }
    if(a[N-1]<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     ll      long long int
#define     yes         cout<<"YES"<<endl
#define     no      cout<<"NO"<<endl
int main()
{
    int f=0;
    string s,s2;
    cin>>s>>s2;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s2[i]){
            f=1;
            break;
        }
    }
    if(f==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repinv(i, n) for (int i = (int)n - 1; i >= 0; i--)

long long n, m, a, b;
vector<pair<long long, long long>> jobs;

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

    jobs.resize(n);
    rep(i, n)
    {
        cin >> a >> b;
        jobs[i] = {a, b};
    }

    sort(jobs.begin(), jobs.end());

    long long ans = 0;
    int j = 0;
    priority_queue<long long> q;
    rep(i, m)
    {
        while (jobs[j].first <= i + 1 && j < n)
        {
            q.push(jobs[j].second);
            j++;
        }
        
        if (q.empty() == false)
        {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2936
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin>>s;
	if (s.size()<5) return puts("NO"),0;
	int pos = s.find("KIH");
	if (pos<0||pos>1) return puts("NO"),0;
	if (pos==0) s.insert(0,"A");
	pos = s.find("B");
	if (pos<0||pos!=5&&pos!=4) return puts("NO"),0;
	if (pos==4) s.insert(4,"A");
	pos = s.find("R");
	if (pos<0||pos!=7&&pos!=6) return puts("NO"),0;
	if (pos==6) s.insert(6,"A");
	if (s.back()!='A') s.push_back('A');
	puts(s=="AKIHABARA"?"YES":"NO");
}







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

#define INF ((ll)2e18)

using namespace std;

typedef long long ll;

int main() {
  ll h, n; cin >> h >> n;

  vector<ll> a(n), b(n);

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

  // dp[x] := 体力xを削るのに必要な魔力の最小値
  ll dp[1000006] = {0};
  for (ll i = 0; i < 1000006; i++) {
    dp[i] = INF;
  }
  dp[0] = 0;

  for (ll x = 0; x <= 10*h; x++) {
    for (ll j = 0; j < n; j++) {
      if (dp[x] != INF) {
        dp[x+a[j]] = min(dp[x]+b[j], dp[x+a[j]]);
      }
    }
  }

  ll ans = INF;
  for (ll x = h; x <= h*10; x++) {
    if (dp[x] != INF) {
      ans = min(ans, dp[x]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8064
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] h=new int[200001];
		HashSet<Integer> hs=new HashSet<>();
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			h[a]++;
			hs.add(a);
		}
		Arrays.sort(h);
		int ans=0;
		int cnt=hs.size()-k;
		for(int i=0;i<h.length;i++) {
			if(cnt<=0) {
				break;
			}else if(h[i]==0) {
				continue;
			}
			ans+=h[i];
			cnt--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 101244
import sys
l, r = list(map(int, input().split()))

minmod = 2 * 10 ** 9


if r - l >= 2019:
    print(0)
    sys.exit()

for i in range(l,r):
    imod = i % 2019
    for j in range(i+1,r+1):
        jmod = j % 2019
        minmod = min(minmod, (imod * jmod) % 2019)
        if minmod == 0:
            break

print(minmod)

Measured memory_bytes: 3060
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 1e5 + 10;
int a[maxN];
int val[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        char c;
        cin >> c;
        if (c == 'o') val[i] = 0;
        else val[i] = 1;
    }
    for (int x = 0; x < 2; x++) {
        for (int b = 0; b < 2; b++) {
            a[1] = x;
            a[2] = b;
            for (int i = 2; i <= n - 1; i++) {
                a[i + 1] = (a[i - 1] ^ a[i]) ^ val[i];
            }
            bool ok = true;
            for (int i = 1; i <= n; i++) {
                int p = a[i];
                if (i == 1) p ^= a[n];
                else p ^= a[i - 1];
                if (i == n) p ^= a[1];
                else p ^= a[i + 1];
                if (p != val[i]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                for (int i = 1; i <= n; i++) {
                    cout << (a[i] == 1 ? 'W' : 'S');
                }
                exit(0);
            }
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 1152
#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;}

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main2() {
  ll A = nextInt();
  ll B = nextInt();
  ll ans = A / gcd(A, B) * B;
  cout << ans << endl;
  return 0;
}

int main() {

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

Measured memory_bytes: 256
import math

n, m = map(int, input().split())

# student input
student = []
for i in range(n):
    a, b = map(int, input().split())
    student.append([a, b])

# check point input
check = []
for j in range(m):
    c, d = map(int, input().split())
    check.append([c, d])

# calc
for s in student:
    distance = 10e9
    near = 0
    for index, k in enumerate(check):
        v = math.fabs(s[0] - k[0]) + math.fabs(s[1] - k[1])
        if v < distance:
            distance = v
            near = index + 1
    print(near)


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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    int res = 0;
    rep(i, N) {
        cin >> m[i];
        X -= m[i];
        res++;
    }

    sort(m.begin(), m.end());
    while(X-m[0] >= 0) {
        X -= m[0];
        res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Maybe
import Control.Monad
import Data.Function (fix)
import Data.Array (Array, array, (!))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt

data Tree a = Tree (Tree a) a (Tree a)

instance Functor Tree where
    fmap f (Tree l m r) = Tree (fmap f l) (f m) (fmap f r)

index :: Tree a -> Int -> a
index (Tree _ m _) 0 = m
index (Tree l _ r) n = case (n - 1) `divMod` 2 of
    (q,0) -> index l q
    (q,1) -> index r q

nats :: Tree Int
nats = go 0 1
    where go !n !s = Tree (go l s') n (go r s')
            where l = n + s
                  r = l + s
                  s' = s * 2

memo :: (Int -> a) -> (Int -> a)
memo f = index cached
    where cached = fmap f nats

memo2 :: (Int -> Int -> a) -> (Int -> Int -> a)
memo2 f = memo (\x -> memo (f x))

memo3 :: (Int -> Int -> Int -> a) -> (Int -> Int -> Int -> a)
memo3 f = memo (\x -> memo2 (f x))

solve :: [Int] -> Int
solve (x:xs)
    | x == 0 = 1 + min (go 1 xs) (go (-1) xs)
    | x > 0 = min (x + 1 + go (-1) xs) (go x xs)
    | x < 0 = min (-x + 1 + go 1 xs) (go x xs)
    where go _ [] = 0
          go sum (x:xs)
            | sum < 0 = let k = max 0 (1-sum-x) in k + go (sum+x+k) xs
            | sum > 0 = let k = max 0 (sum+x+1) in k + go (sum+x-k) xs

main :: IO ()
main = do
    getInts
    arr <- getInts
    print $ solve arr

Measured memory_bytes: 11644
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

	int a,b,c;
	
	cin >> a >> b >> c;
	
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a==5&&b==5&&c==7) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//






ll h[100010];
ll dp[100010];

int main(){
        ll n;
        cin >> n;
        for(int i = 1; i <= n; i++) cin >> h[i];

        dp[1] = 0;
        for(int i = 2; i <= n; i++)
        {
                dp[i] = dp[i-1] + abs(h[i]- h[i-1]);
                if(i >= 3){
                        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
                }
        }

        cout << dp[n] << endl;
        return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>

#define MOD 1000000007

using namespace std;

typedef long long LL;

const int MAXN = 2000 + 10;
const int MAXM = MAXN * MAXN;

int N, K;

LL fact[MAXM]= {0}, invfact[MAXM]= {0};
void init () {
	fact[0] = fact[1] = invfact[0] = invfact[1] = 1;
	for (int i = 2; i <= N * K; i ++) {
		fact[i] = fact[i - 1] * i % MOD;
		invfact[i] = (MOD - MOD / i) * invfact[MOD % i] % MOD;
	}
	for (int i = 1; i <= N * K; i ++)
		invfact[i] = invfact[i - 1] * invfact[i] % MOD;
}
inline LL C (int n, int m) {
  	if (n < 0) return 0;
	if (m == 0) return 1;
	return fact[n] * invfact[m] % MOD * invfact[n - m] % MOD;
}

LL f[MAXN][MAXN]= {0};

int main () {
	scanf ("%d%d", & N, & K);
	if (K == 1) {
		puts ("1");
		return 0;
	}
	init ();
	f[0][0] = 1;
	for (int i = 1; i <= N; i ++)
		for (int j = 0; j <= i; j ++) {
			LL delta = f[i][j - 1] * (N - j + 1) % MOD * C (N * K - i - (K - 1) * (j - 1) - 1, K - 2) % MOD;
			if (j == 0) delta = 0;
			f[i][j] = (f[i][j] + f[i - 1][j] + delta) % MOD;
		}
	cout << f[N][N] << endl;

	return 0;
}

/*
2 2
*/

/*
3 1
*/

/*
2 3
*/

/*
2000 2000
*/

Measured memory_bytes: 93184
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, A, B, C, D;
char s[200200];
bool dp[200200], ep[200200];

signed main(){
    cin >> N >> A >> B >> C >> D;
    cin >> s;
    dp[A] = true;
    for(int i = 1; i <= N; i++){
        if(s[i - 1] == '.' && s[i] == '.'){
            dp[i + 1] |= dp[i];
        }
        if(s[i - 1] == '.' && s[i + 1] == '.'){
            dp[i + 2] |= dp[i];
        }
    }
    
    ep[B] = true;
    for(int i = 1; i <= N; i++){
        if(s[i - 1] == '.' && s[i] == '.'){
            ep[i + 1] |= ep[i];
        }
        if(s[i - 1] == '.' && s[i + 1] == '.'){
            ep[i + 2] |= ep[i];
        }
    }
    bool flag = false;
    if(D < C){
        for(int i = B; i <= D; i++){
            if(ep[i]){
                if(dp[i - 1] && dp[i + 1]){
                    flag = true;
                }
            }
        }
    }
    else flag = true;

    if(dp[C] && ep[D] && flag){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return 0;
}

/*

*/

Measured memory_bytes: 768
import sys

sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def dfs(n, d):
    if depth[n] != -1:
        return
    depth[n] = d
    for nn in eAB[n]:
        dfs(nn, d + 1)
    return


N = int(input())
AB = [inpl() for i in range(N - 1)]

eAB = [[] for i in range(N)]
for a, b in AB:
    eAB[a - 1].append(b - 1)
    eAB[b - 1].append(a - 1)

depth = [-1 for i in range(N)]

dfs(0, 0)

eo = [[], []]
for i in range(N):
    eo[depth[i] % 2].append(i)

# print(eo)
ans = [-1 for i in range(N)]
if len(eo[0]) > N // 3 and len(eo[1]) > N // 3:
    for i in range(N // 3):
        ans[eo[0][i]] = 3 * i + 1
        ans[eo[1][i]] = 3 * i + 2
    t_0 = N // 3
    t_1 = N // 3
    if N % 3 > 0:
        ans[eo[0][N // 3]] = 3 * (N // 3) + 1
        t_0 += 1
    if N % 3 > 1:
        ans[eo[1][N // 3]] = 3 * (N // 3) + 2
        t_1 += 1
    # print(ans)
    for i, v in enumerate(eo[0][t_0:] + eo[1][t_1:]):
        ans[v] = 3 * (i + 1)
else:
    if len(eo[0]) <= N // 3:
        ni = 0
    else:
        ni = 1
    tmp = [True for i in range(N + 1)]
    for i in range(len(eo[ni])):
        ans[eo[ni][i]] = 3 * (i + 1)
        tmp[3 * (i + 1)] = False
    tmp = [i for i, t in enumerate(tmp) if t is True]
    j = 1
    for i in range(N):
        if ans[i] != -1:
            continue
        ans[i] = tmp[j]
        j += 1

print(" ".join(list(map(str, ans))))


Measured memory_bytes: 207372
//Practice more and more
//learn for better
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define ALL(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
	ll a,b,n,m,t,i,j,p,k,x,l,d;
	string str;
	cin>>n;
	while(n!=0)
	{
	if(n%26==0){
		str+='z';
	n=n/26-1;	
	}
	else{
		str+=(char)(n%26+96);
		n/=26;
	}
	}
reverse(ALL(str));
cout<<str<<endl;
str="\0";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD             1000000007
#define INF             1e18
#define endl "\n"
#define lli long long int


void radib()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main(){
	radib();
	lli k;
	cin>>k;
	lli a,b;
	cin>>a>>b;
	if(a%k==0 || b%k==0){
		cout<<"OK";
	}
	else if(b>=k*(a/k)+k){
		cout<<"OK";
	}
	else{
		cout<<"NG";
	}
	return 0;
}

Measured memory_bytes: 3652
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: u64,
        av: [u64; n],
    }

    let digits = 64 - k.leading_zeros();
    // println!("{:?}", digits);

    let mut zero_or_one_count = vec![(0, 0); digits as usize];
    for &a in &av {
        for i in 0..digits {
            if (a >> i) & 1 == 0 {
                zero_or_one_count[i as usize].0 += 1;
            } else {
                zero_or_one_count[i as usize].1 += 1;
            }
        }
    }

    let mut x = 0u64;
    for (i, &(zero, one)) in zero_or_one_count.iter().enumerate().rev() {
        x = if zero > one {
            let new_x = 1 << i | x;

            if new_x <= k {
                new_x
            } else {
                x
            }
        } else {
            x
        };
    }

    let mut answer = 0;
    for &a in &av {
        answer += a ^ x;
    }
    println!("{}", answer);
}


Measured memory_bytes: 4352
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????\?????????

N ??????????´????????????°??? A ????????????????????????????????\????????????????????°????????????????????????????????????

1 insertionSort(A, N) // N??????????´??????????0-?????????????????????A
2   for i ??? 1 ?????? N-1 ?????§
3     v = A[i]
4     j = i - 1
5     while j >= 0 ?????? A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v

????????????????????????????????¢?????´????????????????£??????????????????????
??¢?????´??????????????????????¢???????????????????????¨??????????????????§?????????
?????\?????´??????????????¨?????? i ??????????????????????????´?????????????????????????????????????????????

"""

def iSort(A,N):
    """ ?????\????????? """
    print(" ".join(map(str,A)))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >=0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str,A)))

# ?????????
num = int(input().strip())
arr = list(map(int,input().strip().split()))
iSort(arr,num)

Measured memory_bytes: 7772
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n1 = scn.nextInt();
		int n2 = scn.nextInt();
		int n3 = scn.nextInt();
		System.out.println((n1+n2)*n3/2);
		scn.close();
	}
}

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

int main() {
cout<<fixed<<setprecision(10);

 int K;
 cin >>K;
 ll sum=0;
 for (int i=1; i<K+1;i++){
    for (int j=1; j<K+1;j++){
        for (int l=1; l<K+1;l++){
            sum += gcd(gcd(i,j),l);
        }
    }
 }    
 cout << sum;          
	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    int N;
    cin >> N;
    int P[N];
    int ans = 1;
    cin >> P[0];
    int min_num = P[0];
    for (int i=1; i<N; i++){
        cin >> P[i];
        if (P[i] < min_num){
            ans++;
        }
        min_num = min(min_num, P[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=1e5+5;
vector<int> G[maxn],order;
int n,a,b,known[maxn],val[maxn],l[maxn],r[maxn],k,used[maxn],known_parity[maxn][2],shit,par[maxn],ans[maxn];
void dfs(int v)
{
	used[v]=1;
	l[v]=-1e9;
	r[v]=1e9;
	for (int i=0;i<G[v].size();i++)
	{
		int to=G[v][i];
		if(used[to]) continue;
		dfs(to);
		par[to] = v;
		if(known_parity[to][0]) known_parity[v][1]=1;
		if(known_parity[to][1]) known_parity[v][0]=1;
		l[v]=max(l[v],l[to]-1);
		r[v]=min(r[v],r[to]+1);
	}
	if(known[v]==1)
	{
		l[v]=max(l[v],val[v]);
		r[v]=min(r[v],val[v]);
		known_parity[v][val[v]%2]=1;
	}
	if(known_parity[v][0] == 1 && known_parity[v][1] == 1) shit=1;
	if(l[v] > r[v]) shit = 1;
	order.pb(v);
}
int solve_val(int v,int par)
{
	if(par == 0) return l[v];
	l[v] = max(l[v],ans[par] - 1);
	r[v] = max(r[v],ans[par] + 1);
	while(l[v] % 2 == ans[par] % 2) ++l[v];
	return l[v];
}
int main(int argc, char const *argv[])
{
	cin>>n;
	for (int i=1;i<=n-1;i++)
	{
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cin>>k;
	for(int i = 1;i <= k; ++i)
	{
		cin>>a>>b;
		known[a] = 1;
		val[a] = b;
	}
	dfs(1);
	if(shit)
	{
		cout<<"No\n";
		return 0;
	}
	reverse(order.begin(),order.end());
	printf("Yes\n");
	for(int i = 0;i < order.size(); ++i)
	{
		int v = order[i];
		ans[v] = solve_val(v,par[v]);
	}
	for (int i=1;i<=n;i++)
	{
		cout<<ans[i];
		if (i!=n) cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 15096