akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include<map>
#include<set>
#include<stack>
#include<sstream>
#define endl '\n'
#define debug(x) cout<<"This is "<<x<<'\n'
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int maxn=2e6+10;
ll a[maxn],k=0;
void dfs(ll i){
    if(i>1e10)
        return ;
    a[k]=i;
    ++k;
    for(int j=0;j<=9;++j){
        if(abs(i%10-j)<=1)
            dfs(i*10+j);
    }

}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=9;++i) dfs(i);
//    sort(a,a+k);
    nth_element(a,a+n-1,a+k);
    cout<<a[n-1]<<endl;
}


Measured memory_bytes: 1792
//هوالحق
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;

template<typename T>
T In() {
   T x;
   cin >> x;
   return x;
}

int main() {
   ios::sync_with_stdio(false), cin.tie(nullptr);
   int n = In<int>(), k = In<int>(), q = In<int>();
   vector<int> V(n);
   for(int i = 0; i < q; i++) V[In<int>() - 1]++;
   for(int i = 0; i < n; i++) cout << (V[i] + k - q > 0 ? "Yes" : "No") << "\n";
   return cout << endl, 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
P = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

#マスに与えられたスコアが全部負だった場合には，その中で最もダメージの小さいマスを一つ踏んで終わる。
C_max = max(C[1:])
if C_max < 0:
    print(C_max)
    exit()


ans = 0

done = [False] * (N + 1) #チェック済みのマスはTrueにしていく。(loopはバラバラの構成員で構成されてるので。)

#loopの構成員をもらう。 -→ loopの中でマスaから始まりマスbで止まる操作をする場合の最大スコアを数える。
#の順番で解く。

for i in range(1, N + 1):
    if done[i]:
        continue
        #マスiがチェック済みの場合には何もせずiを次に進める。（continue）

    loop = [i] #ここにloopの構成員が記録される。iは最初から入れておく。
    now = P[i] #iから一歩進んだマスを起点として，loop構成員の記録を開始する。
    while now != i:
        loop.append(now)
        done[now] = True
        now = P[now]
        #今立っているマスがiでない場合は，loop構成員リストに記録して，doneをTrueにして，足を一歩進める。

    #print(loop)
    #loopの構成員のメモが完了！

    L = len(loop)
    S = sum(C[v] for v in loop) #loopを一周した時のスコア

    for a_ind in range(L):
        a = loop[a_ind]
        score_ab = -C[a]
        #例えば[3, 6, 4, 7]のloopがあった時，a = 3→6→4→7 と移っていきたいので，a_ind = 0→1→2...として，a =  loop[0]→loop[1]→loop[2]→loop[3]とする。bもまた然り。
        for b_ind in range(a_ind, a_ind + L):#aから数週してaに戻るプレイも可能なので，b == aとなる場合も含んでおかなければならない。
            dist_ab = b_ind - a_ind
            if dist_ab > K:
                break
            b = loop[b_ind % L]
            score_ab += C[b]

            max_score = score_ab + max(0, S) * ((K - dist_ab) // L)
            #スコアの最大値は，
            # S > 0の場合，[aからbまで移動した時のスコア] ＋ S * [可能な限りloopを周回する]　（周回した方が得なので）
            # S < 0の場合，[aからbまで移動した時のスコア]　（周回した方が損なので）
            #上の場合分けの切り替えを　max(0, S)　で行っている！地味にすごい！

            ans = max(ans, max_score)

print(ans)

Measured memory_bytes: 75040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

vector<int> Eratosthenes(const int N) {
  vector<bool> is_prime(N + 1);
  for (int i = 0; i <= N; ++i) {
    is_prime[i] = true;
  }
  vector<int> P;
  for (int i = 2; i <= N; ++i) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int Q;
  cin >> Q;
  vector<int> L(Q);
  vector<int> R(Q);
  rep(i, 0, Q) cin >> L[i] >> R[i];

  vector<int> p = Eratosthenes(100000);
  vector<int> num;
  for (int i : p) {
    int n = (i + 1) / 2;
    if (binary_search(all(p), n)) num.push_back(i);
  }
  rep(i, 0, Q) {
    int l = lower_bound(all(num), L[i]) - num.begin();
    int r = upper_bound(all(num), R[i]) - num.begin();
    cout << r - l << endl;
  }
  return 0;
}


Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = input()
    S = list(str(N))

    sm = 0
    for s in S:
        n = int(s)
        sm += n

    if sm % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solve()



Measured memory_bytes: 10856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)

int main() {
	int L; cin >> L;
	double ans = L*L*L/(double)27;
	cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3772
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;


signed main()
{
	char str[100];
	cin >> str;
	if (strlen(str) >= 4)
	{
		if (str[0] == 'Y' &&
			str[1] == 'A' &&
			str[2] == 'K' &&
			str[3] == 'I')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}



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

int main(){
  int a, b, c; char x;
  int rectangle = 0, diamond = 0;
  while(cin >> a >> x >> b >> x >> c){
    if(a*a + b*b == c * c) rectangle++;
    if(a == b) diamond++;
  }

  cout << rectangle << endl;
  cout << diamond << endl;
}
  
  


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r,d,a=0,i;
	cin>>l>>r>>d;
	for(i=l;i<=r;i++){
		if(i%d==0)
		a++;
	}
	cout<<a;
	
	
	return 0;
}

Measured memory_bytes: 3620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ERedScarf {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<ll> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      ll x = 0;
      rep(i, n) {
        x ^= a[i];
      }
      rep(i, n) {
        cout << (a[i]^x) << ' ';
      }
      cout << endl;

    }
};

signed main() {
  ERedScarf solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 4772
import collections

n = int(input())
lst = [int(s) for s in input().split()]

is_success = True

if n % 2 == 1:
    is_success = lst.count(0) == 1

counters = collections.Counter(lst)

for i in range(n - 1, 0, -2):
    if counters[i] != 2:
        is_success = False
        break

if is_success:
    tmp = 1

    for _ in range(n // 2):
        tmp *= 2
        tmp %= 10 ** 9 + 7

    print(tmp)
else:
    print(0)

Measured memory_bytes: 14820
import collections

N = int(input())

lw = list()
for i in range(N):
    lw.append(input())

def check1(l):
    c = collections.Counter(l)
    lv = list(c.values())
    if lv == [1] * len(lv):
        return 1

def check2(l):
    c = 0
    for i in range(len(l)-1):
        if l[i][-1] == l[i+1][0]:
            c += 1
    if c == len(l) - 1:
        return 1

if check1(lw) == 1 and check2(lw) == 1:
    print("Yes")
else:
    print("No")        


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

int n, k;

int main() {
    cin >> n >> k;
    long long a[n*k];
    for (int i=0; i<n; i++) a[i] = 1;
    for (int i=1; i<k; i++) a[n*i] = 1;
    for (int i=1; i<k; i++) {
        for (int j=1; j<n; j++) {
            a[n*i+j] = (i+1)*(a[n*i+j-1]);
            for (int u=0; u<i-1; u++) a[n*i+j] = (a[n*i+j] - a[n*u+j-1]);
            a[n*i+j] = ((a[n*i+j] % 1000000007) + 1000000007) % 1000000007;
        }
    }
    cout << a[n*k-1] << endl;
}


Measured memory_bytes: 10904
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for (int i = 0; i < N; i++) 
			X[i] = sc.nextInt();

		int ans = Integer.MAX_VALUE;
		for (int i = 1; i <= 100; i++) {
			ans = Math.min(ans, caluc(X, i));
		}
		System.out.println(ans);
	}
	static int caluc(int[] X, int p) {
		int sum = 0;
		for (int i = 0; i < X.length; i++) {
			sum += Math.abs(p-X[i]) * Math.abs(p-X[i]);
		}
		return sum;
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int n, v[55];
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v, v + n);
	int p = 1;
	long double ans = 0;
	for (int i = n - 1; i > 1; i--)
	{
		ans += v[i] * 1.0 / (1ll << p);
		p++;
	}
	ans += (v[0] + v[1]) * 1.0 / (1ll << p);
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const solve = (i, m) => {
    if (m == 0) return true;
    if (i >= n1) return false;
    return res = solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  };

  arr2.map(m => solve(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();



Measured memory_bytes: 16936
ans = ['Possible', 'Impossible']

def judge(a, b):
	if a % 3 == 0:
		return 0
	elif b % 3 == 0:
		return 0
	elif (a + b) % 3 == 0:
		return 0
	return 1

inpt = map(int, raw_input().split())
print ans[judge(inpt[0], inpt[1])]


Measured memory_bytes: 2568
H, W, M = map(int, input().split())
lh = [0]*(H+1)
lw = [0]*(W+1)
l = []
for _ in range(M):
  h, w = map(int, input().split())
  lh[h] += 1
  lw[w] += 1
  l += [[h, w]]

maxh = max(lh)
maxw = max(lw)
cnt = 0

ch = lh.count(maxh)
cw = lw.count(maxw)
for y, x in l:
  if lh[y] == maxh and lw[x] == maxw:
    cnt += 1

ans = maxh+maxw
if cnt == ch*cw:
  ans -= 1

print(ans)    


Measured memory_bytes: 123624
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++) {
		    nodes[i] = new Node(i);
		}
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    int count = sc.nextInt();
		    for (int j = 0; j < count; j++) {
		        int y = sc.nextInt();
		        nodes[x].add(y);
		        nodes[y].parent = x;
		    }
		}
		for (Node x : nodes) {
		    if (x.parent == -1) {
		        set(nodes, x.idx, 0);
		        break;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (Node x : nodes) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
	
	static void set(Node[] nodes, int idx, int depth) {
	    nodes[idx].depth = depth;
	    for (int x : nodes[idx].children) {
	        set(nodes, x, depth + 1);
	    }
	}
	
	static class Node {
	    int idx;
	    int parent;
	    int depth;
	    ArrayList<Integer> children;
	    
	    public Node(int idx) {
	        this.idx = idx;
	        parent = -1;
	        children = new ArrayList<>();
	    }
	    
	    public void add(int x) {
	        children.add(x);
	    }
	    
	    public String toString() {
	        StringBuilder sb = new StringBuilder();
	        sb.append("node ").append(idx).append(": parent = ");
	        sb.append(parent).append(", depth = ").append(depth).append(", ");
	        if (parent == -1) {
	            sb.append("root");
	        } else if (children.size() == 0) {
	            sb.append("leaf");
	        } else {
	            sb.append("internal node");
	        }
	        sb.append(", [");
	        for (int i = 0; i < children.size(); i++) {
	            if (i > 0) {
	                sb.append(", ");
	            }
	            sb.append(children.get(i));
	        }
	        sb.append("]");
	        return sb.toString();
	    }
	}
}



Measured memory_bytes: 217588
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int w,h,a,b,r;
    cin >> w >> h >> a >> b >> r;
    if(0 <= a - r && w >= a + r && 0 <= b - r && h >= b + r) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define N 200005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, x, y;
int c[N], w[N];
int col_min[N], cnt[N], mina, minb, tot;
int fac[N], ifac[N];
bool pd_col[N];

void init() {
	ifac[0] = fac[0] = 1;
	for (int i = 1; i < N; ++i) fac[i] = mul(fac[i - 1], i);
	ifac[N - 1] = inv(fac[N - 1]);
	for (int i = N - 2; i; --i) ifac[i] = mul(ifac[i + 1], i + 1);
}

int C(int x, int y) {
	if (x < y || y < 0) return 0;
	return mul(fac[x], mul(ifac[y], ifac[x - y]));
}

int main() {
	init();
	read(n, x, y);
	memset(col_min, 0x3f, sizeof col_min);
	mina = minb = inf;

	for (int i = 1; i <= n; ++i) {
		read(c[i], w[i]);
		chkmin(col_min[c[i]], w[i]);
	}
	for (int c = 1; c <= n; ++c) {
		if (col_min[c] < mina) minb = mina, mina = col_min[c];
		else if (col_min[c] < minb) minb = col_min[c];
	}

	if (mina + minb > y) return puts("1"), 0;
	for (int c = 1; c <= n; ++c)
		if (col_min[c] + mina > y)
			pd_col[c] = true;

	for (int i = 1; i <= n; ++i) {
		if (pd_col[c[i]]) continue;
		if (col_min[c[i]] + w[i] <= x) ++cnt[c[i]], ++tot;
		else if ((col_min[c[i]] == mina ? minb : mina) + w[i] <= y) ++cnt[c[i]], ++tot;
	}

	int ans = 1;
	for (int c = 1; c <= n; ++c)
		ans = mul(ans, C(tot, cnt[c])), tot -= cnt[c];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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; }

long long int a[3][100001];

struct mise {
	int number;
	string name;
	int value;
};

bool biggerthan(mise a, mise b) {
	if (a.name != b.name)  return a.name < b.name;
	return a.value > b.value;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int z;
			cin >> z;
			a.at(z - 1)++;
		}
	}
	int cnt = 0;
	for (int i = 0; i < m; i++) {
		if (a.at(i) == n) cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
  //  freopen("in.cpp","r",stdin);
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x = x2 - x1;
    int y = y2 - y1;
    for(int i=0;i<x;i++)cout<<"R";
    for(int i=0;i<y;i++)cout<<"U";
    for(int i=0;i<x;i++)cout<<"L";
    for(int i=0;i<y;i++)cout<<"D";
    cout<<"D";
    for(int i=0;i<x+1;i++)cout<<"R";
    for(int i=0;i<y+1;i++)cout<<"U";
    cout<<"L";
    cout<<"U";
    for(int i=0;i<x+1;i++)cout<<"L";
    for(int i=0;i<y+1;i++)cout<<"D";
    cout<<"R"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace AOJ
{
    class Program
    {


        private static string solve(int n)
        {
            string[,] cnvTbl = new string[,]{
                {"7","9"}
                ,{"6","8"}
                ,{"5","7"}
                ,{"4","5"}
            };

            string str8 = Convert.ToString(n, 8);

            for (int i = 0; i < cnvTbl.GetLength(0); i++)
            {
                str8 = str8.Replace(cnvTbl[i, 0], cnvTbl[i, 1]);
            }
            return str8;
        }
        static void Main(string[] args)
        {

            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                Console.WriteLine(solve(n));
            }
        }
        //private static void solve(int n)
        //{
        //    char[,] cnvTbl = new char[,]{
        //        {'7','9'}
        //        ,{'6','8'}
        //        ,{'5','7'}
        //        ,{'4','5'}
        //    };

        //    string str8 = Convert.ToString(n, 8);

        //    char[] char8 = str8.ToCharArray();
            
        //    for (int j = 0; j < char8.Length; j++)
        //    {
        //        for (int i = 0; i < cnvTbl.GetLength(0); i++)
        //        {
        //            if (cnvTbl[i, 0] == char8[j])
        //            {
        //                char8[j] = cnvTbl[i, 1];
        //                break;
        //            }
        //        }
        //    }
        //    for (int i = 0; i < char8.Length; i++) Console.Write(char8[i]);
        //    Console.WriteLine();
        //}
        //static void Main(string[] args)
        //{

        //    while (true) {
        //        int n  = int.Parse(Console.ReadLine());
        //        if (n == 0) break;
        //        solve(n);
        //    }
        //}
    }
}

Measured memory_bytes: 5580
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a[9];
    for(int i = 0; i < 9; i++){
        cin >> a[i];
    }
    int n;
    cin >> n;
    int aa[n];
    for(int j = 0; j < n; j++){
     cin >> aa[j];
     if(aa[j] == a[0]){
         a[0] = 0;
     }
     if(aa[j] == a[1]){
         a[1] = 0;
     }
     if(aa[j] == a[2]){
         a[2] = 0;
     }
     if(aa[j] == a[3]){
         a[3] = 0;
     }
     if(aa[j] == a[4]){
         a[4] = 0;
     }
     if(aa[j] == a[5]){
         a[5] = 0;
     }
     if(aa[j] == a[6]){
         a[6] = 0;
     }
     if(aa[j] == a[7]){
         a[7] = 0;
     }
     if(aa[j] == a[8]){
         a[8] = 0;
     }
    }
    if(a[0] == 0 && a[1] == 0 && a[2] == 0){
        cout << "Yes";
        return 0;
    }else if(a[3] == 0 && a[4] == 0 && a[5] == 0){
        cout << "Yes";
        return 0;
    } else if(a[6] == 0 && a[7] == 0 && a[8] == 0){
        cout << "Yes";
        return 0;
    } else if(a[0] == 0 && a[3] == 0 && a[6] == 0){
        cout << "Yes";
        return 0;
    }else if(a[1] == 0 && a[4] == 0 && a[7] == 0){
        cout << "Yes";
        return 0;
    }else if(a[2] == 0 && a[5] == 0 && a[8] == 0){
        cout << "Yes";
        return 0;
    } else if(a[2] == 0 && a[4] == 0 && a[6] == 0){
        cout << "Yes";
        return 0;
    }else if(a[0] == 0 && a[4] == 0 && a[8] == 0){
        cout << "Yes";
        return 0;
    } else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3572
from collections import Counter
N = int(input())
S = input()
ctr1 = Counter()
ctr2 = Counter()

for b in range(2**N):
    blue = red = ''
    for k in range(N):
        if b & (1<<k):
            blue += S[k]
        else:
            red += S[k]
    ctr1[(blue,red)] += 1

T = S[::-1][:N]
for b in range(2**N):
    blue = red = ''
    for k in range(N):
        if b & (1<<k):
            blue += T[k]
        else:
            red += T[k]
    ctr2[(blue,red)] += 1

ans = 0
for (b1,r1),v1 in ctr1.items():
    ans += v1 * ctr2[(r1,b1)]
print(ans)

Measured memory_bytes: 237932
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

ans = 0
cur = 0
for i in range(1, N):
  if A[i] <= A[i - 1]:
    cur += 1
    if cur > ans:
      ans = cur
  else:
    cur = 0

print(ans)

Measured memory_bytes: 20704
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    cout << 3*pow(n,2);
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
    ll A,B,C,K,sum=0;
    cin>>A>>B>>C>>K;
    while(K>0 && A>0){
        A--;
        K--;
        sum++;
    }
    while(K>0 && B>0){
        B--;
        K--;
    }
    while(K>0 && C>0){
        C--;
        K--;
        sum--;
    }
    cout<<sum<<endl;
return 0;

}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int gcd(int x,int y){
	if(x==0)return y;
	return gcd(y%x,x);
}
int main(){
	while(true){
		int a,b;
		cin>>a>>b;
		if(cin.eof())return 0;
		int g=gcd(a,b);
		cout<<g<<' '<<a/g*b<<endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void){
    int n,m,i,j,k,s,ans=0;
    scanf("%d%d",&n,&m);
    int a[10]={0},p=0;
    for(i=0;i<m;i++){
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&s);
            s--;
            a[s] |= 1<<i;
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&s);
        p |= s<<i;
    }
    for(i=0;i<(1<<n);i++){
        int t=0;
        for(j=0;j<n;j++){
            if(i>>j&1) t^=a[j];
        }
        if(t==p) ans++;
    }
    printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 999;
  for(int i; i<n-2; i++){
    int m = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2] - '0';
    ans = min(ans, abs(m-753));
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    Int a;
    cin >> a;
    Int result = a;
    for (Int i = 0; i < 2; ++i) {
        result += 1;
        result *= a;
    }
    cout << result << endl;
    return 0;
}


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

