akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;

/*
 * Hopcroft Karp
 */
struct Hopcroft_Karp {

  const static int max_n1 = 10010;
  const static int max_n2 = 10010;
  const static int max_m  = 20010;

  int n1, n2, edges;
  vi last, prev, head, matching, dist, q;
  vb used, vis;

  Hopcroft_Karp( ) :
    last( max_n1 ), prev( max_m ), head( max_m ),
    matching( max_n2 ), dist( max_n1 ), q( max_n1 ),
    used( max_n1 ), vis( max_n1 ) {
  }

  void init( int n1, int n2 ) {
    this->n1 = n1;
    this->n2 = n2;
    edges = 0;
    fill( last.begin( ), last.begin( )+n1, -1 );
  }

  void add_edge( int u, int v ) {
    head[ edges ] = v;
    prev[ edges ] = last[ u ];
    last[ u ] = edges++;
  }

  void bfs( ) {
    fill( dist.begin( ), dist.begin( )+n1, -1 );
    int size_q = 0;
    for( int u = 0; u < n1; u++ ) {
      if( !used[ u ] ) {
        q[ size_q++ ] = u;
        dist[ u ] = 0;
      }
    }
    for( int i = 0; i < size_q; i++ ) {
      int u1 = q[ i ];
      for( int e = last[ u1 ]; e >= 0; e = prev[ e ] ) {
        int u2 = matching[ head[ e ] ];
        if( u2 >= 0 && dist[ u2 ] < 0 ) {
          dist[ u2 ] = dist[ u1 ] + 1;
          q[ size_q++ ] = u2;
        }
      }
    }
  }

  bool dfs( int u1 ) {
    vis[ u1 ] = true;
    for( int e = last[ u1 ]; e >= 0; e = prev[ e ] ) {
      int v = head[ e ];
      int u2 = matching[ v ];
      if( u2 < 0 || ( !vis[ u2 ] && dist[ u2 ] == dist[ u1 ]+1 && dfs( u2 ) ) ) {
        matching[ v ] = u1;
        used[ u1 ] = true;
        return true;
      }
    }
    return false;
  }

  int max_matching( ) {
    fill( used.begin( ), used.begin( )+n1, false );
    fill( matching.begin( ), matching.begin( )+n2, -1 );
    int ans = 0;
    while( true ) {
      bfs( );
      fill( vis.begin( ), vis.begin( )+n1, false );
      int f = 0;
      for( int u = 0; u < n1; u++ ) {
        if( !used[ u ] && dfs( u ) ) {
          f++;
        }
      }
      if( f == 0 ) {
        return ans;
      }
      ans += f;
    }
    return 0;
  }

}hp;


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n1, n2, m;
  cin>>n1>>n2>>m;
  hp.init(n1, n2);
  for(int i = 0; i < m; i++){
      int u,v;
      cin>>u>>v;
      hp.add_edge(u, v);
  }
  cout<<hp.max_matching()<<"\n";
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,i;cin>>n;vll a(n);
  for(i=0;i<n;i++){cin>>a[i];}
  //caricurate
  vrsort(a);ll mini=INF;ll ans;
  for(i=1;i<n;i++){
    ll rest=a[0]-a[i];ll nw=abs(rest-a[i]);
    if(mini>nw){mini=nw;ans=a[i];}
  }
  //output
  cout<<a[0]<<" "<<ans<<endl;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            char[] tmp = new char[100000000];
            int i = 0;
            StringBuilder sb = new StringBuilder();

            while (n > 0) {
                long mod = (long) (n - 1) % 26;
                tmp[i] = (char) ('a' + mod);
                sb.append(tmp[i]);
                i++;
                n = (n - mod) / 26;
            }

            // 出力
            out.println(sb.reverse());

        }

    }
}



Measured memory_bytes: 233868
def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def merge(left, mid, right):
    L = merge_list[left:mid]
    R = merge_list[mid:right]
    L.append(["", INFTY])
    R.append(["", INFTY])
    i, j = 0, 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            merge_list[k] = L[i]
            i += 1
        else:
            merge_list[k] = R[j]
            j += 1

def merge_sort(left, right):
    if left+1 < right:
        mid = int( (left+right)/2 )
        merge_sort(left, mid)
        merge_sort(mid, right)
        merge(left, mid, right)

INFTY = 1000000001

N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
merge_list = A[:]

quick_sort(0, N-1)
merge_sort(0, N)

if A == merge_list:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))



Measured memory_bytes: 19156
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    vector<int> v(3);
    rep(i,3)cin>>v[i];
    
    sort(all(v));
    
    cout<<v[0]+v[1]<<endl;
}


