akhauriyash/Code-Regression huggingface dataset:
import copy
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
S_result = [[0]*(W+2) for _ in range(H+2)]

dx = [-1,-1,-1,0,0,1,1,1]
dy = [-1,0,1,-1,1,-1,0,1]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            for x,y in zip(dx,dy):
                if S_result[i+y+1][j+x+1] != "#":
                    S_result[i+y+1][j+x+1] += 1
            S_result[i+1][j+1] = "#"
            
for h in S_result[1:H+1]:
    print("".join(map(str, h[1:W+1])))

Measured memory_bytes: 3572
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<Integer> stack = new ArrayList<Integer>();
	static int top_index = -1;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] input = sc.nextLine().split(" ");

		for(int i = 0; i < input.length; i++) {
			if(isNumber(input[i])) {
				push(input[i]);
			}else {
				int b = pop();
				int a = pop();
				switch(input[i]) {
				case "+":
					push(a + b);
					break;
				case "-":
					push(a - b);
					break;
				case "*":
					push(a * b);
					break;
				case "/":
					push(a / b);
					break;
				default:
					System.out.println("予期せぬ値が含まれています。");
					break;
				}
			}
		}

		System.out.println(stack.get(0));
		sc.close();
	}

	public static void push(String num) {
		int n = Integer.parseInt(num);
		stack.add(n);
		top_index ++;
	}

	public static void push(int num) {
		stack.add(num);
		top_index ++;
	}

	public static int pop() {
		int n = stack.get(top_index);
		stack.remove(top_index);
		top_index --;
		return n;
	}

	// 文字列numが数値かどうか
	public static boolean isNumber(String num) {
		try {
			Integer.parseInt(num);
			return true;
		}catch(NumberFormatException e) {
			return false;
		}
	}
}


Measured memory_bytes: 26332
using System;
using System.Linq;
using System.Text;

namespace AtCoder {
  class Program {
    static void Main(string[] args) {
      var first = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).ToArray();
      var N = first[0];
      var M = first[1];
      var X = first[2];
      var C = new int[N];
      var A = new int[N][];
      for (int i = 0; i < N; i++) { 
        var line = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s));
        C[i] = line.First();
        A[i] = line.Skip(1).ToArray();
        if (A[i].Length != M) return;
      }
      var minCost = C.Sum();
      var isFound = false;

      var understand = new int[M];
      for (uint bit = 0; bit < (1<<N); bit++) {
        for (int i = 0; i < M; i++) understand[i] = 0; // Init
        var cost = 0;
        for (int i = 0; i < N; i++) {
          if( ((bit >> i) & 1) == 1 ) {
            cost += C[i];
            for (int j = 0; j < M; j++) {
              understand[j] += A[i][j];
            }
          }
        }
        if (understand.All(i => i >= X) && cost <= minCost) {
          minCost = cost;
          isFound = true;
        }
      }

      if (isFound) {
        Console.WriteLine(minCost);
      } else {
        Console.WriteLine(-1);
      }
    }
  }
}


Measured memory_bytes: 28444
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());

int main() {
ll n;
cin >> n;
ll h[n];
ll cnt=0;
ll cmax=0;
REP(i,n) {
  cin >> h[i];
  if(i>0&&h[i-1]>=h[i]) {
    cnt++;
  } else {
    cnt=0;
  }
  cmax=max(cmax,cnt);
}
cout << cmax << endl;
return 0;
}


Measured memory_bytes: 1024
var a:array[0..200001] of longint;
    n,i:longint;p:boolean;
procedure sort(l,r:longint);
var
 i,j,t,mid:longint;
begin
 i:=l;j:=r;mid:=a[(i+j) div 2];
 repeat
  while a[i]<mid do inc(i);
  while a[j]>mid do dec(j);
  if i<=j then
   begin
    t:=a[i];a[i]:=a[j];a[j]:=t;
    inc(i);dec(j);
   end;
 until i>j;
 if i<r then sort(i,r);
 if j>l then sort(l,j);
end;
begin
 readln(n);
 for i:=1 to n do read(a[i]);
 sort(1,n);
 p:=false;
 for i:=2 to n do if a[i]=a[i-1] then p:=true;
 if p then writeln('NO')
  else writeln('YES');
end.

Measured memory_bytes: 896
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int mod=1e9+7;
int n,k;
long long ans;

inline int modpow(int x,int y,int res=1) {
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}
int vis[1000005],mui[1000005],prime[1000005],cnt;
inline void _pre_mui() {
    mui[1]=1;
    for(int i=2;i<=k;++i) {
        if(!vis[i]) prime[++cnt]=i,mui[i]=-1;
        for(int j=1;j<=cnt;++j) {
            if(i*prime[j]>k) break;
            vis[i*prime[j]]=1;
            if(!(i%prime[j])) {mui[i*prime[j]]=0;break;}
            else mui[i*prime[j]]=-mui[i];
        }
    }
}