int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;
  char k = S[K-1];
  for(int i = 0; i < N; i++){
    if(S[i] != k){
      S[i] = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a,b,c,d,e,k int
	fmt.Scan(&a,&b,&c,&d,&e,&k)

	if b - a > k {
		fmt.Println(":(")
	} else if c - a > k {
		fmt.Println(":(")
	} else if d - a > k {
		fmt.Println(":(")
	} else if e - a > k {
		fmt.Println(":(")
	} else if c - b > k {
		fmt.Println(":(")
	} else if d - b > k {
		fmt.Println(":(")
	} else if e - b > k {
		fmt.Println(":(")
	} else if d - c > k {
		fmt.Println(":(")
	} else if e - c > k {
		fmt.Println(":(")
	} else if e - d > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}

Measured memory_bytes: 512
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int A, B;
  sc.scan(A, B);

  if (B % A == 0)
    writeln(A + B);
  else
    writeln(B - A);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  int n,a[50],mina,minp,maxa,maxp;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  maxa=mina=a[0];
  minp=maxp=0;
  for(int i=1;i<n;i++){
    if(a[i]<mina){
      mina=a[i];
      minp=i;
    }
    if(a[i]>maxa){
      maxa=a[i];
      maxp=i;
    }
  }
  printf("%d\n",2*n-1);
  for(int i=1;i<=n;i++){
    if(abs(mina)>abs(maxa))
      printf("%d %d\n",minp+1,i);
    else
      printf("%d %d\n",maxp+1,i);
  }
  if(abs(mina)>abs(maxa))
    for(int i=n;i>1;i--)
      printf("%d %d\n",i,i-1);
  else
    for(int i=1;i<n;i++)
      printf("%d %d\n",i,i+1);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int a[100][100], b[100][100], n, m, l;
int main() {
    cin >> n >> m >> l;
    rep(i,n) {
        rep(j,m) {
            cin >> a[i][j];
        }
    }
    rep(i,m) {
		rep(j,l) {
	        cin >> b[i][j];
		}
    }
    rep(i,n) {
        rep(j,l) {
			ll ret = 0;
			rep(k,m) {
		        ret += a[i][k] * b[k][j];
	        }
			cout << ret;
			if(j != l - 1) cout << " ";
		}
		cout << endl;
    }
	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int width = sc.nextInt();
		String c[] = new String[height];
		for(int i = 0; i < height;i++){
			c[i] = sc.next();
		}
		int crowd[][] = new int[width][height];
		for(int i = 0;i <height;i++){
			for(int j = 0;j < width;j++){
				if(c[i].charAt(j) == 'c'){
					crowd[j][i] = 0;
				}else{
					crowd[j][i] = -1;	
				}
			}
		}
		for(int i = 0;i <height;i++){
			for(int j = 0;j < width;j++){
				for(int k = width-1;k >= 0;k--){
					if(crowd[k][i] == 0 && crowd[j][i] == -1 && k < j){
						crowd[j][i] = j-k;
					}
				}
			}
		}
		for(int i = 0;i <height;i++){
			for(int j = 0;j < width;j++){
				if(j < width-1){
					System.out.print(crowd[j][i]+" ");					
				}else{
					System.out.print(crowd[j][i]);						
				}
			}
			System.out.println();
		}
		
	}

}

