akhauriyash/Code-Regression huggingface dataset:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


a, b, c, d = list(map(int, sys.stdin.buffer.readline().split()))

while True:
    c -= b
    if not  (a > 0 and c > 0):
        break
    a -= d
    if not  (a > 0 and c > 0):
        break
if a > 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 27128
def main():
    H, W, M = map(int, input().split())
    hw = [tuple(list(map(int, input().split()))) for _ in [0]*M]
    hw_set = set(hw)
    h_count = [0 for i in range(H+1)]
    w_count = [0 for i in range(W+1)]
    for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
    h_m = max(h_count)
    w_m = max(w_count)
    h_list = []
    w_list = []
    for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
    for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
    for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
    print(h_m+w_m-1)


main()


Measured memory_bytes: 85976
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N=in();
  vector<ll> A(N);
  rep(i,N) cin >> A[i];

  int cnt=0;
  bool has_zero = false;
  rep(i,N){
    if(A[i]<0) cnt++;
    if(A[i]==0) has_zero = true;
  }
  ll ret = 0;
  rep(i,N) ret += abs(A[i]);
  if(has_zero){
    cout << ret << endl;
  } else {
    ll m=numeric_limits<ll>::max();
    if(cnt%2==1){
      rep(i,N){
        if(A[i]==0) continue;
        if(m>abs(A[i])) m = abs(A[i]);
      }
      ret -= 2*m;
    }
    cout << ret << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*int n;
bool flag;
int main(){
    read(n);
    int s=0,t=0;
    for (;n--;){
        int a,b,t;
        read(t),read(a),read(b);
        if (abs(s-a)+abs(t-b)>t){
            return puts("No"),0;
        }
        s=a,t=b;
    }
    puts("Yes");
    return 0;
}*/
/*int main(){
    ll a,b;
    cin>>a>>b;
    puts((a*b)&1?"Odd":"Even");
    return 0;
}*/
int main(){
    int a,b;cin>>a>>b;
    if (b<10) a=a*10+b;
    else if (b==100) a=a*1000+b;
    else a=a*100+b;
    if ((int)sqrt(a)==sqrt(a)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
def I():return input()
def II():return int(input())
def LI():return list(map(int, input().split()))
def L():return input().split()

def count_num(lis):
    v = {}
    for i in lis:
        if i not in v.keys():
            v[i] = 1
        else:
            v[i] += 1
    return v
def dict_to_list(dic):
    ret = []
    for i in dic.keys():
        ret.append([i,dic[i]])
    return ret

def main():
    n = II()
    e = n//2
    o = e + n%2

    v = LI()
    v_o = count_num(v[::2])
    v_e = count_num(v[1::2])
    cnt_o = dict_to_list(v_o)
    cnt_e = dict_to_list(v_e)
    cnt_o.sort(key=lambda x: x[1], reverse=True)
    cnt_e.sort(key=lambda x: x[1], reverse=True)
    
    cnt_o.append([0,0])
    cnt_e.append([0,0])
    if cnt_e[0][0] != cnt_o[0][0]:
        ans = (e - cnt_e[0][1]) + (o - cnt_o[0][1])
    else:
        ans = min((e-cnt_e[0][1]) + (o-cnt_o[1][1]), (e-cnt_e[1][1]) + (o-cnt_o[0][1]))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 23744
//
// Created by 佐竹俊哉 on 2019/11/12.
//

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    ll A, B; cin >> A >> B;
    ll x = __gcd(A, B);
    int ans = 0;
    for (ll i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
            ++ans;
            while (x % i == 0) x /= i;
        }
    }
    if (x != 1) ++ans;
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
ll n;
ll ans;

void solve(ll val, bool f1, bool f2, bool f3){
    if(val <= n){
        if(f1 && f2 && f3)  ++ans;
        solve(val*10+7,true,f2,f3);
        solve(val*10+5,f1,true,f3);
        solve(val*10+3,f1,f2,true);
    }
}


int main(){
    cin >> n;
    solve(7,true,false,false);
    solve(5,false,true,false);
    solve(3,false,false,true);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int calc(int inp, int inj, int map[],int max);
int disp(int map[],int inj);

int main(){
  int n;
  int emp[99999];
  
  while(cin >> n && n>0){
    calc(n,0,emp,n);
  }
}

int calc(int inp, int inj,int map[],int max){
  if(inp==1){
    map[inj]=1;
    disp(map,inj);
  }else{
    if(max>=inp){
      map[inj]=inp;
      disp(map,inj);
    
      for(int i=inp-1;i>=1;i--){
	map[inj]=i;
	calc(inp-i,inj+1,map,i);
      }
    }else{
      for(int i=max;i>=1;i--){
	map[inj]=i;
	calc(inp-i,inj+1,map,i);
      }
    }
  }
  return 0;
}

int disp(int map[],int inj){
  for(int i=0;i<=inj;i++){
    cout << map[i];
    if(i==inj) cout << endl;
    else cout << " ";
  }
  return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    
    rep(i,s.size()){
        if(i==a){
            if(s[i]!='-'){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            if(!isdigit(s[i])){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 384
'use strict'

const gcd = (a, b) => {
    const r = a % b
    if(r === 0){
        return b
    }
    return gcd(b, r)
}

const main = (input) => {
    input = input.split('\n')
    const n = parseInt(input[0].split(' ')[0])
    const x = parseInt(input[0].split(' ')[1])
    const arr = input[1].split(' ').map(v => Math.abs(parseInt(v) - x))
    console.log(arr.reduce((p, c) => gcd(p, c)))
    
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 17484
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long K { get; private set; }
        public static long N { get; private set; }
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetLongs();
            K = inputs[0];
            N = inputs[1];
            A = CR.GetLongs();

            var d = 0L;
            for (int i = 0; i < A.Count - 1; i++)
            {
                d = Math.Max(d, A[i + 1] - A[i]);
            }

            d = Math.Max(d, K - A.Last() + A.First());

            return K - d;
        }
    }
}


Measured memory_bytes: 34932
#include<string>
#include<iostream>

using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    
    size_t size=s.length();
    
    if(n>=size)
        cout<<s<<endl;
    else{
        for(int i=0 ; i<n ;i++){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3572
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<map>
using namespace std;

int main(void){
	int a[200000];	
	int b[200000];
	int p[200000];
	for (int i = 0; i < 200000; i++){
		a[i] = 0;
b[i]=0;
p[i]=0;
	}
	int n=0;
	int x = 0;
	int c = 0;
int y=0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
      scanf("%d", &y);
p[y-1]=i+1;
	}
	a[0] = 1;
	for (int i = 1; i < n; i++){
		if (p[i - 1] < p[i]){
			a[i]=a[i - 1] + p[i ] - p[i-1] + 1;
		}
		else a[i] = a[i - 1] + 1;
	}
	for (int i = 0; i < n; i++){
		b[i] = a[n-1]+p[i]-p[n-1]+ - a[i]+1;
	}
	for (int i = 0; i < n-1; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[n - 1]);
	for (int i = 0; i < n - 1; i++){
		printf("%d ", b[i]);
	}
	printf("%d\n", b[n - 1]);
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	long double ans = 0;
	bool f = true;
	long long count = 0;


	for (int i = 1; i <= n; i++)
	{
		f = true;
		count = 0;
		while (f)
		{
			//cout << i * pow(2,count) << endl;;
			if ((i * pow(2, count)) >= k)
			{
				f = false;
				//cout << count << endl;
			}
			count++;
		}
		ans = ans + (pow(2,10))*(double)(1 / pow(2, count-1));
	}
	ans /= n*(pow(2,10));
	cout <<setprecision(10)<<ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();

		double lim = Math.floor((T + 0.5) / A);
		int sum = 0;
		for (int i = 1; i <= lim; i++){
			sum += B;
		}	
		sc.close();
		System.out.println(sum);

	}	
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

vi KMP(string s) {
    vi A(sz(s) + 1);
    A[0] = -1;
    int j = -1;
    for (int i = 0; i < s.size(); i++) {
        while (j >= 0 && s[i] != s[j]) j = A[j];
        j++;
        A[i + 1] = j;
    }
    return A;
}
signed main() {
    string w;
    cin >> w;
    {
        string tmp = w;
        sort(all(tmp));
        if (tmp.front() == tmp.back()) {
            cout << sz(w) << endl;
            cout << 1 << endl;
            return 0;
        }
    }

    int n = sz(w);
    vi kmp = KMP(w);
    string r = w;
    reverse(all(r));
    vi kmp_rev = KMP(r);

    rep(i, 0, n + 1) {
        kmp[i] = i - kmp[i];
        kmp_rev[i] = i - kmp_rev[i];
    }
    dump(kmp);

    auto check = [&](const vi &a, int prefix_len) {
        return prefix_len != a[prefix_len] && prefix_len % a[prefix_len] == 0;
    };

    if (!check(kmp, n)) {
        cout << "1\n1" << endl;
        return 0;
    }

    int ans = 0;
    rep(i, 1, n) {
        if (!check(kmp, i) && !check(kmp_rev, n - i)) {
            ans++;
            dump(i);
        }
    }
    cout << 2 << endl;
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 9524
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int D, N;
int a[2000000];

int main(int argc, char** argv) {
    cin >> D >> N;
    if (N == 100) N++;
    if (D == 0) {
        cout << N << endl;
    }
    if (D == 1) {
        cout << 100 * N << endl;
    }
    if (D == 2) {
        cout << 10000 * N << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	vector<int>vec(3);
	rep(i, 3) {
		cin >> vec[i];
	}
	sort(vec);
	int a =2*vec[2] - vec[1] - vec[0];
	if (a % 2 != 0) {
		a += 3;
	}
	cout << a / 2 << endl;
}




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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int X,t;
    cin>>X>>t;
    cout<<max(X-t,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
s=input()
length=len(s)

ans=0
mylist=list(itertools.product('01',repeat=length-1))

for j in range(len(mylist)):
    tmp=s[0]
    for i in range(length-1):
        if mylist[j][i]=='1':
            tmp+="+"+s[i+1]
        else:
            tmp+=s[i+1]
    tmp=eval(tmp)
    ans+=tmp
print(ans)


Measured memory_bytes: 3064
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, x = na()
x_li = na()
li = []
for i in range(n):
    li.append(abs(x - x_li[i]))
import fractions

ans = li[0]
for i in range(n):
    ans = fractions.gcd(ans, li[i])
print(ans)

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

int main(void) {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  vector<vector<int>> a(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
      }
    }
  }

  long long ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a[i][j] == -1) continue;
      if (a[i][j] != 1) {
        ans += c[a[i][j]][1];
      }
    }
  }

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

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

ll dp[101010][3], A[101010][3];

int main(){
  int N; cin>>N;
  rep(i,N) rep(j,3) cin>>A[i][j];
  rep(i,3) dp[0][i]=A[0][i];
  rep(i,N-1) rep(j,3){
    int k=(j+1)%3, l=(j+2)%3;
    dp[i+1][k]=max(dp[i+1][k],dp[i][j]+A[i+1][k]);
    dp[i+1][l]=max(dp[i+1][l],dp[i][j]+A[i+1][l]);
  }
  cout<<max({dp[N-1][0],dp[N-1][1],dp[N-1][2]})<<endl;
  return 0;
}


Measured memory_bytes: 4992
def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n = int(input())
prime_list = prime(n)
p = len(prime_list)
key = dict()
for value in prime_list:
    key[value] = 0
for i in range(1, n+1):
    div = make_divisors(i)
    for d in div:
        if d in key:
            k = 0
            i_c = i
            while i_c%d == 0:
                k += 1
                i_c //= d
            key[d] += k
ans = 1
for v in key.values():
    ans *= v+1
    ans %= 10**9+7
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();

        String set = "ACGT";

        int start = 0;
        int max = 0;

        for (int i = 0; i < arr.length; i++) {
            if (!set.contains(String.valueOf(arr[i]))) {
                max = Math.max(max, i - start);
                start = i + 1;
            }
            if (i == arr.length - 1) {
                max = Math.max(max, i - start + 1);
            }
        }

        System.out.println(max);
    }
}


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

using namespace std;
typedef long long ll;

const int MaxN = 300010;

int n, a[MaxN], pe[2], sum[MaxN];

bool check(int m) {
  int t = 0;
  for (int i = n - 1; i; i -= 2)
    if (m + t <= sum[i])
      t = min(t, sum[i - 1]);
  return sum[0] - t >= m;
}

int main() {
  scanf("%d", &n);
  int total = 0;
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]), total += a[i];
  for (int i = 0; i < n; i++)
    pe[i & 1] += a[i];
  int ans = 0;
  if (!(n & 1)) {
    ans = max(pe[0], pe[1]); 
  } else {
    for (int i = n, s = 1; i--; s = -s)
      sum[i] = sum[i + 1] + s * a[i];
    int l = 0, r = INT_MAX >> 2;
    while (l + 1 < r) {
      int m = l + r >> 1;
      check(m) ? (l = m) : (r = m);
    }
    ans = pe[1] + l;
  } 
  printf("%d %d\n", ans, total - ans);
  return 0;
}



Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(b>a)
         if(x>(a+b)/2)
            cout<<"B";
         else
            cout<<"A";
    else
        if(x>(a+b)/2)
            cout<<"A";
        else
            cout<<"B";
}

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

void down(int x,int a){
  if(x==a){cout<<0<<endl;return;}
  if(x==10)return;
  down(x+1,a);
  return;
}
void up(int x,int a){
  if(a==x){cout<<10<<endl;return;}
  if(a==10)return;
  up(x,a+1);
  return;
}

int main(){
  int x,a;cin>>x>>a;
  up(x,a); down(x+1,a);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    
    cout << N/2  + N%2<< endl;


    return 0;
    

}

Measured memory_bytes: 3592
N,M=map(int,input().split())
if N%2==1:
  for i in range(M):
    print(i+1,N-i)
else:
  middle=int((M+1)/2)
  for i in range(middle):
    print(i+1,N-i)
  for j in range(middle,M):
    print(j+2,N-j)

Measured memory_bytes: 9256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.14159265358979;
/******変数定義start******/
ll n, m;
priority_queue<ll> a;
/*******変数定義end*******/

ll solve(){
    cin >> n >> m;
    ll A;
    REP(i, n){
        cin >> A;
        a.push(A);
    }
    REP(i, m){
        ll max_num = a.top();
        ll atai = max_num / 2;
        a.pop();
        a.push(atai);
    }
    ll ans = 0;
    REP(i, n){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;

    return 0;
}
int main(){

    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return end;
}


Measured memory_bytes: 1400
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Data.Int (Int64)
import Data.List (foldl')
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  _ :: Int <- readLn
  heights :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  let (_,n) = foldl' (\(maxH,n) h -> if maxH <= h then let !n'=n+1 in (h,n') else (maxH,n)) (0,0) heights
  print (n :: Int)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

class UnionFind {
private:
    vector<int> par, sizes;

public:

    UnionFind(int n = 100010) : par(n), sizes(n, 1) {
        rep(i, n) par[i] = i;
    }

    int root(int x) {
        if (x == par[x]) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

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

    int size(int x) {
        return sizes[root(x)];
    }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;
  cin >> n >> a >> b;
  int easy=0, normal=0, hard=0;
  rep(i,n){
    int p; cin >> p;
    if(p <= a) easy++;
    else if(p > b) hard++;
    else normal++;
  }
  cout << min({easy, normal, hard}) << endl;
    return 0;
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,m,vis[1001][1001],cnt;
string s[1001];
queue<pii> q;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
void solve(){
	cin>>n>>m;
	rep(i,0,n) cin>>s[i];
	rep(i,0,n){
		rep(j,0,m){
			if(s[i][j]=='#'){
				q.push({i,j});
				vis[i][j]=1;
				cnt++;
			}
		}
	}
	int ans=0;
	while(1){
		if(cnt==n*m) break;
		ans++;
		int d=sz(q);
		rep(_,0,d){
			pii w=q.front();
			q.pop();
			rep(i,0,4){
				if(w.x+dx[i]>=0 and w.y+dy[i]>=0 and w.x+dx[i]<n and w.y+dy[i]<m and vis[w.x+dx[i]][w.y+dy[i]]==0){
					vis[w.x+dx[i]][w.y+dy[i]]=1;
					cnt++;
					q.push({w.x+dx[i],w.y+dy[i]});
				}	
			}
		}
	}
	cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
    // cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=2019,M=2019;
int c1[N],c2[N];
int pwr(int a,int b)
{
	int r=1;
	while(b)
	{
		if(b%2) r=r*a%N;
		b/=2;
		a=a*a%N;
	}
	return r;
}
int dp[2][N];
int main()
{
	string s;
	cin>>s;
	ll r=0,sm=0;
	//dp[0][0]=1;
	s=" "+s;
	int inv=1;
	for(int i=1;i<2019;i++)
	{
		if(i*10%N==1)
		{
			inv =i;
			break;
		}
	}
	//cout<<dp[0][1971]<<"wtf\n";
	//cout<<inv*10%N<<"wtf\n";
	for(int i=1;i<s.size();i++)
	{
		//cout<<dp[0][1971]<<"wtf\n";
		for(int j=0;j<N;j++)
			dp[i%2][j]=0;
		dp[i%2][s[i]-'0']=1;
		//cout<<dp[0][1971]<<"wtf\n";
		for(int j=0;j<N;j++)
		{
			int prev=(j-(s[i]-'0')+N)%N*inv%N;
			dp[i%2][j]+=dp[!(i%2)][prev];
			// if(dp[i%2][j])
			// 	cout<<i<<" "<<j<<" "<<prev<<"\n";
		}
		r+=dp[i%2][0];

	}
	
	cout<<r;
	return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    reverse(all(l));
    int sum = 0;
    rep(i, k) sum += l[i];
    put(sum)
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

void chmax(string &a, const string &b) {
    if (a.length() > b.length()) {
        return;
    }
    if (a.length() < b.length()) {
        a = b;
        return;
    }
    if (a < b) {
        a = b;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    //              0  1  2  3  4  5  6  7  8  9
    int match[] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    string inf = "#";
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    vector<string> dp(n + 1, inf);
    dp[0] = "";
    rep(i, n) {
        if (dp[i] == inf) continue;
        for (auto x : a) {
            int idx = i + match[x];
            if (idx > n) continue;
            chmax(dp[idx], dp[i] + (char)('0' + x));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
LL mod;

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
	LL N, P;
	cin >> N >> P;
	string S;
	cin >> S;
	LL ans=0;
	if(P==2 || P==5){
		for(LL i=0; i<N; i++){
			LL n=S[i]-'0';
			if(n%P==0) ans+=i+1;
		}
		cout << ans << endl;
		return 0;
	}
	reverse(S.begin(),S.end());
	mod=P;
	vector<LL> dp(N+1);
	map<LL,LL> m;
	m[0]++;
	rep(i,N){
		LL n=S[i]-'0';
		dp[i+1]=(dp[i]+n*modpow(10,i))%mod;
		dp[i+1]%=mod;
		m[dp[i+1]]++;
	}
	for(auto itr:m) ans+=itr.second*(itr.second-1)/2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2564
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s,t;
	cin>>s>>t;
	int pos = -1;
	for (int i = 0; i <= s.size()-t.size(); i++){
		if(i+t.size()-1>s.size()-1) break;
		for (int j = 0; j < t.size(); j++){
			if(!(s[i+j] == t[j] || s[i+j] == '?')) break;
			if(j==t.size()-1){
				pos = i;
			}
		}
	}

	if(pos>=0){
		for (int j = 0; j < t.size(); j++) s[pos+j] = t[j];
		for (int i = 0; i < s.size(); i++){
			if(s[i]=='?') s[i] = 'a';
		}
		cout<<s<<endl;
	}else{
		cout<<"UNRESTORABLE"<<endl;
	}
	
	return 0;
}

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


int main()
{
  int n;
  int a[10000];
  while(1){
    cin>>n;
    if(n==0)return 0;
    int sum=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      sum+=a[i];
  }
    int ans=0;
    for(int i=0;i<n;i++){
      if(a[i]<=sum/n)
	ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3124
N,A,B = map(int,input().split())
S = input()

total = 0
b = 0
answer = []

for s in S:
  bl = False
  if s == 'a':
    if total < A+B:
      bl = True
      total += 1
  elif s == 'b':
    if total < A+B and b < B:
      bl = True
      total += 1
      b += 1
  answer.append('Yes' if bl else 'No')
  
print(*answer, sep='\n')

Measured memory_bytes: 6448
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    char[] S = scn.nextLine().toCharArray();
    ArrayList<Character> Slist = new ArrayList<>();
    for (Character ch : S) {
      Slist.add(ch);
    }

    int count = 0;
    for (int i = 0; i < Slist.size() - 1; i++) {
      String chunk = Slist.get(i).toString() + Slist.get(i + 1).toString();

      if (chunk.equals("10") || chunk.equals("01")) {
        count += 2;
        Slist.remove(i);
        Slist.remove(i);
        // System.out.println(Slist);
        i -= 2;

        if (i < -1) {
          i = -1;
        }
      }

    }

    System.out.println(count);
  }

}


Measured memory_bytes: 43196
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
k,n = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに
As = list(map(int, stdin.readline().rstrip().split()))

kyori = []

for i in range(1, n):
    kyori.append(As[i] - As[i-1])
kyori.append(As[0]+k-As[-1])
kyori.append(As[-1]-As[-2])

print(k - max(kyori))


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

typedef struct _process_ {
	string name;
	int time;
}process;

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

	

	process p;
	queue<process> qu;

	for (int i = 0; i < n; i++) {
		cin >> p.name;
		cin >> p.time;
		qu.push(p);
	}

	int time = 0;

	for (int f = 0; f != n;){
		if (qu.front().time <= q){
			time += qu.front().time;
			cout << qu.front().name << " " << time << endl;
			qu.pop();
			f++;
		}
		else {
			p.name = qu.front().name;
			p.time = qu.front().time - q;
			qu.push(p);
			qu.pop();
			time += q;
		}
	}
	return 0;
}

Measured memory_bytes: 6176
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  string s;
  cin >> s;
  int sum = 0;
  for (char c : s) {
    sum += c - '0';
  }
  cout << (sum % 9 ? "No" : "Yes") << '\n';
}


Measured memory_bytes: 3764
N = int(input())

def f9(a,i):
    if a < 9**i:
        return i-1
    return f9(a,i+1)

def f6(a,i):
    if a < 6**i:
        return i-1
    return f6(a,i+1)

def func(a,ans):
    if a < 6:
        return ans+a
    elif a < 9:
        return ans+1+(a-6)
    return min(func(a-6**f6(a,0),ans+1),func(a-9**f9(a,0),ans+1))

print(func(N,0))

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

const string YES = "Yes";

const string NO = "No";

void solve(string N)
{
    int r = 0;
    for (int i = 0; i < (int)N.size(); i++)
    {
        int c = N.at(i) - '0';
        r += c;
    }
    if (r % 9 == 0)
        cout << YES << endl;
    else
        cout << NO << endl;
}

int main()
{
    string N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int num=0;
        int ar[] = new int[1000];
        double sa=0;
        double a=0;
        double sum=0;
        while(true){
            num=sc.nextInt();
            if(num==0){
                break;
            }
            for(int i=0;i<num;i++){
                ar[i]=sc.nextInt();
                sa+=ar[i];
            }
            sa = sa/num;
            for(int i=0;i<num;i++){
                sum += Math.pow(ar[i] - sa, 2);
            }
            a=Math.sqrt(sum/num);
            System.out.println(a);
            sa=0;
            sum=0;
        }


        sc.close();
    }
}



Measured memory_bytes: 31448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
int main()
{
	ll x;
	cin >> x;
	ll a = 100;
	ll c = 0;
	while (a < x) {
		a = a*1.01;
		c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3196
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.Set as S

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  print $ solve n s

solve :: Int -> String -> Int
solve n s = maximum . map count $ splits n s

splits :: Int -> [a] -> [([a], [a])]
splits n xs = [splitAt i xs | i <- [0 .. n-1]]

count :: Ord a => ([a], [a]) -> Int
count (xs, ys) = S.size $ S.intersection xs' ys' where
  xs' = S.fromList xs
  ys' = S.fromList ys


Measured memory_bytes: 1020
#include<stdio.h>
int main(void){
	int box[101]={0},max=0,num;
	while(scanf("%d",&num)!=EOF){box[num]++;}
	for(num=1;num<=100;num++){if(max<box[num])max=box[num];}
	for(num=1;num<=100;num++){if(max==box[num])printf("%d\n",num);}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  cout<<H*W-(h*W+w*H-h*w)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin >> str;
	
	reverse(str.begin(), str.end());
	int num = 0, len = str.length();
	while(1) {
		if(num == len) {
			cout << "YES" << endl;
			break;
		}

		if(str.substr(num, 7) == "remaerd") {
			num += 7;
		} else if(str.substr(num, 6) == "resare") {	
			num += 6;
		} else if(str.substr(num, 5) == "maerd") {
			num += 5;
		} else if(str.substr(num, 5) == "esare") {
			num += 5;
		} else {
			cout << "NO" << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int K = in.nextInt();
            out.println((n + 1) / 2 >= K ? "YES" : "NO");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

int main(){
    int i1, i2, y1, y2;
    int a, b, c, d;
    
    cin >> i1 >> y1;
    cin >> i2 >> y2;
    cin >> a >> b >> c >> d;
    
    int hiroshi_score, kenjiro_score;
    hiroshi_score = i1 * a + y1 * b + ( i1 / 10 ) * c + ( y2 / 20 ) * d;
    kenjiro_score = i2 * a + y2 * b + ( i2 / 10 ) * c + ( y2 / 20 ) * d;
    
    if( hiroshi_score > kenjiro_score ){
        cout << "hiroshi" << endl;
    }else if( hiroshi_score < kenjiro_score ){
        cout << "kenjiro" << endl;
    }else{
        cout << "even" << endl;
    }
}


Measured memory_bytes: 3080
n,m=map(int,input().split())
s={}
for i in range(m):
    a,b=map(int,input().split())
    s[a]=s.get(a,0)+1
    s[b]=s.get(b,0)+1
for i in range(1,n+1):
    print(s.get(i,0))

Measured memory_bytes: 3060