akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
  bool same(int x, int y) { // 同じ集合ならtrue
    return root(x) == root(y);
  }
  int num() { // 異なる集合の数
    int res = 0;
    REP(i, data.size()) res += root(i) == i;
    return res;
  }
};

struct Edge {
  int a, b;
  ll c;
};

ll a[333][333];
ll g[333][333];
ll s[333][333];

int main2() {
  int N = nextInt();
  REP(i, N) REP(j, N) a[i][j] = nextInt();
  REP(i, N) REP(j, N) g[i][j] = a[i][j];

  REP(k, N) REP(i, N) REP(j, N) {
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  }

  bool same = true;
  REP(i, N) REP(j, N) {
    if (a[i][j] != g[i][j]) same = false;
  }
  if (!same) {
    cout << -1 << endl;
    return 0;
  }

  const ll INF = 1LL << 58;
  REP(i, N) REP(j, N) s[i][j] = INF;
  REP(i, N) s[i][i] = 0;

  UnionFind uf(N);
  vector<Edge> es;
  REP(i, N) REP(j, i) {
    es.emplace_back( (Edge){i, j, g[i][j]} );
  }
  sort(ALL(es),  [](const Edge& a, const Edge& b) -> bool {
    return a.c < b.c;
  });
  
  ll ans = 0;
  for (const Edge& e : es) {
    if (!uf.same(e.a, e.b) || s[e.a][e.b] > e.c) {
      uf.link(e.a, e.b);
      s[e.a][e.b] = s[e.b][e.a] = e.c;
      ans += e.c;
      REP(i, N) REP(j, N) {
        s[i][j] = min(s[i][j], s[i][e.a] + s[e.a][e.b] + s[e.b][j]);
        s[i][j] = min(s[i][j], s[i][e.b] + s[e.b][e.a] + s[e.a][j]);
      }
    }
  }

  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



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

int main() {
    long x;
    cin >> x;
    long k = 100;
    long cnt = 0;
    while(k < x) {
        k += k * 0.01;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main()
{
	map< string, vector<int> > m;
	string word;
	int page;

	while (cin >> word >> page){
		if (m.count(word)) m[word].push_back(page);
		else {
			vector<int> v;

			v.push_back(page);
			m.insert(make_pair(word, v));
		}
	}

	for (map< string, std::vector<int> >::iterator it = m.begin(); it != m.end(); it++){
		cout << it->first << endl;
		sort(it->second.begin(), it->second.end());
		for (int i = 0; i < it->second.size(); i++){
			printf("%d%c", it->second[i], i == it->second.size() - 1 ? '\n' : ' ');
		}
	}
}

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

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




int main() {
	int N;
	cin >> N;
	vector<int> H;
	rep(i, N) {
		int h;
		cin >> h;
		H.emplace_back(h);
	}
	int counter = 0;
	int ans = 0;
	int h_now = H[0];
	for (int i = 1; i < N;++i) {
		if (H[i]<=h_now) {
			counter++;
			ans = max(counter,ans);
		}
		else {
			counter = 0;
		}
		h_now = H[i];
	}
	cout << ans << endl;

		return 0;
}

Measured memory_bytes: 892
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
      	if ((a == b ) && b != c)
          System.out.println("Yes");
        else if (a == c && b != c)
					System.out.println("Yes");
      	else if (b == c && a != c)
          System.out.println("Yes");
        else
					System.out.println("No");
    }
}



Measured memory_bytes: 21972
n=int(input())
ans=[0]*(6*(10**4)+1)
for i in range(1, 101):
  for j in range(1, 101):
    for k in range(1, 101):
      ans[i**2+j**2+k**2+i*j+j*k+k*i]+=1

for i in range(1, n+1):
  print(ans[i])

Measured memory_bytes: 9452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		if (A <= B*2){
			System.out.println(0);
		} else {
			System.out.println(A-B*2);
		}
	}

}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;


