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

int main() {

  int H,W;
  cin >> H >> W;

  string data[H];
  int count[H][W] = {};

  for(int i=0; i<H; i++){
    cin >> data[i];
  }

  for(int i=0; i<H; i++){

    bool hm = i-1 >= 0;
    bool hp = i+1 <= H-1;

    for(int j=0; j<W; j++){

      bool wm = j-1 >= 0;
      bool wp = j+1 <= W-1;

      if(data[i].at(j)=='#'){

        if(hm&&wm)count[i-1][j-1]++;
        if(hm)count[i-1][j]++;
        if(hm&&wp)count[i-1][j+1]++;
        if(wm)count[i][j-1]++;
        count[i][j]++;
        if(wp)count[i][j+1]++;
        if(hp&&wm)count[i+1][j-1]++;
        if(hp)count[i+1][j]++;
        if(hp&&wp)count[i+1][j+1]++;

      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i].at(j)=='#'){
        cout << '#';
      }else{
        cout << count[i][j];
      }
    }
    cout << endl;
  }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace v0_0003
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for (int i = 0; i < N; i++)
            {
                var len = Console.ReadLine().Split(' ');
                var lenVal = new List<int> {
                    int.Parse(len[0]),
                    int.Parse(len[1]),
                    int.Parse(len[2]),
                };

                int max = lenVal.Max();
                int sum = 0;

                for (int j = 0; j < 3; j++)
                {
                    if (lenVal[j] != max)
                    {
                        sum += lenVal[j] * lenVal[j];
                    }
                }

                Console.WriteLine((sum == max * max) ? "YES" : "NO");
            }
        }
    }
}

Measured memory_bytes: 9272
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	ll ans = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			for(int k = j + 1; k < n; ++k) {
				if( a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i] ) {
					if( a[i] != a[j] && a[i] != a[k] && a[j] != a[k] ) {
						ans++;
					}
				}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;
use std::vec::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn readChars(size: usize) -> Vec<char> {
    let mut s0: String = read();
    let mut s = Vec::new();
    for _ in 0..size {
        s.push(s0.pop().expect(""));
    }
    s.reverse();
    s
}

use std::cmp::*;

fn main() {
    let a: usize = read();
    let b: usize = read();

    let d = b - a;
    let s = sum(d);

    let r = s - b;

    println!("{}", r);
}

fn sum(n: usize) -> usize {
    if n == 0 {0} else {n + sum(n - 1)}
}


Measured memory_bytes: 4352
#pragma comment(linker, "/stack:200000000")
                #pragma GCC optimize ("Ofast")
                #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
                #include <iostream>
                #include <iomanip>
                #include <sstream>
                #include <cstring>
                #include <vector>
                #include <deque>
                #include <queue>
                #include <set>
                #include <map>
                #include <valarray>
                #include <iterator>
                #include <functional>
                #include <limits>
                #include <algorithm>
                #include <numeric>
                #include <cmath>
                #include <cassert>
                #include <unordered_map>
                #include <unordered_set>
                #include <stack>
                using namespace std;
                #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
                 #define trace(x) cerr << #x << ": " << x << " " << endl;
             
                typedef int64_t ll;
             
                #define endl '\n'
                #define int ll
                ll mod=1e9+7;
                ll mod1=1e9+5;
                
                ll power(ll a,ll b)
                {
                    if(b==0) return 1;
                    else if(b%2==0)
                        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
                    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
                }
                bool check(string s,string s1)
                {
                    int j=0;
                    for(int i=0;i<s.length();++i)
                    {
                        if(j==3)
                            break;
                        if(s[i]==s1[j])
                        {
                            j++;
                        }
                    }
                    if(j==3)
                        return 1;
                    return 0;

                }
             int32_t main()
                {
                IOS
              
                int s;
                cin>>s;
                int p=s/100;
                s=s%100;
                
                    for(int j=0;j<=100;++j)
                        for(int k=0;k<=100;++k)
                            for(int l=0;l<=100;++l)
                                for(int m=0;m<=100;++m)
                                    for(int n=0;n<=100;++n)
                                    {
                                        int cos=j+2*k+3*l+4*m+5*n;
                                        if(cos==s and j+k+l+m+n<=p)
                                        {
                                            cout<<1;
                                            return 0;
                                        }

                                        if(cos>s or j+k+l+m+n>p)
                                            break;
                                    }
                                    cout<<0;
                
            }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX ((int)(1e9)+2)