int main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	//IN(n),IN(k);
	_pre_mui();
	for(int x=1;x<=k;++x) 
	{
		int res=modpow(k/x,n); /*次数*/
		for(int t=2;x*t<=k;++t)
			(res+=1ll*mui[t]*modpow(k/(x*t),n)%mod)%=mod;
		(ans+=1ll*res*x%mod)%=mod; /*贡献*/
	}
	printf("%lld\n",ans);
	return 0;
	//return printf("%d\n",ans),0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    string s, t;
    cin >> s >> t;
    if (s == t.substr(0, s.size())) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,k;
  cin >> n >> k;
  vector<int> data(n);
  for ( int64_t i = 0 ; i < n ; i++ ) {
    cin >> data.at(i);
  }
  int64_t recorda,recordb,recordc;
  vector<int> a(n,0);
  int64_t x = data.at(0);
  for ( int64_t i = 0 ; i < n ; i++ ) {
    if (a.at(data.at(x-1)-1)==1){
       recorda=data.at(x-1);
       recordb=i+2;
      break;
    }
    a.at(data.at(x-1)-1)=1;
    x=data.at(x-1);
  }
  
  int64_t y = data.at(recorda-1);
  for ( int64_t i = 0 ; i < n ; i++ ) {
    if (y == recorda){
       recordc = i+1;
      break;
    }
    y = data.at(y-1);
  }
  
if(recordc!=n){
  if (recordb>=k){
    int64_t z = data.at(0);
    for ( int64_t i = 0 ; i < k-1 ; i++ ) {
      
      z=data.at(z-1);  
    }
    cout << z << endl;
  }
  else {
    int64_t amari = (k-recordb)%recordc;
    int64_t z = data.at(recorda-1);
    if(amari==0){
      cout << recorda << endl;
    }
    else{
    for ( int64_t i = 0 ; i < amari-1 ; i++ ) {
      z=data.at(z-1);
    }
    cout << z << endl;
    //cout << amari <<recorda<< recordb << recordc<< endl;
    }
  }
}
else {
  int64_t amari = k%n;
  int64_t z = data.at(0);
  if(amari==0){
    cout << data.at(0) << endl;
  }
  else{
  for ( int i = 0 ; i < amari-1 ; i++ ) {
    z = data.at(z-1);
  }
  cout << z << endl;
  }
  }  
 
}

Measured memory_bytes: 4792
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
X=sorted(X,key=lambda x:x[1])
s=0
t=0
for i in range(N):
  s+=X[i][0]
  if s>X[i][1]:
    print("No")
    break
  else:
    t+=1
if t==N:
  print("Yes")

Measured memory_bytes: 55264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e933
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;
    cin>>n;
    set<int> st;
    int high=0;
    rep(i,0,n){
        int x; cin>>x;
        if(x>=3200)high++;
        else {
        rep(i,0,8){
            if(i+399*i<=x&&x<=399+i+399*i){
                st.insert(i);
                break;
            }
        }
        }
    }
    if(st.empty())cout<<1<<" "<<high<<endl;
    else cout<<st.size()<<" "<<st.size()+high<<endl;
    return 0;
}


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

int main()
{
  int a,b,c,d,e,k;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  cin >> k;
  if(e - a > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  
  return 0;
}

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

using namespace std;
string s[100005];
int n,l; 
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++)
	{
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <unordered_set>
#include <cmath>
// #include <prettyprint.hpp>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;++i)
#define repi(i,n) for(ll i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define slf(n) scanf("%lf", &n);
typedef long long ll;
typedef double lf;
const double PI=3.14159265358979323846;
static const ll max_n = 100010;
static const ll mod = 1000000007;
static const ll max_value = 100000000000100;
// vector<ll> height(max_n, -1);
// vector<pair<ll,ll>> edge_list(max_n);

ll N, M, Q;


void Main(){
    // bool is_ok = true;
    // printf("------------- V=%lld---------\n", V);
    ll A;
    string B;
    sll(A);
    cin >> B;

    ll b1 = B[2] - '0';
    ll b2 = B[3] - '0';


    ll deciaml_b = b1 * 10 + b2;
    // cout << deciaml_b <<endl;
    ll int_b = B[0] - '0';
    // // ll int_b = B;
    // // deciaml_b = deciaml_b % 100;
    // // cout << "B = " << B << ", "<< B / 1<< ", decimal b " << deciaml_b <<endl;
    // // cout << "A * decimal b = " << A * deciaml_b <<endl; 
    ll ans = A * int_b + (A * deciaml_b) / 100;
    // ll ans = floor(A * B);

    cout <<  ans <<endl;

}

int main(){
    Main();

    return 0;
}

Measured memory_bytes: 3268
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))