Measured memory_bytes: 256
from bisect import bisect_left, insort_left


def main():
    n = int(input())
    s = list(input())
    q = int(input())
    qs = [input().split() for _ in range(q)]

    abc = [[] for _ in range(26)]
    for i, e in enumerate(s):
        j = ord(e) - ord("a")
        abc[j].append(i)

    for t, e1, e2 in qs:
        if t == "1":
            i = int(e1) - 1
            c = e2

            let = s[i]

            if let == c:
                continue

            idx = ord(let) - ord("a")
            popi = bisect_left(abc[idx], i)
            abc[idx].pop(popi)

            idx = ord(c) - ord("a")
            insort_left(abc[idx], i)

            s[i] = c

        else:
            l = int(e1) - 1
            r = int(e2) - 1

            cnt = 0
            for i in range(26):
                li = bisect_left(abc[i], l)
                if li >= len(abc[i]):
                    continue
                if abc[i][li] <= r:
                    cnt += 1

            print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34844
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(auto& i:p)cin>>i;
  vector<double> e(n);
  for(int i=0;i<n;++i)e[i]=(p[i]+1)/2.0;
  double s=0,r=0;
  for(int i=0;i<k-1;++i)s+=e[i];
  for(int i=k-1;i<n;++i){
    s+=e[i];
    r=max(r,s);
    s-=e[i-k+1];
  }
  cout<<fixed<<setprecision(15)<<r;
}

Measured memory_bytes: 3328
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        tq: [(usize, usize, usize); q],
    }
    let mut f = UnionFind::new(n);
    for (t, u, v) in tq {
        if t == 0 {
            f.union(u, v);
        } else if t == 1 {
            println!("{}", if f.equiv(u, v) { 1 } else { 0 });
        }
    }
}
struct UnionFind {
    parents: Vec<usize>,
}
impl UnionFind {
    /// O(n) # create n trees with themselves as roots
    fn new(n: usize) -> Self {
        UnionFind {
            parents: (0..n).collect(),
        }
    }

    /// O(log(n)) # marge 2 trees with primary and standby roots
    fn union(&mut self, primary: usize, standby: usize) -> bool {
        let primary_root = self.find(primary);
        let standby_root = self.find(standby);
        if primary_root != standby_root {
            self.parents[standby_root] = primary_root;
        }
        primary_root != standby_root
    }

    /// O(log(n)) # find the root of x, and update the roots of intermediate nodes
    fn find(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            x
        } else {
            let root = self.find(self.parents[x]);
            self.parents[x] = root;
            root
        }
    }

    /// O(log(n)) # check does x and y belong same root
    fn equiv(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}


Measured memory_bytes: 10136
import math
import itertools

# 入力
n = int(input())
point_list = []
for i in range(n):
    point = input()
    point_list.append(tuple(int(p) for p in point.split(' ')))

# 計算
count = 0
sum_distance = 0
for points in itertools.permutations(point_list):
    x1, y1 = points[0]
    count += 1
    for point in points[1:]:
        x2, y2 = point
        distance = math.sqrt(((x1 - x2) ** 2) + (y1 - y2) ** 2)
        sum_distance += distance
        x1, y1 = x2, y2
    