int main() {
	ll n, m;
	scanf("%lld %lld", &n, &m);
	
	ll x = (ll)n * m;
	if (n > m) swap(n, m);
	if (n == 1) {
		if (m == 1) return !printf("1");
		else return !printf("%lld", x - 2);
	}
	if (n == 2) return !printf("0");
	else {
		return !printf("%lld", x - ((n + m) * 2 - 4));
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
using namespace std;
#pragma warning(disable:4996)
int H, W, Q, a[60000], b[60000], c[60000], d[60000], e, f, g;
int main() {
	while (true) {
		cin >> H >> W >> Q; if (H == 0)break;
		for (int i = 0; i < H; i++) { a[i] = -1; c[i] = 0; }
		for (int i = 0; i < W; i++) { b[i] = -1; d[i] = 0; }
		for (int i = 0; i < Q; i++) {
			scanf("%d%d%d", &e, &f, &g);
			if (e == 0) { a[f] = i; c[f] = g; }
			if (e == 1) { b[f] = i; d[f] = g; }
		}
		long long R1 = 0, R2 = 0, M = 0, cnt = 0;
		vector<tuple<int, int, int>>tup;
		for (int i = 0; i < H; i++)tup.push_back(make_tuple(a[i], 0, c[i]));
		for (int i = 0; i < W; i++)tup.push_back(make_tuple(b[i], 1, d[i]));
		sort(tup.begin(), tup.end());
		for (int i = 0; i < tup.size(); i++) {
			int a1 = get<0>(tup[i]), a2 = get<1>(tup[i]), a3 = get<2>(tup[i]);
			if (a2 == 0)R1++; if (a2 == 1)R2++;
			if (a3 == 1)cnt += R1*R2 - M; M = R1*R2;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 6324
#include<iostream>

int main() {
    char S[4];
    int i,num = 0;
    std::cin >> S;

    for (i = 0; i < 4; i++) {
      if (S[i] == '+') {
        num = num + 1;
      }
      else
        num = num - 1;
    }
      std::cout << num;

  return 0;
}


Measured memory_bytes: 256
def print_list(A):
    for x in range(len(A) - 1):
        print(A[x],end = " ")
    print(A[len(A) - 1])

def insertionsort(A,n):
    count = 0
    for i in range(1,n):
        print_list(A)
        right = i
        left = i - 1
        while A[left] > A[right] and left >= 0:
            A[left],A[right] = A[right],A[left]
            right = left
            left -= 1
            count += 1
    print_list(A)
    return A

if __name__ == '__main__':
    n = int(input())
    A = [int(i) for i in input().split()]
    A = insertionsort(A,n)



Measured memory_bytes: 5980
try:
    while True:
        n=int(input())
        cnt=0
        for a,b,c,d in [(a,b,c,d) for a in range(10) for b in range(10) for c in range(10) for d in range(10)]:
            if a+b+c+d==n:
                cnt+=1
        print(cnt)
except EOFError:
    pass



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

int main() {
  int N, K;
  int Z = 1;// N;試行回数, K;任意の数 Z;電光掲示板上の数字
  cin >> N >> K;
  int A;//A思考：Addition (N - A)B試行：Mulitiplication
  for (int i = 0; i < N ; i ++){
    if ( K < Z ){
      Z += K;
    }
    else if (K >= Z ){
      Z *= 2;
    }
  }
  cout << Z << endl;
}


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

int main(){
  int n;
  cin>>n;
  int b[n];
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int j=0;j<(n-2);j++){
    if(b[j]<b[j+1]){ans=ans+b[j];}
    else{ans=ans+b[j+1];}
  }
  ans=ans+b[0]+b[(n-2)];
  cout<<ans<<endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b == 3) cout << 3 << endl;
    else if(a+b == 4) cout << 2 << endl;
    else if(a+b == 5) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3556
from heapq import heapify, heappop, heappush


if __name__ == "__main__":
    heap_num, query_num = map(lambda x: int(x), input().split())
    heaps = [[] for _ in range(heap_num)]  # type: ignore
    for heap in heaps:
        heapify(heap)

    for _ in range(query_num):
        op, *value = map(lambda x: int(x), input().split())
        heap = heaps[value[0]]
        if (0 == op):
            heappush(heap, -value[1])
        elif (1 == op):
            if (0 != len(heap)):
                print(-heap[0])
        elif (2 == op):
            if (0 != len(heap)):
                heappop(heap)
        else:
            pass



Measured memory_bytes: 13372
import base64

exec(base64.b64decode(b'aW1wb3J0IHN1YnByb2Nlc3MKaW1wb3J0IHN5cwoKY29kZSA9IHIiIiIjaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Yml0c2V0PgojaW5jbHVkZSA8Y2Fzc2VydD4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGNocm9ubz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y29tcGxleD4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxkZXF1ZT4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPG51bWVyaWM+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHJhbmRvbT4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDx1dGlsaXR5PgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnVzaW5nIGludDY0ID0gbG9uZyBsb25nOwoKI2RlZmluZSBhbGwoXykgYmVnaW4oXyksIGVuZChfKQojZGVmaW5lIHJhbGwoXykgcmJlZ2luKF8pLCByZW5kKF8pCgppbnQ2NCBkcFszMDAwXVszMDAwXVs0XTsKCmludCBtYWluKCkgewogIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogIGNpbi50aWUobnVsbHB0cik7CgogIGludCByLCBjLCBrOyBjaW4gPj4gciA+PiBjID4+IGs7CiAgaW50IHZhbFtyXVtjXTsKICBmaWxsKHZhbFswXSwgdmFsW3JdLCAwKTsKICBmb3IgKGludCBpID0gMDsgaSA8IGs7ICsraSkgewogICAgaW50IHgsIHksIHo7IGNpbiA+PiB4ID4+IHkgPj4gejsKICAgIC0teDsgLS15OwogICAgdmFsW3hdW3ldID0gejsKICB9CgogIGlmICh2YWxbMF1bMF0gIT0gMCkgZHBbMF1bMF1bMV0gPSB2YWxbMF1bMF07CgogIGZvciAoaW50IGkgPSAwOyBpIDwgcjsgKytpKSB7CiAgICBmb3IgKGludCBqID0gMDsgaiA8IGM7ICsraikgewogICAgICBpZiAoaSA9PSAwICYmIGogPT0gMCkgY29udGludWU7CgogICAgICBpZiAodmFsW2ldW2pdICE9IDApIHsKICAgICAgICBpZiAoaSA+IDApIHsKICAgICAgICAgIGZvciAoaW50IGwgPSAwOyBsIDwgNDsgKytsKSBkcFtpXVtqXVswXSA9IG1heChkcFtpXVtqXVswXSwgZHBbaSAtIDFdW2pdW2xdKTsKICAgICAgICAgIGZvciAoaW50IGwgPSAwOyBsIDwgNDsgKytsKSBkcFtpXVtqXVsxXSA9IG1heChkcFtpXVtqXVsxXSwgZHBbaSAtIDFdW2pdW2xdICsgdmFsW2ldW2pdKTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPiAwKSB7CiAgICAgICAgICBkcFtpXVtqXVswXSA9IG1heChkcFtpXVtqXVswXSwgZHBbaV1baiAtIDFdWzBdKTsKICAgICAgICAgIGZvciAoaW50IGwgPSAxOyBsIDwgNDsgKytsKSB7CiAgICAgICAgICAgIGRwW2ldW2pdW2xdID0gbWF4KHtkcFtpXVtqXVtsXSwgZHBbaV1baiAtIDFdW2xdLCBkcFtpXVtqIC0gMV1bbCAtIDFdICsgdmFsW2ldW2pdfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmIChpID4gMCkgewogICAgICAgICAgZm9yIChpbnQgbCA9IDA7IGwgPCA0OyArK2wpIGRwW2ldW2pdWzBdID0gbWF4KGRwW2ldW2pdWzBdLCBkcFtpIC0gMV1bal1bbF0pOwogICAgICAgIH0KICAgICAgICBpZiAoaiA+IDApIHsKICAgICAgICAgIGZvciAoaW50IGwgPSAwOyBsIDwgNDsgKytsKSBkcFtpXVtqXVtsXSA9IG1heChkcFtpXVtqXVtsXSwgZHBbaV1baiAtIDFdW2xdKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CgogIGludDY0IGFucyA9IDA7CiAgZm9yIChpbnQgaSA9IDA7IGkgPCA0OyArK2kpIGFucyA9IG1heChhbnMsIGRwW3IgLSAxXVtjIC0gMV1baV0pOwogIGNvdXQgPDwgYW5zIDw8IGVuZGw7CgogIHJldHVybiAwOwp9CiIiIgoKd2l0aCBvcGVuKCdzb2wuY3BwJywgJ3cnKSBhcyBmOgogICAgZi53cml0ZShjb2RlKQoKc3VicHJvY2Vzcy5Qb3BlbihbJ2crKycsICctc3RkPWMrKzE3JywgJy1PMicsICdzb2wuY3BwJ10pLmNvbW11bmljYXRlKCkKc3VicHJvY2Vzcy5Qb3BlbihbJy4vYS5vdXQnXSwgc3RkaW49c3lzLnN0ZGluLCBzdGRvdXQ9c3lzLnN0ZG91dCkuY29tbXVuaWNhdGUoKQ=='))

Measured memory_bytes: 322300
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

template <typename T>
vector<pair<int, T>> rle(vector<T> a)
{
	int n = (int)a.size();
	vector<pair<int, T>> res;
	if (n == 0)
	{
		return res;
	}
	T now = a[0];
	int con = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] == now)
		{
			con++;
		} else
		{
			res.push_back(pair<int, T>(con, now));
			now = a[i];
			con = 1;
		}
	}
	res.push_back(pair<int, T>(con, now));
	return res;
}


int main() {
	IOS;
	string s;
	cin >> s;
	int n = s.size();
	vector<int> t(n);
	REP(i, n) {
		if (s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T') {
			t[i] = 1;
		} else {
			t[i] = 0;
		}
	}
	auto rl = rle(t);
	int res = 0;
	REP(i, rl.size()) {
		if (rl[i].second == 1) {
			chmax(res, rl[i].first);
		}
	}
	put(res);
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	S := sc.next()
	SArr := strings.Split(S, "")
	var ng bool
	for i := 0; i < len(SArr); i++ {
		if (i+1)%2 == 0 {
			if SArr[i] == "R" {
				ng = true
			}
		}
		if (i+1)%2 != 0 {
			if SArr[i] == "L" {
				ng = true
			}
		}
	}
	if ng {
		no()
	} else {
		yes()
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = ("R" * x + "U" * y + "L" * x + "D" * y + "D" + "R" * -~x + "U" * -~y +
       "L" + "U" + "L" * -~x + "D" * -~y + "R")
print(ans)


Measured memory_bytes: 9044
#include <stdio.h>
#include <string.h>
int main(){
    int n,i,c=0,ng=0;
    char s[11];
    scanf("%s",s);
    n=strlen(s);
    if(s[0]!='A'||s[1]<97)printf("WA");
    else {
        for(i=2;i<n;i++){
            if(i<=n-2&&c==0&&s[i]=='C')c=1;
            else if(s[i]<97)ng=1;
        }
        if(!c)ng=1;
        if(ng)printf("WA");
        else printf("AC");
    }
}

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

int main()
{
    ll h, n;
    cin >> h >> n;
    vector<ll> A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];
    //配るDPで実装→hの例外処理が扱いやすい
    vector<vector<ll>> dp(n + 1, vector<ll>(h + 1, INF));
    rep(i, h + 1) dp[0][0] = 0;

    for (int i = 0; i <= n - 1; i++)
    {
        for (int j = 0; j <= h; j++)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]); //一度もi番目の魔法を使わない
            dp[i + 1][min(j + A[i], h)] = min(dp[i + 1][min(j + A[i], h)], dp[i + 1][j] + B[i]);
        }
    }

    cout << dp[n][h] << endl;
}