ll a[99],x[99],y[99];
ll ans;
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",a+i);
	
	ll M=-INF,m=INF,Mi,mi;
	rep(i,0,n){
		if(a[i]>M){
			M=a[i];
			Mi=i;
		}
		if(a[i]<m){
			m=a[i];
			mi=i;
		}
	}
	if(M>0&&m<0){
		if(M>=-m)rep(i,0,n){x[ans]=Mi;y[ans]=i;ans++;m+=M;}//全部0以上にする
		else rep(i,0,n){x[ans]=mi;y[ans]=i;ans++;M+=m;}//全部0以下にする
	}
	
	//累積和をとる
	if(m>=0)rep(i,1,n){x[ans]=i-1;y[ans]=i;ans++;}//全部0以上のとき
	else for(int i=n-1;i>=1;i--){x[ans]=i;y[ans]=i-1;ans++;}//全部0以下のとき
	
	printf("%lld\n",ans);
	rep(i,0,ans)printf("%lld %lld\n",x[i]+1,y[i]+1);
	return 0;
}

Measured memory_bytes: 128
from operator import itemgetter

N = int(input())
reds = []
for i in range(N):
    a,b = map(int, input().split())
    reds.append((a,b))
blues = []
for i in range(N):
    a,b = map(int, input().split())
    blues.append((a,b))

# reds = sorted(reds,key=itemgetter(0,1),reverse=True)
# blues = sorted(blues,key=itemgetter(1))
# blues = sorted(blues,reverse=True)


cnt = 0
from collections import defaultdict
edges = defaultdict(list)
for i,(c,d) in enumerate(blues):
    for j,(a,b) in enumerate(reds):
        if c > a and d > b:
            edges[i].append(j+N)
            edges[j+N].append(i)
            
            
# print(edges)
def dfs(v, visited):
    """
    :param v: X側の未マッチングの頂点の1つ
    :param visited: 空のsetを渡す（外部からの呼び出し時）
    :return: 増大路が見つかればTrue
    """
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False
 
 
# 標準入力からのグラフ読み取り
# xn, yn, e = map(int, input().split())
# edges = [set() for _ in range(xn)]
matched = [-1] * 2*N
 
# for _ in range(e):
#     x, y = map(int, input().split())
#     edges[x].add(y)
# 増大路発見に成功したらTrue(=1)。合計することでマッチング数となる
print(sum(dfs(s, set()) for s in range(N)))

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		if(a.equals("H") && b.equals("H")) {
			System.out.println("H");

		}else if(a.equals("H")&& b.equals("D")) {
			System.out.println("D");
		}else if(a.equals("D")&& b.equals("H")) {
			System.out.println("D");
		}else {
			System.out.println("H");
		}
	}

}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int64_t gcd(int64_t p, int64_t q)
{
    if (p < q)
        swap(p, q);

    if (p % q == 0)
        return q;
    else
        return gcd(q, p % q);
}

int main()
{
    int N, X, p, q, ans;
    cin >> N >> X;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (i == 0)
            ans = abs(X - tmp);
        else
            ans = gcd(ans, abs(X - tmp));
    }
    cout << ans;
}

Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
ll tot=0;
tot=n/100;
ll z=n%100;
ll cnt=0;
while((z-5)>=0)
{
    z=z-5;
    cnt++;
}
while((z-4)>=0)
{
    z=z-4;
    cnt++;
}
while((z-3)>=0)
{
    z=z-3;
    cnt++;
}
while((z-2)>=0)
{
    z=z-2;
    cnt++;
}
while((z-1)>=0)
{
    z=z-1;
    cnt++;
}
if(cnt>tot)
{
    cout<<0<<endl;
}else
{
    cout<<1<<endl;
}


return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
dp=[False]*(n+1)
c=["dream","dreamer","erase","eraser"]
if s[:5] in c:
    dp[5]=True
if s[:6] in c:
    dp[6]=True
if s[:7] in c:
    dp[7]=True
for i in range(n+1):
    if dp[i]:
        l=""
        if i+5<=n:
            for idx in range(5):
                l+=s[i+idx]
            if l in c:
                dp[i+5]=True
        if i+6<=n:
            l+=s[i+5]
            if l in c:
                dp[i+6]=True
        if i+7<=n:
            l+=s[i+6]
            if l in c:
                dp[i+7]=True
