akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int answer = IntStream.rangeClosed(1, 5)
            .mapToObj(i -> scanner.nextInt())
            .collect(Collectors.toList())
            .indexOf(0) + 1;
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 34264
s=input()
s=s.replace("BC","D").replace("B","C")
l=[i for i in s.split("C") if len(i) !=0]
cnt=0

for line in l:
  dcnt =0 
  for ch in reversed(line):
    if ch == "D":
      dcnt+=1
    else:
      cnt+=dcnt

print(cnt)

Measured memory_bytes: 48880
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, l;
  cin >> n >> l;
  vector<ll> v(n);
  ll tmp = INT_MAX;
  ll idx = -1;
  ll res = 0;
  rep(i, n) v[i] = i + l, res += v[i];
  rep(i, n){
    if(tmp > abs(v[i])){
      tmp = abs(v[i]);
      idx = i;
    }
  }


  cout << res - v[idx] << endl;

}


Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s;
  cin >> s;
  if (s[0] == s[1]) cout << "Bad" << endl;
  else if (s[1] == s[2]) cout << "Bad" << endl;
  else if (s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(0, N):
	A.append(input())
B = []
Flag = True
for i in range(0, M):
	B.append(input())
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		flag = True
		for p in range(0, M):
			for q in range(0, M):
				if A[i+p][j+q] != B[p][q]:
					flag = False
					break
			if not flag: break
		if flag: break
	if flag: break
if flag: print('Yes')
else: print('No')

Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    double num, t;
	int n;
	while( cin >> num ) {
		t = 4.9  * ( num / 9.8 ) * ( num / 9.8 );	
		n = ceil( ( t + 5 ) / 5 );
	    cout << n << endl;
	}

        return 0;
}
  

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 2, 0);

  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  for (int i = 0; i <= n; i++) {
    sum += abs(a[i + 1] - a[i]);
  }

  for (int i = 1; i <= n; i++) {
    int diff = abs(a[i + 1] - a[i - 1]);
    diff -= (abs(a[i + 1] - a[i]) + abs(a[i] - a[i - 1]));
    cout << sum + diff << endl;
  }

  return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    int res = 30;
    for(ll i = 1; i*i <= N; ++i) {
        if(N%i) continue;
        ll j = N/i;
        int cnt = 0;
        while(j > 0) ++cnt, j /= 10;
        res = min(res, cnt);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

n, m = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(m)]

E = [[] for i in range(n+1)]
IN = [0] * (n+1)

for a, b in X:
    E[a].append(b)
    IN[b] += 1

q = deque((i, 0) for i in range(1, n+1) if IN[i] == 0)
D = [0] * (n+1)

while q:
    i, d = q.popleft()
    IN[i] -= 1
    if IN[i] > 0:
        continue
    D[i] = d
    for e in E[i]:
        q.append((e, d+1))

print(max(D))

