akhauriyash/Code-Regression huggingface dataset:
S = list(input().rstrip())
ts = 'abcdefghijklmnopqrstuvwxyz'

ns = []

for c in S:
    if c not in ns:
        ns.append(c)


if len(ns) == 26:
    print('None')
else:
    ns.sort()
    for tc in ts:
        if tc not in ns:
            print(tc)
            break




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

int n, a, b, c;
vector<int> v;
int ans = 1000000000;

int check(string s) {
  if (s.size() > n || s.size() == 0) return 10000000;

  int cont_A = 0, cont_B = 0, cont_C = 0;
  int sum_A = 0, sum_B = 0, sum_C = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'a') {
      cont_A++;
      sum_A += v.at(i);
    }
    if (s.at(i) == 'b') {
      cont_B++;
      sum_B += v.at(i);
    }
    if (s.at(i) == 'c') {
      cont_C++;
      sum_C += v.at(i);
    }
  }
  if (cont_A == 0 || cont_B == 0 || cont_C == 00) return 10000000;

  int mp = abs(a - sum_A) + abs(b - sum_B) + abs(c - sum_C);
  int cnt = max(cont_A - 1, 0) + max(cont_B - 1, 0) + max(cont_C - 1, 0);
  mp += cnt * 10;
  return mp;
}

void dfs(string s) {
  ans = min(ans, check(s));

  if (s.size() <= n) {
    dfs(s + "a");
    dfs(s + "b");
    dfs(s + "c");
    dfs(s + "d");
  }
}

int main() {
  cin >> n >> a >> b >> c;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  string s = "";
  dfs(s);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using lli = long long int;

int main(){
  int n;
  std::cin >> n;
  vector<vector<lli> > adj(n, vector<lli>(n, 0));
  vector<vector<int> > mini;
  for (int i = 0; i < n; i++) {
    vector<int> tmp(3);
    for (int j = 0; j < n; j++) {
      std::cin >> adj[i][j];
      tmp[0] = adj[i][j], tmp[1] = i, tmp[2] = j;
      if(i < j)mini.push_back(tmp);
    }
  }
  sort(mini.begin(), mini.end());
  vector<vector<lli> > dist = adj;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
      }
    }
  }

  if(dist != adj){
    std::cout << -1 << std::endl;
    return 0;
  }
  dist = vector<vector<lli> >(n, vector<lli>(n, 2e9));
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  lli ans = 0;
  for (int i = 0; i < mini.size(); i++) {
    int u = mini[i][1], v = mini[i][2];
    if(dist[u][v] <= adj[u][v])continue;
    ans += adj[u][v];
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        lli md = dist[j][u] + adj[u][v] + dist[v][k];
        if(md < dist[j][k]) dist[j][k] = dist[k][j] = md;
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 4788
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int nx = n % 10;
        if (nx == 2 || nx == 4 || nx == 5 || nx == 7 || nx == 9) {
            System.out.println("hon");
        } else if (nx == 0 || nx == 1 || nx == 6 || nx == 8) {
            System.out.println("pon");
        } else if (nx == 3) {
            System.out.println("bon");
        }
    }
}