#print(dp)
if dp[n]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9736
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
int head[100010],net[100010*2],to[100010*2];
long long val[100010*2],dis[100010];
int n,m,k,tot;
int deep[100010],fa[100010][21];
void add(int x,int y,long long c)
{
    net[++tot]=head[x],head[x]=tot,to[tot]=y,val[tot]=c;
}
void dfs(int x)
{
    deep[x]=deep[fa[x][0]]+1;
    for(int i=1;fa[x][i-1];i++)
        fa[x][i]=fa[fa[x][i-1]][i-1];
    for(int i=head[x];i;i=net[i])
        if(to[i]!=fa[x][0])
            fa[to[i]][0]=x,dis[to[i]]=dis[x]+val[i],dfs(to[i]);
}
int lca(int x,int y)
{
    if(deep[x]<deep[y]) swap(x,y);
    int temp=20;
    while(temp>=0)
    {
        if(deep[fa[x][temp]]>=deep[y]) x=fa[x][temp];
        temp--;
    }
    temp=20;
    if(x==y) return x;
    while(temp>=0)
    {
        if(fa[x][temp]!=fa[y][temp]) 
            x=fa[x][temp],y=fa[y][temp];
        temp--;
    }
    return fa[x][0];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int x,y;
        long long c;
        scanf("%d%d%lld",&x,&y,&c);
        add(x,y,c),add(y,x,c);
    }
    dfs(1);
    scanf("%d%d",&m,&k);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        int lc=lca(x,k);
        long long sum=0;
        sum+=dis[x]+dis[k]-2*dis[lc];
        lc=lca(y,k);
        sum+=dis[y]+dis[k]-2*dis[lc];
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 19328
#include<iostream>
#include<string>
using namespace std;
struct Dice
{
    int s[6];
    void roll(char c)
    {


    int b;
    if(c=='E')
    {
        b=s[0];
        s[0]=s[3];
        s[3]=s[5];
        s[5]=s[2];
        s[2]=b;
    }
    if(c=='W')
    {
        b=s[0];
        s[0]=s[2];
        s[2]=s[5];
        s[5]=s[3];
        s[3]=b;
    }
    if(c=='N')
    {
        b=s[0];
        s[0]=s[1];
        s[1]=s[5];
        s[5]=s[4];
        s[4]=b;
    }
    if(c=='S')
    {
        b=s[0];
        s[0]=s[4];
        s[4]=s[5];
        s[5]=s[1];
        s[1]=b;
    }
    if(c=='R')//这是什么鬼东西，怎么还有往右的
    {
        b=s[1];
        s[1]=s[2];
        s[2]=s[4];
        s[4]=s[3];
        s[3]=b;
    }
    }
    int top()
    {
        return s[0];
    }
    int right()
    {
        return s[2];
    }
    int left()
    {
        return s[3];
    }
    int front ()
    {
        return s[1];
    }
};
bool same(Dice a,Dice b)
{
    for(int i=0;i<6;i++)
        if (a.s[i]!=b.s[i])
        return false;
    return true;

}
int main()
{


    Dice d[2];
    for (int j=0;j<2;j++)
        for(int i=0;i<6;i++)
        cin>>d[j].s[i];
    bool f=false;

    for(int i=0;i<4;i++)
    {
        d[1].roll('R');
        for(int j=0;j<4;j++)
        {
            d[1].roll('N');
            if(same(d[0],d[1]))  f=true;
        }
    }
    d[1].roll('E');
    for(int j=0;j<4;j++)
    {
        d[1].roll('N');
        if(same(d[0],d[1]))  f=true;
    }

    d[1].roll('W');
    d[1].roll('W');
    for(int j=0;j<4;j++)
    {
        d[1].roll('N');
    if(same(d[0],d[1])) f=true;
    }
    cout <<(f?"Yes":"No")<<endl;
    return 0;

}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c,d,cnt,maxi;
string str;
int main()
{
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	cin>>str;
	str+='#'; 
	for(int i=a-1;i<c;i++)
	{
		if(str[i]=='#') cnt++;
		else cnt=0;
		if(cnt==2)
		{
			printf("No");
			return 0;
		}
	}
	cnt=0;
	for(int i=b-1;i<d;i++)
	{
		if(str[i]=='#') cnt++;
		else cnt=0;
		if(cnt==2)
		{
			printf("No");
			return 0;
		}
	}
	cnt=0;
	if(c<d)
	{
		printf("Yes");
		return 0;
	}
	for(int i=b-1;i<=d;i++)
	{
		if(str[i]=='.') cnt++;
		else cnt=0;
		maxi=max(maxi,cnt);
	}
	if(str[b-2]=='.'&&str[b]=='.') maxi=3;
	if(maxi<=2)
		printf("No");
	else printf("Yes");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll h,w;
  int a;
  string s[30][30];
  cin >> h >> w;
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      a=j;
      if(s[i][j]=="snuke")printf("%c%lld",'A'+a,i+1);
    }
  }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val (N, A, B) = readLine()!!.split(" ").map { s -> s.toInt() }
    val v = readLine()!!.split(" ").map { s -> s.toLong() }.toLongArray()

    v.sort()
    v.reverse()

    var sum = 0L
    for (i in 0 until A) {
        sum += v[i]
    }

    System.out.printf("%1.10f\n", sum.toDouble() / A)

    val a = v.indexOfFirst { n -> n == v[(A-1)] }
    val b = v.indexOfLast { n -> n == v[(A-1)] }
    val m = b - a + 1;

    val comb = Array(60) { Array<Long>(60) {0L} }

    comb[0][0] = 1
    for (i in 1 until 60) {
        comb[i][0] = 1
        for(j in 1..i) {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j]
        }
    }

    var res = 0L
    if (v[0] == v[A - 1]) {
        for (i in A..B) {
            if (v[(i - 1)] != v[(A - 1)]) {
                continue
            }

            res += comb[m][(i - a)]
        }
    } else {
        res += comb[m][A - a]
    }

    println(res)
}

Measured memory_bytes: 36400
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C - Many Formulas
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