print(sum_distance / count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	long long int ans = 0;
	int N,a;
	bool flag = true;
	vector<int> s;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		ans += a;
		if (a % 10 != 0) {
			s.push_back(a);
			flag = false;
		}
	}
	if (flag) {
		ans = 0;
	}
	else {
		if (ans % 10 == 0) {
			std::sort(s.begin(),s.end());
			while (ans % 10 == 0) {
				ans -= s[0];
				s.erase(s.begin()+1);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const double pi=3.1415926535;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll cnt=0;
    if(k<=a+b){
    	if(k<a)cnt=k;
    	else cnt=a;
	}
	else cnt=a-(k-a-b);
	cout<<cnt<<endl;
    return 0;
}

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

int main(){
    long long N, M; cin >> N >> M;
    set<int> candidate;
    for( int i = 1; i * i <= M; i++ ){
        if( M%i == 0 ){
            candidate.insert(i);
            candidate.insert(M/i);
        }
    }

    for( auto itr = candidate.begin(); itr != candidate.end(); itr++ ){
        int now = *itr;
        if( M/now < N ){
            cout << *(--itr) << endl;
            return 0;
        }
    }

    cout<< *candidate.rbegin() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << ", ";
#define ll long long
#define pb push_back
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int INF = (1e9 + 7);
const int MAX = 3005;
int dp[MAX][MAX];

int main()
{
    FAST_IO
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i < n && j < m && a[i] == b[j])
            {
                // cout << a[i] << " " << i << " " << j << endl;
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            }

            if (i < n)
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            if (j < m)
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
        }
    }
    // for (int i = 0; i <= n; i++)
    // {
    //     for (int j = 0; j <= m; j++)
    //     {

    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    // cout << dp[n][m] << endl;
    string ans = "";
    int x = n, y = m;
    for (int i = dp[n][m]; i >= 0; i--)
    {
        // cout << x << " " << y << endl;
        if (x > 0 && y > 0 && dp[x][y] - 1 == dp[x - 1][y - 1])
        {
            if (a[x - 1] == b[y - 1])
            {
                ans += a[x-1];
                x = x - 1;
                y = y - 1;
                continue;
            }
        }
        if (x > 0 && dp[x - 1][y] == dp[x][y])
        {
            x = x - 1;
            i++;
            continue;
        }
        if (y > 0 && dp[x][y - 1] == dp[x][y])
        {
            y = y - 1;
            i++;
            continue;
        }

    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

int main() {
	int N;
	cin>>N;
	vector<int> arr(N);
	int sum=0;
	for(auto& val:arr){
		cin>>val;
		sum+=val;
	}

	int basis=0;
	if(sum%N==0){
		basis=sum/N;
	}
	else{
		double ave=static_cast<double>(sum)/static_cast<double>(N);
		double rest=ave-static_cast<int>(ave);
		if(ave>0){
			if(rest>=0.5)basis=static_cast<int>(ave)+1;
			else basis=static_cast<int>(ave);
		}
		else{
			if(abs(rest)>=0.5)basis=static_cast<int>(ave)-1;
			else basis=static_cast<int>(ave);
		}
	}

	int ans=0;

	for(int i=0;i<N;++i){
		ans+=(basis-arr[i])*(basis-arr[i]);
	}

	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <complex>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

using ld = long double;
using pnt = complex<ld>;
constexpr ld EPS = 1e-12;

template<class T>
inline bool chmin(T &a, const T b) { return a > b && (a = b, true); }

ld cross(const pnt &a, const pnt &b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <class iter>
std::pair<pnt, ld> min_ball(iter left, iter right, int seed = 1333) {
	const int n = right - left;

	assert(n >= 1);
	if (n == 1) {
		return { *left, ld(0) };
	}

	std::mt19937 mt(seed);
	std::shuffle(left, right, mt);
	// std::random_shuffle(left, right); // simple but deprecated

	iter ps = left;
	using circle = std::pair<pnt, ld>;

	auto make_circle_3 = [](const pnt &a, const pnt &b, const pnt &c) -> circle {
		ld A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b),
			S = cross(b - a, c - a);
		pnt p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
		ld r2 = std::norm(p - a);
		return { p, r2 };
	};

	auto make_circle_2 = [](const pnt &a, const pnt &b) -> circle {
		pnt c = (a + b) / (ld)2;
		ld r2 = std::norm(a - c);
		return { c, r2 };
	};

	auto in_circle = [](const pnt &a, const circle &c) -> bool {
		return std::norm(a - c.first) <= c.second + EPS;
	};

	circle c = make_circle_2(ps[0], ps[1]);

	// MiniDisc
	for (int i = 2; i < n; ++i) {
		if (!in_circle(ps[i], c)) {
			// MiniDiscWithPoint
			c = make_circle_2(ps[0], ps[i]);
			for (int j = 1; j < i; ++j) {
				if (!in_circle(ps[j], c)) {
					// MiniDiscWith2Points
					c = make_circle_2(ps[i], ps[j]);
					for (int k = 0; k < j; ++k) {
						if (!in_circle(ps[k], c)) {
							c = make_circle_3(ps[i], ps[j], ps[k]);
						}
					}
				}
			}
		}
	}
	return c;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<pnt> xy(N);
	for (int i = 0; i < N; i++) {
		ld x, y;
		cin >> x >> y;
		xy[i] = { x,y };
	}
	cout << setprecision(20) << sqrt(min_ball<decltype(xy.begin())>(xy.begin(), xy.end()).second) << "\n";

	return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    set<string> dist;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        dist.insert(s);
    }
    cout << dist.size();
    return 0;
}


Measured memory_bytes: 19248
# include <iostream>
using namespace std;
typedef long long ll;

int main(void){
  int n, m;
  ll inf = 1e+09 +7;
  cin >> n>> m;
  ll x[n], y[m];
  for (int i = 0; i<n; i++) cin >> x[i];
  for (int i = 0; i<m; i++) cin >>  y[i];
  
  ll sum_x = 0, sum_y = 0;
  ll sabun_x[n], sabun_y[m];
  for (int i = 0; i<n-1; i++) sabun_x[i] = x[i+1] - x[i];
  for (int i = 0; i< m-1; i++) sabun_y[i] = y[i+1] -y[i];


  for (int i = 0; i<n-1; i++) sum_x += sabun_x[i]*(i+1)*(n-(i+1));
  for (int i = 0; i<m-1; i++) sum_y += sabun_y[i]*(i+1)*(m-(i+1));

  sum_x = sum_x %inf;
  sum_y = sum_y %inf;
  ll total_sum = sum_x * sum_y %inf;
  cout << total_sum << endl;
}
  

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>

void battle(char taro[1000][101],char hana[1000][101],int point[2],int n){
	int i_count,i_point;
	for (i_count = 0; i_count < n; i_count++){
		i_point = 0;
		while (i_point<100){
			if (taro[i_count][i_point] > hana[i_count][i_point]){
				point[0] = point[0] + 3;
				break;
			}
			else if (taro[i_count][i_point] < hana[i_count][i_point]){
				point[1] = point[1] + 3;
				break;
			}
			else  //同じ文字の場合
				if (taro[i_count][i_point + 1] == '\0' &&
					hana[i_count][i_point + 1] == '\0'){
					point[0] = point[0] + 1;
					point[1] = point[1] + 1;
					break;
				}
				else
					;

			i_point++;
		}
	}
}

int main(void){
	int n;
	char taro[1000][101], hana[1000][101];
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++){
		scanf("%s %s", taro[i], hana[i]);
		taro[i][strlen(taro[i])] = '\0';
		hana[i][strlen(hana[i])] = '\0';
	}

	int point[2] = { 0 };
	battle(taro, hana, point, n);
	printf("%d %d\n", point[0], point[1]);


	return 0;
}


Measured memory_bytes: 2148
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Math;

namespace Half_And_Half
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var input = GetArray<int>();
                int a = input[0], b = input[1], c = input[2], x = input[3], y = input[4];
                if (a + b <= 2 * c)
                {
                    CWrite(a * x + b * y);
                    return;
                }
                else
                {
                    int tmp = Min(x, y) * 2 * c;
                    int tmp2 = tmp + 2 * c * Abs(x - y);
                    int tmp3 = tmp + Abs(x - y) * (x > y ? a : b);
                    CWrite(Min(tmp2, tmp3));
                }
            }
        }

        static void CWrite<T>(T str) => Console.WriteLine(str);
        static string GetString() => Console.ReadLine();
        static T[] GetArray<T>()
        {
            var t = typeof(T);
            var str = Console.ReadLine();
            if (t == typeof(string))
            {
                return (T[])(object)str.Split();
            }
            if (t == typeof(int))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            throw new NotSupportedException($"{t} is not supported.");
        }
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static T[] ToNumArray<T>(this string str)
        {
            var t = typeof(T);
            if (t == typeof(int))
            {
                return (T[])(object)str.Split().Select(int.Parse).ToArray();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.Split().Select(long.Parse).ToArray();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.Split().Select(double.Parse).ToArray();
            }
            throw new NotSupportedException();
        }

        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {

        public static bool isBwin(string str0, string str1, string str2) {
            if (str0 == "bbb") { return true; }
            if (str1 == "bbb") { return true; }
            if (str2 == "bbb") { return true; }
            if (str0[0] == 'b' && str1[0] == 'b' && str2[0] == 'b' ) { return true; }
            if (str0[1] == 'b' && str1[1] == 'b' && str2[1] == 'b') { return true; }
            if (str0[2] == 'b' && str1[2] == 'b' && str2[2] == 'b') { return true; }
            if (str0[0] == 'b' && str1[1] == 'b' && str2[2] == 'b') { return true; }
            if (str0[2] == 'b' && str1[1] == 'b' && str2[0] == 'b') { return true; }
            return false;
        }

        public static bool isWwin(string str0, string str1, string str2) {
            if (str0 == "www") { return true; }
            if (str1 == "www") { return true; }
            if (str2 == "www") { return true; }
            if (str0[0] == 'w' && str1[0] == 'w' && str2[0] == 'w') { return true; }
            if (str0[1] == 'w' && str1[1] == 'w' && str2[1] == 'w') { return true; }
            if (str0[2] == 'w' && str1[2] == 'w' && str2[2] == 'w') { return true; }
            if (str0[0] == 'w' && str1[1] == 'w' && str2[2] == 'w') { return true; }
            if (str0[2] == 'w' && str1[1] == 'w' && str2[0] == 'w') { return true; }
            return false;
        }

       

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                if (line.Equals("0")) { break; }
                string s1 = Console.ReadLine();
                string s2 = Console.ReadLine();
                if (isBwin(line, s1, s2)) { Console.WriteLine("b"); }
                else if (isWwin(line, s1, s2)) { Console.WriteLine("w"); }
                else { Console.WriteLine("NA");}
            }
        }
    
    }



    
}