Measured memory_bytes: 35756
#include<bits/stdc++.h>
#define int   long long int  
#define pb push_back
#define BOOST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debugL(i)  cout<<"line no-> "<<i<<" working"<<endl
#define debugVL(i,l)  cout<<"val at line no."<<i<< " ->"<<l<<endl
#define  init(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
const int M=1e9 + 7;
using namespace std;
int N=200000;
int32_t main() {
	BOOST;
	int n;cin>>n;
	int* a=new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=1;
	int cur=a[0];
	int s=1;
	for(int i=1;i<n;i++)
	{
		if(cur>=a[i])
		{
			s++;
			cur=a[i];
		}else{
			s=1;
			cur=a[i];
		}
		ans=max(s,ans);
	}
	cout<<(ans-1)<<endl;
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 1024
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    rep(_, n) {
        int a, b;
        cin >> a >> b;
        if (a >= h && b >= w) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const ll INF = 1e9;
const ll INFF = 1e18;
const ll MAXN = 510;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

ll tab[3010][3010];
ll dp[3010][3010][5]; // [r][c][rem]
ll n,m,k;

ll rec(ll r,ll c,ll rem)
{
    if (r > n) return 0;
    if (c > m) return 0;
    if (r == n && c == m) return tab[r][c] * (rem > 0);
    if (dp[r][c][rem] != -1) return dp[r][c][rem];
    ll ret = 0;
    // cout << r << " " << c << " " << rem << endl;
    ret = max(ret,rec(r,c + 1,rem));
    if (rem == 0)
    {
        ret = max(ret,rec(r + 1,c,3));
    }
    else
    {
        ret = max(ret,tab[r][c] + rec(r,c + 1,rem - 1));
        ret = max(ret,tab[r][c] + rec(r + 1,c,3));
    }
    // cout << r << " " << c << " " << rem << ": " << ret << endl;
    return dp[r][c][rem] = ret;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin >> n >> m >> k;
    for (ll i = 1 ; i <= k ; i++)
    {
        ll r,c,v;
        cin >> r >> c >> v;
        tab[r][c] = v;
    }
    ll ans = rec(1,1,3);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 428516
#include <algorithm>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif

    set<string> s;
    int n;
    cin >> n;
    string st;
    for (int i = 0; i < n; i++) {
        cin >> st;
        s.insert(st);
    }
    cout << s.size();


    #ifndef ONLINE_JUDGE   
    std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 19248
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  ll N,X;
  cin>>N>>X;
  
  ll A[2*N+1],ANS[N+1];
  ANS[0]=0LL;
  for(int i=1; i<=N; ++i){
    cin>>A[i];
    A[N+i]=A[i];
    ANS[i]=i*X;
  }
  
  ll DP[N+1][N+1];
  // DP[i][j] 魔法をj回唱えるとき、スライムiを捕まえるのにかかる最短時間
  
  REP(i,N+1){
    REP(j,N+1){
      DP[i][j]=0LL;
      if(j==0 && i>0) DP[i][j]=A[i];
    }
  }
  
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=N-1; ++j){
      DP[i][j]=min(DP[i][j-1],A[i+N-j]);
    }
  }
  
  for(int i=1; i<=N; ++i){
    for(int j=0; j<=N-1; ++j){
      ANS[j]+=DP[i][j];
    }
  }
  
  cout<<*min_element(ANS+0,ANS+N)<<endl;
  return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

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

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    ll sum = 0;
    REP(i, 0, n){cin >> lis[i]; sum += lis[i];}
    vector<ll> anslis(n);
    ll mid = 0;
    for(int i = 1; i < n; i += 2){
        mid += 2 * lis[i];
    }
    anslis[0] = sum - mid;
    
    REP(i, 1, n){
        anslis[i] = 2 * lis[i-1] - anslis[i-1];
    }
    REP(i, 0, n){cout << anslis[i] << " ";}
}

Measured memory_bytes: 2816
inpl = lambda: list(map(int,input().split()))
N, X, Y = inpl()
X -=1
Y -=1
ans = [0] * N
for i in range(N-1):
    for j in range(i+1,N):
        d = min(j-i, abs(X-i)+abs(Y-j)+1)
        ans[d] += 1
for n in range(1,N):
    print(ans[n])


