akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n, x;
  cin >> n >> x;

  vector<int> m(n);
  rep(i, n) cin >> m.at(i);

  int single_total = 0;
  rep(i, n) single_total += m.at(i);
  int remaining = x - single_total;

  int min_g = 1100;
  rep(i, n) min_g = min(min_g, m.at(i));

  int cnt = n;
  while (remaining >= min_g) {
    remaining -= min_g;
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main(){
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<vector<int> > data(26);
  for(int i = 0; i < n; i++) data[s[i] - 'a'].push_back(i);
  for(int i = 0; i < 26; i++) data[i].push_back(INF);
  for(int i = 0; i < m; i++){
    if(data[t[i] - 'a'].size() == 1){
      cout << -1 << endl;
      return 0;
    }
  }
  int id = -1, cnt = 0;
  for(int i = 0; i < m; i++){
    int num = t[i] - 'a';
    int next = *upper_bound(data[num].begin(), data[num].end(), id);
    if(next == INF){
      cnt++;
      id = data[num][0];
    }
    else{
      id = next;
    }
  }
  ll ans = ll(n) * ll(cnt) + ll(id + 1);
  printf("%lld\n", ans);
}


Measured memory_bytes: 4192
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			int k = sc.nextInt();
			
			int r = sc.nextInt();
			int s = sc.nextInt();
			int p = sc.nextInt();
			
			
			String t = sc.next();
			
			char[] hands = new char[n];
			
			char[] mhands = t.toCharArray();
			
			int score = 0;
			
			for(int i = 0 ; i < n ; i++ ) {
				
				if ( i < k) {
					score += calcScore(mhands[i], r, s, p);
				}
				else {
					if ( mhands[i] != mhands[i-k] ) {
						score += calcScore(mhands[i], r, s, p);
					}
					else {
						mhands[i] = 'x'; //blank?
					}
				}
				
			}
			
			System.out.println(score);
		}
	}
	
	public static int calcScore(char h, int r, int s, int p) {
		if ( h == 'r') {
			return p;
		}
		else if ( h == 's') {
			return r;
		}
		else if ( h == 'p') {
			return s;
		}
		return 0;
	}
}

Measured memory_bytes: 39724
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

struct data {
	int score, time, team;
	data(int score, int time, int  team) :score(score), time(time), team(team) {}
};

bool cmp(data d1, data d2){
	if(d1.score == d2.score){
		if(d1.time == d2.time) return d1.team > d2.team;
		return d1.time < d2.time;
	}
	return d1.score > d2.score;
}