using namespace std;

int dp[102][(int)(1e5)+7], c[105], v[105];

int call(int n, int rem)
{
    if(rem<=0) return 0;
    if(n==0){
        return MAX;
    }
    if(dp[n][rem]!=-1) return dp[n][rem];
    dp[n][rem] = MAX;
    dp[n][rem] = min(dp[n][rem],call(n-1,rem));
    dp[n][rem] = min(dp[n][rem],call(n-1,rem-v[n])+c[n]);
    return dp[n][rem];
}

int main()
{
    int n, w;
    scanf("%d %d",&n,&w);
    for(int i = 1; i<=n; i++) scanf("%d %d",&c[i],&v[i]);
    memset(dp,-1,sizeof dp);
    for(int i = ((int)(1e5)+2); i>=0; i--){
        if(call(n,i)<=w){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 40064
// ------------------------------------
// Date:2018/ 3/ 7
// Problem:ABC 076 AdditionAndMultiplication b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N, K;
  cin >> N >> K;
  int ans = 1;
  REP(i, N) {
    ans = min(2 * ans, ans + K);
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
    int n;
    cin>>n;
    vector <long long> vec (n,0);
    vector <long long> sum(n,0);
    vector <vector <long long>> dp(n,vector<long long>(n,0));
    long long sm=0;
    for(int i=0;i<n;i++){
        cin>>vec[i];
        sm+=vec[i];
        sum[i]=sm;
    }
    for(int i=1;i<=n;i++){
     for(int j=0;j<=n-i;j++){
         long long sub=(j==0)?0:sum[j-1];
         long long sm=sum[j+i-1]-sub;
         if(i==1)dp[j][j]=vec[j];
         else dp[j][j+i-1]=sm-min(dp[j+1][j+i-1],dp[j][j+i-2]);
     }
    }
    long long oth=sum[n-1]-dp[0][n-1];
    cout<<dp[0][n-1]-oth<<endl;
}

Measured memory_bytes: 70784
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

N = int(input())
MOD = 10**9 + 7
S = ['A', 'G', 'C', 'T']
M = set(['AGC', 'GAC', 'ACG'])

for s in S:
    M.add(s + 'AGC')
    M.add(s + 'GAC')
    M.add(s + 'ACG')
    M.add('A' + s + 'GC')
    M.add('AG' + s + 'C')

@lru_cache(maxsize=None)
def search(prev, length):
    if length >= N:
        return 1

    ret = 0

    for s in S:
        T = prev + s
        if not T in M:
            T = T[:: -1][: 3][:: -1]
            ret += search(T, length + 1)
    return ret

ans = search('', 0) % MOD
print(ans)


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

int main(void)
{
  int N;
  scanf("%d", &N);
  char s[N][10];
  for (int i = 0; i < N; i++) {
    scanf("%s", &s[i]);
  }
  
  
  int M;
  scanf("%d", &M);
  char t[M][10];
  for (int i = 0; i < M; i++) {
    scanf("%s", &t[i]);
  }
  
  int max = 0;
  for (int i = 0; i < N; i++) {
    int cnt = 0;
    //青で同じものを数える
    for (int j = 0; j < N; j++) {
      if (strcmp(s[i], s[j]) == 0) {
        cnt++;
      }
    }
    //赤で同じものを差し引く
    for (int j = 0; j < M; j++) {
      if (strcmp(s[i], t[j]) == 0) {
        cnt--;
      }
    }
    if (cnt > max) {
      max = cnt;
    }
  }
  
  printf("%d", max);
  
  return 0;
}


int judge(char s[10], char t[10]) {
  for (int i = 0; i < 10; i++) {
    if (s[i] != t[i])  {
      return 0;
    }
  }
  
  return 1;
}








Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n;
	int sum;
	int i;
	
	sum = 100000;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		sum *= 1.05;
		if (sum % 1000 != 0){
			sum = (sum / 1000 + 1) * 1000;
		}
	}
	printf("%d\n", sum);
	
	return (0);
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define long long ll;
using namespace std;
const int mod=1e9+7;

const int maxn = 1e6+5;

int main()
{
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++) {
        cout << 'x';
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,M = map(int, input().split())
stores = [tuple(map(int, input().split())) for _ in range(N)]
stores.sort()
total = 0
for store in stores:
    if store[1] < M:
        M -= store[1]
        total += store[0] * store[1]
    else:
        total += store[0] * M
        break
print(total)

Measured memory_bytes: 16904
/*input
9
4 2 5 8 3 6 1 7 9
6 8 8 4 6 3 5 7 5
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
using namespace std;
#define N  200005
map <lld,lld> bt;
lld bt2[N];
void add2(lld val,lld inc)
{
	for(lld i=val;i<N;i=i+(i&(-i)))
	{
		bt2[i]=max(inc,bt2[i]);
	}
}
lld ans2(lld val)
{
	lld fans=0;
	for(int i=val;i>0;i-=(i&(-i)))
	{
		fans=max(bt2[i],fans);
	}
	return fans;
}
void solve()
{
	lld n;
	cin >> n;
	lld a[n],b[n];
	set <lld> s;
	rep(i,0,n)
	{
		cin >> a[i];
		s.insert(a[i]);
	}
	map <lld,lld> ind2;
	lld c=0;
	for(auto i:s)
	{
		ind2[i]=c+1;
		c++;
	}
	rep(i,0,n)
	{
		a[i]=ind2[a[i]];
	}
	rep(j,0,n)
	{
		cin >> b[j];
	}
	lld fas=0;
	rep(i,0,n)
	{
		lld q1=ans2(a[i]);
		add2(a[i],q1+b[i]);
		fas=max(fas,q1+b[i]);
	}
	cout << fas << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, d[50];

int main() {
	cin >> n;
	inc(i, n) { cin >> d[i]; }
	
	int ans = 0;
	inc(i, n) {
	inc(j, i) {
		ans += d[i] * d[j];
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using in6 = int64_t;
using ind = double;
using vi = vector<in6>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<in6,in6>;
using psi = pair<string,in6>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() { cout << "Yes"; }

void no() { cout << "No"; }

int main() {
  kyun;
  in6 n,m;
  cin >> n >> m;
  vi check(n,0);
  vi pen(n,0);
  in6 ans = 0, miss = 0;
  rep(i,m) {
    in6 p;
    string r;
    cin >> p >> r;
    if(check[p-1] == 0) {
      if(r == "WA") pen[p-1]++;
      else { ans++; check[p-1]++; }
    }
  }
  rep(i,n) if(check[i] == 1) miss += pen[i];
  cout << ans << " " << miss;
  hinata;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next()) * 2;
		long x = Integer.parseInt(sc.next());
		long y = Integer.parseInt(sc.next());
		long am = 0;
		long bm = 0;
		if (x < y) {
			am = c * x;
			bm = (y - x) * b;
			bm = Math.min(bm, (y - x) * c);
		}
		else {
			bm = c * y;
			am = (x - y) * a;
			am = Math.min(am, (x - y) * c);
		}
		if (a * x + b * y < am + bm) {
			am = a * x;
			bm = b * y;
		}
		System.out.println(am + bm);
	}
}

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

ll N,H,d,h;

int main(){
  cin >> N >> H;
  ll ans = 0;

  ll cur = H;
  priority_queue<pll> q;
  for(int i=0;i<N-1;i++){

    cin >> d >> h;
    ll rem = H-cur;
    priority_queue<pll> tmp;
    while(q.size() && q.top().first >= h){
      pll p = q.top(); q.pop();
      rem -= p.second * p.first;
      tmp.push(p);
    }
    swap(q,tmp);
    ll times = rem/h;
    if(times)q.push(pll(h,times));
    if(times*h != rem)q.push(pll(rem-times*h,1));

    cur -= d;
    while(cur<=0){
      pll p = q.top(); q.pop();
      ll need = -cur/p.first+1;

      if(need <= p.second){
	ans += need;
	p.second -= need;
	cur += need * p.first;
	if(p.second)q.push(p);
      }else{
	ans += p.second;
	cur += p.first * p.second;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1200
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC156
{
    /// <summary>
    /// 
    /// </summary>
    static class B
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var k = NextInt();


            var count = 0;
            while (n >= k)
            {
                n /= k;
                count++;
            }

            Console.WriteLine(count+1);
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;

namespace Aojx
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s;
            while ((s = Console.ReadLine()) != null)
            {
                var row = s.Split(',');
                string num = row[0];
                double w = double.Parse(row[1]);
                double h = double.Parse(row[2]);

                double bmi = w / h / h;

                if (bmi >= 25)
                {
                    Console.WriteLine(num);
                }
            }
        }
    }
}

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

int main(){
  int n;
  while(cin >> n, n){
    vector<vector<int> > v;
    vector<int> l;
    v.resize(n);
    int m, k, info;
    for(int i = 0; i < n; i++){
      cin >> m;
      for(int j = 0; j < m; j++){
        cin >> info;
        v[i].push_back(info);
      }
    }
    cin >> k;
    for(int i = 0; i < k; i++){
      cin >> info;
      l.push_back(info);
    }
    int cri = 0, ans = 0;
    for(int i = 0; i < n; i++){
      if(v[i].size() == 0) continue;
      int cnt = 0;
      for(int j = 0; j < v[i].size(); j++){
        for(int t = 0; t < l.size(); t++){
          if(v[i][j] == l[t]) cnt++;
        }
      }
      if(cnt == l.size()){
        cri++;
        ans = i + 1;
      }
    }
    cout << (cri != 1 ? -1 : ans) << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
H,W=map(int,input().split())
s=[0]*H
for i in range(H):
  s[i]= list(input())

dp= [[float("inf") for _ in range(W)] for _ in range(H)]
dp[0][0]= 1 if s[0][0]=="#" else 0

mv=[(-1,0),(0,-1)]
for i in range(H):
  for j in range(W):
    if i==0 and j==0: pass
    else:
      tmp=float("inf")
      for k in mv:
        a = i+k[0]
        b = j+k[1]
        if 0 <=a <= H-1 and 0 <=b <= W-1:
          if s[i][j]=="#" and s[a][b]==".":
            tmp= dp[a][b]+1
          else:
            tmp= dp[a][b]
        dp[i][j]=min(dp[i][j],tmp)
        
print(dp[-1][-1])

Measured memory_bytes: 3444
H, W = map(int, input().split())
M = [[j if j == "#" else 0 for j in input()] for i in range(H)]

for i in range(H):
    M[i].append(0)
    M[i].insert(0, 0)
HH = [0 for i in range(W+2)]
M.append(HH)
M.insert(0, HH)

for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == "#":
            if M[i-1][j-1] != "#":
                M[i-1][j-1] += 1
            if M[i-1][j] != "#":    
                M[i-1][j] += 1
            if M[i-1][j+1] != "#":
                M[i-1][j+1] += 1
            if M[i][j-1] != "#":
                M[i][j-1] += 1
            if M[i][j+1] != "#":
                M[i][j+1] += 1
            if M[i+1][j-1] != "#":
                M[i+1][j-1] += 1
            if M[i+1][j] != "#":
                M[i+1][j] += 1
            if M[i+1][j+1] != "#":
                M[i+1][j+1] += 1
for i in range(1, H+1):
    for j in range(1, W+1):
        print(M[i][j], end="")
    print()

Measured memory_bytes: 3572
#include<iostream>
#include<cstring>
int main (void){
  int n,ans=0;
  scanf("%d",&n);
  int b[n+1],a[n+1];
  for(int i=1;i<=n-1;i++){
    scanf("%d",&b[i]);
    a[i]=b[i];
  }
  a[n]=b[n-1];
  for(int i=1;i<=n-1;i++){
    if(b[i]<a[i]){a[i]=b[i];}
    if(b[i]<a[i+1]){a[i+1]=b[i];}
  }
  for(int i=1;i<=n;i++){
    ans=ans+a[i];
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	if A+B > C+D {
		fmt.Print("Left")
	} else if A+B < C+D {
		fmt.Print("Right")
	} else {
		fmt.Print("Balanced")
	}
}


Measured memory_bytes: 1832
#include <iostream>
#include <cstdlib>

using namespace std;
int main() {
  int N;
  cin>>N;
  
  for(int i=0;i<=N/4;++i){
      if((N-4*i)%7==0){
          cout<<"Yes"<<endl;
          return 0;
      }
  }
  cout<<"No"<<endl;
}

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


bool lt(const string &a,const string &b){
	if(a.length() != b.length()) return a.length() < b.length();
	else return a < b;
}
string merge(string a,string b){
	if(~a.find(b)) return a;
	for(int i = 0 ; i < a.size() ; i++){
		bool f = true;
		for(int j = 0 ; i+j < a.size() ; j++){
			if( a[i+j] != b[j] ){ f = false; break; }
		}
		if(f) return a.substr(0,i) + b;
	}
	return a+b;
}

int main(){
	int n;
	while(cin >> n && n){
		string v[10];
		map<string,string> memo[1024];
		for(int i = 0 ; i < n ; i++) cin >> v[i];
		sort(v,v+n);
		for(int i = 0 ; i < n ; i++) memo[1<<i][v[i]] = v[i];
		
		for(int bit = 0 ; bit < (1<<n) ; bit++){
			for( map<string,string>::iterator it = memo[bit].begin() ; it != memo[bit].end() ; ++it){
				string s = it->second;
				for(int i = 0 ; i < n ; i++){
					if(!(bit>>i&1)){
						string r = merge(s,v[i]);
						string key = r.substr(max(0,(int)r.size()-10));
						string& ans = memo[bit|(1<<i)][key];
						
						if(ans == "" || lt(r,ans)) ans = r;
					}
				}
			}
		}
		string ans = "";
		for( map<string,string>::iterator it = memo[(1<<n)-1].begin() ; it != memo[(1<<n)-1].end() ; ++it){
			string m = it->second;
			if(ans == "" || lt(m,ans)) ans = m;
		}
		cout << ans << endl;
	}
}

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

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

    replace(s.begin(), s.end(), ',', ' ');
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    // 整数の入力
    int n, m, x;
    int a[m];
    cin >> n >> m >> x;
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    
    // kangaeru
    int counter=0;
    for(int i=0;a[i]<x;i++){
        counter++;
    }
    
    // output
    if(counter<m-counter){
        cout << counter << endl;
    }else{
        cout << m-counter << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    vector<int> on(101, 0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    repeat_from_to(i, a, b) ++on[i];
    repeat_from_to(i, c, d) ++on[i];
    
    int ans = count(on.begin(), on.end(), 2);
    if (ans > 0) cout << ans - 1 << endl;
    else cout << 0 << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long>data(N);
  for (int i=0; i<N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  long long sum=0;
  for (int i=1; i<N; i++) {
    sum = sum + data.at(i/2);
  }
  cout << sum << endl;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a[100];
  cin >> n;
  for (int i = 0; i < n;i++){
    cin >> a[i];
  }
  int b=0, c=0, d=0;
  sort(a, a + n, greater<int>());
  for (int j = 0; j < n;j++){
    if(j%2==0){
      b = b + a[j];
    }else{
      c = c + a[j];
    }
  }
  cout << b - c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

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

vector<edge> E;
int d[1005];

bool bellman_ford(int s, int n){
	fill(d,d+n,INF);
	d[s] = 0;
	int cnt = 0;

	while(true) {
		bool update = false;
		rep(i, E.size()) {
			edge e = E[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}

		if(!update) break;
		cnt++;
		if(cnt > n) {
			return false;
		}
	}

	return true;
}

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

	rep(i, m) {
		int s, t, c;
		cin >> s >> t >> c;

		E.push_back(edge(s, t, c));
	}

	if(bellman_ford(r, n)) {
		rep(i, n){
			if(d[i] == INF) cout << "INF" << endl;
			else cout << d[i] << endl;
		}
	} else {
		cout << "NEGATIVE CYCLE" << endl;
	}

	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);


  int a, b, c; cin >> a >> b >> c;
  cout<<(abs(a-b)<abs(a-c)?'A':'B')<<endl;


  return 0;
}


Measured memory_bytes: 256
// Problem : B - Homework
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m;
	cin >> n >> m;
	long long tot = 0;
	for(int i = 0; i < m; i++) {
		int x; cin >> x;
		tot += x;
	}
	long long ans = n - tot;
	if(ans < 0) {
		ans = -1;
	}
	cout << ans << '\n';
				
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  
  for(int i = 0; i < n-1; i++){
  for(int j = i+1; j < n; j++){
  
  	int k = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
  	ans += k - j - 1;
  
  }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)>d)
	{
		if(abs(a-b)>d || abs(b-c)>d)
		{
			cout<<"No"<<endl;
		}
		else
		{
			cout<<"Yes"<<endl;
		}
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int n[3];
  cin >> n[0] >> n[1] >> n[2];
  sort(n,n+3);
  int mx;
  mx=n[2]*10 + n[1] + n[0];
  cout << mx << endl;
  return 0;
}

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

int main() {
  int R;
  cin >>R;
  if(R<1200){
    cout <<"ABC" <<endl;
  }
  else if(R<2800){
    cout <<"ARC" <<endl;
  }
  else{
    cout <<"AGC" <<endl;
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

map<int, int> g[MAXN];

set<pii> st;

int sz[MAXN];

void solve(){
	int n, a, b;
	scanf("%d", &n);
	REP(i, 0, 2 * (n - 1)) {
		scanf("%d%d", &a, &b);
		g[a][b]++;
		g[b][a]++;
	}
	REPN(i, 1, n) {
		FA(it, g[i]) {
			if (it->_1 > i && it->_2 > 1) {
				st.insert(mp(i, it->_1));
				
				//printf("+ %d %d\n", i, it->_1);
			}
		}
		sz[i] = 1;
	}
	int cnt = 0;
	while(!st.empty()) {
		a = st.begin()->_1;
		b = st.begin()->_2;
		st.erase(st.begin());
		
		//printf("- %d %d\n", a, b);
		
		cnt++;
		if (sz[a] < sz[b]) {
			swap(a, b);
		}
		
		sz[a] += sz[b];
		
		g[b].erase(a);
		g[a].erase(b);
		
		FA(it, g[b]) {
			int to = it->_1;
			int d = it->_2;
			
			g[to].erase(b);
			
			int mn = min(b, to);
			int mx = b + to - mn;
			if (st.find(mp(mn, mx)) != st.end()) {
				st.erase(mp(mn, mx));
			}
			
			mn = min(a, to);
			mx = a + to - mn;
			
			if (g[a].find(to) == g[a].end() && d > 1 || g[a][to] == 1) {
				st.insert(mp(mn, mx));
				
				//printf("+ %d %d\n", mn, mx);
			}
			
			g[a][to] += d;
			g[to][a] += d;
		}
		
		g[b].clear();
	}
	if (cnt == n - 1) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 24064
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

//今井先生仕様

#include <stdio.h>
void quicksort(int a[],int lower,int upper);
void swap(int *a,int *b);
void printArray(int a[],int n);

void quicksort(pair<int,int> a[],int lower,int upper){
	int bound=a[lower].second,l=lower,u=upper;
	do{
		while(a[l].second<bound)l++;
		while(a[u].second>bound)u--;
		if(l<=u){
			a[u].swap(a[l]);
			l++;
			u--;
		}
	}while(l<u);
	if(lower<u)quicksort(a,lower,u);
	if(l<upper)quicksort(a,l,upper);
}

int main(){
	int num=0;
	pair<int,int> time[200000]={};
	cin>>num;
	for(int i=0;i<num;i++){
		cin>>time[i].first>>time[i].second;
	}
	quicksort(time,0,num-1);
	long sum=0;
	for(int i=0;i<num;i++){
		sum+=time[i].first;
		if(sum>time[i].second){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<long> x(N); vector<long> y(M);
rep(i, N) cin >> x.at(i);
rep(i, M) cin >> y.at(i);
sort(x.begin(), x.end());
sort(y.begin(), y.end());
long MAX = max(X, x.at(N - 1));
long MIN = min(Y, y.at(0));
string ans = "War";
if(MIN > MAX) ans = "No War";



// cout << MAX << ' ' << MIN << endl;
cout << ans << endl;
return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];

    sort(all(d));
    int now = 0, ans = 0;
    rep(i, n) {
        if(d[i] > now) {
            ans++;
            now = d[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  // N要素の配列で初期化
  vector<int> vec(N);
 
  // N個の入力を受け取る
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int s;
  s=0;
    for (int j = 0; j < N; j++) {
      for ( int k = j; k < N-1; k++) {
        s += vec.at(j) * vec.at(k+1);
      }
    }
  cout<< s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>                                      
                                                       
signed main()                                          
{                                                      
  int a,b,t;                                           
  scanf("%d %d %d",&a,&b,&t);                          
                                                       
  int ans = 0;                                         
  int i;                                               
                                                       
  for( i = 1; i * a <= t + 0.5; ++i ){                 
  ans += b;                                            
  }                                                    
  printf("%d\n",ans);                                  
                                                       
  return 0;                                            
                                                       
}                                                      
                                                       

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}
map<char,int> a;
void solve() {
    string w;
    cin >> w;
    for(int i = 0;i < w.size();i++){
        a[w[i]]++;
    }
    bool flag = false;
    for(int i = 0;i < w.size();i++){
        if(a[w[i]]%2 != 0){
            flag = true;
        }
    }
    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    

}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let mut wait: Vec<i64> = (&mut iter).take(5).map(|x| x.parse().unwrap()).collect();
    let mut wait_ceil = vec![];
    wait.sort_by_key(|x| (x - 1) % 10);
    for i in 0..5 {
        if wait[i] % 10 > 0 {
            wait_ceil.push(wait[i] - wait[i]%10 + 10);
        } else {
            wait_ceil.push(wait[i]);
        }
    }
    println!("{}", wait[0] + wait_ceil.iter().skip(1).fold(0, |acc, x| x + acc));
}


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

                            #define FOR(i,a,b) for(int i = (a); i < (b); i++)
                            #define rep(i,n) FOR(i,0,n)
                            #define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
                            #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
                            #define FILL(a, value) memset(a, value, sizeof(a)

                            #define SZ(a) (int)a.size()
                            #define ALL(a) a.begin(), a.end()
                            #define PB push_back
                            #define MP make_pair
                            #define er erase
                            #define in insert
                            #define f first
                            #define s second



                            typedef  long long LL;
                            typedef vector<int> VI;
                            typedef vector<LL > VL;
                            typedef vector<vector<int > > VVI;
                            typedef vector<vector<LL>> VVL;
                            typedef vector <vector<pair<int, int >> >VVPI;
                            typedef vector<vector<pair<LL, LL >> >VVPL;
                            typedef vector<pair<LL, LL >> PL;
                            typedef vector<PL> VPL;
                            typedef pair<int, int> PII;
                            typedef vector<PII> VPI;

                            const double PI = acos(-1.0);
                            const int INF = 1e9;
                            const LL LINF = (LL)1e18;

                            const double EPS = 1e-7;
                            const int MAS =  3 *1e5 + 10;
                            const int mod = 998244353;
                            const int MOD =1e9+7;
                            const int LOG= 19;
                            const int ar = 1e5 +100;
                            const int MAX = 1e6 + 1e2;

                        int main() {
                            ios_base::sync_with_stdio(false);
                            cin.tie(NULL);
                            int  n,k ;
                            cin >> n >> k;
                            VI a(n);
                            rep(i,n)cin >> a[i];
                            VI dp(n + 10,INF);
                            dp[0] = 0 ;
                            dp[1] = abs(a[0] - a[1]);
                            FOR(i,2,n)
                            {
                                FOR(j,1,min(k,i) + 1)
                                dp[i] = min(dp[i],abs(a[i] - a[i - j]) + dp[i - j]);
                            }
                            cout << dp[n -1];
                            }

















































Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    sort( all(S) );
    if( S[0] == S[1] && S[2] == S[3] && S[0] != S[3] ) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
def code_run
  until ( iM,iF,iR=$stdin.gets.split.map(&:to_i) ) == [-1,-1,-1] do
    puts jadge(iM,iF,iR)
  end
end
def jadge(m,f,r)
  return "F" if m<0 or f<0
  case m+f
  when (80..100); return "A"
  when (65..79); return "B"
  when (50..64); return "C"
  when (30..49); return r>=50 ? "C" : "D"
  when (0..29); return "F"
  end
  return "Z"
end
code_run


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> a_sum(n + 1);
    a_sum[0] = 0;
    _rep(i, 1, n + 1){
        a_sum[i] = a_sum[i - 1] + a[i - 1];
        //cout << a_sum[i] << endl;
    }
    ll ans_min = INFINITY;
    _rep(i, 1, n){
        ans_min = min(abs((a_sum[n] - a_sum[i]) - a_sum[i]), ans_min);
    }
    cout << ans_min << endl;
}

Measured memory_bytes: 3328
ans = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')
k = int(input())
print(ans[k - 1])

Measured memory_bytes: 2940