Measured memory_bytes: 47452
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int n;
      cin >> n;
      cout << "Christmas";
      if(n==24) cout << " Eve";
      else if(n==23) cout << " Eve Eve";
      else if(n==22) cout << " Eve Eve Eve";
      
      cout << endl;
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main()
{
   int a[4][14] , r = 1 , n , i , x , y , z ;
   char q ;
   cin >> n ;
   n <= 54 ;
   for ( i = 0 ; i < 4 ; i ++ ){
       for ( z = 1 ; z < 14 ; z ++ )
       {
           a[i][z] = 0 ;
       }
   }
   for ( i = 0 ; i < 4 ; i ++ ){
       for ( z = 1 ; z < 14 ; z ++ )
       {
           while ( r <= n ){
           cin >> q >> x ;
           if ( q == 'S'){
               y = 0 ;
               a[y][x] = 1 ;
           }
           else if ( q == 'H' ){
               y = 1 ;
               a[y][x] = 1 ;
           }
           else if ( q == 'C' ){
               y = 2 ;
               a[y][x] = 1 ;
           }
           else if ( q == 'D' ){
               y = 3 ;
               a[y][x] = 1 ;
           }
           r ++ ;
       }
         }
   }
   for ( i = 0 ; i < 4 ; i ++ ){
       for ( z = 1 ; z < 14 ; z ++ ){
            if ( i == 0  && a[i][z] == 0 )
            {
               cout << "S" << " " << z << endl ;
            }
            else if ( i == 1 && a[i][z] == 0 ){
               cout << "H" <<" " << z << endl ;
            }
            else if ( i == 2 && a[i][z] == 0 ){
               cout << "C" << " "<< z << endl ; 
            }
            else if ( i == 3 && a[i][z] == 0 ){
               cout << "D" << " "<< z << endl ;
            }
           }
   }
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
     
    typedef long long ll;
     
    int main(){
        ll X, K, D;
        ll x, cnt;
        cin >> X >> K >> D;
        X = abs(X);
        if(X/D>K){
            cout << X-K*D << endl;
            return 0;
        }
        else{
            cnt = X/D;
            x = X-(cnt+1)*D;
        }
        if((K-cnt+1)%2) cout << abs(x+D) << endl;
        else cout << abs(x) << endl;
        return 0;
    }

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int cum = 0;
    while (N--){
        int l, r;
        cin >> l >> r;
        cum += r - l + 1;
    }
    cout << cum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; string s; cin >> n >> s;
  map<int,int> C;
  rep(i, n) C[s[i]]++;

  ll ans = 1;
  for(auto it : C){
    ans *= (it.second + 1);
    ans %= MOD;
  }
  std::cout << ans-1 << '\n';
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		//List<Integer> list=new ArrayList<Integer>();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int count=0;

		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			if(a>=k)
				count++;
		}

		System.out.println(count);

	}

}

Measured memory_bytes: 49184
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll a,v,b,w; cin >> a >> v >> b >> w;
    ll t; cin >> t;
    if(abs(a-b) <= (v-w)*t) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N, input;
  bool flag = false;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> input;
    if(flag == false && input % 2 == 1) flag = true;
  }
  if(flag == false) cout << "second" << endl;
  else cout << "first" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N = NI()
A = [0 for _ in range(N+1)]
S = LI()
for i in S:
    A[i] += 1
for i in range(1,N+1):
    print (A[i])



Measured memory_bytes: 96192
from collections import deque

N=int(input())

E={i:{} for i in range(1,N+1)}

for _ in range(N-1):
    a,b,c=map(int,input().split())
    E[a][b]=c
    E[b][a]=c

Q,K=map(int,input().split())
inf=float("inf")
Dist=[inf]*(N+1)
Dist[K]=0
X=deque([K])

while X:
    u=X.popleft()
    for v in E[u]:
        if Dist[v]==inf:
            X.append(v)
            Dist[v]=Dist[u]+E[u][v]

T=[0]*Q
for i in range(Q):
    x,y=map(int,input().split())
    T[i]=Dist[x]+Dist[y]

print("\n".join(map(str,T)))

Measured memory_bytes: 135888
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int main()
{
	int n; cin >> n;
	bool flag = false;
	for(int i = 0; i <= 25; i++){
		for(int j = 0; j <= 20; j++){
			if(i * 4 + j * 7 == n) flag = true;
		}
	}
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc174/tasks/abc174_d
// greedy
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    const int n = readln.chomp.to!int;
    string s = readln.strip;

    int reds = 0;
    foreach(ch; s)
        if(ch == 'R')
            reds += 1;

    int ans = 0;
    for(int i = 0; i < reds; i++)
        if(s[i] == 'W')
            ans += 1;

    ans.writeln;
}