signed main() {
	int M, T, P, R, m, t, p, r;
	while (1) {
		cin >> M >> T >> P >> R;
		if (M + T + P + R == 0)  break;
		int wa[51][11] = { 0 };
		vector<data> d;
		rep(i, 0, T) {
			d.push_back(data(0, 0, 0));
			d[i].team = i + 1;
		}
		rep(i, 0, R) {
			cin >> m >> t >> p >> r;
			t--; p--;
			if (r == 0) {
				d[t].score++;
				d[t].time += m + wa[t][p] * 20;
				//cout << "  " << t + 1 << " " << d[t].score << " " << d[t].time << endl;
			}
			else {
				wa[t][p]++;
			}
		}
		sort(all(d), cmp);
		rep(i, 0, T) {
			if (i == 0) {
				cout << d[i].team;
				continue;
			}
			if (d[i].score == d[i - 1].score && d[i].time == d[i - 1].time) {
				cout << "=";
			}
			else {
				cout << ",";
			}
			cout << d[i].team;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    vint A(M);
    rep(i, M) cin >> A[i];
    ll S = 0;
    rep(i, M) S += ll(A[i]);
    
    ll ans = ll(N - S);
    if (ans < 0) ans = -1;
    cout << ans << endl;
    return 0;
}

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

typedef struct Card
{
    char suit;
    int n;
} Card;

void copyCards(Card a, Card *b)
{
    b->n = a.n;
    b->suit = a.suit;
}

void swapCards(Card *a, Card *b)
{
    Card tmp;
    copyCards(*a, &tmp);
    copyCards(*b, a);
    copyCards(tmp, b);
}

int Partition(Card card[], int p, int r)
{
    int x = card[r].n;
    int i = p - 1;

    for (int j = p; j < r; j++)
    {
        if (card[j].n <= x)
        {
            i++;
            swapCards(&card[i], &card[j]);
        }
    }
    swapCards(&card[i + 1], &card[r]);
    return i + 1;
}

void quickSort(Card card[], int p, int r)
{
    if (p < r)
    {
        int q = Partition(card, p, r);
        quickSort(card, p, q - 1);
        quickSort(card, q + 1, r);
    }
}

void merge(Card card[], int n)
{
    Card l[n / 2 + 1];
    Card r[n - n / 2 + 1];

    for (int i = 0; i < n / 2; i++)
        copyCards(card[i], &l[i]);
    l[n / 2].suit = 'N';
    l[n / 2].n = 1145141919;
    for (int i = 0; i < n - n / 2; i++)
        copyCards(card[n / 2 + i], &r[i]);
    r[n - n / 2].suit = 'N';
    r[n - n / 2].n = 1145141919;

    int i = 0, j = 0;
    for (int k = 0; k < n; k++)
    {
        if (l[i].n <= r[j].n)
        {
            copyCards(l[i], &card[k]);
            i++;
        }
        else
        {
            copyCards(r[j], &card[k]);
            j++;
        }
    }
}

void mergeSort(Card card[], int n)
{
    if (n > 1)
    {
        mergeSort(card, n / 2);
        mergeSort(card + n / 2, n - n / 2);
        merge(card, n);
    }
}

int main()
{
    int n;
    cin >> n;
    Card card[n], mcard[n];
    for (int i = 0; i < n; i++)
        cin >> card[i].suit >> card[i].n;
    for (int i = 0; i < n; i++)
        copyCards(card[i], &mcard[i]);
    quickSort(card, 0, n - 1);
    mergeSort(mcard, n);
    bool f = true;
    for (int i = 0; i < n; i++)
    {
        if (card[i].suit != mcard[i].suit)
        {
            f = !f;
            break;
        }
    }
    if (f)
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
    for (int i = 0; i < n; i++)
        cout << card[i].suit << ' ' << card[i].n << endl;
}


Measured memory_bytes: 5328
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define MAXN  50005 
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(ll i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
	IOS;
	ll n,i,k,m,ans,ans1;
	cin>>k>>n;
	bool a[105]={false};
	rep(i,0,n)cin>>m,a[m]=true;
	rep(i,k,102)if(a[i]==false){ans=i;break;}
	inv(i,k-1,0)if(a[i]==false){ans1=i;break;}
	if(abs(ans1-k)<=abs(ans-k))cout<<ans1;
	else cout<<ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    string S;
    cin >> S;
    string T[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    REP(i,7){
        if(S==T[i]){
            cout << 7-i << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, OverloadedStrings #-}
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: B.ByteString -> B.ByteString -> B.ByteString
solve !s !t = walk
 where
  toIndex !i !j = j * succ (B.length s) + i
  sChars = V.unfoldrN (B.length s) (\(!k) -> Just (B.index s k, k + 1)) 0
  tChars =
    V.convert $ V.unfoldrN (B.length t) (\(!k) -> Just (B.index t k, k + 1)) 0

  dp :: V.Vector (VU.Vector Int16)
  dp = V.scanl'
    ( \(!prev) (!si) -> VU.scanl'
      ( \(!cur) (!j, !tj) ->
        if si == tj then prev VU.! j + 1 else max cur (prev VU.! (j + 1))
      )
      0
      (VU.indexed tChars)
    )
    (VU.replicate (B.length t + 1) 0)
    sChars

  walk =
    fst
      $ B.unfoldrN (fromIntegral $ dp V.! B.length s VU.! B.length t)
                   (\(x:xs) -> Just $ (,) (B.index s x) xs)
      $ fst
      $ fix
          ( \(!f) (!acc, (!i, !j)) -> if i == 0 || j == 0
            then (acc, (i, j))
            else if s `B.index` (i - 1) == t `B.index` (j - 1)
              then f ((i - 1) : acc, (i - 1, j - 1))
              else if dp V.! (i - 1) VU.! j < dp V.! i VU.! (j - 1)
                then f (acc, (i, j - 1))
                else f (acc, (i - 1, j))
          )
          ([], (B.length s, B.length t))

main = do
  s <- B.getLine
  t <- B.getLine
  B.putStrLn $ solve s t


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

int k,genap,ganjil;

int main(){
	cin>>k;
	for(int i=0;i<k;i++){
		if(i%2==0){
			genap++;
		}
		if(i%2==1){
			ganjil++;
		}
	}
	cout<<genap*ganjil<<endl;
}

			


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        vector<string> a(n);
        for(int i=0;i<n;i++)cin>>a[i];
        sort(all(a));
        int ans = 1;
        for(int i=1;i<n;i++)if(a[i]!=a[i-1])ans++;
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  char s[100];
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  for(int i = 0;i < n;i++){
    cin >> s[i];
    if(s[i] == 'P') p = 1;
    if(s[i] == 'W') w = 1;
    if(s[i] == 'G') g = 1;
    if(s[i] == 'Y') y = 1;
  }
  if(p == 1 && w == 1 && g == 1 && y == 1) cout << "Four" << endl;
  else if(p == 1 && w == 1 && g == 1) cout << "Three" << endl;

  return 0;

}


Measured memory_bytes: 256
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


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


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

// Main program
void solve(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2==1){
        cout << "IMPOSSIBLE"<< endl;
    }
    else{
        cout << (a+b)/2 << endl;
    }

}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize m:i64 q:usize){q;list:(usize,usize,i64,i64)});
    f(Vec::new(), 1, n, m, &list).to_string()
}

fn f(a_list: Vec<i64>, min: i64, n: usize, m: i64, list: &Vec<(usize, usize, i64, i64)>) -> i64 {
    if a_list.len() == n {
        list.iter()
            .filter(|(a, b, c, _)| a_list[b - 1] - a_list[a - 1] == *c)
            .map(|(_, _, _, d)| d)
            .sum::<i64>()
    } else {
        (min..=m)
            .map(|min| {
                let mut a_list = a_list.clone();
                a_list.push(min);
                f(a_list, min, n, m, list)
            })
            .max()
            .unwrap()
    }
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
    test1: "3 4 3\n1 3 3 100\n1 2 2 10\n2 3 2 10\n" => "110\n",
    test2: "4 6 10\n2 4 1 86568\n1 4 0 90629\n2 3 0 90310\n3 4 1 29211\n3 4 3 78537\n3 4 2 8580\n1 2 1 96263\n1 4 2 2156\n1 2 0 94325\n1 4 3 94328\n" => "357500\n",
    test3: "10 10 1\n1 10 9 1\n" => "1\n",
}


Measured memory_bytes: 2188
n=int(input())
c=input()
if 'W' not in c or 'R' not in c:
  print(0)
  exit()
rr=[0]*(n+1)
lw=[0]*(n+1)
tmp=0
for i in range(n):
  x=c[i]
  if x=='W':
    tmp+=1
  lw[i+1]=tmp
tmp=0
for i in range(n-1,-1,-1):
  x=c[i]
  if x=='R':
    tmp+=1
  rr[i]=tmp
ans=n
for i in range(n+1):
  lwi=lw[i]
  rri=rr[i]
  tmp=lwi+rri-min(rri,lwi)
  ans=min(tmp,ans)
print(ans)
#print(lw)
#print(rr)

Measured memory_bytes: 71372
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,k;
    cin>>n>>k;
    if((2*k)>(n+1))
    {
        cout<<-1;
        return;
    }
    set <ll> one;
    vl two,three;
    for(int i=0;i<n;i++)
    {
        one.insert(i);
        two.pb(i+n);
        three.pb(i+2*n-k);
    }
    vector <tuple<ll,ll,ll>> ans;
    int indx=0;
    for(int i=0;i<n;i+=2)
    {
        ll y=two[i];
        ll diff=three[indx]-y;
        auto it=one.upper_bound(diff);
        it--;
        ll x=(*it);
        one.erase(it);
        ans.pb(make_tuple(x+k,y+k,three[indx]+2*k));
        indx++;
    }
    for(int i=1;i<n;i+=2)
    {
        ll y=two[i];
        ll diff=three[indx]-y;
        auto it=one.upper_bound(diff);
        it--;
        ll x=(*it);
        one.erase(it);
        ans.pb(make_tuple(x+k,y+k,three[indx]+2*k));
        indx++;
    }
    for(auto t:ans)
    {
        cout<<get<0>(t)<<' '<<get<1>(t)<<' '<<get<2>(t)<<'\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 24868
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if ((i+1) % 2 == 0) {
            if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
                cout << "No\n";
                return 0;
            }
        } else {
            if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) cout << 1 << endl;
  else if (a == b || b == c || a == c) cout << 2 << endl;
  else cout << 3 << endl;
}

