akhauriyash/Code-Regression huggingface dataset:
package main
 
import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)
 
func main() {
	sc := NewScanner(os.Stdin)
	h, _ := sc.NextInt()
	w, _ := sc.NextInt()
	k, _ := sc.NextInt()
	x1, _ := sc.NextInt()
	y1, _ := sc.NextInt()
	x2, _ := sc.NextInt()
	y2, _ := sc.NextInt()
	stage := make([]string, h)
	for i := 0; i < h; i++ {
		sc.Scan()
		stage[i] = sc.Text()
	}
	ans := solve(h, w, k, x1-1, y1-1, x2-1, y2-1, stage)
	fmt.Println(ans)
}
 
type state struct {
	x, y, dist int
}
 
var inf = math.MaxInt64
var dxs, dys = []int{0, 0, -1, 1}, []int{-1, 1, 0, 0}
 
func solve(h, w, k, x1, y1, x2, y2 int, stage []string) int {
	dists := make([][]int, h)
	for x := range dists {
		dists[x] = make([]int, w)
		for y := range dists[x] {
			dists[x][y] = inf
		}
	}
 
	dists[x1][y1] = 0
	// q := priorityQueue{}
	q := []*state{}
	s := &state{x1, y1, 0}
	// heap.Push(&q, s)
	q = append(q, s)
	//for len(q) > 0 {
	for idx := 0; idx < len(q); idx++ {
		//fmt.Println(q.String())
		// p := heap.Pop(&q).(*state)
		p := q[idx]
		//if p.x == x2 && p.y == y2 {
		//	return p.dist
		//}
		for d := range dxs {
			for i := 1; i <= k; i++ {
				x, y := p.x+i*dxs[d], p.y+i*dys[d]
				if x < 0 || h <= x || y < 0 || w <= y {
					break
				}
				if stage[x][y] == '@' {
					break
				}
				dist := p.dist + 1
				if dist > dists[x][y] {
					break
				}
				if dist == dists[x][y] {
					continue
				}
				dists[x][y] = dist
				s := &state{x, y, dist}
				q = append(q, s)
			}
 
		}
	}
	if dists[x2][y2] == inf {
		return -1
	}
	return dists[x2][y2]
}
 
// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}
 
// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}
 
// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

Measured memory_bytes: 56344
# change minimum
def chmin(a,b):
    return b if a>b else a

# change maximum
def chmax(a,b):
    return b if a<b else a

INF = 1000000000

def main():
    N = int(input())
    h = list(map(int,input().split()))

    # DPテーブル
    dp = [INF]*(10**5+10)

    # 初期条件
    dp[0] = 0

    # roop
    for i in range(1,N):
        dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
        if i>1:
            dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

    print(dp[N-1])

main()

Measured memory_bytes: 20624
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    ll n,a;
    cin >> n >> a;
    cout << n*n-a << endl;
}


Measured memory_bytes: 3580
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let m = v[1];

    let mut vs = vec![0usize; m];
    for _i in 0..n {
        let v2 = read_vec::<usize>();
        for j in 1..(v2[0]+1){
            vs[v2[j]-1] += 1;
        }
    }

    let ans = vs.into_iter().filter(|&i| i == n).count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    double a, b;
    double h, m;
    cin >> a >> b >> h >> m;

    double th = PI * h / 6.0 + PI * m / 360.0;
    double tm = PI * m / 30.0;

    double hm2 = a * a + b * b - 2 * a * b * cos(th - tm);
    cout << fixed << setprecision(16) << sqrt(hm2) << endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int h,w;cin>>h>>w;

	string s[h];
	for(int i=0;i<h;i++)cin>>s[i];

	vector<int> row;
	set<int>col;

	for(int i=0;i<h;i++){
		bool ch = 0;
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				ch=1;
				break;
			}
		}
		if( ch ){row.push_back(i);}
	}

	for(int i=0;i<w;i++){
		bool ch = 0;
		for(int j=0;j<row.size();j++){
			if(s[row[j]][i]=='#'){
				ch=1;
				break;
			}
		}
		if( ch ){col.insert(i);}
	}
	
	string ans[row.size()];

	for(int i=0;i<row.size();i++){

		string t="";

		for(int j=0;j<w;j++){
			if(col.find(j)!=col.end()){
				t+=s[row[i]][j];
			}
		}
		ans[i]=t;
	}

	for(int i=0;i<row.size();i++){

		cout<<ans[i]<<endl;
	}

	

	return 0;

}

