akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}
int n;

string s;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		int m=s.size();
		set<string> st;
		for(int i=1;i<m;i++){
			string s1=s.substr(0,i),s2=s.substr(i,m-i);
			for(int j=0;j<8;j++){
				string t1=s1,t2=s2,t;
				if(j%2==0) reverse(t1.begin(),t1.end());
				if(j/2%2==0) reverse(t2.begin(),t2.end());
				if(j/4%2==0) t=t1+t2;
				else t=t2+t1;
				st.insert(t);
			}
		}
		cout<<st.size()<<endl;
	}
}


Measured memory_bytes: 3260
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int w,h;
vector<string> m;
int memo[50][50];
int mx;

int f(int sy, int sx){
  int dy[4] = {-1,0,0,1};
  int dx[4] = {0,-1,1,0};

  memset(memo,0,sizeof(memo));

  memo[sy][sx] = 1;

  queue<int> q1,q2,q3;
  q1.push(sy);
  q2.push(sx);
  q3.push(0);

  while(!q1.empty()){
    int y = q1.front();
    int x = q2.front();
    int c = q3.front();
    q1.pop();
    q2.pop();
    q3.pop();

    mx = max(mx,c);

    for(int t = 0; t < 4; t++){
      int y1 = y + dy[t];
      int x1 = x + dx[t];
      if(y1 < 0 || y1 >= h)continue;
      if(x1 < 0 || x1 >= w)continue;
      if(m[y1][x1] == '#')continue;
      if(memo[y1][x1] == 1)continue;
      memo[y1][x1] = 1;
      q1.push(y1);
      q2.push(x1);
      q3.push(c+1);
    }
  }
  return -1;
}



int main(){
  mx = 0;
  cin>>h>>w;
  rep(i,0,h){
    string s;
    cin>>s;
    m.pb(s);
  }
  rep(y,0,h){
    rep(x,0,w){
      clr(memo,0);
      if(m[y][x]!='#'){
        f(y,x);
      }
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

#include <boost/heap/fibonacci_heap.hpp>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	int tank;
	Edge() {}
	Edge(int to, T cost, int tank = 0) : to(to), cost(cost), tank(tank) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, L;
	cin >> N >> M >> L;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < M; i++) {
		int u, v, len;
		cin >> u >> v >> len;
		u--, v--;
		if (len > L) continue;
		edges[u].emplace_back(v, len);
		edges[v].emplace_back(u, len);
	}

	auto dijkstra = [&](int st) {
		vector<pair<int, int>> dp(N, { -INF, 0 });
		dp[st] = { 0, L };
		using ppi = pair<pair<int, int>, int>;
		boost::heap::fibonacci_heap<ppi> que;
        vector<decltype(que)::handle_type> handles(N);
        for (int v = 0; v < N; v++) handles[v] = que.emplace(dp[v], v);
		while (!que.empty()) {
			auto now = que.top();
			que.pop();

			for (const auto &e : edges[now.second]) {

				auto tmp = now.first;
				if (e.cost > tmp.second) {
					tmp.first--;
					tmp.second = L - e.cost;
				}
				else tmp.second -= e.cost;

				if (tmp > dp[e.to]) {
					dp[e.to] = tmp;
					que.update(handles[e.to], ppi(tmp, e.to));
				}

			}
		}
		return dp;
	};

	vector<vector<pair<int, int>>> memo(N);
	for (int i = 0; i < N; i++) memo[i] = dijkstra(i);

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		auto tmp = memo[s][t].first;
		if (tmp != -INF) cout << -tmp << "\n";
		else cout << -1 << "\n";
	}

	return 0;
}