//体力jを満たす最小の魔力のDPテーブル→ぴったりないとinfが答えになってまう

Measured memory_bytes: 81640
#include <bits/stdc++.h>
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#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(25) << 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 10000000
#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))
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  map<pint,int>mp1;
  map<pint,int>mp2;
  rep(i,0,N){
    cin >> A >> B;
    if(A==B&&A==0)flag++;
    else if(B==0)mp1[pint(1,0)]++;
    else if(A==0)mp2[pint(1,0)]++;
    else if((double)A/B>0){
      C=gcd(abs(A),abs(B));
      A/=C;
      B/=C;
      A=abs(A);
      B=abs(B);
      mp1[pint(A,B)]++;
    }
    else{
      C=gcd(abs(A),abs(B));
      A/=C;
      B/=C;
      A=abs(A);
      B=abs(B);
      mp2[pint(B,A)]++;
    }
  }
  num=1;
  set<pint>st;
  for(auto v:mp1)st.insert(v.first);
  for(auto v:mp2)st.insert(v.first);
  for(auto v:st){
    if(mp1.find(v)!=mp1.end()&&mp2.find(v)!=mp2.end()){
      num*=(repow(2,mp1[v],mod)+repow(2,mp2[v],mod)-1)%mod;
    }
    else if(mp1.find(v)!=mp1.end()){
      num*=(repow(2,mp1[v],mod));
    }
    else{
      num*=(repow(2,mp2[v],mod));
    }
    num%=mod;
  }
  Out((num+mod+flag-1)%mod);
}


