akhauriyash/Code-Regression huggingface dataset:
sx,sy,i,x,y,n;
xx[12],yy[12];
q[9999],t,h,p,ok,c,k;
char *d="22210/.../01";
main()
{
  for(;scanf("%d%d",&sx,&sy),sx;puts(ok?"OK":"NA")){
    for(i=scanf("%d",&n);i<=n;)scanf("%d%d",xx+i++,yy+i);
    for(ok=t=h=0,p=q[t++]=sx*10+sy;t!=h;p=q[h++]){
      c=p/100;
      if(c&&(abs(xx[c]-p/10%10)>1||abs(yy[c]-p%10)>1))continue;
      if(c==n){ok=1;break;}
      for(i=0;i<12;x>=0&x<10&y>=0&x<10?q[t++]=(c+1)*100+x*10+y:0)
        x=p/10%10+d[i]-48,y=p%10+d[11-i++]-48;
    }
  }
}

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

main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  a+=b;
  c+=d;

  if(a>c)
    cout << "Left" << endl;
  if(a<c)
    cout << "Right" << endl;
  if(a==c)
    cout << "Balanced" << endl;

  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// clang-format off
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
#define gcn(N) int N;cin >> N;
#define debug(var) do {std::cout << #var << " : "; view(var);} while (0)
template <typename T> void view(T e) { std::cout << e << std::endl; } template <typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void view(const std::vector<std::vector<T>>& vv) { for (const auto& v : vv) { view(v); } } using namespace std; void before_main() { std::cout << std::fixed << std::setprecision(10); } namespace { struct before_main_caller { before_main_caller() { before_main(); } } caller; }
// clang-format on
signed main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A_arr(N, 0);
    vector<int> D_arr(N, 0);  //Di: AiとAi+1の距離
    rep(i, N)
    {
        cin >> A_arr[i];
    }
    rep(i, N - 1)
    {
        D_arr[i] = A_arr[i + 1] - A_arr[i];
    }
    D_arr[N - 1] = A_arr[0] + K - A_arr[N - 1];
    int max = *std::max_element(D_arr.begin(), D_arr.end());
    int sum = 0;
    rep(i, N)
    {
        sum += D_arr[i];
    }
    cout << sum - max << endl;
}


Measured memory_bytes: 3328
a, b = map(int,input().split())
A = [input() for _ in range(a)]
B = [input() for _ in range(b)]
ans = "No"
for i in range(a-b+1):
    for j in range(a-b+1):
        cnt = 0
        if A[i][j] == B[0][0]:
            for k in range(b):
                for l in range(b):
                    if A[i+k][j+l] == B[k][l]:
                        cnt += 1
                    if cnt == b**2:
                        ans = "Yes"

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<vector<long long>> T(M + 1);

	for (int i = 0; i < N; ++i) {
		int A, B;
		cin >> A >> B;
		if (M - A >= 0) {
			T[M - A].push_back(B);
		}
	}
	
	long long ans = 0;

	priority_queue<long long> q;
	for (int i = M; i >= 0; --i) {
		for (auto x : T[i]) {
			q.push(x);
		}
		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

signed main() {
  int A, B;
  cin >> A >> B;

  vector<int> vec;
  for(int i = 1; i*i <= min(A, B); i++){
    if(A%i == 0 && B%i == 0){
      vec.push_back(i);
    }
    int j = A/i;
    if(i == j) continue;
    if(A%j == 0 && B%j == 0){
      vec.push_back(j);
    }
  }

  vector<int> ans;
  sort(ALL(vec));
  REP(i, vec.size()){
    int flag = 1;
    REP(j, ans.size()){
      if(vec[i]%ans[j] == 0 && ans[j] != 1){
        flag = 0;
        break;
      }
    }
    if(flag) ans.push_back(vec[i]);
  }

  cout << ans.size() << endl;

  return 0;
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}



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

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    	cin>>a[i];

    ll sum=0,mx=0;
    for(int i=0;i<n;i++)
    {
 		if(mx>a[i]) sum+=(mx-a[i]);
 		mx=max(mx,a[i]);
    }

    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 5176
def main():
    import sys
    input = sys.stdin.readline
    M = int(input())  # M[1,2*10**5]

    d_sum, c_sum = 0, 0
    for _ in range(M):
        d_, c_ = map(int, input().split())
        d_sum += d_ * c_
        c_sum += c_

    ret = ((d_sum - 9 + 8) // 9) + (c_sum - 1)
    print(ret)


if __name__ == '__main__':
    main()

# 桁が減って総和が変わらず
# 桁が変わらず総和が減る
# 桁が1で総和が10未満まで


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char a[11],b[11],c[11];
    scanf("%s %s %s",a,b,c);
    if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0]) printf("YES\n");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    ss=[0]*n
    cc=0
    for j in range(n):
        if i>>j&1:
            ss[j]=1
    for j in range(m):
        c=0
        k=s[j][0]
        for l in range(1,k+1):
            c+=ss[s[j][l]-1]
        if c%2==p[j]:
            cc+=1
    if cc==m:
        ans+=1
