akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Stack;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if ((H | W) == 0) {
				return;
			}
			char map[][] = new char[H][W];
			int cnt[][] = new int[H][W + 1];
			for (int i = 0; i < H; i++) {
				String line = sc.next();
				for (int j = 0; j < W; j++) {
					map[i][j] = line.charAt(j);
					if (map[i][j] == '.') {
						cnt[i][j] = 1;
					}
				}
				cnt[i][W] = 0;
			}
			for (int i = 1; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (map[i][j] == '.') {
						cnt[i][j] = cnt[i - 1][j] + 1;
					}
				}
			}
			Stack<Rect> stack = new Stack<Rect>();
			int max = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j <= W; j++) {
					Rect rect = new Rect(cnt[i][j], j);
					if (stack.isEmpty() || stack.peek().height < cnt[i][j]) {
						stack.push(rect);
					} else if (stack.peek().height > cnt[i][j]) {
						int last = -1;
						while (!stack.isEmpty()
								&& stack.peek().height > cnt[i][j]) {
							Rect pre = stack.pop();
							max = Math.max(max, pre.height * (j - pre.pos));
							last = pre.pos;
						}
						rect.pos = last;
						stack.push(rect);
					}
				}
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	class Rect {
		int height;
		int pos;

		Rect(int height, int pos) {
			this.height = height;
			this.pos = pos;
		}
	}
}

Measured memory_bytes: 42992
import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)

Measured memory_bytes: 5232
#include <iostream>

using namespace std;

char table[5][6] = {

  {'a','f','k','p','u','z'},
  {'b','g','l','q','v','.'},
  {'c','h','m','r','w','?'},
  {'d','i','n','s','x','!'},
  {'e','j','o','t','y',' '}

};

int main() {

  string buf;


  while(getline(cin,buf)) {

    if(buf.size()%2==1) goto NA;

    for(int i=0;i<buf.size();i++) {

      if(i%2==0 && ((buf[i]-'0')<1 || (buf[i]-'0')>6)) goto NA;

      if(i%2==1 && ((buf[i]-'0')<1 || (buf[i]-'0')>5)) goto NA;

    }

    for(int i=0;i<buf.size()/2;i++) {

      cout << table[(buf[2*i+1]-'0'-1)][(buf[2*i]-'0'-1)];

    }

    cout << endl;

    continue;


  NA:
    cout << "NA" << endl;

  }

  return 0;

}

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