Measured memory_bytes: 28628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int N, count, max_count = 0;
	string S, S_left, S_right;

	cin >> N >> S;

	//切る場所をループ
	for (int i = 0; i < N; i++) {
		S_left = S.substr(0, i);
		S_right = S.substr(i, N - 1);

		/*両方の文字列に各文字があるかをチェック（26種類ループ）
		charだから++でまわすとよい*/
		count = 0;
		for (char j = 'a'; j <= 'z'; j++) {
			if (S_left.find(j) != string::npos && S_right.find(j) != string::npos) {
				count++;
			}

		}
		if (max_count < count) {
			max_count = count;
		}
	}

	cout << max_count;



	return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
from collections import deque
import heapq
#n = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))
a = list(map(lambda x: -x, a))
heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a) * (-1)
    x = math.floor(x/2)
    heapq.heappush(a, -x)

print(-sum(a))

    


Measured memory_bytes: 14628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define N 10005

int main()
{
    int n;
    cin>>n;
    ll ara[n+5];
    for(int i=0;i<n;i++) cin>>ara[i];
    priority_queue<ll> pq1,pq2;
    for(int i=0;i<n;i++) pq1.push(ara[i]);
    ll ans=pq1.top();
    pq1.pop();
    pq2.push(pq1.top());
    pq1.pop();
    while(pq1.size())
    {
        ans+=pq2.top();
        pq2.push(pq1.top());
        pq1.pop();
        if(pq1.empty()) break;
        ans+=pq2.top();
        pq2.push(pq1.top());
        pq1.pop();
        pq2.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8232
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node
{
  int key;
  Node *next;
  Node *prev;
};

Node *nil;

Node* listSearch(int key)
{
  Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key)
    {
      cur=cur->next;
    }
  return cur;
}

void init()
{
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList()
{
  Node *cur = nil->next;
  int isf = 1;
  while(1)
    {
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
    }
  printf("\n");
}

void deleteNode(Node *t)
{
  if(t==nil)
    {
      return;
    }
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst()
{
  deleteNode(nil->next);
}

void deleteLast()
{
  deleteNode(nil->prev);
}

void deleteKey(int key)
{
  deleteNode(listSearch(key));
}


void insert(int key)
{
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main()
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	deleteKey(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 33864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  if (b < a) swap(a, b);
  cout << max(b - (W + a), 0) << endl;
  return 0;
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, 0, n)
    {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    ll a = 0, b = 0;
    for (auto i : mp)
    {
        if (i.first > a && i.second >= 2)
            a = i.first, i.second -= 2;
        if (i.second >= 2 && i.first > b)
            b = i.first;
        if (a > b)
            swap(a, b);
    }
    cout << a * b << endl;
}


Measured memory_bytes: 9760
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;
struct XX{
int s;
    int e;
};

class xxGreater {
public:
bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
if((riLeft.s) == (riRight.s)){
return riLeft.e < riRight.e;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
           //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.s) > (riRight.s);
    }
};


int main(int argc, const char * argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
int n;
cin>>n;
vector<int>ans;
    for(int i=0;i<n;i++){
    int a,b;
    cin >> a>> b;
if(a==b){
ans.push_back(i);
}
}

int f=0;
if(ans.size()>2){
for(int i=0;i<n-2;i++){
if(ans[i+2]-ans[i+1]==1&&ans[i+1]-ans[i]==1){
f=1;
}
}
}

if(f==1){
cout << "Yes" <<endl;
}else{
cout << "No" <<endl;
}
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}//素数の時true
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n; 
 ll l[n+10],r[n+10],mx=0;
 rep(i,0,n){
  cin>>l[i]>>r[i];
  mx=max(mx,r[i]);
 }

 ll a[mx+10]={0},now;
 bool f1,f2;
 rep(j,0,mx+1){
  now=j;
  f1=prime(now);
  f2=prime((now+1)/2);
  if(j>0)a[now]=a[now-1];
  if(f1&&f2&&j%2==1)a[now]++;
  //cout<<now<<" "<<a[now]<<endl;
 }
 rep(i,0,n){
  ll ans=a[r[i]]-a[l[i]-1];
 // cout<<i<<" "<<a[r[i]]<<" "<<a[l[i]-1]<<endl;
  pr(ans);
 }
return 0;}


Measured memory_bytes: 5936
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

alias P = Tuple!(int, "i", double, "c");

void main()
{
    auto xy = readln.split.to!(double[]);
    double[] xs, ys, rs;
    xs ~= xy[0];
    ys ~= xy[1];
    rs ~= 0;
    auto N = readln.chomp.to!int;
    foreach (_; 0..N) {
        auto xyr = readln.split.to!(double[]);
        xs ~= xyr[0];
        ys ~= xyr[1];
        rs ~= xyr[2];
    }
    xs ~= xy[2];
    ys ~= xy[3];
    rs ~= 0;

    auto G = new double[][](N+2, N+2);
    foreach (i; 0..N+2) {
        G[i][i] = 0;
        foreach (j; i+1..N+2) {
            G[i][j] = G[j][i] = max(0.0, sqrt((xs[i] - xs[j])^^2 + (ys[i] - ys[j])^^2) - rs[i] - rs[j]);
        }
    }

    auto DP = new double[](N+2);
    DP[] = 10L^^9*3;
    DP[0] = 0;
    auto Q = heapify!"a.c > b.c"([P(0, 0)]);
    while (!Q.empty) {
        auto i = Q.front.i;
        auto c = Q.front.c;
        Q.popFront();
        if (DP[i] < c) continue;
        foreach (j; 0..N+2) if (DP[j] > c + G[i][j]) {
            DP[j] = c + G[i][j];
            Q.insert(P(j, c + G[i][j]));
        }
    }
    writefln!"%.12f"(DP[N+1]);
}

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

#define LL long long

int main(){
    double n;
    cin>>n;
    vector<double>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    set<double,greater<>>res;
    cout<<fixed<<setprecision(5);
    sort(v.begin(),v.end());
    double s=v[0];
    for(int i=1;i<n;i++){
//        cout<<"("<<s<<"+"<<v[i]<<")/"<<2<<"="<<s<<endl;
        s=(s+v[i])/2;
    }
    cout<<s<<endl;
    return 0;
}


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

int N, M, X;
int C[15], A[15][15];
int MAX = 2000100;
int skill[15];

int calc(int n, int val) {
    if (n == N) {
        bool flag = true;
        for (int i = 0; i < M; i++) {
            if (skill[i] < X) {
                flag = false;
                break;
            }
        }
        if (flag) {
            return val;
        } else {
            return MAX;
        }
    }
    int a = calc(n + 1, val);
    for (int i = 0; i < M; i++) {
        skill[i] += A[n][i];
    }
    int b = calc(n + 1, val + C[n]);
    for (int i = 0; i < M; i++) {
        skill[i] -= A[n][i];
    }
    return min(a, b);
}

int main(void) {
    std::cin >> N >> M >> X;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = calc(0, 0);
    if (ans == MAX) {
        printf("-1\n");
    } else {
        printf("%d\n", ans);
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
 ll h,a;
  cin >> h >> a;
  
  cout << (h-1)/a+1 << endl;
  
  
}


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

#define pb push_back
#define ff first
#define ss second
#define N 200005
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef pair<int,int> pii;
typedef long long int ll;
typedef long int li;
int mod1 = 998244353;

map<int,int> m;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n;
    cin>>n;
    int a[n+3];
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        m[a[i]]++;
    }
    ll ans = 0;
    for(auto u : m) {
        ans += 1ll*u.ss*(u.ss-1)/2;
    }
    for(int i=1;i<=n;i++) {
        cout<<(ans - m[a[i]] + 1)<<"\n";
    }
}


Measured memory_bytes: 8320
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	for(int n;cin>>n;){
		vi a;
		rep(i,10)
			if((1<<i)&n)
				a.push_back(1<<i);
		rep(i,a.size())
			cout<<(i==0?"":" ")<<a[i];
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vvec<char> S(H,vec<char>(W));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        cin >> S[i][j];
    }
    int inf = 1e9;
    vvec<int> dp(H,vec<int>(W,inf));
    struct P{
        int x,y;
    };
    deque<P> Q;

    vec<int> dx = {1,0},dy = {0,1};

    auto in = [&](int x,int y){
        return 0<=x && x<H && 0<=y && y<W;
    };

    Q.push_front({0,0});
    dp[0][0] = S[0][0]=='#';

    while(!Q.empty()){
        P p = Q.front(); Q.pop_front();
        cerr << p.x << " " << p.y << "\n";
        for(int i=0;i<2;i++){
            int nx = p.x+dx[i],ny = p.y+dy[i];
            if(!in(nx,ny)) continue;
            if(dp[nx][ny]!=inf) continue;
            int cost = (S[p.x][p.y]=='.' && S[nx][ny]=='#');
            dp[nx][ny] = dp[p.x][p.y]+cost;
            if(S[p.x][p.y]==S[nx][ny]) Q.push_front({nx,ny});
            else Q.push_back({nx,ny});
        }
    }
    cout << dp[H-1][W-1] << "\n";

//    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cerr << dp[i][j] << (j!=W-1? " ":"\n");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n,k;
	int ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		ans+=min(a,k-a)*2;
	}
	cout<<ans<<endl;
	return 0;
}


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