print(ans)

            



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

int main(){
  std::string s,t;
  std::cin >> s;
  while( ! s.empty() ) {
    t += s[ s.size() - 1 ];
    s.erase( s.size() - 1 );
  }
  std::cout << t << std::endl;
  return 0;
}

Measured memory_bytes: 1176
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = arr_data[0][0]
b = arr_data[0][1]



if (a=="H" and b=="H") or (a=="D" and b=="D"):
    
    print("H")
    
else:
    
    print("D")
    
    

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

int main(){
	int n,m;
	cin>>n>>m;
	int a[m+1];
	
	for(int i=1;i<=m;i++){
		cin>>a[i];
		n-=a[i];
	}
		
	if(n<0){
		cout<<"-1"<<endl;
		return 0;
	}
	else
		cout<<n<<endl;
		
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	long long int  p, c = 0, count = 0, d, ans = 0, n = 0, k, mem[100000] = { 0 }, m, ac = 0, wa = 0;
	string s;
	bool b, h[100000] = {false};
	vector<int> x;
	cin >> n>>m;
	for (int i = 0; i < m; i++) {
		cin >> p >> s;
		if (s == "AC")b = 1;
		else b = 0;
		if (b == 1&&h[p]!=1) {
			ac++;
			h[p] = 1;
			wa += mem[p];
		}
		if (b == 0 && h[p] != 1)mem[p]++;
	
	}
	
	cout << ac <<" " <<wa<<endl;
	
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/rational.hpp>

int main(){
    using namespace std;
    using real = boost::rational<boost::multiprecision::cpp_int>;
    using point = complex<real>;
    using circle = pair<point, real>;
    unsigned long N;
    cin >> N;
    vector<point> p(N);
    for(auto& i : p){
        unsigned long im, re;
        cin >> im >> re;
        i.imag(real(im));
        i.real(real(re));
    }
    {
        mt19937_64 mt{random_device{}()};
        shuffle(p.begin(), p.end(), mt);
    }
    const auto& circle_from_diameter = [](const point& a, const point& b) -> circle {
        auto center = (a + b) / real(2);
        return {center, norm(a - center)};
    };
    const auto& circle_from_triangle = [](const point& a, const point& b, const point& c) -> circle {
        if(((a - b) / (a - c)).imag() == 0)return circle{};
        auto center = ((a - b) * norm(c) + (b - c) * norm(a) + (c - a) * norm(b)) / ((a - b) * conj(c) + (b - c) * conj(a) + (c - a) * conj(b));
        return {center, norm(a - center)};
    };
    const auto& is_included = [](const circle& c, const point& a) -> bool {
        return norm(a - c.first) <= c.second;
    };
    const auto& is_all_include = [&p, &is_included](const circle& c) -> bool {
        return all_of(p.begin(), p.end(), [&c, &is_included](const point& a){return is_included(c, a);});
    };
    auto c = circle_from_diameter(p[0], p[1]);
    for(unsigned long i{2}; i < N; ++i)if(!is_included(c, p[i])){
        c = circle_from_diameter(p[0], p[i]);
        for(unsigned long j{1}; j < i; ++j)if(!is_included(c, p[j])){
            c = circle_from_diameter(p[i], p[j]);
            for(unsigned long k{0}; k < j; ++k)if(!is_included(c, p[k]))c = circle_from_triangle(p[i], p[j], p[k]);
        }
    }
    cout << setprecision(15) << sqrt(boost::rational_cast<long double>(c.second)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL (long long)1e18
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int x,y;
    cin>>x>>y;
    if(y%2==0&&(y-2*x)>=0&&(4*x-y)>=0)OUT("Yes");
    else OUT("No");
    return 0;
}


Measured memory_bytes: 3596
import math
X, K, D = map(int, input().split())

if X < 0:
    X = -1*X

M = math.ceil(X/D)
right = abs(X-(M-1)*D)
left = abs(X-M*D)

if K < M:
    print(X-K*D)
    exit()

if right <= left:
    if (M-1)%2 == K%2:
        print(right)
    else:
        print(left)
else:
    if M%2 == K%2:
        print(left)
    else:
        print(right)

Measured memory_bytes: 61976
import Control.Monad
import Data.List

main = do
    [n, m] <- map read . words <$> getLine
    a <- map ( map read . words) <$> replicateM n getLine
    putStrLn $ show $ sum $ take m $ concat $ map (\x -> replicate (x !! 1) (x !! 0)) $ sortBy (\x y -> compare (x !! 0) (y !! 0)) a


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

int main(void){
    int a,b,c;
    int count=0;
    cin >> a >> b >> c;
    for(int j=a; j<=b; j++){
        if(c % j == 0) count++;
    }
    cout << count << endl;
    return 0;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

vi divs(ll n) {
    vi ans;
    ans.pb(1);
    if (n == 1)
        return ans;
    ans.pb(n);
    for (ll i = 2; i*i <= n; i++) {
        if (n%i == 0) {
            ans.pb(i);
            if (i*i != n)
                ans.pb(n/i);
        }
    }
    sort(all(ans));
    return ans;
}

int main() {
    fast;
    ll n, k;
    cin >> n >> k;
    vi arr(n);
    ll s = 0;
    REP(i, 0, n) {
        cin >> arr[i];
        s += arr[i];
    }
    vi div = divs(s);
    RREP(i, div.size() - 1, -1) {
        vi diff(n);
        ll x = 0, m = 0;
        REP(j, 0, n) {
            diff[j] = arr[j]%div[i];
            x += diff[j];
        }
        ll t = x/div[i], c = 0;
        sort(all(diff), greater<ll>());
        REP(j, 0, t)
            c += div[i] - diff[j];
        if (c <= k) {
            cout << div[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i, j;
	int H, W;
	
	
    scanf("%d%d", &H, &W);

	while (H != 0 || W != 0) {
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if(i==0||i==H-1||j==0||j==W-1)
					printf("#");
				else printf(".");
			}printf("\n");
		}
		printf("\n");
		scanf("%d%d", &H, &W);
	}


}

Measured memory_bytes: 1004
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < 3; ++i)if(s[i] == 'o')cnt++;
	int ans = 700 + 100*cnt;
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = sorted([int(input()) for _ in range(n)])
if n % 2:
    s = a[:n//2]
    t = a[n//2:]
    ans1 = 2*(sum(t)-sum(s))-t[0]-t[1]
    p = a[:n//2+1]
    q = a[n//2+1:]
    ans2 = 2*(sum(q)-sum(p))+p[-1]+p[-2]
    print(max(ans1, ans2))
else:
    s = a[:n//2]
    t = a[n//2:]
    ans = 2*(sum(t)-sum(s))-t[0]+s[-1]
    print(ans)



Measured memory_bytes: 8552
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

int n, a[100*1000+5], ans;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a+i);
    for (int i = 1; i <= n; i++) if (a[a[i]] == i) ans++;
    printf("%d\n", ans/2);
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ld a,p=0;
	ll n;
	cin>>n;
	while(n--)
	{
		cin>>a;
		p+=1/a;
	}
	cout<<fixed<<setprecision(8)<<1/p;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
#define MOD 1e9 + 7
#define N 1e5 + 10
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	string str1="";
	string str2="";
	ll i=0,a=0,b=0;
	if(s.size()%2==0)
	{
		for(i=0;i<s.size()/2;i++)
		{
			str1+="01";
			str2+="10";
		}
	}
	else
	{
		for(i=0;i<s.size()/2;i++)
		{
			str1+="01";
			str2+="10";
		}
		str1+="0";
		str2+="1";
	}
	for(i=0;i<s.size();i++)
	{
		if(s[i]!=str1[i])
			a++;
		if(s[i]!=str2[i])
			b++;
	}
	cout<<min(a,b);
}	

Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    char t[4];
    cin >> t;
    
    int n = 700;
    
    for(int i = 0; i < 3; i++){
        if(t[i] == 'o') n += 100;
    }
    
    cout << n;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int n,x,y,z;
int Y,ii;
int ans;

int main(){
    cin >> n;
for(int i=1;i<=n;i++){
    for(int x=1;3*x*x<=4*i;x++){
        for(int y=x;3*y*y<=4*i;y++){
            ii = -3*x*x-3*y*y-2*x*y+4*i;
            // int flag = 0;
            // if(ii < 0 || flag) continue;
            for(int X=x+3*y;9*X*X<=50*i;X++){
                Y = -y-x+X;
                // cout << i << " " << x << " " << y << " " << Y << endl;
                if(ii == X*X && Y%2 == 0 && Y/2 > 0) {
                    // cout << i << " " << x << " " << y << " " << Y << endl;
                    if(x == y && y == Y/2){
                        ans += 1;
                    }
                    else if(x != y && y != Y/2 && x != Y/2){
                        // cout << x << " " << y << " " << Y << endl;
                        ans += 6;
                        // flag = 1;
                        // break;
                    }
                    else{
                        ans += 3;
                        // flag = 1;
                        // break;
                    }
                    
                }
            }
        }
    }
    cout << ans << endl;
    ans=0;
}


return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();
		int m = sc.nextInt();

		if(n%m == 0){
			System.out.println(-1);
			return;
		}
		
		long max = 1000000000000000000L;
		
		for(long x = n;x <= max; x+=n){
			if(x % m != 0){
				System.out.println(x);
				return;
			}
		}
		System.out.println(-1);
		
	}
}


Measured memory_bytes: 23380
import java.util.*;

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

		Scanner sc = new Scanner(System.in);

		String st = sc.next();
		ArrayList<String> arr = new ArrayList<>();
		arr.add("a");
		arr.add("b");
		arr.add("c");

		for(int n=0;n<3;n++){
			String ch = String.valueOf(st.charAt(n));
			if(arr.indexOf(ch) != -1) arr.remove(arr.indexOf(ch));
		}

		if(arr.size()==0) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 19924
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String s = sc.next();
    
    String[] english = {"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"};
    
    for (int i = 0; i < s.length(); i++) {
      for (int j = 0; j < english.length; j++) {
        if (s.substring(i, i+1).equals(english[j])) {
          int limit = j + n;
          if (limit >= 26) {
            System.out.print(english[j + n - 26]);
          } else {
            System.out.print(english[j+n]);
          }
        }
      }
    }
  }
}

Measured memory_bytes: 39788
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int a,b,c,d,ans;
  cin >> a >> b >> c >> d;
  if(c>a) {
    if(d>b) ans = b - c;
    else ans = d - c;
  }
  else {
    if(b>d) ans = d - a;
    else ans = b - a;
  }
  if(c>b) ans = 0;
  if(a>d) ans = 0;
  cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int n;
	while(scanf("%d", &n), n) {
		double s[1010], sum = 0.0;
		rep(i,n) {
			cin >> s[i];
			sum += s[i];
		}
		sum = sum / n;
		double ret = 0;
		rep(i,n) {
			ret += pow((sum - s[i]), 2.0);
		}
		printf("%.10lf\n", sqrt(ret / n));
	}
	return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong ans = 1ll << 60ll;
llong n, m;
char str[128];
llong s[128];
char c[128];

llong dig(llong x) {
    llong d = 0;

    do {
        x /= 10;
        d++;
    } while (x);

    return d;
}

bool f(llong x) {
    for (int i = 0; i < 128; i++) str[i] = 0;
    sprintf(str, "%lld", x);

    bool res = true;

    for (int i = 0; i < m; i++) {
        if (str[s[i] - 1] != c[i]) res = false;
    }

    return res;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }

    llong a = 0;
    while (dig(a) < n) a++;
    for (; dig(a) <= n; a++) {
        if (ans > a && f(a)) ans = a;
    }

    if (ans == (1ll << 60ll)) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
n,m = map(int,input().split())

info = [list(map(int,input().split())) for i in range(m)]
info = sorted(info,key = itemgetter(1))

ans = 0
cut_pos = -1
for i in range(m):
    if cut_pos <= info[i][0]:
        ans += 1
        cut_pos = info[i][1]
print(ans)

Measured memory_bytes: 29920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();

		String YES = "Yes";
		String NO = "No";
		String ans = NO;
		if ( A == B && A != C ) {
			ans = YES;
		} else if ( A == C && A != B ) {
			ans = YES;
		} else if ( B == C && A != B ) {
			ans = YES;
		}
		System.out.println(ans);
	}
}


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

int main()
{
  int A, B;
  double H, M, C;
  cin >> A >> B >> H >> M;
  
  C = sqrt(A * A + B * B - 2 * A * B * cos(M_PI * (11 * M / 360 - H / 6)));
  cout << setprecision(14) << C << endl;
}

Measured memory_bytes: 4184
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    vector<ll> X(N);
    for(int i = 0; i < N; i++){
        ll a;
        cin >> a;
        sum += a;
        A[i] = a;
    }
    for(int i = 1; i < N - 1; i+=2){
        sum -= 2 * A[i];
    }
    X[0] = sum;
    for(int i = 1; i < N; i++){
        X[i] = 2 * A[i - 1] - X[i - 1];
    }
    for(int i = 0; i < N; i++){
        cout << X[i] << ' ';
    }
}

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

using namespace std;
//using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    while(1){
        int n,x = 0;
        cin >> n >> x;
        if(n == 0 && x == 0){
            break;
        }
        int cnt = 0;
        for(int i = 1;i <= n;i++){
            for(int j = i + 1;j <= n;j++){
                if(i == j){
                    continue;
                }
                for(int k = j + 1;k <= n;k++){
                    if(j == k || i == k){
                        continue;
                    }
                    if(i + j + k == x){
                        //cout << i << " " << j << " " << k << endl;
                        cnt ++;
                        break;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll memo[101][101][101];

int main(){
    ll N;
    //string S;
    cin >> N;
    vector<ll> L(N);
    rep(i,N){
        cin >> L[i];
    }
    ll ans = 0;
    rep(i,N){
        REP(j,i+1,N){
            REP(k,j+1,N){
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) continue;
                ll a = L[i];
                ll b = L[j];
                ll c = L[k];
                if((a+b>c && b+c > a && c+a>b )&&memo[i][j][k]==0){
                    memo[i][j][k] = 1;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7724
#include<iostream>
using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    int p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
    int ans,i=0;
    while(0<1){
        int check=0;
        for(int j=0;j<n;j++)
            if(x-i==p[j])
                check=1;
        if(check==0){
            ans=x-i;
            break;
        }
        for(int j=0;j<n;j++)
            if(x+i==p[j])
                check=2;
        if(check==1){
            ans=x+i;
            break;
        }
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
j0 = int(input())
str1 = input().split(" ")
str2 = input().split(" ")

str0 = [str1] + [str2]

ary = [[], []]

for i in range(2):
    for j in range(j0):
        ary[i].append(int(str0[i][j]))

#print(ary)

sm = 0
for k in range(j0)[::-1]:
    sm1 = 0
    sm0 = []
    for j in range(j0):        
        if j <= k:
            sm1 += ary[0][j]
            sm0.append(ary[0][j])
        if j>= k:
            sm1 += ary[1][j]
            sm0.append(ary[1][j])
#    print(sm1,sm0)
    if sm < sm1:
        sm = sm1

print(sm)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n; cin >> n;
	int cnt = 0;
	bool ans = true;
	rep(i, n) {
		string s;
		cin >> s;

		if (s == "A")cnt++;
		if (s == "Un")cnt--;

		if (cnt < 0)ans = false;
	}
	if (cnt != 0)ans = false;
	puts(ans ? "YES" : "NO");
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double eps = 1e-8;
 
#define INF 2147483647
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define FILL(v,n) memset(v,n,sizeof(v))
#define EB emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep1n(i,n)	for(int i=1;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie();cout.tie();
 
#define MXN 1000000 //10^6

int main(){
	ll t1, t2, a1, a2, b1, b2;
	ll ans;
	
	cin>>t1>>t2>>a1>>a2>>b1>>b2;
	
	a1 *= t1;
	b1 *= t1;
	a2 *= t2;
	b2 *= t2;
	
	if(a1 + a2 == b1 + b2)
		cout<<"infinity";
	else if(a1 + a2 > b1 + b2){
		if(b1 < a1)	cout<<0;
		else{
			ans = (b1 - a1) / (a1 + a2 - b1 - b2);
			ans *= 2;
			if(ans * (a1 + a2 - b1 - b2) / 2 != (b1 - a1))	ans++;
			cout<<ans;
		}
	}	
	else{
		if(a1 < b1)	cout<<0;
		else{
			ans = (a1 - b1) / (b1 + b2 - a1 - a2);
			ans *= 2;
			if(ans * (b1 + b2 - a1 - a2) / 2 != (a1 - b1)) ans++;
			cout<<ans;
		}
	}
		
	
}







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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;

    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long k = Long.parseLong(sc.next());
    int a[] = new int[n + 1];
    for (int i = 0; i < n; i++) {
      a[i + 1] = Integer.parseInt(sc.next());
    }
    if (a[0] == 1) {
      pw.println(1);
      return;
    }
    int arrivedStep[] = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      arrivedStep[i] = -1;
    }
    int current = 1;
    int loopStart = 0;
    int loopLength = 0;
    long remainK = k;
    for (int i = 0; i < k; i++) {
      if (arrivedStep[current] != -1) {
        // loop is detected
        loopStart = current;
        loopLength = i - arrivedStep[current];
        remainK -= i;
        break;
      }
      arrivedStep[current] = i;
      current = a[current];
      if (i == k - 1) {
        pw.println(current);
        return;
      }
    }
    remainK %= loopLength;
    current = loopStart;
    for (long i = 0; i < remainK; i++) {
      current = a[current];
    }
    pw.println(current);
  }
}


Measured memory_bytes: 60052
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[] w = new long[N + 1];
        int[] v = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            w[i] = sc.nextLong();
            v[i] = sc.nextInt();
        }
        long[][] dp = new long[N + 1][100001];
        for (int i = 0; i <= N; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        dp[0][0] = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= 100000; j++) {
                if (j >= v[i]) {
                    dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
                }
                dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
            }
        }
        long ans = 0;
        for (int i = 0; i <= 100000; i++) {
            if (dp[N][i] <= W) {
                ans = i;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 134216
#include <iostream>

using namespace std;

int main()
{   
    int a;
    int b;
    cin >> a >>b;
    while (a!=0 && b!=0){
        for (int i = 0; i < a; i++){
            if (i==0 || i==a-1){
                for (int j =0; j<b; j++){
                cout << "#" ;
                }
            }else{
                cout << "#" ;
                for (int j =2; j<b; j++){
                cout << "." ;
                }
                cout << "#" ;
            }cout << endl;
            
        }cout << endl;
         cin >> a >>b;
    }
    

    return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    bool isRepeat = true;
    int ans = 0;

    while (isRepeat) {
        for (int j = 0; j < n; ++j) {
            if (a[j] % 2 == 1) {
                isRepeat = false;
                break;
            }
            a[j] /= 2;
        }
        if (isRepeat) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    int[] v = readln.split.to!(int[]);
    int[] c = readln.split.to!(int[]);
    int ans;
    foreach (i; 0 .. n) {
        int diff = v[i] - c[i];
        if (diff > 0) ans += diff;
    }
    ans.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

int N, p[105];
string words[105];
string s;
int dp1[500], dp2[3000];

bool same(int x, int idx){
  
  if( (int)s.size() - x < (int)words[idx].size() ) return false;
  
  for(int i=0;i<(int)words[idx].size();i++){
    
    if( s[x+i] != words[idx][i] ) return false;
    
  }

  return true;
}

void solve(){
  
  memset(dp1,-1,sizeof(dp1));
  
  dp1[0] = 0;
  
  for(int i=0;i<(int)s.size();i++){
    
    if( dp1[i] == -1 ) continue;
    
    for(int j=0;j<N;j++){
      
      if( same( i, j ) == true ){
	
	int len = (int)words[j].size();
	
	dp1[i+len] = max( dp1[i+len], dp1[i] + p[j] );
	
      }
      
    }
    
  }
  
  int P = dp1[(int)s.size()];
  
  const int INF = 1e9;
  
  for(int i=0;i<=P;i++) dp2[i] = INF;
  
  dp2[0] = 0;
  
  int cnt = 2005;
  
  while(cnt--){
    
    for(int i=0;i<N;i++){
      
      int len = (int)words[i].size();
      
      for(int j=P;j>=0;j--){
	
	if( dp2[j] == INF ) continue;
	
	dp2[j+p[i]] = min( dp2[j+p[i]], dp2[j] + len );
	
      }
      
    }
    
  }
  
  cout<<dp2[P]<<endl;
  
}

signed main(){
  
  int casenum = 1;
  
  while(1){
    
    cin>>N;
    if( N == 0 ) break;
    
    for(int i=0;i<N;i++) cin>>words[i]>>p[i];
    
    cin>>s;
    
    cout<<"Case "<<casenum<<": ";
    
    solve();

    casenum++;
  }
  
  return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,k;
char s[20];
char res[20];
void solve(){
  char key=s[k-1];
  rep(i,n){
    if(s[i]==key){
      res[i]=s[i];
    }
    else{
      res[i]='*';
    }
  }
  rep(i,n){
    cout<<res[i];
  }
  cout<<"\n";
}
int main(){
  cin>>n;
  rep(i,n) cin>>s[i];
  cin>>k;
  solve();
  return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::slice::*;
use std::*;

const MOD: isize = 1000000007;
fn main() {
    let S: String = read();
    let cs: Vec<char> = S.chars().collect();
    let n = cs.iter().filter(|&x| *x == 'A').count();
    let ans: bool = {
        match n {
            0 | 3 => false,
            _ => true,
        }
    };
    println!("{}", if ans { "Yes" } else { "No" });
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace() // iter
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	if (n == 2) {
		cout << n << endl;
	}
	else {
		while (1) {
			bool flg = 1;
			for (ll i = 2; i <= sqrt(n); i++) {
				if (n % i == 0) {
					flg = 0;
					if (n % 2 == 0) {
						++n;
					}
					else {
						n += 2;
					}
					break;
				}
			}
			if (flg) {
				cout << n << endl;
				return 0;
			}
		}
	}
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<iterator>
#include<vector>

using namespace std;
typedef unsigned int val;

struct pred{
	bool operator()(int m, int n) { return m - n == 2; }
};

int main() {
	int n;
	while(cin>>n && n)
	{
		vector<int>so(10000);
		so.clear();
		bool flag[10010];
		for(int i=0; i<=10010; i++) flag[i]=true;
		flag[0]=flag[1]=false;
		for(int i=2; i<=n; i++)
		{
			if( flag[i] )
			{
				so.push_back(i);
				for(int j=i*2; j<=n; j+=i) flag[j]=false;
			}
		}
		vector<int>::reverse_iterator ite = adjacent_find(so.rbegin(), so.rend(), pred());
		cout<< *(ite+1) << " "<< *ite << endl;

	}
	return 0;
}

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

    cin >> a >> b;

    cout << (a+b+1)/2 << endl;
}

    


Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int H = int.Parse(input[0]);
        int W = int.Parse(input[1]);
        
        string[] map = new string[H];
        string[] ans = new string[H];
        
        int[] dx = {-1,0,1,-1,1,-1,0,1};
        int[] dy = {-1,-1,-1,0,0,1,1,1};
        
        for(var i = 0;i < H;i++){
            map[i] = Console.ReadLine();
        }
        
        
        for(var h = 0;h < H;h++){
            for(var w = 0;w < W;w++){
                if(map[h][w] == '#'){
                    ans[h] += "#";
                }else{
                    int count = 0;
                    for(var s = 0;s < 8;s++){
                        int sh = h + dy[s];
                        int sw = w + dx[s];
                        
                        if(sh < 0 || H <= sh){
                            continue;
                        }
                        if(sw < 0 || W <= sw){
                            continue;
                        }
                        
                        if(map[h][w] == '.' && map[sh][sw] == '#'){
                            count++;
                        }
                    }
                    ans[h] += count.ToString();
                }
            }
        }
        
        foreach(var a in ans){
            Console.WriteLine(a);
        }
        
    }
}


Measured memory_bytes: 13140
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (1 ++ n)
    |> List.enum

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (h, w)  = scan "%d %d" Tuple.Tuple2.make
let g = scan_matrix h w "." id
let m = Array.make_matrix h w (-1)
let ds = [(-1,0);(1,0);(0,-1);(0,1)]

let rec bfs visited queue =
  if Queue.is_empty queue then ()
  else
    let (i, j, n) = Queue.pop queue in
    ListL.iter ds ~f:(fun (di, dj) ->
        let x, y = i + di, j + dj in
        if between 0 x h && between 0 y w && not visited.(x).(y)
           && g.(x).(y) = "." then
          (visited.(x).(y) <- true;
           m.(x).(y) <- (succ n);
           Queue.push (x,y, succ n) queue));
    bfs visited queue

let () =
  let visited = Array.make_matrix h w false in
  let q = Queue.create () in
  visited.(0).(0) <- true;
  m.(0).(0) <- 0;
  Queue.push (0,0,1) q;
  bfs visited q;
  let n = m.(h-1).(w-1) in
  (if n = -1 then -1
   else
     h*w -
     (ArrayL.map g
        ~f:(fun line ->
            ArrayL.filter line ~f:((=) "#")
            |> Array.length)
      |> Array.sum) - n)
  |> Printf.printf "%d\n"


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;


int main(int argc, char const *argv[]) {
    long long N;
    cin >> N;
    string ans;

    char c;
    while (N > 0) {
        N -= 1;
        c = N % 26;
        ans += c + 97;
        N /= 26;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int A,B,C; cin >> A >> B >> C;
    int niketa = max({A,B,C});
    if(niketa == A)
        cout << A*10+B+C << endl;
    else if(niketa == B)
        cout << B*10+A+C << endl;
    else if(niketa == C)
        cout << C*10+A+B << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    void run() {
        String S = read();
        String P = read();
        S = S + S;
        sysout.println(S.contains(P) ? "Yes" : "No");
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

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

#define ll long long
#define pb push_back

int main()
{
    string s;
    cin >> s;
    
        if(s[2] == s[3] && s[4] == s[5]){
            cout << "Yes" << endl;
            return 0;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
        return 0;
}


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

const int INF = 1e9;
const int MOD = 998244353;

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

    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> ranges(k);
    for (int i = 0; i < k; i++) {
        int l, r;
        cin >> l >> r;
        ranges[i] = {l, r};
    }
    vector<int> dp(n + 100, 0);
    vector<int> pre(n + 100, 0);
    pre[0] = dp[0] = 0;
    pre[1] = dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        int a = 0;
        for (auto [l, r] : ranges) {
            if (l >= i) continue;
            r = min(r, i - 1);
            a = (a + (pre[i - l] - pre[(i - r) - 1] + MOD) % MOD) % MOD;
        }
        dp[i] = a;
        pre[i] = (pre[i - 1] + a) % MOD;
    }
    cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 4716