Measured memory_bytes: 37992
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){

int num = 0;
int *data;
int i;
int k;
int count = 0;
int finalans = 0;

while(1){
  scanf("%d",&num);
  if(1 <= num && num <=10000){
    break;
  }
}

data = (int *)malloc(sizeof(int)*num);

for(i = 0;i < num;i++){
  scanf("%d",&data[i]);
if(data[i] > 2 && data[i] % 2 == 0){
  continue;
}
  for(k = 2;k <= sqrt(data[i]);k++){
   if(data[i] % k == 0){
    count = 1;
   }
}
if(count != 1){
  finalans++;
}
count = 0;
}

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



Measured memory_bytes: 2120
/*
Priority Queue(https://onlinejudge.u-aizu.ac.jp/#/problems/ALDS1_9_C)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef long long ll;

void solve(void){
	string ope;
	ll n;
	priority_queue<ll> q;
	while (cin >> ope) {
		if (ope == "end") break;
		if (ope == "insert") {
			cin >> n;
			q.push(n);
		}
		else {
			cout << q.top() << endl;
			q.pop();
		}
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 11108
n = int(input())
a = [int(i) for i in input().split()] 
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)

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

int main() {
  int x, y, z, k, s, cnt = 0;
  cin >> k >> s;
  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      z = s - x - y;
      if (0<=z && z<=k) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<int> G[3000];
int a[3000],c[3000];
bool used[3000];
bool dfs(int k) {
	used[k] = true;
	int len = G[k].size();
	int mi = (int)mod;
	rep(i, len) {
		int v = G[k][i];
		mi = min(mi, c[v]);
	}
	if (mi >= c[k])return false;
	c[k]--;
	rep(i, len) {
		int v = G[k][i];
		if (used[v]||c[k]<c[v])continue;
		if (!dfs(v))return true;
	}
	return false;
}
int main(){
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n - 1) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	vector<int>out;
	rep(i, n) {
		fill(used, used + n, false);
		rep(j, n) {
			c[j] = a[j];
		}
		if (dfs(i))out.push_back(i + 1);
	}
	int l = out.size();
	rep(i, l) {
		if (i > 0)cout << " ";
		cout << out[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
import sys
lines = sys.stdin.readlines()
sizes = lines[0].split(" ")
W=int(sizes[0])
H=int(sizes[1])
N=int(sizes[2])
#print (W,H,N)

calW = W
calH = H
maxX = 0
minX = W
maxY = 0
minY = H
for line in lines[1:]:
    inp = []
    for i in line.split(" "):
        inp.append(int(i))
    #print (inp)
    if inp[2]==1 and inp[0]>maxX:
        calW -= inp[0] - maxX
        maxX = inp[0]
    elif inp[2]==2 and inp[0]<minX:
        calW -= W-inp[0] - (W-minX)
        minX = inp[0]
    elif inp[2]==3 and inp[1]>maxY:
        calH -= inp[1] - maxY
        maxY = inp[1]
    elif inp[2]==4 and inp[1]<minY:
        calH -= H-inp[1] - (H-minY)
        minY = inp[1]
    #print (calW,calH)

if calW<0 or calH<0:
    print (0)
else:
    print (calW*calH)


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	string s,t;
	int cnt = 0;
	cin >> s >> t;
	for(int i = 0;i < s.length();i++){
		if(s[i] != t[i]){
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3820
#include <stdio.h>

int main (void) {
  int l, r, d, ans = 0;
  scanf("%d %d %d", &l, &r, &d);
  for (; l <= r; r--) {
    if (r%d == 0) {
      ans++;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1700
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

using namespace std;

int memo[45] = {0};

int fibo(int n){
  if(memo[n] != 0){
    return memo[n];
  }
  if(n == 0){
    memo[0] = 1;
    return memo[0];
  }else if(n == 1){
    memo[1] = 1;
    return memo[1];
  }else{
    memo[n] = fibo(n-1) + fibo(n-2);
    return memo[n];
  }
}


int main() {
  int n;
  cin >> n;
  
  cout << fibo(n) << endl;

  return 0;
}



Measured memory_bytes: 3092
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long startTime = System.currentTimeMillis();
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] d = new long[N];
		for (int i = 0; i < N; ++i) {
			d[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				ans += d[i] * d[j];
			}
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

int main(void){
    int n;
    cin >> n;
    int mx = 0;
    int cnt = 0;
    rep(i,n) {
        int h;
        cin >> h;
        if (mx <= h) cnt ++;
        mx = max(mx, h);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int N, X, D, B;
  cin >> N >> X;
  vector<int> a(N);
  D = 0;
  B = 0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    D = D + a[i];
    if(D<=X){
      B++; 
    }
  }
  cout << B + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
(defn input []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn ChooseIntegers [[A B C]]
  (if ((complement empty?) (eduction
                             (comp (take B)
                               (map #(rem % B))
                               (filter (partial = C))
                               (take 1))
                             (iterate (partial + A) A)))
    "YES"
    "NO"))

(->> (input)
  ChooseIntegers
  println)

Measured memory_bytes: 67764
#include <iostream>
using namespace std;
long long a[100000];
int main(){
    long long n;
    cin >> n;
    for(long long i=1;i<=n;i++){
        cin >> a[i];
        
    }
    for(long long j=n;j>=1;j -= 1){
        cout<<a[j];
        if(j > 1){
            cout<<" ";
        }
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 2000000000;

const int MAX_V = 1001;
const int MAX_E = 2001;

struct edge {
  int from, to, cost;
};

// 辺
edge es[MAX_E];
// 最短距離
int d[MAX_V];
int V, E;

// 単一始点全点間最短路を求めるアルゴリズム。
// 負辺があっても動作する。また負閉路も検出する。
// ref. https://ei1333.github.io/luzhiled/snippets/graph/bellman-ford.html
//
// 計算量: O(VE)
//
// - falseを返す場合は負の経路が存在.
// - d[i]がINFの場合は経路が存在しない.
bool bellman_ford(int s) {
  fill(d, d + V, INF);
  d[s] = 0;

  for (int i = 0; i < V - 1; i++) {
    for (int j = 0; j < E; j++) {
      edge e = es[j];
      if (d[e.from] == INF) {
        continue;
      }
      d[e.to] = min(d[e.to], d[e.from] + e.cost);
    }
  }

  for (int j = 0; j < E; j++) {
    edge e = es[j];
    if (d[e.from] == INF) {
      continue;
    }
    if (d[e.from] + e.cost < d[e.to]) {
      return false;
    }
  }

  return true;
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B&lang=jp
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin >> V >> E >> r;
  for (int i = 0; i < E; i++) {
    int si, ti, di;
    cin >> si >> ti >> di;
    es[i] = edge{si, ti, di};
  }

  bool flag = bellman_ford(r);
  if (!flag) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  for (int i = 0; i < V; i++) {
    if (d[i] == INF) {
      cout << "INF" << endl;
    } else {
      cout << d[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3224
def sum(n)
    a = 0
    a += n / 10000
    n %= 10000
    a += n / 1000
    n %= 1000
    a += n / 100
    n %= 100
    a += n / 10
    n %= 10
    a += n
    return a
end

num = gets.chomp.split(" ").map(&:to_i)
ans = 0
for i in 1..num[0] do
    sumsum = sum(i)
    if (num[1] <= sumsum) && (sumsum <= num[2])
        ans += i
    end
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>

int main(){

    int p,q,r;
    scanf("%d %d %d",&p,&q,&r);
    
    int path[3] = {p+q,q+r,p+r};
    int min=1000;
    for(int i=0;i<3;i++){
        if(path[i]<min){
            min=path[i];
        }
    }
    printf("%d\n",min);

    return 0;
}

Measured memory_bytes: 128
nums = input().split()
s_N = str(nums[0])
i_N = int(nums[0])
K = int(nums[1])
nums2 = input().split()
count = 0

while count < K:
    #x=嫌いな数候補
    x = nums2[count]
    if x in s_N:
        i_N += 1
        s_N = str(i_N)
        count = 0
    else:
        count += 1

print(s_N)


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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> border = {0, W, 0, H};
    int x, y, a;
    for (int i = 0; i < N; i++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                border[0] = max(x, border[0]);
                break;
            case 2:
                border[1] = min(x, border[1]);
                break;
            case 3:
                border[2] = max(y, border[2]);
                break;
            case 4:
                border[3] = min(y, border[3]);
                break;
            default:
                break;
        }
    }
    cout << max(0, border[1]-border[0])*max(0, border[3]-border[2]) << endl;
    return 0;  
}

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

struct Problem {

	void Solve() {
		LL K; cin >> K;
		LL X, Y; cin >> X >> Y;
		if (K % 2 == 0) if (abs(X + Y) % 2 != 0) { cout << -1 << endl; return; }
		LL x = 0, y = 0;
		vector<pair<LL, LL>> ans;
		while (abs(X) + abs(Y) >= K * 2) {
			if (abs(X) + abs(Y) < K * 3 && abs(X + Y) * K % 2 != 0) break;
			if (X >= K) { x += K; X -= K; }
			else if (-X >= K) { x -= K; X += K; }
			else if (Y >= K) { y += K; Y -= K; }
			else if (-Y >= K) { y -= K; Y += K; }
			ans.push_back({ x, y });
		}
		bool xMinus = (X < 0); if (xMinus) { X = -X; }
		bool yMinus = (Y < 0); if (yMinus) { Y = -Y; }
		bool xyFlip = (X < Y); if (xyFlip) { swap(X, Y); }
		vector<pair<LL, LL>> ans2;

		if (X + Y == K) { ans2.push_back({ X, Y }); }
		else if ((X + Y) % 2 == 1) {
			LL b = (K - X - Y) / 2;
			LL a = K - abs(b);
			ans2.push_back({ -b, -a });
			ans2.push_back({ -b * 2, 0 });
			ans2.push_back({ X, Y });
		}
		else {
			LL b = (K * 2 - X - Y) / 2;
			LL a = K - b;
			ans2.push_back({ a, -b });
			ans2.push_back({ X, Y });
		}

		cout << (ans.size() + ans2.size()) << endl;
		for (auto p : ans) {
			cout << p.first << " " << p.second << endl;
		}
		for (auto p : ans2) {
			if (xyFlip) swap(p.first, p.second);
			if (yMinus) p.second *= -1;
			if (xMinus) p.first *= -1;
			p.first += x; p.second += y;
			cout << p.first << " " << p.second << endl;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 5484
n = int(input())
v1 = [0 for i in range(n//2)]
v2 = [0 for i in range(n//2)] 

tmp = list(map(int, input().split()))
for i in range(n//2):
    v1[i], v2[i] = tmp[2 * i], tmp[2 * i + 1]

v1set = {n : 0}
v2set = {n+1 : 0}
for i in range(n//2):
    if v1[i] in v1set:
        v1set[v1[i]] += 1
    else:
        v1set[v1[i]] = 1
    if v2[i] in v2set:
        v2set[v2[i]] += 1
    else:
        v2set[v2[i]] = 1
lis1 = sorted(list(v1set.items()),reverse=True,key = lambda x: x[1])
lis2 = sorted(list(v2set.items()),reverse=True,key = lambda x: x[1])
i1 = 0
i2 = 0
tmp1 = lis1[0][0]
tmp2 = lis2[0][0]
if tmp1 == tmp2:
    print(min(n - lis1[0][1] - lis2[1][1],n - lis2[0][1] - lis1[1][1]))
else:
    print(n - lis1[0][1] - lis2[0][1])

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

int main() {
	int n, p;

	while (1) {
		int flag = 0;
		int player[50] = { 0 };
		cin >> n >> p;
		if (n == 0 && p == 0) break;
		int p_max = p;

		while (1) {
			for (int j = 0; j < n; j++) {
				if (p != 0) player[j] += 1, p--;
				else p = player[j], player[j] = 0;
				if (player[j] == p_max) {
					flag = -1;
					cout << j << endl;
					break;
				}
			}
			if (flag == -1) break;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include "random"

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) return(gcd(b, a%b));
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int Uniform_random(int a, int b){

  random_device rd;
  mt19937 mt(rd());
  
  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
  
}

int main(){

  int n; cin >> n;
  cout << pow(n, 2) << endl;

  return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0||y-r<0||x+r>W||y+r>H)printf("No\n");
  else printf("Yes\n");
  return 0;
}

Measured memory_bytes: 584
use strict;
use warnings;

my $N = <>;
my @as = split(/ /, <>);
my $sum = 0;
for my $a (@as) {
    $sum += $a;
}
my $l = 0;
for my $a (@as) {
    if ($l <= ($sum / 2) && ($sum / 2) <= ($l + $a)) {
        my $ans1 = $sum - $l * 2;
        my $ans2 = ($l + $a) * 2 - $sum;
        print $ans1 < $ans2 ? $ans1 : $ans2;
        last;
    }
    $l += $a;
}


Measured memory_bytes: 34340
# coding: utf-8
def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)

def merge(a, left, mid, right):
    global cnt
    global inf

    l = a[left:mid]
    r = a[mid:right]

    l.append(inf)
    r.append(inf)

    i, j = 0, 0

    for k in range(left, right, 1):
        cnt += 1
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1


cnt = 0
inf = 1 << 32

n = int(input())
a = [int(x) for x in input().split(" ")]

merge_sort(a, 0, len(a))
print(" ".join(map(str, a)))
print(cnt)


Measured memory_bytes: 66588
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;

    bool inc_c = false;
    bool inc_f = false;
    rep(i, s.length()){
        if(!inc_c){
            if(s[i] == 'C') inc_c = true;
        }else{
            if(s[i] == 'F') inc_f = true;
        }
    }

    if(inc_c && inc_f) ans(true);
    else ans(false);

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
char str[120],str2[20],str3[20];
int a,b;
int main()
{
    scanf("%s",str);
    int n=strlen(str);
    for(int i=0;i<n;i++)
    {
        printf("x");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8] = { +1, +1, +1, 0, 0, -1, -1, -1};
int YY[8] = { +1, 0, -1, +1, -1, +1, 0, -1};
int dx[4] = { -1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

vector<int> adj[100005];
int vis[100005], dp[100005];
int n, m;

void dfs(int node) {
	vis[node] = 1;
	for (auto it : adj[node]) {
		if (!vis[it]) {
			dfs(it);
		}

		dp[node] = max(dp[node], 1 + dp[it]);
	}
}

signed main() {

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

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
	}

	int ans = -inf;

	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			dfs(i);
			ans = max(ans, dp[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 13312
#include<stdio.h>
int main(){
	char n[200000];
	int cnt = 0;
	scanf("%s", &n);
	for(int i=0;n[i]!='\0';i++){
		cnt += n[i]-'0';
	}
	printf("%s\n", cnt%9==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1796
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
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()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
78786    print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(dead_code)]
fn vector_accumulation(vec: &Vec<i64>) -> Vec<i64> {
    let mut res = Vec::new();
    let size = vec.len();
    res.push(0);
    for i in 0..size {
        res.push(vec[i]);
    }
    for i in 0..size {
        res[i + 1] += res[i];
    }
    res
}

fn solve() {
    let n: usize = read();
    let vec: Vec<i64> = read_vec();
    let mut avec = vector_accumulation(&vec);
    let mut map = BTreeMap::new();
    for i in 0..n + 1 {
        if (map.get(&avec[i]) == None) {
            map.insert(avec[i], 1);
        } else {
            let mut val = *map.get(&avec[i]).unwrap();
            map.remove(&avec[i]);
            map.insert(avec[i], val + 1);
        }
    }

    let mut res: usize = 0;
    for x in map {
        // println!("{:?}", x);
        res += x.1 * (x.1 - 1) / 2;
    }
    println!("{}", res);
    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 10996
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//#pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)(x).size()

typedef  long long ll;

const int maxn = (int)2e6 + 13;
const ll INFL = 9223372036854775807;
const ll INF = 2147483647;
const ll MOD = (int)1e9 + 7, MOD2 = 998244353;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
ll a[maxn];
ll b[maxn];
ll pref[maxn];
int main() {
	drobucs;
	ll n, m, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i)cin >> a[i];
	for (int i = 1; i <= m; ++i)cin >> b[i];
	for (int i = 1; i <= m; ++i)pref[i] = pref[i - 1] + b[i];
	ll ans = 0;
	ll sum = 0;
	for (int i = 0; i <= n; ++i) {
		sum += a[i];
		if (sum > k)break;
		ll l = 0, r = m + 1;
		while (r - l > 1) {
			ll mid = (l + r) / 2;
			if (pref[mid] + sum <= k)l = mid;
			else r = mid;
		}
		ans = max(ans, l + i);
	}
	cout << ans << "\n";
	return 0;
}

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

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    // cout<<__gcd(420 ,660);
    
    ll a,b;
    cin>>a>>b;
    
    ll k = __gcd(a,b);
    
    ll ans =1;
    
    if(k%2==0)
    {
        ans++;
        while(k%2==0)
        {
            k/=2;
        }
    }
    
    for(ll i=3;i*i<=k;i++)
    {
        if(k%i==0)
        {
            ans++;
            while(k%i==0)
            {
                k/=i;
            }
        }
    }
    if(k>2)
        ans++;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def d_line():
    N, X, Y = [int(i) for i in input().split()]
    ans = [0] * N
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            dist = min(abs(j - i), abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X))
            ans[dist] += 1
    return '\n'.join(map(str, ans[1:]))

print(d_line())

Measured memory_bytes: 3188
import math, sys

N = int(input())
a = list(map(int, input().split()))

p = [0] * math.ceil(N / 2)

even = (N & 1 == 0)

for i in range(N):
    p[ int((a[i] - even) / 2) ] += 1

# check
if (even and p[0]!=2) or (not even and p[0]!=1):
    print(0)
    sys.exit()
    
ans = p[0]
for i in range(1, len(p)):
    val = p[i]
    if val!=2:
        print(0)
        sys.exit()
    ans = (ans * p[i]) % 1000000007

print(ans)

Measured memory_bytes: 13940
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000;
const char ENDL = '\n';
//vector<ll> bit(5, 0);

void makebit(ll x, ll n,vector<ll> &bit) {
	rep(i, n) {
		if (x >= pow(2, n - 1 - i)) {
			bit[i] = 1;
			x -= pow(2, n - 1 - i);
		}
		else
			bit[i] = 0;
	}
}

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

	ll N, ini, Ans = 0;
	vector<ll> judge(5);
	judge[0] = 'M' - 'A';
	judge[1] = 'A' - 'A';
	judge[2] = 'R' - 'A';
	judge[3] = 'C' - 'A';
	judge[4] = 'H' - 'A';

	vector<ll> sub(5, 0);
	cin >> N;
	rep(i, N) {
		string S;
		cin >> S;
		ini = S[0] - 'A';
		rep(j, 5) {
			if (ini == judge[j])
				sub[j] += 1;
		}
	}

	rep(i, pow(2, 5)) {
		vector<ll> bit(5, 0);
		makebit(i, 5, bit);
		ll er = 0, plas = 1;
		for (auto x : bit) {
			if (x == 1) er++;
		}
		if (er != 3) continue;

		rep(j, 5) {
			if (bit[j] == 1)
				plas *= sub[j];
		}
		Ans += plas;
	}
	cout << Ans << ENDL;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))

L = [0 for i in range(N+1)]

for q in range(M):
  A, B = map(int, input().split())
  if H[A-1] < H[B-1]:
    L[A] += 1
  elif H[A-1] > H[B-1]:
    L[B] += 1
  else:
    L[A] += 1
    L[B] += 1
    
ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 <<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;

/**
 * Created by ??\??? on 2016/12/7.
 */

public class Main {
    static int si(String s){
        return Integer.parseInt(s);
    }
    static void run(String[] args) throws Exception{
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = scan.readLine().split(" ");
        int T = si(lines[0]);
        int H = si(lines[1]);
        Map<String,Integer> m = new HashMap<>();
        Queue<String> q = new ArrayDeque<>();
        Queue<String> done = new ArrayDeque<>();
        for(int i = 0;i<T;i++){
            lines = scan.readLine().split(" ");
            m.put(lines[0],si(lines[1]));
            q.add(lines[0]);
        }
        int time =0;
        while(T>0){
            String w = q.poll();
            int ti = m.get(w)-H;
            if(ti>0) {
                q.add(w);
                m.replace(w,ti);
                time+=H;
            }
            else{
                time+=m.get(w);
                done.add(w+" "+String.valueOf(time));
                m.replace(w,0);
                T--;
            }
        }
        for(String s: done){
            System.out.println(s);
        }
    }
    public static void main(String[] args) throws Exception{
        run(args);
    }
}

Measured memory_bytes: 72528
n = int(input())
T = [[] for _ in range(n+1)]
todo = []
seen = [-1 for _ in range(n+1)]
for i in range(n-1):
    u, v, w = [int(_) for _ in input().split()]
    T[u].append((v, w))
    T[v].append((u, w))
seen[1] = 1
todo.append(1)
while len(todo) != 0:
    t = todo.pop()
    for j in T[t]:
        v = j[0]
        w = j[1]
        color = seen[t]
        if seen[v] == -1:
            todo.append(v)
            if w % 2 == 0:
                seen[v] = color
            else:
                seen[v] = (color + 1) % 2
        else:
            continue
for i in range(1, n+1):
    print(seen[i])



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

int main(){
  int n;
  cin>>n;
  vector<vector<long long int> > a(n,vector<long long int>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }

  vector<vector<long long int> > rui(n+3,vector<long long int>(n+3,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      rui[i+1][j+1]=a[i][j];
    }
  }
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      rui[i][j+1]+=rui[i][j];
    }
  }
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      rui[i+1][j]+=rui[i][j];
    }
  }

  /*
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      cout<<rui[i][j]<<" ";
    }
    cout<<endl;
  }
  */



  long long int ans = -1e18;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=i+1;k<n+1;k++){
        for(int l=j+1;l<n+1;l++){
          long long int tmp=rui[k][l]-rui[i][l]-rui[k][j]+rui[i][j];
          ans=max(ans,tmp);
        }
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3216
using System;

namespace CS_Repo
{
    class Program1
    {
        static void Main(string [] args)
        {
            long input = int.Parse(Console.ReadLine());
            long sum = 0;
            for (long i = 1; i <= input; i++)
            {
                if(i%3==0 && i%5==0)
                {

                }
                else if(i%3==0)
                {

                }
                else if(i%5==0)
                {

                }
                else
                {
                    sum = sum + i;
                }
            }
            Console.WriteLine(sum);
            
        }
    }
}

Measured memory_bytes: 27480
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 10000007;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a+b >= c) {
		cout << b + c << endl;
	}
	else {
		cout << a + b*2 + 1 << endl;
	}
	return 0;
}


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