int main() {
  char c;
  cin >> c;

  if(c == 'a'){
    cout << "vowel" << endl;
  }else if(c == 'e'){
    cout << "vowel" << endl;
  }else if(c == 'i'){
    cout << "vowel" << endl;
  }else if(c == 'o'){
    cout << "vowel" << endl;
  }else if(c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


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

using namespace std;
int main(int argc, char *argv[]) {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	
	if (a1 + a2 + a3 <= 21) {
		cout << "win" << endl;
	} else {
		cout << "bust" << endl;
	}
}

Measured memory_bytes: 256
N=gets.to_i
m=Array.new(N+1){Array.new}
(N-1).times{
    a,b,c=gets.split.map(&:to_i)
    m[a] << [b,c]
    m[b] << [a,c]
}
Q,K=gets.split.map(&:to_i)
d=Array.new(N+1)
d[K]=0
q=[K]
until q.empty?
    n=q.shift
    m[n].each{|nn,c|
        next if d[nn]
        d[nn]=d[n]+c
        q<<nn
    }
end
#warn d.inspect
Q.times{
    x,y=gets.split.map(&:to_i)
    puts d[x]+d[y]
}


Measured memory_bytes: 34220
n,k,s = map(int,input().split())
ans = []
for i in range(k):
  ans.append(str(s))
  
for j in range(n-k):
  if s != 1:
    ans.append(str(s-1))
  else:
    ans.append(str(s+1))
print(' '.join(ans))

Measured memory_bytes: 18364
import sys

sys.setrecursionlimit(10**6)

N,M = map(int,input().split())

E_list = [[]for i in range(N)]

marks = [False for i in range(N)]
m = 1
def dfs(n):
    global E_list
    global marks
    global N,M

    marks[n] = True

    steps = 1

    for nx in E_list[n]:
        if not marks[nx]:
            marks[nx] = True
            steps += dfs(nx)
    
    return steps



for i in range(M):
    e1,e2 = map(int, input().split())
   
    E_list[e1-1].append(e2-1)
    E_list[e2-1].append(e1-1)


for i in range(N):
    E_list[i] = list(set(E_list[i]))

for i in range(N):
    if not marks[i]:
        st = dfs(i)

    m = max(m,st)

print(m)

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

int main() {

  int line;
  int row;
  cin >> line;
  cin >> row;
  
  vector<vector<char>> masu(line + 1, vector<char>(row + 1));

  for (int i = 0; i < line; i++) {
    for (int j = 0; j < row; j++) {
      cin >> masu.at(i).at(j) ;
    }
  }
  
  // for (int i = 0; i < line; i++) {
  //  for (int j = 0; j < row; j++) {
  //    cout << masu.at(i).at(j);
  //  }
  //  cout <<endl;
  // }
  // cout << "----" << endl;
  int line_flg;
  int flg;

  int line_out_flg;
  for (int i = 0; i < line; i++) {			// i --> line
    line_out_flg = 0;
    if (masu.at(i).at(0) != '#') {
      for (int j = 1; j < row; j++) {
        if (masu.at(i).at(j) == '#') {
            line_out_flg = 1;
            // cout << "line = " << i << ", row = " << j << "find #" << endl;
            break;
        }
      }
    } else {
      line_out_flg = 1;
    }
    if (line_out_flg == 0) {
      // cout << i << " skip " << endl;
      continue;
    }
    line_flg = 0;
    for (int j = 0; j < row; j++) {			// j --> row
        flg = 0;
        if (masu.at(i).at(j) != '#') {
          for (int k = 0; k < line; k++) {
            if (k != i) {
               if (masu.at(k).at(j) == '#') {
                 flg = 1;
                 break;
               }
            }
          }
        } else {
          flg = 1;
        }
        // cout << "line = " << i << ", row = " << j << ", flg = " << flg << endl;    
        if (flg == 1) {
          cout << masu.at(i).at(j);
          line_flg = 1;
        }
    }
    if (line_flg == 1) {
      cout << endl;
    }
  }
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for(int i = 0; i < K; i++){
        cin >> D[i];
    }

    int ans = N;
    string S;
    bool F;
    while(true){
        S = to_string(ans);
        F = true;
        for(int i = 0; i < K; i++){
            if(count(S.begin(), S.end(), D[i]+'0')){
                F = false;
                ans++;
                break;
            }
        }

        if(F == true){
            break;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
while True:
    N,M=map(int,raw_input().split())
    if N==M==0:break
    L=[map(int,raw_input().split()) for i in range(N)]
    L=[(j,i) for i,j in L]
    L.sort()
    L=reversed(L)
    cost=0
    for p,d in L:
        cost+=p*(max(d-M,0))
        M=max(M-d,0)
    print cost

Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 205;
const int MAXM = 1e5 + 5;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, x, a[MAXN], dp[MAXN][MAXM];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(x), dp[0][x] = 1;
	for (int i = 1; i <= n; i++)
		read(a[i]);
	sort(a + 1, a + n + 1, [&] (int x, int y) {return x > y; });
	for (int i = 1; i <= n; i++)
	for (int j = 0; j <= x; j++) {
		int tmp = dp[i - 1][j];
		update(dp[i][j % a[i]], tmp);
		update(dp[i][j], 1ll * tmp * (n - i) % P);
	}
	int ans = 0;
	for (int i = 0; i <= x; i++)
		update(ans, 1ll * dp[n][i] * i % P);
	writeln(ans);
	return 0;
}

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

typedef long long LL;

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

const int SZ = 1003;
int n, m;
int a[SZ];

int main() {
    setIO();
    // for (int i = 1; i <= n; i++) {
    //     cin>>a[i];
    // }
    int d, t, s;
    cin>>d>>t>>s;
    cout<<((d<=s*t)?"Yes":"No")<<endl;
    
    return 0;
}


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

typedef long long ll;

int main(){
    ll N, M;
    cin >> N >> M;
    
    ll Scc=0;
    if(M<2){ cout << 0 << endl; return 0; }
    
    if((M-N*2)>=0){
        Scc += N;
        M -= N*2;
        N = 0;
    }
    else {
        ll v = M/2;
        Scc += v;
        M -= v*2;
        N -= v;
    }
    
    Scc += M/4;
    cout << Scc << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int seica(int a){
  return a < 10 ? 1 : seica(a / 10) + 1;
}

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

  ll n, m;cin >> n >> m;
  vector<P> v(m);
  REP(i, m){
    cin >> v[i].FI >> v[i].SE;
    v[i].FI = n - v[i].FI;
  }

  REP(i, 1000){
    if(seica(i) != n)continue;
    vector<ll> tmp(3);
    tmp[0] = i % 10;
    tmp[1] = (i / 10) % 10;
    tmp[2] = (i / 100) % 10;

    bool flag = true;
    REP(j, m)if(tmp[v[j].FI] != v[j].SE)flag = false;
    if(flag){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

	return 0;
}


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

int n;
set <int > s;

int main(){
	
	scanf("%d",&n);
	for ( int i = 0; i < n; i++ ){
                int x;
		scanf("%d",&x);
		if ( s.find(x) == s.end() ) s.insert(x);
		else s.erase(s.find(x));
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> C;
const int MAX_N = 200010;

ll dp[MAX_N];
vector<int> indices[MAX_N];
map<int, int> map_nxt_index;
ll memo(int pos)
{

    if (pos >= N)
    {
        return 1;
    }
    ll &res = dp[pos];
    if (res >= 0)
    {
        return res;
    }
    res = 0;
    res += memo(pos + 1);
    res %= MOD;
    if (map_nxt_index.count(pos) > 0)
    {
        res += memo(map_nxt_index[pos]);
        res %= MOD;
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    cin >> N;
    C.resize(N);
    for (auto &val : C)
    {
        cin >> val;
    }
    //erase
    C.erase(unique(C.begin(), C.end()), C.end());
    N = C.size();
    for (int i = 0; i < C.size(); i++)
    {
        indices[C[i]].push_back(i);
    }

    for (int i = 0; i < MAX_N; i++)
    {
        if (indices[i].size() < 2)
        {
            continue;
        }

        int pre = indices[i][0];

        for (int j = 1; j < indices[i].size(); j++)
        {

            map_nxt_index[pre] = indices[i][j];
            pre = indices[i][j];
        }
    }

    memset(dp, -1, sizeof(dp));
    cout << memo(0) % MOD << endl;
    return 0;
}


Measured memory_bytes: 30080
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        x: i64
    }
    if x == 0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2160
import sys

def main():
    input = sys.stdin.readline
    C = []
    s = 0
    for _ in range(3):
        c = list(map(int, input().split()))
        C.append(c)
        s += sum(c)
    if s % 3 != 0:
        print('No')
    else:
        p1 = C[0][0] - C[1][0] == C[0][1] - C[1][1] == C[0][2] - C[1][2]
        p2 = C[0][0] - C[2][0] == C[0][1] - C[2][1] == C[0][2] - C[2][2]
        p3 = C[1][0] - C[2][0] == C[1][1] - C[2][1] == C[1][2] - C[2][2]
        p4 = C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]
        p5 = C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]
        p6 = C[0][1] - C[0][2] == C[1][1] - C[1][2] == C[2][1] - C[2][2]

        if all([p1, p2, p3, p4, p5, p6]):
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int N,Y;
  scanf("%d",&N);
  scanf("%d",&Y);

  int i,j,k;
  for(i=0;i<=N;i++){
    for(j=0;j<=N-i;j++){
      for(k=0;k<=N-i-j;k++){
		if(Y==10000*i+5000*j+1000*k){
          if(N==i+j+k){
			printf("%d %d %d",i,j,k);
			return 0;
          }
		}
      }
    }
  }
  printf("-1 -1 -1");
  return 0;
}


Measured memory_bytes: 128
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-27 23:11:46
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n; cin >> n;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; ++i) {
    int a, b; cin >> a >> b;
    v.emplace_back(a, b);
  }

  sort(all(v), [](const pair<int, int>& x, const pair<int, int>& y){
    return x.first + x.second > y.first + y.second;
  });

  int64 t = 0, a = 0;

  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      a += v[i].second;
    } else {
      t += v[i].first;
    }
  }

  cout << t - a << endl;

  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    int a=1;
    int vec[3][3];
    rep(i,0,3)rep(j,0,3)cin>>vec[i][j];
    rep(i,0,3)rep(j,0,3)vec[i][j]-=vec[i][2];
    rep(i,0,3)rep(j,0,3)vec[j][i]-=vec[2][i];
    rep(i,0,3)rep(j,0,3)a*=!vec[i][j];
    cout<<(a?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath> 
#include <vector>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
  int A, B, C, D, P, val1, val2;
  cin >> A >> B >> C >> D >> P;
  val1 = A * P;
  val2 = B;
  if(C < P)
    val2 += (P - C)*D;
  cout << min(val1, val2) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int x,y,x2,y2,x3,y3,x4,y4;

int main()
{
	cin>>x>>y>>x2>>y2;
	y3=y2+x2-x;
	x3=x2-y2+y;
	y4=y3-y2+y;
	x4=x3-x2+x;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}



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

int main() {
  vector<int> v(4);
  for(int i=0; i<4; i++) cin >> v[i];
  sort(v.begin(), v.end());
  
  bool can = true;
  for(int i=0; i<4; i++) {
    if(i==0) {
      if(v[i]!=1) can = false;
    }
    if(i==1) {
      if(v[i]!=4) can = false;
    }
    if(i==2) {
      if(v[i]!=7) can = false;
    }
    if(i==3) {
      if(v[i]!=9) can = false;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;
const int N = 1e6+1;
int cn[N];
int main()
{
    FAST
    int n;cin>>n;
    int a[n];
    f(i,0,n) cin>>a[i];
    int res=0;
    f(i,0,n) res = __gcd(res,a[i]);
    f(i,0,n)
    {
        int num = a[i];
        for(int j=2;j*j<=num;j++)
        {
            if(num%j==0)
            {
                cn[j]++;
                while(num%j==0) num/=j;
            }
        }
        if(num>2) cn[num]++;
    }
    int f=0;
    f(i,0,N) if(cn[i]>1) f++;
    if(!f) cout<<"pairwise coprime\n";
    else if(res==1) cout<<"setwise coprime\n";
    else cout<<"not coprime\n";
}


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

// class TTable//???????????????????????????TNode*???????????????(vector??????????????¢?????????????????????)
// {
// 	vector<TNode*> Nodes;
// 	~TTable();
// };

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

enum TNodeType {Root, InternalNode, Leaf};

void Create(int Id, vector<TNode*>& Nodes)
{
	if(Nodes[Id] == NULL){
		TNode* Node;
		Node = new TNode;
		*Node = {Id, NULL, NULL, NULL};
		Nodes[Id] = Node;
	}
}

void CreateLeftRelation(TNode* ParentNode, TNode* LChildNode)
{
	ParentNode->LChild = LChildNode;
	LChildNode->Parent = ParentNode;
}

void CreateRightRelation(TNode* ParentNode, TNode* RChildNode)
{
	ParentNode->RChild = RChildNode;
	RChildNode->Parent = ParentNode;
}

vector<TNode*> Input()
{
	int n;
	cin >> n;
	vector<TNode*> Nodes(n, NULL);
	for(int i = 0; i < n; i++){
		int Id;
		cin >> Id;
		Create(Id, Nodes);
		int left;
		cin >> left;
		if(left != -1){
			Create(left, Nodes);
			CreateLeftRelation(Nodes[Id], Nodes[left]);
		}
		int right;
		cin >> right;
		if(right != -1){
			Create(right, Nodes);
			CreateRightRelation(Nodes[Id], Nodes[right]);
		}
	}
	return Nodes;
}

int GetSibling(const TNode* Node)
{
	const TNode* Parent = Node->Parent;
	if(Parent == NULL){
		return -1;
	}
	if(Node == Parent->LChild && Parent->RChild){
		return Parent->RChild->Id;
	}
	if(Node == Parent->RChild && Parent->LChild){
		return Parent->LChild->Id;
	}
	return -1;
}

int GetDegree(const TNode* Node)
{
	return (Node->LChild ? 1 : 0) + (Node->RChild ? 1 : 0);
}

int GetDepth(const TNode* Node)
{
    int depth = 0;
    while(Node->Parent){
        depth++;
        Node = Node->Parent;
    }
    return depth;
}

int GetHeight(const TNode* Node)
{
	if(Node == NULL) return -1;
	return 1 + max(GetHeight(Node->LChild), GetHeight(Node->RChild));
}

TNodeType GetType(const TNode* Node)
{
    if(Node->Parent == NULL){
        return Root;
    }
	if(Node->LChild == NULL && Node->RChild == NULL){
        return Leaf;
    }
    return InternalNode;
}

void Output(const vector<TNode*>& Nodes)
{
	for(unsigned int i = 0; i < Nodes.size(); i++){
		cout << "node " << Nodes[i]->Id << ": ";
		if(Nodes[i]->Parent){
		    cout << "parent = " << Nodes[i]->Parent->Id << ", ";
		}else{
		    cout << "parent = -1, ";
		}
		cout << "sibling = " << GetSibling(Nodes[i]) << ", ";
		cout << "degree = "  << GetDegree(Nodes[i])  << ", ";
		cout << "depth = "   << GetDepth(Nodes[i])   << ", ";
		cout << "height = "  << GetHeight(Nodes[i])  << ", ";
		if(GetType(Nodes[i]) == Root){
		    cout << "root"; 
		}else if(GetType(Nodes[i]) == InternalNode){
		    cout << "internal node";    
		}else{
		    cout << "leaf";
		}
		cout << endl;
	}
}

void Delete(vector<TNode*>& Nodes)
{
	int n = Nodes.size();
	for(int i = 0; i < n; i++){
		delete Nodes[i];
	}
}

int main()
{
	vector<TNode*> Nodes = Input();
	Output(Nodes);
//	Delete(Nodes);
    return 0;
}

Measured memory_bytes: 3088
import math
a, b, h, m = map(int, input().split())

ab = a
ac = b

rad = abs(30 * (h + m / 60) - 6 * m)
cosA = math.cos(math.radians(rad))

bc2 = ab * ab + ac * ac - 2 * ab * ac * cosA

print(math.sqrt(bc2))


Measured memory_bytes: 62360
#!/usr/bin/env python3
from collections import Counter

n, *v = map(int, open(0).read().split())
odd = [v[i] for i in range(0, n, 2)]
even = [v[i] for i in range(1, n, 2)]
o = Counter(odd)
e = Counter(even)

if o.most_common()[0][0] != e.most_common()[0][0]:
    print(n - o.most_common()[0][1] - e.most_common()[0][1])
else:
    a = n - o.most_common()[0][1] - max(sorted(e.values())[:-1] + [0])
    b = n - e.most_common()[0][1] - max(sorted(o.values())[:-1] + [0])
    print(min(a, b))


Measured memory_bytes: 24700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int N;
vector<string>ans;
void rec(int k = 0, string res = "") {
	if (res.size() == N) {
		ans.push_back(res);
		return;
	}
	rep(i, 0, k + 1) {
		char ch = 'a' + i;
		rec(k + (i == k), res + ch);
	}
	return;
}

int main() {
	init();

	cin >> N;
	rec();
	sort(all(ans));
	rep(i, 0, ans.size())cout << ans[i] << "\n";

	return 0;
}


Measured memory_bytes: 7296
from collections import deque


r, p = map(int, input().split())
graph = [[] for _ in range(r)]

for x in range(p):
    x1, x2 = map(int, input().split())
    graph[x1-1].append(x2-1)
    graph[x2-1].append(x1-1)

q = deque([0])
res = [-1]*r
res[0] = 0
while q:
    l = q.popleft()
    for x in graph[l]:
        if res[x] == -1:
            res[x] = l
            q.append(x)
if -1 in res[1:]:
    print("No")
    exit()
print("Yes")
for x in res[1:]:
    print(x+1)

Measured memory_bytes: 34932
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int b = int.Parse(s[0]);
            int m = int.Parse(s[1]);

            if ( m == 1)
            {
                Console.WriteLine("0");
                return;
            }

            Console.WriteLine(b - m);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>

int main()
{
  int n,k;
  int l[51];
  int i,j;
  int t;
  int sum=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      t=l[i];
      if(l[i]<l[j]){
        l[i]=l[j];
        l[j]=t;
       }
     }
  }
  for(i=0;i<k;i++){
    sum+=l[i];
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 1716
#include <stdio.h>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;

int h, w, a, b;
char m[1024][1024];
int main() {
	scanf("%d %d %d %d", &h, &w, &a, &b);
	for (int i = 0; i < h; i++)
		for (int j = 0; j < a; j++)
			m[i][j] = 1;
	for (int i = 0; i < b; i++)
		for (int j = 0; j < w; j++)
			m[i][j] ^= 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)
			m[i][j] += '0';
		printf("%s\n", m[i]);
	}
}


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

using namespace std;
long long a[1<<18];

struct BestTwo {
    int id[2];
    BestTwo(){ id[0] = id[1] = -1; }


    void add(int x){
        if( x == -1 ) return;

        if( id[0] == x || id[1] == x ) return;

        if( id[0] == -1 ){
            id[0] = x;
            return;
        }
        if( id[1] == -1 ){
            id[1] = x;
            return;
        }

        if( a[id[0]] < a[id[1]] ) swap(id[0], id[1]);
        if( a[id[0]] < a[x] ){
            id[1] = id[0];
            id[0] = x;
            return;
        }
        if( a[id[1]] < a[x] ){
            id[1] = x;
            return;
        }
    }
    long long get(){
        return a[id[0]] + a[id[1]];
    }
};
BestTwo dp[1<<18];

int main(){
    int N;
    cin >> N;
    for(int i = 0 ; i < (1<<N) ; i++){
        cin >> a[i];
        dp[i].add(i);
    }
    for(int i = 0 ; i < (1<<N) ; i++){
        for(int j = 0 ; j < N ; j++){
            dp[i|(1<<j)].add(dp[i].id[0]);
            dp[i|(1<<j)].add(dp[i].id[1]);
        }
    }

    long long sum = 0;
    for(int i = 1 ; i < (1<<N) ; i++){
        long long ans = dp[i].get();
        sum = max(ans, sum);
        cout << sum << endl;
    }



}

Measured memory_bytes: 7168
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int[][] a = new int[3][3];
 
		for (int i = 0;i<3 ;i++ ) {
			for (int j = 0;j<3 ;j++ ) {
				a[i][j] = sc.nextInt();
			}
		}
 
		int n = sc.nextInt();
		int[] data = new int[n];
 
		for (int i = 0;i<n ;i++ ) {
			data[i] = sc.nextInt();
		}
 
		for (int k = 0;k<n ;k++ ) {
			for (int i = 0;i<3 ;i++ ) {
				for (int j = 0;j<3 ;j++ ) {
					if (a[i][j]==data[k]) {
							a[i][j] = -1;
					}
				}
			}
		}
 
		for (int i = 0;i<3 ;i++ ) {//横
			int count = 0;
			for (int j = 0;j<3 ;j++ ) {
				if (a[i][j]==-1) {
					count++;
				}
			}
				if (count==3) {
					System.out.println("Yes");
					System.exit(0);
				}
		}
		for (int j = 0;j<3 ;j++ ) {//たて
			int count = 0;
			for (int i = 0;i<3 ;i++ ) {
				if (a[i][j]==-1) {
					count++;
				}
			}
				if (count==3) {
					System.out.println("Yes");
					System.exit(0);
				}
		}
 
		if (a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1) {
			System.out.println("Yes");
			System.exit(0);
		}
		if (a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1) {
			System.out.println("Yes");
			System.exit(0);
		}
		System.out.println("No");
 
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n, m, l;
  cin >> n;
  int x = 1;
  while (true) {
    if (x * (x + 1) >= 2 * n) break;
    x++;
  }
  m = x * (x + 1) / 2;
  l = m - n;
  for (int j = 1; j <= x; j++) {
    if (j == l) continue;
    cout << j << endl;
  }
  //   cout << endl;
  //   cout << l << endl;
}

Measured memory_bytes: 384
def makeIsPrimeList(n):
  is_primes=[True]*(n+1)
  is_primes[0], is_primes[1]=False, False
  for i in range(2, int(n**0.5)+1):
    if not is_primes[i]:
      continue
    for j in range(i*2, n+1, i):
      is_primes[j]=False
  return is_primes

q=int(input())
lr=[tuple(map(int, input().split())) for _ in range(q)]
is_primes=makeIsPrimeList(10**5)
mylst=[0]*(10**5+1)
cnt=0
for i in range(len(mylst)):
  if is_primes[i] and is_primes[(i+1)//2]:
    cnt+=1
  mylst[i]=cnt
for l, r in lr:
  print(mylst[r]-mylst[l-1])

Measured memory_bytes: 18896
#include <iostream>
using namespace std;
int main(){
	int n;
	int weight[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(cin >> n){
		int t = 0;
		for(int i = 0; i < 10; i++){
			if(n % 2){
				if(t++) cout << " ";
				cout << weight[i];
			}
			n /= 2;
		}
		cout << endl;
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
    long min = 1e+15;
    long N;
    cin >> N;

    for(int i = 0; i < 5; i++)
    {
        long temp;
        cin >> temp;
        if (temp < min) {
            min = temp;
        }
        
    }

    // cout << min << endl;
    // cout << ceil(N/min) << endl;
    // cout << 4 + ceil(double(N) / min) << endl;
    printf("%ld", long(4 + ceil(double(N) / min)));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it
int n, *x;
int main()
{
    cin.tie(nullptr); ios_base::sync_with_stdio(false);
    cin >> n;
	x = new int[n];
	for(int i = 0; i < n; i++)
		cin >> x[i];
	ll ans = 1000;
	for(int i = 0; i < n;)
	{
		int maxi = -1;
		for(int j = i + 1; j < n; j++)
			if(x[j] > x[i])
			{
				maxi = j;
				break;
			}
		if(!~maxi)
		{
			i++;
			continue;
		}
		int mini = i;
		for(int j = i + 1; j < maxi; j++)
			if(x[j] < x[i])
			{
				mini = j;
				break;
			}
		if(mini != i)
			i = mini;
		else
		{
			ll buy = ans / x[i];
			ans += buy * (x[maxi] - x[i]);
			i = maxi;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main (void){
  int n,cnt,i1;
  int ans=0;
  scanf("%d",&n);
  for(int i=1;i<n+1;i++){
    cnt=0;
    i1=i;
    while(i1>0){
      i1=i1/10;
      cnt++;
    }
    if(cnt%2==1){
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 600, mod = 1e9 + 7;
int n, m, s[maxn + 10][maxn + 10];
int a[maxn + 10], b[maxn + 10];
int f[maxn + 10][maxn + 10], g[maxn + 10];
int ans;

bool in(int p, int l, int r) {
	if (l <= r) return p >= l && p <= r;
	else return p >= l || p <= r;
}

int rlink(int l, int r) {
	if (s[l][r] == -1) return 0;
	else return g[s[l][r]];
}

int main() {
	scanf("%d%d", &n, &m); n *= 2;
	for (int i = 1; i <= m; ++i) scanf("%d%d", &a[i], &b[i]);
	g[0] = 1;
	for (int i = 2; i <= n; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= n; ++k)
				if (in(k, i, j)) ++s[i][j];
			for (int k = 1; k <= m; ++k) {
				bool d1 = in(a[k], i, j), d2 = in(b[k], i, j);
				if (d1 ^ d2) {
					s[i][j] = -1; break;
				}
				if (d1 && d2) s[i][j] -= 2;
			}
		}
	for (int l = 0; l < n; ++l)
		for (int i = 1; i <= n; ++i) {
			int j = i + l;
			if (j > n) j -= n;
			f[i][j] = rlink(i, j);
			for (int k = i; k != j; k = k == n ? 1 : k + 1) {
				f[i][j] -= 1ll * f[i][k] * rlink(k == n ? 1 : k + 1, j) % mod - mod;
				f[i][j] %= mod;
			}
			if (l < n - 1) {
				if (i <= j)
					(ans += 1ll * f[i][j] * rlink(j == n ? 1 : j + 1, i == 1 ? n : i - 1) % mod) %= mod;
			}
			else if (i == 1)
				(ans += f[i][j]) %= mod;
		}
	printf("%d", ans);
}


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

bool isPointOnSegment(int px, int py, int sx, int sy, int ex, int ey){
	int ip = (px*ex+py*ey) - ((ex+px)*sx+(ey+py)*sy) + (sx*sx+sy*sy);
	return (py - ey)*(sx - ex) - (px - ex)*(sy - ey) == 0 && ip >=0 && ip <= (ex-sx)*(ex-sx)+(ey-sy)*(ey-sy);
}

int sign(int n){
	if(n>0)return 1;
	if(n<0)return -1;
	return 0;
}

float angle(int ax, int ay, int bx, int by, int cx, int cy){
	//angle between ab and ac
	float ab = atan2(by-ay,bx-ax);
	float ac = atan2(cy-ay,cx-ax);
	if(ab < 0)ab += 2*M_PI;
	if(ac < 0)ac += 2*M_PI;
	float ang = ac - ab;
	return (fabs(ang) < M_PI ? ang : -sign(ang) * 2 * M_PI + ang) * 180 / M_PI;
}

int main() {
	int n, q, x, y, res;
	vector< int > vtx, vty;
	float sum;
	
	cin >> n;
	vtx.resize(n);
	vty.resize(n);
	
	for(int i=0;i<n;++i){
		cin >> vtx[i] >> vty[i];
	}
	
	cin >> q;
	for(int i=0;i<q;++i){
		cin >> x >> y;
		res = 0;
		
		//is the point on segments
		for(int k=0;k<n;++k){
			if(isPointOnSegment(x,y,vtx[k],vty[k],vtx[(k+1)%n],vty[(k+1)%n])){
				res = 1;
				break;
			}
		}
		
		sum = 0;
		if(!res){
			//is the point in the polygon
			for(int k=0;k<n;++k){
				sum += angle(x,y,vtx[k],vty[k],vtx[(k+1)%n],vty[(k+1)%n]);
			}
			
			if(sum >= 180){
				res = 2;
			}else{
				res = 0;
			}
		}
		cout << res << endl;
	}
	
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string a,b; cin>>a>>b;
  string s1="";
  string s2="";
  
  rep(i,stoi(b)) s1+=a;
  rep(i,stoi(a)) s2+=b;
  if(s1>=s2) cout<<s2<<endl;
  else cout<<s1<<endl;
}

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

int main() {

	int a, b;

	cin >> a >> b;

	double c = (double)(a + b) / 2;

	if (c > (a + b) / 2) {

		cout << (a + b) / 2 + 1;

	}
	else {

		cout << (a + b) / 2;

	}
	
	return 0;

}

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


int main()
{
    int n;
    cin >> n;
    int t,a;
    cin >> t >> a;
    vector<int> h(n);
    for(int i = 0;i < n;i++) cin >> h[i];
    double min_a = 100000000;
    int min_n;
    for(int i = 0;i < n;i++){
        double tmp = t - h[i]*0.006;
        double b = fabs(a - tmp);
        if(min_a > b){
            min_n = i + 1;
            min_a = b;
        }
    }
    cout << min_n << endl;
        
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int count = 0;
  for (int i = 0; i < N - 2; i++) {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C')
      count++;
  }
  
  cout << count << endl;
    
}


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

int sx, sy, tx, ty;
string ans = "";


int dfs(vector<vector<bool>> Map){
    return 0;
}

int main(){
    cin >> sx >> sy >> tx >> ty;
    tx = tx-sx+1;
    ty = ty-sy+1;
    sx = sy = 1;

    vector<vector<bool>> Map(tx-sx+3, vector<bool>(ty-sy+3));
    for(int i = 0; i < abs(tx-sx); i++){
        if(sx < tx) ans+='R';
        else ans+='L';
    }
    for(int i = 0; i < abs(ty-sy); i++){
        if(sy < ty) ans+='U';
        else ans+='D';
    }

    for(int i = 0; i < abs(tx-sx); i++){
        if(sx < tx) ans+='L';
        else ans+='R';
    }
    for(int i = 0; i < abs(ty-sy)+1; i++){
        if(sy < ty) ans+='D';
        else ans+='U';
    }

    /////
    for(int i = 0; i < abs(tx-sx)+1; i++){
        if(sx < tx) ans+='R';
        else ans+='L';
    }
    for(int i = 0; i < abs(ty-sy)+1; i++){
        if(sy < ty) ans+='U';
        else ans+='D';
    }
    if(sx < tx) ans+='L';
    else ans+='R';

    if(sy < ty) ans+='U';
    else ans+='D';
    
    for(int i = 0; i < abs(tx-sx)+1; i++){
        if(sx < tx) ans+='L';
        else ans+='R';
    }
    for(int i = 0; i < abs(ty-sy)+1; i++){
        if(sy < ty) ans+='D';
        else ans+='U';
    }
    if(sx < tx) ans+='R';
    else ans+='L';

    cout << ans << endl;
}

Measured memory_bytes: 896
package main

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

func main() {
	defer writer.Flush()
	n := ReadInt()
	A := ReadInts(n)
	pivot := Partition(A, 0, n-1)
	for i, a := range A {
		if i > 0 {
			Printf(" ")
		}
		if i == pivot {
			Printf("[%d]", a)
		} else {
			Printf("%d", a)
		}
	}
	Printf("\n")
}

func Partition(A []int, p, r int) int {
	x := A[r]
	i := p - 1
	for j := p; j < r; j++ {
		if A[j] <= x {
			i++
			A[i], A[j] = A[j], A[i]
		}
	}
	A[i+1], A[r] = A[r], A[i+1]
	return i + 1
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = ReadInt()
	}
	return v
}

var writer = bufio.NewWriter(os.Stdout)

func Printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }



Measured memory_bytes: 3168
import collections

n, k = map(int, input().split(" "))
r, s, p = map(int, input().split(" "))

ans = 0
q = collections.deque([-1]*k)
for i in input():
    prev = q.popleft()
    if i == 'r':
        if prev == 'r':
            q.append(-1)
        else:
            q.append(i)
            ans += p
    if i == 's':
        if prev == 's':
            q.append(-1)
        else:
            q.append(i)
            ans +=  r
    if i == 'p':
        if prev == 'p':
            q.append(-1)
        else:
            q.append(i)
            ans +=  s

print(ans)


Measured memory_bytes: 49596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.length() > b.length())
            System.out.println("GREATER");
        else if (a.length() < b.length())
            System.out.println("LESS");
        else {
            for (int i = 0; i < a.length(); i++) {
                if (a.charAt(i) == b.charAt(i))
                    ;
                else if (a.charAt(i) > b.charAt(i)) {
                    System.out.println("GREATER");
                    System.exit(0);
                } else {
                    System.out.println("LESS");
                    System.exit(0);
                }
            }
            System.out.println("EQUAL");
        }
    }
}


Measured memory_bytes: 21972
from collections import *
from heapq import*
import sys
input=lambda:sys.stdin.readline()

d=defaultdict(list)
n=int(input())

for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})

def DIJKSTRA(point,d):
    cost      = {node:float("inf") for node in d.keys()}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

q,k=map(int,input().split())
y=DIJKSTRA(k,d)

for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])

Measured memory_bytes: 63500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        //string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        //string str = "<>>><<><<<<<>>><";
        decimal A = Int64.Parse(str);
        //int B = int.Parse(str[1]);
        //string[] strHeight = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        //string[] results = new string[N];
        //long[] result = new long[str.Length+1];
        //result[0] = 0;
        //long min = 0;
        //long minpoint = 0;

        if( A % 2 == 0)
        {
            Console.WriteLine((A / 2) - 1);
        }
        else
        {
            Console.WriteLine(Math.Floor(A / 2));
        }
    }
}

Measured memory_bytes: 11092
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		out.println((int)ceil((Double.parseDouble(br.readLine()))/2));
		

	}
	
	
}




Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
ll a[N],n;
map<ll,ll> cnt;
int main()
{
	while(cin>>n)
	{
		cnt.clear();
		for(int i=1;i<=n;i++)	
			scanf("%d",&a[i]),cnt[a[i]]++;
		sort(a+1,a+1+n);
		reverse(a+1,a+1+n);
		ll ans=0,x=-1,y=-1;
		for(int i=1;i<=n;i++)
		{
			if(cnt[a[i]]>=4)
			{
				if(x!=-1)
					ans=x*a[i];
				else
					ans=a[i]*a[i];
				break;
			}
			if(cnt[a[i]]>=2)
			{
				if(x!=-1)
				{
					y=a[i];
					ans=x*y;	
					break;
				}
				else
					x=a[i];
				cnt[a[i]]=0;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
} 

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;

  int tgt = 0;

  while (true) {
    if (a < b) break;
    b *= 2;
    ++tgt;
  }

  if (tgt > k) {
    cout << "No\n";
    return 0;
  }

  while (true) {
    if (b < c) break;
    c *= 2;
    ++tgt;
  }

  if (tgt > k) {
    cout << "No\n";
    return 0;
  } else {
    cout << "Yes\n";
    return 0;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

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

const int inf=(int)2e9;
const long long mod=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=mod;a%=mod;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,mod-2); }

const int N=301;
long double DP[N][N][N];
bool vis[N][N][N];

int n;
long double sol(int a,int b,int c){
	if(a<0||b<0||c<0) return 0;
	if(a+b+c==0) return 0;
	if(vis[a][b][c]) return DP[a][b][c];
	vis[a][b][c]=1;
	long double& ans=DP[a][b][c];
	int z=n-a-b-c;
	ans=1;
	ans+=a*sol(a-1,b,c)/n;
	ans+=b*sol(a+1,b-1,c)/n;
	ans+=c*sol(a,b+1,c-1)/n;
	ans*=n;
	ans/=n-z;
	return ans;
}

signed main(){
	IOS
	cin>>n;
	int a=0,b=0,c=0;
	forn(i,n){
		int x;cin>>x;
		if(x==1) a++;
		else if(x==2) b++;
		else if(x==3) c++;
	}
	cout<<setprecision(20)<<sol(a,b,c);
}


Measured memory_bytes: 452864
#include <cstdio>
using namespace std;
typedef long long ll;
#define M (1000000007)

ll pow( ll a, ll b ) {
    if ( b == 0 ) return 1;
    else {
	ll tmp = pow( (a * a) % M, b / 2 ) % M;
	if ( b % 2 ) tmp = ( tmp * a ) % M;

	return tmp;
    }
}

int main()
{
    int m, n;
    scanf("%d %d", &m, &n);
    
    ll ans = pow( m, n );

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

Measured memory_bytes: 1024
n,m=list(map(int, input("").split()))
h=list(map(int, input("").split()))
o=[]
for i in range(n):
    o.append(1)
for i in range(m):
    a,b=list(map(int, input("").split()))
    if h[a-1] <=h[b-1]:
        o[a-1]=0
    if h[a-1] >=h[b-1]:
        o[b-1]=0
print(sum(o))

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 80+2;
const int mod = 1e9 + 7;

bitset<N*N*4> dp[N][N];
int a[N][N], b[N][N];
int32_t main()
{
    int n = in(), m = in();
    for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) a[i][j]=in();
    for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) b[i][j]=in();
    dp[1][1][N*N*2]=1;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            int k=abs(a[i][j]-b[i][j]);
            dp[i][j]=(dp[i][j]<<k)|(dp[i][j]>>k);
            dp[i+1][j]|=dp[i][j];
            dp[i][j+1]|=dp[i][j];
        }
    }
    int ans=1e9;
    for(int i=0; i<N*N*4; i++) if(dp[n][m][i]) ans=min(ans, abs(i-N*N*2));
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 22144