akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[100001][13];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  REP(i, n) REP(j, 13) {
    if (s[i] == '?') {
      REP(k, 10) {
        dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
        dp[i + 1][(j * 10 + k) % 13] %= MOD;
      }
    } else {
      dp[i + 1][(j * 10 + s[i] - '0') % 13] += dp[i][j];
      dp[i + 1][(j * 10 + s[i] - '0') % 13] %= MOD;
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}

Measured memory_bytes: 10624
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 `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 2019
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

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

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

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 atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

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

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

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 s = String.to_list @@ scan "%s" id
let arr = Array.make (List.length s) 0

let () =
  List.fold_lefti (fun prev i c ->
      let open ModOp in
      let n = prev + pow 10 i * atoi c in
      arr.(i) <- n mod 2019; n)
    0 (List.rev s) |> ignore;
  let h = Hashtbl.create (Array.length arr) in
  Hashtbl.add h 0 1;
  ArrayL.iter arr ~f:(fun i -> Hashtbl.modify_def 0 i succ h);
  Hashtbl.map (fun _ i -> i*(i-1)/2) h |> Hashtbl.to_list
  |> List.map Tuple2.second
  |> List.sum
  |> Printf.printf "%d\n"


Measured memory_bytes: 24540
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000],cntl=0,ab[220000];
pair<int,int> pp[220000];
string s,sa,ss[220000];
char c,cc[220000];
queue<int> que;
signed main(){
    cin>>s>>sa;
    if(s+sa[sa.size()-1]==sa){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 10512
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int a,b;

    cin >> a >> b;

    for(int i=0;i<max(a,b);i++){
        cout << min(a,b);
    }

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	bool b[26] = {};
	string s; cin >> s;
	rep(i, 0, s.size()) {
		b[s[i] - 'a'] = true;
	}
	rep(i, 0, 26) {
		if (!b[i]) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int p,m,c;
  cin >> p >> m >> c;
  cout << p + m + c << endl;
}



Measured memory_bytes: 3088
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
// use std::collections::BinaryHeap;

fn main() {
  let n = read::<i64>();
  let mut four = 0;
  let mut two = 0;
  for _ in 0..n {
    let a = read::<i64>();
    if a % 4 == 0 {
      four += 1;
    } else if a % 2 == 0 {
      two += 1;
    }
  }

  if 0 < four && two == 0 {
    println!("{}", if 2 * four + two + 1 < n { "No" } else { "Yes" });
  } else if 0 < four {
    println!("{}", if 2 * four + two < n { "No" } else { "Yes" });
  } else {
    println!("{}", if two < n { "No" } else { "Yes" });
  }
}


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

int main(){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    if(b == 'T') cout << 'A' << endl;
    if(b == 'C') cout << 'G' << endl;
    if(b == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
n = [0 for i in range(n)]

for i in range(k):
  d = int(input())
  oyatu = list(map(int, input().split()))
  for i in oyatu:
    n[i-1]+=1
  
  
count = 0
for i in n:
  if i == 0:
    count+=1
print(count)

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



int main() {
    string S;
    cin >>S;
    int a =(S[0]-'0')*10+(S[1]-'0');
    int b =(S[2]-'0')*10+(S[3]-'0');
    if((a>=13||a==0) && 0<b&&b<=12)cout <<"YYMM"<<endl;
    else if(0<a&&a<=12 && (b>=13 || b==0))cout<<"MMYY"<<endl;
    else if((a>=13 || a==0)  && (b>=13 || b==0))cout<<"NA"<<endl;
    else cout <<"AMBIGUOUS"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

int ds[10];
bool used[11];

/* subroutines */

inline int dsum(int i0, int i1, int i2) {
  return (ds[i0] + ds[i1] + ds[i2]) % ds[9];
}

bool check() {
  int diag0 = dsum(0, 4, 8);
  return
    dsum(2, 4, 6) == diag0 &&
    dsum(0, 1, 2) == diag0 &&
    dsum(3, 4, 5) == diag0 &&
    dsum(6, 7, 8) == diag0 &&
    dsum(0, 3, 6) == diag0 &&
    dsum(1, 4, 7) == diag0 &&
    dsum(2, 5, 8) == diag0;
}

int rec(int k) {
  if (k >= 10) return check();

  if (ds[k] == 0) {
    int sum = 0;
    for (int d = 1; d <= 10; d++)
      if (! used[d]) {
	ds[k] = d;
	used[d] = true;
	sum += rec(k + 1);
	ds[k] = 0;
	used[d] = false;
      }
    return sum;
  }

  return rec(k + 1);
}

/* main */

int main() {
  for (;;) {
    cin >> ds[0];
    if (ds[0] == -1) break;

    for (int i = 1; i < 10; i++) cin >> ds[i];

    memset(used, false, sizeof(used));

    for (int i = 0; i < 10; i++)
      if (ds[i] > 0) used[ds[i]] = true;

    cout << rec(0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
a[9],i,f;main(w){for(;++i/6||1u/scanf("%d",i+a);i>10?i=f=0:0)i<6?f|=1<<a[i]:i<7?w=f-6?f-10?f-12?0:2:3:1:printf("%d\n",w?a[i-6]-w?2:1:3);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;
    vector<int> sets(n);
    rep(i, n) cin >> sets[i];

    // make all partial sums
    set<int> sums;
    for (int bit = 0; bit < (1 << n); bit++) {
        int sum = 0;
        for (int i = 0; i < (int)sets.size(); i++) {
            if (bit & (1 << i))
                sum += sets[i];
        }
        sums.insert(sum);
    }
    // otuput
    int q;
    cin >> q;
    rep(qi, q) {
        int key;
        cin >> key;

        cout << ((sums.count(key) ? "yes" : "no")) << endl;
    }
}


Measured memory_bytes: 3268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hh = sc.nextInt();
		int ww = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int sum = hh * ww;
		int row = h * ww;
		int column = w * hh;
		System.out.println(sum - row - column + h * w);
	}
}


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

using namespace std;

int main(void){

  string S;
  cin >> S;
  int s_len = S.size();

  for(int i = s_len - 1 ; i > 1; --i){
    if(i % 2 == 0){
      string S_sub_f = S.substr(0, i/2);
      string S_sub_l = S.substr(i/2, i/2);
      if(S_sub_f == S_sub_l){
	cout << i << endl;
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

#define EPS (1e-10)
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define equals(a, b) (fabs((a) - (b)) < EPS)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = 1e18;

// 点を表すクラス
class Point{
public:
  double x, y;
  Point(double x=0, double y=0): x(x), y(y) {}

  Point operator + (Point p) {return Point(x+p.x, y+p.y);}
  Point operator - (Point p) {return Point(x-p.x, y-p.y);}
  Point operator * (double a) {return Point(a*x, a*y);}
  Point operator / (double a) {return Point(x/a, y/a);}

  double abs() {return sqrt(norm());}
  double norm() {return x*x + y*y;}

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x: y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;  // ベクトルを表す構造体（成分表示）

double dot(Vector a, Vector b) {  // ベクトルの内積
  return a.x*b.x + a.y*b.y;
}
double cross(Vector a, Vector b) {  // ベクトルの外積
  return a.x*b.y - a.y*b.x;
}

struct Segment {Point p1, p2;};  // 線分を表す構造体(p1:始点、p2:終点)
typedef Segment Line;  // 直線を表す構造体（直線は無限長にする必要あり）

// 直交判定
bool isOrthogonal(Vector a, Vector b) {  // ベクトル同士の直交判定
  return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {  // a1とa2、b1とb2をそれぞれ端点にもつ線分の直交判定
  return isOrthogonal(a1-a2, b1-b2);
}
bool isOrthogonal(Segment s1, Segment s2) {  // 線分s1、s2の直交判定
  return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}

// 平行判定
bool isParallel(Vector a, Vector b) {  // ベクトル同士の平行判定
  return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2) {  // a1とa2、b1とb2をそれぞれ端点にもつ線分の平行判定
  return isParallel(a1-a2, b1-b2);
}
bool isParallel(Segment s1, Segment s2) {  // 線分s1、s2の平行判定
  return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}

// 線分sに対する点pの射影
Point project(Segment s, Point p) {
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

class Circle {  // 円を表す構造体
public:
  Point c;  // 中心
  double r;  // 半径
  Circle(Point c=Point(), double r=0.0): c(c), r(r) {}
};

typedef V<Point> Polygon;  // 多角形を表す構造体（頂点座標の配列）

int main() {
  ll x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  Segment seg; seg.p1 = Point(x1, y1); seg.p2 = Point(x2, y2);
  ll q; cin >> q;
  REP(i, q) {
    ll qx, qy; cin >> qx >> qy;
    Point p = project(seg, Point(qx, qy));
    cout << fixed << setprecision(10) << p.x << ' ' << p.y << endl;
  }
  return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,E,F;
set<int>water;
set<int>sugar;
int main(void)
{
    cin>>A>>B>>C>>D>>E>>F;
    for(int a=0;100*a<=F;a+=A)
    {
        for(int b=0;100*b+100*a<=F;b+=B)
        {
            water.insert(100*a+100*b);
        }
    }
    water.erase(0);
    for(int c=0;c<=F;c+=C)
    {
        for(int d=0;d+c<=F;d+=D)
        {
            sugar.insert(c+d);
        }
    }
    int perfact_water=0;
    int perfact_sugar=0;
    for(auto wa:water)
    {
        for(auto su:sugar)
        {
            if(wa+su<=F)
            {
                if((100*su<=wa*E)&&(su*(perfact_sugar+perfact_water)>=(wa+su)*perfact_sugar))
                {
                     perfact_water=wa;
                     perfact_sugar=su;
                }
            }
        }
    }
    cout <<perfact_water+perfact_sugar<<" "<<perfact_sugar<<endl;
    return 0;
    }




















//#include <bits/stdc++.h>
//using namespace std;
//int A,B,C,D,E,F;
//set<int>water;
//set<int>sugar;
//int main(void)
//{
//    cin>>A>>B>>C>>D>>E>>F;
//    for(int a=0;100*a<=F;++a)
//    {
//        for(int b=0;100*b+100*a<=F;++b)
//        {
//            water.insert(100*a+100*b);
//        }
//    }
//    water.erase(0);
//    for(int c=0;c<=F;c+=C)
//    {
//        for(int d=0;d<=F;d+=D)
//        {
//            sugar.insert(c+d);
//        }
//    }
//    int perfact_water;
//    int perfact_sugar;
//    double perfact_density=0.0;
//    for(auto wa:water)
//    {
//        for(auto su:sugar)
//        {
//            if(wa+su<=F)
//            {
//                double density=su*1.0/wa;
//                if(100*density<=E&&density>perfact_density)
//                {
//                     perfact_density=density;
//                     perfact_water=wa;
//                     perfact_sugar=su;
//                }
//            }
//        }
//    }
//    cout <<perfact_water+perfact_sugar<<" "<<perfact_sugar<<endl;
//    return 0;
//    }


Measured memory_bytes: 384
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
A = [[0 if j in b else j for j in A[i]] for i in range(3)]

for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        print('Yes')
        exit()

for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        print('Yes')
        exit()

if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
    exit()

if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
a = [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]
n = int(input()) - 1
print(a[n])

Measured memory_bytes: 3060
use std::io::{stdin, stdout, BufReader, BufWriter, Read, StdinLock, StdoutLock, Write};
use std::iter::Iterator;
use std::str::FromStr;

fn read<F: FromStr>(reader: &mut BufReader<StdinLock>) -> F {
    let str = reader
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    str.parse::<F>().ok().unwrap()
}

fn write(writer: &mut BufWriter<StdoutLock>, format: String) -> () {
    writeln!(writer, "{}", format).unwrap();
}

macro_rules! r {
    ($stream: expr) => (read::<String>($stream));
    ($stream: expr; ) => (r!($stream));
    ($stream: expr; $t: ty) => (read::<$t>($stream));
    ($stream: expr; $($t: ty),*) => (($(r!($stream; $t)),*));
    ($stream: expr; $t: ty; $n: expr) => ((0..$n).map(|_| read!($stream; $t)).collect::<Vec<_>>());
}

macro_rules! w {
    ($stream: expr) => (writeln!($stream).unwrap());
    ($stream: expr; ) => (w!($stream));
    ($stream: expr; $($arg:tt)*) => (write($stream, format!($($arg)*)));
}

fn main() {
    let sin = stdin();
    let sr = &mut BufReader::new(sin.lock());
    let sout = stdout();
    let sw = &mut BufWriter::new(sout.lock());

    let (a, b) = r!(sr; i64, i64);
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    w!(sw; "{}", ans);
}


Measured memory_bytes: 2100
N = int(input())
lis = list(map(int,input().split()))
lis.sort()
a = lis[0];fir=0;sec=0;torf=False
for i in range(N-1):
    if torf:
        torf = False
    elif a == lis[i+1]:
        if a > fir:
            sec = fir
            fir = a
            torf = True
        elif a > sec:
            sec = a
            torf = True
    a = lis[i+1]

print(fir*sec)

Measured memory_bytes: 63472
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> grid(h, vector<char>(w));
    rep(y, h)rep(x, w) cin >> grid[y][x];

    vector<vector<int>> distances(h, vector<int>(w, INT_MAX / 10));

    rep(y, h) rep(x, w) if (grid[y][x] == '#')distances[y][x] = 0;
    struct Point {
        ll y, x, cost;
    };

    queue<Point> q;
    rep(y, h) rep(x, w) if (grid[y][x] == '#') q.push({y, x, 0});


    auto to_id = [&](int y, int x) {
        return y * w + x;
    };

    struct Direction {
        int y, x;
    };


    vector<Direction> directions = {
            {0,  1},
            {1,  0},
            {0,  -1},
            {-1, 0},
    };


    auto reachable = [&](int y, int x, int distance) {
        if (x == -1 || x == w || y == -1 || y == h) return false;
        if (grid[y][x] == '#') {
            return false;
        }
        if (distances[y][x] <= distance) {
            return false;
        }
        return true;
    };


    while (!q.empty()) {
        Point p = q.front();
        q.pop();
        for (Direction d : directions) {
            int nx = p.x + d.x;
            int ny = p.y + d.y;
            int nd = p.cost + 1;
            if (reachable(ny, nx, nd)) {
                distances[ny][nx] = nd;
                q.push({ny, nx, nd});
            }
        }
    }

    int ans = 0;
    rep(y, h) rep(x, w) cmax(ans, distances[y][x]);
    cout << ans << endl;

}




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

int main(){
    int h,n;
    cin >>h>>n;
    
    int a;
    
    rep(i,n){
        cin >> a;
        h -= a;
    }
    if(h>0)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,M;
    cin >> N;
    vector<string> S(N);
    for(int i = 0;i < N;i++) cin >> S[i];
    cin >> M;
    vector<string> T(M);
   
    for(int i = 0;i < M;i++) cin >> T[i];
    int ans = 0;
    for(int i = 0;i < N;i++){
        int a = 0;
        for(int j = 0;j < N;j++){
            if(S[i] == S[j])a++;
        }
        for(int j = 0;j < M;j++){
            if(S[i] == T[j])a--;
        }
        ans = max(a,ans);
    }
    cout << ans << endl;
}   

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;

void solve() {
	vector<string> a = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	map<string, int> mp; 
	for (int i = 0; i < a.size(); i++) mp[a[i]] = i;

	string s;
	cin >> s;
	cout << 7 - mp[s];
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a>=13){
            System.out.println(b);
        }else if(6<=a && a<=12){
            System.out.println(b/2);
        }else{
            System.out.println(0);
        }
        
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0] == 'a' || S[0] == 'i' || S[0] == 'u' || S[0] == 'e' || S[0] == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);

	if (A + B == C + D) {
		printf("Balanced\n");
	} else if (A + B > C + D) {
		printf("Left\n");
	} else if (A + B < C + D) {
		printf("Right\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <stdio.h>

int main(){

	int A, B, X;

	scanf("%d %d %d", &A, &B, &X);

	if (A > X)
		printf("NO\n");
	else if (A + B >= X || A == X || B >= X)
		printf("YES\n");
	else
		printf("NO\n");


	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int time[6],i,sum=0,min=0;
  for(i=0;i<5;i++){
    scanf("%d",&time[i]);
    sum+=time[i];
    if(time[i]%10!=0){
      if(min<10-time[i]%10){
        sum+=min;
        min=10-time[i]%10;
      }
      else
        sum+=10-time[i]%10;
    }
  }
  printf("%d\n",sum);
  return 0;
}


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

int K,S;

int main(){
    cin >> K >> S;
    int ans = 0;

    REP(i,K){
        REP(j,K){
            int sum = S - i - j;
            if(sum >= 0 && sum <= K){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){

    int n;
    vector<int> a(20), b(50), c(50);
    cin >> n;
    for(int i=0; i<n; i++) cin >> a.at(i);
    for(int i=0; i<n; i++) cin >> b.at(i);
    for(int i=0; i<n-1; i++) cin >> c.at(i);

    int sum = 0;
    for(int i=0; i<n; i++){
        sum += b[a[i]-1];
        if(a[i]==a[i-1]+1){
            sum += c[a[i-1]-1];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp::max;

// knapsack-1.rs --- Knapsack-1
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        w_max: usize,
        items: [(u64, u64); n],
    }

    let mut dp = vec![vec![0u64; w_max + 1]; n + 1];

    for (i, (w, v)) in items.into_iter().enumerate() {
        for j in 0..w_max + 1 {
            dp[i + 1][j] = if w as usize <= j {
                max(dp[i][j], dp[i][j - w as usize] + v)
            } else {
                dp[i][j]
            }
        }
    }

    let ans = dp[n][w_max];
    println!("{}", ans);
}


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

using namespace std;

#define prev(x) ((x - 1 + (M+1)) % (M+1))
#define next(x) ((x + 1) % (M+1))

int main(){
    int N,M,p;
    cin >> N >> M >> p;
    vector<int> d(M+1);
    for(int i = 0 ; i < M ; i++){
        cin >> d[i];
    }
    d[M] = p;
    for(int i = 0 ; i <= M ; i++){
        d[i] -= p;
        if(d[i] < 0) d[i] += N;
    }
    sort(d.begin(),d.end());
    int res = min(d[prev(0)],N-d[next(0)]);
    for(int i = 1 ; i <= M ; i++){
        int pr = d[prev(i)],ne = d[next(i)];
        int pc = (N-d[i])*2 + pr,nc = d[i]*2+(N-ne);
        res = min(res,pc);
        res = min(res,nc);
    }
    cout << res*100 << endl;
    return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int n, a[200000];
int solve(int mid){
  int s = a[mid];
  rrep(i,n){
    if(i == mid)continue;
    if(a[i] <= 2*s){s += a[i];continue;}
    return 0;
  }
  return 1;
}

signed main(){
  scanf("%lld", &n);
  rrep(i,n)scanf("%lld", &a[i]);
  sort(a+1, a+n+1);
  int lb = 0, ub = n;
  while(ub-lb > 1){
    int mid = (ub+lb)/2;
    int res = solve(mid);
    if(res)ub = mid;
    else lb = mid;
  }
  printf("%lld\n", n-ub+1);
	return 0;
}









Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

using int64 = long long;

const int64 INF = (1LL << 50);

int64 memo[2][2010];
int64 N, Z, W, a[2010];

int64 game_result(int turn, int next) {
    if (memo[turn][next] >= 0) return memo[turn][next];

    // nextから相手の今持っているカードが特定できる
    int64 enemy = (next == 0) ? W : a[next - 1];

    int64 res = (turn == 0) ? -INF : INF;
    for (int i = next; i < N - 1; i++) {
        if (turn == 0) {
            res = max(res, game_result(turn ^ 1, i + 1));
        } else {
            res = min(res, game_result(turn ^ 1, i + 1));
        }
    }
    if (next < N) {
        if (turn == 0) {
            res = max(res, abs(enemy - a[N - 1]));
        } else {
            res = min(res, abs(enemy - a[N - 1]));
        }
    }
    return memo[turn][next] = res;
}

int main() {
    // X: 最大化
    // Y: 最小化
    // どちらかは必ずa_{N-1}を持っている
    // Xがa_{N-1}を持っている場合

    cin >> N >> Z >> W;

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

    memset(memo, -1, sizeof(memo));

    cout << game_result(0, 0) << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#define int long long int
#define endl "\n"
using namespace std;
int findRank(string str) 
{ 
	// store original string 
	string orgStr = str; 

	// Sort the string in lexicographically 
	// ascending order 
	sort(str.begin(), str.end()); 

	// Keep iterating until 
	// we reach equality condition 
	long int i = 1; 
	do { 
		// check for nth iteration 
		if (str == orgStr) 
			break; 

		i++; 
	} while (next_permutation(str.begin(), str.end())); 

	// return iterator value 
	return i; 
} 

void solve()
{
	//Enter your code here Tanmay:)
	int n;string s1,s2;
	cin>>n;
	int j=n;
	while(j--)
	{
		string str;
		cin>>str;
		s1=s1+str;
	}
	while(n--)
	{
		string str;
		cin>>str;
		s2=s2+str;
	}

	//cout<<s1<<s2;
	//cout<<str1;
	int a1=findRank(s1);
	int b1=findRank(s2);
	//cout<<s1<<" "<<s2;
	//cout<<a<<b;
	cout<<abs(a1-b1);
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
public class Main {
  private static void solve() {
    int r = ni();
    int g = ni();
    
    int d = g - r;
    System.out.println(r + d * 2);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 23124
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,z,w = LI()
    a = LI()
    m = {}
    def f(z,w,i,t):
        if i >= n:
            return abs(z-w)
        if t:
            k = (-1,w,i)
            if k in m:
                return m[k]
            r = -1
            for j in range(i,n):
                jr = f(a[j],w,j+1,False)
                if r < jr:
                    r = jr
            m[k] = r
        else:
            k = (z,-1,i)
            if k in m:
                return m[k]
            r = inf
            for j in range(i,n):
                jr = f(z,a[j],j+1,True)
                if r > jr:
                    r = jr
            m[k] = r
        return m[k]

    return f(z,w,-1,True)



print(main())




Measured memory_bytes: 8096
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//よくわかんなくなってきた
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	ll N = getint(), M = getint();
	int A[100002] = {};
	rep(i, N) A[getint()]++;	
	for (int i = 100000; i > 1; i--) {
		A[i - 1] += A[i];
	}

	int L = 2;
	int R = 200001;
	while (L + 1 < R) {
		int m = (L + R) / 2;

		ll kazu = N * A[min(100001, m - 1)];
		for (int i = min(100000, m - 2); i >= max(1, m - 100000); i--) {
			ll k = A[i] - A[i + 1];
			if (k) {
				kazu += A[m - i] * k;
			}
		}

		if (kazu >= M) L = m;
		else R = m;
	}

	ll S[100002];
	S[100001] = 0;
	for (int i = 100000; i >= 1; i--) {
		S[i] = S[i + 1] + ll(A[i] - A[i + 1]) * i;
	}
	ll kotae = 0;
	ll kazu = 0;
	for (int i = 100000; i >= 1; i--) {
		ll k = A[i] - A[i + 1];
		if (k) {
			int k2 = L - i;
			if (k2 <= 1) {
				kotae += S[1] * k;
				kotae += N * k * i;
				kazu += N * k;
			}
			else if (k2 <= 100000) {
				kotae += S[k2] * k;
				kotae += A[k2] * k * i;
				kazu += A[k2] * k;
			}
		}
	}

	kotae -= ll(kazu - M) * L;

	printf("%lld", kotae);


	Would you please return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    a[0] = sc.nextInt();
    a[1] = sc.nextInt();
    a[2] = sc.nextInt();
    Arrays.sort(a);
    String str = ((a[0]+a[1]) == a[2]) ? "Yes" : "No";
    System.out.println(str);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N, K;
    int mindist = INT_MAX;
    cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    if (K == 1) {
        for (int i = 0; i < N; i++) {
            mindist = min(mindist, abs(x[i]));
        }
        cout << mindist << endl;
        return 0;
    }

    for (int i = 0; i < N - K + 1; i++) {
        int dist;
        if (x[i + K- 1] >= 0 && x[i] >= 0) {
            dist = x[i + K - 1];
        } else if (x[i + K - 1] <= 0 && x[i] <= 0) {
            dist = -x[i];
        } else {
            dist = min(x[i + K - 1], -x[i]) + (x[i + K - 1] - x[i]);
        }
        // cout << i << " " << x[i + K - 1] << " " << x[i] << " " << dist << endl;
        mindist = min(mindist, dist);
    }
    cout << mindist << endl;
    return 0;
}


Measured memory_bytes: 640
import numpy as np

N = int(input())
xy = []
for _ in range(N):
  xy.append(list(map(int, input().split())))
  
xy = np.array(xy)
d = np.linalg.norm(xy[np.newaxis,:,:] - xy[:,np.newaxis,:], axis=2)

print(np.sum(d)/N)

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")

typedef long long ll;
typedef unsigned long long ull;
#define fatnet ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll MOD = 1e9 + 7;
const ll MOD1 = 1e9 + 7;
const ll MOD2 = 2000003983;
const ll MOD3 = 1e9 + 9;
const ll p1 = 1e6 + 3;
const ll p2 = 2017;
const ll p3 = 37;
const ll INF = 5e18;

int main() {
    fatnet;

    ll n;
    cin >> n;
    cout << n * n * n << "\n";

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if ((a+b) < (c+d)) {
    cout << "Right" << endl;
  }
  else 
  if ((a+b) > (c+d)) {
    cout << "Left" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int n=(int)s.size();
  vector<int> ans(n, 0);
  int cnt=0;char c='R';
  int boundary=-1;
  rep(i, n){
    if(s[i]==c){
      cnt++;
    }else if(c=='R'){
      ans[i-1]+=(cnt+1)/2;
      ans[i]+=cnt/2;
      boundary = i;
      cnt=1;
      c=s[i];
    }else{
      ans[boundary-1]+=cnt/2;
      ans[boundary]+=(cnt+1)/2;
      cnt=1;
      c=s[i];
    }
  }
  ans[boundary-1]+=cnt/2;
  ans[boundary]+=(cnt+1)/2;
  rep(i, n)cout<<ans[i]<<" ";cout<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
    
using namespace std;
    
int main() {    
    int n;
    cin >> n;
    
    bool yes = false;
    while (n) {
        if (n % 10 == 7) {
            yes = true;
            break;
        }
        
        n /= 10;
    }
    
    cout << (yes ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 3624
import std.stdio;
import std.string;
import std.conv;

void main() {
	long n, y;
	scanf("%ld %ld", &n, &y);
	y /= 1000;
	foreach(i; 0..n+1) {
		foreach(j; 0..(n+1-i)) {
			if (i*10+j*5+(n-i-j) == y) {
				writef("%s %s %s", i, j, n-i-j);
				return;
			}
		}
	}
	write("-1 -1 -1");
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()

using pii=pair<int,int>;
using ll=long long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }


bool box[21][41];
void solve(int r,int n){
  rep(y,21) rep(x,41) box[y][x]=false;
  rep(i,n) {
    int li,ri,hi;
    cin >> li >> ri >> hi;

    for(int y=0;y<hi;++y) {
      for(int x=li+20;x<ri+20;++x){
        box[y][x]=true;
      }
    }
  }
  auto ans=numeric_limits<double>::max();
  rep(y,21){
    for(int x=-r+20;x<r+20;++x) {
      if(!box[y][x]){
        double time;
        if(x<20) time = (double) y+r-sqrt(pow((double)r,2.0)-pow(x-19.0, 2.0));
        else time = (double) y+r-sqrt(pow((double)r,2.0)-pow(x-20.0, 2.0));
        ans=min(ans,time);
      }
    }
  }
  printf("%.4lf\n",ans);
}

int main()
{
  int r,n;
  while(cin>>r>>n && r){
    solve(r,n);
  }
  return 0;
}



Measured memory_bytes: 3188
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
string s;
string a="dream",b="erase";
int main()
{
	cin>>s;
	int i,j;
	for(i=0;i<s.length();i=i)
	{
		if(s[i]==a[0])
		{
			for(j=0;i<s.length()&&j<a.length();j++,i++)
				if(s[i]!=a[j])
				{
					cout<<"NO"<<endl;
					return 0;
				}
			//cout<<i<<" "<<j<<endl;
			//system("pause");
			if((i==s.length()&&j<a.length())||(i!=s.length()&&s.length()-i<2))
			{
				cout<<"NO"<<endl;
				return 0;
			}
			if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]!='a')
				i+=2;
		}
		else if(s[i]==b[0])
		{
			for(j=0;i<s.length()&&j<b.length();j++,i++)
				if(s[i]!=b[j])
				{
					cout<<"NO"<<endl;
					return 0;
				}
			//cout<<i<<" "<<j<<endl;
			//system("pause");
			if((i==s.length()&&j<b.length())||(i!=s.length()&&s.length()-i<1))
			{
				cout<<"NO"<<endl;
				return 0;
			}
			if(s[i]=='r')i++;
		}
		else
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int main(){
	int a,b;
	int add,sub,mul;
	cin >> a;
	cin >> b;
	add = a + b;
	sub = a - b;
	mul = a*b;
	if(add >= sub){
		if(add >= mul){
			cout << add;
		}
		else if(mul > add){
			cout << mul;
		}
	}
	else if(sub > add){
		if(sub >= mul){
			cout << sub;
		}
		else if(mul > sub){
			cout << mul;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define INF 1000000;

using namespace std;

int main() {
   int n, m;
   int a[1010];
   cin >> n >> m;
   int count=0;

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

   for (int i=0; i<n; i++){
       if(a[i]>=goukei/(4*m)) count++;
   }
 


   if (m<=count) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ll n,t,a;
    ll ans=1,mnt=1,mna=1;
    cin>>n;
    rep(i,n){
        cin>>t>>a;
        ll m=max(mna/a+(mna%a==0?0:1),mnt/t+(mnt%t==0?0:1));
        mnt=t*m;
        mna=a*m;
    }
    cout<<mnt+mna<<endl;
    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int a,b,c;
  cin >> a >>b >> c;
  if(a!=b||b!=c||c!=a) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int f(int n,int number) {
	if (number == 4)return(n + 3);
	if (number % 2==0)f(n + 1, number/2);
	else f(n + 1, number * 3 + 1);
}
int main()	
{
	int n;
	cin >> n;
	if (n <= 2)cout << 4 << endl;
	else cout <<f(1,n)<< endl;
}


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

int main() {
	int l[10];
	int v1, v2;
	char d;
	while (cin >> l[0] >> d >> l[1] >> d >> l[2] >> d >> l[3] >> d >> l[4] >> d >> l[5] >> d >> l[6] >> d >> l[7] >> d >> l[8] >> d >> l[9] >> d >> v1 >> d >> v2) {
		double sum = 0;
		for (int i = 0; i < 10; ++i) {
			sum += l[i];
		}
		double p1 = v1 * sum / (v1 + v2);
		for (int i = 0; i < 10; ++i) {
			p1 -= l[i];
			if (p1 <= 0) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    n,k=map(int,readline().split())
    G=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(lambda x:int(x)-1,readline().split())
        G[a].append(b)
        G[b].append(a)

    ans=k
    stack=deque([0])
    flags=[False]*n
    flags[0]=True
    #dfs
    while len(stack)>0:
        now=stack.pop()
        if now==0:
            ans*=P(k-1,len(G[0]),mod)
            ans%=mod
        else:
            ans*=P(k-2,len(G[now])-1,mod)
            ans%=mod
        for nex in G[now]:
            if flags[nex]==False:
                flags[nex]=True
                stack.append(nex)

    print(ans)

def P(n,k,mod):
    res=1
    for m in range(n,n-k,-1):
        res*=m
        res%=mod
    return res

if __name__=="__main__":
    main()

Measured memory_bytes: 23824