Measured memory_bytes: 33344
H,W = map(int,input().split())

c = []

for i in range(10):

    C = list(map(int,input().split()))
    c.append(C)

Q = [1]

cost = [float("inf")] * 10
cost[1] = 0


while len(Q) > 0:

    q = Q.pop(0)

    for i in range(10):

        ncos = cost[i]
        nexcos = cost[q] + c[i][q]

        if nexcos < ncos:

            cost[i] = nexcos
            Q.append(i)


ans = 0
cost.append(0)

for i in range(H):

    A = list(map(int,input().split()))

    for a in A:
        ans += cost[a]

print (ans)


Measured memory_bytes: 3064
#include "stdio.h"
#include "string.h"
int main(void){
  char s[100];
  int i;
  int count = 0;
  scanf("%s", s);

  for(i=0; i < 3; i++){
    if('1' == s[i]){
      count++;
    }
  }

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

  return 0;
}



Measured memory_bytes: 128
# A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
# MOD=1000000007


A,B,C,D=gets.split.map(&:to_i)

AC=(A-1)/C
BC=B/C
AD=(A-1)/D
BD=B/D
ACD=(A-1)/(C.lcm(D))
BCD=B/(C.lcm(D))

puts (B-BC-BD+BCD)-(A-1-AC-AD+ACD)

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