def adjust(a, b, va, vb):
  r = max(a // va, b // vb)
  if va * r < a or vb * r < b:
    r += 1
  
  return va * r, vb * r

t, a = [int(x) for x in input().split()]
for n in range(N - 1):
  ti, ai = [int(x) for x in input().split()]
  t, a = adjust(t, a, ti, ai)

print(t + a)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
  int a,b;
  while(scanf("%d %d", &a, &b) != EOF){
    char str[1024];
    sprintf(str, "%d", a+b);
    printf("%zd\n", strlen(str));
  }

  return 0;
}

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

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int N,M,Q;
vector<int> a(50),b(50),c(50),d(50);
int ans = 0;

void dfs(vector<int> A){
    if(A.size() == N + 1){
        int calc = 0;
        rep(i,Q){
            if(A[b[i]] - A[a[i]] == c[i]) calc += d[i];
        }
        chmax(ans , calc);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= M){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> N >> M >> Q;
    rep(i,Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(vector<int>(1,1));
    cout << ans << endl;
}

Measured memory_bytes: 3568
import java.io.*;
public class Main{
    static int[] e;
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        int N = r.i();
        e = new int[N+1];
        for(int i = 2; i < e.length; i++){
            int cur = i;
            for(int j = 2; j < i+1; j++){
                while(cur%j == 0){
                    e[j] += 1;
                    cur /= j;
                }
            }
        }        
        print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)/2);
    }
    static int num(int m){
        int num = 0;
        for(int x : e) if(m-2 < x) num++;
        return num;
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static int max(int[] ii){
        int max = ii[0];
        for(int i : ii) if(max < i) max = i;
        return max;
    }
    static int min(int[] ii){
        int min = ii[0];
        for(int i : ii) if(i < min) min = i;
        return min;
    }
    static long max(long[] ll){
        long max = ll[0];
        for(long l : ll) if(max < l) max = l;     
        return max;
    }
    static long min(long[] ll){
        long min = ll[0];
        for(long l : ll) if(l < min) min = l;
        return min;
    }
    static double max(double[] dd){
        double max = dd[0];
        for(double d : dd) if(max < d) max = d;
        return max;
    }
    static double min(double[] dd){
        double min = dd[0];
        for(double d : dd) if(d < min) min = d;
        return min;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return readLine().split(" ");
        }
        int i() throws IOException{
            return Integer.parseInt(readLine());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int j = 0; j < N; j++) ii[j] = i();
            return ii;
        }
        long l() throws IOException{
            return Long.parseLong(readLine());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
        long[] ll(int N) throws IOException{
            long[] ll = new long[N];
            for(int j = 0; j < N; j++) ll[j] = i();            
            return ll;
        }
    }
}