#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll>> //vvl data(10, vector<ll>(10);
#define fo(i,a,b) for(ll i=a; i<b; i++)

vl prime_factorize(ll N) {
    vl res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            res.push_back(a);
            N /= a;
        }
    }

    // 最後に残った数について
    if (N != 1) res.push_back(N);
    return res;
}

vl findFactors(ll num){
    vl factors;
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        factors.push_back(2);
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
            factors.push_back(i);
            num /= i;
        }
    }

    return factors;
}

int main(){
    ll N;
    cin >> N;
    vl factors = prime_factorize(N);

    // fo(i, 0, factors.size()){
    //     cout << factors[i] << endl;
    // }
    
    ll ans = 0;
    ll count, border, next;
    fo(i, 0, factors.size()){
            if((i==0) || (factors[i] != factors[i-1])){
                ans++;
                count = 1;
                border = 3;
                next = 3;
            }else{
                count++;
                if(count == border){
                    ans++;
                    border += next;
                    next++;
                }
            }
    }

    cout << ans << endl;

}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3608
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long N = sc.nextLong();
 	long A = sc.nextLong();
 	long B = sc.nextLong();
  	long amari = N%(A+B);
  	long ans=0;
     
  	ans = A * (N/(A+B));
  	if(amari<=A){
     ans += amari; 
    }else{
      ans += A;
    }
  
	System.out.print(ans);
	}
}

