akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 1000000007;
const int mod = 1000000007;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int s, w;

void Solve()
{	
	cin >> s >> w;
	if(s <= w)
	{
		cout << "unsafe";
	}	
	else
	{
		cout << "safe";
	}
}

int main()
{
//	freopen("PARK.inp", "r", stdin);
//	freopen("PARK.out", "w", stdout);
	Fastio();
	Solve();
}

Measured memory_bytes: 3608
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, k, q;
  std::cin >> n >> k >> q;
  std::vector<int> a(n); std::cin>>a;

  auto cal = [&] (int X, int Y) {
    std::vector<int> now;
    std::vector<std::vector<int>> seqs;
    for (int x: a) {
      if (x < X) {
        if (!now.empty()) {
          seqs.emplace_back(now);
          now.resize(0);
        }
      } else {
        now.emplace_back(x);
      }
    }
    if (!now.empty()) {
      seqs.emplace_back(now);
    }
    debug(seqs);

    int ans = 0;
    for (auto&& v : seqs) {
      if ((int)v.size() < k) continue;
      int count = 0;
      for (int x : v) {
        count += x <= Y;
      }
      int now = std::min(count, (int)v.size() - k + 1);
      assert(0 <= now);
      ans += now;
    }
    return ans;
  };

  int inf = *std::max_element(all(a));
  int ans = inf;
  for (int X : a) {
    if (cal(X,inf) < q) continue;
    int l = X - 1, r = inf;
    while (1 < r - l) {
      int Y = (l + r) / 2;
      int ret = cal(X,Y);
      (ret < q ? l : r) = Y;
    }
    int Y = r;
    int now = Y - X;
    debug(X,Y, cal(X,Y));
    cmn(ans,now);
  }
  std::cout << ans << std::endl;
  return 0;
}

