akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
c = 0

for i in range(len(A)):
    minA = i
    for j in range(i, len(A)):
        if A[j] < A[minA]:
            minA = j

    if i != minA:
        p = A[i]
        A[i] = A[minA]
        A[minA] = p
        c += 1

print(" ".join(map(str, A)))
print(c)


Measured memory_bytes: 5596
s = input()
last_word = ""
count = 0

for _ in s:

	if last_word == "":
		last_word = _
		
	elif last_word == _:
		if last_word == "1":
			_ = "0"
		else:
			_ = "1"
		count += 1
			
	last_word = _
	
print(count)
		
	

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

int main()
{
	char alph[26]= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','r','x','y','z'};
	int a[26] = {0};
	string S;
	cin >> S;
	
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 26; j++) {
			if (S[i] == alph[j])
				a[j]++;
		}
	}

	bool flag = false;
	for (int i = 0; i < 26; i++) {
		if (a[i] == 0) {
			cout << alph[i];
			flag = true;
			break;
		}	
	}

	if (flag == false)cout << "None";

    return 0;
}

Measured memory_bytes: 512
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	ll n, a, b;
	cin >> n >> a >> b;
	cout << ((b - a) % 2 ? min(a - 1, n - b) + 1 + (b - a - 1) / 2 : (b - a) / 2) << '\n';
}

Measured memory_bytes: 3604
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (ab, bc, ca) = listOfInt()
    println(ab * bc / 2)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37904
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <ctype.h>

