akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

// Binary Indexed Tree // {{{
struct BIT {
    vector<int> bit;
    int n;
    BIT(int n) {
        bit.resize(n+1, 0);
        this->n = n;
    }
    int sum(int i) {
        int s = 0;
        while(i > 0){
            s += bit[i];
            // i & -i はiの最後の1のビット
            i -= i & -i;
        }
        return s;
    }
    void add(int i, int x) {
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }
};

// 順列の転倒数 (1-indexed)
LL inv(vector<int> a) {
    int n = a.size();
    BIT bit(n);
    LL ans = 0;
    for(int j=0;j<n;j++){
        ans += j - bit.sum(a[j]);
        bit.add(a[j], 1);
    }
    return ans;
}
// }}}

// 文字列sは並び替えて回文にできるか
bool palindromable(string s) {
    map<char, int> m;
    for(auto c : s){
        m[c]++;
    }
    int ocnt = 0;
    for(auto kv : m){
        if(kv.second%2 == 1) ocnt++;
    }
    return ocnt < 2;
}

// 隣り合う文字をswapすることを繰り返して
// 文字列sを文字列tにするswapの最小回数
// (必ずsをtにできると仮定する)
LL nSwapST(string s, string t) {
    map<char, vector<int>> pos;
    map<char, int> cnt;
    vector<int> p;
    int n = s.size();
    for(int i=0;i<n;i++){
        pos[s[i]].push_back(i+1);
    }
    for(int i=0;i<n;i++){
        p.push_back(pos[t[i]][cnt[t[i]]++]);
    }
    return inv(p);
}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();

    // そもそも回文にできない
    if(!palindromable(s)){
        cout << -1 << endl;
        return 0;
    }

    // 左右に分ける
    map<char, int> sum, cnt;
    for(auto c : s) sum[c]++;
    string sl = "";
    string sc = "";
    for(int i=0;i<n;i++){
        char c = s[i];
        cnt[c]++;
        if(cnt[c] <= sum[c]/2){
            sl += c;
        }else if(cnt[c] == (sum[c]+1)/2){
            sc += c;
        }
    }

    // 右を左の逆と同じにする
    string sr = sl;
    reverse(sr.begin(), sr.end());

    cout << nSwapST(s, sl+sc+sr) << endl;

    return 0;
}


Measured memory_bytes: 4808
package main

import (
	"fmt"
	"sort"
)

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

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

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))

	ans := nums[0]
	for i := 1; i < len(nums); i++ {
		ans = gcd(ans, nums[i])
	}

	fmt.Println(ans)
	return
}

Measured memory_bytes: 5504
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B;
  ci(A, B);
  co((A + B) % 24);
}