ll h, w, n;
vector<P> vs;
Factorial f(1);
vector<ll> dp;

ll dfs(int i) {
	if (dp[i] >= 0) return dp[i];
	const int x1 = vs[i].first;
	const int y1 = vs[i].second;
	ll all = f.cmb(x1 + y1, x1);
	rep(j, n) {
		if (i == j) continue;
		const int x2 = vs[j].first;
		const int y2 = vs[j].second;
		if (x2 <= x1 and y2 <= y1) {
			ll sub = dfs(j) * f.cmb(x1 + y1 - x2 - y2, x1 - x2);
			all += mod - sub % mod;
			all %= mod;
		}
	}
	dp[i] = all;
	return all;
}

int main() {
	cin >> h >> w >> n;
	vs.resize(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
		vs[i].first--;
		vs[i].second--;
	}
	f = Factorial(h + w + 2);
	dp.resize(n, -1);
	ll all = f.cmb(h + w - 2, h - 1);
	rep(i, n) {
		const int x1 = vs[i].first;
		const int y1 = vs[i].second;
		ll sub = dfs(i) * f.cmb(h + w - 2 - x1 - y1, h - 1 - x1) % mod;
		all += mod - sub;
		all %= mod;
	}
	cout << all << endl;
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORD(i, b, a) for (int i = b; i >= a; --i)

#define sz(v) ((int) v.size())
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())

