akhauriyash/Code-Regression huggingface dataset:
// E - Common Subsequence
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n, m;
	cin >> n >> m;
	vector<int> s(n), t(m);
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < m; i++) cin >> t[i];

	vector<vector<long long> > dp(n + 1, vector<long long>(m + 1));
	for (int i = 0; i <= n; i++) dp[i][0] = 1;
	for (int i = 0; i <= m; i++) dp[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + MOD) % MOD;
			if (s[i - 1] == t[j - 1]) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
		}
	}

	cout << dp[n][m] << endl;

	return 0;
}


Measured memory_bytes: 31616
/**
 * Header Files
 */
#include <bits/stdc++.h>

/**
 * Namespace declaration
 */
using namespace std;

int main(void){

    string s;
    cin >> s;

    string resultNext;

    if(s == "Sunny"){
        resultNext = "Cloudy";
    }
    else if(s =="Cloudy"){
        resultNext = "Rainy";
    }else{
        resultNext = "Sunny";
    }

    cout << resultNext;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    string s,t;
    cin >> N;
    cin >> s >> t;
    RREP(i,N+1){
        string u=s.substr(N-i,i);
        string v=t.substr(0,i);
        if(u==v){
            cout << 2*N-i << endl;
            return 0;
        }
        
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
	
    public static void main(String[] args) {
		OriginScanner os = new OriginScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		String s = os.next();
		boolean isNo = false;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if ((i + 1) % 2 == 0) {
				if (c == 'R') {
					isNo = true;
					break;
				}
			}
			else {
				if (c == 'L') {
					isNo = true;
					break;
				}
			}
		}
		if (isNo) pw.println("No");
		else pw.println("Yes");
		pw.close();
	}
    
	static class OriginScanner {
		StringTokenizer token;
		BufferedReader br;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		
		String next() {
			while (token == null || !token.hasMoreElements()) { 
				token = new StringTokenizer(nextLine());
			}
			return token.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k, ans;

int main() {
	cin >> n >> k;
	if(k%2 == 1){
		ll m = n/k;
		ans = m*m*m;
	}
	if(k%2 == 0){
		ll e = n/k;
		ll o = (n%k >= k/2)? n/k+1 : n/k;
		ans = e*e*e + o*o*o;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(int argc, char const* argv[])
{
    double n, t, a;
    std::cin >> n >> t >> a;

    double diff = std::numeric_limits<double>::max();
    auto result = 0;

    for (int i = 0; i < n; ++i) {
        double h;
        std::cin >> h;
        double tmp = t - h * 0.006;
        double abs_val = std::abs(tmp - a);
        if (abs_val < diff) {
            result = i;
            diff = abs_val;
        }
        /* std::cout << tmp - a << " " << abs_val << " " << diff << std::endl; */
    }

    std::cout << result + 1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

ans = str()
if a == 1 or b == 1:
    if a == 1 and b == 1:
        ans = "Draw"
    elif a == 1:
        ans = "Alice"
    elif b == 1:
        ans = "Bob"
else:
    if a > b:
        ans = "Alice"
    elif b > a:
        ans = "Bob"
    else:
        ans = "Draw"

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

namespace std
{
    class Test {
        static void Main(string[] args) {
            List<int> ary = new List<int>();
            var num = Console.ReadLine();
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(num);
            for (int i = 0; i< n; i++) {
                var inp = int.Parse(input[i]);
                ary.Add(inp);
            }
            Test obj = new Test();
            obj.selectionSort(ary, n);   
        }

        public void selectionSort(List<int> ary, int num) {
        
            int  i, j, tmp, minj, cnt = 0;
       
            for( i = 0; i < num; i++) {
               minj = i;
               for( j = i; j < num; j++) {
                 if (ary[j] < ary[minj])  minj = j;
               }
                // swap 　ary[i] と ary[minj]
                tmp = ary[i];
                ary[i] = ary[minj];
                ary[minj] = tmp;
                if(i != minj) cnt++;
                  
            }    
            for  (i = 0; i < num; i++) {
                Console.Write(ary[i]);
               if(i < num-1) Console.Write(" ");              
            }
            Console.WriteLine("");
               Console.Write(cnt);
               Console.WriteLine("");
        }
    }
}




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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

int n;

ll f[N], dp[N];

int h[N], a[N];

void upd(int pos, ll x) {
	for (int i = pos; i <= n; i += (i & -i)) f[i] = max(f[i], x);
}

ll get(int pos) {
	ll ret = 0;
	for (int i = pos; i > 0; i -= (i & -i)) ret = max(ret, f[i]);
	return ret;
}

int main() {
	FREOPEN();
	cin >> n;
	for (int i = 1; i <= n; i++) scanf("%d ", &h[i]);
	for (int i = 1; i <= n; i++) scanf("%d ", &a[i]);
	for (int i = 1; i <= n; i++) {
		dp[i] = get(h[i] - 1) + a[i];
		upd(h[i], dp[i]);
	}
	printf("%lld", get(n));
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int C[501]={0};
    int S[501]={0};
    int F[501]={0};
    for(int i=0; i<N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i=0; i<N; i++){
        int t = 0;
        for(int j=i; j<N-1; j++){
            if(t<S[j]) t = S[j];    // 次の列車はj番目の駅の始発なので待つ
            else if(t%F[j]==0);     // 即乗り換え可能
            else t=t+F[j]-t%F[j];   // 次の列車は F[j] - t%F[j] 秒後
            t += C[j];
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
task = [list(map(int, input().split())) for _ in range(n)]
task.sort(key=itemgetter(1))
time = 0
flag = 0
for i in range(n):
    time += task[i][0]
    if time > task[i][1]:
        flag = 1
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 53732
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long[] S = new long[n];
        for (int i = 0; i < n; i++) S[i] = Integer.parseInt(sc.next());
        int cnt = 0;
        int q = Integer.parseInt(sc.next());
        for (int i = 0; i < q; i++) {
            long T = Integer.parseInt(sc.next());
            if (search(S, n, T)) cnt++;
        }
        System.out.println(cnt);
    }

    private static boolean search(long[] A, int n, long key) {
        long[] copy = Arrays.copyOf(A, n+1);
        copy[n] = key;
        int i = 0;
        while(copy[i] != key) i++;
        return i != n;
    }
}



Measured memory_bytes: 46880
N = int(input())
p = tuple(int(x) for x in input().split())
q = tuple(int(x) for x in input().split())
r = []
a=0
c1 =0
c2 =0
import itertools

def for_factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
    return val

a =for_factorial(N)

r =list(itertools.permutations(range(1,N+1)))
for i in range(a):
    if p == r[i]:
        c1 = i+1

for i in range(a):
    if q == r[i]:
        c2 = i+1

if c1 >= c2:
    print(c1-c2)
else:
    print(c2-c1)


Measured memory_bytes: 45040
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }
 
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}
 
struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};
 
vector<int> solve(ll K, ll N) {
  if (K == 1) {
    return vector<int>((N + 1) / 2, 1);
  }
  if (K % 2 == 0) {
    vector<int> res(N);
    REP(i,N) res[i] = K;
    res[0] = K / 2;
    return res;
  }
  vector<int> res(N);
  REP(i,N) res[i] = (K + 1) / 2;
  REP(loop,N/2) {
    for (int i = N - 1; i >= 0; --i) {
      if (res[i] == 0) continue;
      if (res[i] == 1) { res[i] = 0; break; }
      res[i] = res[i] - 1;
      for (int j = i + 1; j < N; ++j) res[j] = K;
      break;
    }
  }
  while (res.back() == 0) res.pop_back();
  return res;
}
 
vector<vector<int>> all(ll K, ll N) {
  vector<vector<int>> res;
  REP(i,K) res.push_back(vector<int>(1, i + 1));
  if (N == 1) return res;
  auto vec = all(K, N - 1);
  REP(i,K) {
    auto vec2 = vec;
    for (auto &v: vec2) {
      v.push_back(i + 1);
      res.push_back(v);
    }
  }
  return res;
}
 
vector<int> solve2(ll K, ll N) {
  auto vec = all(K, N);
  sort(ALL(vec));
  // for (auto &v: vec) {
  //   for (int i: v) cout << i << " ";
  //   cout << endl;
  // }
  const int m = vec.size();
  return vec[(m + 1) / 2 - 1];
}
 
int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll K;
	ll N;
  // REP(K_,5) REP(N_,10) {
  //   K = K_ + 1; N = N_ + 1;
  //   // if (K % 2 == 0) continue;
  //   cout << K << " " << N << endl;
  //   vector<int> res = solve(K, N);
  //   for (int i: res) cout << i << " ";
  //   cout << endl;
  //   vector<int> res2 = solve2(K, N);
  //   for (int i: res2) cout << i << " ";
  //   cout << endl;
  //   assert (res == res2);
  //   cout << "ok" << endl;
  // }
	scanf("%lld", &K);
	scanf("%lld", &N);
  vector<int> res = solve(K, N);
  const int n = res.size();
  REP(i,n) cout << res[i] << " \n"[i == n - 1];
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

long long modpow(long long a, long long n, long long mod){
  long long res = 1;
  while(n > 0){
    //nを２進数に分解してビットの立っているところだけ掛け算していく。
    if (n &  1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a inverse (mod m)
// a^(-1) = a^(p-2) (mod p)
long long modinv(long long a, long long mod){
  return modpow(a, mod-2, mod);
}

const int max_fac = 2 * 1e6;
long long fac[max_fac], finv[max_fac], inv[max_fac];
void ComInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_fac; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long Comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ComInit();
  int x,y;
  cin >> x >> y;

  int cnt_1 = 0;
  long long ans = 0;
  bool flag = 0;
  while(!flag){
    long long cur_x = cnt_1;
    long long cur_y = 2 * cnt_1;
    if(cur_x > x || cur_y > y) break;
    long long res_x = x - cur_x;
    long long res_y = y - cur_y;
    // cout << "now (x,y) = " << cur_x << ", " << cur_y << endl;
    // cout << "rest (x,y) = " << res_x << ", " << res_y << endl;
    if(res_y * 2 == res_x){
      // can be reached
      // cout << "can be reached " << endl;
      int cnt_2 = res_y;
      // cout << "cnt1 = " << cnt_1 << ", cnt2 = " << cnt_2 << endl;
      ans += Comb(cnt_1+cnt_2, cnt_1);
      ans %= MOD;
    }
    cnt_1 ++;
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 50512
#include <iostream>
#include <string.h>
#include <stdio.h>
#define ll long long
#define re register
#define IL inline
using namespace std;
const int maxn=3e3+5;
template<typename T> void fread(T &x){
	T f=1;x=0;
	char s=getchar();
	while(s<'0' || s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0' && s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();}
	x*=f;
}
string sa,sb;
int dp[maxn][maxn];
int memory[maxn][maxn];
char goal[maxn];
int cnt=0;
void dfs(int x,int y){
	if(memory[x][y]==1){
		dfs(x-1,y-1);
		cout<<sa[x-1];
	} 
	if(memory[x][y]==2){
		dfs(x-1,y);
	}
	if(memory[x][y]==3){
		dfs(x,y-1);
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>sa;
	cin>>sb;
	for(re int i=1;i<=sa.size();i++){
		for(re int j=1;j<=sb.size();j++){
			if(sa[i-1]==sb[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
				memory[i][j]=1;
			}
			else{
				if(dp[i-1][j]>dp[i][j-1]){
					dp[i][j]=dp[i-1][j];
					memory[i][j]=2;
				}
				else{
					dp[i][j]=dp[i][j-1];
					memory[i][j]=3;
				}
			} 
		}	
	}
	dfs(sa.size(),sb.size());
	return 0;
}


Measured memory_bytes: 74408
#include <bits/stdc++.h>
//#define DEBUG
#define REP( i , nn ) for(int i = 0 ; i < (int) nn; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

constexpr int maxV = 1e4;

void solve(){
    int a, b;
    cin >> a >> b;
    int ans;
    for( ans = 0 ; ans <= maxV ; ans++){
        if( ans * 8 / 100 == a && ans / 10 == b){
            break;
        }
    }
    if( ans <= maxV){
        cout << ans << "\n";
    }else{
        cout << "-1";
    }
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3636
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	string box = "MARCH";
	vector<long long int>v(5);
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < 5; j++) {
			if (s[0] == box[j]) {
				v[j]++;
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += v[i] * v[j] * v[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<?php

$ope = explode(',', '+,-,*,/');
while (($line = trim(fgets(STDIN))) !== '') {
    $stack = new \SplStack();
    foreach (explode(' ', $line) as $v) {
        if (!in_array($v, $ope)) {
            $stack[] = (float)$v;
            continue;
        }

        $b = $stack->pop();
        $a = $stack->pop();
        if ($v === $ope[0]) {
            $stack[] = $a + $b;
        } elseif ($v === $ope[1]) {
            $stack[] = $a - $b;
        } elseif ($v === $ope[2]) {
            $stack[] = $a * $b;
        } else {
            $stack[] = $a / $b;
        }
    }
    printf("%f\n", $stack->pop());
}

Measured memory_bytes: 6680
import sys
import numpy as np
from heapq import heappush, heappop


def main():
    x, y, z, K = map(int, sys.stdin.readline().split())
    abc = np.array(sys.stdin.read().split(), dtype=np.int64)
    a = abc[:x]
    b = abc[x:x + y]
    c = abc[x + y:x + y+ z]
    a = np.sort(a)[::-1]
    b = np.sort(b)[::-1]
    c = np.sort(c)[::-1]

    hq = []
    heappush(hq, (-(a[0]+b[0]+c[0]), 0, 0, 0))
    res = []
    added_before = set()
    # setで確認をO(1)でする
    added_before.add((0, 0, 0))

    for _ in range(K):
        sum_deli, i, j, k = heappop(hq)
        res.append(-sum_deli)
        if i < x - 1 and not (i+1, j, k) in added_before:
            heappush(hq, (-(a[i+1]+b[j]+c[k]), i+1, j, k))
            added_before.add((i+1, j, k))
        if j < y - 1 and not (i, j+1, k) in added_before:
            heappush(hq, (-(a[i]+b[j+1]+c[k]), i, j+1, k))
            added_before.add((i, j+1, k))
        if k < z - 1 and not (i, j, k+1) in added_before:
            heappush(hq, (-(a[i]+b[j]+c[k+1]), i, j, k+1))
            added_before.add((i, j, k+1))

    for s_deli in res:
        print(s_deli)

if __name__ == "__main__":
    main()


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


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

   int n,m;
   cin>>n>>m;
   vector< pair<int,int> > v(m);
   for(int i=0;i<m;i++)
   {
   	   cin>>v[i].first>>v[i].second;
   }
   ll st[n+2];
   ll ed[n+2];
   ll cm[n+2];

   memset(st,0,sizeof(st));
   memset(ed,0,sizeof(ed));
   cm[0]=0;

   for(int i=0;i<m;i++)
   {
   	    int f=v[i].first;
   	    int s=v[i].second;
   	    st[f]++;
   	    ed[s+1]++;        
   }
   
   int ct=0;
   for(int i=1;i<=n;i++)
   {
   	  cm[i]=cm[i-1]+st[i]-ed[i];
   //  cout<<cm[i]<<" ";
   	  if(cm[i]==m){ct++;}
   }

   cout<<ct<<endl;
}

Measured memory_bytes: 3456
//#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define ALL(a)					(a).begin(),(a).end()
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b) 
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

/* 最小公倍数 */
ll lcm(ll a, ll b) 
{
	ll gcdRes = gcd(a, b);
	return (a * (b / gcdRes));
}

int main()
{
	int N;
	cin >> N;
	cout << lcm(N, 2) << endl;
	return 0;
}



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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

int main()
{
   int N; cin>>N;
   string s; cin>>s;

   vector<vector<mint>> dp(N+1,vector<mint>(N));
   for(int i=1;i<=N;i++) dp[1][i-1]=1;
   for(int i=1;i<N;i++){
      for(int j=0;j<=N-i;j++){
         if(s[i-1]=='>'){
            if(j==0) continue;
            int L=0,R=j-1;
            dp[i+1][L]+=dp[i][j];
            dp[i+1][R+1]-=dp[i][j];
         }else{
            if(N-i-j==0) continue;
            int L=j,R=N-i-1;
            dp[i+1][L]+=dp[i][j];
            dp[i+1][R+1]-=dp[i][j];
         }
      }
      for(int j=1;j<N;j++) dp[i+1][j]+=dp[i+1][j-1];
   }
   cout<<dp[N][0].value()<<endl;
   return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void read(i64 &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=2005;
i64 a[maxn],n,k;
i64 v[maxn];
int main(){
	read(n);read(k);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)v[i]=a[i];
	i64 res=1ll<<60;
	rep(t,1,n){
		i64 tot=(t-1)*k;
		rep(i,1,n)tot+=v[i];
		res=min(res,tot);
		rep(i,1,n){
			v[i]=min(v[i],a[(i-t+n-1)%n+1]);
		}
	}cout<<res;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        Program pg = new Program();
        pg.Exe();
    }

    public void Exe()
    {
        long input = long.Parse(Console.ReadLine());
        string ans = "";
        int div = 26;
        long div_ans = 0;
        long mod_ans = 0;
        int ascii = 96;
        char c = '\0';
        while(true)
        {
            mod_ans = input % div;
            div_ans = input / div;
            //zの桁処理
            if(mod_ans == 0)
            {
                mod_ans = 26;
                div_ans -= 1;
            }
            //終了条件
            if(div_ans == 0)
            {
                c = (char)(mod_ans + ascii);
                //Console.WriteLine($"c:{c} mod_ans:{mod_ans} div_ans:{div_ans}");
                ans += c;
                break;
            }
            
            c = (char)(mod_ans + ascii);
            //Console.WriteLine($"c:{c} mod_ans:{mod_ans} div_ans:{div_ans}");
            ans += c;
            input = div_ans;
        }
        //Console.WriteLine($"not reverse ans:{ans}");
        
        //文字列の反転処理
        ans = string.Join("",ans.Reverse());
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 28300
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 300005;

template<class T>
struct segment_tree {
    using F = function<T(T,T)>;
    int n;     
    vector<T> data;
    F f;
    T init_v;

    segment_tree(int n_, T init_v, F f) : f(f), init_v(init_v) {
        n = 1;
        while (n < n_) n *= 2;
        data.assign(2*n-1,init_v);
    }

    //kをaに変更
    void update(int k, T a) {
        k += n-1;
        data[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = f(data[k*2+1],data[k*2+2]);
        }
    }

    //[a,b)のquery,kは節点番号
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return data[k];
        else {
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T operator[](int a) {return data[a+n-1];}

    //[a,b)を出力
    void debug_seg(int a, int b) {
        a += n-1; b += n-1;
        for (int i = a; i < b; i++) {
            cout << data[i] << " ";
        }
        cout << endl;
    }
};

int dp[MAX];

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    auto f = [](int a, int b) {return max(a, b);};
    segment_tree<int> st(MAX, 0, f);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int l = max(a[i-1] - k, 0);
        int r = a[i-1] + k;
        dp[i] = st.query(l, r + 1) + 1;
        chmax(ans,dp[i]);
        st.update(a[i-1], dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9536
n,m,x,y=map(int,input().split())
ans=0
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(x+1,y+1):
    if max(a)<i<=min(b) and x<i<=y:
        ans+=1
if ans>=1:
    print('No War')
else:
    print('War')

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

int main() {
  
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if ( (A + B) > (C + D) ) cout << "Left" << endl;  
  else if ( (A + B) == (C + D) ) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<int> Node;
typedef vector<Node> Graph;
int V1, V2;
Graph G;
int dist[1002];
int match[1002];
const int NIL = 1001;
bool BFS(){
  queue<int> que;
  REP(v, V1){
    if(match[v] == NIL){
      dist[v] = 0;
      que.push(v);
    }else{
      dist[v] = INF;
    }
  }
  dist[NIL] = INF;
  while(!que.empty()){
    int v = que.front(); que.pop();
    if(dist[v] < dist[NIL]){
      for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i];
        if(dist[match[u]] == INF){
          dist[match[u]] = dist[v] + 1;
          que.push(match[u]);
        }
      }
    }
  }
  return dist[NIL] != INF;
}

bool DFS(int v){
  if(v != NIL){
    for(int i = 0; i < G[v].size(); i++){
      int u = G[v][i];
      if(dist[match[u]] == dist[v] + 1 && DFS(match[u])){
        match[u] = v;
        match[v] = u;
        return true;
      }
    }
    dist[v] = INF;
    return false;
  }
  return true;
}

int Hopcroft_Karp(){
  REP(v, G.size()) match[v] = NIL;
  int matching = 0;
  while(BFS()){
    REP(v, V1){
      if(match[v] == NIL && DFS(v)){
        matching ++;
      }
    }
  }
  return matching;
}
int main(){
  while(scanf("%d %d", &V1, &V2) && (V1 != 0 || V2 != 0)){
    G = Graph(V1 + V2);
    static int blue[500];
    static int red[500];
    REP(i, V1) scanf("%d", blue + i);
    REP(i, V2) scanf("%d", red + i);
    REP(u, V1) REP(v, V2){
      if(__gcd(blue[u], red[v]) != 1) {
        G[u].push_back(V1 + v);
        //G[V1 + v].push_back(u);
      }
    }
    printf("%d\n", Hopcroft_Karp());
  }
  return 0;
}

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


int initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

#define false 0
#define true 1
#define MAX 199

int top=0;
int S[MAX];

int main(){
  int x,y,pl,mi,ka;
  char s[MAX];
 
  while( scanf("%s",s) != EOF ){
    
    if ( s[0] == '+' ){
      pl = pop() + pop();          
      push(pl);     
    }
    
    else if ( s[0] == '-' ){
      x = pop();
      y = pop(); 
      mi= y-x;            
      push(mi);     
    }
    
    else if ( s[0] == '*' ){
      ka =  pop() * pop();    
      push(ka);
    }
    
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}

int initialize(void){
  return top=0;
}

int isEmpty(void){
  if(top==0) return true;
  else return false;
}

int isFull(void){
  if(top >= MAX - 1) return true;
  else return false;
}

void push(x){
  if(isFull() == true) exit(1);
  top++;
  S[top] = x;
}

int pop(void){
  if(isEmpty() == true) exit(1);
  top--;
  return S[top+1];
}
  
  



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

int main(){
  long int N;
  vector<long int> v;
  cin >> N;
  for(long int i=1;i*i<=N;i+=1){
    if(N % i == 0){
      v.push_back(i);
    }
  }
  long int min = v[0] - 1 + N / v[0] - 1;
  for(long int i=0;i< v.size();i++){
    long int tmp1 = v[i] - 1;
    long int tmp2 = N / v[i] - 1;
    
    if(min > tmp1 + tmp2){
      min = tmp1 + tmp2;
    }
  }

  cout << min << endl;
		  
  return 0;
}


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

int main()
{
  int N, A;
  cin >> N >> A;
  N = N % 500;
  if (N <= A)
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var s string
	fmt.Fscan(read, &s)

	mp := make(map[rune]int)
	for _, v := range s {
		mp[v]++
	}

	ans := "Yes"
	for _, v := range mp {
		if v != 2 {
			ans = "No"
		}
	}
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 640
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));
        int n = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");
 
        for (int i = 1; i < n; i++) {
            System.out.println(String.join(" ", array));
            for (int j = i - 1; j >= 0; j--) {
                if (Integer.parseInt(array[j]) > Integer.parseInt(array[j + 1])) {
                    String tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                }
            }
        }
        System.out.println(String.join(" ", array));
    }
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> wcnt(n+1,0), ecnt(n+1,0);
    for(int i=0;i<n;i++){
        if(s[i] == 'W') wcnt[i+1]++;
        wcnt[i+1] += wcnt[i];
    }
    for(int i=n-1;i>0;i--){
        if(s[i] == 'E') ecnt[i-1]++;
        ecnt[i-1] += ecnt[i];
    }
    int ans = n+1;
    for(int i=0;i<n;i++){
        ans = min(ans, wcnt[i] + ecnt[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 200005;
typedef long long ll;
vector<pair<ll,ll> >s[MAXN],a,b;
struct Edge{
	int to,next,w;
}e[MAXN<<1];
int n,head[MAXN],cnt;
inline void insert(int u,int v,int w)
{
	e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt,e[cnt].w=w;
	e[++cnt].to=u,e[cnt].next=head[v],head[v]=cnt,e[cnt].w=w;
}
inline void add(vector<pair<ll,ll> >&x,pair<ll,ll>a)
{
	if(x.size() && a.second>=x.back().second)return;
	while(x.size() && x.back().first==a.first && x.back().second>=a.second)x.pop_back();
	x.push_back(a);
}
int dfs(int x,int fa,ll mid)
{
	int v1=0,v2=0,w1=0,w2=0;
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa)continue;
		if(!v1)v1=v,w1=e[i].w;
		else v2=v,w2=e[i].w;
		if(!dfs(v,x,mid))return 0;
	}
	s[x].clear();
	if(v1){
		if(!s[v1].size() || !s[v2].size())return 0;
		if(s[v1].size()>s[v2].size())swap(v1,v2),swap(w1,w2);
		a.clear(),b.clear();
		int p=0;
		for(int i=0;i<s[v1].size();++i){
			while(p<s[v2].size() && s[v1][i].first+s[v2][p].second+w1+w2>mid)++p;
			if(p>=s[v2].size())break;
			else{
				a.push_back(make_pair(s[v1][i].second+w1,s[v2][p].first+w2));
			}
		}
		p=0;
		for(int i=0;i<s[v1].size();++i){
			while(p+1<s[v2].size() && s[v1][i].second+s[v2][p+1].first+w1+w2<=mid)++p;
			if(s[v1][i].second+s[v2][p].first+w1+w2<=mid){
				b.push_back(make_pair(s[v2][p].second+w2,s[v1][i].first+w1));
			}
		}
		int p1=a.size()-1,p2=b.size()-1;
		while(p1>=0 && p2>=0){
			if(a[p1].first<=b[p2].first)add(s[x],a[p1]),--p1;
			else add(s[x],b[p2]),--p2;
		}
		while(p1>=0)add(s[x],a[p1]),--p1;
		while(p2>=0)add(s[x],b[p2]),--p2;
	}else{
		s[x].push_back(make_pair(0,0));
	}
	return s[x].size();
}
ll sum=0;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i){
		int f,w;
		scanf("%d%d",&f,&w),sum+=w;
		insert(f,i,w);
	}
	ll l=0,r=sum,mid,ans=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(dfs(1,0,mid))r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 34012
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll w, h, n;
  cin >> w >> h >> n;
  ll W = 0, H = 0;
  for (ll i = 0; i < n; i++) {
    ll x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      if (W < x) W = x;
    }
    if (a == 2) {
      if (w > x) w = x;
    }
    if (a == 3) {
      if (H < y) H = y;
    }
    if (a == 4) {
      if (h > y) h = y;
    }
  }
  if ((w-W)< 0 || (h-H) < 0) {
    cout << 0 << '\n';
    return 0;
  }
  cout << (w-W)*(h-H) << '\n';
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var d = ria();
		Console.WriteLine(d[2] >= d[0] && d[2] <= d[1] ? "Yes" : "No");
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
use proconio::marker::Chars;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: u32, s: Chars};
    let a = 'A' as u32;

    println!(
        "{}",
        s.iter()
            .map(|&x| std::char::from_u32((x as u32 - a + n) % 26 + a).unwrap())
            .collect::<String>()
    )
}


Measured memory_bytes: 2232
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int N,M;
    cin >> N >> M;
    int ans = N *( N - 1)/2 + M *( M - 1)/2;
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

long long solve(const vector<vector<pair<long long, long long> > >& v, long long t)
{
    vector<pair<long long, long long> > ans(2, {INF, -INF});
    for(int i=0; i<2; ++i){
        for(int d=-1; d<=1; ++d){
            if(v[i][d+1].first == INF)
                continue;
            ans[i].first  = min(ans[i].first,  v[i][d+1].first  + d * t);
            ans[i].second = max(ans[i].second, v[i][d+1].second + d * t);
        }
    }
    return (ans[0].second - ans[0].first) * (ans[1].second - ans[1].first);
}

int main()
{
    int n;
    cin >> n;
    vector<vector<pair<long long, long long> > > v(2, vector<pair<long long, long long> >(3, {INF, -INF}));
    for(int i=0; i<n; ++i){
        long long x, y;
        char d;
        cin >> x >> y >> d;
        x *= 2;
        y *= 2;

        int dx = 0;
        int dy = 0;
        if(d == 'L')
            dx = -1;
        else if(d == 'R')
            dx = 1;
        else if(d == 'D')
            dy = -1;
        else
            dy = 1;

        v[0][dx+1].first  = min(v[0][dx+1].first,  x);
        v[0][dx+1].second = max(v[0][dx+1].second, x);
        v[1][dy+1].first  = min(v[1][dy+1].first,  y);
        v[1][dy+1].second = max(v[1][dy+1].second, y);
    }

    long long ans = solve(v, 0);
    for(int i=0; i<2; ++i){
        for(int d1=-1; d1<=1; ++d1){
            for(int d2=-1; d2<=1; ++d2){
                if(d1 == d2 || v[i][d1+1].first == INF || v[i][d2+1].first == INF)
                    continue;

                long long t1 = (v[i][d2+1].first - v[i][d1+1].first) / (d1 - d2);
                if(t1 >= 0)
                    ans = min(ans, solve(v, t1));

                long long t2 = (v[i][d2+1].second - v[i][d1+1].second) / (d1 - d2);
                if(t2 >= 0)
                    ans = min(ans, solve(v, t2));
            }
        }
    }
    printf("%.2f\n", ans / 4.0);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}

int n,m,d[100010];
vector<edge>v[100010];
void dijkstra(){
	fill(d,d+n,INF);
	priority_queue<P,vector<P>,greater<P>>q;
	d[0]=0;
	q.push({0,0});
	while(!q.empty()){
		P p=q.top();
		q.pop();
		for(edge e:v[p.se]){
			if(d[e.to]>p.fi+e.cost){
				d[e.to]=p.fi+e.cost;
				q.push({d[e.to],e.to});
			}
		}
	}
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		v[a].pb({b,c});
	}
	rep(i,n-1)v[i+1].pb({i,0});
	dijkstra();
	cout<<(d[n-1]==INF?-1:d[n-1])<<endl;
	return 0;
}


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

using namespace std;

int main(void) {
    string c;
    cin >> c;
    if (c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o')
      cout << "vowel" << endl;
    else cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	list<int>v;
	int a,b,n;cin>>n;
	list<int>::iterator c=v.end();
	while(n--){
		cin>>a;
		if(a==0){
			cin>>b;
			c=v.insert(c,b);
		}else if(a==1){
			cin>>b;
			if(b>0)while(b--)c++;
			else while(b++)c--;
		}else c=v.erase(c);
	}
	for(c=v.begin();c!=v.end();c++)cout<<*c<<"\n";
	return 0;
}


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

using namespace std;

typedef long long ll;

constexpr int MOD = 1000000007;
constexpr char nl = '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int N, K;
  cin >> N >> K;
  ll sum = 0;
  for (ll k = K; k <= N + 1; k++) {
    ll min_sum = (k - 1) * k / 2;
    ll max_sum = (N - (k - 1) + N) * k / 2;
    sum += max_sum - min_sum + 1;
    // cerr << max_sum << ":" << min_sum << nl;
  }
  cout << sum % MOD << nl;
  return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

const int nmax = 8;
//vector<vector<bool>> graph;
array<array<bool, nmax>, nmax> graph;

int dfs(int v, int n, array<bool, nmax> visited)
{
	bool all_visited = true;

	REP(i, n)
	{
		if (visited[i] == false) all_visited = false;
	}

	if (all_visited) return 1;

	int ret = 0;

	REP(i, n)
	{
		if (graph[v][i] == false) continue;
		if (visited[i]) continue;

		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}

	return ret;
}

int main()
{
	int n, m;
	//cin >> n, m;
	scanf("%d%d", &n, &m);

	for (int i = 0; i < m; i++)//REP(i, m)
	{
		int A, B;
		//cin >> A >> B;
		scanf("%d%d", &A, &B);
		graph[A - 1][B - 1] = true;
		graph[B - 1][A - 1] = true;
	}

	array<bool, nmax> visited;
	REP(i, n)
		visited[i] = false;

	visited[0] = true;
	//cout << dfs(0, n, visited) << endl;
	printf("%d\n", dfs(0, n, visited));
}

Measured memory_bytes: 256