Measured memory_bytes: 256
/* This Template is property of Pranav Khiste aka desmond_kaneki*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define fit(a,b) for(auto it=a;it!=b;it++)
#define vll vector<ll>
#define pb push_back
#define qll queue<ll>
#define p push
#define mp make_pair
#define fst first
#define snd second
#define pll pair<ll,ll>
#define vpll vector<pll>
#define debug(x) cout<<#x<<' '<<x<<endl;
#define endl '\n'
#define SUP LLONG_MAX
#define INF -1000000000000
#define MAX_N 100005
#define test() ll var;  cin>>var; while(var--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fileio freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);  // use cin cout only!!
main()
{
    ll n,k;
    cin>>k>>n;
    ll ar[n];
    fi(0,n)
        cin>>ar[i];
    sort(ar,ar+n);
    ll ans=SUP;
    ll a,b,c;
    a=ar[0];
    b=ar[1];
    c=ar[n-1];
    ll d1,d2;
    d1=k-(b-a);
    d2=c-a;
    ans=min(d1,d2);
    a=ar[n-1];
    b=ar[0];
    c=ar[n-2];
    d1=k-(a-c);
    d2=a-b;
    ans=min(ans,min(d1,d2));
    fi(1,n-1)
    {
        a=ar[i];
        c=ar[(i-1+n)%n];
        b=ar[(i+1)%n];
        d1=k-(a-c);
        d2=k-(b-a);
        ans=min(ans,min(d1,d2));
    }
    cout<<ans;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] s = line.Split(' ');
            int[] i = s.Select(str => int.Parse(str)).ToArray();

            if(Math.Abs(i[0] - i[2]) <= i[3])
            {
                Console.WriteLine("Yes");
            } else if (Math.Abs(i[0] - i[1]) <= i[3] && Math.Abs(i[1] - i[2]) <= i[3])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


MAX_NUM = 1000000000  # 1_000_000_000
X = int(input())

for num in range(X, MAX_NUM):
    if is_prime(num):
        print(num)
        break


Measured memory_bytes: 38768
#include <stdio.h>
#include <ctype.h>
#include <string.h>

typedef struct _node {
	int key;
	struct _node *next;
	struct _node *prev;
} NODE, *PNODE;

PNODE root;

void init(void) {
	root = malloc(sizeof(NODE));
	root->next = root;
	root->prev = root;
}

void insert(key) {
	PNODE t = malloc(sizeof(NODE));
	t->key = key;
	t->next = root->next;
	t->prev = root;
	root->next->prev = t;
	root->next = t;
}

void deleteNode(PNODE node) {
	if (node == root) {
		return;
	}
	node->next->prev = node->prev;
	node->prev->next = node->next;
	free(node);
}

void delete(key) {
	PNODE cur = root->next;
	while (cur != root) {
		if (cur->key == key) {
			deleteNode(cur);
			return;
		}
		cur = cur->next;
	}
}

void deleteFirst(void) {
	deleteNode(root->next);
}

void deleteLast(void) {
	deleteNode(root->prev);
}

void printNodes(void) {
	PNODE cur = root->next;
	while (1) {
		printf("%d", cur->key);
		cur = cur->next;
		if (cur != root) {
			putchar(' ');
		} else {
			break;
		}
	}
	putchar('\n');
}

void release(void) {
	PNODE tmp, cur = root->next;
	while (cur != root) {
		tmp = cur;
		cur = cur->next;
		deleteNode(tmp);		
	}
	free(root);
} 

int main(void) {
	char cmd[100];
	int n, i, f;
	int key;
	
	init();	
	
	scanf("%d", &n);
	
	f = 0;
	while (scanf("%s", cmd) > 0) {
		if (cmd[0] == 'i') {
			f = 1;
		} else if (cmd[0] == 'd') {
			switch (cmd[6]) {
			case '\0':
				f = 2;
				break;
			case 'F':
				deleteFirst();
				break;
			case 'L':
				deleteLast();
				break;
			}
		} else {
			key = atoi(cmd);
			if (f == 1) {
				insert(key);
			} else if (f == 2) {
				delete(key);
			}
		}
	}
	
	printNodes();
	
	release();
	
	return 0;
}

Measured memory_bytes: 31852
let mk_ls n =
  let rec aux i tmp =
    if i = 0 then List.sort_uniq compare tmp else aux (i - 1) (read_int () :: tmp)
  in
  aux n []


let rec solve ans = function
  | [] | [_] -> ans
  | h :: (n :: _ as t) ->
    if h = n then ans else solve (ans + 1) t

let () = read_int () |> mk_ls |> solve 1 |> Printf.printf "%d\n"

Measured memory_bytes: 384
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=105;

map<string,int> find_;
char s[15];
int t[SIZE*2];

int main(){
	int a,b;
	scanf("%d\n",&a);
	for(int i=0;i<a;i++){
		string tmp;
		scanf("%s",s);
		tmp=s;
		if(!find_[tmp]) find_[tmp]=i+1;
		t[find_[tmp]]++;
	}
	scanf("%d\n",&b);
	for(int i=0;i<b;i++){
		string tmp;
		scanf("%s",s);
		tmp=s;
		if(!find_[tmp]) find_[tmp]=a+i+1;
		t[find_[tmp]]--;
	}
	int MAX=0;
	for(int i=1;i<=a+b;i++) MAX=max(MAX,t[i]);
	printf("%d\n",MAX);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A, B, C, ats;

int main() {
    scanf("%d %d %d", &A, &B, &C);

    ats = A / (B + C);
    if (A % (B+C) >= C) cout << ats << endl;
    else cout << max(ats - 1, 0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define COUNT_RESET 0
#define LOOP_RESET 0
#define ARRAY_RESET 0
void array_reset(unsigned char * array, unsigned short size);
unsigned short serch_word(unsigned char * word, unsigned char * sent);
unsigned short s_scan_word(unsigned char * str, unsigned short length_max);
int main(){
	unsigned char word[10];
	unsigned char sent[1000];
	unsigned short word_length, sent_length;
	unsigned short count = 0;
	unsigned char sentence_end[] = {"END_OF_TEXT\n"};
	unsigned short i;
	array_reset(word, 10);
	array_reset(sent, 1000);
	word_length = s_scan_word(word, 1000);
	while(1){
		sent_length = s_scan_word(sent, 1000);
		if(serch_word(sentence_end, sent) == 1){
			break;
		}
		for(i = 0;i < word_length;i++){
			word[i] |= 0x60;
		}
		for(i = 0;i < sent_length;i++){
			sent[i] |= 0x60;
		}
		if(word_length == sent_length){
			count += serch_word(word, sent);
		}
		array_reset(sent, sent_length);
	}
	printf("%d\n", count);
	return 0;
}

void array_reset(unsigned char * array, unsigned short size)
{
	unsigned short usW_C_i; 	/* ループ変数 */
	/* 配列の初期化 */
	for(usW_C_i = COUNT_RESET;usW_C_i < size;usW_C_i++){
		*(array + usW_C_i) = ARRAY_RESET;
	}
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET; /* 文字列長カウンタ */
	unsigned short usW_C_i; /* ループ変数 */
	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i); /* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}
	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short serch_word(unsigned char * word, unsigned char * sent)
{
	unsigned int frg = 0;
	unsigned int i = 0;
	while(1){
		if(*(word + i) == '\n'){
			frg =1;
		}
		if(*(word + i) != *(sent + i)){
			break;
		}
		i++;
	}
	return frg;
} 


Measured memory_bytes: 2100
#include<cstdio>
#define f(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;i=-(~i))
#define rf(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;i=~(-i))
const int neko=100010,mod=1e9+7;
int n,a[neko],fac[neko],ifac[neko],ht[neko];
int spow(int m,int n)
{
	int b=1;
	for(;n;n>>=1,m=1ll*m*m%mod)if(n&1)b=1ll*b*m%mod;
	return b;
}
int ADD(int x,int y){return (x+=y)>=mod?x-mod:x;}
int C(int n,int m){if(n<m)return 0;return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void initM(int n)
{
	fac[0]=ifac[0]=1;
	f(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=spow(fac[n],mod-2);
	rf(i,n-1,1)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
int main()
{
	int x,X,Y;
	scanf("%d",&n);
	initM(n+5);
	f(i,1,n+1){scanf("%d",&x);if(ht[x])X=ht[x],Y=i;ht[x]=i;}
	printf("%d\n",n);
	f(k,2,n+1)printf("%d\n",ADD(mod,ADD(C(n+1,k),mod-C(X+n-Y,k-1))));
	return 0;
}

Measured memory_bytes: 2304
/* ****TCIITB**** */
                     