/*
最小値 X を全探索、最大値 Y を二分探索です。
X 以下のものを消して別問題です。
それぞれの中で Y 以下のものを列挙します。ただし len - K + 1 個までしか選べません。
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  if(N%10==0||N%10==1||N%10==6||N%10==8) cout<<"pon"<<endl;
  else if(N%10==3) cout<<"bon"<<endl;
  else cout<<"hon"<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        arr.at(i) = a;
    }
    sort(arr.begin(), arr.end(), greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < arr.size(); i++) {
        if (i % 2 == 0) {
            Alice += arr.at(i);
        } else {
            Bob += arr.at(i);
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct E {
	int d;
	int e;
};

void process(vector<int>& ns, vector<bool>& is_searched, queue<int>& search, const pair<int, E>& e)
{
	if (is_searched[e.second.d]) return;

	ns[e.second.d] = ns[e.first] ^ e.second.e;
	is_searched[e.second.d] = true;
	search.push(e.second.d);
}

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

	int n; cin >> n;

	multimap<int, E> edges;
	FOR_LT(i, 0, n - 1) {
		int v, w, d; cin >> v >> w >> d;

		edges.insert(make_pair(v, E{ w, (d & 1) }));
		edges.insert(make_pair(w, E{ v, (d & 1) }));
	}

	vector<int> ns(n + 1);
	vector<bool> is_searched(n + 1);

	queue<int> search;
	ns[1] = 1;
	is_searched[1] = true;
	search.push(1);

	while (!search.empty()) {
		int i = search.front();
		search.pop();

		auto e = edges.find(i);
		while (e != edges.end() && e->first == i) {
			process(ns, is_searched, search, *e);
			e++;
		}
	}

	FOR_LE(i, 1, n) {
		cout << ns[i] << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int d, a;
  double x = 0, y = 0, degree = 90;
  char c;
  while (cin >> d >> c >> a, d != 0 || a != 0) {
    x += d * cos(degree / 180 * M_PI);
    y += d * sin(degree / 180 * M_PI);
    degree -= a;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}


Measured memory_bytes: 3512
# 入力：整数の各桁を要素とする配列としてうけとる
ary = gets.chomp.split("").map(&:to_i)
# 配列の要素の総和を9で割ったあまりが0ならYes、そうでないならNoを出力
puts (ary.sum % 9 == 0) ? "Yes" : "No"

Measured memory_bytes: 26352
#include<stdio.h>
#define MAX 20

int A[MAX],n;

bool check(int i,int m){
	if (m == 0)return 1;
	if (i >= n)return 0;
	int res = check(i + 1, m) || check(i + 1, m - A[i]);
	return res;
}

int main(){
	int q, m;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%d", &m);
		if (check(0,m)){
			printf("yes\n");
		}
		else{
			printf("no\n");
		}
	}
}

Measured memory_bytes: 2576
#include <iostream>
// #include <bits/stdc++.h>
#include <unordered_set>
#include <string>
typedef long long int ll;

using namespace std;


int main(){
    int n;
    cin >> n;
    string s;
    unordered_set<string> st;   
    while(n > 0){
        cin >> s;
        st.insert(s);
        n = n - 1;
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 17728
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
struct Dot{
	int x;int y;int t;
	Dot(int a,int b,int c):x(a),y(b),t(c) {}
};
int H,W,N;
char map[1000][1000];
int map_by[1000][1000];
int cheeses_x[10];
int cheeses_y[10];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int sx,sy;

void input(){
	cin >> H >> W >> N;
	for(int i = 0;i < H;++i){
		for(int j = 0;j < W;++j){
			cin >> map[i][j];
			if(map[i][j] == 'S'){
				sx = i;
				sy = j;
			}else if(map[i][j] >= '1' && map[i][j] <= '9'){
				int crt = map[i][j] - '0';
				cheeses_x[crt] = i;
				cheeses_y[crt] = j;
			}
		}
	}
}

int bfs(int s,int e){
	fill(map_by[0],map_by[0]+1000*1000,0);
	Dot st = Dot(cheeses_x[s],cheeses_y[s],0);
	queue<Dot> Q;
	Q.push(st);
	map_by[st.x][st.y] = 1;
	while(!Q.empty()){
		Dot d = Q.front();
		Q.pop();
		for(int i = 0;i < 4;++i){
			int cx = d.x+dx[i], cy = d.y+dy[i],ct = d.t+1;
			if(!(cx >= 0 && cx < H && cy >= 0 && cy < W && !map_by[cx][cy])) continue;
			if(map[cx][cy]-'0' == e) return ct;
			if(map[cx][cy] == '.' || (map[cx][cy] >= '1' && map[cx][cy] <= '9') || map[cx][cy] == 'S'){
				Q.push(Dot(cx,cy,ct));
				map_by[cx][cy] = 1;
			}
		}
	}
	return -1;
}

int main(){
	input();
	int res = 0;
	cheeses_x[0] = sx;cheeses_y[0] = sy;
	for(int i = 0;i < N;++i){
		int tmp = bfs(i,i+1);
	//	cout << tmp << endl;
		if(tmp == -1){
			res = -1;
			break;
		}
		res += tmp;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 7884
import sys
input = sys.stdin.readline
def print_ans(A, B):
    """Test Case
    >>> print_ans(1, 1)
    1000000
    >>> print_ans(3, 101)
    100000
    >>> print_ans(4, 4)
    0
    """
    ans = 0
    if A == 1:
        ans += 300000
    elif A == 2:
        ans += 200000
    elif A == 3:
        ans += 100000

    if B == 1:
        ans += 300000
    elif B == 2:
        ans += 200000
    elif B == 3:
        ans += 100000

    if A == 1 and B == 1:
        ans += 400000
    print(ans)

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)




Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {N:usize,A:[usize;N]}
    let mut m = HashMap::<usize, usize>::new();
    let mut ans = 0;
    for i in 0..N {
        if i >= A[i] {
            ans += *m.entry(i - A[i]).or_insert(0);
        }
        *m.entry(i + A[i]).or_insert(0) += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 10204
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 10005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,a[N],ans;
int main() {
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
		while(a[i]%2==0){
			a[i]/=2;
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000,mo=1e9+7;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int n,m,a[N],b[3][3],c[3][3],d[3][3],ans[3][3];
void mul(int a[3][3],int b[3][3],int _c[3][3]){
	int c[3][3]={0};
	rep(i,0,2)rep(k,0,2)rep(j,0,2)add(c[i][j],1LL*a[i][k]*b[k][j]%mo);
	memcpy(_c,c,sizeof(c));
}
int main() {
	read(n);read(m);
	rep(i,1,m)read(a[i]);a[++m]=n;
	b[0][0]=1;b[1][0]=2;b[1][1]=1;b[2][0]=1;b[2][1]=1;b[2][2]=1;
	c[0][0]=1;c[0][1]=1;c[0][2]=1;
	rep(i,0,2)rep(j,0,2)d[i][j]=b[i][j]+c[i][j];
	rep(i,0,2)ans[i][i]=1;
	rep(i,1,m){
		int e[3][3];memcpy(e,d,sizeof(e));int t=a[i]-a[i-1]-1;
		while(t){
			if(t&1)mul(e,ans,ans);//swap??
			mul(e,e,e);t>>=1;
		}
	//	printf("<%d %d %d>\n",ans[0][0],ans[1][0],ans[2][0]);
		if(i<m)mul(b,ans,ans);else mul(c,ans,ans);
	}
	printf("%d",ans[0][0]);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

vector<pair<pll, int>> PX, PY;
vector<int> parent;

//ノードXの根を返す
int root(int X){
	if(parent[X] < 0)return X;
	return parent[X] = root(parent[X]);
}
//ノードXが属するグループのサイズ(属するノード数)を返す
int size(int X){
	return -parent[root(X)];
}
//Xの属するグループとYの属するグループを繋ぐ
//それぞれの根どうしを繋ぐ
bool connect(int X, int Y){
	//根同士をつなぐため指すノードを根にする
	X = root(X);
	Y = root(Y);
	//すでに繋がっているときは繋がずにfalseを返す
	if(X == Y){
		return false;
	}
	//大きいほうに小さいほうを繋ぎたいので逆ならスワップ
	if(size(X) < size(Y))swap(X, Y);
	//繋がれる方のサイズを更新
	parent[X] += parent[Y];
	//繋ぐ方の親を設定
	parent[Y] = X;
	return true;
}

int main(){

	int N;
	cin >> N;
	PX = vector<pair<pll, int>>(N);
	PY = vector<pair<pll, int>>(N);
	ll x, y;
	for(int i = 0; i < N; i ++){
		cin >> x >> y;
		PX[i] = mp(mp(x, y), i);
		PY[i] = mp(mp(y, x), i);
	}
	sort(all(PX));
	sort(all(PY));
	parent = vector<int>(N, -1);
	vector<pair<ll, pint>> dist;
	for(int i = 0; i < N - 1; i ++){
		dist.pm(abs(PX[i].fpf - PX[i + 1].fpf), mp(PX[i].second, PX[i + 1].second));
		dist.pm(abs(PY[i].fpf - PY[i + 1].fpf), mp(PY[i].second, PY[i + 1].second));
	}
	sort(all(dist));
	ll ans = 0;
	for(int i = 0; i < dist.size(); i ++){
		if(connect(dist[i].spf, dist[i].sps)){
			ans += dist[i].first;
		}
	}
	cout << ans << endl;

//"Hiroakimm0415"
	return 0;
}

Measured memory_bytes: 11504
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    string s0 = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int ans = 0;
    forn(i, 16) ans += (s[i] != s0[i]);
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int[] a = new int[n + 2];
        int[] l = new int[n + 2];

        a[0] = 0;
        for(int i = 1; i <= n; i++)
        {
            a[i] = x[i - 1];
        }
        a[n + 1] = 0;

        for (int i = 1; i <= n + 1; i++)
        {
            l[i] = Math.Abs(a[i] - a[i - 1]) + l[i - 1];
        }

        for(int i = 1; i <= n; i++)
        {
            Console.WriteLine(l[n + 1] - Math.Abs(a[i] - a[i - 1]) - Math.Abs(a[i + 1] - a[i]) + Math.Abs(a[i + 1] - a[i - 1]));
        }
    }
}

Measured memory_bytes: 27868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author Node2
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String str = in.readLine();
        
     
        
        String[] sp = str.split(" ");
        int[] a = new int[sp.length];
        for(int i=0;i<sp.length;i++){
            a[i] = Integer.parseInt(sp[i]);
        }
        int num = a[0];
        int length = a[1];
      
        str = in.readLine();
        String[] sp2 = str.split(" ");
        int[] a2 = new int[sp2.length];
        for(int i=0;i<sp2.length;i++){
            a2[i] = Integer.parseInt(sp2[i]);
        }
        
        int anser = 0;
       
        while(true){
             boolean flug = true;
            String str2 = String.valueOf(anser);
            for(int k=0;k<str2.length();k++){
                int n = Character.digit(str2.charAt(k),10);
                for(int j=0;j<a2.length;j++){
                    if(n==a2[j]){
                        flug = false;
                        break;
                    }
                }
            }

            if(flug && num <= anser){
                break;
            }
            anser++;
          
        }
        
        System.out.println(anser);
    }
}

Measured memory_bytes: 14792
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, s = 0; cin >> n;
  v1i v(n), a(n); rep(i, n) cin >> v[i];
  rep(i, n) s ^= v[i];
  rep(i, n) a[i] = s ^ v[i];
  rep(i, n){
    cout << a[i];
    if(i < n-1) cout << " ";
    else cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 4712
#include <iostream>
#include <set>

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, res = 0;
    cin >> n;
    set<int> t;
    for (int i = 0; i < n; i++)
    {
        int val;
        cin >> val;
        t.insert(val);
        auto it = *t.begin();
        if (it == val)
            res++;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 9600
import scala.io.StdIn.readLine

object Main extends App {
  val input = readLine.split(" ").map(_.toInt)
  val (a, b) = (input(0), input(1))

  (a, b) match {
    case _ if a > b => println("a > b")
    case _ if a < b => println("a < b")
    case _ if a == b => println("a == b")
  }

}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;

    cout << 0 << endl;

    string r0;
    cin >> r0;

    if (r0 == "Vacant") {
        return;
    }

    string r;
    int left = -1, right = N;
    while (right - left > 1) {
        int mid = (left + right) >> 1;
        cout << mid << endl;
        cin >> r;
        if (r == "Vacant") {
            return;
        }

        if (mid & 1) {
            if (r == r0) {
                right = mid;
            }
            else {
                left = mid;
            }
        }
        else {
            if (r == r0) {
                left = mid;
            }
            else {
                right = mid;
            }
        }
    }

}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}


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

long long int MOD = 1000000007;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    if (S[0] == 'W' || S[2 * N - 1] == 'W')
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> C(2 * N);
    C[0] = 1;
    long long int cnt = 1;
    for (int i = 1; i < 2 * N; i++)
    {
        if (S[i] == S[i - 1])
        {
            C[i] = 1 - C[i - 1];
        }
        else
        {
            C[i] = C[i - 1];
        }
        cnt += (2 * C[i] - 1);
    }
    if (C[2 * N - 1] == 1 || (cnt != 0))
    {
        cout << 0 << endl;
        return 0;
    }
    cnt = 1;
    int cl = 0;
    for (int i = 0; i < 2 * N; i++)
    {
        if (C[i])
        {
            cl++;
        }
        else
        {
            cnt = cnt * cl % MOD;
            cl--;
        }
    }
    for (int i = 0; i < N; i++)
    {
        cnt = cnt * (i + 1) % MOD;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1412
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val p = IntArray(n){int()-1}
    val indices = IntArray(n)
    for (i in n) indices[p[i]] = i
    val s = TreeSet<Int>()
    var ret = 0L
    for (x in (0 until n).reversed()) {
        val i = indices[x]
        s.add(i)
        val l = IntArray(2){-1}
        val r = IntArray(2){n}
        do {
            l[1] = s.lower(i) ?: break
            l[0] = s.lower(l[1]) ?: break
        } while (false)
        do {
            r[0] = s.higher(i) ?: break
            r[1] = s.higher(r[0]) ?: break
        } while (false)
        val ls = IntArray(2)
        val rs = IntArray(2)
        ls[0] = l[1] - l[0]
        ls[1] = i - l[1]
        rs[0] = r[0] - i
        rs[1] = r[1] - r[0]
        ret += (x + 1) * (ls[0].toLong() * rs[0] + ls[1].toLong() * rs[1])
    }
    println(ret)
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }

    inline fun println(block: IO.() -> Any) {
        println(block())
        out.flush()
    }
}
// endregion

Measured memory_bytes: 46892
// input macro 
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        a: i32,
        b: i32,
        k: usize,
    }
    let mut v = vec![];
    let n = std::cmp::min(a, b) + 1;
    for i in 1..n {
        if a % i == 0 && b % i == 0 {
            v.push(i);
        }
    }
    let m = v.len();
    println!("{}", v[m - k]);
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int d,t,s;
	scanf("%d %d %d",&d,&t,&s);
	int jarak = t * s;
	if(jarak >= d){printf("Yes\n");}
	else{printf("No\n");}
	
	return 0;
};

Measured memory_bytes: 3764
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> A;
  int amap[1000005];
  int bmap[1000005];
  for(int i=0;i<1000005;++i) {
    amap[i] = 0;
    bmap[i] = 0;
  }
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) A.push_back(tmp);
    amap[tmp]++;
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for(int i=0;i<A.size();++i) {
    if(amap[A[i]]==1 && bmap[A[i]]==0) {
      ans++;
      for(int j=1;A[i]*j<=1000000;++j) bmap[A[i]*j]++;
    }
    else if(bmap[A[i]]>0) continue;
    else {
      for(int j=1;A[i]*j<=1000000;++j) bmap[A[i]*j]++;
    }
  }
  cout<<ans<<endl;
}



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

int gcd(int a,int b){
	
	if(b==0)
		return a;
	
	return gcd(b,a%b);
}
int main(){
  	
  	int x;
  	cin>>x;
  	int temp = gcd(x,360);
  	cout<<360/temp;
}

Measured memory_bytes: 3632
package main

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

type path struct {
	node int
	cost int
}

type graph [][]path

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)

	graph := make(graph, n+1)
	for i := 0; i < n-1; i++ {
		a := scanInt(sc)
		b := scanInt(sc)
		cost := scanInt(sc)
		graph[a] = append(graph[a], path{b, cost})
		graph[b] = append(graph[b], path{a, cost})
	}

	q := scanInt(sc)
	k := scanInt(sc)

	costs := make([]int, n+1)
	calcCosts(graph, costs, k, -1, 0)

	for i := 0; i < q; i++ {
		a := scanInt(sc)
		b := scanInt(sc)
		cost := costs[a] + costs[b]
		fmt.Println(cost)
	}
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func calcCosts(graph graph, costs []int, from int, prev int, totalCost int) {
	paths := graph[from]
	for _, p := range paths {
		if p.node != prev {
			cost := totalCost + p.cost
			costs[p.node] = cost
			calcCosts(graph, costs, p.node, from, cost)
		}
	}
}

Measured memory_bytes: 61824
N = gets.to_i
A = gets.chomp.split.map(&:to_i)

ans = true
A.each do |i|
  if i.even? # 偶数か？
    if !(i % 3 == 0 || i % 5 == 0) 
      ans = false
    end
  end
end

puts ans ? "APPROVED" : "DENIED"

Measured memory_bytes: 1788
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn abs(n: i32) -> u64 {
    if n >= 0 {
        n as u64
    } else {
        -n as u64
    }
}

fn main() {
    let n: usize = read();
    let mut av: Vec<i32> = read_vec();
    let l = av.len();

    for i in 0..av.len() {
        av[i] -= i as i32 + 1;
    }

    av.sort();

    let b: i32 = av[l / 2];
    let mut ans: u64 = 0;
    for a in av {
        ans += abs(a - b);
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	string s, t; cin >> s >> t;
	string ans = s + t;
	REP(i, n) {
		bool same = true;
		REP(j, n - i) {
			same &= s[j + i] == t[j];
		}
		if (same) {
			ans = s.substr(0, i) + t;
			break;
		}
	}
	cout << ans.length() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int h, w, n;
	cin >> h >> w >> n;
	vector<int> a(n), b(n);
	map<P, int> mp;
	rep(i, n) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		rep(j, 3) rep(k, 3) if (0 <= a[i] - j && a[i] - j <= h - 3 && 0 <= b[i] - k && b[i] - k <= w - 3) mp[{a[i] - j, b[i] - k}]++;
	}
	vector<int> ans(10);
	ans[0] = (h - 2)*(w - 2);
	for (auto i : mp) {
		ans[0]--;
		ans[i.second]++;
	}
	for (int i : ans) cout << i << endl;
}

Measured memory_bytes: 60160
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin>>n;
  vector<int> l(2*n);
  for(int i=0;i<2*n;++i) cin >> l[i];
  sort(all(l));
  int out=0;
  for(int j=0; j<n;++j)out += l[2*j];
  cout << out << endl;
  return 0;
}


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

using namespace std;


#define MAXN 51
int dx[4] = {1,  0, -1,  0};
int dy[4] = {0, -1,  0,  1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string a[MAXN];
  int h, w, black = 0;;
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> a[i];
    for (auto &c : a[i]) {
      black += c=='#';
    }
  }
  queue<pair<int, pair<int, int>>> q;
  q.push({1, {0, 0}});
  int ans = -1;
  while (!q.empty()) {
    auto nxt = q.front();
    q.pop();
    int i, j;
    tie(i, j) = nxt.second;
    if (i==h-1 && j==w-1) {
      ans =  h*w-black-nxt.first;
      break;
    }
    for (int di = 0; di < 4; ++di) {
      int I = i+dx[di];
      int J = j+dy[di];
      if (I<0 || I>=h || J<0 || J>=w || a[I][J]=='#') continue;
      a[I][J] = '#';
      q.push({nxt.first+1, {I, J}});
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef pair<int, int> pii;

int N, K;
int c[5000], r[5000];
vector<int> road[5000];
vector<pii> g[5000]; // cost, to
bool done[5000];
int d[5000];

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%d %d", &c[i], &r[i]);
	
	REP(i, K) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	
	REP(i, N) {
		int cost = c[i];
		int from = i;
		fill(done, done + N, false);
		
		queue<pii> que;
		que.push(pii(r[i], from));
		
		while (!que.empty()) {
			pii now = que.front(); que.pop();
			
			int lim = now.first;
			int pos = now.second;
			
			if (done[pos]) continue;
			done[pos] = true;
			if (from != pos) g[from].push_back(pii(cost, pos));
			
			if (lim == 0) continue;
			
			REP(j, road[pos].size()) que.push(pii(lim - 1, road[pos][j]));
		}
	}
	
	priority_queue<pii, vector<pii>, greater<pii> > pq; // cost, pos
	pq.push(pii(0, 0));
	fill(d, d + N, INF);
	
	while (!pq.empty()) {
		pii now = pq.top(); pq.pop();
		
		int nc = now.first;
		int pos = now.second;
		
		if (d[pos] <= nc) continue;
		d[pos] = nc;
		
		REP(i, g[pos].size()) {
			int cost = g[pos][i].first;
			int to = g[pos][i].second;
			
			if (d[to] > d[pos] + cost) pq.push(pii(d[pos] + cost, to));
		}
	}
	
	cout << d[N - 1] << endl;	
	return 0;
}

Measured memory_bytes: 193260
# coding: utf-8
s=''
sx,sy,tx,ty=map(int,input().split())
for i in range(tx-sx):
    s+='R'
for i in range(ty-sy):
    s+='U'
for i in range(tx-sx):
    s+='L'
for i in range(ty-sy):
    s+='D'
s+='D'
for i in range(tx-sx+1):
    s+='R'
for i in range(ty-sy+1):
    s+='U'
s+='LU'
for i in range(tx-sx+1):
    s+='L'
for i in range(ty-sy+1):
    s+='D'
s+='R'
print(s)

Measured memory_bytes: 3064
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
k = [-1] * 26
for i in range(d):
    res = -100000000
    p = 0
    for j in range(26):
        tmp = 0
        tmp += s[i][j]
        for x in range(26):
            if x == j:
                continue
            tmp -= c[x] * (i - k[x])
        if res < tmp:
            res = tmp
            p = j
    k[p] = i
    print(p + 1)


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

const ll MOD = 1e9+7;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  
  vector<int> num(n);
  rep(i, n) {
    num[i] = i+1;
  }
  
  int pnum = 0;

  int qnum = 0;
 
  int cnt = 0;
  do {
    int pcnt = 0;
    int qcnt = 0;
    ++cnt;
    rep(i, n) {
      if(p[i] == num[i]) {
        ++pcnt;
      }
      if(q[i] == num[i]) {
        ++qcnt;
      }
    }
    if(pcnt == n) {
      pnum = cnt;
    }
    if(qcnt == n) {
      qnum = cnt;
    }
  }while(next_permutation(num.begin(), num.end()));
  
  int ans = abs(pnum- qnum);
  
  cout << ans << endl;
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> primeFactors;
    for (int i = 2; i <= 55555; i++)
    {
        bool isPrime = true;
        for (int j = 2; j * j <= i; j++)
        {
            if (i % j == 0)
            {
                isPrime = false;
                break;
            }
        }
        if (isPrime)
        {
            primeFactors.push_back(i);
        }
    }
    vector<int> answers;
    for(int primeFactor: primeFactors)
    {
        if(primeFactor % 10 == 3)
        {
            answers.push_back(primeFactor);
            if(answers.size() == N)
            {
                break;
            }
        }
    }
    for (int i = 0; i < N; i++)
    {
        if (i > 0)
        {
            cout << " ";
        }
        cout << answers.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int R = Integer.parseInt(sc.next());
        out.println(R*R);
        
        out.flush();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

ll burger(int level) {
    if (level == 0) return 1;
    return burger(level - 1) * 2 + 3;
}

ll patti(int level) {
    if (level == 0) return 1;
    return patti(level - 1) * 2 + 1;
}

ll eat(int level, ll x) {
    if (level == 0 && x == 1) return 1;
    if (x <= 1) return 0;
    if (burger(level) - x < 2) return patti(level);

    x--;
    ll ret = 0;
    if (x >= burger(level - 1)) {
        x -= burger(level - 1);
        ret += patti(level - 1);
        if (x == 0) return ret;
        else {
            x--;
            ret++;
        }
    }
    return ret + eat(level - 1, x);
}

int main() {
    ll N, X;
    cin >> N >> X;
    cout << eat(N, X) << endl;
    return 0;
}

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

class DisjointSet{
    public:
        vector<int> rank,p;
        
        DisjointSet(int size){
            rank.resize(size,0);
            p.resize(size,0);
            for(int i=0;i<size;i++){
                rank[i]=0;
                p[i]=i;
            }
        }
        
        bool same(int x,int y){
            return find(x)==find(y);
        }
        
        int find(int x){
            if(x==p[x]){
                return p[x];
            }else{
                return find(p[x]);
            }
        }
        
        void unite(int x,int y){
            link(find(x),find(y));
        }
        
        void link(int x,int y){
            if(x==y) return;
            if(rank[x]>rank[y]){
                p[y]=x;
            }else{
                p[x]=y;
                if(rank[x]==rank[y]) rank[y]++;
            }
        }
        
};

int main(void){
    int n,q;
    int t,a,b;
    cin >> n >> q;
    
    DisjointSet ds = DisjointSet(n);
    
    for(int i=0;i<q;i++){
        cin >> t >> a >> b;
        if(t==0){
            ds.unite(a,b);
        }
        else if(t==1){
            if(ds.same(a,b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int n;
vector<int> x, y;
int main() {
    cin >> n;
    x.resize(n);
    y.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    int a = 0;
    for (int i = 0; i < n; ++i) {
        int j = (i + 1) % n;
        a += x[i] * y[j] - x[j] * y[i];
    }
    printf("%.1f\n", abs(double(a)) / 2);
    return 0;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int cnt[10][10];

void Get(int x){
  int l = x % 10;
  int f = -1;
  while (x){
    f = x % 10;
    x /= 10;
  }
  cnt[f][l]++;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int n; cin >> n;
  for (int i = 1; i <= n; ++i) Get(i);
  ll ans = 0;
  For(a, 1, 9) For(b, 1, 9) ans = ans + 1ll * cnt[a][b] * cnt[b][a];
  cout << ans;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MX=2e5+5;
int n,x,l,r,p,q,a[MX],b[MX];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    reverse(b,b+n);
    l=r=-1;
    for(int i=0; i<n; i++){
        if(a[i]!=b[i]) continue;
        if(l==-1) l=i;
        r=i;
        x=a[i];
    }
    if(l==-1){
        cout << "Yes\n";
        for(int i=0; i<n; i++) cout << b[i] << " ";
        return 0;
    }
    p=q=-1;
    for(int i=0; i<n; i++){
        if(a[i]==x || b[i]==x){
            if(p==-1) p=i;
            q=i;
        }
    }
    int i=0,j=l;
    while(i<p && j<=r) swap(b[i++],b[j++]);
    i=q+1;
    while(i<n && j<=r) swap(b[i++],b[j++]);
    for(int i=0; i<n; i++){
        if(a[i]==b[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for(int i=0; i<n; i++) cout << b[i] << " ";
    return 0;
}

Measured memory_bytes: 5232