Measured memory_bytes: 5260
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

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


void solve(){
    queue<ll> q;
    for(ll i = 1; i < 10; i++) q.push(i);

    ll k, kk = 0;
    cin >> k;

    while(!q.empty()){
        ll t = q.front(); q.pop(); kk++;
        if(kk == k){
            cout << t; break;
        }
        if(t%10 == 0){
            q.push(t*10);   q.push(t*10+1);
        }
        else if(t%10 == 9){
            q.push(t*10+8);   q.push(t*10+9);
        }
        else{
            q.push(t*10+ (t%10)-1);   q.push(t*10+ (t%10)); q.push(t*10+ (t%10)+1);
        }
    }


}

int main()
{
    solve();
}



Measured memory_bytes: 1792
#include <stdio.h>

int ans = 0;

void merge(int *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1]; int R[n2+1];
    int i, j, k;
    for (i = 0; i < n1; i++) {
        L[i] = A[left+i];
    }
    for (i = 0; i < n2; i++) {
        R[i] = A[mid+i];
    }
    L[n1] = (1e+9)+1;
    R[n2] = (1e+9)+1;
    i = 0; j = 0;
    for (k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
        ans++;
    }
}

void mergeSort(int *A, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(void) {
    int n, i;
    scanf("%d", &n);
    int S[n];
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }

    mergeSort(S, 0, n);

    for (i = 0; i < n; i++) {
        printf("%d", S[i]);
        if (i < n - 1) printf(" ");
    }
    printf("\n");
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 5604
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,i,j,k;
int A[100005],B[100005];
long long ans,now,C;

int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",&A[i],&B[i]);
	for(i=n;i>=1;--i)
	{
		now=A[i]+ans;
		C=now/B[i]*B[i];if(C<now)C+=B[i];
		ans+=C-now;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
class Queue:
    _items = []
    _capacity = 0
    _head = 0
    _tail = 0

    def __init__(self, cap):
        self._capacity = cap + 1
        for i in range(self._capacity):
            self._items.append(None)

    def enqueue(self, val):
        index = (self._tail + 1)%self._capacity
        if index == self._head:
            raise Exception('Queue is full')
        self._items[self._tail] = val
        self._tail = index

    def dequeue(self):
        if self._head == self._tail:
            raise Exception('Queue is empty')
        val = self._items[self._head]
        self._items[self._head] = None
        self._head = (self._head + 1)%self._capacity
        return val

    def is_empty(self):
        return  self._head == self._tail
        


class Task:
    name = ''
    time = 0

    def __init__(self, name, time):
        self.name = name
        self.time = time

    def __str__(self):
        return '%s %d'%(self.name, self.time)

if __name__ == '__main__':
    N, p = map(int, input().split())

    tasks = Queue(N)
    finished_tasks = []
    total_time = 0  

    for i in range(N):
        n, t = input().split()
        tasks.enqueue(Task(n, int(t)))

    while not tasks.is_empty():
        cur = tasks.dequeue()
        if cur.time <= p:
            total_time += cur.time
            cur.time = total_time
            finished_tasks.append(cur)
        else:
            total_time += p
            cur.time -=p
            tasks.enqueue(cur)

    for i in finished_tasks:
        print(i)


Measured memory_bytes: 19332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
typedef long long LL;
const int N=2e5+10;
int t[N+10],a[N+10],v[N+10],vis[N+10],b[N+10],c[N+10],n;
vector <int> ve[100];
char s[N+10];
int lowbit(int x) {
	return x&(-x);
}
void Add(int x) {
	while (x<=N) {
		t[x]++;
		x+=lowbit(x);
	}
}
LL Query(int x) {
	LL ans=0;
	while (x>0) {
		ans+=t[x];
		x-=lowbit(x);
	}
	return ans;
}
LL work(int n) {
	memset(t,0,sizeof(t));
	LL ans=0;
	for (int i=1;i<=n;i++) {
		ans+=Query(a[i]);
		Add(a[i]+1);
	}
	return ans;
}
int main() {
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++) v[s[i]-97]++;
	int k=0;
	for (int i=0;i<26;i++) if (v[i]%2) k++;
	if (k>1) {
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++) {
		vis[s[i-1]-97]++;
		if (v[s[i-1]-97]%2&&vis[s[i-1]-97]==(v[s[i-1]-97]+1)/2) a[i]=1;
			else if (vis[s[i-1]-97]<=v[s[i-1]-97]/2) a[i]=2;
				else a[i]=0;
	}
	LL ans=work(n);
	int totb=0,totc=0;
	for (int i=1;i<=n;i++) if (a[i]==0) b[++totb]=s[i-1]-97;
		else if (a[i]==2) c[++totc]=s[i-1]-97;
	for (int i=1;i<=n/2;i++) ve[c[i]].push_back(n/2+1-i);
	for (int i=1;i<=n/2;i++) {
		int nowlen=ve[b[i]].size();
		a[i]=n/2-ve[b[i]][nowlen-1];
		ve[b[i]].pop_back();
	}
	ans+=work(n/2);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

class Main {

  static boolean RS(String S, int n) {
    
    if (n%2 == 1) return false;
      
    for(int i = 0; i < n/2; i++)
      if(S.charAt(i) != S.charAt(i+n/2))
        return false;
      
    return true;
  }
  
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    
    int n = stdIn.nextInt();
    String S = stdIn.next();
     
    if(RS(S, n))
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


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

int main()
{
	long long  n,m=10000000000000000,a;
	cin>>n;
	for(int i=0;i<5;i++){cin>>a;m=min(a,m);}
	if(n<=m)cout<<5<<endl;
	else cout<<(5+(n-m)/m+(((n-m)%m)!=0))<<endl;
	

}



Measured memory_bytes: 3560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }

LL gcd(LL n, LL m){
    if(n < m) swap(n, m);
    if(m == 0) return n;
    return gcd(m, n % m);
}

bool check(string& s, string& t, LL c){
    LL a = c / s.size();
    LL b = c / t.size();
    for(LL i = 0; i < c; i += a){
        if(i % b != 0) continue;
        if(s[i / a] != t[i / b]) return false;
    }
    return true;
}

int main(){
    LL n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    LL c = n * m / gcd(n, m);
    cerr << "c=" << c << endl;
    if(check(s, t, c)){
        cout << c << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 512
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int d=sc.nextInt();
  		int c=0;
		int ans=0;
  
		while(c<n){
          c+=d*2+1;
          ans++;
    		
    	}
    
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int N,K;
    cin>>N>>K;
    vector<long int> h(N),dp(N);
    rep(i,N) cin>>h[i];
    dp[0]=0;
    for (long int i=1;i<N;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for (int j=2;j<=min(K,i);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  char s='A'-'a';
  printf("%c%c%c",a[0]+s,b[0]+s,c[0]+s);
  cout<<endl;
  return 0;
}

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

void solve(long long N, std::vector<long long> xx, std::vector<long long> yy,
           std::vector<long long> hh) {
  for(int x = 0 ; x <= 100 ; x++){
    for(int y = 0 ; y <= 100 ; y++){
      vector<long long> hs(N);
      for(int i = 0 ; i < N ; i++){
        hs[i] = hh[i] + abs(x-xx[i]) + abs(y-yy[i]);
      }
      for( auto h : hs ){
        bool f = true;
        for(int i = 0 ; i < N ; i++){
          if( max(0ll, h - abs(x - xx[i]) - abs(y - yy[i])) != hh[i] ){
            f = false;
          }
        }
        if(f){
          cout << x << " " << y << " " << h << endl;
          return;
        }
      }
    }
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> x(N);
  std::vector<long long> y(N);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
    scanf("%lld", &h[i]);
  }
  solve(N, std::move(x), std::move(y), std::move(h));
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007

string syugei(int N){
  string ST="b";
  for(int i=0;i<N;i++){
    if(i%3==0||i==0)ST="a"+ST+"c";
    else if(i%3==1||i==1)ST="c"+ST+"a";
    else if(i%3==2||i==2)ST="b"+ST+"b";
  }
  return ST;
}
// int hantei(string S){
//   for(int i=0;i<S.size(),i++){
//     for(int j=0;j<)
//   }
// }
//main
signed main(){
  int N,M,O,P,X,count=0,count2=0;
  double D;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>N>>M;
  while(1){
    if(M==1)break;
    else if(N+(N-1)*count>=M)break;
    count+=1;
  }
  if(M==1)cout<<count<<endl;
  else cout<<count+1<<endl;
}


Measured memory_bytes: 256
def main():
    from fractions import gcd

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

    MOD = 10 ** 9 + 7

    tmp = 1
    for a in A:
        tmp *= a // gcd(tmp, a)

    ans = 0
    for a in A:
        ans += tmp // a
    ans %= MOD

    print (ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 6072
import java.util.Scanner;

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

    public void run() {
        Scanner scanner = new Scanner(System.in);
        int P = scanner.nextInt();
        int Q = scanner.nextInt();
        int R = scanner.nextInt();

        int sum = 0;
        if (P >= Q && P >= R) {
            sum = Q + R;
        }
        if (Q >= P && Q >= R) {
            sum = R + P;
        }
        if (R >= Q && R >= P) {
            sum = Q + P;
        }
        System.out.println(sum);
    }

}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
ll a[10005];
int main()
{
	ll n,s,count=0;
	scl(n);scl(s);
	rep(i,1,n){
		ll u;scl(u);a[0]=i;
		if(u<=s)dep(j,s-u,0)(a[j+u]+=a[j])%=mod;
		count+=a[s]%mod*(n-i+1)%mod;a[s]=0;
		count%=mod;
	}pf("%lld\n",count%mod);
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
Ps = list(map(int, input().split()))
Qs = list(map(int, input().split()))
Rs = list(map(int, input().split()))

Ps.sort()
Qs.sort()
Ss = Ps[-X:] + Qs[-Y:]
Ss.sort()

Rs.sort()

for i, s in enumerate(Ss):
    r = Rs.pop()
    if s < r:
        Ss[i] = r
    else:
        break
    if len(Rs) == 0:
        break

print(sum(Ss))

Measured memory_bytes: 23328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  gcd(int a, int b, int c);


int main(void) {

	int    N;
	long long   a,b,c,tmp = 0;
	int s,l;

	i_cin(N);
	for (a = 1; a < N+1; a++) {
		for (b = 1; b < N+1; b++) {
			for (c = 1; c < N+1; c++) {
				tmp += (long long)gcd(a, b, c);
			}
		}
	}
	ll_cout(tmp); return 0;	
}
	
int  gcd(int a, int b, int c) {
	int r,tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}

	if (c < b) { tmp = c; c = b; b = tmp; }
	r = c % b;
	while (r) {
		if (!r) break;
		c = b; b = r;
		r = c % b;
	}
	return(b);

	}

int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}



Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
Int LSB(Int x) { return x & (-x); }
struct FenwickTree {
    vector<Int> A;
    FenwickTree(int n) { // [1, n]
        A.resize(n + 1);
    }
    Int sum(int idx) { // sum [1, idx]
        Int ans = 0;
        while (idx > 0) {
            ans += A[idx], idx -= LSB(idx);
        }
        return ans;
    }
    void add(int idx, Int val) { // ft[idx] += val
        while (idx < A.size()) {
            A[idx] += val, idx += LSB(idx);
        }
    }
};
int main() {
    int N, Q; cin >> N >> Q;
    FenwickTree ft(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a; ft.add(i + 1, a);
    }
    while (Q--) {
        int t, a, b; cin >> t >> a >> b;
        if (t == 0) {
            ft.add(a + 1, b);
        } else {
            cout << ft.sum(b) - ft.sum(a) << '\n';
        }
    }
    return 0;
}


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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef complex<int>C;
C getC(){
    int x,y;
    cin>>x>>y;
    return C(x,y);
}

int cross(C p1,C p2){
    return real(p1)*imag(p2)-real(p2)*imag(p1);
}

void getL(vint &ds,vint &arg){
    ds.clear();arg.clear();
    int m;cin>>m;
    C p1=getC();
    C p2=getC();
    ds.pb(abs(real(p1)-real(p2))+abs(imag(p1)-imag(p2)));
    rep(i,m-2){
        C p3=getC();
        ds.pb(abs(real(p3)-real(p2))+abs(imag(p3)-imag(p2)));
        int tmp=cross(p1-p2,p3-p2);
        if(tmp>0)arg.pb(1);
        else arg.pb(-1);
        p1=p2;p2=p3;
    }
}

int N;
void solve(){
    vint ds,arg;
    getL(ds,arg);
    rep(i,N){
        vint dds,aarg;
        getL(dds,aarg);
        if(ds.size()!=dds.size())continue;
        bool ok=false;
        rep(t,2){
            bool f=true;
            rep(j,ds.size())f&=ds[j]==dds[j];
            rep(j,arg.size())f&=arg[j]==aarg[j];
            ok|=f;

            reverse(all(ds));
            reverse(all(arg));
            rep(j,arg.size())arg[j]*=-1;
        }
        if(ok)cout<<i+1<<endl;
    }
    cout<<"+++++"<<endl;
}

signed main(){
    while(cin>>N,N)solve();
    return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int count(int);
int main()
{
  int a,c=0,i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&a);
  if(count(a)==1) c++;
  }
  printf("%d\n",c);
  return 0;
}
int count(int x){
  int i;
  if(x==2)return 1;
  if(x<2 || x%2==0)return 0;
  for(i=3;i<=sqrt(x);i+=2){
    if(x%i==0)return 0;
  }
  return 1;
  
}

Measured memory_bytes: 596
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};

    let mut sum = 0;
    for i in 1..n + 1 {
        if i % 3 == 0 || i % 5 == 0 {
            continue;
        } else {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2140
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let slst = List.sort_uniq compare
    (Array.to_list (Array.init n @@ fun _ -> Scanf.scanf "%s " @@ fun s -> s)) in
  Printf.printf "%s\n" (if List.length slst = 3 then "Three" else "Four")

Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t;
ll p,q;
int main()
{
    int i,j;
    scanf("%lld%lld",&p,&q);
    puts(abs(p-q)<=1?"Brown":"Alice");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int[] A = new int[x];
        
        for(int i = 0; i < x; i++){
            A[i] = sc.nextInt();
        }
        
        int count = -1;
        boolean state = true;
        while(state){
            count++;
            //偶数であれば2で割って格納し、奇数であればbreak。
            for(int j = 0; j < x; j++){
                if(A[j] % 2 == 0){
                    A[j] /= 2;
                }else{
                    state = false;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22996
def resolve():
    A, B, C = list(map(int, input().split()))
    if (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):
        if (A == B and B == C and C == A):
            print(-1)
            return

    if (A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
        print(0)
        return

    ans = 0
    while True:
        A, B, C = (B / 2 + C / 2), (C / 2 + A / 2), (A / 2 + B / 2)
        ans += 1
        if (A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
            print(ans)
            return

    return


resolve()


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

#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;

//https://codeforces.com/problemset/problem/1343/C
//https://codeforces.com/problemset/problem/1154/B

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

char c;
cin>>c;
if(isupper(c))
  cout<<'A'<<endl;
else
  cout<<'a'<<endl;
return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	ll n, i;
	cin >> n;
	vector<ll> a(n + 1), b(n);
	ll answer = 0;
	ll margin;

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

	for (i = 0; i < n; i++) {
		if (a[i] >= b[i]) {
			answer += b[i];
			a[i] -= b[i];
		} else {
			margin = b[i] - a[i];
			answer += a[i];
			a[i] = 0;
			if (margin > a[i + 1]) {
				answer += a[i + 1];
				a[i + 1] = 0;
			} else {
				answer += margin;
				a[i + 1] -= margin;
			}
		}
	}		   		
	
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

int main() {
  int N;
  cin >> N;

  vector<vector<int>> abc(3, vector<int>(N));

  REP(i,N){
    REP(j,3){
      cin >> abc[j][i];
    }
  }

  vector<vector<ll>> dp(N+1, vector<ll>(3,0));
 
  REP(i, N){
    REP(j, 3){
      REP(k, 3){
        if(j != k) chmax(dp[i+1][j], dp[i][k] + abc[j][i]);
      }
    }
  }

  ll  ans = 0;

  REP(i, 3){
    chmax(ans, dp[N][i]);
  }

  cout << ans << endl;

}


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

int main() {
	int n;
	scanf("%1d",&n);
	int a,b;
	scanf("%1d%1d",&a,&b);
	if(n==a&&a==b){
		cout<<n<<n<<n;
		return 0;
	}else if(n*100+n*10+n>n*100+a*10+b)cout<<n<<n<<n;
	else cout<<n+1<<n+1<<n+1;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S,T = input().split()
decl = 1
res= [i for i in range(len(S)+len(T))]
for j in range(len(S)+len(T)):
    if j % 2 == 0 :
        res[j] = S[int(j/2)]
    else:
        res[j] = T[int(j-decl)]
        decl = decl + 1

print(''.join(res))

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<bits/stdc++.h>
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    int a,b,c;
    cin>>a>>b>>c;
    if(c==a&&c==b)
     cout<<"Yes";
    else
    cout<<"No";}

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

int main() {
  long long x, a;
  cin >> x;
  a = x / 11;
  if(x%11==0){
    cout << a * 2 << endl;
  }
  else{
    if(x%11 <= 6){
      cout << 2*a+1 << endl;
    }
    else{
      cout << 2*a+2 << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main(){
    int N, M; cin >> N >> M;
    vector<bool> issafe;
    issafe.assign(N + 1, true);
    for(int i = 0; i < M; i++){
        int a; cin >> a;
        issafe[a] = false;
    }

    vector<int> dp(N + 1, 0);

    dp[0] = 1;
    if(issafe[1]) dp[1] = 1;

    for(int n = 2; n <= N; n++){
        if(issafe[n - 1]) dp[n] += dp[n - 1];
        if(issafe[n - 2]) dp[n] += dp[n - 2];
        dp[n] %= MOD;
    }

    cout << dp[N] << endl;

}

Measured memory_bytes: 640