akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let A: Vec<Vec<char>> = sc.mat_chars(N);
    let B: Vec<Vec<char>> = sc.mat_chars(M);
    for row_a in 0..N-M+1 {
        for col_a in 0..N-M+1 {
            let mut ok = true;
            for row_b in 0..M {
                for col_b in 0..M {
                    if A[row_a + row_b][col_a + col_b] != B[row_b][col_b] {
                        ok = false;
                    }
                }
            }
            if ok {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
"use strict"

const { Z_ASCII } = require("zlib");

const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let v = nextIntArray()
    v.sort((a, b) => a - b)
    let ans = (v[0] + v[1]) / 2
    if(v.length == 2){
        console.log(ans)
        return
    }
    for (let i = 2; i < v.length; i++) {
        ans = (ans + v[i]) / 2
    }
    console.log(ans)
}
Main()



Measured memory_bytes: 29948
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = int64_t;
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
#define DEBUG

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

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) << "..." << endl;
  }

  #ifdef DEBUG
  // cout << 123 << endl;
  #endif
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	ll a,ans=0ll,m=0ll;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		ans += std::max(m-a,0ll);
		m = std::max(m,a);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, A));
    }

    private static long solve(int N, int[] A) {
        long ans = 0;
        int sum = 0;
        int right = 0;

        for (int left=0; left<N; left++) {
            while (right < N && (sum ^ A[right]) == (sum + A[right])) {
                    sum += A[right++];
            }

            ans += right - left;
            if (left == right) {
                right++;
            } else {
                sum -= A[left];
            }
        }


        return ans;
    }
}

Measured memory_bytes: 75140
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
x = 0
bj = M
for i in range(N + 1):
    if a[i] > K:
        break
    for j in range(bj, -1, -1):
        if a[i] + b[j] <= K:
            bj = j
            x = max(x, i + j)
            break
print(x)

Measured memory_bytes: 47480
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int main(void) {
  int a, b;
  cin >> a >> b;
  printf("%.10lf\n", (double) a*b / 3.305785);

  return 0;
}





// EOF

Measured memory_bytes: 3184
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	vector<int> number_list({ A, B, A - 1, B - 1 });

	sort(number_list.begin(), number_list.end());

	cout << number_list[3] + number_list[2];

	return 0;
}


Measured memory_bytes: 3624
M = 10**9+7
n = int(input())
s = input()
t = input()
ans = 3 if s[0] == t[0] else 6
for i in range(1, n):
  if s[i-1] == s[i]:
    continue
  if s[i-1] == t[i-1]:
    ans = ans * 2 % M
  elif s[i] != t[i]:
    ans = ans * 3 % M
print(ans)

Measured memory_bytes: 3064
from itertools import product
def resolve():
  N, M = map(int, input().split())
  k = []
  s = []
  for i in range(M):
    s.append(list(map(int, input().split())))
    k.append(s[-1].pop(0))
  p = list(map(int, input().split()))
  ret = 0
  print(sum([1 for st in product(range(2), repeat=N)
       if sum([1 for i in range(M)
               if sum([st[sij-1] for sij in s[i]])%2 == p[i]
              ]) == M
      ]))
resolve()

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