using namespace std;

int n, k;
int a[111], dp[100010];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    REP(i, n) cin >> a[i];
    for (int i = 1; i <= k; ++i) for (int j = 0; j < n; ++j) if (a[j] <= i && !dp[i - a[j]]) {
        dp[i] = 1;
    }
    cout << (dp[k] ? "First" : "Second") << "\n";
    return 0;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    X--;
    Y--;
    vector<int> A(N);
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            int d=min(j-i, abs(j-X)+1+abs(i-Y));
            d=min(d, abs(j-Y)+1+abs(i-X));
            A[d]++;
        }
    }
    for(int i=1;i<N;i++) cout<<A[i]<<endl;
    return 0;
}


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

#define ll long long
#define all(it) it.begin(), it.end()
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FORU(i, a, b, s) for(int i = a; i < b; i += s)
#define FORD(i, a, b, s) for(int i = a; i > b; i -= s)
#define endl "\n"

ll INF = 2e18;
ll MOD = 1e9 + 7;
int i, j, k, t;

int main() {
    int N, sum = 0, max_num = -1;
    cin >> N;

    FOR(i, N) {
        cin >> t;
        sum += t;
        max_num = max(max_num, t);
    }

    sum -= max_num / 2;
    cout << sum << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int array[128];

int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}