Measured memory_bytes: 22484
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

sum = 0
pre = -1
a.each do |i|
    sum += b[i-1]
    if i - pre == 1
        sum += c[i-2]
    end
    pre = i
end
puts sum

Measured memory_bytes: 1788
#include<stdio.h>

int main()

{
   int i,j,tc,a[100000],cnt=0,z;

   scanf("%d",&tc);

   for(i=0;i<tc;i++)
   {
      scanf("%d",&a[i]);
   }

   for(j=1,z=0;j<=tc;j++,z++)
   {
      if(j!=a[z])
      {
         cnt++;
      }
   }

   if(cnt<=2)
   {
      printf("YES\n");
   }

   else
   {
      printf("NO\n");
   }
}


Measured memory_bytes: 1648
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
d = stdin.readline().rstrip()
print(d.replace('?', 'D'))


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  string s;cin>>s;
  int ans=0;
  REP(i,4){
    char c=s[i];
    if(c=='+'){
      ans++;
    }else{
      ans--;
    }
  }
  cout << ans << endl;
}


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

  ll a5, b5;
  for(int i=-1000; i<=1000; i++){
    for(int j=-1000; j<=1000; j++){
      if(pow(i,5)-pow(j,5)==x){
           printf("%d %d\n", i, j);
           return 0;
      }
    }
  } 

  return 0;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll n, m;