Measured memory_bytes: 2960
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[200010];
    rep(i, N) cin >> a[i];
    int cnt = 0;
    rep(i, N) {
        if(a[i] == cnt + 1) cnt++;
    }
    if(cnt == 0) {
        cout << -1 << endl;
    } else {
        cout << N - cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 4416
($h,$w)=split$",<>;
push@s,[split//]for<>;
@dx=(0,1,0,-1,1,1,-1,-1);
@dy=(1,0,-1,0,1,-1,1,-1);
for$i(0..$h-1){
	for$j(0..$w-1){
		if($s[$i][$j]eq'.'){
			$c=0;
			for(0..7){
				$tx=$i+$dx[$_];$ty=$j+$dy[$_];
				$c+=$tx>=0&&$ty>=0&&$tx<$h&&$ty<$w&&$s[$tx][$ty]eq'#';
			}
			$s[$i][$j]=$c;
		}
	}
	print@{$s[$i]};
}

Measured memory_bytes: 768
N,P=map(int,input().split());S,a,i,j,c=list(map(int,input())),0,0,1,[1]+[0]*P
if 10%P:
	for v in S[::-1]:i=(i+v*j)%P;j=j*10%P;a+=c[i];c[i]+=1
else:
	for i,v in enumerate(S):
		if v%P<1:a+=i+1
print(a)

Measured memory_bytes: 6432
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	cin>>t;
	if(t>=30)
		cout<<"Yes";
	else
		cout<<"No";
}


	

		

Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        Input input = InputParser.perse(sn, 2);
        sn.close();

        Integer n = input.getInt(0, 0);
        List<Integer> p = input.getIntLine(1);

        int min = p.get(0);
        int count = 1;
        for (int i = 1; i < p.size(); i++) {
            if (p.get(i) <= min) {
                count++;
                min = p.get(i);
            }
        }

        System.out.println(count);
    }

    private static class InputParser {
        static Input perse(Scanner sn, int line) {
            Input result = new Input();
            while (line-- > 0) {
                String[] args = sn.nextLine().split(" ");
                result.add(args);
            }
            return result;
        }
    }

    private static class Input {
        private List<List<String>> inputs;

        Input() {
            inputs = new ArrayList<>();
        }

        void add(String[] args) {
            inputs.add(Arrays.asList(args));
        }

        String getString(int i, int j) {
            return inputs.get(i).get(j);
        }

        int getInt(int i, int j) {
            return Integer.parseInt(getString(i, j));
        }

        double getDouble(int i, int j) {
            return Double.parseDouble(getString(i, j));
        }

        List<Integer> getIntLine(int i) {
            return inputs.get(i).stream().map(e -> Integer.parseInt(e)).collect(Collectors.toList());
        }

        List<Integer> getIntVerticalLine(int line, int start, int size) {
            List<Integer> list = new ArrayList<>();
            for (int i = start; i < start + size; i++) {
                list.add(getInt(i, line));
            }
            return list;
        }
    }
}

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

int n, m;
char mp[60][60];
int ans[60][60] = {0};

void solve(int posx, int posy) {
    for (int i = -1; i <= 1; i++) {
        int nx = posx + i;
        for (int j = -1; j <= 1; j++) {
            int ny = posy + j;
            if (nx < 0 || n <= nx) continue;
            if (ny < 0 || m <= ny) continue;
            if (mp[nx][ny] == '#') 
                ans[posx][posy]++;
        }
    }
}

int main(void) {
    cin >> n >> m;
    for (int i = 0;i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> mp[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            solve(i, j);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (mp[i][j] == '#') {
                cout << mp[i][j];
                continue;
            }
            cout << ans[i][j];
        }
        cout << '\n';
    }
    return 0;
}

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

int main() {

  string s, t;
  cin >> s >> t;

  int a, b;
  cin >> a >> b;

  string u;
  cin >> u;

  if (u == s) {
    a--;
  } else {
    b--;
  }

  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

int a=0;
int b=0;
int c=0;

int ok=0;

cin>>a>>b>>c;

if(a==b+c)ok=1;
if(b==a+c)ok=1;
if(c==a+b)ok=1;

if(ok==1)cout<<"Yes";
if(ok==0)cout<<"No";

}

Measured memory_bytes: 256
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <vector>
#include <iostream>

#define MAXCHAR 255

using namespace std;

int main()
{
	int numOf500 = 0;
	int limit = 0;
	cin >> numOf500;
	cin >> limit;
	if (500 * numOf500 >= limit)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	
	return 0;
}



Measured memory_bytes: 256
def left_bin(a, n, c):
    ns = [int(i) for i in bin(n)[3:]]
    t = a
    for i in ns:
        t = t*t % c
        if i == 1:
            t = t*a % c
    return t


n, k = map(int, input().split())
c = 10**9+7
tm = [0] + [1]*k
a = k//2
ans = k*(k+1)//2 - a*(a+1)//2
for i in range(k//2, 0, -1):
    a = k//i
    t = (left_bin(a, n, c) - sum([tm[j*i] for j in range(2, a+1)])) % c
    ans = (ans + t*i) % c
    tm[i] = t
print(ans)


Measured memory_bytes: 11992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a+b) % 24 << endl;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a, b;
	cin >> a >> b;
	a = ceil((a * 1.0) / b);
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int>v1,v2;;
	for (int i = 0 ; i < n ; i++) {
		int x;
		cin >> x;
		v1.pb(x);
		cin >> x;
		v2.pb(x);
	}
	sort(all(v1));
	sort(all(v2));
	if (n % 2) {
		int lb = v1[n/2];
		int rb = v2[n/2];
		cout << rb - lb + 1 << '\n';
	}
	else {
		int lb = v1[n/2] + v1[n/2-1];
		int rb = v2[n/2] + v2[n/2-1];
		cout << rb - lb + 1 << '\n';
	}
}