#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          int long long
#define pb          push_back
#define endl        '\n'
#define piil         pair<ll ,ll >
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
                    
                   
using namespace std;

ll expo(ll base, ll exponent, ll mod) {                //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            
        }
        base = base*base;
       
        exponent>>= 1;
    }
    return ans;
}
int main()
{
   ll t;
   t=1;
   while(t--)
   { 
    ll x;
    cin>>x;
    ll ans=1;
    rep(i,2,x+1)
    {
       ll p=2;
       while(1)
       {
         ll z=expo(i,p,hell);
         if(z<=x)
         {
           ans=max(ans,z);
         }
         else
          break;
        p++;
       }

    }
    cout<<ans;
     

     

   }

  
} 
 


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

int main() {

	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int ans;

	if (K <= A) ans = K;
	else if (K <= A + B) ans = A;
	else ans = (2 * A + B) - K;

	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
a_b_c = input()
a = int(str(a_b_c).split(" ")[0])
b = int(str(a_b_c).split(" ")[1])
c = int(str(a_b_c).split(" ")[2])

if a + b + c >= 22:
    print("bust")
else:
    print("win")



Measured memory_bytes: 2940
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1005;
char map[MAXN][MAXN];
int n,m,a,b,N,M;
void pr()
{
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
		{
			printf("%c",map[i][j]==0?'.':map[i][j]);
		}
		printf("\n");
	}
}
int main()
{
	scanf("%d %d %d %d",&n,&m,&a,&b);
	N=n,M=m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			map[i][j]='.';
	if(n%2==1)
	{
		for(int i=1;i<m&&a>0;i+=2)
		{
			map[n][i]='<';
			map[n][i+1]='>';
			a--;
		}
	}
	if(m%2==1)
	{
		for(int j=1;j<n&&b>0;j+=2)
		{
			map[j][m]='^';
			map[j+1][m]='v';
			b--;
		}
	}
	//pr();
	if(n%2==1&&m%2==1&&a%2==1&&b%2==1)
	{
		map[n-2][m-2]='<';
		map[n-2][m-1]='>';
		map[n-2][m   ]='^';
		map[n-1][m-2]='^';
		map[n-1][m   ]='v';
		map[n   ][m-2]='v';
		map[n   ][m-1]='<';
		map[n   ][m   ]='>';
		a--;
		b--;
	}
	for(int i=1;i<=N&&b;i+=2)
	{
		for(int j=1;j<=M&&b;j++)
		{
			if(map[i+1][j]=='.'&&map[i][j]=='.')
			{
				map[i][j]='^';
				map[i+1][j]='v';
				b--;
			}
		}
	}
	for(int i=1;i<=N&&a;i+=2)
	{
		for(int j=1;j<=M&&a;j++)
		{
			if(map[i][j+1]=='.'&&map[i][j]=='.')
			{
				map[i][j]='<';
				map[i][j+1]='>';
				a--;
			}
			if(map[i+1][j+1]=='.'&&map[i+1][j]=='.'&&a)
			{
				map[i+1][j]='<';
				map[i+1][j+1]='>';
				a--;
			}
		}
	}
	//pr();
	if(a||b)
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	pr();
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----


const int M = 10000;
int n, a[M], b[M], c[M], d[M], ans[M];
vector<int> g[M];

int main() {
	cin >> n;
	inc(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		g[a[i]].PB(b[i]);
		g[b[i]].PB(a[i]);
	}
	inc(i, n) { cin >> c[i]; }
	sort(c, c + n);
	
	inc(i, n) { d[i] = SI(g[i]); }
	
	queue<int> q;
	inc(i, n) { if(d[i] == 1) { q.push(i); } }
	
	int cnt = 0;
	while(! q.empty()) {
		int v = q.front(); q.pop();
		ans[v] = c[cnt++];
		
		RF(e, g[v]) { if(--d[e] == 1) { q.push(e); } }
		d[v] = 0;
	}
	assert(cnt == n);
	
	int s = 0;
	inc(i, n - 1) { s += min(ans[a[i]], ans[b[i]]); }
	
	cout << s << endl;
	inc(i, n) { cout << (i == 0 ? "" : " ") << ans[i]; }
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string.h>
using namespace std;

#define DATASIZE 200000

int main(void){
    // Your code here!
    int A[DATASIZE];
    long Acum[DATASIZE];
    int B[DATASIZE];
    long Bcum[DATASIZE];
    int N, M, K, Nlim, Mlim;
    
    scanf("%d %d %d",&N,&M,&K);
    Nlim = N-1;
    Mlim = M-1;
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&A[i]);
        if(i == 0)
            Acum[i] = A[i];
        else
            Acum[i] = Acum[i-1] + A[i];
            
        if(Acum[i] > K && Nlim == N-1)
            Nlim = i-1;
    }
    
    for(int i = 0; i < M; i++)
    {
        scanf("%d",&B[i]);
        if(i == 0)
            Bcum[i] = B[i];
        else
            Bcum[i] = Bcum[i-1] + B[i];
            
        if(Bcum[i] > K && Mlim == M-1)
            Mlim = i-1;
    }
        
    int mx = 0;
    int i = Nlim;
    int j = 0;
    if(Nlim < 0)
    {
        if(Mlim < 0)
        {
            mx = 0;
        }
        else
        {
            mx = Mlim+1;
        }
    }
    else
    {
        if(Mlim < 0)
        {
            mx  = Nlim+1;
        }
        else
        {
            mx = Nlim+1;
            while(i >= 0 && j <= Mlim)
            {
                if(Acum[i] + Bcum[j] <= K)
                {
                    if(i+1 + j+1 > mx)
                    {
                        mx = i+1 + j+1;
                        //printf("i:%d, j:%d, %ld + %ld < %d, mx = %d\n", i,j,Acum[i],Bcum[j],K,mx);
                    }
                    j++;
                }
                else
                {
                    i--;
                }
            }
            if(mx < Mlim+1) mx = Mlim+1;
        }
    }
    
    
    printf("%d\n", mx);
}