Measured memory_bytes: 2944
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		char tmp[] = new char[] {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
		int calc[] = new int[] {1, 5, 10, 50, 100, 500, 1000};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while((str = br.readLine()) != null) {
			char c[] = str.toCharArray();
			int ret = 0;
			int cur = 7, prev = 7;
			for(int i = 0; i < str.length(); i++) {
				for(int j = 0; j < 7; j++) {
					if(c[i] == tmp[j]) {
						prev = cur;
						cur = j;
						break;
					}
				}
				if(cur > prev) ret -= 2 * calc[prev];
				ret += calc[cur];
			}
			System.out.println(ret);
		}
	}
}

Measured memory_bytes: 16876
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main(){
  long N, M;
  cin >> N >> M;

  // 自身含めたものが偶数なら白、奇数なら黒になる
  // 数が変わるのは変だけ

  long res = N*M;
  if (N == 1 && M == 1) res = 1;
  else if (N == 1 || M == 1) res -= 2;
  else {
    res -= N*2 + M*2 - 4;
  }

  cout << res << endl;
}


Measured memory_bytes: 888
nums =  [list(map(int,input().split())) for i in range(3)]
a1 = 0
b1,b2,b3 = map(int,nums[0])
a2 = nums[1][0] -b1
a3 = nums[2][0] -b1
if nums[1][1] == a2+b2 and nums[1][2] == a2+b3 and nums[2][1] == a3+b2 and nums[2][2] == a3+b3:
    print("Yes")
else:print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int x1, y1, x2, y2, x3, y3, x4, y4;
    int a, b;
    cin >> x1 >> y1 >> x2 >> y2;
    a = x2 - x1;
    b = y2 - y1;
    cout << x2 - b << ' ' << y2 + a << ' ' << x1 - b << ' ' << y1 + a << endl;
    return 0;
}



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