string s, t;

ll gcd (ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	cin >> s >> t;

	n /= gcd(s.size(), t.size());
	m /= gcd(s.size(), t.size());

	for (int i = 0, j = 0; i < s.size(); i += n, j += m)
		if (s[i] != t[j]) {
			cout << -1 << endl;
			return 0;
		}

	cout << n * m * gcd(s.size(), t.size()) << endl;

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
    // printf("%d\n", N);
    return 0;
}

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

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	lint a,b;
	std::cin >> a >> b;

	std::cout << ((a-b*2 < 0) ? 0 : a-b*2) << std::endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

ll a, b, r;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> a >> b;
	if (b % a)
		r = b - a;
	else
		r = b + a;
		
	cout << r;
	
	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int main() {   
    int n;
    cin>>n;
    cout<<n/3<<endl;
}

                           


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

int main(){
  long long a, b, c, d;

  cin >> a >> b >> c >> d;

  if(a*b > c*d){
    cout << a*b << endl;
  }else{
    cout << c*d << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define li long long int
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i = 0; i< n ; i++){
    cin>>a[i];
  }
  li count=0;
  for(int i = 1; i < n - 1; i++){
    if(a[i]<max(a[i-1],a[i+1])&&a[i]>min(a[i-1] , a[i+1]))
        count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
function main(input: string): void {
  const nums: number[] = input.split('\n').map(n => parseInt(n, 10)).slice(1)
  const uniqNums: number[] = nums.filter((arg: number, index: number, self: number[]) => {
    return self.indexOf(arg) === index
  })

  console.log(uniqNums.length)
}

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

Measured memory_bytes: 7500