akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll r,d,x;
    cin>>r>>d>>x;
    for(ll i=1;i<=10;i++){
        x=(x*r)-d;
        cout<<x<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 100030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,k;
cin>>n>>k;
int x;
int cnt=0;
while(n--)
{
	cin>>x;
	if(x>=k)
	cnt++;
}
cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>

using namespace std;


int main()
{
	string S;
	map<string, int> m;
	m["SUN"] = 7;
	m["MON"] = 6;
	m["TUE"] = 5;
	m["WED"] = 4;
	m["THU"] = 3;
	m["FRI"] = 2;
	m["SAT"] = 1;

	cin >> S;
	cout << m[S] << endl;

	return 0;
}

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

bool f(string s){
	int len = s.size();
	if(len % 2 == 1) return false;
	for(int i = 0;i < len/2;i++){
		if(s[i] != s[i+len/2]) return false;
	}
	return true;
}

int main(){
	string s;
	cin >> s;
	int len = s.size();
	rep(i,len){
		s.pop_back();
		if(f(s)){
			int ans = s.size();
			cout << ans;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))

using namespace std;

void get_ans(int n, string s){
		vector<int> r,g,b;
	map<int,int> m;
	for(int i=0;i<n;i++){
		if(s[i] == 'R'){
			r.push_back(i);
		}else
		if(s[i] == 'G'){
			g.push_back(i);
		}else{
			b.push_back(i);
			m[i]++;
		}
	}
	ll ans = r.size()*g.size()*b.size();
	ll a=0;
	for(int i=0;i<r.size();i++){
		a++;
	}
	for(int i=0;i<r.size();i++){
		for(int j=0;j<g.size();j++){
			int mn = min(r[i],g[j]);
			int mx = max(r[i],g[j]);
			int num = mx-mn;
			if(num%2 == 0){
				if(m[mn+(num/2)]>0)ans--;
			}
			if(m[mx+num]>0)ans--;
			if(m[mn-num]>0)ans--;
		}
	}
	cout<<ans;
}

int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	get_ans(n,s);
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;
    vector<int> P(N),Q(N);
    rep(i,0,N){
        cin >> P[i];
        --P[i];
        Q[P[i]]=i;
    }
    
    vector<int> len(N,1);
    int max_len=1;
    rep(i,0,N){
        if(P[i]>0 and Q[P[i]-1]<i){
            len[i]=len[Q[P[i]-1]]+1;
            max_len=max(max_len,len[i]);
        }
    }

    cout << N-max_len << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)

int main(){
    int n,m;
    cin>>n>>m;
    int ans[n];
    int s[m], c[m];
    int flag[n]={};
    for(int i=0;i<n;i++) ans[i]=0;
    rep(i,m) {
        cin>>s[i]>>c[i];
    }
    rep(i,m){
        if(flag[s[i]-1]==0){
            ans[s[i]-1]=c[i];
            flag[s[i]-1]++;
        }
        else{
            if(ans[s[i]-1]==c[i]){
                ans[s[i]-1]=c[i];
                flag[s[i]-1]++;
            }
            else{
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    if(n==1){
        cout<<ans[0]<<endl;
        return 0;
    }
    else if (n>1){
        if(ans[0]==0 && flag[0]!=0){
            cout<<-1<<endl;
            return 0;
        }
      	if(ans[0]==0){
            ans[0]=1;
        }
        for(int i=0;i<n;i++){
            cout<<ans[i];
        }
        cout<<endl;
        return 0;
    }

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


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


}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define MOD 1000000007
int main()
 {
   int n,m,i,x;
   cin>>n>>m;
   ll dp[n+1];
   int broken[n+1]={0};
   for(i=0;i<m;i++)
    {cin>>x;
    broken[x]=1;
    }
    dp[0]=1,dp[1]=!(broken[1]);
   for(i=2;i<=n;i++)
   {
       if(broken[i])
        dp[i]=0;
       else
        dp[i]=(dp[i-1]+dp[i-2])%MOD;
   }
   cout<<dp[n]<<e;
}


Measured memory_bytes: 1408
'''
Created on 2020/09/10

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  if N==3:
    ans=[1,0,0]
    for _ in [0]*M:
      s,c=map(int,pin().split())
      if s==1 and c==0:
        print(-1)
        return 
      if s!=1 and ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        return 
      ans[s-1]=c
    a=""
    for i in ans:
      a+=str(i) 
    print(a)
    return 
  elif N==2:
    ans=[1,0]
    for _ in [0]*M:
      s,c=map(int,pin().split())
      if s==1 and c==0:
        print(-1)
        return 
      if s!=1 and ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        return 
      ans[s-1]=c
    a=""
    for i in ans:
      a+=str(i)
    print(a)
    return
  else:
    if M==0:
      print(0)
      return
    s,c=map(int,pin().split())
    ans=c 
    
    for j in range(M-1):
      s,c=map(int,pin().split())
      if c!=ans:
        print(-1)
        return 
    print(ans)
    return 
  
main()

Measured memory_bytes: 9308
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = arrayInt(sc, n);
		sc.close();
		int sousa = 0;
		for (int i = 0; i < n; i++) {
			if (i + 1 != a[i]) {
				sousa++;
			}
		}
		System.out.println(sousa <= 2 ? "YES" : "NO");
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
  int h,w;
  cin>>h>>w;
  char mine[h][w];

  REP(i,h){
    REP(j,w){
      cin>>mine[i][j];
    }
  }
  int dx[8]={1,-1,0,0,1,1,-1,-1};
  int dy[8]={0,0,-1,1,1,-1,1,-1};
  REP(i,h){
    REP(j,w){
      if (mine[i][j]=='#')
      {
        /* code */
        continue;
      }
      int num=0;
      for (int k = 0; k < 8; k++)
      {
        /* code */
        
        int ni=i+dy[k];
        int nj=j+dx[k];
        if (ni < 0 or h <= ni) continue;
        if (nj < 0 or w <= nj) continue;
        if (mine[ni][nj]=='#')
        {
          /* code */
          num++;
        }
      }
      mine[i][j]=char(num+'0');

    }
  }
  REP(i,h){
    REP(j,w){
      if (j==w-1)
      {
        /* code */
        cout<<mine[i][j]<<endl;
      }
      else
      {
        cout<<mine[i][j];
      }
      
      
    }
  }
  }

Measured memory_bytes: 256
/*
    [Gnana Deepak]
    [August 01, 2020 5:39 PM]
    [A - Frog 1]
    [https://atcoder.jp/contests/dp/tasks/dp_a]
    [2000 ms]
    [1024 MB]
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ld = long double;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define F first
#define S second
#define orderKey order_of_key
#define findOrder find_by_order
#define s(x) set<x>
#define um(x, y) unordered_map<x, y>
#define m(x, y) map<x, y>
#define p(x, y) pair<x, y>
#define v(x) vector<x>
#define min_heap(t) priority_queue<t, vector<t>, greater<t>>
#define max_heap(t) priority_queue<t>
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define eb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define ss(v) stable_sort(all(v))
#define fori(i, a, b) for (int i = a; i <= b; i++)
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define stprs(x) cout << fixed << setprecision(x);
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define bs binary_search
#define deb(x) cout << #x << "=" << x << '\n';
#define scn(v1)        \
    for (auto &x : v1) \
        cin >> x;
#define R(x) reverse(all(x));
#define lb lower_bound
#define ub upper_bound
const char nl = '\n';
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const ld PI = acos(-1);
const int N = 1e5;
const int imx = LLONG_MAX;
int DP[N + 1];
int H[N + 1];
void accio_ac(void)
{
    int n;
    cin >> n;
    fori(i, 1, n) cin >> H[i];
    DP[1] = 0;
    DP[2] = abs(H[1] - H[2]);
    fori(i, 3, n)
    {
        DP[i] = DP[i - 1] + abs(H[i] - H[i - 1]);
        DP[i] = min(DP[i], DP[i - 2] + abs(H[i] - H[i - 2]));
    }
    cout << DP[n] << endl;
}
int32_t main(void)
{
    fastio;
    int __ = 1;
    // cin >> __;
    while (__--)
    {
        accio_ac();
    }
    return 0;
}


Measured memory_bytes: 5168
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B, C = get_ints

x = C - (A - B)

puts x < 0 ? 0 : x


Measured memory_bytes: 14508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;

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

    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
        cout << "No" << endl;
        return 0;
    }
    else if(s.at(1)==s.at(2)&&s.at(2)==s.at(3)){
        cout << "No" << endl;
        return 0;
    }
    else if(s.at(0)==s.at(2)&&s.at(2)==s.at(3)){
        cout << "No" << endl;
        return 0;
    }

    if(s.at(0)==s.at(1) && s.at(2)==s.at(3)){
        cout << "Yes" << endl;
        return 0;
    }
    else if(s.at(0)==s.at(2) && s.at(1)==s.at(3)){
        cout << "Yes" << endl;
        return 0;
    }
    else if(s.at(0)==s.at(3) && s.at(1)==s.at(2)){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,m;
    cin>>n>>m;
    if(m%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    ll maxi=(m/2);
    ll mini=(m/4);
    if(m%4!=0)
        mini++;
    if((n>=mini)&&(n<=maxi))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;

int main(void){
    ll w[11], k[11];
    for(int i=0; i<10; i++){
        cin >> w[i];
    }
    for(int i=0; i<10; i++){
        cin >> k[i];
    }
    sort(w, w+10);
    sort(k, k+10);
    ll W, K;
    W=w[9]+w[8]+w[7];
    K=k[9]+k[8]+k[7];
    cout << W << " " << K << "\n";
     
     
    return 0;
}


Measured memory_bytes: 3076
program range_set
  integer :: n,a,b
  integer(8) :: modu=1000000007,x=1,f(0:5000,2)=0,g(0:5000,2)=0
  read(*,*) n,a,b
  if(a>b)then
    i=a
    a=b
    b=i
  endif
  g(1,2)=1
  do i=2,b-1
    g(i,2)=mod(sum(g(i-1,:)),modu)
    g(i,1)=mod(sum(g(1:i-a,2)),modu)
  enddo
  f(0,:)=1
  do i=1,n
    x=mod(x*2,modu)
    f(i,1)=mod(sum(f(max(i-a+1,0):i-1,2)),modu)
    do j=1,min(b-1,i)
      if(i==n)f(i,1)=mod(f(i,1)+f(i-j,1)*g(j,1),modu)
      f(i,2)=mod(f(i,2)+merge(sum(g(j,:)),mod(f(i-j,1)*g(j,2),modu),j==i),modu)
    enddo
  enddo
  print'(i0)',modulo(x-sum(f(n,:)),modu)
end program range_set

Measured memory_bytes: 2980
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter 
def main():
    N = int(readline())
    S = readline().rstrip().decode()
    d = Counter(S)
    sg = d['R']*d['G']*d['B']
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            if (i+j)%2 == 0:
                m = (i+j)//2
                if (S[i]!=S[j]) and (S[j]!=S[m]) and (S[m]!=S[i]):
                    cnt += 1
    print(sg-cnt)
if __name__ == '__main__':
    main()


Measured memory_bytes: 68744
from bisect import bisect_left
N, A, B, C, D = map(int, input().split())
A, B, C, D = A*2, B*2, C*2, D*2
M = C + (D - C) // 2
W = (D - C) // 2
arr = list(range(-(N-1)*M+A, N*M+A, C+D))

#s = []
#for n in arr:
#    s.append(str("%d-%s-%d" % ((n-W*(N-1))/2, n/2, (n+W*(N-1))/2)))
#print(', '.join(s))
    

idx = bisect_left(arr, B)
ans = 'NO'
if idx > 0:
    if B - arr[idx-1] <= W*(N-1):
        ans = 'YES'
if idx < N:
    if arr[idx] - B <= W*(N-1):
        ans = 'YES'
print(ans)


Measured memory_bytes: 28696
### 数列をいったん文字列に変換
numberString = input()
sumNumber = 0

### 文字列を分割、整数化
for i in range(len(numberString)):
  sumNumber += int(numberString[i])
  
  
### 和を9を法とする式で計算。
if sumNumber % 9 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9208
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int n=0;cin>>n;
	for(long long int a=1+n/4;n!=0&&a<=3*n/4;a++)
	{
		for(long long int b=a;n!=0&&b<3499;b++)
		{
			for(long long int c=max(b,3*n/4);n!=0&&c<3499;c++)
			{
				if(n*(a*b+b*c+c*a)==4*a*b*c)
				{
					cout<<a<<" "<<b<<" "<<c<<endl;
					n=0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n,a[200000],b[200000];
long long r;
int main (){
	cin >> n;
	for (int i=0;i<n;++i){
		cin >> a[i];
		b[i]=a[i]-i;
	}
	sort(b,b+n);
	for (int i=0;i<n;++i){
		r+=abs(b[i]-b[(n-1)/2]);
	}
	cout << r;
	return 0;
}


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

int main()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> h[i];
  }

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

  ll ans = 0;
  for (ll i = 0; i < n - k; i++)
  {
    ans += h[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4768
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define Find(v,key) ((v).find(key) != (v).end())
# define cauto const auto
# define int long long
using namespace std;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& fst, const Type& lst) { return (fst <= x) && (x < lst); }
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
#define Cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define Cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]

# define mp(f,s) make_pair(f, s)

using P = pair<int, int>;
# define Y first
# define X second

struct phash {
    inline size_t operator ()(const pair<int,int>& p) const {
        const auto h1 = hash<int>()(p.first);
        const auto h2 = hash<int>()(p.second);
        return h1 ^ (h2 << 1);
    }
};

bool can(const vector<vector<int>>& c, int h, int w, P pos) {
    return InRange(pos.Y, (int)0, h)
       and InRange(pos.X, (int)0, w)
       and c[pos.Y][pos.X] == 1;
}

signed main() {
    while (true) {
        Cin(int, w, h);
        if (w == 0 and h == 0) break;
        Cinvv(int, c, h, w);

        set<P> visited;
        int ans = 0;
        rep (y, h) rep (x, w) {
            stack<P> stk;
            P ini = mp(y, x);
            if (!Find(visited, ini) and can(c, h, w, ini)) ans++;
            else continue;
            stk.push(ini);
            visited.insert(ini);

            while (!stk.empty()) {
                P now = stk.top(); stk.pop();
                for (int dy = -1; dy <= 1; ++dy) {
                    for (int dx = -1; dx <= 1; ++dx) {
                        P nxt = mp(now.Y + dy, now.X + dx);
                        if (!can(c, h, w, nxt)) continue;
                        if (Find(visited, nxt)) continue;
                        stk.push(nxt);
                        visited.insert(nxt);
                    }
                }
            }
        }

        cout << ans << "\n";
    }

    return 0;
}



Measured memory_bytes: 3276
N,A,B,C,D = list(map(lambda x: int(x),input().split()))
S = " "+input()
def isAble():
    if "##" in S[A:C+1] or "##" in S[B:D+1]:
        return "No"
    if C>D:
        if "..." not in S[B-1:D+2]:
            return "No"
    return "Yes"

print(isAble())

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef long int li;
typedef unsigned long long ull;

int main(int argc,char* argv[])
{
    string w,ans="Yes";
    cin>>w;
    int a[26]={};
    for(char c:w) a[c-'a']++;
    for(int i:a) if(i%2) ans="No";
    cout<<ans<<endl;
    return 0;
}

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

if n != A+B+1:
    print('No')
    exit()
for i in range(n):
    if i == A:
        if S[i] == '-':
            continue
        else:
            break
    if not S[i].isdigit():
        break
else:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int h, w;
    cin >> h >> w;
    
    vector<string> vc( h * w );
    for( auto &x: vc )
    {
        cin >> x;
    }
    REP( i, h + 2 )
    {
        REP( j, w + 2 )
        {
            if( i == 0 || j == 0 || i == h + 1 || j == w + 1 )
            {
                cout << "#";
                continue;
            }
            cout << vc[ i - 1 ][ j - 1 ];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin >> k >> a >> b;
    int sum = k;
    int flag=0;
    while(sum<=b){
        if(a<=sum&&sum<=b){
            flag = 1;
            break;
        }
        sum+=k;
    }
    if(flag==1)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int X;
  cin >> X;
  int a = 100;

  int ans = 0;
  while(true) {
    ans++;
    a = (double)a * 1.01;
    if (X <= a) {
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int n;
	cin>>n;
	int ans=0;
	REP(i,n){
		string s=to_string(i+1);
		if(s.length()%2==1)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3688
N,A,B,C=map(int,input().split())
T=[int(input()) for i in range(N)]
INF=10**15

def solve(n,a,b,c):
  if n==N:
    if min(a,b,c) > 0 :
      return abs(a-A)+abs(b-B)+abs(c-C)-30
    else:
      return INF
  else:
    ret0=solve(n+1,a,b,c)
    ret1=solve(n+1,a+T[n],b,c)+10
    ret2=solve(n+1,a,b+T[n],c)+10
    ret3=solve(n+1,a,b,c+T[n])+10
    return min(ret0,ret1,ret2,ret3)
  
print(solve(0,0,0,0))
    

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define listcount 100000


typedef struct num{
	int value;
	struct num* under;
	struct num* over;
} number;



int main() {
	int n;
	scanf("%d",&n);
	if(n > 0){ //念のため
		int v;
		scanf("%d",&v);
		number first;
		first.value = v;
		first.under = NULL;
		first.over = NULL;
		
		for(int i = 1; i < n; i++){
			scanf("%d",&v);
			number *p = &first;
			
			for(int quit = 0;quit < 5 ;){
				if(p->value < v){
					if(p->over == NULL){
						//導入
						number *ins;
						if ((ins = (number *) malloc(sizeof(number))) == NULL) {
							break;
						}
						ins->value = v;
						ins->under = NULL;
						ins->over = NULL;
						p->over = ins;
						quit = 10;
					}else{
						p = p->over;
					}
				}else if(p->value > v){
					if(p->under == NULL){
						//導入
						number *ins;
						if ((ins = (number *) malloc(sizeof(number))) == NULL) {
							break;
						}
						ins->value = v;
						ins->under = NULL;
						ins->over = NULL;
						p->under = ins;
						quit = 10;
					}else{
						p = p->under;
					}
				}else{
					quit = 10;
				}
			}
		}
		//qの値
		scanf("%d",&n);
		int counter = 0; /// 一致数
		for(int i = 0; i < n; i++){
			scanf("%d",&v);
			number *p = &first;
			
			for(int quit = 0;quit < 5 ;){
				if(p->value < v){
					if(p->over == NULL){
						quit = 10;
					}else{
						p = p->over;
					}
				}else if(p->value > v){
					if(p->under == NULL){
						quit = 10;
					}else{
						p = p->under;
					}
				}else{
					counter++;
					quit = 10;
				}
			}
			
			
		}
		printf("%d\n",counter);
	}
	return 0;
}






Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const ll INF = pow(500,4);
const int MOD = 1000000007;
const double EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

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

ll dg[555][555], ds[555][555];
int main()
{
	REP(i, 555)REP(j, 555) dg[i][j] = ds[i][j] = INF;
	int w, h;
	cin >> w >> h;
	vs fld(h);
	REP(i, h) cin >> fld[i];
	pii s, g;
	vector<pii> sp, fl;
	REP(i, h)REP(j, w)
	{
		if (fld[i][j] == 's')
		{
			s = pii(i, j);
			fld[i][j] = '.';
		}
		if (fld[i][j] == 'g')
		{
			g = pii(i, j);
		}
		if (fld[i][j] == '.') fl.push_back(pii(i, j));
		if (fld[i][j] == '*')
		{
			sp.push_back(pii(i, j));
			ds[i][j] = 0;
		}
	}
	queue<pii> que;
	que.push(g);
	dg[g.first][g.second] = 0;
	while (que.size())
	{
		int tx = que.front().first;
		int ty = que.front().second;
		que.pop();
		REP(i, 4)
		{
			int nx = tx + dx[i]; int ny = ty + dy[i];
			if (fld[nx][ny] == '.'&&dg[nx][ny] == INF)
			{
				dg[nx][ny] = dg[tx][ty] + 1;
				que.push(pii(nx, ny));
			}
		}
	}
	while (que.size()) que.pop();
	REP(i, sp.size()) que.push(sp[i]);
	while (que.size())
	{
		int tx = que.front().first;
		int ty = que.front().second;
		que.pop();
		REP(i, 4)
		{
			int nx = tx + dx[i]; int ny = ty + dy[i];
			if (fld[nx][ny] == '.'&&ds[nx][ny] == INF)
			{
				ds[nx][ny] = ds[tx][ty] + 1;
				que.push(pii(nx, ny));
			}
		}
	}
	ld lb = 0, ub = INF;
	REP(cnt,200)
	{
		ld mid = (lb + ub) / 2;
		ld sum = 0;
		REP(i, fl.size())
		{
			int x = fl[i].first, y = fl[i].second;
			sum += min((ld)dg[x][y], ds[x][y] + mid);
		}
		sum /= fl.size();
		if (mid > sum) ub = mid;
		else lb = mid;
	}
	ld sum = 0;
	REP(i, fl.size()) sum += min((ld)dg[fl[i].first][fl[i].second], ds[fl[i].first][fl[i].second] + lb);
	cout << D10 << min((ld)dg[s.first][s.second], ds[s.first][s.second] + lb) << endl;
	return 0;
}

Measured memory_bytes: 8216
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;
using boost::bind;
using boost::function;
//e.g., function<int(int, int)> f = bind(add, 2, _1, _2);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

bool isBetween(int a, int l, int r){
  return l<=a&&a<r;
}

int main () {
  IN(n);
  IN(q);
  INS(s);
  vector<pair<int,int> > list;
  REP(i,q){
    int l,r;
    cin>>l;
    cin>>r;
    list.push_back(make_pair(l-1,r-1));
  }

  // set<int> aclist;
  // REP(i,n-1){
  //   if(s[i]=='A'&&s[i+1]=='C'){
  //     aclist.insert(i);
  //   }
  // }
  vector<int> aclist;
  REP(i,n-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      aclist.push_back(i);
    }
  }

  REP(i,q){
    cout << lower_bound(ALL(aclist), list[i].second)-lower_bound(ALL(aclist), list[i].first) << endl;
      //    boost::function<bool(int)> cond = bind(isBetween, _1, list[i].first, list[i].second);
    //    cout<<count_if(ALL(aclist), cond)<<endl;
  }
    
  
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, a, b;

int main(){
    cin >> n >> a >> b;
    if (abs(b-a)&1) puts("Borys");
    else puts("Alice");
}
































Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	cinf(a,n);
	ll max=a[0];
	ll min=a[0];
	ll sum=0;
	rep(i,n){
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
		sum+=a[i];
	}
	cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
int f,p;
string s;
map<char,int>m;
int bns1();
int g_A(){
  int r=0;
  if(s[p]=='('){
    p++;
    r=bns1();
    p++;
  }
  else{
    while(isdigit(s[p])){
      r=r*10+(s[p]-'0');
      p++;
    }
  }
  return r;
}
int bns3(){
  int res=g_A();
  while(m[s[p]]==3){
    int t=p++;
    if(s[t]=='+')res+=g_A();
    if(s[t]=='-')res-=g_A();
    if(s[t]=='*')res*=g_A();
  }
  return res;
}
int bns2(){
  int res=bns3();
  while(m[s[p]]==2){
    int t=p++;
    if(s[t]=='+')res+=bns3();
    if(s[t]=='-')res-=bns3();
    if(s[t]=='*')res*=bns3();
  }
  return res;
}
int bns1(){
  int res=bns2();
  while(m[s[p]]==1){
    int t=p++;
    if(s[t]=='+')res+=bns2();
    if(s[t]=='-')res-=bns2();
    if(s[t]=='*')res*=bns2();
  }
  return res;
}
int dfs(){
  int res=LLONG_MIN;
  r(i,3)r(j,3)r(k,3){
    m['+']=i+1;
    m['-']=j+1;
    m['*']=k+1;
    p=0;
    res=max(res,bns1());
  }
  return res;
}
main(){
  cin>>s;
  cout<<dfs()<<endl;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

const int LIM = 100000;

struct union_find {
    int par[LIM];

    union_find() { fill(par, par+LIM, -1); }

    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    bool unify(int x, int y) {
        int xx = find(x), yy = find(y);
        if (xx == yy) return false;
        if (par[xx] < par[yy]) {
            par[xx] += par[yy];
            par[yy] = xx;
        } else {
            par[yy] += par[xx];
            par[xx] = yy;
        }
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -par[find(x)];
    }
};

struct edge {
    int x, y, cost;
    edge() {}
    edge(int a, int b, int c): x(a), y(b), cost(c) {}

    bool operator < (const edge& o ) const {
        return cost > o.cost;
    }
};

int N;

vector<pair<int, i64> > arx, ary;


int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        i64 x, y;
        cin >> x >> y;
        arx.emplace_back(x, j);
        ary.emplace_back(y, j);
    }
    sort(begin(arx), end(arx));
    sort(begin(ary), end(ary));

    priority_queue<edge> pqx, pqy;

    for (int j = 0; j < N-1; ++j) {
        pqx.emplace(arx[j].second, arx[j+1].second, abs(arx[j].first - arx[j+1].first));
        pqy.emplace(ary[j].second, ary[j+1].second, abs(ary[j].first - ary[j+1].first));
    }

    union_find uf;
    i64 ans = 0;

    while (uf.size(0) < N) {
        assert(!pqx.empty() && !pqy.empty());
        edge ex = pqx.top(), ey = pqy.top();

        if (!uf.same(ex.x, ex.y) && ex.cost <= ey.cost) {
            ans += ex.cost;
            uf.unify(ex.x, ex.y);
        } else if (!uf.same(ey.x, ey.y) && ey.cost <= ex.cost) {
            ans += ey.cost;
            uf.unify(ey.x, ey.y);
        }

        if (uf.same(ex.x, ex.y)) {
            pqx.pop();
        }
        if (uf.same(ey.x, ey.y)) {
            pqy.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  
  vector<int> tmp(N);
  
  int score = 0;
  
  for (int i = 0; i < K; i++) {
    if (T.at(i) == 'r') {
      score += P;
      tmp.at(i) = 1;
//      cout << P << endl;
    }
    else if (T.at(i) == 's') {
      score += R;
      tmp.at(i) = 1;
//      cout << R << endl;
    }
    else {
      score += S;
      tmp.at(i) = 1;
//      cout << S << endl;
    }
  }
  
  int m = 2;
  
//  while ((m * K) < N) {
//    for (int i = (m - 1) * K; i < m * K; i++) {
//      if (T.at(i) == T.at(i - K) && tmp.at(i) == 1) {
//        tmp.at(i) = 0;
//      }
//      else if (T.at(i) == 'r') {
//        score += P;
//        tmp.at(i) = 1;      
//      }
//      else if (T.at(i) == 's') {
//        score += R;
//        tmp.at(i) = 1;
//      }
//      else {
//        score += S;
//        tmp.at(i) = 1;
//      }
//    }
//    m++;
//  }
  
  for (int i = K; i < N; i++) {
    if ((T.at(i) == T.at(i - K)) && (tmp.at(i- K) == 1)) {
      tmp.at(i) = 0;
//      cout << 0 << endl;
    }
    else if (T.at(i) == 'r') {
      score += P;
      tmp.at(i) = 1;
//      cout << P << endl;
    }
    else if (T.at(i) == 's') {
      score += R;
      tmp.at(i) = 1;
//      cout << R << endl;
    }
    else {
      score += S;
      tmp.at(i) = 1;
//      cout << S << endl;
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 848
#include <iostream>
#include <algorithm>
#include <deque>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> svector;
typedef vector <int> ivector;
typedef deque <string> sdeque;

int split(svector &tokens, const string &text, char delim=' '){
	int start = 0, end = 0;
	while ((end = text.find(delim, start)) != string::npos){
		tokens.push_back(text.substr(start, end - start));
		start = end + 1;
	}
	tokens.push_back(text.substr(start));
	return 0;
}

int sdeque_out(sdeque &A){
    int n=A.size();
    for (int i=0; i<n; i++){
        cout << A[i];
        if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int main(void){
	int n;
	string text = "";
	svector strs;
	sdeque que;
	sdeque::iterator pos;
	
	cin >> n;
	getline(cin, text);

	for (int i=0; i<n; i++){
		getline(cin, text);
		strs.clear();
		split(strs, text);

		if (strs[0]== "insert")
			que.push_front(strs[1]);
		else if (strs[0] == "delete"){
			pos = find( que.begin(), que.end(), strs[1] );
			if (pos != que.end()) que.erase(pos);
		}else if (strs[0] == "deleteFirst")
			que.pop_front();
		else if (strs[0] == "deleteLast")
			que.pop_back();
	}

	sdeque_out(que);
	return 0;
}

Measured memory_bytes: 56188
import sys
import os
import math

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

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

MOD = 10 ** 9 + 7


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

    N = ii()
    ret = []
    for n in range(N):
        S, P = sl()
        ret.append([S, int(P), n + 1])
    ret.sort(key=lambda List: (List[0], -List[1]))
    for s, p, n in ret: print(n)


if __name__ == '__main__':
    main()


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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
    mod = (i64)mod;
    i64 res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

template <int mod>
struct ModInt {
    using i64 = int64_t;
    i64 x;
    ModInt() : x(0) {}
    ModInt(i64 y) : x(y >= 0 ? y % mod : ((mod - (-y) % mod) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &rhs) {
        x = x * rhs.x % mod;
        return *this;
    }
    ModInt &operator/=(const ModInt &rhs) {
        *this *= rhs.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) {
        return os << rhs.x;
    }
    friend istream &operator>>(istream &is, ModInt &rhs) {
        i64 t;
        is >> t;
        rhs = ModInt<mod>(t);
        return (is);
    }

   private:
    ModInt inverse() const {
        i64 a = x, u = 1LL, v = 0LL, t, b = (i64)mod;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
};
using mint = ModInt<1000000007>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    i64 n, a, b;
    cin >> n >> a >> b;
    mint ans = (mod_pow(2, n, MOD) - 1) % MOD;
    mint nca = 1;
    rep(k, a) { nca *= (n - k); }
    rep(k, a) { nca /= (k + 1); }
    mint ncb = 1;
    rep(k, b) { ncb *= (n - k); }
    rep(k, b) { ncb /= (k + 1); }

    ans -= nca;
    ans -= ncb;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
h,w = map(int,input().split())
grid = []

for _ in range(h):
    l = list(input())
    grid.append(l)

def search(a,b):
    if grid[a][b] == "#":
        return "#"

    mine = 0

    if 0 <= a-1 and 0 <= b-1:
        if grid[a-1][b-1] == "#":
            mine += 1

    if 0 <= a-1:
        try:
            if grid[a-1][b] == "#":
                mine += 1
        except:
            pass

        try:
            if grid[a-1][b+1] == "#":
                mine += 1
        except:
            pass

    if 0 <= b-1:
        if grid[a][b-1] == "#":
                mine += 1

        try:
            if grid[a+1][b-1] == "#":
                mine += 1
        except:
            pass

    try:
        if grid[a][b+1] == "#":
            mine += 1
    except:
        pass


    try:
        if grid[a+1][b] == "#":
            mine += 1
    except:
        pass

    try:
        if grid[a+1][b+1] == "#":
            mine += 1
    except:
        pass

    return mine

ans = []
for i in range(h):
    l = []
    for j in range(w):
        l.append(search(i,j))
    ans.append(l)

for i in range(h):
    print(''.join(map(str, ans[i])))


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

const int maxn = 2e5 + 5;
int num[maxn];
long long ans;
int cnt = 0;
int mm;

int main(){
	int k,n; cin >> k >> n;
	for(int i = 1; i <= n; i++){
		cin >> num[i];
		if(num[i] == 0) cnt++;
	}

	for(int i = 1; i < n; i++){
		mm = max(mm , num[i + 1] - num[i]);
	}

	mm = max(mm , k - (num[n] - num[1]));


	cout << k - mm << endl;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL << 25) // 33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dp[1010][1010];
signed main(void) {
  while (true) {
    int n;
    string s[1010];
    cin >> n;
    if(!n) break;
    REP(i, n) cin >> s[i];

    REP(i, 1010) REP(j, 1010) dp[i][j] = 0;
    int ans = 0;
    REP(i, n) REP(j, n) {
      if (s[i][j] == '*')
        dp[i][j] = 0;
      else if (s[i][j] == '.') {
        if (i > 0 && j > 0)
          dp[i][j] = min({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]}) + 1;
        else
          dp[i][j] = 1;
      }
      ans = max(ans, dp[i][j]);
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 8120
n = int(input())
a_lst = list(map(int,input().split()))
b_lst = list(map(int,input().split()))
c_lst = list(map(int,input().split()))
ans = 0

for i in range(n):
    ans += b_lst[a_lst[i]-1]
    if  i != 0 and a_lst[i] == a_lst[i-1] + 1:
        ans += c_lst[a_lst[i-1]-1]
        
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
#include<set>
using namespace std;
int n,a[120000],b[120000];
int x,fa[120000],ans,tot,siz[120000];
map<int,int>p;
int find(int x){
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),x^=a[i],p[a[i]]++;
	p[x]++;
	int flag=0;
	for(int i=1;i<=n;i++)scanf("%d",&b[i]),p[b[i]]--,fa[i]=i,siz[i]=1,flag=max(flag,(int)(b[i]==x));
	for(int i=1;i<=n;i++)if(p[b[i]]<0){printf("-1\n");return 0;}
	ans=-flag;
	p.clear();
	for(int i=1;i<=n;i++){
		if(p[a[i]]==0)p[a[i]]=++tot;
		if(p[b[i]]==0)p[b[i]]=++tot;
		if(a[i]!=b[i])ans++;
		int x=find(p[a[i]]),y=find(p[b[i]]);
		if(x!=y)fa[x]=y,siz[y]+=siz[x],siz[x]=0;
	} 
	for(int i=1;i<=n;i++)if(siz[i]>1)ans++;
	ans=max(ans,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 8064
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

const int maxn = 2000005;

string s;
int n;
int a[maxn];

int dp[maxn][20];

int main() {
#ifdef __APPLE__
  freopen("main.in", "r", stdin);
#endif
  cin >> s;
  n = s.length();
  for (int i = 0; i < s.length(); ++i) {
    a[i + 1] = s[i] - '0';
  }

  for (int i = 0; i < 10; ++i) {
      dp[0][i] = min(i, 10 - i + 1);
  }

  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 10; ++j) {
      int cur = a[i] + j;
      dp[i][j] = 0x3f3f3f3f;
      for (int k = 0; k < 10; ++k) {
          dp[i][j] = min(dp[i][j], dp[i-1][k] + k + cur);
          if (cur >= 10 && k > 0)
              dp[i][j] = min(dp[i][j], dp[i-1][k] + k - 1 + cur - 10);
          if (cur < 10)
              dp[i][j] = min(dp[i][j], dp[i-1][k] + k + 1 + 10 - cur);
      }
    }

  int ans = 0x3f3f3f3f;
  for (int k = 0; k < 10; ++k) {
      ans = min(ans, dp[n][k] + k);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 87428
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    long long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
        cout << 1 ;
    else
        cout << (w * h) / 2 + ((w * h) % 2 != 0);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a-c)<= d || (abs(a-b)<= d && abs(b-c)<= d)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
int a[3001];
int dp[3001][3001][2];
int n, s;
int main(void)
{
	cin >> n >> s;
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int x=1;x<=s;x++)
		{
			dp[i][x][1] = dp[i-1][x][1];
			if(x == a[i]) dp[i][x][1] += i;
			else if(x > a[i]) dp[i][x][1] += dp[i-1][x-a[i]][1];
			dp[i][x][1] %= MOD;
			dp[i][x][0] = dp[i-1][x][0] + dp[i][x][1];
			dp[i][x][0] %= MOD;
		}
	}
	cout << dp[n][s][0] << endl;
	return 0;
}


Measured memory_bytes: 70656
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<LL> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    vector<int> ans(1, 0);
    LL cur = h[0];
    rep(i, n - 1) {
        if (h[i + 1] <= cur) {
            cur = h[i + 1];
            ans.back() += 1;
        } else {
            cur = h[i + 1];
            ans.push_back(0);
        }
    }
    sort(ans.begin(), ans.end(), greater<int>());
    cout << ans[0] << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  rep(i,n) cin >> s[i];
  int count = 0;
  rep(i,n){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
          count++;
        }
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;
ll fact[100001];

ll mod_pow(ll x, ll n) {
  if (n == 1) return x;
  ll res = mod_pow(x * x % mod, n / 2);
  if (n & 1) res = res * x % mod;
  return res;
}

ll nCk(ll n, ll k) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k == 0 || k == n) return 1;
  return fact[n] * mod_pow(fact[k], mod - 2) % mod * mod_pow(fact[n - k], mod - 2) % mod;
}

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

  vector<int> a(n + 1);
  int same;
  set<int> st;
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
    if (st.find(a[i]) != st.end()) {
      same = a[i];
    }
    st.insert(a[i]);
  }
  
  int b[2], j = 0;
  for (int i = 0; i < n + 1; i++) {
    if (a[i] == same) b[j++] = i;
  }

  fact[0] = fact[1] = 1;
  for (int i = 2; i <= 100000; i++) {
    fact[i] = i * fact[i - 1] % mod;
  }

  vector<ll> ans(n + 1, 0);
  for (int i = 1; i <= n + 1; i++) {
    ans[i - 1] += nCk(n - 1, i - 2);
    ans[i - 1] += nCk(n - 1, i - 1);
    ans[i - 1] += nCk(n - 1, i - 1);
    ans[i - 1] += mod - nCk(b[0] + n - b[1], i - 1);
    ans[i - 1] += nCk(n - 1, i);
    ans[i - 1] %= mod;

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

  return 0;
}

Measured memory_bytes: 7808
#include<iostream>

using namespace std;

int d[4][2];

int c(double x){
	if(x<0.2)return 3;
	if(x<0.6)return 2;
	if(x<1.1)return 1;
	return 0;
}
int main(){
	double a,b;
	while(cin>>a>>b){
		d[c(a)][0]++;
		d[c(b)][1]++;
	}
	for(int i=0;i<4;i++)cout<<d[i][0]<<" "<<d[i][1]<<endl;
}

Measured memory_bytes: 1224