akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define repit(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define sortt(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define mkp make_pair
#define mkt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
// inline void fastio() { ios::sync_with_stdio(false), cin.tie(0); }
/******* Variable ************************************/
const int maxn = 1e6 * 50;
const int inf = 1e9 + 7;
const double pi = 3.141592653589;
/******* Function ************************************/
/******* Main ****************************************/
void Main() {
  int n, A = 0, B = 0;
  cin >> n;
  rep(i, 0, n) {
    string a, b;
    cin >> a >> b;
    if (a > b) {
      A += 3;
    } else if (a < b) {
      B += 3;
    } else {
      A++, B++;
    }
  }
  cout << A << " " << B << '\n';
}

/******************************************************
  Smaile!
▕▔╲┊┊┊┊┊┊┊┊┊╱▔▏
┊╲┈╲╱▔▔▔▔▔╲╱┈╱┊
┊┊╲┈╭╮┈┈┈╭╮┈╱┊┊
┊┊╱┈╰╯┈▂┈╰╯┈╲┊┊
┊┊▏╭╮▕━┻━▏╭╮▕┊┊
┊┊╲╰╯┈╲▂╱┈╰╯╱
                      How`s it going?
                              |＼
                      　／￣＼　ヽ
                      ／　　　ヽ |_
                      ￣＼　　　　 ＼
                      ／￣　/|/| /ﾚ､ ヽ＿
                      ￣＼ Yヘ |/ヘ幺　∠
                      　＜_|(･> <･) 6) ／
                      　　 (ﾞ　_　ﾞ／＜
                      　　　＞､ーイ￣￣
                      　　／厂ヽ／￣/＼
                      　 ( ｜　(亀)(>　)▏

                            Take a rest before getting tired!
                                        　　 ●
                                        　　/⌒ヽ
                                        　 ｜ 　|/⌒ヽ(ヽ
                                        　 (｀　∥ー⌒) |
                                        　|￣||￣￣￣￣￣|
                                        　|―||―――――|
                                        　|　Ｕ　　　　　|
                                        　|￣￣￣￣￣￣￣|
                                        　|＿＿＿＿＿＿＿|
                                        　　|―――――|
                                        　　|―――――|
                                        ｗｗＷｗｗＷｗＷＷｗ

******************************************************/
int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3100
H, W = map(int, input().split())
canvas = list()
canvas.append(['.' for _ in range(W + 2)])
for _ in range(H):
    r = ['.']
    for c in input():
        r.append(c)
    r.append('.')
    canvas.append(r)
canvas.append(['.' for _ in range(W + 2)])

for i in range(len(canvas)):
    row = canvas[i]
    for j in range(len(row)):
        cell = row[j]
        if cell == '#':
            if '#' in [canvas[i - 1][j], canvas[i + 1][j], canvas[i][j - 1], canvas[i][j + 1]]:
                continue
            else:
                print('No')
                exit(0)
print('Yes')

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""077-b"""

import sys
import pprint
import re
import math

import itertools
pp = pprint.PrettyPrinter(indent=2)

def main():
    """Main function."""
    N = int(input())
    print(int(math.sqrt(N)) * int(math.sqrt(N)))


if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll N,M;
    cin >> N >>M;
    ll num;
    string ans;
    ll countw=0,counta=0;
    
    vector<ll> vec(N);
    for (ll i = 0; i < M; i++) {
        cin >> num;
        cin >> ans;
        if(vec.at(num-1)!=-1&&ans=="AC"){
            counta++;
            countw+=vec.at(num-1);
            vec.at(num-1)=-1;
        }
        else if(vec.at(num-1)!=-1&&ans=="WA"){
            vec.at(num-1)++;
        }
    }
    
        cout << counta << " " <<countw <<endl;

    
}

Measured memory_bytes: 1024
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use proconio::{fastout, input};
use std::cmp::*;
use std::collections::*;
use std::mem::*;

#[fastout]
fn main() {
  input! {
    n:usize,
    s:usize,
    a:[usize;n],
  }
  let mut dp = vec![vec![0; s + 1]; n + 1];
  dp[0][0] = 1;
  for i in 0..n {
    for j in 0..=s {
      dp[i + 1][j] = (dp[i + 1][j] + 2 * dp[i][j]) % MOD;
      if j + a[i] <= s {
        dp[i + 1][j + a[i]] = (dp[i + 1][j + a[i]] + dp[i][j]) % MOD;
      }
    }
  }
  println!("{}", (dp[n][s] + MOD) % MOD);
}
const MOD: usize = 998244353;


Measured memory_bytes: 72508
import numpy as np
D = int(input())
C = np.array(input().split(), dtype=int)

S = tuple(tuple(map(int, input().split())) for _ in range(D))
T = [int(input()) for _ in range(D)]

last = np.ones(26, dtype=int)


ans = 0
for d, t in enumerate(T):
    t -= 1
    last[t] = 0

    score = S[d][t]
    score -= (C * last).sum()
    ans += score
    print(ans)
    last += 1

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

int c[10001][10001];

int llcs(string X, string Y)
{
    //cout << "hhh" << endl;
    //cout << X << " " << Y << endl;
    int m=X.size();
    int n=Y.size();
    //cout << m << " " << n << endl;
    int maxl=0;
    X=' '+X;
    Y=' '+Y;

    for(int i=1;i<=m;i++)c[i][0]=0;
    for(int i=1;i<=n;i++)c[0][i]=0;


    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            //cout << i << " " << j << c[i][j] << endl;
            if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
            else c[i][j]= max(c[i-1][j],c[i][j-1]);
            maxl=max(maxl,c[i][j]);
        }
    }
    return maxl;
}

int main()
{
    int N;
    cin >> N;
    string X,Y;
    for(int i=0;i<N;i++)
    {
        cin >> X;
        cin >> Y;
        cout << llcs(X,Y) << endl;
    }

    return 0;
}




Measured memory_bytes: 11020
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int Ceil(int a,int b){return ((a%b==0)?a/b:a/b+1);}

int main(){
	int n;
	cin>>n;
	cout<<(n%2==0?n:2*n)<<endl;
	return 0;
}


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

def cal_divisors(N):
    divisors = []
    i = 1
    while i*i <= N:
        if N % i == 0:
            divisors.append(i)
        i += 1
    return divisors

divisors = cal_divisors(N)
ans = 10**12

for d in divisors:
    ans = min(ans,max(len(str(d)),len(str(N//d))))
print(ans)

Measured memory_bytes: 65844
main :: IO ()
main = do
    [x,y] <- map read . words <$> getLine :: IO [Int]
    let a = [1,3,5,7,8,10,12]
        b = [4,6,9,11]
        c = [2]
    putStrLn $ if (elem x a && elem y a) || (elem x b && elem y b) then "Yes" else "No"


Measured memory_bytes: 3824
from collections import Counter
N, M = [int(i) for i in input().split()]

roads = []

for i in range(M):
    roads.extend(input().split())
    
c = Counter(roads)

for i in range(N):
    if str(i+1) in c.keys():
        print(c[str(i+1)])
    else :
        print('0')

Measured memory_bytes: 3316
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    readln;
    auto AS = readln.split.to!(int[]);
    AS.sort!"a > b";

    int A, B;
    foreach (i, a; AS) {
        if (i&1)
            B += a;
        else
            A += a;
    }
    writeln(A - B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef pair<ll,ll> P;typedef pair<ll,P> PP;
ll dx[6]={-1,0,0,1,0,0},dy[6]={0,-1,0,0,1,0},dz[6]={0,0,-1,0,0,1},a,b,c,n,s,t,r;
set<PP> m;
int main(){
  cin>>a>>b>>c>>n;
  ll ans=(a*b+b*c+c*a)*2;
  while(n--) {
    cin>>s>>t>>r;
    for(ll i=0;i<6;i++) {
      ll x=s+dx[i],y=t+dy[i],z=r+dz[i];
      ans+=(x<0||x>=a||y<0||y>=b||z<0||z>=c||m.count(PP(x,P(y,z))))?-1:1;
    }
    m.insert(PP(s,P(t,r)));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll a, b, k;cin >> a >> b >> k;
  // a -= k;
  // k -= a;
  if(a - k >= 0){
    cout << a - k << " " << b << endl;
  }else{
    k -= a;
    if(b - k >= 0){
      cout << 0 << " " << b - k << endl;
    }else{
      cout << 0 << " " << 0 << endl;
    }
  }
}

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

typedef long long ll;

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

      int n, m; cin >> n >> m;
      if (n == 1) {cout << m; return 0;}
      int ans = 0;
      for (int i = 1; i*i <= m; i++) {
            if (m % i == 0) {
                  if (m/i >= n) {ans = max(ans, i);}
                  if (i >= n) {ans = max(ans, m/i);}
            }
      }
      cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;

  int start=h1*60+m1;
  int end=h2*60+m2;
  int a=end-k;
  cout<<max(a-start,0);

return 0;
}


Measured memory_bytes: 3636
n = int(input())
ans = [0,0,0]
temp = [0,0,0]
for i in range(n):
    a = list(map(int,input().split()))
    temp[0] = max(ans[1],ans[2])+a[0]
    temp[1] = max(ans[0],ans[2])+a[1]
    temp[2] = max(ans[0],ans[1])+a[2]
    for i in range(3):
        ans[i] = temp[i]
print(max(ans))

Measured memory_bytes: 3064
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    total = sum(A) % MOD

    ans = total * total % MOD
    for a in A:
        ans = (ans - a * a) % MOD

    ans = ans * pow(2, MOD - 2, MOD) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 110560
#include"bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	if (S == "Sunny") {
		puts("Cloudy");
	}
	else if (S == "Cloudy") {
		puts("Rainy");
	}
	else {
		puts("Sunny");
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
#define NIL -1

struct Node{
    int parent;
    int left;
    int right;
};

Node T[10000];
int D[10000], H[10000];

void setDepth(int u, int d){    //上から下
    if(u==NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1=0, h2 = 0;
    if(T[u].left!=NIL) h1 = setHeight(T[u].left) + 1;
    if(T[u].right!=NIL) h2 = setHeight(T[u].right) + 1;

    return H[u] = max(h1, h2);
}

//節点uの兄弟を探す
int getSibling(int u){
    if(T[u].parent==NIL) return NIL;
    if((T[T[u].parent].left!=u)&&(T[T[u].parent].left!=NIL))
        return T[T[u].parent].left;
    if((T[T[u].parent].right!=u)&&(T[T[u].parent].right!=NIL))
        return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    printf("node %d: parent = %d, sibling = %d, ", u, T[u].parent, getSibling(u));
    int deg = 0;
    if(T[u].left!=NIL) deg++;
    if(T[u].right!=NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, height = %d, ", D[u], H[u]);

    if(T[u].parent==NIL) printf("root\n");
    else if(T[u].left==NIL && T[u].right==NIL) printf("leaf\n");
    else printf("internal node\n");
}

int main(){

    int n;
    scanf("%d", &n);

    for(int i=0; i<n; i++) T[i].parent = NIL;

    for(int i=0; i<n; i++){
        int v, l, r;    //子の数は決まっている
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l!=NIL) T[l].parent = v;
        if(r!=NIL) T[r].parent = v;
    }

    int root = 0;
    for(int i=0; i<n; i++){
        if(T[i].parent==NIL) root = i;
    }

    setDepth(root, 0);
    setHeight(root);

    for(int i=0; i<n; i++) print(i);

    return 0;

}


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

int main()
{
    ll N; cin >> N;
    vector<ll> a(N, 0);
    rep(i,N) {
        ll t; cin >> t;
        a[i] = t;
    }
    ll ans = 0;
    rep(i,N) {
        if ((i+1) % 2) {
            if (a[i] % 2) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
h, w = [ int(v) for v in input().split() ]
n = int(input())
num_list = [ int(v) for v in input().split() ]

grid_list = []
for i in range(n):
	grid_list += [str(i+1)]*num_list[i]

for i in range(h):
	if i % 2 == 0: 
		print(" ".join(grid_list[i*w:(i+1)*w]))
	else:
		print(" ".join(grid_list[i*w:(i+1)*w][::-1]))


Measured memory_bytes: 3700
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,fa[13];
int find(int a)
{
    if(a==fa[a])
    {
        return a;
    }
    return fa[a]=find(fa[a]);
}
void join(int a,int b)
{
    int f1=find(a),f2=find(b);
    if(f1!=f2)
    {
        fa[f1]=f2;
    }
}
int main()
{
	for(int i=1;i<=12;i++)
	{
	    fa[i]=i;
	}
	join(1,3);
	join(1,5);
	join(1,7);
	join(1,8);
	join(1,10);
	join(1,12);
	join(4,6);
	join(4,9);
	join(4,11);
	cin>>n>>m;
	if(find(n)==find(m))
	{
	    cout<<"Yes";
	}
	else
	{
	    cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import scala.collection._
object Main extends App {
    val Array(n, m) = scala.io.StdIn.readLine().split("\\s").map(_.toInt)
    var cnt_array = mutable.Seq[Int]()

    for (i <- 1 to 31){
        cnt_array :+= 0
    }

    for (i<-1 to n){
    val tmp_array = scala.io.StdIn.readLine().split("\\s").map(_.toInt)
    val k = tmp_array.take(1)
    val as = tmp_array.drop(1)
      for (j <- 0 until k(0)){
        cnt_array(as(j)) = cnt_array(as(j)) + 1
      }
    }

    var result = 0
    for (i<- cnt_array){
      if (i == n){
        result += 1
      }
    }

    println(result)
}

Measured memory_bytes: 25528
#include <cstdio>

typedef long long ll;

int main() {
    int A, B, N;
    scanf("%d%d%d", &N, &A, &B);
    if (N == 1) {
        if (A == B)
            printf("1\n");
        else
            printf("0\n");
    } else {
        if (A > B)
            printf("0\n");
        else
            printf("%lld\n", (ll)(B - A) * (N - 2) + 1);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3912
n=int(input())
s=set()
s.add(1)
a=6
while a<=n:
  s.add(a)
  a*=6
b=9
while b<=n:
  s.add(b)
  b*=9
dp=[10**9]*(n+1)
dp[0]=0
dp[1]=1
for i in range(n+1):
  for t in s:
    if i+t<=n:
      dp[i+t]=min(dp[i+t],dp[i]+1)
print(dp[n])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  vector<int> antennas(5);
  int N;
  cin >> N;
  vector<int> monster(N);
  for (int i = 0; i < N; i++) {
    cin >> monster[i];
  }
  sort(monster.begin(), monster.end());
  while (monster[1] != 0) {
    for (int i = 1; i < monster.size(); i++) {
      monster[i] %= monster[0];
      if(monster[i] == 0){
        monster.erase(monster.begin() + i);
      }
    }
    sort(monster.begin(), monster.end());
  }
  cout << monster[0] << endl;
}

Measured memory_bytes: 3720
//using System;
//class p0003
//{
//    static void Main(string[] args)
//    {
//        int cnt = int.Parse(Console.ReadLine());
//        while (0 < cnt--)
//        {
//            var ary = Console.ReadLine().Split(' ');
//            Array.Sort(ary);
//            var x = (int)Math.Pow(double.Parse(ary[0]), 2);
//            var y = (int)Math.Pow(double.Parse(ary[1]), 2);
//            var z = (int)Math.Pow(double.Parse(ary[2]), 2);
//            Console.WriteLine((x + y == z) ? "YES" : "NO");
//        }
//    }
//}


using System;
 
class p0003{
     
    static void Main(string[] args){
        int n;
        //string str;
        string[] s;
        int[] a = new int[3];

        //while ((str = Console.ReadLine()) != null)
        //{
            n = int.Parse(Console.ReadLine());

            while (0 < n--)
            {
                s = (Console.ReadLine()).Split(' ');
                for (int i = 0; i < 3; ++i)
                {
                    a[i] = int.Parse(s[i]);
                    a[i] = a[i] * a[i];
                }
                Console.WriteLine("{0}", ((a[0] == a[1] + a[2] || a[1] == a[0] + a[2] || a[2] == a[0] + a[1]) ? "YES" : "NO"));
            }
        //}
    }
     
}

Measured memory_bytes: 5468
import sys
import math

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

n = ni()
a = nil()

ans = 1
c = a[0]
fg = 0
for i in range(1, n):
    if a[i] == c:
        c = a[i]
    elif a[i] > c :
        if fg == 1 or fg == 0:
            fg = 1
            c = a[i]
        else:
            ans += 1
            c = a[i]
            fg = 0
    else:
        if fg == -1 or fg == 0:
            fg = -1
            c = a[i]
        else:
            ans += 1
            c = a[i]
            fg = 0


print(ans)






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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
char block[1010][1010];

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

int wrapx[5]={-2,-1,0,1,2};
int wrapy[5]={-2,-1,0,1,2};
int main(){
    long long h,w;
    cin>>h>>w;
    int ch,cw;
    cin>>ch>>cw;
    int dh,dw;
    cin>>dh>>dw;

    int warp=0;
    rep2(i,h){
        rep2(k,w){
            cin>>block[i][k];
        }
    }
    queue<int>q;
    queue<int>Q;
    q.push(ch);
    q.push(cw);
    Q.push(ch);
    Q.push(cw);
    //bool reached[1010][1010];
    long long  dist[1010][1010];

    rep2(i,h)rep2(k,w)dist[i][k]=INF;

    dist[ch][cw]=0;

    
        

while(!q.empty()){

    //コスト0で行ける範囲にたどり着く
    while(!q.empty()){
        int nowy=q.front();
        q.pop();
        int nowx=q.front();
        q.pop();
        //if(block[nowy][nowx]=='#')continue;
        Q.push(nowy);
        Q.push(nowx);
        rep(i,4){
            int ny=nowy+dy[i];
            int nx=nowx+dx[i];
            

            if(ny<1 || ny>h || nx<1 ||nx>w || block[ny][nx]=='#'){
                continue;
            }
            else if(dist[ny][nx]>dist[nowy][nowx]){
                dist[ny][nx]=dist[nowy][nowx];
                
                q.push(ny);
                q.push(nx);
            }
        }
    }
    //コスト+1しないといけない範囲を探索
    while(!Q.empty()){
        int i=Q.front();
        Q.pop();
        int k=Q.front();
        Q.pop();

            
                rep(l,5)
                {
                    rep(p,5)
                    {
                        if(abs(wrapy[l])+abs(wrapx[p])<=1)continue;

                        int ny=i+wrapy[l];
                        int nx=k+wrapx[p];

                            if(ny<1 || ny>h || nx<1 ||nx>w || block[ny][nx]=='#'){
                                continue;
                            }
                            //ワープして行ける範囲でコスト0の幅優先探索
                            else if(dist[ny][nx]>dist[i][k]+1){
                            dist[ny][nx]=dist[i][k]+1;
                            q.push(ny);
                            q.push(nx);
                            }
                    }
                }
            
            
    }
    
}

    
    if(dist[dh][dw]==INF){
        cout<<"-1"<<endl;
    }
    else{
        cout<<dist[dh][dw]<<endl;
    }
    // rep2(i,h){
    //     rep2(k,w){
    //         if(dist[i][k]==INF){
    //             cout<<"INF ";
    //         }
    //         else{
    //             cout<<dist[i][k]<<"    ";
    //         }
    //     }
    //     cout<<endl;
    // }


    return 0;

}
/*


*/


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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
#define int long long
#define endl '\n'
#define all(a)                   (a).begin(),(a).end()

#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))))

using namespace std;

const int N = 2e5 + 77;

string a , b ;
int n ; 
int A[N] , B[N];

int32_t main()
{
    fast;
    cin >> a >> b;
    n = a.length();
    bool ok = true;
    for(int i = 0 ; i < n ; ++i){
        int x = a[i]-'a' , y = b[i]-'a';
        A[x]++;B[y]++;
        if(A[x]!=B[y]){
            ok = false;
            break;
        }
    }
    
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3776
// D - Coloring Edges on Tree

// 色の選び方の無駄を改善

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

#define LEN 100001

typedef struct _Node {
    vector<int> connected_node_indeces;
    int parent_node_idx = 0;
} Node;

typedef struct _Edge {
    int color;
} Edge;

int a[LEN];
int b[LEN];
Node nodes[LEN];
map<pair<int, int>, Edge> edges;
int num_colors = 0;
queue<int> target_node_idx_queue;

// ノードの接続をセット
void set_connection (int node1_idx, int node2_idx) {
    nodes[node1_idx].connected_node_indeces.emplace_back(node2_idx);
    nodes[node2_idx].connected_node_indeces.emplace_back(node1_idx);
}

// 辺の色を取得
int get_edge_color(int node1_idx, int node2_idx) {
    if (node1_idx > node2_idx) swap(node1_idx, node2_idx);
    return edges[make_pair(node1_idx, node2_idx)].color;
}

// 辺の色をセット
void set_edge_color(int node1_idx, int node2_idx, int color) {
    if (node1_idx > node2_idx) swap(node1_idx, node2_idx);
    edges[make_pair(node1_idx, node2_idx)].color = color;
}


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

    for (int i=1; i<=N-1; i++) {
        cin >> a[i] >> b[i];
    }

    // まず接続だけを定義する
    for (int i=1; i<=N-1; i++) {
        set_connection(a[i], b[i]);
    }

    target_node_idx_queue.emplace(1);

    while(!target_node_idx_queue.empty()) {
        int target_node_idx = target_node_idx_queue.front();
        target_node_idx_queue.pop();
        auto& target_node = nodes[target_node_idx];
        int parent_node_idx = target_node.parent_node_idx;
        unordered_set<int> used_colors;

        //cout << "target node = " << target_node_idx << endl; // **** debug ****
        //cout << "parent node = " << parent_node_idx << endl; // **** debug ****

        // まず親と接続する辺の色をused_colorsに追加
        if (parent_node_idx > 0) {
            used_colors.insert(get_edge_color(parent_node_idx, target_node_idx));
        }

        int color = 1;
        for (int child_node_idx : target_node.connected_node_indeces) {
            if (child_node_idx == parent_node_idx) continue; // 親nodeは除外

            while (used_colors.find(color) != used_colors.end()) {
            	color++; // 既に使われている色の場合は次の色へ
            }

            set_edge_color(target_node_idx, child_node_idx, color);
            used_colors.insert(color);
            if (color > num_colors) num_colors = color;

            nodes[child_node_idx].parent_node_idx = target_node_idx;
            target_node_idx_queue.emplace(child_node_idx);
            //cout << child_node_idx << endl; // **** debug ****
            color++;
        }
    }

    cout << num_colors << endl;

    for (int i=1; i<=N-1; i++) {
        cout << get_edge_color(a[i], b[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 13824
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define max2(a,b) ((a)>(b)?(a):(b))   
#define min2(a,b) ((a)<(b)?(a):(b)) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef pair<ll,ll>     pll;
typedef pair<int,int>   pii;
typedef vector<ll>      vll;
typedef vector<int>      vi;
typedef vector< pll >  vpll;
typedef vector< pii >  vpii;
typedef set<ll>         sll;
typedef set<int>         si;
typedef set< pll >     spll;
typedef set< pii >     spii;
clock_t clk=clock();       

ll i,j,k;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
// #define cerr if(0)cerr

void solve()
{
	int n; cin>>n;
	double v[n],ans=0.0;
	rep(i,0,n-1)
	{
		cin>>v[i];
	}
	sort(v,v+n);

	rep(i,0,n-1)
		if(i==0) ans+=v[i];
		else ans+=(1LL<<(i-1))*v[i];
		
	ans/=(1LL<<(n-1));
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
//package abc174;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		
		if(N >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 32496
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double mTHeta = 6 * m;
        double hTheta = 30 * h + 0.5 * m;
        double theta = Math.abs(hTheta - mTHeta);

        double ans = 0;
        double bDash = 0;
        if (theta == 0 || theta == 360) ans = Math.abs(b - a);
        else if (theta == 180) ans = b + a;
        else if (theta > 180) {
            theta = 360 - theta;
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        } else {
            bDash = b - (Math.cos(Math.toRadians(theta)) * a);
            ans = Math.sqrt(bDash * bDash + Math.sin(Math.toRadians(theta)) * a * Math.sin(Math.toRadians(theta)) * a);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37504
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    int y=-1;
    int ans=0;
    int t=0;
    int x;
    for(int i=0;i<n;i++){
        cin>>x;
        if(y>=x){
           t++;
        }
        else t=0;
        if(t>ans) ans=t;
        y=x;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &q, &s)

	cnt := make([]int, n)
	c := 0
	for i := 1; i < n;i++ {
		if string(s[i]) == "C" {
			if string(s[i-1]) == "A" {
				c++
			}
		}
		cnt[i] = c
	}

	for i := 0 ; i < q; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		fmt.Println(cnt[r-1] - cnt[l-1])
	}
}


Measured memory_bytes: 6332
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n,m,ans=0;
	cin>>n>>m;
	vector<pair<lint,lint>>a(n);
	rep(i,n){
		lint p,c;
		cin>>p>>c;
		a.emplace_back(p,c);
	}
	sort(all(a));
	each(it,a){
		ans+=(*it).first*(*it).second;
		m-=(*it).second;
		if(m<=0){
			ans+=(*it).first*m;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4736
import sys
input = lambda: sys.stdin.readline().rstrip()

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(l[K-1])

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<vector<ll>> x(h, vector<ll>(w, -1)), y(h, vector<ll>(w, -1));
    REP(i, h) {
        ll con = 0;
        REP(j, w) {
            if(s[i][j] == '#') con = 0;
            else con++;
            x[i][j] = con;
        }
        ll now = -1;
        for(ll j=w-1; j>=0; --j) {
            if(x[i][j] == 0) now = -1;
            else {
                chmax(now, x[i][j]);
                chmax(x[i][j], now);
            }
        }
    }
    REP(i, w) {
        ll con = 0;
        REP(j, h) {
            if(s[j][i] == '#') con = 0;
            else con++;
            y[j][i] = con;
        }
        ll now = -1;
        for(ll j=h-1; j>=0; --j) {
            if(y[j][i] == 0) now = -1;
            else {
                chmax(now, y[j][i]);
                chmax(y[j][i], now);
            }
        }
    }

    // REP(i, h) cout << x[i] << endl;
    // cout << endl;
    // REP(i, h) cout << y[i] << endl;

    ll ans = 0;
    REP(i, h) REP(j, w) {
        chmax(ans, x[i][j]+y[i][j]-1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 67328
#include<iostream>
#include<cstring>
using namespace std;
const int N=200020;
long long s,n,a[N],ans=0;
int main()
{
	cin>>n;
	//memset(last,0,sizeof(last));
	for(int i=1;i<=n;i++) cin>>a[i];
	long long j=0;
	long long suma=0,sumb=0;
	for(int i=1;i<=n;i++)
	{
		while(j+1<=n&&sumb+a[j+1]==(suma^a[j+1]))
		{
			suma^=a[j+1];
			sumb+=a[j+1];
			j++;
		}
		ans+=j-i+1;
		suma^=a[i];
		sumb-=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define mkpr make_pair
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define init0(x) memset(x,0,sizeof(x));

using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int maxlimit=2e5+2;
const ll inf=1e18;
//TTBDC

// dekh k kiya

double dp[301][301][301];
int n;

double solve(int x,int y,int z){
  if(dp[x][y][z]!=-1)return dp[x][y][z];
  if(x+y+z==0)return dp[x][y][z]=0;
  double xyz = x+y+z;
  double N = n;
  dp[x][y][z]=(N-xyz)/xyz;
  if(x!=0)dp[x][y][z]+=x*(solve(x-1,y,z)+1)/xyz;
  if(y!=0)dp[x][y][z]+=y*(solve(x+1,y-1,z)+1)/xyz;
  if(z!=0)dp[x][y][z]+=z*(solve(x,y+1,z-1)+1)/xyz;
  return dp[x][y][z];
}

int main()
{
  fatafat
  int x;
  cin>>n;
  int cnts[4]={0,0,0,0};
  for(int i=0;i<n;i++){cin>>x;cnts[x]++;}
  for(int i=0;i<=300;i++){
    for(int j=0;j<=300;j++){
      for(int k=0;k<=300;k++){
        dp[i][j][k]=-1;
      }
    }
  }
  cout<<fixed<<setprecision(10)<<solve(cnts[1],cnts[2],cnts[3]);
  return 0;
}

Measured memory_bytes: 216836
'use strict'
function Main(input) {

  let Aset = input.split(" ").map(v => parseInt(v));
  // console.log({ Aset });

  let Answer = Aset[0] + Aset[1] + Aset[2];
  // console.log({ Answer });
  console.log(Answer >= 22 ? 'bust' : 'win');

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

/*
3 8
3 30
4 50
5 60

90
 */
public class Main {
    static long[][] mindist;
    static int[][] graph;

    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
//        Scanner scanner = new Scanner(System.in);
//        int N = scanner.nextInt();
//        int M = scanner.nextInt();

        int N = nextInt();
        int M = nextInt();
        mindist = new long[110][110110]; // nowまでの最小のコスト
        graph = new int[110][110];

        // dp[0][0] = 0
        for (long[] m : mindist) {
            Arrays.fill(m, 0);
        }

        for (int[] g : graph) {
            Arrays.fill(g, 0);
        }

        // graph for input
        for (int i = 0; i < N; i++) {
            // scanner
            int w = nextInt();
            int v = nextInt();

            graph[i][0] = w; // weight
            graph[i][1] = v; // cost
        }

        for (int i = 0; i < N; i++) { // next_id
            for (int weight = 0; weight <= M; weight++) { // weight
                // buy
                if (weight >= graph[i][0]) {
                    mindist[i + 1][weight] =
                            Math.max(mindist[i + 1][weight], mindist[i][weight - graph[i][0]] + graph[i][1]);
                }

                // not buy
                mindist[i + 1][weight] = Math.max(mindist[i + 1][weight], mindist[i][weight]);
            }
        }

        System.out.println(mindist[N][M]);
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 162900
import sys

n = int(input())
x = list(map(int, input().split()))
min_hp = sys.maxsize

for i in range(1, 100):
    hp = 0    
    for j in range(n):
        hp += (x[j] - i) * (x[j] - i)

    
    min_hp = min(hp, min_hp)
    
print(min_hp)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc129/tasks/abc129_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 累積和をとって順番に各区切りで分割した時の差分を見て行く
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<ll> T(N); for(auto& in:T) cin >> in;
    auto cusum = T;
    partial_sum(T.begin(),T.end(),cusum.begin());
    res = LINF;
    for(int i = 0; i < N-1;i++){
        res = min(res,abs((cusum[N-1]-cusum[i])-cusum[i]));
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  int A,B;
  cin>>A>>B;
  if (A>9||B>9) puts("-1");
  else cout<<A*B<<endl;
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a >= 13){
    cout << b << endl;
  }
  else if(a <= 5){
    cout << 0 << endl;
  }
  else{
    cout << b/2 << endl;
  }
}


Measured memory_bytes: 256
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if (a<=8 && b<=8) {
        console.log('Yay!');
    } else {
        console.log(':(');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<stdio.h>
int main(){
  long long int n,y,i,j,k;
  scanf("%lld %lld",&n,&y);
  y /= 1000;
  for(i = 0;i <= n;i++){
    for(j = 0;j + i <= n;j++){
      k = n - i - j;
      if(10 * i + 5 * j + k == y){
        printf("%lld %lld %lld\n",i,j,k);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){

int n;
char s[10000];

    cin >> n;
    cin >> s;
    if(n%2!=0)
        cout << "No" << endl;
    else{

        int i=0,j=n/2;
        bool flag = true;
        while(j<n){
              if(s[i]!=s[j]){
                flag = false;
                break;
              }
              i++;
              j++;
        }
        if(flag)
            cout << "Yes" << endl;
        else

            cout << "No" << endl;
    }
return 0;
}


Measured memory_bytes: 256
w,h,x,y=map(int,input().split())
m=w*h/2
if x==0 or y==0:
    print(m,0)
    exit()
if x==w or y==h:
    print(m,0)
    exit()


if w%x==0 and h%y==0:
    print(m,1)
else:
    print(m,0)

Measured memory_bytes: 38256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a > b){
    cout << a - 1<< endl;
  }else{
    cout << a << endl;
  }
}

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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

int n, m;
int x1, y_1;
int x2, y2;
vector<vector<char>> g;
int dist[(int)1e3 + 1][(int)1e3 + 1];

int d1[] = {1, -1, 0, 0};
int d2[] = {0, 0, 1, -1};

bool ok(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m && g[x][y] != '#';
}

void bfs(int x, int y) {
    deque<pair<int, int>> dq;
    dq.push_front({x1, y_1});
    while (!dq.empty()) {
        pair<int, int> u = dq.front();
        dq.pop_front();
        for (int i = 0; i < 4; i++) {
            int nx = u.first + d1[i], ny = u.second + d2[i];
            if (ok(nx, ny)) {
                if (dist[nx][ny] > dist[u.first][u.second]) {
                    dist[nx][ny] = dist[u.first][u.second];
                    dq.push_front({nx, ny});
                }
            }
        }

        for (int i = u.first - 2; i <= u.first + 2; i++) {
            for (int j = u.second - 2; j <= u.second + 2; j++) {
                if (ok(i, j)) {
                    if (dist[i][j] > dist[u.first][u.second]+1) {
                        dist[i][j] = dist[u.first][u.second]+1;
                        dq.push_back({i, j});
                    }
                }
            }
        }
    }
}


void solve() {
    cin >> n >> m;
    cin >> x1 >> y_1 >> x2 >> y2;
    x1--, y_1--, x2--, y2--;
    g = vector<vector<char>>(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> g[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            dist[i][j] = mod;
        }
    }

    dist[x1][y_1] = 0;

    bfs(x1, y_1);

    cout << (dist[x2][y2] != mod ? dist[x2][y2] : -1) << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 8580
#include<bits/stdc++.h>
using namespace std;
int a[3],b[3],c[3][3];
int main(){
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	cin>>c[i][j];
	a[1]=c[1][0]-c[0][0];
	a[2]=c[2][0]-c[0][0];
	b[0]=c[0][0];
	b[1]=c[0][1];
	b[2]=c[0][2];
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	if((a[i]+b[j])!=c[i][j]){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
}

Measured memory_bytes: 3608