int main(){
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	int N = n;
	int counter = 0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if((n-i*r-j*g)%b==0 && (n-i*r-j*g)>=0) counter++;
			
		}
	}
	cout << counter;
	
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n;
    scanf("%d",&n);
    int a[n],max=3;
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (a[i]>max){
            max=a[i]+1;
        }
    }
    int count[max];
    for (int i=0; i<max; i++){
        count[i]=0;
    }
    for(int i=0; i<n; i++){
        count[a[i]]++;
    }
    int tmp=0;
    for (int i=1; i<max-1; i++){
        if(count[i-1]+count[i]+count[i+1]>tmp){
            tmp=count[i-1]+count[i]+count[i+1];
        }
    }
    printf("%d\n",tmp);
	return 0 ;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    ll dp[100];
    dp[0]=2;
    dp[1]=1;
    int n;
    cin>>n;
    rep2(i,2,100){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

s1 = s[0,n/2]
s2 = s[n/2,s.length-1]
if n%2 != 0
    puts 'No'
else
    if s1 == s2
        puts 'Yes'
    else
        puts 'No'
    end
end


Measured memory_bytes: 3836
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
int gcd(int m, int n) {
    if (n > m) return gcd(n, m);

    if (n == 0) return m;
    else return gcd(n, m % n);
}
int main() {
    int n; cin >> n;
    vector<LL> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int res = a[0];
    for (auto x : a) {
        res = gcd(res, x);
    }
    cout << res << endl;
}


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

using std::pair;
using std::vector;
using std::string;
 
typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int T;
    ll a, b, c, d;

    read(T);
    while(T--) {
        read(a), read(b), read(c), read(d);

        if(a < b || d < b) { 
            puts("No"); 
        } else if(c >= b) {
            puts("Yes");
        } else if(a % b > c) {
            puts("No");
        } else {
            ll x = std::__gcd(b, d), y = a % b;
            ll t = (c - y + x) / x;
            if(y + t * x < b) puts("No"); else puts("Yes");
        }
    }

    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val k = in(0).toInt
  val K = "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"   
  val ls = K.split(", ").map(_.toInt)
  
  println(ls(k-1))
}


Measured memory_bytes: 27332
const main = (input) => {
  const [s, t] = input.trim().split('\n')

  let count = 0
  for (let i=0; i<s.length; i++) if (s[i] !== t[i]) count++
  return console.log(count)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main() {
   char s1,s2,s3;
   cin >> s1 >> s2 >> s3;
   int ans = 0;
   if(s1=='1')ans++;
   if(s2=='1')ans++;
   if(s3=='1')ans++;
   cout << ans <<endl;
}

Measured memory_bytes: 3584
n,m = map(int,input().split())
P = [list(map(int,input().split())) for _ in range(n)]
C = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
  min_dist = 10**18
  idx = 0
  for j in range(m):
    dist = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
    if min_dist > dist:
      idx = j + 1
      min_dist = dist
  print(idx)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll inf=1e18;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    c-=a+b;
    if(c<0) cout<<"No";
    else{
        c*=c;
        if(a*b  > inf/4) cout<<"Yes";
        else{
            if(a*b*4 < c) cout<<"Yes";
            else cout<<"No";
        }
    }
}

Measured memory_bytes: 256
//AtCoder ABC108 C - Triangular Relationship
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N,K; cin>>N>>K;
    //a%K==0
    ll num=N/K;
    ll ans=num*num*num;
    //a%K==K/2
    if(K%2==0){//Kが偶数
        ll k2=K/2;
        ll num2=(N+k2)/K;
        ans+=num2*num2*num2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    REP(i, n)
    {
        int a;
        cin >> a;
        v.push_back(make_pair(a, i + 1));
    }
    sort(v.begin(), v.end());
    REP(i, n)
    {
        pair<int, int> pr;
        pr = v[i];
        cout << pr.second << endl;
    }
}

Measured memory_bytes: 1780
<?php
$str = trim(fgets(STDIN));
$N = strlen($str);
$num = 0;
$d = 1;
$count = array_fill(0,2019,0);
$count[0]++;
for($i = $N-1; $i >= 0; $i--){
  $num+=((int)$str[$i])*$d;
  $num%=2019;
  $d*=10;
  $d%=2019;
  $count[$num]++;
}
$sum = 0;
for($i = 0; $i < 2019; $i++)$sum+=$count[$i]*($count[$i]-1)/2;
echo $sum;


Measured memory_bytes: 16508
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ary = new int[n];
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
            ary[i] = int.Parse(line[i]);
        for (int i = n - 1; i >= 0; i--)
        {
            Console.Write(ary[i]);
            if (i == 0) Console.WriteLine();
            else Console.Write(" ");
        }
    }
}

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