Measured memory_bytes: 256
N,a,b = map(int,input().split())
MOD = 10**9 + 7
def comb(n,k, mod):
    m = 1#分子
    l = 1#bunnbo
    for i in range(k):
        m *= n - i
        l *= (i + 1)
        m %= mod
        l %= mod
    return m * pow(l, mod-2, mod) % mod

Sum = pow(2, N, 10**9+7) -1 - comb(N, a, MOD) - comb(N, b, MOD)
Sum = Sum % (10**9+7)
print(Sum)

Measured memory_bytes: 38512
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;
   vector<int> b(n + 1);
   vector<int> w(n + 1);
   for(int i = 1;i <= n;i++){
         if(s[i - 1] == '#')b[i]++;
         else w[i]++;
         b[i] += b[i - 1];
         w[i] += w[i - 1];
   }
   int ans = n;
   for(int i = 0;i <= n;i++){
         ans = min(ans,b[i] + w[n] - w[i]);
   }
   cout << ans << endl;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e9

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,R; cin>>n>>m>>R;
    vi r(R);
    rep(i,R){
        cin>>r[i];
        r[i]--;
    }
    sort(all(r));
    vector<vi> adj(n,vi(n,INF));
    rep(i,n) adj[i][i] = 0;
    rep(i,m){
        int a,b,c; cin>>a>>b>>c; a--; b--;
        adj[a][b] = c;
        adj[b][a] = c;
    }
    rep(k,n)rep(i,n)rep(j,n)
        adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
    ll ans = INF;
    do{
        ll sum=0;
        rep(i,R-1){
            sum+=adj[r[i]][r[i+1]];
        }
        chmin(ans,sum);
    }while(next_permutation(all(r)));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[20005],b[20005],per[20005];