int main(){

    array['A']=1,array['C']=2,array['G']=3,array['T']=4;

    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];

    char* check_table = new char[TABLE_SIZE];

    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}



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

import copy
x=copy.deepcopy(X)
x.sort()
A=x[N//2-1]
B=x[N//2]

for i in range(N):
    if X[i]<=A:
        print(B)
    else:
        print(A)


Measured memory_bytes: 121592
#include<iostream>
using namespace std;
int N;
int A[201];
int main(int argc, char const *argv[]){
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];
    int count=0;
    int flag=0;
    while(flag==0)
    {
        for (int j=0;j<N;++j){
            if(A[j]%2==0)A[j]=A[j]/2;
            else flag=1;
        }
        count++;
    }
    cout<<count-1<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m, v, p = [ int(v) for v in input().split() ]
a_list = [ int(v) for v in input().split() ]
a_list.sort()

# 選ばれる可能性のある最低点を求める
# 選びかた　・目標のやつには審査員だけ入れてやる
#          ・上よりP-1番目以下のやつらも入れられるだけ入れてやる
# 　　　　　・残りの奴らにはなでるように入れてやる
#          ・これでP番目以上になるやつがあったらご愁傷さま

def vote(x):
    if x >= n - p:
        return True
    elif x == -1:
        return False
    else:
        total_vote = m * (v-1)
        b_list = a_list[::]
        b_list[x] += m

        if b_list[x] < b_list[n-p]:
            return False

        for i in range(p-1):
            a = min(total_vote, m)
            b_list[-i-1] += a
            total_vote -= a
            if total_vote == 0:
                break
        
        for i in range(n-p+1):
            if i != x and b_list[x] > b_list[i]:
                a = min(total_vote, m, b_list[x] - b_list[i])
                b_list[i] += a
                total_vote -= a
                if total_vote == 0:
                    break

        if total_vote == 0:
            return True
        else:
            return False

if vote(0):
    print(n)
else:
    ok = n-1
    ng = 0
    while ok - ng > 1:
        mid = (ok+ng)//2
        if vote(mid):
            ok = mid
        else:
            ng = mid
    print(n- ok)


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

using namespace std;

vector<vector<pair<int,int> > > tree(100000);

void treediameter(int from,int now,int dist,int &maxdist,int &maxv){
  if(dist>maxdist) maxdist=dist,maxv=now;
  for(auto next:tree[now]){
    if(next.first==from) continue;
    treediameter(now,next.first,dist+next.second,maxdist,maxv);
  }
}

int main() {
  int n; cin >> n;
  int s,t,w,v=0;
  for(int i=0;i<n-1;++i){
    cin >> s >> t >> w;
    tree[s].push_back(make_pair(t,w));
    tree[t].push_back(make_pair(s,w));
    v=s; //適当な辺
  }
  int start=0,end=0,dist=0;
  treediameter(-1,v,0,dist,start);
  dist=0;
  treediameter(-1,start,0,dist,end);
  cout << dist << endl;
  
  return 0;
}


Measured memory_bytes: 15860
#include <iostream>
#include <string>
int main() {
    int K;
    std::string S;
    std::cin >> K;
    std::cin >> S;
    if(S.size() <= K){
        std::cout << S;
    }
    else{
        std::cout << S.substr(0,K) << "..." ;
    }
    return 0;
}//
// Created by ooshi on 2020/06/13.
//



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string s;
int ans=1<<30; 
int main()
{
    cin>>s;
    for(int i=1;i<s.length();i++) 
    {
        if(s[i]!=s[i-1]) 
            ans=min(ans,max(i,int(s.length())-i)); 
    }
    cout<<min(ans,int(s.length()))<<endl; 
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int N, K, p[200005];
int main() {
  scanf("%d %d", &N, &K);
  for(int i = 1; i <= N; ++i) scanf("%d", &p[i]);
  int sum = 0;
  for(int i = 1; i <= K; ++i) sum += p[i];
  int l = 1, r = K, sumx = sum;
  for(int i = K+1; i <= N; ++i) {
    sum += p[i]-p[i-K];
    if(sumx <= sum) {
      sumx = sum;
      l = i-K+1, r = i;
    }
  }
  double ans = 0.0;
  for(int i = l; i <= r; ++i) ans += (p[i]+1)*0.5;
  printf("%.10lf\n", ans);
}

Measured memory_bytes: 896
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy

#N = int(input())
N,K,d= map(int,input().split())
#A = list(map(int,input().split()))
#S = str(input())
#T = str(input())

c=0
for i in range(N,K+1):
    if i%d==0:
        c+=1
print(c)

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

int compare(const void *a, const void *b)
{
	int A = *((int*)a);
	int B = *((int*)b);
	
	return A-B;
}


int main()
{
	//変数宣言
	int A,B;
	
	
	//初期入力
	scanf("%d %d",&A,&B);
	
	
	//最終出力
	printf("%ld\n",A*B);

	
	return 0;
}

Measured memory_bytes: 1728
import sys

f_i = sys.stdin

n = int(f_i.readline())

adj = [[]] * n
for x in f_i:
    x = list(map(int, x.split()))
    adj[x[0]] = [c_v for c_v in zip(x[3::2], x[2::2])]

import heapq

def dijkstra():
    PQ = [(0, 0)]
    isVisited = [False] * n
    distance = [999900001] * n

    distance[0] = 0
    
    while PQ:
        uc, u = heapq.heappop(PQ)

        if uc <= distance[u]:
            isVisited[u] = True
        
            for vc, v in adj[u]:
                if isVisited[v] == False:
                    t_cost = distance[u] + vc
                    if t_cost < distance[v]:
                        distance[v] = t_cost
                        heapq.heappush(PQ, (t_cost, v))

    for v, d in enumerate(distance):
        print(v, d)


dijkstra()

Measured memory_bytes: 70252
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  vector<int> v = {a,b,c};
  sort(v.begin(),v.end());
  v.at(2) *= pow(2,k);
  cout << v.at(0) + v.at(1) + v.at(2) << endl;
}

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

// 插入此處

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ti = n % x == 0 ? n / x : n / x + 1;
    cout << t * ti << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    string s;
    cin >> s;
    cout << "2018/01/" << s[8] << s[9] << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<deque>
#include<utility>
#include<string>
#include<set>
#include<math.h>
#include<iterator>
#include<queue>
#include<algorithm>
using namespace std;

long long i, n, k, sum, q;
pair<int, int> p;
long long a[100009];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> k;
		a[k]++;
		sum += k;
	}
	cin >> q;
	for (i = 1; i <= q; i++) {
		cin >> p.first >> p.second;
		sum -= a[p.first] * p.first;
		sum += a[p.first] * p.second;
		cout << sum << endl;
		a[p.second] += a[p.first];
		a[p.first] = 0;
	}
	
}

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

int main(){
	int a,b,c;cin>>a>>b>>c;
	int goal=c%b;
	for(int i=0;i<=b;i++){
		if((a*i)%b==goal){
			cout<<"YES";return 0;
		}
	}
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 3676