Measured memory_bytes: 22100
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 2000000000
#define rep(i,rept)	for(int i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	//new
	int x, y;
	cin >> x >> y;
	cout << max(0, x - y * 2) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int M, K;

int main() {
  cin >> M >> K;

  int N = (1 << M);

  if ((M < 2 && K != 0) || K >= N) {
    cout << -1 << endl;
    return 0;
  }

  if (M < 2) {
    rep(i, N) {
      if (i != 0) cout << " ";
      cout << i << " " << i;
    }
    cout << endl;
    return 0;
  }

  bool first = true;
  rep(i, N) {
    if (i == K) continue;
    if (!first) cout << " ";
    first = false;
    cout << i;
  }
  cout << " " << K;
  for (int i = N - 1; i >= 0; --i) {
    if (i == K) continue;
    cout << " " << i;
  }
  cout << " " << K << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        int b = 0;
		Long c = a;
        for(int i=1;i<=Math.sqrt(a);i++){if(a%i==0){c=a/i;}
                            }    
        while(c>0){c/=10;
                   b++;
                  }
		System.out.println(b);
	}
}


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
constexpr int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
constexpr int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
constexpr int32_t LCM(int32_t a, int32_t b){return a / GCD(a, b) * b;}
constexpr int64_t LCM(int64_t a, int64_t b){return a / GCD(a, b) * b;}

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