ll sums[MAX_N + 1], cs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  string s;
  cin >> s;
  int n = s.size();

  cs[0] = 1;
  for (int i = 1; i <= n; i++) {
    ll d = 0, t = 1;
    for (int j = i - 1; j >= 0; j--) {
      d += (s[j] - '0') * t;
      sums[i] += sums[j] + cs[j] * d;
      cs[i] += cs[j];
      //printf("%d-%d: %lld -> %lld\n", j, i, d, sums[j] + d);
      t *= 10;
    }
  }

  printf("%lld\n", sums[n]);
  return 0;
}


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

int a,b;

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

int main(){
  	scanf("%d%d",&a,&b);
  	if ( a == b ) printf("%d\n",a+b);
  	else printf("%d\n",max(a,b) * 2 - 1 );
	return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
tmp = 2 
alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans = deque()
len1 = 0
for i in range(1,100):
    if (n <= 26 ** i):
        len1 = i
        break
    else:
        n = n - 26**i

n = n -1
for i in range(len1):
    tmp = n % 26
    ans.appendleft(alpha[tmp])
    n = int(n / 26)


for i in range(len(ans)):
    print(ans.popleft(),end ="")


Measured memory_bytes: 9364
#include <stdio.h>

int main()
{
  int x,y,d;

  scanf("%d%d", &x, &y);
  while(1){
    if( y==0 )break;
    d = x%y;
    x = y;
    y = d;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

struct WF {
    int n;
    static const long long INF = 1ll << 60;
    vector<vector<long long>> d;
    WF(int _n) :n(_n), d(_n, vector<long long>(_n, INF)) {
        rep(i, n) d[i][i] = 0;
    }
    void add_edge(int u, int v, long long w) {
        d[u][v] = w;
    }
    void calc() {
        for (int k = 0; k<n; ++k) for (int u = 0; u<n; ++u) for (int v = 0; v<n; ++v)
            if (d[u][k] != INF&&d[k][v] != INF)
                d[u][v] = min(d[u][v], d[u][k] + d[k][v]);
    }
    bool has_negative_cycle() {
        rep(i, n) if (d[i][i]<0) return 1;
        return 0;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, R;
    cin >> N >> M >> R;
    vi r(R);
    rep(i, R) {
        cin >> r[i];
        --r[i];
    }
    WF wf(N);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        wf.add_edge(a, b, c);
        wf.add_edge(b, a, c);
    }
    wf.calc();

    const ll INF = LLONG_MAX / 3;

    ll ans = INF;
    sort(all(r));
    do {
        ll x = 0;
        rep(i, R - 1)x += wf.d[r[i]][r[i + 1]];
        smin(ans, x);
    } while (next_permutation(all(r)));
    cout << ans << endl;
}


Measured memory_bytes: 640
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int cnt[200000+20];
int main(){
	fastio;
	int n;
	cin>>n;
	int a[200000+20];
	rb(i,1,n) cin>>a[i],cnt[a[i]]++;
	LL res=0;
	rb(i,1,n){
		if(cnt[i]>=2){
			res+=(LL)cnt[i]*(cnt[i]-1)/2;		
		}
	}
	rb(i,1,n){
		cout<<res-(cnt[a[i]]-1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int H, W;

int main() {
    cin >> H >> W;
    vector<vector<int>> a(H + 1, vector<int>(W + 1));
    vector<vector<int>> b(H + 1, vector<int>(W + 1, 0));
    for(int i = 0; i < W + 1; i++){
        a.at(H).at(i) = 1;
    }
    for(int j = 0; j < H; j++){
        string str;
        cin >> str;
        a.at(j).at(W) = 1;
        for(int i = 0; i < W; i++){
            if(str.at(i) == '.')
                a.at(j).at(i) = 0;
            else
                a.at(j).at(i) = 1;
        }
    }

    //横方向
    for(int j = 0; j < H; j++){
        int prev = 1;
        int start = 0;
        for(int i = 0; i < W + 1; i++){
            if (a.at(j).at(i) == 0){
                if(prev == 1){
                    start = i;
                    prev = 0;
                }
            }else{
                if(prev == 0){
                    int num = i - start;
                    for(int k = start; k < i; k++){
                        b.at(j).at(k) = num;
                    }
                    prev = 1;
                }
            }
        }
    }

    //縦方向
    for(int i = 0; i < W; i++){
        int prev = 1;
        int start = 0;
        for(int j = 0; j < H + 1; j++){
            if (a.at(j).at(i) == 0){
                if(prev == 1){
                    start = j;
                    prev = 0;
                }
            }else{
                if(prev == 0){
                    int num = j - start;
                    for(int k = start; k < j; k++){
                        b.at(k).at(i) += num - 1;
                    }
                    prev = 1;
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < H; j++){
        int m1 = *max_element(b.at(j).begin(), b.at(j).end());
        ans = max(ans, m1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 31616
#include<iostream>
#include<cstdio>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
using namespace std;
typedef pair<int,int> ii;
ii p[200];
int n;

void solve()
{
  int M[n+1][n+1];
  rep(i,n+1)rep(j,n+1)M[i][j] = inf;
  rep(i,n+1)M[i][i] = 0;

  rep(j,n)
    {
      rep(i,n-j)
	{
	  REP(k,i+1,i+j+1)
	    {
	      int cost = M[i][k-1] + M[k][i+j] + p[i].first*p[k-1].second*p[k].first*p[i+j].second;
	      if(cost < M[i][i+j])
		  M[i][i+j] = cost;
	    }
	}
    }
  cout << M[0][n-1] << endl;
}

int main()
{

  while(cin >> n)
    {
      rep(i,n)cin >> p[i].first >> p[i].second;
      solve();
    }
  return 0;
}

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

int main()
{
    int h, n, a[100002];
    cin >> h >> n;
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    if(s >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, c[30], ans, fo, tw, b, foo;
int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char ch;
			cin >> ch;
			c[ch-'a']++;
		}
	}
	for(int i=0;i<26;i++){
		if((c[i]+20)%2!=0){
			b++;
		}else if((c[i]+20)%4!=0){
			tw++;
		}else{
			fo++;
		}
	}

	if((m+20)%2==0&&(n+20)%2==0){
		if(fo!=26) ans=1;	
	}else if((m+20)%2==0&&(n+20)%2!=0){
		if(b!=0) ans=1;
		if(tw>m/2) ans=1;
	}else if((m+20)%2!=0&&(n+20)%2==0){
		if(b!=0) ans=1;
		if(tw>n/2) ans=1;
	}else if((m+20)%2!=0&&(n+20)%2!=0){
		if(b!=1) ans=1;
		if(tw>(n-1+m-1)/2) ans=1;
	}


	if(ans==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    cnt = 0
    ret = 1
    for n in range(1, N+1):
        tmp = 0
        q = n
        while n % 2 == 0:
            n = n // 2
            tmp += 1
        if tmp > cnt:
            ret = q
            cnt = tmp

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include <stdio.h>
#define MAX 100
#define INF 1000000
#define NIL -1

void prim();

int n;
int a[MAX][MAX];
int key[MAX];
int p[MAX];

int main(){
  int i, j, cnt=0;
  scanf("%d",&n);

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

  prim();
  for(i=0; i<n; i++) cnt+=key[i];
  printf("%d\n",cnt);

  return 0;
}


void prim(){
  int u, c, b, flag[MAX], min, i;

  for(u=0; u<n; u++){
    key[u]=INF;
    p[u]=NIL;
    flag[u]=0;
  }

  key[0]=0;

  for(b=0;b<n; b++){

    min = INF;
    for ( i = 0; i < n; i++ ){
      if(flag[i]==1) continue;
      if(key[i]<=min){
        min=key[i];
        u=i;
      }
    }

    for(c=0; c<n; c++){
      if(flag[c]==1) continue;
      if(a[u][c]==-1) continue;
      if(a[u][c]<key[c]){
        key[c]=a[u][c];
        p[c]=u;
      }
    }
    flag[u]=1;
  }
}



Measured memory_bytes: 2048
#include<iostream>

using namespace std;
int main(){
int n,m,cade[201],h,wake[201],wa[201],k=0,c1=0,c2=0;
cin >> n >> m ;
for(int i=0;i<2*n;i++){cade[i]=i+1;}
for(int i=0;i<m;i++){
        k=0;
        c1=0;
        c2=0;
    cin >> h;
    if(h==0){
            for(int j=0;j<2*n;j++)
            wake[j]=cade[j];
        for(int j=0;j<2*n;j++){
            if(j%2==0){cade[j]=wake[c1];c1++;}
            else{cade[j]=wake[c2+n];c2++;}
        }
    }else{
        for(int j=0;j<n*2;j++)
        wa[j]=cade[j];
        for(int j=h;j<2*n;j++){
            cade[k]=wa[j];
            k++;
        }k=0;
        for(int j=0;j<h;j++){
            cade[2*n-h+j]=wa[j];
        }

    }
}
for(int u=0;u<2*n;u++){
    cout << cade[u] << endl;
}
return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K,Q;
    cin>>N>>K>>Q;
    int P[100001]={0},A;
    for(int i=0;i<Q;++i){
        scanf("%d",&A);
        ++P[A-1];
    }
    for(int i=0;i<N;++i){
        if(P[i]-Q+K>0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}


Measured memory_bytes: 1024
//Here I come unstoppable_N
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define booster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PB push_back
#define F first
#define S second
#define forn(i,n) for(int i=0;i<n;i++)

const int mod=1e9+7;
ll xor1_n(ll n){switch(n%4){case 0:return n;case 1:return 1;case 2:return n+1;}return 0;}
int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }
clock_t time_p=clock();
void rtime(){ time_p=clock()-time_p; cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

string all[120];
int ind=0;
void permute(string s,int l,int r)
{
	int i;
	if(l==r)
	{
		all[ind++]=s;
		//cout<<s<<"\n";
	}
	else
	{
		for(i=l;i<=r;i++)
		{
			swap(s[l],s[i]);
			permute(s,l+1,r);
			swap(s[l],s[i]);
		}
	}
}

int main()
{
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	booster;
	int t=1;
	//cin>>t;
	while(t--)
	{
		int a,b,c;
		cin>>a>>b>>c;
		if(a==b && b==c)
			cout<<"Yes";
		else cout<<"No";

	}
	rtime();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int i,n,j,k;
  int b,f,r,v;
  int p[4][3][10]={0};



  scanf("%d",&n);

  for(i =0; i <n; i++) {
    scanf("%d %d %d %d",&b,&f,&r,&v);
    p[b-1][f-1][r-1] += v;
  }

  for(k=0; k<4; k++) {
    for(j=0; j<3; j++) {
      for(i=0; i<10;i++) {
	printf(" %d",p[k][j][i]);
      }
      printf("\n");
    }
    if(k == 3){
      break;
    }
    printf("####################\n");

  }
  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

ll INF = 1001001001;

void dfs(ll v, vector<vector<LP>> es, vector<bool>& visited) {
    if (visited[v]) return;

    visited[v] = true;
    for (auto u : es[v]) {
        dfs(u.second, es, visited);
    }
}

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

    ll n, m, p;
    cin>>n>>m>>p;
    vector<vector<ll>> edge(m);
    vector<vector<LP>> es(n);
    vector<vector<LP>> rs(n);
    rep(i, m) {
        ll a, b, c;
        cin>>a>>b>>c; a--; b--;
        vector<ll> v {a, b, p - c};
        edge[i] = v;
        es[a].push_back(LP(c, b));
        rs[b].push_back(LP(c, a));
    }

    vector<ll> dist(n, INF);
    dist[0] = 0;
    vector<ll> neg;
    rep(i, n) {
        rep(j, m) {
            vector<ll> e = edge[j];
            if (dist[e[1]] > dist[e[0]] + e[2]) {
                dist[e[1]] = dist[e[0]] + e[2];
                if (i == n - 1) {
                    neg.push_back(e[1]);
                }
            }
        }
    }
    if (neg.size() == 0) {
        cout<<max(0LL, -dist[n - 1])<<endl;
        return 0;
    }

    vector<bool> from(n);
    dfs(0, es, from);
    vector<bool> to(n);
    dfs(n - 1, rs, to);
    for (auto v : neg) {
        if (from[v] && to[v]) {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<max(0LL, -dist[n - 1])<<endl;
}

Measured memory_bytes: 345088
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    1)Testcase to prove why Greedy fails
      A)4
        1 7 5 11
      Greedy approach of choosing at each step one which finds to have min |hi-hj| at a point fails here
      B)6
        1 2 10 3 0 1
     Greedy of approach of always jumping from i to i+2 so that min jumps lead to min addition of differences fails for this testcase
     
    In testcase B after handrunning bottom to top i.e right to left
    You can observe
    Optimal substructure as well as Overlapping Subproblems so Definitely Dynamic Programming
    
    State is only position
    position indicates if I start from this position what is the optimal Answer
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
int N;
int H[100005];
ll dp[100005];//long long since sum can surpass limits of int
ll recursion(int pos)//Bottom to top approach
{
    if(dp[pos]!=-1)return dp[pos];

    if(pos+2<N)
    dp[pos]=min(abs(H[pos]-H[pos+1])+recursion(pos+1),abs(H[pos]-H[pos+2])+recursion(pos+2));
    else if(pos+1<N)
        dp[pos]=abs(H[pos]-H[pos+1])+recursion(pos+1);
        else 
        dp[pos]=0;
    
    return dp[pos];
}
void solve()
{
   memset(dp,-1,sizeof(dp));
   int i;cin>>N;
   fo(i,0,N)cin>>H[i];
   
   recursion(0);
   cout<<dp[0]<<"\n";
   
   
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3840
import sys

N, M = map(int, input().split())
S = input()
tmp = 0
for i in range(N+1):
	if S[i] == '1':
		tmp += 1
		if tmp == M:
			print(-1)
			sys.exit()
	else:
		tmp = 0

ans = []

i = N
while i > M:
	ind = S[i-M:i].find('0')
	ans.append(M-ind)
	i -= M - ind

ans.append(i)

print(*ans[::-1])

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int d[11];
int main(){
    int n,k;
    cin>>n>>k;
    rep(i,k) cin>>d[i];
    sort(d,d+k);
    for(int i=n;;++i){
        int x=i;
        bool flag=true;
        while(x){
            if(binary_search(d,d+k,x%10)){
                flag=false;break;
            }
            x/=10;
        }
        if(flag){
            cout<<i<<endl;break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
// TLE???
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
#define MAX 100100
int x[MAX];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  for (int i = 0; i < MAX; i++) x[i]=0;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l,r; cin>>l>>r;
    if (l > N+1) continue;
    r=min(r,N+1);
    for (int j = l; j <= r; j++) {
      x[j]++;
    }
  }

  for (int i = N+1; i >= 2; i--) {
    if (x[i]+1 >= i) {
      cout << i-1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}



Measured memory_bytes: 3940
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
using namespace std;

void solve(){
	ll n;
	cin>>n;
	int cnt = 0;
	char c[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
		if (c[i]=='R')
		{
			cnt++;
		}
	}
	ll ans = 0;
	for (int i = 0; i < cnt; ++i)
	{
		if (c[i]=='W')
		{
			ans++;
		}
	}
	cout<<ans;
}
  
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<long long> a(n), t(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        t[i] = (n - i - 1) - a[i];
    }
    sort(t.begin(), t.end());
    long long ans = 0;
    for(int i = n - 1; i >= 0; --i){
        auto f = lower_bound(t.begin(), t.end(), a[i] + (n - 1 - i));
        auto l = upper_bound(t.begin(), t.end(), a[i] + (n - 1 - i));
        ans += l - f;
    }
    cout << ans;
}


Measured memory_bytes: 6436
N = int(input())
S = input()

memo = {}
def dp(s1, s2, l1, l2, r1, r2, i):
  #print(i, s1 + '|' +s2)
  if s1 + s2 in memo:
    return memo[s1 + s2]
  if i == 2 * N:
    ret = int(s1 == s2)
  else:
    ret = 0
    if i % 2 == 0:
      c = S[i // 2]
      # S1のl1か、S2のr2に入れる
      if s1[l1] == ' ' and (s2[l1] == ' ' or s2[l1] == c):
        ret += dp(s1[:l1] + c + s1[l1+1:], s2, l1+1, l2, r1, r2, i+1)
      if s2[r2] == ' ' and (s1[r2] == ' ' or s1[r2] == c):
        ret += dp(s1, s2[:r2] + c + s2[r2+1:], l1, l2, r1, r2-1, i+1)
    else:
      c = S[-(i // 2 + 1)]
      # S2のl2か、S1のr1に入れる
      if s1[r1] == ' ' and (s2[r1] == ' ' or s2[r1] == c):
        ret += dp(s1[:r1] + c + s1[r1+1:], s2, l1, l2, r1-1, r2, i+1)
      if s2[l2] == ' ' and (s1[l2] == ' ' or s1[l2] == c):
        ret += dp(s1, s2[:l2] + c + s2[l2+1:], l1, l2+1, r1, r2, i+1)
  memo[s1 + s2] = ret
  return ret


a = S[0] + (' ' * (N-1))
b = ' ' * N

print(dp(a, b, 1, 0, N-1, N-1, 1) * 2)

Measured memory_bytes: 19972
def main():
    x1, y1, x2, y2 = map(int, input().split())

    x = x2 - x1
    y = y2 - y1

    x3 = x2 - y
    y3 = y2 + x

    x4 = x1 - y
    y4 = y1 + x
    print(x3, y3, x4, y4)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, a[10000], i;
	int64_t sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		sum += a[i];
	}
	sort(a, a + n);
	cout << a[0] << " " << a[n - 1] << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
#define inf 1e12+7
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int RS(char *s){
	int i=0;
	while(1){
		if(s[i]==0)break;
		i++;
	}
	int k=1;
	for(int j=0;j<(i-1)/2;j++){
		if(s[j]!=s[i-j-1])k=0;
	}
	if(i>0&&k)return 1;
	return 0;
}
int RS2(char *s){
	int i=0;
	while(1){
		if(s[i]==0)break;
		i++;
	}
	i=(i-1)/2;
	int k=1;
	for(int j=0;j<i/2;j++){
		if(s[j]!=s[i-j-1])k=0;
	}
	if(i>0&&k)return 1;
	return 0;
}
int main(){
	char s[100];
	scanf("%s",s);
	if(RS(s)&&RS2(s))printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
N = int(input())
count_ac = 0
count_wa = 0
count_tle = 0
count_re = 0
for i in range(N):
    S = input()
    if S == "AC":
        count_ac += 1
    if S == "WA":
        count_wa += 1
    if S == "TLE":
        count_tle += 1
    if S == "RE":
        count_re += 1
    del S

print("AC x ",count_ac)
print("WA x ",count_wa)
print("TLE x ",count_tle)
print("RE x ",count_re)

Measured memory_bytes: 9144
a=[0]*3
b=[0]*3
C=[list(map(int,input().split())) for _ in range(3)]
for i in range(3):
  a[i]=C[0][i]
for i in range(3):
  b[i]=C[i][0]-a[0]
for i in range(3):
  for j in range(3):
    if a[j]+b[i] != C[i][j]:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int n,k;
int f[100100];
vector<vector<int> >G;
void init()
{
    G.clear();
    G.resize(n+500);
    for(int i=1;i<=n+100;i++)  G[i].clear();
}
void dfs(int x,int fa)
{
    int now=1;
    if(fa!=-1)  now++;
    for(int &i:G[x])
    {
        if(i==fa)  continue;
        f[i]=k-now;now++;
        dfs(i,x);
    }
}
int main()
{
    cin>>n>>k;
    int x,y;
    init();
    for(int i=1;i<=n-1;i++)
    {
        scanf("%d%d",&x,&y);
        G[x].push_back(y);G[y].push_back(x);
    }
    f[1]=k;
    dfs(1,-1);
    long long ans=1;
    long long M=1000000007;
    for(int i=1;i<=n;i++)
    {
       // cout<<f[i]<<" ";
        ans=ans*f[i]%M;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13756