Measured memory_bytes: 5092
N = int(input())
A = list(map(int, input().split()))

# X xor Y = X + Y ならば X & Y = 0 が成り立つことを利用して
# しゃくとり法により解を求める
j = 0
acc = 0
s = 0
for i, a in enumerate(A):
    while a & acc != 0 and j < i:
        acc ^= A[j]
        j += 1
    s += i - j + 1
    acc ^= a
ans = s

print(ans)


Measured memory_bytes: 24840
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  long long int X;
  cin >> X;

  long long int five_h, five;
  five_h = X/500;
  X %= 500;
  five = X/5;

  cout << 1000*five_h + 5*five << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	var lines []string
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		lines = append(lines, stdin.Text())
	}

	if lines[0] == lines[1][:len(lines[1]) - 1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	string s;
	cin >> s;
	if(s[0] == 'S') cout << "Cloudy" << endl;
	if(s[0] == 'C') cout << "Rainy" << endl;
	if(s[0] == 'R') cout << "Sunny" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n;
	string s;
	cin>>n;
	cin>>s;
	ll ans = LINF;
	vector<ll> dp,dp2;
	rep(i,n+1){
		dp.push_back(0);
		dp2.push_back(0);
	}
	REP(i,n){
		if(s[i] == '.'){
			dp2[i] = dp2[i+1] + 1;
		}else{

			dp2[i] = dp2[i+1];
		}
	}
	rep(i,n){
		if(i==0){
			if(s[i] == '#'){
				dp[0] = 1;
			}
			continue;
		}
		if(s[i] == '#'){
			dp[i] = dp[i-1] + 1;
		}else{
			dp[i] = dp[i-1];
		}
	}
	rep(i,n){
		//cout<<i<<" "<<dp[i]<<" "<<dp2[i]<<endl;
	}

	rep(i,n-1){

		chmin(ans, dp[i] + dp2[i+1]);
	}
	chmin(ans,dp2[0]);
	chmin(ans,dp[n-1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <vector>

using namespace std;

string s1, s2, ans;
vector<vector<int>> dp(3005, vector<int>(3005, -1));

//1-based indexing makes it easier to print the LCS
void LCS()
{
    int pos1 = s1.length(), pos2 = s2.length();
    while(pos1 > 0 && pos2 > 0)
    {
        if(s1.at(pos1-1) == s2.at(pos2-1))
            ans = s1.at(pos1-1) + ans, pos1--, pos2--;
        else
        {
            if(dp[pos1][pos2-1] > dp[pos1-1][pos2]) pos2--;
            else pos1--;
        }
    }
}

//dp[pos1][pos2] stores the length of the longest common subsequence
//between s1 and s2 upto positions pos1 and pos2 (1-based indexing)
int solve(int pos1, int pos2)
{
    if(dp[pos1][pos2] != -1)
        return(dp[pos1][pos2]);
    if(pos1 == 0 || pos2 == 0)
        return(dp[pos1][pos2] = 0);
    if(s1.at(pos1-1) == s2.at(pos2-1))
        return(dp[pos1][pos2] = 1 + solve(pos1-1, pos2-1));
    return(dp[pos1][pos2] = max(solve(pos1, pos2-1), solve(pos1-1, pos2)));
}

int main()
{
    int len;
    cin >> s1 >> s2;
    len = solve(s1.length(), s2.length());
    LCS();
//    cout << len << endl;
    cout << ans << endl;
    return(0);
}

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

int h[100010],a[100010], b[100010];
int ans=0;

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,n)cin >> h[i];
  rep(j,m)cin >> a[j] >> b[j];

  bool checked[n];
  memset(checked,true,sizeof(checked));
  
  rep(j,m){
    if(h[a[j]-1]>h[b[j]-1])checked[b[j]-1]=false;
    else if(h[a[j]-1]<h[b[j]-1])checked[a[j]-1]=false;
    else{
      checked[a[j]-1]=false;
      checked[b[j]-1]=false;
    }
  }

  rep(i,n)if(checked[i])ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;
typedef vector<ll> vll;
// ll gcd(ll a, ll b){if (b==0){return a;}return gcd(b, a%b);}
// for (ll i=0;i<n;i++) {
// sort(.begin(),.end());
int main(){
  ll z,x,c;
  cin>>z>>x>>c;
  ll ans=min({z+x,x+c,c+z});
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    int k;
    cin>>k;
    rep(i,k) cout<<"ACL";
    cout<<endl;
    return 0;
}


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

// nCr mod を計算する O(n)
const int MAX_N = 1000010;
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ll s;
    cin>>s;

    ll c=s/3;

    COMinit();
    ll ans=0;
    for(ll k=1;k<=c;k++){
        ll n=s-k*3;
        ll tmp=COM(n+k-1,n);
        ans=(ans+tmp)%MOD;
    }

    cout<<ans<<endl;
} 


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

int main()
{
    int N;
    string ans;
    cin >> N;

    vector<vector<int>> T(9, vector<int>(9));
    for (int i = 0; i < T.size(); i++)
    {
        for (int j = 0; j < T.at(0).size(); j++)
        {
            T.at(i).at(j) = (i + 1) * (j + 1);
        }
    }
    bool flag = false;
    for (int i = 0; i < T.size(); i++)
    {
        for (int j = 0; j < T.at(0).size(); j++)
        {
            if (N == T.at(i).at(j))
            {
                flag = true;
                break;
            }
        }
        if (flag)
        {
            break;
        }
    }
    if (flag)
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int sx, sy, tx, ty;
  int i;
  int x, y;

  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  x = tx-sx;
  y = ty-sy;

  for(i = 0; i < x; i++) {
    printf("R");
  }
  for(i = 0; i < y; i++) {
    printf("U");
  }
  for(i = 0; i < x; i++) {
    printf("L");
  }
  for(i = 0; i < y; i++) {
    printf("D");
  }
  printf("DR");
  for(i = 0; i < x; i++) {
    printf("R");
  }
  for(i = 0; i < y; i++) {
    printf("U");
  }
  printf("ULUL");
  for(i = 0; i < x; i++) {
    printf("L");
  }
  for(i = 0; i < y; i++) {
    printf("D");
  }
  printf("DR\n");

  return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
mod = ["" for _ in range(k)]
# mod k の値同士しか干渉しない
for i in range(1, n + 1):
    mod[i % k] += t[i - 1]

ans = 0

for modk in mod:
    my_hand = ""
    for your_hand in modk:
        if your_hand == 'r' and my_hand != 'p':
            my_hand = 'p'
            ans += p
        elif your_hand == 's' and my_hand != 'r':
            my_hand = 'r'
            ans += r
        elif your_hand == 'p' and my_hand != 's':
            my_hand = 's'
            ans += s
        else:
            my_hand = ""

print(ans)


Measured memory_bytes: 6260
# Aizu Problem 0014: Integral
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def f(x):
    return x**2


def integral(d):
    s = 0
    dd = d
    while dd <= 600 - d:
        s += d * f(dd)
        dd += d
    return s

    
for line in sys.stdin:
    d = int(line)
    print(integral(d))

Measured memory_bytes: 7728
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	int cnt = 0;
      	int n = s.length();
      	for (int i = 0; i < n; i++) {
        	if (s.charAt(i) == '1') {
            	cnt++;
            }
        }
      System.out.println(cnt);
    }
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(void) {
int A,B;
scanf("%d %d",&A,&B);
int max =0;
if (A>B) max=A;
else max =B;
for (int i=0;i<max;i++){
    if (abs(A-i)==abs(B-i)){printf("%d",i);
                             break;          }
 else if ((abs(A-i)!=abs(B-i)) && i==max-1) {printf("IMPOSSIBLE");}

}
return EXIT_SUCCESS;
}


Measured memory_bytes: 128
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
#define ll long long int
const ll mod = 1000000007ll;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int N,K;

vector<ll> numcase;
 
void solve(){
	combination blue(K-1);//struct combinationのコンストラクタを呼び出す
	combination red(N-K+1);//struct combinationのコンストラクタを呼び出す
	for(int i=1;i<=K;i++){
		ll cases = red(N-K+1,i).x * blue(K-1,i-1).x;
		numcase.push_back(cases%mod);
	}
}
 
int main(){
	cin >> N >> K;
 
	solve();
 
	for(int i=0;i<numcase.size();i++) cout << numcase[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
using i64 = long long;
using namespace std;

const int maxn = 1e5;
i64 h[maxn], dp[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) dp[i] = min(
    dp[i - 1] + abs(h[i] - h[i - 1]), 
    dp[i - 2] + abs(h[i] - h[i - 2]));
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))
old = H[0]
for i in range(1, N):
    if H[i-1] > H[i] + 1:
        print("No")
        break
    else:
        if H[i-1] > H[i]:
            H[i] += 1
else:
    print("Yes")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n;
  cin >> n;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  //cout << n << "\n";
  
  cout << ( n >= 30 ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a, b) a = (((a)<(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
  ll n,a,b; cin>>n>>a>>b;
  VL x(n); rep(i,n) cin>>x[i];
  ll ans = 0;
  rep(i,n-1){
    ll d = x[i+1]-x[i];
    ans += min(a*d,b);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();

		String ans = "No";

		/*
		 * iは鶴
		 */
		for (int i = 0; i <= x; i++) {
			int j = x - i;
			if (y == 2 * i + 4 * j) {
				ans = "Yes";
			}

		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 35800
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var answers = new long[n + 1,3];
        
        for(var i = 0;i < n;i++){
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            for(var j = 0;j < 3;j++){
                answers[i + 1,j] = Math.Max(answers[i,(j + 1) % 3],answers[i,(j + 2) % 3]) + input[j]; 
            }
            
            
        }
        Console.WriteLine(Math.Max(answers[n,0],Math.Max(answers[n,1],answers[n,2])));
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, t, res;

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

int main(int argc, char **argv) {
	cin >> n >> res;
	REP(i, n - 1) {
		cin >> t;
		res = res / gcd(res, t) * t;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;

int binary_search(int key,vector<int> &a) {
    int ng = -1;
    int ok = (int)a.size(); 
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (a[mid] >= key) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> l(q),r(q);
	vector<int> p;
	rep(i,q){
		int le,re;
		cin >> le >> re;
		l[i] = le-1;
		r[i] = re-1;
	}
	rep(i,n-1){
		if(s[i]=='A' and s[i+1]=='C'){
			p.push_back(i);
		}
	}
	rep(i,q){
		int left_index = binary_search(l[i],p);
		int right_index = binary_search(r[i],p); 
		cout << right_index -left_index << " ";
	}
}

Measured memory_bytes: 2044
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	if sc.Text() == "0" {
		fmt.Println(1)
	}else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 1772
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));

function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $array[] = 1<<(ord($str[$i])-97);
}
$seg = new SegTree($array);

while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);

class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    if(is_array($n)){
      $array = $n;
      $n = count($array);
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = $n, $I = 2**$this->bits; $i < $I; ++$i){
        $array[] = 0;
      }
      $this->tree[0] = $array;
      $this->rollupAll();
    }else{
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = 0; $i < $this->bits; ++$i){
        $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
      }
    }
  }
  function rollupAll(){
    for($i = 1; $i < $this->bits; ++$i){
      $treei = &$this->tree[$i];
      $treeim = $this->tree[$i-1];
      for($j = 0, $J = 2**($this->bits - $i + 1); $j < $J; $j+=2){
        $treei[] = $treeim[$j] | $treeim[$j+1];
      }
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = $this->tree[$j-1][$i>>$j<<1] | $this->tree[$j-1][($i>>$j<<1) + 1];
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    $bits = $this->bits;
    $i = 0;
    while($f!=$t){
      $treei = $tree[$i];
      if(($f >> $i) & 1 == 1){
        $sum |= $treei[$f>>$i];
        $f+=1<<$i;
      }
      if(($t >> $i) & 1 == 1){
        $sum |= $treei[($t>>$i)-1];
        $t-=1<<$i;
      }
      ++$i;
    }
    return $sum;
  }
}

//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 55912
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> num(n);
  for(int i = 0;i < n;i++)cin >> num[i];
  ll res = 0;
  ll memo = 0;
  for(int i = 0;i < n;i++){
    if(num[i] == 0){
      res += memo / 2;
      memo = 0;
    }
    memo += num[i];
  }
  res += memo / 2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024