#define int int64_t

/*global*/



signed main()
{
	int n; cin >> n;
	vector<vector<int>> a(n, vector<int>(n-1));

	for(int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n-1; ++j)
		{
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(a[i].begin(), a[i].end());
	}
	using pi = pair<int, int>;
	vector<pi> q;//直近の試合の予定を保持するため

	//選手iの試合の予定のチェックと作成
	auto check = [&](int i)
	{
		if(a[i].size() == 0) return;
		int j = a[i].back();
		if(a[j].back() == i)
		{
			pi p(i, j);
			if(p.second < p.first) swap(p.first, p.second);
			q.emplace_back(p);
		}
	};

	for (int i = 0; i < n; ++i)
	{
		check(i);
	}

	int day{};
	//qには試合の予定が入る
	//qの試合の予定を整形してからprevQに移して、本体aの予定消化（予定から削除してやったことにする）
	//選手i,jだけが試合を行ったのでi,jについてだけcheck
	while(q.size() > 0)
	{
		day++;
		sort(q.begin(), q.end());
		q.erase(unique(q.begin(), q.end()), q.end());
		vector<pi>  prevQ;
		swap(prevQ, q);
		for(pi p: prevQ)
		{
			int i = p.first; int j = p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		
		for(pi p: prevQ)
		{
			int i = p.first; int j = p.second;
			check(i);
			check(j);
		}
	}
	
	for(int i = 0; i < n; ++i)
	{
		if(a[i].size() != 0)
		{
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << day << '\n';

}

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

int main(){
int Ans[500][1000];
int n[100000],x[100000];
int c=0;
memset(Ans,0,sizeof(Ans));
for(int i=3;i<=100;i++){
for(int j=3;j<=i;j++){
for(int k=2;k<j;k++){
for(int l=1;l<k;l++){
Ans[i][j+k+l]++;
}
}
}
}
for(int i=1;i<=100000;i++){
cin>>n[i]>>x[i];
if(x[i]==0 && n[i]==0){
goto Exit;
}
c++;
}
Exit:
for(int i=1;i<=c;i++){
cout<<Ans[n[i]][x[i]]<<endl;
}
return 0;
}

Measured memory_bytes: 3276
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    double r=sc.nextDouble();
    double pi=Math.PI;
    double area=r*r*pi;
    double length=2*r*pi;
    System.out.printf("%f %f",area,length);
    sc.close();
  }
}



Measured memory_bytes: 28268
#include <stdio.h>

int main() {
  int A,B;
  scanf("%d %d",&A, &B);
  int sum, dif, mul, max;
  sum = A + B;
  dif = A - B;
  mul = A * B;
  // printf("%d %d %d\n",sum, dif, mul);
  max = sum;
  if (max < dif) max = dif;
  if (max < mul) max = mul;
  printf("%d\n",max);
  return 0;
}


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


int main(){
  string S;
  cin >> S;
  int a = 0;
  int b = 0;
  for(auto& s : S){
    if(s=='0'){
      a++;
    }else{
      b++;
    }
  }
  cout << min(a, b) * 2 << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  double x = 0.0;
  
  for (int i = 0; i < N; i ++){
    int a;
    cin >> a;
    x += 1.0/a;
  }
  
  cout << fixed << setprecision(6);
  cout << 1.0/x << endl;

}


Measured memory_bytes: 256
#include<cstdio>
//#include<Hatsune_Miku>
using namespace std;
char s[10];
int ans;
int main(){
    scanf("%s",s);
    for(int i=0;i<6;++i){
    	if(s[i]=='1')++ans;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
double dist(int x1,int y1,int x2,int y2)
{
    return sqrt(pow(abs(x1-x2),2)+pow(abs(y1-y2),2));
}
double fac(int n)
{
    double ans=1;
    while(n)
    {
        ans*=n;
        n--;
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> vect;
    //int a[]={1,2,6,18,54,162,486};
    double ans=0;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        vect.push_back({x,y});
    }
    for(int i=0;i<fac(n);i++)
    {
        int t=next_permutation(vect.begin(),vect.end()); 
        for(int j=0;j<n-1;j++)
        {
            ans+=dist(vect[j].first,vect[j].second,vect[j+1].first,vect[j+1].second);
        }
    }
    printf("%.6f",ans/fac(n));
    return 0;
}


Measured memory_bytes: 256