Measured memory_bytes: 3612
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  VECV(A,3,3);
  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<bool>> C(3, vector<bool>(3));
  int N;
  // 入力 (2重ループを用いる)
  rep(i,3){
    rep(j,3) {
      cin >>A.at(i).at(j);
    }
  }
  cin>>N;
  VEC(b,N);
  rep(i,N){
    cin >>b.at(i);
  }

  rep(i,3){
    rep(j,3){
      C.at(i).at(j)=false;
    }
  }
  rep(i,3){
    rep(j,3){
      rep(k,N){
        if(b[k]==A[i][j])
      		C[i][j]=true;
      }
    }
  }
  string ans="No";

  if(C[0][0] && C[1][1] && C[2][2])
    ans="Yes";
  if(C[1][1] && C[1][2] && C[1][0])
    ans="Yes";
  if(C[2][1] && C[2][2] && C[2][0])
    ans="Yes";
  if(C[0][1] && C[0][2] && C[0][0])
    ans="Yes";
  if(C[1][1] && C[2][1] && C[0][1])
    ans="Yes";
  if(C[1][2] && C[2][2] && C[0][2])
    ans="Yes";
  if(C[1][0] && C[2][0] && C[0][0])
    ans="Yes";
  if(C[2][0] && C[1][1] && C[0][2])
    ans="Yes";
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);

my %res = ();
for(my $i=0;$i<$n;$i++){
  my $s = <STDIN>;
  my %h = ();
  for(my $j=0;$j<10;$j++){
    my $c1 = substr($s,$j,1);
    $h{$c1} ++;
  }
  my $k = '';
  foreach my $c1 (sort keys %h){
    $k .= "$c1\t$h{$c1}\t";
  }
  $res{$k} ++;
}

my $r1 = 0;
foreach my $c2 (keys %res){
  $r1 += ( ($res{$c2} * ( $res{$c2} - 1 )) / 2 );
}
print "$r1\n";



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


const ll MOD = ((ll)1e9)+7;

#define SZ(v) ((int)(v).size())
typedef vector<ll> Array;
typedef vector<Array> Matrix;

Matrix zero(int N){ return Matrix(N, Array(N)); }

Matrix identity(int N) {
  Matrix A = zero(N);
  REP(i, N) A[i][i] = 1;
  return A;
}

Matrix add(const Matrix &A, const Matrix& B){
  const int N = SZ(A);
  const int M = SZ(A[0]);
  Matrix C(N, Array(M));
  REP(i, N) REP(j, M) {
    C[i][j] += A[i][j] + B[i][j];
    if (C[i][j] >= MOD) C[i][j] %= MOD;
  }
  return C;
}

Array mul(const Matrix &A, const Array &x){
  const int N = SZ(A);
  const int M = SZ(A[0]);
  Array y(N);
  REP(i, N) REP(j, M)
    y[i] += A[i][j] * x[j];
  return y;
}

// A:[N,P] * B:[P,M] = C:[N,M]
Matrix mul(const Matrix &A, const Matrix& B) {
  const int N = SZ(A);
  const int P = SZ(A[0]);
  const int M = SZ(B[0]);
  Matrix C(N, Array(M));
  REP(i, N) REP(j, M) REP(k, P) {
    C[i][j] += A[i][k] * B[k][j];
    if (C[i][j] >= MOD) C[i][j] %= MOD;
  }
  return C;
}

// O ( n^3 log e )
// Matrix pow(const Matrix& A, ll e) {
//   return e == 0 ? identity(SZ(A)) :
//     e % 2 == 0 ? pow( mul(A,A) , e/2 ) : mul(A, pow(A,e-1));
// }
Matrix pow(Matrix A, ll b) {
  Matrix C = identity(SZ(A));
  while (b > 0) {
    if ((b & 1) == 1) C = mul(C, A);
    A = mul(A, A);
    b >>= 1;
  }
  return C;
}

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