Measured memory_bytes: 8512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; ++i){ cin >> d[i]; }
	set<int> s;
	for(int i = 1; i <= 4; ++i){
		for(int j = 0; j + i <= n; ++j){
			int x = 0;
			for(int k = 0; k < i; ++k){
				x = x * 10 + d[j + k];
			}
			s.insert(x);
		}
	}
	int answer = 0;
	for(auto x : s){
		if(x != answer){ break; }
		++answer;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3316
#include<stdio.h>
#define n 20
#define q 200
int recursion(int,int);
int G[n],p;


int main(){
  int x,i,j[q],a,b,c;

  scanf("%d",&p);
  for(i=0;i<p;i++){
    scanf("%d",&G[i]);
      }
  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&a);
    j[i] = recursion(0,a);
  }
  for(i=0;i<x;i++){
    if(j[i]==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int recursion(int i,int m){
  if(m==0) return 1;
  if(i>=p) return 0;
  int res = recursion(i+1,m) || recursion(i+1,m-G[i]);
  return res;
}

  

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>

#define ll long long
using namespace std;


ll A[55],B[55],C[55],D[55];
int main() {
    int N,M;
    cin>>N>>M;
    
    
    for(int i=1;i<=N;i++)
        cin>>A[i]>>B[i];
    for(int i=1;i<=M;i++)
        cin>>C[i]>>D[i];
    
    for(int i=1;i<=N;i++) {
        int id=-1;
        ll min_dist = 10000000000000ll;
        for(int j=1;j<=M;j++) {
            ll curr_dist = abs(C[j]-A[i])+abs(D[j]-B[i]);
            if (curr_dist < min_dist) {
                min_dist = curr_dist;
                id = j;
            }
        }
        cout << id << endl;
    }
    
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#define lowbit(n) n & (-n)
#define ls x<<1
#define rs x<<1|1
#define clc(a, b) memset(a, b, sizeof(a))
#define Buff ios::sync_with_stdio(false)
#define rush() int Case = 0; int T; scanf("%d", &T);  while(T--)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define per(i, a, b) for(int i = a; i >= b; i --)
#define reps(i, a, b) for(int i = a; b; i ++)
#define read(a) scanf("%d", &a)
#define readd(a) scanf("%lf", &a)
#define readl(a) scanf("%lld", &a)
#define readc(a) scanf("%c", &a)
#define reads(a) scanf("%s", a)
#define sqr(x) x*x
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>PII;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int N = 1e6+7;
int n, m, p[N];
bool vis[N];
int find(int x)
{
    return p[x] == x ? x : p[x] = find(p[x]);
}
int main()
{
    int n, m;
    read(n);    read(m);
    rep(i, 0, n-1)  p[i] = i;
    rep(i, 0, m-1)
    {
        int u, v;
        read(u);    read(v);
        if(u > v)   swap(u, v);
        if(find(u) == find(v))  continue;
        p[find(v)] = find(u);
    }
    int res = 0;
    rep(i, 0, n-1)  if(!vis[find(i)]) {vis[find(i)] = true; res ++;}
    printf("%d\n", res-1);
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
char A[MC];
int b[MC];
int c[MC];

int main(){
	scanf("%s" , A);
	int n = 0;
	for(; A[n] != 0 ; ++n);
	b[n] = 0;
	c[n] = 0;
	repm(i,n-1,-1){
		b[i] = b[i+1] | (1<<(A[i]-'a'));
		c[i] = c[i+1];
		while(b[i] & (1<<c[i])) ++c[i];
		if(c[i] == 26) b[i] = c[i] = 0;
	}
	for(int i = 0; i < n ; ++i){
		char x = c[i] + 'a';
		printf("%c" , x);
		while(i < n && A[i] != x) ++i;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>

using namespace std;

int n, m;
int a[20];

bool solve(int i, int sum){
  if(i == n) return false;
  if(sum + a[i] == m) return true;

  return solve(i + 1, sum) || solve(i + 1, sum + a[i]);
}

int main(){

  int q;

  cin >> n;
  for(int i = 0;i < n;i++) cin >> a[i];

  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> m;
    if(solve(0, 0)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}



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

int main(void){
  
  long long int sum=0,N;
  long long int tmp;
  while(true){
    sum=0;
    cin >> N;
    if(N==0)
      break;
  vector<int> joint;
  for(int i=0;i<N;i++){
    cin >> tmp;
    sum+=tmp;
  }
  for(int i=0;i<N-1;i++){
    cin >> tmp;
    joint.push_back(tmp);
  }
  sort(joint.begin(),joint.end(),greater<int>());
  for(int i=0;i<N-1;i++){
    if(N*sum>(N-1)*(sum+joint[i]))
      break;
    else{
      N--;
      sum+=joint[i];
    }
  }
  
  cout << (long long int)(N*sum) << endl;
  joint.clear();
  }
  return 0;
}

Measured memory_bytes: 1596
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	S := getStdin()
	T := getStdin()

	ans := 0
	for i := 0; i < len(T); i++ {
		if S[i] != T[i] {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 3020
import math

def B():
    a = [int(i) for i in input().split()]
    x = [a[0], a[2]]
    y = [a[1], a[3]]
    x3 = x[1] - (y[1] - y[0])
    y3 = y[1] + (x[1] - x[0])
    x4 = x[0] - (y[1] - y[0])
    y4 = y[0] + (x[1] - x[0])
    print("{} {} {} {}".format(x3, y3, x4, y4))

if __name__ == '__main__':
    B()

Measured memory_bytes: 3064
N,x,y=map(int,input().split())

ln=[0]*(N-1)

for i in range(1,N+1):
    for j in range(i+1,N+1):
        d2=N
        d=j-i
        if j <= x:
            pass
        elif i<=x and j <=y:
            d2=y-j+1+x-i
        elif j<=y:
            d2=y-j+1+i-x
        elif i<=x and j>=y:
            d2=x-i+j-y+1
        elif j>=y:
            d2=j-y+1+i-x

        if d2 < d:
            d=d2
        
        ln[d-1]+=1

for i in ln:
    print(i)
            

Measured memory_bytes: 46044
N = int(input())
ans = 0
for n in range(1, N + 1, 2):
    j = 1
    tmp = []
    while j < n / 2:
        if n / j == n // j:
            tmp.append(j)
            tmp.append(n // j)
        j += 1
    if len(set(tmp)) == 8:
        ans += 1
print(ans)

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

ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}

int main() {
    int N;
    ll P;
    cin >> N >> P;
    string S;
    cin >> S;
    if (P == 2) {
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            if ((S[i]-'0')%2 == 0) ans += i+1;
        }
        cout << ans << endl;
        return 0;
    }else if (P == 5) {
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            if ((S[i]-'0')%5 == 0) ans += i+1;
        }
        cout << ans << endl;
        return 0;
    }
    
    map<ll, int> mp;
    ll sum = 0;
    ll ans = 0;
    mp[0]++;
    ll inv = modinv(10, P);
    for (int i = 0; i < N; i++) {
        sum += (S[i]-'0') * modpower(inv, i, P);
        sum %= P;
        ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(br.readLine());
        String[] arr = br.readLine().split(" ");

        int ans = 0;
        int max = 0;
        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(arr[i]);
            if (max <= a) {
                ans++;
                max = a;
            }
        }
        out.println(ans);
        out.close();
    }
}


Measured memory_bytes: 22228
a,b,x = map(int, input().split())

count=0
if a==0 :
    count+=1

if a<=x :
    ai = x
else:
    ai = (a//x)*x
    if ai<a :
        ai +=x
if ai<=b :
    count+=1
    count+=(b-ai)//x

print(count)


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

int main(void){
    int N;
    cin >> N;
    int data[N];
    int max = 0;
    int min = 1000000000;
    for(int i = 0; i < N ; i++){
        cin >> data[i];
        if(max < data[i]) max = data[i];
        if(min > data[i]) min = data[i];
    }
    cout << max - min << endl;
    return 0;
}

Measured memory_bytes: 3148
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 2000 + 20;
char M[N][N];
int UP[N][N],
    DOWN[N][N],
    LEFT[N][N],
    RIGHT[N][N];
void sol(){
    int r,c;scanf("%d%d", &r, &c);
    for(int i = 0;i<r;i++){ scanf("%s", M[i]); }
    for(int i = 0;i<r;i++){
        for(int j = 0;j<c;j++){
            if(M[i][j] == '#')continue;
            RIGHT[i][j] = 1;
            if(j != 0 and M[i][j-1] == '.')
                RIGHT[i][j] += RIGHT[i][j-1];
            DOWN[i][j] = 1;
            if(i != 0 and M[i-1][j] == '.')
                DOWN[i][j] += DOWN[i-1][j];
        }
    }

    for(int i = r-1; i>=0; i--){
        for(int j = c - 1;j>=0 ;j--){
            if(M[i][j] == '#')continue;
            LEFT[i][j] = 1;
            if(j != c-1 and M[i][j+1] == '.')
                LEFT[i][j] += LEFT[i][j+1];

            UP[i][j] = 1;
            if(i != r-1 and M[i+1][j] == '.')
                UP[i][j] += UP[i+1][j];
        }
    }

    int ans = 0;
    for(int i = 0;i<r;i++){
        for(int j =0 ;j<c;j++){
            int tmp = 0;
            if(M[i][j] == '#')continue;
            tmp +=  UP[i][j] + DOWN[i][j] + LEFT[i][j] + RIGHT[i][j] - 3;
            ans = max( ans, tmp);
        }
    }
    printf("%d\n", ans);
}
int main(){
    sol();
    return 0;
}


Measured memory_bytes: 67840
#include <stdio.h>
#include <math.h>

int main()
{
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0)
            break;

        double s[n];
        double sum = 0;

        int i;
        for (i = 0; i < n; i++){
            scanf("%lf", &s[i]);
            sum += s[i];
        }

        double m = sum / n;

        double a2 = 0;
        for (i = 0; i < n; i++) {
            a2 += pow((s[i] - m), 2) / n;
        }

        double a = sqrt(a2);
        printf("%lf\n", a);
    }
    return 0;
}



Measured memory_bytes: 2112
n = int(input())
p = list(map(float, input().split()))
dp = [[0] * (n + 1) for _ in range(n + 1)]

dp[0][0] = 1
dp[1][1] = p[0]
for i in range(n):
    dp[i + 1][0] = dp[i][0] * (1 - p[i])

for i in range(1, n):
    for j in range(i):
        dp[i + 1][j + 1] = dp[i][j] * p[i] + dp[i][j + 1] * (1 - p[i])
    dp[i + 1][i + 1] = dp[i][i] * p[i]

print(sum(dp[n][(n + 1) // 2:]))


Measured memory_bytes: 309896
#include <stdio.h>
#define MAX 10001

int main(void){
	int i;
	int joi,ioi;
	char str[MAX];
	while(scanf("%s",str) != EOF){
		joi = 0;
		ioi = 0;
		for(i = 0; str[i+2] != 0; i++){
			if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I'){
				joi++;
			}else if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I'){
				ioi++;
			}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<long long>v;
  v.push_back(a*c);
  v.push_back(a*d);
  v.push_back(b*c);
  v.push_back(b*d);
  long long ans = *max_element(v.begin(),v.end());
  cout << ans << endl;
  return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    rep(i, M)
        cin >> p[i] >> S[i];
    
    bool AC[100001];
    rep(i, 100001)
        AC[i] = false;

    int ans = 0, sum = 0, pen[100001] = {};

    rep(i, M){
        if(S[i] == "AC"){
            if(AC[p[i]] == false){
                ans++;
                AC[p[i]] = true;
                sum += pen[p[i]];
            }
        }else{
            if(AC[p[i]] == false){
                pen[p[i]]++;
            }
        }
    }

    cout << ans << " " << sum << endl;
	
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int k;
    cin >> k;
    int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int ans = v[k-1];
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

def main():
    alphabet = list("abcdefghijklnopqrstuvwxyz")
    str = input()

    found_chars = sorted(set(str), key=lambda x:ascii(x))

    for chars in found_chars:
        if chars in alphabet:
            del alphabet[alphabet.index(chars)]

    if len(alphabet) == 0:
        print("None")
    else:
        print(alphabet[0])



if __name__ == "__main__":
    main()

Measured memory_bytes: 12648
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int op(int a, int b) {
	return max(a, b);
}

int e() {
	return -1;
}

int target;

bool f(int v) {
	return (v < target);
}

int main() {
	int N, Q;
	cin >> N >> Q;
	vi A(N);
	rep(i, N)
		cin >> A[i];
	segtree<int, op, e> seg(A);
	rep(q, Q) {
		int T;
		cin >> T;
		int X, V, L, R;
		switch (T)
		{
		case 1:
			cin >> X >> V;
			X--;
			seg.set(X, V);
			break;
		case 2:
			cin >> L >> R;
			L--;
			cout << seg.prod(L, R) << endl;
			break;
		case 3:
			cin >> X >> V;
			target = V;
			X--;
			cout << seg.max_right<f>(X) + 1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 6124
#include<vector>
#include<random>
#include<stack>
#include<sstream>
#include<list>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<limits>
#include<cmath>
#include<deque>
#include<iostream>
#include<unordered_map>
#include<unordered_set>
#include<queue>
using namespace std;
template<typename T>
void pprintv(T arr)
{
	for(int i=0;i<arr.size();++i)
	{
		cout<<arr[i]<<" ";
	}
	cout<<endl;
}



void solve()
{

}


int main()
{
	string s;
	cin>>s;
	string r("CODEFESTIVAL2016");
	int counter=0;
	for(int i=0;i<16;++i)
		if(r[i]!=s[i])++counter;
	cout<<counter<<endl;
	return 0;
}


Measured memory_bytes: 256
k, n = map(int,input().split())
a_l = list(map(int, input().split()))
d = [ abs(a_l[i+1] - a_l[i]) for i in range(n-1) ]
d += [ k-a_l[-1]+a_l[0] ]
print(sum(sorted(d, reverse=True)[1:]))

Measured memory_bytes: 32352
s = int(input())
i = 1
n = s
a = set()
a.add(n)
while True:
    i += 1
    fn = (n // 2) if (n % 2 == 0) else (3 * n + 1)
    if fn in a:
        print(i)
        break
    a.add(fn)
    n = fn


Measured memory_bytes: 2940
n = gets.to_i
k = gets.to_i
x = gets.chomp.split
n.times do |i|
    x[i] = x[i].to_i
end

distance = 0
x.each do |ball|
    a = ball * 2
    b = (k - ball).abs * 2
    if a < b
        distance += a
    else
        distance += b
    end
end

puts distance

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

int main()
{
    int n, m;
    cin >> n >> m;
    if(n == 2 || m == 2) cout << 0 << endl;
    else if(n == 1 && m != 1) cout << m - 2 << endl;
    else if(n != 1 && m == 1) cout << n - 2 << endl;
    else if(n == 1 && m == 1) cout << 1 << endl; 
    else cout << (ll) (n - 2) * (m - 2) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t = t * i % mod;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    char a;
    cin >> a;
    pf(char(a + 1))
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int x, a;
  if(scanf("%d %d", &x, &a) == 1) {}
  if(0<x||x<10||0<x||x<10)
  {
    if(x<a) printf("0");
    else    printf("10");
  }
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int a, b, i;
  scanf("%d %d", &a, &b);
  char s[a+b+2];
  scanf("%s", s);
  for(i=0;i<a;i++){
    if(s[i]=='-'){
      printf("No\n");
      return 0;
    }else{}
    for(i=a+1;i<a+b+1;i++){
      if(s[i]=='-'){
        printf("No\n");
        return 0;
      }else{}
    }
  }
  if(s[a]!='-'){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, m;
bool used[N];
vector < pair <int, int> > adj[N];

void dfs(int u) {
  if (used[u]) return;
  used[u] = 1;
  for (auto v : adj[u]) {
    if (used[v.first]) continue;
    dfs(v.first);
  }
}

int main() {
  cin >> n >> m;
  vector <int> ve;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      ans++;
      dfs(i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8960
use std::io;


fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();

    if (n * m) % 2 == 0 {
        println!("Even");
    }else{
        println!("Odd");
    }
}

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

vector<int> Change(vector<int> X, int m, int n){
	int x = X[m];
	X[m] = X[n];
	X[n] = x;
	return X;
}

vector<int> Subvec(vector<int> X, int p, int l){
	vector<int> Y;
	for(int i = p; i < p + l; i++) Y.push_back(X[i]);
	return Y;
}

vector<int> BubbleSort(vector<int> A, int i){
	int N = A.size() - 1;
	int j = 0;
	for(int j = 0; j < N-i; j++){
		if(A[j] > A[j+1]){
			A = Change(A, j, j+1);
			A[N]++;
		}
	}
	return A;
}

void Output(vector<int> A){
	int n = A.size() - 1;
	for(int i = 0; i < n; i++) cout << A[i] << ' ';
	cout << A[n] << endl;
}

int main(){
	int N;
	cin >> N;
	vector<int> A;
	for(int i = 0; i < N; i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
	A.push_back(0);
	for(int i = 1; i < N; i++) A = BubbleSort(A, i);
	Output(Subvec(A, 0, N));
	cout << A[N] << endl;
	return 0;
}

Measured memory_bytes: 1220
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<long long>> points;
void rotate () {
  for (auto& p : points) {
    int nx = p[1];
    int ny = 200005 - p[0];
    p[0] = nx;
    p[1] = ny;
    p[2]++;
    p[2] %= 4;
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    char dir;
    cin >> dir;
    if (dir == 'R') points.push_back({x, y, 0});
    if (dir == 'D') points.push_back({x, y, 1});
    if (dir == 'L') points.push_back({x, y, 2});
    if (dir == 'U') points.push_back({x, y, 3});
  }
  long long ans = 1 << 30;
  for (int u = 0; u < 4; u++) {
    vector<vector<pair<long long, long long>>> v(202020);
    for (auto& p : points) {
      if (p[2] == 0 || p[2] == 2) v[p[1]].emplace_back(p[0], p[2]);
    }
    for (auto& line : v) {
      long long l = -(1 << 30);
      sort(line.begin(), line.end());
      for (auto& p : line) {
        if (p.second == 0) l = max(l, p.first);
        else ans = min(ans, p.first - l);
      }
    }
    v = vector<vector<pair<long long, long long>>>(404040);
    for (auto& p : points) {
      if (p[2] == 0 || p[2] == 3) v[p[0] + p[1]].emplace_back(p[0], p[2]);
    }
    for (auto& line : v) {
      sort(line.begin(), line.end());
      long long l = -(1 << 30);
      for (auto& p : line) {
        if (p.second == 0) l = max(l, p.first);
        else ans = min(ans, 2LL * (p.first - l));
      }
    }
    rotate();
  }
  if (ans == 1 << 30) cout << "SAFE" << endl;
  else cout << ans * 5 << endl;
  return 0;
}

Measured memory_bytes: 37572
#include <iostream>
#include <queue>
using namespace std;
const int MAX_V=10000;
typedef pair<int,int> P;
vector<P> G[MAX_V];
bool f[MAX_V];
int v;

int prim(){
  int r=0;
  priority_queue<P,vector<P>,greater<P> > q;
  q.push(P(0,0));
  fill(f,f+v,0);
  for(;!q.empty();){
    P p=q.top();q.pop();
    int b=p.second,d=p.first;
    if(f[b]) continue;
    f[b]=1;
    r+=d;
    for(int i=0;i<(int)G[b].size();i++) q.push(G[b][i]);
  }
  return r;
  
}
int main(){
  int e;
  cin>>v>>e;
  for(int i=0,a,b,c;i<e&&cin>>a>>b>>c;i++) G[a].push_back(P(c,b)),G[b].push_back(P(c,a));
  cout<<prim()<<endl;
  return 0;
}



Measured memory_bytes: 7852
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,f[N][2];
char s[N];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
    if(s[i]=='.')
    {
        f[i][0]=f[i-1][0];
        f[i][1]=min(f[i-1][0],f[i-1][1])+1;
    }
    else{
        f[i][0]=f[i-1][0]+1;
        f[i][1]=min(f[i-1][0],f[i-1][1]);
    }
    printf("%d\n",min(f[n][0],f[n][1]));
}

Measured memory_bytes: 2048
#include <iostream>
#include <map>

constexpr int MOD = 1'000'000'007;

int main() {
	int n;
	std::cin >> n;
	
	std::map<int, int> map;
	for (int i = 2; i <= n; i++) {
		int x = i;
		for (int d = 2; d * d <= x; d++) {
			while (x % d == 0) {
				map[d]++;
				x /= d;
			}
		}
		if (x > 1) map[x]++;
	}
	
	long long ans = 1;
	for (const auto &e : map) {
		ans *= (e.second + 1);
		if (ans > MOD) ans %= MOD;
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3572
#include <cstdio>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a != b and a != c )
	{
		printf("%d", a);
	}
	else if (b != c and b != a)
	{
		printf("%d", b);
	}
	else 
	{
		printf("%d", c);
	}
}


Measured memory_bytes: 1728