//#define DEBUG
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;

    vector<char> s(n);
    for(int i = 0; i < n; i++){
        cin >> s.at(i);
    }
    s.at(k-1) = tolower(s.at(k-1));

    for(int i = 0; i < n; i++){
        cout << s.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
const int qq = 1005;
const int N = 1e9 - 500;
int num[qq];

int main(){
	int a, b;
	string st;
	cin >> st;
	a = 0;
	while(st[a] != 'A') a++;
	b = (int)st.size() - 1;
	while(st[b] != 'Z') b--;
	printf("%d\n", b - a + 1);
	return 0;
}


Measured memory_bytes: 640
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
n, alist = gets_n_and_i_list
ralist = alist.reverse
t1, t2 = [alist.first], [ralist.first]

1.upto(n-1) do |i|
  t1.push(t1[i-1] + alist[i])
  t2.push(t2[i-1] + ralist[i])
end

min = alist.sum
1.upto(n-1) do |s|
  min = [(t1[s-1] - t2[n-1-s]).abs, min].min
end

puts min

Measured memory_bytes: 34900
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b;
  cin>>a>>b;
  if((a+b)%2!=0){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  cout<<(a+b)/2<<endl;
}

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

int main() {
  string a;
  cin>>a;
  if(a.at(0)=='7'||a.at(1)=='7'||a.at(2)=='7'){
    cout << "Yes" <<endl;
  }
  else
    cout << "No"<<endl;
}


Measured memory_bytes: 3624
import java.io.*;
import java.math.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws Exception {
		new Main().solve();
	}
	@SuppressWarnings("unchecked")
	void solve() throws Exception {
		FastScanner in = new FastScanner(System.in);

		int N = in.nextInt();
		int M = in.nextInt();
		nei = new LinkedList[N];
		for (int i = 0; i < nei.length; i++) {
			nei[i] = new LinkedList<Integer>();
		}
		for (int i = 0; i < M; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			nei[a].add(b);
			nei[b].add(a);
		}

		done = new boolean[N];
		path = new LinkedList<Integer>();
		done[0] = true;
		path.add(0);
		dfs(0, true);
		dfs(0, false);

		StringBuilder sb = new StringBuilder();
		sb.append(path.removeFirst() + 1);
		for (int p : path) {
			sb.append(" " + (p + 1));
		}
		System.out.println(path.size() + 1);
		System.out.println(sb);
	}


	LinkedList<Integer>[] nei;
	boolean[] done;
	LinkedList<Integer> path;
	void dfs(int cur, boolean flg) {
		for (int ni : nei[cur]) {
			if (!done[ni]) {
				if (flg) {
					path.addFirst(ni);
				} else {
					path.addLast(ni);
				}
				done[ni] = true;
				dfs(ni, flg);
				break;
			}
		}
	}
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	//
	class FastScanner {

		private InputStream _stream;
		private byte[] _buf = new byte[1024];
		private int _curChar;
		private int _numChars;
		private StringBuilder _sb = new StringBuilder();

		FastScanner(InputStream stream) {
			this._stream = stream;
		}

		public int read() {
			if (_numChars == -1) throw new InputMismatchException();
			if (_curChar >= _numChars) {
				_curChar = 0;
				try {
					_numChars = _stream.read(_buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (_numChars <= 0) return -1;
			}
			return _buf[_curChar++];
		}

		public String next() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			_sb.setLength(0);
			do {
				_sb.appendCodePoint(c);
				c = read();
			} while (!isWhitespace(c));
			return _sb.toString();
		}

		public int nextInt() {
			return (int) nextLong();
		}
		public long nextLong() {
			int c = read();
			while (isWhitespace(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9') throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isWhitespace(c));
			return res * sgn;
		}

		public boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


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

int main()
{
	for (int i = 0; i < 3; i++) {
		int sh, sm, ss, gh, gm, gs, h, m, s;
		cin >> sh >> sm >> ss >> gh >> gm >> gs;
		
		h = gh - sh;

		if (gm >= sm)
			m = gm - sm;
		else {
			h--;
			m = gm + 60 - sm;
		}

		if (gs >= ss)
			s = gs - ss;
		else {
			if (m > 0)
				m--;
			else {
				h--;
				m = 59;
			}
			s = gs + 60 - ss;
		}

		cout << h << " " << m << " " << s << endl;
	}

	return 0;
}


Measured memory_bytes: 3064
def main():
    x, k, d = map(int, input().split())
    abs_x = abs(x)
    if abs_x == d:
        if k % 2 == 0:
            print(abs_x)
            return 0
        else:
            print(0)    
            return 0

    if d > abs_x:
        if k % 2 == 0:
            print(abs_x)
            return 0
        else:
            print(d-abs_x)    
            return 0
    
    s = abs_x // d

    if s <= k:
        if abs(abs_x - s*d) <= abs(abs_x - (s+1)*d):
            if (k-s) % 2 == 0:
                print(abs(abs_x - s*d))
            else:
                print(min(abs(abs_x - s*d + d), abs(abs_x - s*d - d)))

        elif abs(abs_x - s*d) > abs(abs_x - (s+1)*d):
            if (k-(s+1)) % 2 == 0:
                print(abs(abs_x - (s+1)*d))
            else:
                print(min(abs(abs_x - (s+1)*d + d), abs(abs_x - (s+1)*d - d)))

    else:
        print(min(abs(abs_x + k*d), abs(abs_x - k*d)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 61816
N = input()
K = int(input())

Nlen = len(N)

def func(N, K):
    Nlen = len(N)
    ans = 0
    if K == 1:
        ans += (Nlen - 1) * 9
        ans += int(N[0])
    if K == 2:
        for i in range(1, Nlen - 1):
            ans += 9 * 9 * i
        ans += (int(N[0]) - 1) * 9 * (Nlen - 1)
        for i in range(1, len(N)):
            if not N[i] == '0':
                ans += func(N[i:], 1)
                break
    if K == 3:
        for i in range(2, Nlen - 1):
            ans += 9 * 81 * i * (i - 1) // 2
        ans += (int(N[0]) - 1) * 81 * (Nlen - 1) * (Nlen - 2) // 2
        for i in range(1, len(N)):
            if not N[i] == '0':
                ans += func(N[i:], 2)
                break
    return ans
    
print(func(N, K))

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n + 1);
	rep(i, 1, n + 1) read(v[i]);
	int a = 0;
	rep(i, 1, n + 1) if (i % 2 == 1 && v[i] % 2 == 1) a++;
	write(a);
}


Measured memory_bytes: 3612
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long sumNums = 0;
    long sumCount = 0;
    long divideCount = 0;
    long[] diffrences = new long[n];
    long divideCheck = 0;
    bool answer = true;

    for(long i = 0; i < n; i++)
    {
      sumCount += i+1;
      sumNums += nums[i];
      if(i != n-1) diffrences[i] = nums[i+1] - nums[i];
    }
    diffrences[n-1] = nums[0] - nums[n-1];
    
    if(sumNums % sumCount != 0) answer = false;
    else
    {
      divideCount = sumNums / sumCount;
      for(long i = 0; i < n; i++)
      {
        diffrences[i] -= divideCount;
        diffrences[i] *= -1;
        if(diffrences[i] % n != 0 || diffrences[i] < 0)
        {
          answer = false;
          break;
        }
        divideCheck += diffrences[i]/n;
      }

      if(divideCheck != divideCount) answer = false;
    }

    Console.WriteLine((answer) ? "YES" : "NO");
    
	}
}

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

using ll=long long;



void solve(){
    int n,k;
    cin>>n>>k;
    if(n%k==0){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// A utility function that returns maximum of two integers 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
   ll i, w; 
   ll K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
  
int main() 
{ 
    ll n,W;
    cin>>n;
    cin>>W;
    ll wt[n];
    ll val[n];
    for(int i=0;i<n;i++)
      cin>>wt[i]>>val[i];
    printf("%lld\n", knapSack(W, wt, val, n)); 
    return 0; 
} 

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

using namespace std;

// #define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n;
    cin >> n;
    vector<pair<int,int>> v(n);
    for (auto &it: v) {
        cin >> it.first >> it.second;
    }
    int ans = 0;
    map<int,int> diff, add;
    for (auto [x, y]: v) {
        diff[x - y]++;
        add[x + y]++;
    }
    auto rem = [&] (int v, map<int,int> &mp) {
        int t = --mp[v];
        if (!t) mp.erase(v);
    };
    auto readd = [&] (int v, map<int,int> &mp) {
        mp[v]++;
    };
    for (auto [x, y]: v) {
        rem(x - y, diff);
        rem(x + y, add);

        if (!add.empty()) {
            int now = x + y;
            auto it = add.begin();
            ans = max(ans, now - it->first);
        }
        if (!diff.empty()) {
            int now = -x + y;
            auto it = prev(diff.end());
            ans = max(ans, now + it->first);
        }
        readd(x - y, diff);
        readd(x + y, add);
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}


Measured memory_bytes: 23528
#include <stdio.h>

#define N_MAX 100
int count = 0;

void
print_array(int *a, int n)
{
	int i;

	for (i = 0; i < n; i++)
		printf("%d%s", a[i], i + 1 < n ? " " : "");
	printf("\n");
}

int
bubble_sort(int *a, int n)
{
	int i, v, flag = 1;
	while (flag) {
		flag = 0;
		for (i = n - 1; i > 0;i--) {
			if (a[i] < a[i - 1]) {
				v = a[i];
				a[i] = a[i - 1];
				a[i - 1] = v;
				flag = 1;
				count++;
			}
		}
	}
}

int main(void)
{
	int p0, i, n = 0;
	int a[N_MAX];
	char *p;

	scanf("%d", &p0);

	if (p0 < 1 || N_MAX < p0)
		return 1;

	while (n < p0)
		scanf("%d", a + n++);

	bubble_sort(a, n);
	print_array(a, n);
	printf("%d\n", count);

	return 0;
}



Measured memory_bytes: 2100
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in b:
        A = [[(a if a != i else 0) for a in l] for l in A]
    return [NO, YES][any([not any(l) for l in A]) or any([not any([A[i][j] for i in range(3)]) for j in range(3)]) or not any([A[0][0], A[1][1], A[2][2]]) or not any([A[2][0], A[1][1], A[0][2]])]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(A, N, b)}')


if __name__ == '__main__':
    main()


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n,m;
vector<ll> g[101010];
ll col[101010];

bool dfs(ll v,ll c){
  col[v]=c;
  for(ll nv : g[v]){
    if(col[nv]!=-1){
      if(col[nv]!=1-c)return false;
    }else{
      if(!dfs(nv,1-c))return false;
    }
  }
  return true;
}

int main(){
	cin>>n>>m;
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  memset(col,-1,sizeof(col));
  if(dfs(0,0)){
    ll c0=0,c1=0;
    rep(i,n){
      if(col[i]==0)c0++;
      else c1++;
    }
    cout<<c1*c0-m<<endl;
  }else{
    cout<<n*(n-1)/2-m<<endl;
  }
	return 0;
}


Measured memory_bytes: 7424
line = gets.chomp.split(" ").map(&:to_i)
n = line[0]
m = line[1]
x = line[2]
y = line[3]

flag = true
x_wanted = gets.chomp.split(" ").map(&:to_i).sort{|x, y| y <=> x}
y_wanted = gets.chomp.split(" ").map(&:to_i).sort

z = []
z[0] = x < x_wanted[0] ? x_wanted[0] : x
z[1] = y_wanted[0] < y ? y_wanted[0] : y

if z[0] < z[1]
    puts "No War"
else
    puts "War"
end


Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>
#include<vector> 
#define mk make_pair
#define mk make_pair
#define pk push_back 
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;
int main(){
	ios::sync_with_stdio(false);
	int x;
	cin>>x;
	cout<<(x^1)<<endl;
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    long long att = 0;
    sort(h, h+sizeof(h)/sizeof(h[0]));
    for (int i=0; i<n-k; i++) {
        att += h[i];
    }
    cout << att << endl;
}

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

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, q;
  cin >> n >> k >> q;
  int correct[n];
  fill(correct, correct + n, 0);
  int a;
  for(int i = 0; i < q; i++) {
    cin >> a;
    a--;
    correct[a]++;
  }
  const int required = q - k + 1;
  for(int i = 0; i < n; i++) {
    if(correct[i] >= required) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::string S, T;

  std::cin >> N >> S >> T;

  for (int i = 0; i < N; i ++)
    std::cout << S[i] << T[i];
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    //  ios_base::sync_with_stdio(0); 
      //cin.tie(0); 
      //cout.tie(0);
      //freopen("input.txt", "r", stdin);
      //freopen("output.txt", "w", stdout);
    int T = 1;
    vector<string> v = { "AC", "WA", "TLE", "RE" };
    char s1[5];
    int freq[5] = {};
   

      scanf("%d", &T);
    while (T--) {

        scanf("%s", &s1);
       string s(s1);
       for (int i = 0; i < 4; i++)
       {
           if (s == v[i])
               freq[i]++;
       }
      
    }
    for (int i = 0; i < 4; i++)
    {
        printf("%s x %d\n", v[i].c_str(), freq[i]);
    }


    return 0;
}


Measured memory_bytes: 3792
package main

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

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	words := scanStringSlice(sc, n)

	fmt.Println(solve(n, words))
}

func solve(n int, words []string) string {
	log := make([]string, n)
	var firstChar, lastChar string

	word := words[0]
	prevChar := word[len(word)-1:]
	log[0] = word
	for i := 1; i < n; i++ {
		word = words[i]
		firstChar = word[:1]
		lastChar = word[len(words[i])-1:]

		if prevChar != firstChar {
			return "No"
		}
		for j:=0; j<i; j++ {
			if log[j] == word {
				return "No"
			}
		}

		prevChar = lastChar
		log[i] = word
	}

	return "Yes"
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

ll p(ll a, ll n)
{
	if(n <= 0)
		return 1;

	if(n % 2)
	{
		return (a * p(a, n - 1)) % MOD;
	}

	ll p2 = p(a, n / 2);
	return (p2 * p2) % MOD;
}

int main()
{
	ll n;
	cin >> n;

	ll ans = (((p(10, n) + p(8, n)) % MOD)- 2 * p(9, n) + 11 * MOD) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
vector<pair<int, pair<int, int>>>first;
vector<pair<int, pair<int, int>>>second;
int N;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	int i;
	int su = 0;
	for (i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		int j;
		int l = s.length();
		int cur = 0;
		int m = 0;
		for (j = 0; j < l; j++)
		{
			cur += s[j] == '(' ? 1 : -1;
			m = min(m, cur);
		}
		if (cur > 0)
		{
			first.push_back({ -m,{cur,l} });
		}
		else
		{
			second.push_back({ m - cur, {cur,l} });
		}
		su += cur;
	}
	if (su)
	{
		cout << "No";
		return 0;
	}
	sort(first.begin(), first.end());
	sort(second.begin(), second.end());
	for (i = 0; i < second.size(); i++)
	{
		first.push_back({ -second[i].first - second[i].second.first,second[i].second });
	}
	int nowp = 0;
	for (i = 0; i < N; i++)
	{
		if (nowp - first[i].first < 0)
		{
			cout << "No";
			return 0;
		}
		nowp += first[i].second.first;
	}
	cout << "Yes";
}

Measured memory_bytes: 21468
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  long long N;
  std::cin >> N;
  if(N < 2)
  {
    std::cout << 0 << std::endl;
    return 0;
  }
  long long M = std::sqrt(N) + 10;
  std::vector<bool> A(M, true);
  A[0] = false;
  A[1] = false;
  bool b = true;
  for(long long i = 2; i < A.size(); ++i)
  {
    if(A[i])
    {
      for(long long j = 2 * i; j < A.size(); j += i)
      {
        A[j] = false;
      }
      if(b && N % i == 0)
      {
        b = false;
      }
    }
  }
  long long ans = 0;
  for(long long i = 2; i < A.size(); ++i)
  {
    if(A[i])
    {
      long long x = i;
      while(N % x == 0)
      {
        ++ans;
        N /= x;
        x *= i;
      }
      while(N % i == 0)
      {
        N /= i;
      }
    }
  }
  if(b || N != 1)
    ++ans;
  std::cout << ans << std::endl;
  return 0;
}


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


long long P;
int bit[100010];

void add(int x,long long v){
	x++;
	for(int i = x ; i < 100010 ; i += i&-i){
		bit[i] += v;
		bit[i] %= P;
	}
}
int get(int x){
	x++;
	long long ans = 0;
	for(int i = x ; i > 0 ; i -= i&-i){
		ans += bit[i];
		ans %= P;
	}
	return ans;
}
long long pow2[100010]={};

int solve(int A,int B,long long P){
	int ok = 0;
	for(int i = 1 ; i < (1<<(B-A+1)) ; i++){
		if( i != 1 ) continue;
		vector<int> ans;
		vector<string> ans2;
		for(int j = A ; j <= B ; j++){
			if( i >> (j-A) & 1 ){
				ans.push_back(j);
				stringstream ss;
				ss << j;
				ans2.push_back(ss.str());
			}
		}
		int f = 1;
		sort(ans.begin(),ans.end());
		sort(ans2.begin(),ans2.end());			
		for(int j = 0 ; j < ans.size() ; j++){
			stringstream ss(ans2[j]);
			int c;
			ss >> c;
			if( c != ans[j] ) f = 0;
		}
		if( f ) ok++;
	}
	return ok % P;
}
int solver2(long long A,long long B,long long P){
	for(int i = 0 ; i < 100010 ; i++)
		bit[i] = 0;
	pow2[0] = 1 % P;
	for(int i = 1 ; i < 100010 ; i++)
		pow2[i] = (pow2[i-1]*2ll)%P;
	
	vector<string> v;
	for(long long i = A ; i <= B ; i++){
		stringstream ss;
		ss << i;
		v.push_back(ss.str());
	}
	sort(v.begin(),v.end());
	long long ans = 0;
	for(int i = 0 ; i < v.size() ; i++){
		stringstream ss(v[i]);
		long long k;
		ss >> k;
		long long w = k - A;
		add(w,get(w)+1);
	}
	return get(100005);
}

int main(){
	long long A,B;

	while(cin >> A >> B >> P && A){
		cout << solver2(A,B,P)%P << endl;
	}
}

Measured memory_bytes: 7876
import itertools

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

# 最短距離が１の頂点の組は(N - 1)個以下
# 最短距離が２の頂点の組は(N - 1) * (N - 2) // 2個以下
# （star型のときが等号成立）

# よってK > (N - 1) * (N - 2) // 2なら解なし

if K > (N - 1) * (N - 2) // 2:
    print(-1)

# Kがこれ以下の場合はグラフが実際に構築可能である。
# ウニみたいな形を作ってとげ部分をいくつかつなげばよい。
# （単純グラフは二重辺や自己ループがなければ、通常のループはOK!!!）

else:
    diff = (N - 1) * (N - 2) // 2 - K
    print(N - 1 + diff)
    
    for i in range(N - 1):
        print(' '.join(map(str, [1, i + 2])))

    lst = list(range(2, N+1))
    combi = list(itertools.combinations(lst, 2))
    for i in range(diff):
        print(' '.join(map(str, combi[i])))



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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
using pii = pair<int,int>;
constexpr double EPS = 1e-8;
constexpr double INF = 1e8;
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

int main(){
  int n;
  while(cin >> n, n){
    vector<vector<double>> data(n,vector<double>(8));
    rep(i,n) rep(j,8) cin >> data[i][j];

    vector<pair<double,pair<int,int>>> can;
    // 消滅
    rep(i,n)
      can.emplace_back(data[i][6]/data[i][7], pii(i,-1));
    // 衝突
    rep(i,n) FOR(j,i+1,n){
      // 2次方程式の係数を計算
      double a = 0, b = 0, c = 0;
      rep(k,3){
	a += pow(data[i][3+k]-data[j][3+k],2);
	b += 2 * (data[i][k]-data[j][k]) * (data[i][3+k]-data[j][3+k]);
	c += pow(data[i][k]-data[j][k],2);
      }
      a -= pow(data[i][7]+data[j][7],2);
      b -= -2 * (data[i][6]+data[j][6]) * (data[i][7]+data[j][7]);
      c -= pow(data[i][6]+data[j][6],2);
      // 解を候補に追加
      double D = pow(b,2) - 4 * a * c;
      if(D - EPS > 0){
	vector<double> sol{(-b-sqrt(D)) / (2*a), (-b+sqrt(D)) / (2*a)};
	rep(k,2){
	  if(sol[k] - EPS > 0){ // EPSの符号に注意（問題より0に近いところでは衝突しない）
	    can.emplace_back(sol[k], pii(i,j));
	    break;
	  }
	}
      }
    }
    
    sort(all(can));
    vector<double> time(n,INF);
    rep(i,can.size()){
      double t = can[i].first;
      int a = can[i].second.first, b = can[i].second.second;
      if(b == -1 and time[a] == INF){
    	time[a] = t;
      }else if(time[a] == INF and time[b] == INF){
    	time[a] = t;
    	time[b] = t;
      }
    }
    rep(i,n)
      printf("%.10lf\n",time[i]);
  }
}


Measured memory_bytes: 3772
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean found;
        for (char c='a'; c<='z'; c++) {
            found = false;
            for (int i=0; i<s.length(); i++) {
                if ( s.charAt(i) == c ) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                System.out.println(c);
                return;
            }
        }
        System.out.println("None");
    }
}

Measured memory_bytes: 23536
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

void main() {
  int n, k;
  readf("%d %d\n", &n, &k);
  bool[] sunuke = new bool[n];
  for(int i=0; i<k; i++) {
    int d = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    for(int j=0; j<d; j++) sunuke[a[j]-1] = true;
  }
  int count = 0;
  foreach(s;sunuke) if(!s) count++;
  count.writeln;
}


Measured memory_bytes: 3124
import sys

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

    dp = [0] * (N + 1)

    for i in range(1, N + 1):
        for a in A:
            if match[a] <= i:
                if match[a] == i or dp[i - match[a]] != 0:
                    dp[i] = max(dp[i], dp[i - match[a]] * 10 + a)

    print(dp[-1])



if __name__ == '__main__':
    main()


Measured memory_bytes: 20112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
#include <bitset>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int a, b;
    cin >> a >> b;
    rep(i, 100000) {
        if (floor((double)i * 1.08) == a + i && floor((double)i * 1.1) == b + i) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

using namespace std;

const int N = 2100, mod = 1e9+7;
int n, dp[N];

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d", &n);

	dp[0] = 1;

	for (int i = 3; i <= n; i++){
		for (int j = 3; j < N; j++){
			if (i - j < 0)
				break;
			dp[i] = (dp[i] + dp[i - j])%mod;
		}
		//cout << i << " " << dp[i] << endl;
	}

	printf("%d\n", dp[n]);

	return 0;
}

Measured memory_bytes: 3840
s=input()
n=len(s)
K=int(input())
dp=[[[0,0] for _ in range(K+1)] for _ in range(n+1)]
dp[0][0][0]=1
r=range
for i in r(n):
  nd=int(s[i])
  for j in r(K+1):
    for k in r(2):
      for d in r(10):
        ni,nj,nk=i+1,j,k
        if d: nj+=1
        if nj>K: continue
        if k<1:
          if d>nd: continue
          if d<nd: nk=1
        dp[ni][nj][nk]+=dp[i][j][k]
print(dp[n][K][0]+dp[n][K][1])

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


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

    int x;  cin >> x;
    if(x>=30) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main (void)
{
	int p[3],ju1,ju2;
	int sum;
	int tmp;
	for(int i=0;i<3;i++)
	{
		cin >> p[i];
		for(int j=0;j<i;j++)
		{
			if(p[j]>p[i])
			{
				tmp=p[j];
				p[j]=p[i];
				p[i]=tmp;
			}
		}
	}
	cin >> ju1 >> ju2;
	if(ju1>ju2) ju1=ju2;
	sum=p[0]+ju1-50;
	cout << sum << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];

    sort(v.begin(), v.end());

    double t = v[0];
    rep(i,n-1) {
        t = double(t + v[i+1]) /2;
    }

    printf("%.8f\n", t);
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
long long A[26];
int main()
{
	long long i,j=1,k,a,n,c=0;
  cin>>n;
  while(j*2<=n)
	{
		j*=2;
	}
	cout<<j<<endl;
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int op = 0;
	while (b <= a) {
		b *= 2;
		op++;
	}
	while (c <= b) {
		c *= 2;
		op++;
	}
	cout << (op <= k ? "Yes" : "No");
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll N;

int dfs(string s) {
    if (stoll(s) > N) return 0;

    vector<bool> check(3, false);
    for (char c : s) {
        if (c == '3') check[0] = true;
        if (c == '5') check[1] = true;
        if (c == '7') check[2] = true;
    }
    
    int sum = 0;
    if (check[0] and check[1] and check[2]) sum ++;

    for (char c : {'7', '5', '3'}) {
        sum += dfs(s+c);
    }

    return sum;
}

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

    cin >> N;
    
    cout << dfs("0") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int K,data_num,sum,in;

  while(1){

    cin >>K;
    if( K == 0 )break;
    
    sum=0;
    
    data_num=K*(K-1)/2;
    
    for(int i=0 ; i < data_num ; i++){
      cin >>in;
      sum+=in;
    }

    cout <<sum/(K-1)<<endl;

  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, l;std::cin >> n >> l;
  multiset<string> s;
  string t;
  re(i, n){
    std::cin >> t;
    s.insert(t);
  }
  int k = 0;
  for(auto itr = s.begin();itr!=s.end();itr++, k++){
    std::cout << *itr;
    if(k==n-1) std::cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	unsigned long long x, result = 0;
	cin >> x;
	if (x >= 11)
		result += x / 11 * 2;
	int r = x - result / 2 * 11;
	if (r == 0)
		cout << result << endl;
	else if (r <= 6)
		cout << result + 1 << endl;
	else
		cout << result + 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int K = sc.nextInt();
		char[][] c = new char[H][W];
		for (int i=0;i<H;i++) {
			String S = sc.next();
			for (int j=0;j<W;j++) {
				c[i][j] = S.charAt(j);
			}
		}

		int ans = 0;
		for (int i=0;i<(1<<(H+W));i++) {
			int[] arr = new int[H+W];
			int tmp = i;
			for (int j=0;j<H+W;j++) {
				arr[j] = tmp%2;
				tmp/=2;
			}

			int black_cnt = 0;
			for (int j=0;j<H;j++) {
				for (int k=0;k<W;k++) {
					if (arr[j]==1 || arr[H+k]==1) continue;
					if (c[j][k]=='#') black_cnt++;
				}
			}
			if (black_cnt==K) ans++;
			// System.out.println(Arrays.toString(arr));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36892
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s;
  cin>>t;
  int tot=0;
  int l=s.length();
  for(int i=0;i<l;i++)
    	tot+=(s[i]!=t[i]);
  cout<<tot;
  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int a, b, c; cin >> a >> b >> c;

	if(b-a == c -b) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

    rep(i,0,k){
	if(i&1){
	    if(b&1)b--;
	    a += b/2;
	    b /= 2;
	}else{
	    if(a&1)a--;
	    b += a/2;
	    a /= 2;
	}
	    
    }
    PS(a);P(b);
    return  0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n:usize
    }
    let mut ans = 0;
    //    let mut i = 1;
    let s = (n as f64).sqrt() as usize;

    for i in 1..n + 1 {
        let c = n / i;
        ans += i * c * (c + 1) / 2;
        // さらに、c について、いくつかまとめて計算。
        if c > i {
            let d = n / (i + 1);
            ans += (c * (c + 1) - d * (d + 1)) * i * (i + 1) / 4;
        }
        if i >= s {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2112
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] d = new int[10];
        d[scan.nextInt()] += 1;
        d[scan.nextInt()] += 1;
        d[scan.nextInt()] += 1;
        for (int i = 1; i < 10; i++) {
            if (d[i] == 2) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23892
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	ll a[100000];
	ll x;
	cin >> N >> x;
	for (int i = 1; i < N + 1; i++) {
		cin >> a[i];
	}
	a[0] = 0;
	ll sum = 0;
	for (int i = 1; i < N + 1; i++) {
		int b = a[i] + a[i - 1];
		if (b > x) {
			sum += b - x;
			a[i] = x - a[i - 1];
		} 
	}
	
	cout << sum << endl;
	return 0;
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
//#define int long long
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = (1LL << 30);
const ll MOD = 1000000007;

//=============================================================

ll K;

void solve()
{
  ll arr[51];


  for (int i=0; i<50;++i) arr[i] = 50-i-1;

  const int n = 50;
  cout<<n<<endl;
  // n=50.
  for (int i=0; i<n ; ++i){
    if (i < K%n){
      arr[i] = i + K/n + n - K%n + 1;
    }
    else {
      arr[i]  = i + K/n - K%n;
    }
  }

  for (int i=0; i<n;++i){
    cout<<arr[i]<<" ";
  }
  cout<<endl;


}
signed main()
{
  cin >> K;
  solve();
  return 0;
}

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

template < typename T >
void printVector (const vector < T > & vec) {
	for (const T x : vec) {
		cout << x << " ";
	}
	cout << endl;
}

const int INF = 1e9 + 5;

void min_self (int& a, int b) {
	a = min (a, b);
}

void max_self (ll& a, ll b) {
	a = max (a, b);
}

int main() {
	int N, W, w, v;
	scanf ("%d %d", &N, &W);
	vector < ll > dp (W + 1);	// 0 ... W
	// dp[i] - the maximum total value of item
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		scanf ("%d %d", &w, &v);
		for (int weight = W - w; weight >= 0; weight--) {
			max_self (dp[weight + w], dp[weight] + v);
		}
	}
	ll answer = 0;
	for (int i = 0; i <= W; i++) {
		max_self (answer, dp[i]);
	}
	printf ("%lld\n", answer);
	return 0;
}


Measured memory_bytes: 1024
D = 360
x = [0 for i in range(D)]

n = int(input())
for i in range(n):
    m,d,v,s = map(int,input().split())
    m -= 1
    d -= 1

    start = 30*m+d
    end = (start+v-1)%D
    h = [False for _ in range(D)]
    for j in range(v):
        y = (start+j)%D
        h[y] = True

    for j in range(D):
        if h[j]:
            x[j] = max(x[j],s)
        else:
            A = abs(start-j)
            if A>D//2:
                A = D-A
            B = abs(end-j)
            if B>D//2:
                B = D-B
            x[j] = max(x[j], s-min(A,B))

print(min(x))



Measured memory_bytes: 5608
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c,d,f1[10],f2[10],k1,k2;
ll ans=-2000000000000000000;
ll max(ll a,ll b){
	return a>b?a:b;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);in(c);in(d);
	f1[++k1]=a;f1[++k1]=b;
	f2[++k2]=c;f2[++k2]=d;
	if(0>=a&&0<=b)f1[++k1]=0;
	if(1>=a&&1<=b)f1[++k1]=1;
	if(-1>=a&&-1<=b)f1[++k1]=-1;
	if(0>=c&&0<=d)f2[++k2]=0;
	if(1>=c&&1<=d)f2[++k2]=1;
	if(-1>=c&&-1<=d)f2[++k2]=-1;
	for(int i=1;i<=k1;i++)
	for(int i=1;i<=k1;i++)
	for(int j=1;j<=k2;j++)
	ans=max(ans,(1ll)*f1[i]*f2[j]);
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int n,count=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
  	cin >> p[i];
  }
  for(int i=1;i<n-1;i++){
  	if(p[i-1]<p[i] && p[i]<p[i+1])
    	count++;
    else if(p[i+1]<p[i] && p[i]<p[i-1])
      count++;
  }
  cout << count;
}

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

int main()
{
  int n, k;
  cin >>  n >> k;
  double ans = 0.0;
  for(int i = 1; i <= n; i++){
    int score = i;
    double probablity = 1.0/n;
    while(score < k){
      score *= 2;
      probablity *= 0.5;
    }
    ans += probablity;
  }
  cout << fixed << setprecision(9) << ans << endl;
  return 0;
}


Measured memory_bytes: 256