int main2() {
  int N = nextInt();
  ll K; cin >> K;
  Matrix A = identity(N);
  REP(i, N) REP(j, N) A[i][j] = nextInt();

  Matrix M = pow(A, K);
  ll ans = 0;
  REP(i, N) REP(j, N) {
    ans = (ans + M[i][j]) % MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 384
s=input()
if "N" in s:
  if "S" not in s:
    print("No")
    exit()
if "S" in s:
  if "N" not in s:
    print("No")
    exit()
if "W" in s:
  if "E" not in s:
    print("No")
    exit()
if "E" in s:
  if "W" not in s:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    int A,B,C;
    int ans = 0;
  	scanf("%d%d%d",&A,&B,&C);
    if(A == 5 && B == 5 && C == 7){
        ans = 1;
    }
    if(A == 5 && B == 7 && C == 5){
        ans = 1;
    }
    if(A == 7 && B == 5 && C == 5){
        ans = 1;
    }
    if(ans == 0){
         printf("%s","NO");
    }else{
        printf("%s","YES");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
const int Nmax = 1000;
int X[Nmax], Y[Nmax];

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

	vector<ll> p(N), q(N);
	int parity = (X[0]+Y[0]+(1LL<<40))%2;
	for(int i=0; i<N; i++){
		p[i] = X[i] + Y[i];
		q[i] = X[i] - Y[i];
		if((p[i]+(1LL<<40))%2!=parity){
			cout << -1 << endl;
			return 0;
		}
		p[i] += parity-1;
		q[i] += parity-1;
	}

	cout << 40-parity << endl;
	if(parity==0){
		cout << 1 << ' ';
	}
	for(int i=0; i<39; i++) cout << (1LL<<(38-i)) << (i<38?' ':'\n');

	for(int i=0; i<N; i++){
		string ms;
		if(parity==0){
			ms += 'R';
		}

		ll k = 1LL<<38;
		ll x=0, y=0;
		if(parity==0){
			x = 1;
			y = 0;
		}
		while(k>0){
			if(p[i]>0&&q[i]>0){
				ms += 'R';
				p[i] -= k;
				q[i] -= k;
				x += k;
			} else if(p[i]<0&&q[i]<0){
				ms += 'L';
				p[i] += k;
				q[i] += k;
				x -= k;
			} else if(p[i]>0&&q[i]<0){
				ms += 'U';
				p[i] -= k;
				q[i] += k;
				y += k;
			} else{
				ms += 'D';
				p[i] += k;
				q[i] -= k;
				y -= k;
			}
			k = k>>1;
		}
		cout << ms << endl;
		//cout << x << " " << y << endl;
	}

    return 0;
}


Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2019年09月22日 星期日 20时09分45秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 102000;
int n, q, fa[maxn];
ll m, cc;
vector<pii> op[2];
int find(int v) { return fa[v]==v ? v : fa[v] = find(fa[v]); }
void merge(int x, int y) {
    x = find(x), y = find(y);
    if(x != y) fa[x] = y, cc--;
}
int main() {
    int opt, x, y;
    scanf("%d%lld%d", &n, &m, &q), cc = n;
    rep(i, n) fa[i] = i;
    rep(i, q) {
        scanf("%d%d%d", &x, &y, &opt);
        op[opt].emplace_back(x, y);
    }
    for(auto g : op[0]) merge(g.first, g.second);
    if(m == n - 1) {
        puts(op[1].size() ? "No" : "Yes");
        return 0;
    }

    for(auto g : op[1])
        if(find(g.first) == find(g.second)) { puts("No"); return 0; }
    puts(m <= n-cc + cc*(cc-1)/2 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 1912
N, A, B = map(int, input().split())
count = 0
for i in range(1, N+1):
    sum = 0
    cur = i
    for j in range(0, 5):
        q, cur = divmod(cur, 10**(4-j))
        sum = sum+q
    if A<=sum<=B:
        count = count+i
print("{}".format(count))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  vector<string> s;
  REP(i,n){
    string ss;cin>>ss;
    s.push_back(ss);
  }
  REP(i,n){
    REP(j,n){
      if(i==j)continue;
      if(s[i]==s[j]){
        P("No");
        return 0;
      }
    }
  }
  char st = s[0][s[0].size()-1];
  for(int i=1;i<n;i++){
    if(s[i][0]!=st){
      P("No");
      return 0;
    }
    st = s[i][s[i].size()-1];
  }
  P("Yes");
  return 0;
}


Measured memory_bytes: 256
import math
from decimal import *

n=int(input())

t_prev,a_prev=1,1
for i in range(n):
  t,a=map(int,input().split())
  n_koho1=math.ceil(Decimal(t_prev)/Decimal(t))
  n_koho2=math.ceil(Decimal(a_prev)/Decimal(a))

  #これはダメ
  #n_koho1=math.ceil(t_prev/t)
  #n_koho2=math.ceil(a_prev/a)

  #これはOK
  #n_koho1 = t_prev // t
  #n_koho2 = a_prev // a
  #if t_prev % t != 0:
  #    n_koho1 += 1
  #if a_prev % a != 0:
  #    n_koho2 += 1
        
  n=max(n_koho1,n_koho2)
  t=n*t
  a=n*a
    
  t_prev=t
  a_prev=a

print(t_prev+a_prev)

"""
t=10**15
print(t)
print(t+1)
print((t+1)/t)
print(math.ceil((t+1)/t))

t=10**16
print(t)
print(t+1)
print((t+1)/t)
print(math.ceil((t+1)/t))

print(Decimal((t+1)/t))
print(Decimal(t+1)/Decimal(t))
print(math.ceil(Decimal(t+1)/Decimal(t)))
"""

Measured memory_bytes: 5332
#include<iostream>
using namespace std;
int move(int start,int end,char text){
  while(start!=end){
    if(start<end){
      start++;
      }else{
        start--;
      }
      cout <<text;
  }
}
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  move(sy,ty,'U');
  move(sx,tx,'R');
  move(ty,sy,'D');
  move(tx,sx,'L');
  cout <<'L';
  move(sy,ty+1,'U');
  move(sx-1,tx,'R');
  cout<<'D';
  cout<<'R';
  move(ty,sy-1,'D');
  move(tx+1,sx,'L');
  cout<<'U'<<endl;
}


Measured memory_bytes: 256
n, l = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
#s = input()

ans = 0
ls = []
for i in range(1,n+1):
  ls.append(l + i - 1)
ls.sort()
if ls.count(0) == 1:
  print(sum(ls))
else:
  try:
    ls.remove(min(map(abs,ls)))
  except:
  	ls.remove(-min(map(abs,ls)))
  print(sum(ls))

Measured memory_bytes: 3188
const teststr = 
"""
1
11 11
"""

function lines()
  Channel{String}(32) do ch
    ll = readlines()
    lines = isempty(ll) ? split(teststr, "\n") : ll
    for s in lines
      put!(ch, s)
    end
  end
end

quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

function main()
  ch = lines()
  K = in_1(ch)
  A,B = in_a(ch)
  for i in A:B
    if mod(i, K) == 0
      println("OK")
      quit()
    end
  end
  println("NG")
end

main()


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

int main() {
  int n;
  int sum = 0; cin >> n;

  string num = to_string(n);
  for(int i = 0; i < num.size(); ++i){
    char x; int y;
    x = num.at(i);
    y = x -'0';
    sum += y;
  }

  if(n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> L,R;
	long long int ans = 0;
	for(int i=1,l,r;i<=n;i++)
		cin>>l>>r,L.emplace_back(l),R.emplace_back(r);
	L.emplace_back(0);
	R.emplace_back(0);
	sort(L.rbegin(),L.rend());
	sort(R.begin(),R.end());
	long long int cur = 0;
	for(int i=0;i<L.size();i++)
		cur+=L[i]-R[i],ans=max(ans,cur);
	cout<<ans*2<<endl;
}


Measured memory_bytes: 1276
A, B = [int(x) for x in input().split()]
ans = 0

ans_a = A // 0.08
ans_b = B // 0.10

for i in range(1, 10100):
    if A == int(0.08 * i) and B == int(0.10 * i):
        ans = i
        print(ans)
        break
if ans == 0:
    print(-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mo 1000000007
#define mems(a,x) memset(a,x,sizeof(a))
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}



int main() 
{ 
	
	int n,k;
	cin>>n>>k;
	ll v[n];
	for(int i=0;i<n;i++)
		cin>>v[i];
	ll dp[n];
	
	for(int i=0;i<n;i++)
		dp[i]=mo;
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
		if(i+j<n)
		{
			dp[i+j]=min(dp[i+j],dp[i]+abs(v[i]-v[i+j]));
		}
		
	}
	}
	cout<<dp[n-1];

} 

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] list = new int[n];
        for (int i = 0; i < q; i++) {
            list[sc.nextInt() - 1] += 1;
        }
        for (int tmp : list) {
            System.out.println(k - (q - tmp) > 0 ? "Yes" : "No");
        }
    }
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    deque<int> d;
    int _tmp;
    cin >> _tmp;
    int op;
    while(cin >> op) {
        if (0 == op) {
            cin >> op;
            if (0 == op) {
                cin >> op;
                d.push_front(op);
            } else {
                cin >> op;
                d.push_back(op);
            }
        } else if (1 == op) {
            cin >> op;
            cout << d[op] << endl;
        } else {
            cin >> op;
            if (0 == op) d.pop_front();
            else d.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;

vector<vector<ll>> v;
ll n,m,q,ans=0;

void check(vector<ll> &a){
    ll c=0;
    //for(ll i=0;i<a.size();i++)
    //    cout<<a[i]<<" ";
    for(ll i=0;i<v.size();i++){
        if(a[v[i][1]-1]-a[v[i][0]-1]==v[i][2]){
            c+=v[i][3];
            //cout<<i<<",";
        }
    }
    //cout<<"\n";
    ans=max(ans,c);
}

void solve(ll pos,ll st,vector<ll> a){
    a.pb(st);
    if(pos==n-1){
        check(a);
        return;
    }
    for(ll i=st;i<=m;i++)
        solve(pos+1,i,a);
    return;
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>n>>m>>q;
    while(q--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        v.pb({a,b,c,d});
    }
    vector<ll> p;
    for(ll i=1;i<=m;i++){
        solve(0,i,p);
    }
    cout<<ans;

    
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

void show_array(int A[], int N){
    int i;
    for(i = 0; i < N; i++){
        printf("%d", A[i]);
        if(i < N - 1){
            putchar(' ');
        }
        else{
            putchar('\n');
        }
    }
}

void exchange(int A[], int i, int j){
    int tmp;
    tmp = A[i];
    A[i] = A[j];
    A[j] = tmp;
}

int bubble_sort(int A[], int N){
    int cnt = 0;
    int i, j;
    for(i = 0; i < N - 1; i++){
        for(j = N - 1; j > i; j--){
            if(A[j] < A[j-1]){
                exchange(A, j, j - 1);
                cnt += 1;
            }
        }
    }
    return cnt;
}

int main(void){
    int N, i, cnt;
    int A[100];

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    cnt = bubble_sort(A, N);

    show_array(A, N);
    printf("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    ll A[N + 1];
    REP(i, N + 1) cin >> A[i];

    if (N == 0) {
        if (A[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
    }
    else {
        ll p[N + 1];
        ll c[N + 1];
        c[N] = A[N];
        p[N] = 0;
        for (int i = N - 1; i >= 0; --i) {
            c[i] = A[i];
            p[i] = p[i + 1] + c[i + 1];
        }
        ll ans = 0;
        if (A[0] != 0) {
            cout << -1 << endl;
        }
        else {
            ans += 1;
            ll prev = 1;
            bool f = true;
            FOR(i, 1, N + 1) {
                ll pmax = prev * 2;
                if (pmax < c[i]) {
                    cout << -1 << endl;
                    f = false;
                    break;
                }
                else if (pmax < c[i] + p[i]) {
                    ans += pmax;
                    prev = pmax - c[i];
                }
                else {
                    ans += c[i] + p[i];
                    prev = p[i];
                }
            }
            if (f) cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5964
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    const string S = "AGCT";

    int n; cin >> n;

    vector<map<string,int>> dp(n+1);

    vector<string> agct({""});
    REP(i,3) {
        vector<string> tmp;
        swap(tmp,agct);
        for (auto s:tmp) {
            for (auto c: S) {
                agct.push_back(s+c);
            }
        } 
    }

    map<string,int> memo;
    auto isok = [&](string s) {
        if (memo[s] != 0) {
            return memo[s] == 1;
        }
        bool ret = true;
        REP(i,s.size()) {
            if (i == 0) {
                if (s.find("AGC") != string::npos) ret = false;
            } else {
                string t = s;
                swap(t[i],t[i-1]);
                if (t.find("AGC") != string::npos) ret = false;
            }
        }
        if (ret) memo[s] = 1;
        else memo[s] = -1;
        return ret;
    };

    for (auto s:agct) {
        if (isok(s)) dp[3][s] = 1;
        else dp[3][s] = 0; 
    }

    FOR(i,4,n+1) {
        for(auto s:agct) {
            for(auto c:S) {
                string t = s+c;
                if (isok(t)) dp[i][t.substr(1,3)] = mod(dp[i][t.substr(1,3)] + dp[i-1][s]);
            }
        }
    }

    int ans = 0;
    for(auto v:dp[n]) ans = mod(ans + v.second);

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 896
function Main(input) {
	input = input.split("\n");
	input = input[0].split(" ")
	const A = parseInt(input[0])
	const B = parseInt(input[1])
	var count = 1
	var n = 0
	while(count < B){
		count = count - 1 + A
		n++
	}
	console.log(n)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mt make_tuple
#define mod 1000000007
#define pi 3.141592653589793238
#define fl long double
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
vector<ll>ad[100001];
bool vis[100001];
ll sgn[100001];
void bfs(ll nd)
{
    queue<ll>q;
    q.push(nd);
    vis[nd]=true;

    while(!q.empty())
    {
        ll cur=q.front();
        q.pop();

        for(auto x:ad[cur])
        {
            if(vis[x]==0)
            {
                q.push(x);
                sgn[x]=cur;
                vis[x]=true;
            }
        }
    }
}
int main()
{
    ll i,j,k,n,m,t;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>j>>k;
        ad[j].pb(k);
        ad[k].pb(j);
    }
    memset(vis,false,sizeof(vis));
    memset(sgn,0,sizeof(sgn));
    bfs(1);
    for(i=2;i<=n;i++)
    {
        if(vis[i]==false)
        {
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    for(i=2;i<n;i++)
    {
        cout<<sgn[i]<<endl;
    }
    cout<<sgn[n];
    return 0;
}


Measured memory_bytes: 13008
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	string S;
	cin >> S;
	reverse(S);
	rep(i, 10) {
		S.push_back('*');
	}
	lint N = S.size();
	rep(i, N) {
		if (S[i] != '*') {
			if (S.substr(i, 5) == "maerd") {
				rep(j, 5) {
					S[i + j] = '*';
				}
			}
			if (S.substr(i, 7) == "remaerd") {
				rep(j, 7) {
					S[i + j] = '*';
				}
			}
			if (S.substr(i, 5) == "esare") {
				rep(j, 5) {
					S[i + j] = '*';
				}
			}
			if (S.substr(i, 6) == "resare") {
				rep(j, 6) {
					S[i + j] = '*';
				}
			}
		}
	}
	rep(i, N) {
		if (S[i] != '*') {
			cout << "NO" << enld;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph = vector<vector<int> >;
Graph G;

void dfs(int v,vector<bool> &seen,int &res){
  bool end=true;
  for(int i=0;i<seen.size();++i){
    if(seen[i]==false && i!=v){
      end=false;
    }
  }
  if(end==true){
    res++;
    return;
  }
  seen[v]=true;
  for(auto nv : G[v]){
    if(seen[nv]) continue;
    dfs(nv,seen,res);
  }
  seen[v] = false;
}

int main(){
  int n,m;
  cin >> n >> m;
  G.assign(n,vector<int>());
  for(int i=0;i<m;++i){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<bool> seen(n,false);
  int res=0;
  dfs(0,seen,res);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N,M = getNM()
graph = [[] for i in range(N)]
for _ in range(M):
  l,r,d = getNM()
  graph[l-1].append((r-1,d))
  graph[r-1].append((l-1,-d))

q = deque([i for i in range(N)])
pos = [None for i in range(N)]
while q:
  x = q.popleft()
  if pos[x] == None:
    pos[x] = 0
  for y,d in graph[x]:
    if pos[y] == None:
      pos[y] = pos[x] + d
      q.appendleft(y)
      continue
    if pos[y] != pos[x] + d:
      print("No")
      exit()

print("Yes")

Measured memory_bytes: 126932
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> t(n);
    REP(i,n) cin>>t[i];
    int m;cin>>m;
    REP(i,m){
        int p,x;
        cin>>p>>x;
        p--;
        ll sum=0;
        REP(i,n){
            if(i==p) sum+=x;
            else sum+=t[i];
        }
        cout<<sum<<endl;
    }
}

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

int main(){
  int A, B, C;
  
  cin >> A >> B >> C;
  
  if((A < C && C < B) || (B < C && C < A))
    cout << "Yes" << "\n" << endl;
  else
    cout << "No" << "\n" << endl;
  
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

N, K = map(int, input().split())


print(len(Base_10_to_n(N, K)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=305,INF=1<<30;
bool dp[MAX][MAX][MAX];
ll dp2[MAX][MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    int N=si(S);
    dp[0][0][0]=1;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                if(dp[i][j][k]==0) continue;
                
                if(i+1<N){
                    if(S[i]=='0') dp[i+2][j+1][k]=1;
                    else dp[i+2][j][k+1]=1;
                    
                    if(S[i+1]=='0') dp[i+2][j+1][k]=1;
                    else dp[i+2][j][k+1]=1;
                    
                    dp[i+1][j][k]=1;
                }
                
                if(j&&S[i]=='1') dp[i+1][j-1][k+1]=1;
                
                if(k&&S[i]=='0') dp[i+1][j+1][k-1]=1;
                
                if(j||k) dp[i+1][j][k]=1;
            }
        }
    }
    
    reverse(all(S));
    
    dp2[0][0][0]=1;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                if(S[i]=='0'){
                    dp2[i][j][k+1]+=dp2[i][j][k];
                    dp2[i][j][k+1]%=mod;
                }else{
                    dp2[i][j+1][k]+=dp2[i][j][k];
                    dp2[i][j+1][k]%=mod;
                }
                dp2[i+1][j][k]+=dp2[i][j][k];
                dp2[i+1][j][k]%=mod;
            }
        }
    }
    
    ll ans=0;
    
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                if(dp[i][j][k]){
                    ans+=dp2[N-i][j][k];
                    ans%=mod;
                }
            }
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 228960
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
    for (unsigned i = 0; i < v.size(); i++)
        in >> v[i];
    return in;
}

bool compare(vl under_std,lo X){
    REP(0,under_std.size()){
        if(under_std[i]<X)return false;
    }
    return true;
}

lo ans = INT_MAX;


void solve(vll &u_std,vl &cost,vl under_std,lo money,lo N,lo X){
    if(compare(under_std,X)){
        if(money!=0)ans = min(money,ans);
        return;
    }
    if(N==0)return;
    solve(u_std,cost,under_std,money,N-1,X);
    REP(0,under_std.size()){
        under_std[i]+=u_std[N-1][i];
    } 
    solve(u_std,cost,under_std,money+cost[N-1],N-1,X);
   

}
void solve1(){

    lo N,M,X,c;
    vll u_std;
    cin>>N>>M>>X;
    vl cost;
    for(lo i=0;i<N;i++){
        cin>>c;
        cost.push_back(c);
        vl temp;
        for(lo j=0;j<M;j++){
            cin>>c;
            temp.push_back(c);
        }
        u_std.push_back(temp);
        temp.clear();

    }

    vl under_std(M,0);lo money=0;

     solve(u_std,cost,under_std,money,N,X);
     if(ans ==INT_MAX)cout<<"-1"<<endl;
     else cout<<ans<<endl;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(20);
    solve1();
    return 0;
}

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

int main(void) {
    int i, j, N, b[110] = {0}, q[110] = {0};
    scanf("%d", &N);
    for (i=1;i<=N;i++) scanf("%d", &b[i]);
    for (i=N;i>0;i--) {
        for (j=i;j>0;j--) if (b[j] == j) {
            q[i] = j;
            memmove(b+j, b+j+1, sizeof(int)*(i-j));
            break;
        }
        if (j == 0) {
            printf("-1\n");
            return 0;
        }
    }
    for (i=1;i<=N;i++) printf("%d\n", q[i]);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()

m = 0
for i in range(1,len(s)):
    x = s[0:i]
    y = s[i:len(s)]
    a = []
    count = 0
    for j in range(0,i):
        if x[j] in y and not(x[j] in a):
            a.append(x[j])
            count += 1
    m = max(m,count)
print(m)

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

const int SIZE=2010;
int L[SIZE][SIZE],R[SIZE][SIZE];
int U[SIZE][SIZE],D[SIZE][SIZE];

signed main()
{
    int H,W; cin>>H>>W;
    vector<string> s(H);
    for(int i=0;i<H;i++){
	cin>>s[i];
    }

    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(s[i][j]=='#'){
		L[i][j]=R[i][j]=U[i][j]=D[i][j]=-1;
	    }
	}
    }

    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(s[i][j]=='#') continue;
	    if(j==0){
		L[i][j]=0;
	    }else{
		L[i][j]=(s[i][j-1]=='#'? 0:L[i][j-1]+1);
	    }
	}
    }
    for(int i=0;i<H;i++){
	for(int j=W-1;j>=0;j--){
	    if(s[i][j]=='#') continue;
	    if(j==W-1){
		R[i][j]=0;
	    }else{
		R[i][j]=(s[i][j+1]=='#'? 0:R[i][j+1]+1);
	    }
	}
    }
    for(int j=0;j<W;j++){
	for(int i=0;i<H;i++){
	    if(s[i][j]=='#') continue;
	    if(i==0){
		U[i][j]=0;
	    }else{
		U[i][j]=(s[i-1][j]=='#'? 0:U[i-1][j]+1);
	    }
	}
    }
    for(int j=0;j<W;j++){
	for(int i=H-1;i>=0;i--){
	    if(s[i][j]=='#') continue;
	    if(i==H-1){
		D[i][j]=0;
	    }else{
		D[i][j]=(s[i+1][j]=='#'? 0:D[i+1][j]+1);
	    }
	}
    }
    int ans=0;
    for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	    if(s[i][j]=='#') continue;
	    ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]+1);
	}
    }
    cout<<ans<<endl;
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    size_t n, k;
    cin >> n >> k;
    --k;
    auto r = n - k;
    vector<vector<unsigned long>> C(n + 1, vector<unsigned long>(n + 1));
    C[0][0] = 1;
    for(size_t i = 1; i <= n; ++i){
        C[i][0] = 1;
        transform(C[i - 1].begin() + 1, C[i - 1].begin() + i + 1, C[i - 1].begin(), C[i].begin() + 1, [&MOD](auto a, auto b){return (a + b) % MOD;});
    }
    for(size_t i = 0; i <= k; ++i)cout << C[r][i + 1] * C[k][i] % MOD << endl;
    return 0;
}

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

class DICE{
private:
	int temp;
public:
	int dice[6];
	void rollN(){roll(1,5,4);}
	void rollS(){roll(4,5,1);}
	void rollE(){roll(3,5,2);}
	void rollW(){roll(2,5,3);}
	void roll(int a,int b,int c){
		temp=dice[0];dice[0]=dice[a];
		dice[a]=dice[b];dice[b]=dice[c];dice[c]=temp;
	}
	void fi(char ch){
		if(ch=='N'){rollN();}
		if(ch=='S'){rollS();}
		if(ch=='W'){rollW();}
		if(ch=='E'){rollE();}
	}
};



int main(){
	DICE c;
	for(int i=0;i<6;i++){
		cin>>c.dice[i];
	}
    
	string com;
	cin>>com;
	for(int i=0;i<com.size();i++){
		c.fi(com[i]);
	}
	cout<<c.dice[0]<<endl;
	return 0;
}


/*
N 1->2 2->6 6->5 5->1
  S 1->5 5->6 6->2 2->1
  W 1->3 3->6 6->4 4->1
  E 1->4 4->6 6->3 3->1
  */

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h,n;
  cin>>h>>n;
  vll a(n);
  REP(i,n)cin>>a[i];

  ll sum=0;
  REP(i,n)sum+=a[i];
  if(h<=sum)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}


Measured memory_bytes: 1024
N, M = map(int,input().split())
max_L =0
min_R = N
for i in range(M):
    L, R = map(int,input().split())
    if max_L<=L:
        max_L = L
    if min_R>=R:
        min_R = R
print(max(min_R - max_L +1,0))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 

using ll = long long;

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

constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll mod){ll r=1;while(e>0){if(e&1)r=(r%mod)*(b%mod)%mod;b=(b%mod)*(b%mod)%mod;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i < v.size()-1)s<<", ";}s<<']';return s;}