int main()
{
	int n,k=20005;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&per[i]);
	}
	for(int i=1;i<=n;i++)
	{
		a[i]=k;
		b[n-i+1]=k;
		k+=20005;
	}
	for(int i=1;i<=n;i++)
	{
		a[per[i]]-=20004-i+1;
		b[per[i]]-=20004-i+1;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d ",a[i]);
	}
	printf("\n");
	for(int i=1;i<=n;i++)
	{
		printf("%d ",b[i]);
	}
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

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

    cout << std::min(N * A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int main() {
    int D, G; cin >> D >> G;
    vector<Pii> pc(D);
    for (int i = 0; i < D; i++) {
        cin >> pc[i].first;
        cin >> pc[i].second;
    }
    map<int, int> ans;
    ans[0] = 0;
    for (int i = 1; i <= D; i++) {
        map<int, int> temp; temp[0] = 0;
        for (int j = 1; j < pc[i-1].first; j++) temp[j] = i * j * 100;
        temp[pc[i-1].first] = pc[i-1].first * i * 100 + pc[i-1].second;


        map<int, int> tans;
        for (auto x : ans) for (auto y : temp) tans[x.first + y.first] = max(tans[x.first + y.first], x.second + y.second);

        ans = tans;
    }

    int a = 1e8;
    for (auto x : ans) {
        if (x.second >= G) a = min(a, x.first);
    }
    cout << a << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,H,W,i,g[N];
bool b[N];
long long ans;
int gfa(int x){
	return g[x]==x?x:g[x]=gfa(g[x]);
}
struct edge{
	int r,c,a;
	inline void in(){
		scanf("%d%d%d",&r,&c,&a);
	}
	inline bool operator<(const edge&rhs)const{return a>rhs.a;}
	inline void tryuni(){
		r=gfa(r);c=gfa(H+c);
		if(r!=c){
			if(!b[r] || !b[c])ans+=a,g[r]=c,b[c]|=b[r];
		}else if(!b[r])
		//	printf("%d\n",a),
			ans+=a,b[r]=1;
	}
}e[N];
int main(){
	scanf("%d%d%d",&n,&H,&W);
	for(i=1;i<=H+W;++i)g[i]=i;
	for(i=1;i<=n;++i)e[i].in();
	sort(e+1,e+n+1);
	for(i=1;i<=n;++i)e[i].tryuni();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        System.out.println((sc.nextInt() + sc.nextInt()) % 24);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25412
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int a,b;
     cin>>a>>b;
     cout<<a*b/__gcd(a,b)<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
        "strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()

        n := parseInt(line)

        s := ""
        switch n {
        case 25:
                s = "Christmas"
        case 24:
                s = "Christmas Eve"
        case 23:
                s = "Christmas Eve Eve"
        case 22:
                s = "Christmas Eve Eve Eve"
        }
        fmt.Println(s)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long hey;
#define hi string
#define pi 3.141592653589793238
#define fi first
#define mod 1000000007
#define se second
#define pb push_back 
#define pop pop_back 
#define bs binary_search
#define mp make_pair
#define ma map< hey,hey >
#define vi vector < char > 
#define all(v) v.begin(),v.end()
#define qu priority_queue< hey >
#define endl '\n'
#define forn(i, n) for (hey i = 0; i <hey(n); ++i)
#define yorn(i, n) for (hey i = 1; i <hey(n); ++i)
#define vp vector< pair<hey,hey> >
// lower bound - first element equal to or greater than given value.
// upper bound - first element greater than given value.
void frog(hi s,hi t)
{
    hey n=s.size(),m=t.size();
    hey dp[n+1][m+1];
    
    forn(i,n+1)
    forn(j,m+1)
    dp[i][j]=0;
    
    yorn(i,n+1)
    yorn(j,m+1)
    {
        if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
        else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
    hi l;
    while(n>0&&m>0)
    {
	    if(s[n-1]==t[m-1])
	    l+=s[n-1],n--,m--;
	    else if(dp[n][m]==dp[n-1][m])
	    n--;
	    else
    	m--;
    }
    reverse(all(l));
    cout<<l;

}
void hellogadhi()
{
    hi s,t;
    cin>>s>>t;
    
    frog(s,t);
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	    hellogadhi();
	}
	return 0;
}


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

string s[1001];
int r[100000][4];
struct a{
	short jungle;
	short ocean;
	short ice;
	a(){
		jungle=ocean=ice=0;
	}
};
a data[1001][1001];

int main(){
	int m,n,k;
	cin >> m >> n >> k;
	for(int i=1; i<=m; ++i){
		cin >> s[i];
	}
	for(int i=1; i<=m; ++i){
		switch(s[i][0]){
			case 'J':
			++data[i][1].jungle;
			break;
			
			case 'O':
			++data[i][1].ocean;
			break;
			
			case 'I':
			++data[i][1].ice;
			break;
			
			default:
			break;
		}
		for(int j=2; j<=n; ++j){
			data[i][j]=data[i][j-1];
			switch(s[i][j-1]){
				case 'J':
				data[i][j].jungle=data[i][j-1].jungle+1;
				break;
			
				case 'O':
				data[i][j].ocean=data[i][j-1].ocean+1;
				break;
				
				case 'I':
				data[i][j].ice=data[i][j-1].ice+1;
				break;
			
				default:
				break;
			}
		}
	}
	/*
	for(int i=1; i<=m; ++i){
		for(int j=1; j<=n; ++j){
			cout << data[i][j].jungle << " " << data[i][j].ocean << " " << data[i][j].ice << "\n";
		}
	}
	*/
	for(int i=0; i<k; ++i){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		int J,O,I;
		J=O=I=0;
		for(int j=a; j<=c; ++j){
			if(b>1){
				J+=data[j][n].jungle-(data[j][b-1].jungle+data[j][n].jungle-data[j][d].jungle);
				O+=data[j][n].ocean-(data[j][b-1].ocean+data[j][n].ocean-data[j][d].ocean);
				I+=data[j][n].ice-(data[j][b-1].ice+data[j][n].ice-data[j][d].ice);
			} else {
				J+=data[j][d].jungle;
				O+=data[j][d].ocean;
				I+=data[j][d].ice;
			}
		}
		cout << J << " " << O<< " " << I << "\n";
	}
	return 0;
}

Measured memory_bytes: 8380
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define x first
#define y second
#define pii pair<int ,int>
const int N=1005;
queue<pii> Q;
int n,m,ans,flag[N][N],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
char s[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%s",s[i]+1);
	memset(flag,-1,sizeof flag);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (s[i][j]=='#')Q.push(mp(i,j)),flag[i][j]=0;
	while (!Q.empty()){
		pii now=Q.front();Q.pop();
		for (int i=0;i<4;i++){
			pair<int ,int > New=mp(now.x+dx[i],now.y+dy[i]);
			if (New.x>0&&New.y>0&&New.x<=n&&New.y<=m&&flag[New.x][New.y]==-1){
				Q.push(New);
				flag[New.x][New.y]=flag[now.x][now.y]+1;
				ans=max(ans,flag[New.x][New.y]);
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 13328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/












int H, W, h, w;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W >> h >> w;

    int ans = (H - h) * (W - w);
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
ll L;
string S[2];
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>L;
	REP(i,2)cin>>S[i];
	ll cnt[2],len[2];
	REP(i,2)len[i]=S[i].size(),cnt[i]=0;
	ll l=lcm(len[0],len[1]);
	ll ooi=0;
	if(l<=L){
		string t[2];
		REP(i,2){
			t[i]="";
			REP(j,l/len[i]){
				t[i]+=S[i];
			}
		}
		if(t[0]>t[1]){
			ooi=1;
		}
	}
	ll suk=1-ooi;
	REP(i,L+1){
		if(L-i*len[ooi]>=0 && (L-i*len[ooi])%len[suk]==0){
			cnt[ooi]=i;
			cnt[suk]=(L-i*len[ooi])/len[suk];
		}
	}
	ll saki=0;
	if(S[0]+S[1]>S[1]+S[0]){
		saki=1;
	}
	REP(i,cnt[saki]){
		cout<<S[saki];
	}
	REP(i,cnt[1-saki]){
		cout<<S[1-saki];
	}
	cout<<endl;
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");               
    else if(b>=0)puts("Zero");            
    else if((a&1)^(b&1))puts("Positive");  
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 10000;

int main(void){
    vs t(N + 1);

    COUNT(i, N){
        stringstream ss;

        if(!(i % 5) || !(i % 3)){
            if(!(i % 3)) ss << "Fizz";
            if(!(i % 5)) ss << "Buzz";
        }
        else ss << i;

        t[i] = ss.str();
    }

    for(int m, n; cin >> m >> n, m; cout << endl){
        queue<int> rest;
        COUNT(i, m) rest.push(i);
        COUNT(i, n){
            int cur = rest.front(); rest.pop();
            string s; cin >> s;
            if(t[i] == s || rest.empty()) rest.push(cur);
        }

        vi res;
        while(!rest.empty()) res.pb(rest.front()), rest.pop();
        sort(ALL(res));
        rep(i, res.size()) cout << (i ? " ":"") << res[i];
    }
 
    return 0;
}

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

int A, B, C, D, N;

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

  cin >> A >> B >> C >> D;
  for (int i = 0; i < 100 + 1; i++) {
    if (A < i && i <= B && C < i && i <= D) {
      N++;
    }
  }
  cout << N << endl;
}

Measured memory_bytes: 256
#line 2 "../../library/template.cpp"

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

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

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

constexpr char el = '\n';
#line 2 "a.cpp"

ll h, w;
string s[100];
ll dp[100][100];

ll dfs(ll i, ll j) {
  if (i == h-1 and j == w-1) return 0;

  if (dp[i][j] != -1) return dp[i][j];

  ll n = 1LL<<60, m = 1LL<<60;
  if (i+1 < h) n = dfs(i+1, j);
  if (j+1 < w) m = dfs(i, j+1);

  if (i+1 < h and s[i+1][j] == '#' and s[i][j] == '.') {
    n++;
  }
  if (j+1 < w and s[i][j+1] == '#' and s[i][j] == '.') {
    m++;
  }

  return dp[i][j] = min(n, m) + (i == 0 and j == 0 and s[i][j] == '#' ? 1 : 0);
}

int main() {
  cin >> h >> w;
  rep(i, h) {
    cin >> s[i];
  }

  rep(i, h) {
    rep(j, w) {
      dp[i][j] = -1;
    }
  }

  cout << dfs(0, 0) << endl;
}


Measured memory_bytes: 384
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef unsigned long long/*-----------*/ulli;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define lb/*---------------------------*/lower_bound
#define ub/*---------------------------*/upper_bound
#define pb/*---------------------------*/push_back
#define popb/*-------------------------*/pop_back

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz/*---------------------------*/size()

#define MP/*---------------------------*/make_pair
#define bs/*---------------------------*/binary_search
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()

#define ff/*---------------------------*/first
#define ss/*---------------------------*/second

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	int a,b,c;
	scanf("%1d%1d%1d",&a,&b,&c);
	int ans = 0;
	if(a)
        ans++;
    if(b)
        ans++;
    if(c)
        ans++;
    print(ans);
	return 0;
}










Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B, C, D, E, F, r1, r2 int
	var m, w float64
	fmt.Scan(&A, &B, &C, &D, &E, &F)
	for i := 0; i <= 30; i++ {
		for j := 0; j <= 30; j++ {
			if i == 0 && j == 0 {
				continue
			}
			for k := 0; k < 10000; k++ {
				for l := 0; l < 10000; l++ {
					water := i*A*100 + j*B*100
					sugar := k*C + l*D
					if water+sugar > F || water < sugar {
						break
					}
					if sugar > E*(i*A+j*B) {
						break
					}
					w = float64(100*sugar) / float64(water+sugar)
					if m < w {
						m = w
						r1 = water + sugar
						r2 = sugar
					} else if m == w {
						r1 = water + sugar
						r2 = sugar
					}
				}
			}
		}
	}
	fmt.Printf("%d %d\n", r1, r2)
}

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

int main() {
  int N;
  double ans = 0.0, A;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    ans += 1.0/A;
  }
  
  ans = 1.0/ans;
  
  cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>


using namespace std;

double length(vector<int> &a, vector<int> &b, int size) {
  double sum = 0;
  for (int i = 0; i < size; i++) {
    sum += (a[i]-b[i])*(a[i]-b[i]);
  }
  return sqrt(sum);
}

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> a;
  for (int i = 0; i < n; i++) {
    vector<int> b;
    for (int j = 0; j < d; j++) {
      int x;
      cin >> x;
      b.push_back(x);
    }
    a.push_back(b);
  }
  int count = 0;
  for (int i = 0; i < n-1; ++i) {
    for (int j = i+1; j < n; ++j) {
      double len = length(a[i], a[j], d);
      if (abs(len - floor(len)) < numeric_limits<double>::epsilon())
        count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long LL;
const int p = 1000000007;
const int N = 410;

int n, c, a[N], b[N];
LL wee[N][N], f[N][N];

int main()
{
  cin>>n>>c;
  for(int i = 1; i <= n; ++i) cin>>a[i];
  for(int i = 1; i <= n; ++i) cin>>b[i];
  for(int i = 1; i < N; ++i) wee[i][0] = 1;
  for(int i = 1; i < N; ++i) for(int j = 1; j < N; ++j) wee[i][j]=1ll*wee[i][j-1]*i%p;
  for(int i = 1; i < N; ++i) for(int j = 0; j < N; ++j) wee[i][j]=(wee[i][j]+wee[i-1][j])% p;
  f[0][0] = 1;
  for(int i = 1; i <= n; ++i) for(int j = 0; j <= c; ++j) for(int k = 0; k <= j; ++k) f[i][j]=(f[i][j]+f[i - 1][j - k]*(wee[b[i]][k]-wee[a[i]-1][k]+p)%p)%p;
  printf("%lld\n", f[n][c]);
}

Measured memory_bytes: 2816
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()

	spl := strSprit(line)

	K := parseInt(spl[0])
	A := parseInt(spl[1])
	B := parseInt(spl[2])

	if A >= B || (B-A) == 1 {
		fmt.Println(K + 1)
		return
	}

	r := K + 1 - A

	ret := (B-A)*(r/2) + A

	if r%2 == 1 {
		ret++
	}
	fmt.Println(ret)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> X >> Y;
  if(X==1&&Y==1)sum+=400000;
  if(X==1)sum+=300000;
  else if(X==2)sum+=200000;
  else if(X==3)sum+=100000;
  if(Y==1)sum+=300000;
  else if(Y==2)sum+=200000;
  else if(Y==3)sum+=100000;
  Out(sum);
}

Measured memory_bytes: 256