long long int n,i,x,a;
string s;
bool tr;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;n--;
	while (1==1)
	{
		n++;
		x=trunc(sqrt(n));tr=true;
		for (i=2;i<x+1;i++) if (n%i==0) tr=false;
		if (tr)
		{
			cout<<n;return 0;
		}
	}
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ab = a + b;
		int ac = a + c;
		int bc = b + c;
		int ans = ab;
		if (ans > ac)
			ans = ac;
		if (ans > bc)
			ans = bc;
		System.out.println(ans);
		sc.close();
	}
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    bool flag = false;
    for(int i = 0;i < 100; i+=4){
        for(int j = 0;j < 100; j+=7){
            if(n == i + j) flag = true;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, h;
	cin >> n >> h;
	vector<pair<ll, ll>>a(n), b(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
		b[i] = make_pair(a[i].second, a[i].first);
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	ll ans = 0;
	rep(i, n) {
		if (a[0].first <= b[i].first) {
			h -= b[i].first;
			ans++;
		}
		if (h <= 0)break;
	}
	if (h > 0) {
		while (h > 0) {
			ans++;
			h -= a[0].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int A, B;
  cin >> A >> B;
  bool ok = false;
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    ok = true;
  }
  if (ok) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {

    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());
        long X = Integer.parseInt(scan.next());

        long distance;
        long[] distanceArray = new long[N];
        for(int i = 0; i < N; i++){
            distance = Long.parseLong(scan.next()) - X;
            if(distance < 0) distance = -(distance);
            distanceArray[i] = distance;
        }

        Arrays.sort(distanceArray);

        if(distanceArray.length == 1){

            System.out.println(distanceArray[0]);

        }else{

            long ans = distanceArray[distanceArray.length-1];
            for(int i = distanceArray.length -1; -1 < i ; i-- ){

                ans = gcd(ans, distanceArray[i]);
            }
            
            System.out.println(ans);
        }

    }

    private static long gcd(long a, long b){

        if(a%b == 0){

            return b;

        }else{

            return gcd(b, a%b);

        }
    }
}

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

int main() {
  int N;
  cin >> N;
  long long ans = 0;
  
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    else {
      ans = ans + i;
    }
  }
  cout << ans << endl;
}

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

string S;

int main() {
    cin >> S;
    set<char> st;
    rep(i, S.size()) {
        st.insert(S[i]);
    }

    cout << (st.size() == S.size() ? "yes" : "no") << endl;
}

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

int main(){
    int N, A = 0, B = 0;
    cin >> N;
    bool count = false;
    for (int i = 0; i <= N; i++){
        for (int j = 0; j <= N; j++){
            if (N == i*4 + j*7) count = true;
        }
    }
    if (count){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto check = [&](const string& s, const string& t) -> bool {
    vector<int> vec(128, -1);
    for (ll i = 0; i < (ll)s.size(); i++) {
      if (vec[s[i]] == -1) vec[s[i]] = t[i];
      else if (vec[s[i]] != t[i]) return false;
    }
    return true;
  };

  string S, T; cin >> S >> T;
  cout << (check(S, T) && check(T, S) ? "Yes" : "No") << endl;
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;

    cin >> n >> a >> b;

    int ans = 0;
    int x, y;

    int i;

    for (i = 1; i <= n; i++) {
        x = i;
        y = 0;

        while (x) {
            y += (x % 10);
            x /= 10;
        }

        if (a <= y && y <= b) ans += i;
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

int main()
{
    int n,x=0,mx=0;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    for(int i=0;i<n;++i)
    {
        if(s[i]=='I')
         x++;
        mx=max(x,mx);
         if(s[i]=='D')
        {
            abs(x--);
        }
    }
    printf("%d",mx);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d %d",&a,&b);
	if(a<b)
	{
		for(c = 0;c < b;c++)
		{
			d = (a - c);
			if(d < 0)
			{
				d = d * -1;
			}
			e = (b - c);
			if(e < 0)
			{
				e = e * -1;
			}
			if(d == e)
			{
				printf("%d\n",c);
				break;
			}
				
		}
	}
	else if(a>b)
	{
		for(c = 0;c < a;c++)
		{
			d = (a - c);
			if(d < 0)
			{
				d = d * -1;
			}
			e = (b - c);
			if(e < 0)
			{
				e = e * -1;
			}
			if(d == e)
			{
				printf("%d\n",c);
				break;
			}
				
		}
	}
	if(d != e)
	{
		printf("IMPOSSIBLE\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int count = 0;
  rep(i,s.length()) if(s[i] == '1')++count;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;

int dp[1100][(1<<3)+10];

int main(){
	int n;
	string s;
	cin>>n>>s;
	vi v(n+1, 0);
	for(int i = 0; i < n; i++){
		if(s[i]=='J') v[i]=0;
		if(s[i]=='O') v[i]=1;
		if(s[i]=='I') v[i]=2;
	}
	for(int i = 0; i < 8; i++){
		if((i&1)==1 && (1<<v[0]&i)!=0){
			dp[0][i]=1;
		}
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 8; j++){
			for(int k = 0; k < 8; k++){
				if(((j&(1<<v[i]))!=0)&&(j&k)!=0){
					dp[i][j] += dp[i-1][k];
					dp[i][j]%=10007;
				}
			}
		}
	}
	int sum = 0;
	for(int i = 0; i < 8; i++){
		sum += dp[n-1][i];
		sum%=10007;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
//--GLOBAL------------------------------------


//--MAIN------------------------------------
void Main(){
    
    ll N,K; cin>>N>>K;

    vector<ll> A(N);
    vector<ll> F(N);

    rep(i,N){
        cin>>A[i];
    }
    rep(i,N){
        cin>>F[i];
    }

    SORT(A);
    sort(ALL(F),greater<ll>());

    ll low = -1;      // 一番小さい値より1つ前
    ll high = INF2;  // 一番でかい値より1つあと
    while (abs(high - low) > 1) {
        ll mid = (high + low) / 2;
        ll k=K;
        rep(i,N){
            k-=max(0LL,A[i]-(mid/F[i]));
        }
        ( k>=0 ? high=mid : low=mid );
    }

    cout<< high <<"\n";
}

//--START---------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
if N == 2 or M == 2:
    print(0)
elif N == 1 and M == 1:
    print(N * M)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print(((N-2) * (M-2)))

Measured memory_bytes: 3060
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(n - 1):
    if a[i] + a[i + 1] <= x:
        continue

    diff = (a[i] + a[i + 1]) - x
    ans += diff

    tmp = min(diff, a[i + 1])
    a[i + 1] -= tmp
    diff -= tmp
    a[i] -= diff
      
print(ans)


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

int a,d,n,cnt;

int is_prime(int n){
    for (int i=2;i*i<=n;++i){
        if (n%i==0) return 0;
    }
    return n!=1;
}

int solve(){
    cnt=0;
    for (int i=0;;++i){
        if (is_prime(a+d*i)) ++cnt;
        if (cnt==n) return a+d*i;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> a >> d >> n,a){
        cout << solve() << '\n';
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define inf 10000000
using namespace std;
typedef long long int ll;

int main(){

    int N,i,a,b,ans=0;
    cin >> N;

    int h[N+1];
    h[N] = 0;

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

    while(1){
        a = 0;
        b = 1;
        for(i=0 ; i<N+1 ; i++){
            if(h[i] != 0){
                h[i]--;
                a = 1;
                b = 0;
            }else if(h[i] == 0){
                if(a){
                    ans++;
                    a = 0;
                }
            }    
        }

        if(b){
            break;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    w = set()
    c = 0
    for e in a:
        if 1 <= e <= 399:
            w.add(1)
        elif 400 <= e <= 799:
            w.add(2)
        elif 800 <= e <= 1199:
            w.add(3)
        elif 1200 <= e <= 1599:
            w.add(4)
        elif 1600 <= e <= 1999:
            w.add(5)
        elif 2000 <= e <= 2399:
            w.add(6)
        elif 2400 <= e <= 2799:
            w.add(7)
        elif 2800 <= e <= 3199:
            w.add(8)
        elif 3200 <= e:
            c += 1
    print(max(1, len(w)), len(w) + c)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""



Measured memory_bytes: 9384
from collections import defaultdict

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    res = 1
    for i in range(r):
        res *= n
        n -= 1
    for i in range(1,r+1):
        res //= i
    return res

N, A, B = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
mi = 10**18
dic = defaultdict(int)
dic2 = defaultdict(int)
tot = 0
for i,a in enumerate(V):
    if i < A:
        tot += a
        dic2[a] += 1
        if a < mi:
            mi = a
    dic[a] += 1
if len(dic2) == 1:
    ans = 0
    for i in range(A, B+1):
        ans += comb(dic[mi], i)
else:
    ans = comb(dic[mi], dic2[mi])
print(tot/A)
print(ans)


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

using namespace std;

int main()
{
    int n, h, w;
    scanf("%d %d %d", &n, &h, &w);

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        if (h <= a && w <= b)
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


struct Quest {
	int l, r;
	int pos;
	int ans;
};

int N, q;
int c[500010];
Quest quest[500010];

bool compareR(const Quest &a, const Quest &b) {
	if (a.r == b.r) {
		return a.pos < b.pos;
	} else {
		return a.r < b.r;
	}
}

bool comparePos(const Quest &a, const Quest &b) {
	return a.pos < b.pos;
}

//树状数组
const int maxn = 500010; 
int tree[maxn];
int booll[maxn];

int lowbit(int n) 
{
    return n&(-n);
    //树状数组核心操作×1
}

void add(int n,int now)
{
    while (n <= N)
    {
        tree[n] += now;
        n += lowbit(n);
    }
    //树状数组核心操作×2-->更新操作
}

int sum(int n)
{
    int ans = 0;
    while(n != 0)
    {
        ans += tree[n];
        n -= lowbit(n);
    }
    return ans;
    //树状数组核心操作×3———>查询操作
}

int main()
{
	scanf("%d%d", &N, &q);
	
	for (int i = 1 ; i <= N ; i++) {
		scanf("%d", &(c[i]));
	}
	
	for (int i = 0 ; i < q ; i++) {
		scanf("%d%d", &(quest[i].l), &(quest[i].r));
		quest[i].pos = i;
		quest[i].ans = 0;
	}
	
	sort(quest, quest + q, compareR);

    int next = 1;
    for(int i = 0 ; i < q ; i++)
    {
        for(int j = next ; j <= quest[i].r ; j++)
        {
            if (booll[c[j]])
				add(booll[c[j]], -1);
			//之前打过标记，在之前的位置加上-1，保证无重复
            add(j, 1);
            booll[c[j]] = j;
        }
        next = quest[i].r + 1;
        //更新下一次查询的位置
//        nnn[ask[i].pos] = sum(ask[i].r) - sum(ask[i].l - 1);
		quest[i].ans = sum(quest[i].r) - sum(quest[i].l - 1);
        //按询问编号存储每组询问的结果
    }
	
	sort(quest, quest + q, comparePos);
	for (int i = 0 ; i < q ; i++) {
		printf("%d\n", quest[i].ans);
	}
	
	return 0;
}



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

int main(){

    int n;
    cin >> n;

    int count1 = 0;
    int count2 = 0;
    for(int i=0; i<n; i++){

        string str1, str2;
        cin >> str1 >> str2;
        int size = (str1.size()>=str2.size()?str1.size():str2.size());
        bool flag = false;

        for(int j=0; j < size; j++){

            if(flag==true) break;
            if(str1[j]==str2[j]){
                if(j==size-1){
                    count1 += 1;
                    count2 += 1;
                } 
            }else{
                if(str1[j]>str2[j]){ 
                count1 += 3;
                flag = true;
            }
                else if(str1[j]<str2[j]){
                count2 += 3;
                flag = true;
            }
            }
        }
    }

   cout << count1 << " " << count2 << endl;

    return 0;
}


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

int main()
{
    int N, moti;

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

    int len = N;
    sort(motis.begin(), motis.end());

    for (int i = 0; i < len - 1; i++) {
        if(motis[i] == motis[i+1]) {
            motis.erase(motis.begin() + i);
            i--;
            len -= 1;
        }
    }

    cout << len << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
 
const int MOD = 1e9 + 7, MAXN = 1e5 + 10;

int t, n, m;
vector<int> graph[MAXN];
vector<pair<int, int> > edges;
int deg[MAXN];
set<pair<int, int> > used;
bool vis[MAXN];

void reset(){
    for(int i = 0; i < MAXN; i++){
        graph[i].clear();
        deg[i] = 0;
    }
    used.clear();
    mem(vis, 0);
    edges.clear();
}

void dfs(int node){
    if(vis[node])
        return;
    vis[node] = true;
    for(auto u : graph[node])
        dfs(u);
    if(deg[node]%2 == 0){
        for(auto u:graph[node]){
            if(used.find(mp(node, u)) != used.end())
                continue;
            if(used.find(mp(u, node)) != used.end())
                continue;
            used.insert(mp(node, u));
            deg[u]--;
        }
    }
    else{

        for(auto u:graph[node]){
            if(used.find(mp(node, u)) != used.end())
                continue;
            if(used.find(mp(u, node)) != used.end())
                continue;
            used.insert(mp(u, node));
            deg[node]--;
            break;
        }

        for(auto u:graph[node]){
            if(used.find(mp(node, u)) != used.end())
                continue;
            if(used.find(mp(u, node)) != used.end())
                continue;
            used.insert(mp(node, u));
            deg[u]--;
        }
    }
}

signed main(){
    
    
    t = 1;
    while(t--){
        reset();
        cin>> n >> m;
        for(int i = 0; i < m; i++){
            int u, v;
            cin>> u >> v;
            u--; v--;
            graph[u].append(v);
            graph[v].append(u);
            deg[u]++;
            deg[v]++;
            edges.append(mp(u, v));
        }
        dfs(0);
        bool flag = true;
        for(int i = 0; i < n; i++)
            if(deg[i]%2)
                flag = false;
        if(flag){
            for(int i = 0; i < m; i++){
                if(used.find(edges[i]) != used.end())
                    cout<<edges[i].F + 1 << ' ' << edges[i].S + 1<< endl;
                else
                    cout<<edges[i].S + 1<< ' ' << edges[i].F + 1<< endl;
            }
        }
        else
            cout<<-1<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}   

Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n>=3200)
		cout<<s<<endl;
	else
		cout<<"red"<<endl;
}

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

int main(){
	stack<int> a;
	int x,y;
	string s;
	while(cin>>s){
		if(s[0] == '+'){
			x = a.top();a.pop() ;
			y = a.top(); a.pop() ;
			a.push(x+y);  
		}
		else if(s[0] == '-'){
			x = a.top();a.pop() ;
			y = a.top(); a.pop() ;
			a.push(y-x);
		}
		else if(s[0] == '*'){
			x = a.top();a.pop() ;
			y = a.top(); a.pop() ;
			a.push(x*y);  
		}
		else{
			a.push(atoi(s.c_str()));
		}
	}
	cout<<a.top()<<endl ;
	return 0;
}


Measured memory_bytes: 3176
a,b,c,k=map(int,input().split())
if a>=k:
  print(k)
  exit()
else:
  k-=a
  if b>=k:
    print(a)
    exit()
  else:
    k-=b
    if c>=k:
      print(a-k)
    else:
      print(a-c)
    

Measured memory_bytes: 9004
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;


int main(void){
	int N; cin>>N;
	int a[N]; rep(i , N) cin>>a[i];

	sort(a, a + N);
	cout<<a[N - 1] - a[0];
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
        Scanner stdin = new Scanner(System.in);

        int N = stdin.nextInt();
        String S;;

        S = stdin.next();

        String T = S.substring(0,N/2);

        if(T.equals(S.substring(N/2))){
        	System.out.print("Yes");
        }
        else {
        	System.out.print("No");
        }
	}
}


Measured memory_bytes: 23124
#include <stdio.h>

void Swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a  = *b;
	*b  = tmp;
}

int main(void)
{
	int i, cup[3]={1,0,0};
	char m1, m2;
	
	while(scanf("%c%*c%c%*c", &m1, &m2)!=EOF)
		Swap(&cup[m1-'A'], &cup[m2-'A']);

	for(i=0; i<3; i++)
		if(cup[i] == 1)printf("%c\n", i+'A');

	return 0;
}

Measured memory_bytes: 540
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double c = scan.nextDouble();
		
		Double Sin = Math.sin(Math.toRadians(c));
		
		double d = (a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(c)));
		
		double S = 0.5 * a * b * Sin;
		double L = a + b + Math.sqrt(d);
		double h = b * Sin;
		
		System.out.printf("%.8f\n", S);
		System.out.printf("%.8f\n", L);
		System.out.printf("%.8f\n", h);
	}
}


Measured memory_bytes: 28156
#include "bits/stdc++.h"
using namespace std;
int n;
string s;
int main()
{
	cin>>n>>s;
	char now=s[0];
	int cnt=1;
	for(int i=0;i<n;i++)
		if(now!=s[i])
		{
			now=s[i];
			cnt++;
		}
	cout<<cnt<<endl; 
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");
		int a = Integer.parseInt(cut[0]);
		int b = Integer.parseInt(cut[1]);

		System.out.println((a * b) % 2 == 0 ? "Even" : "Odd");
	}
}

Measured memory_bytes: 21076
fn main() {
  let s = gets();
  let t = gets();
  let cs = s.chars();
  let ds = t.chars();
  
  let mut cnt = 0;
  for (c, d) in cs.zip(ds) {
    if c != d {
      cnt += 1
    }
  };
  
  println!("{}", cnt);
}

// 今回使ってません
fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}

Measured memory_bytes: 2620
using System;
using System.Linq;

public class Program{
    public static void Main(){
        int[] input=Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        Console.WriteLine(input[0]%((input[1]*2)+1)==0?input[0]/((input[1]*2)+1):input[0]/((input[1]*2)+1)+1);
    }
}


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

int main(){
  
  ll a,b,x;
  
  ll ans;
  
  cin >> a >> b >> x;
  
  ans = floor((long double)b/x) - ceil((long double)a/x) +1;

  cout << ans;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string n;
    cin >> n;
    string ans = "Yes";
    for(int i=0;i<n.length();i++){
        if(n.substr(i,1)!=n.substr(n.length()-i-1,1)){
            ans = "No";
        }
    }
    cout << ans << endl;
}


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

vector< vector<int> > ot;
vector< vector<int> > et; 
vector<int> ret;

void paint(int id,int clr){
    if(ret[id] != -1)return;
    ret[id] = clr;
    for(int i = 0;i < et[id].size();i++){
        paint(et[id][i],clr);
    }
    for(int i = 0;i < ot[id].size();i++){
        if(clr == 1){
            paint(ot[id][i],0);
        }else{
            paint(ot[id][i],1);
        }
    }
}

int main(){
    int n;
    cin >> n;
    ot = vector< vector<int> >(n);
    et = vector< vector<int> >(n); 
    ret = vector<int>(n,-1);
    for(int i = 0;i < n-1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        if(w%2 == 0){
            et[u].push_back(v);
            et[v].push_back(u);
        }else{
            ot[u].push_back(v);
            ot[v].push_back(u);
        }
    }
    paint(0,0);
    for(int i = 0;i < n;i++){
        cout << ret[i] << endl;
    }
}


Measured memory_bytes: 11052
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> _01={0,0};//累積和
  string S;
  cin >> S;
  bool flag=false;
  ll n=0;
  //if(S[0]=='1')_01.push_back(0);
  FORi(S.size()){
    bool b = S[i]=='0';
    if(flag)b=!b;
    if(!b){
      flag=!flag;
      _01.push_back(i);
    }
  }
  _01.push_back(S.size());
  _01.push_back(S.size());
  //最後が0と仮定というか
  if(_01.size()%2==0)_01.push_back(S.size());
  ll ma=0;
  //ll tsize= K*2+1;
  //if(tsize>_01.size()/2)tsize=_01.size()/2;
  //cout<<-tsize+1;
  if(K*2>=_01.size())K=_01.size()/2-1;
  for(int i=1;i<(int)_01.size()-K*2;i+=2){
    //cout<<"a"<<i;
    ll tmp = _01[i+K*2] - _01[i-1];
    if(ma<tmp)ma=tmp;
  }
  for(auto a: _01){
    //cout<<a<<endl;
  }
  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 1528
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define REP(i,n) for(int i=0;i<n;i++)
const ll maxn=100005;
const ll mod=1e9+7;


int main(){
	fast;
	int x;
	cin>>x;
	if(x==0)
		cout<<1;
	else
		cout<<0;
}





Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll n, a, b,c,d;
string s;
int main() {
	cin >>a>>b>>c>>d ;
	cout << (a - c) * (b - d)<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var m int
	fmt.Scan(&m)

	sumOfDigits := 0
	numberOfDigits := 0
	for i := 0; i < m; i++ {
		var d, c int
		fmt.Scan(&d, &c)
		sumOfDigits += d * c
		numberOfDigits += c
	}

	ans := 0
	ans += (sumOfDigits - 1) / 9
	ans += numberOfDigits - 1
	fmt.Println(ans)
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), K = input();
    vector< int > h(N);
    cin >> h;

    vector< int > dp(N, inf);
    dp[0] = 0;
    
    range(i, 1, N) {
        range(k, 1, K + 1) {
            if (i - k < 0) continue;
            chmin(dp[i], dp[i - k] + abs(h[i] - h[i - k]));
        }
    }
    
    cout << dp.back() << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1152
N=int(input())
X=list(map(int, input().split()))

ans=1
if 0 in X:
    print(0)
else:
    X.sort(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)    

Measured memory_bytes: 21572
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0])
    W = input[1].split(" ").map(str => parseInt(str, 10))
    var ans = 100000
    for(var t=1; t < N; t++){
        S1=0
        S2=0
        for(var i=1; i <= t; i++){
            S1 += W[i-1]
        }
        for(var i=t+1; i <= N; i++){
            S2 += W[i-1]
        }
        diff = Math.abs(S2-S1)
        if(ans > diff){
            ans = diff
        }
    }
    console.log(ans)
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("4\n1 3 1 1");

Measured memory_bytes: 21064
n = gets.to_i
arr = gets.chomp.split.map(&:to_i)

count = 0
swap = true
while swap
    swap = false
    (n - 1).downto(1){|j|
        if arr[j - 1] > arr[j]
            arr[j - 1], arr[j] = arr[j], arr[j - 1]
            swap = true
            count += 1
        end
    }
end
puts arr.join(" ")
puts count

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

#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

struct vec {
    double x, y;
    vec() : x(0), y(0) {}
    vec(double x, double y) : x(x), y(y) {}

    double len() const {
        return sqrt(pow(this->x,2.0) + pow(this->y,2.0));
    }

    vec& operator+=(const vec a) {
        this->x += a.x;
        this->y += a.y;
        return *this;
    }
    vec operator+(const vec a) const {
        vec res(*this);
        return res += a;
    }
    double angle() const {
        return atan2(this->x, this->y);
    }
    bool operator>(const vec a) const {
        return this->angle() > a.angle();
    }
    bool operator<(const vec a) const {
        return this->angle() < a.angle();
    }
};
using vv = vector<vec>;
using vvv = vector<vv>;

int main() {
    int N; cin >> N;
    vv v(N);
    rep(i,N) {
        double x, y; cin >> x >> y;
        v[i] = vec(x, y);
    }

    sort(v.begin(), v.end());
    double ans = 0;
    rng(k,1,N+1) rep(i,N) {
        vec sum;
        rng(j,i,i+k) {
            sum += v[j%N];
        }
        chmax(ans, sum.len());
    }

    printf("%.12lf\n", ans);
    return 0;
}


Measured memory_bytes: 768
H1, M1, H2, M2, K = map(int, input().split())
H = H2 - H1
M = 0

if M2 - M1 >= 0:
  M = M2 - M1
else:
  M = M2 - M1 + 60
  H -= 1
  
ans = H*60 + M - K

print(ans)

Measured memory_bytes: 9176
O = input()
E = input()

ans = ''

if len(O) == len(E):
   for i in range(len(O)):
      ans += O[i]
      ans += E[i]
else:
   for i in range(len(E)):
      ans += O[i]
      ans += E[i]
   ans += O[-1]

print(ans)

Measured memory_bytes: 9060
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[]p = new int[n + 1];
		int[][]m = new int[n + 1][n + 1];
		for(int i = 0; i < n; i++) {
			int r = scan.nextInt();
			int c = scan.nextInt();
			p[i] = r;
			p[i + 1] = c;
		}
		scan.close();
		for(int l = 2; l <= n; l++) {
			for(int i = 1; i <= n - l + 1; i++) {
				int j = i + l - 1;
				m[i][j] = (1 << 21);
				for(int k = i; k <= j - 1; k++) {
					m[i][j] = Math.min(m[i][j],
							+ m[i][k] + m[j][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
				}
			}
		}
		System.out.println(m[1][n]);
	}
}


Measured memory_bytes: 26580