ll five(ll n){
    ll cnt = 0;
    for(ll m = 10; m <= n; m *= 5){
        cnt += n/m;
    }
    return cnt;
}

int main(){

    ll n;
    scanf("%lld", &n);
    eee(n%2);
    if(n%2 == 0) {
        ppp(five(n));
    }
    else{
        ppp(0);
    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N,M;
int main () {
    cin >> N >> M;
    int l=1;
    int r=N;
    for(int i=0; i<M; i++) {
        int x,y;
        cin >> x >> y;
        l = max(x,l);
        r = min(y,r);
    }
    cout << ( l<=r ? r-l+1 : 0 ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define MAX 1000000
using namespace std;

struct pp{
    int t;
    string s;
};

class queue{
public:
    int head;
    int tail;
    vector<pp> v;
    queue();
    void enqueue(pp x);
    pp dequeue();
    bool isEmpty();
};

queue::queue(){
    head = 0;
    tail = 0;
    v.resize(MAX);
}

void queue::enqueue(pp x){
    v[tail].t = x.t;
    v[tail].s = x.s;
    tail++;
}

pp queue::dequeue(){
    head++;
    return v[head-1];
}

bool queue::isEmpty(){
    return head == tail;
}


int main(){
    int n;cin >> n;
    int q;cin >> q;
    queue q1;
    for(int i=0;i<n;i++){
        pp p;
        cin >> p.s >> p.t;
        // cout << p.s << endl;
        q1.enqueue(p);
    }

    int passtime = 0;
    vector<pp> v;
    while(!q1.isEmpty()){
        pp ptmp = q1.dequeue();
        // cout << ptmp.s << endl;
        if(ptmp.t > q){
            passtime +=q;
            ptmp.t -= q;
            q1.enqueue(ptmp);
        }
        else{
            passtime += ptmp.t;
            ptmp.t = passtime;
            v.push_back(ptmp);
        }
    }
    for(int i=0;i<v.size();i++){
        cout << v[i].s << " " << v[i].t << endl;
    }
}

Measured memory_bytes: 20044
import queue

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

a = []
b = []

for i in range(m):
	s, t = map(int, input().split())
	a.append(s-1)
	b.append(t-1)

#各部屋から行ける部屋
c = [[] for i in range(n)]

for i in range(m):
	c[a[i]].append(b[i])
	c[b[i]].append(a[i])

q = queue.Queue()
q.put(0)

#部屋1からの距離
inf = 10**8
d = [inf]*n
d[0] = 0
ans = [0]*n

while not q.empty():
	x = q.get()
	for i in c[x]:
		if d[i]==inf:
			q.put(i)
			d[i] = d[x]+1
			ans[i] = x+1

print('Yes')
for i in range(1,n):
	print(ans[i])

Measured memory_bytes: 41012
#include<stdio.h>

int a, b, c, num = 0;
int main() {
	scanf("%d %d %d", &a, &b, &c);
	for (int i=a; i<=b; i++) {
		if (c % i == 0) {
			num++;
		}
	}
	printf("%d\n", num);
	return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define MD 17
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,Q,x[MN+5],L,f[MD+1][MN+5];
int main()
{   
    n=read();
    for(int i=1;i<=n;++i) x[i]=read();
    L=read();f[0][n]=n;
    for(int i=n;--i;) 
        for(f[0][i]=f[0][i+1];x[f[0][i]]-x[i]>L;--f[0][i]);
    for(int i=1;i<=MD;++i) for(int j=1;j<=n;++j) f[i][j]=f[i-1][f[i-1][j]];
    for(Q=read();Q--;)
    {
        int a=read(),b=read();if(a>b) swap(a,b);int ans=0;
        for(int j=MD;~j;--j) if(f[j][a]<b) ans+=(1<<j),a=f[j][a];
        printf("%d\n",ans+1);
    }
    return 0;
}

Measured memory_bytes: 8192