using namespace std;

#define ll long long

int main(){
    //freopen("tree.in","r",stdin);
    //freopen("tree.out","w",stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    
    int n, w;
    cin >> n >> w;
    vector<ll> dp(w+1);
    for(int i = 0; i < n; ++i){
        int weight, value;
        cin >> weight >> value;

        for(int weight_cal = w-weight; weight_cal >= 0; --weight_cal){
            dp[weight_cal+weight] = max(dp[weight_cal+weight], dp[weight_cal]+value);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= w; ++i){
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <cmath>

using namespace std;
using lli = long long int;

//int main(void) {
//	lli N,ans = 0;
//	cin >> N;
//
//	if (N == 1) {
//		cout << "0" << endl;
//		return 0;
//	}
//
//	for (lli i = 1; i <= sqrt(N); i++) {
//		lli m = (N - i) / i;
//
//		if (N % m == N / m) {
//			ans += m;
//		}
//
//	}
//
//	cout << ans << endl;
//
//	return 0;
//}
//
int main(void) {

	lli N,ans = 0;
	cin >> N;

	lli a = 0, b = 0, ab = 0;

	for (int i = 0; i < N; i++) {
		string str;
		cin >> str;

		if (str[0] == 'B' && str[str.size() - 1] == 'A') ab++;
		else if (str[0] == 'B') b++;
		else if (str[str.size() - 1] == 'A') a++;
		for (int j = 0; j < str.size() - 1; j++) {
			if (str[j] == 'A' && str[j + 1] == 'B') {
				ans++;
			}
		}
	}

	cout << ans + min(a, b) + ((a == 0 && b == 0 && ab > 0) ? ab - 1 : ab) << endl;

	return 0;
}
//
//int main(void) {
//
//	lli r, g, b, n, ans = 0;
//	cin >> r >> g >> b >> n;
//
//	for (int i = 0; i <= n; i++) {
//		for (int j = 0; j <= n; j++) {
//			if ((n - r * i - g * j) >= 0 && (n - r * i - g * j) % b == 0) {
//				ans++;
//				cout << r << " " << g << " " << (n - r * i - g * j) / b << endl;
//			}
//		}
//	}
//
//	cout << ans << endl;
//
//	return 0;
//}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  int n,k,s;
  cin >> n >> k >> s;
  for(int i = 0;i <= k - 1;i++){
      cout << s << " ";
  }
  if(s == 1000000000){
    for(int i = 0;i <= n - k - 1;i++){
      if(i == n - k - 1){
        cout << 1 << endl;
      }
      else{
        cout << 1 << " " << endl;
      }
    }
  }
  else{
    for(int i = 0;i <= n - k - 1;i++){
      if(i == n - k - 1){
        cout << s + 1 << endl;
      }
      else{
        cout << s + 1 << " ";
      }
    }
  }
  return 0;
}





Measured memory_bytes: 1280
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n,a,b,c,d = map(int, input().split())
    a -=1
    b -=1
    c -=1
    d -=1

    s = input()

    a_r = a
    cnt = 0
    for i in range(a, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        a_r = i
        if cnt == 2:
            a_r = i
            break

    b_r = b
    cnt = 0
    for i in range(b, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        b_r = i
        if cnt == 2:
            b_r = i
            break
    if a_r < c or b_r < d:
        print('No')
        return
    if c < d:
        print('Yes')
        return
    cnt = 0
    for i in range(b, d+1):
        if s[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            return

    if s[b-1] == '.' and s[b+1] == '.':
        print('Yes')
        return
    if s[d-1] == '.' and s[d+1] == '.':
        print('Yes')
        return
    print('No')


main()

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int d[N];
  for (int i = 0; i < N; i++) cin >> d[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) break;
      ans += d[i] * d[j];
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
ps = []
for _ in range(n):
    x, y, h = map(int, input().split())
    ps.append((x, y, h))

def calc(cx, cy):
    excepth = -1
    for x, y, h in ps:
        if h > 0:
            tmph = h + abs(x - cx) + abs(y - cy)
            if excepth == -1:
                excepth = tmph
            elif excepth != tmph:
                return -1
    for x, y, h in ps:
        if h == 0:
            tmpd = abs(x - cx) + abs(y - cy)
            if excepth - tmpd > 0:
                return -1
    return excepth

for cy in range(101):
    for cx in range(101):
        resh = calc(cx, cy)
        if resh != -1:
            print(cx, cy, resh)
            break

Measured memory_bytes: 3064
class Main {
    public static void main(String[] a) {
        int i, j, result;

        for (i = 1; i < 10; ++i) {
            for (j = 1; j < 10; ++j) {
                result = i * j;
                System.out.printf("%dx%d=%d\n", i,j,result);
            }
        }
    }
}

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

int main() {
	//cout << "" << endl; // prints
	long long int a, b, c, d;
	long long int ac, ad, bc, bd;
	cin >> a >> b >> c >> d;
	ac = a * c;
	ad = a * d;
	bc = b * c;
	bd = b * d;
	long long int ans;
	ans = max({ac, ad, bc, bd});
	cout << ans;

	return 0;
}

Measured memory_bytes: 3640
h,w,k=map(int,input().split())
l=[input()for _ in range(h)]
def t(m,h,w):
    n=[]
    for i in range(w):
        s=''
        for j in range(h):
            s+=m[j][i]
        n.append(s)
    return n
ans=0
for i in range(2**h):
    m=l.copy()
    b=bin(i)[2:].zfill(h)
    for n,i_ in enumerate(b):
        if i_=='1':
            m[n]='x'*w
    m=t(m,h,w)
    for j in range(2**w):
        x=m.copy()
        b=bin(j)[2:].zfill(w)
        for n,j_ in enumerate(b):
            if j_=='1':
                x[n]='x'*h
        c=0
        for r in x:
            c+=r.count('#')
        if c==k:
            ans+=1
print(ans)


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <string>
#include <complex>
#include <cmath>
#include <algorithm>

using namespace std;

int n, m;
int a[500], b[222500], c[500];

int main()
{
    cin >> n;
    for (int i = 1; i < n; i++) cin >> b[i];
    b[0] = 1e9, b[n] = 1e9;
    for (int i = 0; i < n; i++)
    {
        m += min(b[i], b[i + 1]);
    }
    cout << m;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    string s;
    int q;
    cin >> s >> q;

    int rev=0;
    for(int i=0;i<q;i++){
        int t;
        cin >> t;
        if(t==1){
            if(rev){
                rev = 0;
            }else{
                rev = 1;
            }
        }
        if(t==2){
            int f;
            char c;
            cin >> f >> c;
            if(f==1){
                if(rev){
                    s += c;
                }else{
                    s = c+s;
                }
                
            }
            if(f==2){
                if(rev){
                    s = c+s;
                }else{
                    s += c;
                }
            }
        }
    }
    if(rev) reverse(s.begin(),s.end());
    cout << s << endl;
}

Measured memory_bytes: 4748
s=input()
n=len(s)

result=0

for i in range(2**(n-1)):
    ##print("####",bin(i))
    ll=0
    for j in range(n-1):
        if ((i>>j) & 1):
            #print(bin(i),j)
            result+=int(s[ll:j+1])
            ll=j+1
    result+=int(s[ll:])
print(result)







Measured memory_bytes: 39408
import java.util.*;

class Main{
	public static void main(String[] args){
		
		Scanner sc =new Scanner(System.in);
		String str = sc.nextLine();
		int q = Integer.parseInt(sc.nextLine());
		for(int i=0;i<q;i++){
			String[] line=sc.nextLine().split(" ");
			int a=Integer.parseInt(line[1]);
			int b=Integer.parseInt(line[2]);
		//index	
			int index=0;
			if(line[0].equals("print")){
				index=1;
			}else if(line[0].equals("reverse")){
				index=2;
			}else if(line[0].equals("replace")){
				index=3;
			}
			switch(index){
				case 1:
					System.out.println(str.substring(a,b+1));
					break;
				case 2:
					StringBuffer sb = new StringBuffer();
					String[] strReverse = new String[b-a+1];
					for(int j=b;j>a-1;j--){
						sb.append(str.charAt(j));
					}
					String str1=str.substring(0,a);
					String str2=str.substring(b+1);
					str = str1+sb.toString()+str2;
					break;	
				case 3:
					String str3=str.substring(0,a);
					String str4=str.substring(b+1);
					str = str3+line[3]+str4;
					break;
			}
//			System.out.println(i+":"+index+"*: "+str);
		}
	}
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][102];

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

ll h,w;
  cin>>h>>w;
  vpl ans;
  REP(i,h){
    REP(j,w){
      string s;
      cin>>s;
      if(s=="snuke")
        ans.push_back(pll(i,j));
    }
  }
  
  for(auto p:ans){
    char W='A'+p.SE;
    ll H = p.FI+1;
    cout<<W<<H<<endl;
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define N 100101
#define forn(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define F first
#define S second
int main()
{
         boost;
         int n,ans=0;
         cin>>n;
         
         int arr[n];
         forn(i,n)
         {
               cin>>arr[i];
               ans+=(arr[i]-1);
         }
         cout<<ans<<endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if a[0]!=0 or a.count(0)!=1:
  print(0)
else:
  a.sort()
  i=1
  j=1
  p=1
  q=0
  r=1
  while i<n:
    while a[i]==j:
      q+=1
      i+=1
      if i==n:
        break
    j+=1
    r*=p**q
    p=q
    q=0
  print(r%998244353)

Measured memory_bytes: 13892
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
aa = inpl()
g = 1
for a in aa:
    g = a*g//fractions.gcd(a,g)
g %= mod
res = 0
for a in aa:
    res += g*pow(a,mod-2,mod)
    res %= mod
print(res)


Measured memory_bytes: 6184
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector
typedef long long ll;
const int INF = 1001001001;
const double PI = 3.141592653589793238;


/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 


///////////////////////////////////////////////////////////////////////////


int main() {

   long double A, b;
     double B;
  cin >> A >> B;
  b = B * 1000;
  cout << (ll)(A * b / 1000) << endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k;
string s,s1,s2;

int main(){
  cin >> n >> s;
  int ans = 0;
  rep(i,n-2) if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  cout << ans << "\n";
}

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

llong N, W;
llong w[105], v[105];
llong dp[105][100005];

int main() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j >= w[i]) {
                dp[i][j] = max(dp[i - 1][j],
                               dp[i - 1][j - w[i]] + v[i]);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


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

int main(){
  int N,n,digit;
  digit = 0;
  cin >> N;
  n = N;
  while(N != 0){
    N = N / 10;
    ++digit;
  }
  if(digit == 1)
    cout << n;
  else if(digit == 2)
    cout << 9;
  else if(digit == 3){
    int k = 0;
    k = n -100 + 1;
    cout << 9 + k;
  }
  else if(digit == 4)
    cout << 909;
  else if(digit == 5){
    int l = 0;
    l = n - 9999;
    cout << 909 + l;
  }
  else if(digit == 6)
    cout << 90909;
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
gr = []
for i in range(H):
	w = input()
	if set(w) == {"."}:
		pass
	else:
		gr.append(w)

gr = [list(x) for x in zip(*gr)]
GR = []
for j in range(W):
	w = gr[j]
	if set(w) == {"."}:
		pass
	else:
		GR.append(w)
GR = [list(x) for x in zip(*GR)]
for i in range(len(GR)):
	print("".join(GR[i]))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int sx,sy,gx,gy;
signed main(){
    cin>>sx>>sy>>gx>>gy;
    int dy=gy-sy;
    int dx=gx-sx;
    for(int i=0;i<dy;i++)cout<<'U';
    for(int i=0;i<dx;i++)cout<<'R';
    for(int i=0;i<dy;i++)cout<<'D';
    for(int i=0;i<dx;i++)cout<<'L';
    cout<<'L';
    for(int i=0;i<dy+1;i++)cout<<'U';
    for(int i=0;i<dx+1;i++)cout<<'R';
    cout<<'D';
    cout<<'R';
    for(int i=0;i<dy+1;i++)cout<<'D';
    for(int i=0;i<dx+1;i++)cout<<'L';
    cout<<'U'<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;

int main(void)
{
	int count = 0;
	int k, s;

	cin >> k >> s;

	for (int a = 0; a <= k; a++)
	{
		for (int b = 0; b <= k; b++)
		{
			if (s - a - b < 0)
			{
				break;
			}
			else if (s - a - b <= k)
			{
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

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

def solve() :
    for i in range(A+B+1) :
        if 0 <= i < A or A + 1 <= i <= A + B :
            if not 48 <= ord(S[i]) <= 57 :
                return 'No'
        else :
            if S[i] != '-' :
                return 'No'
    return 'Yes'
print(solve())

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var l = Input().ToInt();
		Array.Sort(l);
		Array.Reverse(l);
		int wa = 0;
		for(int i = 1; i < n; i++)
			wa += l[i];
		if(wa>l[0])
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;
const long long INF = 1LL << 60;
ll N, M;
int main(){
   cin >> N;
   ll ans = (N / 11) * 2;
   ll a = N % 11;
   if(a > 6) ans += 2;
   else if(a > 0) ans += 1;
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  int od = a/2;
  int ev = a - a/2;
  cout << od*ev << endl;
}


Measured memory_bytes: 256
N , M = map(int , input().split())
switch = []
bit_switch = []
for _ in range(M):
    switch = list(map(int ,input().split()))
    del switch[0]
    k = 0
    for i in switch:
        k += 1 << (i - 1)
    bit_switch.append(k)
p = list(map(int,input().split()))
cnt = 0
dp = [[] for _ in range(M + 1)]
dp[0] = [i for i in range(2 ** N)]
#print(bit_switch)
#print(dp)
for i in range(M):
    for j in dp[i]:
        if str(bin(j & bit_switch[i])).count('1')% 2 == p[i]:
            dp[i + 1].append(j)
#print(dp)
print(len(dp[M]))

Measured memory_bytes: 3064
n = int(input())
hi = [int(i) for i in input().split()]
dp = [10000000000000]*(n)
dp[0] = 0

for i in range(1,n) :
  
  dp[i] = min(dp[i],dp[i-1] + abs(hi[i-1] - hi[i]))
  
  if 0 < i :
    dp[i] = min(dp[i],dp[i-2] + abs(hi[i-2] - hi[i]))


print(dp[-1])

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll r = 0;
	ll a, b; read(a, b);
	if (b - a <= 20) {
		for (ll i = a; i <= b; i++) r ^= i;
	} else {
		while (a % 4 != 0) { r ^= a; a++; }
		while (b % 4 != 3) { r ^= b; b--; }
	}
	die(r);
}


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

using ll = long long;

const ll MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int N; cin >> N;
	vector<pair<int, int>> coords;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		coords.emplace_back(a, 1);
	}
	for (int i = 0; i < N; i++) {
		int b; cin >> b;
		coords.emplace_back(b, -1);
	}
	sort(coords.begin(), coords.end());

	int cur = 0;
	ll ans = 1;
	for (auto it : coords) {
		int s = it.second;
		if (s * cur < 0) {
			ans *= abs(cur);
			ans %= MOD;
		}
		cur += s;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3444
#include<stdio.h>
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a > b)
		printf("a > b\n");
	if (a < b)
		printf("a < b\n");
	if (a == b)
		printf("a == b\n");
	return 0;
}

Measured memory_bytes: 1008
#include <iostream>

using namespace std;
char cell[51][51];

int main()
{
    int n, m, cnt;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
        cin >> cell[i][j];

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j){
        if (cell[i][j] == '.') {
            cnt = 0;
            if (cell[i - 1][j - 1] == '#')
                cnt++;
            if (cell[i][j - 1] == '#')
                cnt++;
            if (cell[i + 1][j - 1] == '#')
                cnt++;
            if (cell[i - 1][j] == '#')
                cnt++;
            if (cell[i + 1][j] == '#')
                cnt++;
            if (cell[i - 1][j + 1] == '#')
                cnt++;
            if (cell[i][j + 1] == '#')
                cnt++;
            if (cell[i + 1][j + 1] == '#')
                cnt++;
            cell[i][j] = 48 + cnt;
        }
        cout << cell[i][j];
        }
        cout << "\n";
    }

    return 0;
}


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

int main()
{
	int n, sum = 0;
	cin >> n;
	vector <int> a(n);
	vector <int> b(n);
	vector <int> c(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		cin >> c[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			sum += b[a[i]];
		}
		else if (a[i] - 1 != a[i - 1])
		{
			sum += b[a[i]];
		}
		else
		{
			sum += c[a[i - 1]];
			sum += b[a[i]];
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
s=input()
s1=s[:2]
s2=s[2:]

def is_month(s):
  return 0 < int(s) < 13

s1_is_month = is_month(s1)
s2_is_month = is_month(s2)

if s1_is_month or s2_is_month:
  if s1_is_month and not s2_is_month:
    print('MMYY')
  elif not s1_is_month and s2_is_month:
    print('YYMM')
  else:
    print('AMBIGUOUS')
elif not is_month(s1) and not is_month(s2):
  print('NA')


Measured memory_bytes: 3060
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int k, s, ans;

int main()
{
	cin >> k >> s;
	
	FOR (i, 0, k)
	FOR (j, 0, k)
	if (i+j<=s&&s-i-j<=k) ans++;
	
	printf("%d", ans);
}


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

struct potential_Unionfind{
    vector<int> rank;
    vector<int> par;
    vector<int> weights;
    potential_Unionfind(int n){
        rank.resize(n);
        par.resize(n);
        weights.resize(n);
        for(int i=0;i<n;i++) par[i] = i,rank[i] = 0,weights[i] = 0;
    }

    int find(int x){
        if(par[x] == x) return x;
        else{
            int p = find(par[x]);
            weights[x] += weights[par[x]];
            return par[x] = p;
        }
    }

    //weight[y] - weights[x] = wとなるようにuniteする。
    bool unite(int x,int y,int w){
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if(x == y) return false;//もうすでに繋がれている頂点ならfalseを返す
        if(rank[x] < rank[y]) {swap(x,y); w = -w;}
        if(rank[x] == rank[y]) rank[x] ++;
        par[y] = x;
        weights[y] = w;
        return true;
    }

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

    //weightsは各頂点から根までの距離
    int weight(int x){
        find(x);
        return weights[x];
    }

    int diff(int x,int y){
        return weight(y) - weight(x);
    }


};

int main(){
    int n,m;
    cin >> n >> m;
    potential_Unionfind uf(n);
    rep(i,m){
        int a,b,w;
        cin >> a >> b >> w;
        --a;--b;
        if(!uf.unite(a,b,w)){
            if(uf.diff(a,b) != w){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    return 0;

}

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

long long int dp[1005][1005];
char S[1005][1005];
const long long int mod=1e9+7;
int main(){
    int i,j;
    int H,W;
    cin >> H >> W;
    for(i=0;i<H;i++)for(j=0;j<W;j++)cin >> S[i][j];
    dp[0][0]=1;
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            dp[i][j]%=mod;
            if(S[i+1][j]=='.')dp[i+1][j]+=dp[i][j];
            if(S[i][j+1]=='.')dp[i][j+1]+=dp[i][j];            
        }
    }
    cout << dp[i-1][j-1] << endl;
}

Measured memory_bytes: 9088
n,m,q = gets.to_s.split.map{|t|t.to_i}

abcd = Array.new(q) do
  a, b, c, d = gets.to_s.split
  a, b, c, d = a.to_i-1, b.to_i-1, c.to_i, d.to_i
end

ans = 0
(1..m).to_a.repeated_combination(n) do |cmb|
  
  cnt = 0
  abcd.each do |a,b,c,d|
    
    if cmb[b] - cmb[a] == c
      cnt += d
    end
  end
  
  ans = cnt if ans < cnt
end

puts ans

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

int main(void){
    ll n;
    cin >> n;

    rep(i, 30){
        rep(j, 30){
            if(i * 4 + j * 7 == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
dd = ['dream', 'dreamer', 'erase', 'eraser']
chara = ''.join(reversed(list(S)))
flag = True
while flag:
    cnt = 0
    for i in dd:
        r = ''.join(reversed(list(i)))
        if r in chara[:len(r)]:
            chara = chara[len(r):]
            break
        cnt += 1
    if cnt == 4:
        flag = False

if chara == '':
    print('YES')
else:
    print('NO')

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

int main(){
  int N; cin >> N;
  int a[100000];
  for(int i=0; i<N; i++){
    cin >> a[i];
    a[i]--;
  }
  int result=-1;
  int current=0;
  for(int k=0; k<N; k++){
    current=a[current];
    if(current==1){
      result=k+1;
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int r,d,x;
  cin >> r >> d >> x;
  int cnt = 0;
  while (cnt < 10) {
    cnt++;
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main(){
	string s,t;
	cin >> s >> t;
	int n = s.size(), n1 = t.size();
	sort(s.begin(),s.end());
	sort(t.rbegin(), t.rend());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    A, B, C, D = map(int, input().split())
    ans = "Yes"
    while A > 0 or C > 0:
        C -= B
        if C <= 0:
            break
        A -= D
        if A <= 0:
            ans = "No"
            break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 61688
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int L= nextInt();
		int R= nextInt();
		int d= nextInt();
		int ans=0;
		for(;L<=R;L++) {
			if(L%d==0) {
				ans++;
			}
		}
		pw.println(ans);
	}
	public static void solveB(String[] args) throws Exception{

	}
	public static void solveC(String[] args) throws Exception{

	}

	public static void solveD(String[] args) throws Exception{

	}


	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25396
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
import math
a = []
for i in range(n):
    x,y = mi()
    x += 1e-15
    theta = math.degrees(math.atan2(y,x))
    a.append([theta,x,y])
a.sort()
a2 = list(a)
a = a + a2
import numpy as np
x = []
y = []
for i in range(len(a)):
    x.append(a[i][1])
    y.append(a[i][2])
x = np.array(x)
y = np.array(y)
xsum = np.cumsum(x)
ysum = np.cumsum(y)
ans = 0
for i in range(1,n+1):
    for k in range(i,n+i):
        xtmp = xsum[k] - xsum[i-1]
        ytmp = ysum[k] - ysum[i-1]
        tmp = (xtmp**2 + ytmp**2) ** 0.5
        ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 12568
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          String s = ReadLine();
          if(s[0] != s[1]){
              WriteLine("Yes");
              return;
          }else if(s[1] != s[2]){
              WriteLine("Yes");
              return;
          }else if(s[0] != s[2]){
              WriteLine("Yes");
              return;
          }
          WriteLine("No");
      }
   }
}

Measured memory_bytes: 11092