akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){

while(1){
int n,x;
cin>>n>>x;
if(n==0 && x==0)break;

int r=0;

for(int i=1;i<=n-2;i++){
 for(int j=i+1;j<=n-1;j++){
  for(int k=j+1;k<=n;k++){
   if(i+j+k==x)r++;
  }
 }
}
cout<<r<<endl;
}

}



Measured memory_bytes: 3072
N, A = map(int, input().split())
X = list(map(int, input().split()))
Y = [x - A for x in X]
LMT = max(max(X), A)

dp = [[0 for _ in range(2 * N * LMT + 1)] for _ in range(N + 1)]
 
for j in range(N + 1) :
    for t in range(2 * N * LMT + 1):
        if j == 0 and t == N * LMT:
            dp[j][t] = 1
        elif j >= 1 and (t - Y[j - 1] < 0 or t - Y[j - 1] > 2 * N * LMT):
            dp[j][t] = dp[j - 1][t]
        elif j >= 1 and (0 <= t - Y[j - 1] <= 2 * N * LMT):
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - Y[j - 1]]
        else:
            dp[j][t] = 0
print(dp[N][N*LMT]-1)

Measured memory_bytes: 5740
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll dp[100];
int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	memr(dp, 0);
	int n; cin >> n;
	dp[0] = 1;
	dp[1] = 1;
	rep(i, 50){
		dp[i+2] = dp[i] + dp[i+1];
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 3092
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    H_count=H
    W_count=W
    while True:
        while True:
            print('#',end='')
            W_count-=1
            if not W_count:
                break
            print('.',end='')
            W_count-=1
            if not W_count:
                break
        print('')
        H_count-=1
        W_count=W
        if not H_count:
            break
        while True:
            print('.',end='')
            W_count-=1
            if not W_count:
                break
            print('#',end='')
            W_count-=1
            if not W_count:
                break
        print('')
        H_count-=1
        W_count=W
        if not H_count:
            break
    print('')


Measured memory_bytes: 7012
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int ans[] = new int[n + 1];
    for (int i = 1; i <= n; i++) {
      int a = Integer.parseInt(sc.next());
      ans[a] = i;
    }
    pw.println(
      Arrays.stream(ans).skip(1)
        .mapToObj(Integer::toString)
        .collect(Collectors.joining(" "))
    );
  }
}


Measured memory_bytes: 46228
package main

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

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    line := readLine(reader)
    arr := strings.Split(line, " ")
    N, _ := strconv.Atoi(arr[0])
    M, _ := strconv.Atoi(arr[1])
    C, _ := strconv.Atoi(arr[2])

    line = readLine(reader)
    b_arr := strings.Split(line, " ")
    var cnt int = 0

    for i := 0; i < N; i++ {
        line = readLine(reader)
        arr = strings.Split(line, " ")
        sum := 0

        for j := 0; j < M; j++ {
            a, _ := strconv.Atoi(arr[j])
            b, _ := strconv.Atoi(b_arr[j])
            sum += a*b
        }

        if sum + C > 0 {
            cnt++
        }
    }

    fmt.Println(cnt)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());

template<typename T>
void debug(T var, string label){
    cout << label << " " << var << '\n';
}

typedef long long ll;

void solve(){
    int n;
	cin >> n;
	   pair<int,int> a[n];
	for(int i = 0; i < n; ++i){
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	int ans = a[n - 1].second + a[n - 1].first;
	cout << ans << '\n';
}
int main()
{

    //freopen("C:/Users/LIB-606/Desktop/Contest/in.txt", "r", stdin);
    // freopen("C:/Users/LIB-606/Desktop/Contest/out.txt", "w", stdout);

    for(int i = 0; i < 1; ++i)
	    solve();
}


Measured memory_bytes: 1024
N= int(input())
B = list(map(int, input().split()))

A = []

A.append(B[0])

if len(B) > 1:
    for i in range(0, N - 2):
        A.append(min(B[i], B[i + 1]))
 

A.append(B[N-2])
answer = sum(A)  
print(answer)




Measured memory_bytes: 3060
// ACM-ICPCà\I2010 C. |bN\z

#include <iostream>

using namespace std;

int main(){
	int N;
	int tri[200];
	static int ansA[1000000], ansB[1000000];
	for(int i=0;i<200;i++) tri[i] = i*(i+1)*(i+2)/6;
	ansA[0] = ansB[0] = 0;
	for(int i=1;i<1000000;i++){
		ansA[i] = ansB[i] = i;
		for(int j=0;i-tri[j]>=0;j++){
			ansA[i] = min(ansA[i], ansA[i-tri[j]]+1);
			if(tri[j]%2==1)
				ansB[i] = min(ansB[i], ansB[i-tri[j]]+1);
		}
	}
	while(cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}

Measured memory_bytes: 8532
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[201];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n>>a1>>a2;
    for(i=0;i<=n;i++)
    {
        m=i;
        sum=0;
        while(m>0)
        {
            sum+=m%10;
            m/=10;
        }
        if(sum>=a1&&sum<=a2) sum2+=i;
    }
    cout<<sum2;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int field[105][105];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int N;
        cin >> N;
        if(N == 0) break;
        int H, W;
        cin >> W >> H;
        for(int h = 1; h <= H; h++) {
            for(int w = 1; w <= W; w++) {
                field[h][w] = 0;
            }
        }
        while(N--) {
            int x, y;
            cin >> x >> y;
            field[y][x] = 1;
        }
        int S, T;
        cin >> S >> T;
        int ans = 0;
        for(int h = 1; h + T - 1 <= H; h++) {
            for(int w = 1; w + S - 1 <= W; w++) {
                int now = 0;
                for(int nh = h; nh <= h + T - 1; nh++) {
                    for(int nw = w; nw <= w + S - 1; nw++) {
                        now += field[nh][nw];
                    }
                }
                ans = max(now, ans);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String S = sc.next();
    
    int count = 0;
    for (int i = 0; i+2 < N; i++) {
      if (
      S.charAt(i) == 'A' &&
      S.charAt(i+1) == 'B' &&
      S.charAt(i+2) == 'C'
      ) {
        count++;
      }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 23764
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
lcm = A[0]
for i in range(1,N):
    lcm = (lcm*A[i])//gcd(lcm,A[i])

MOD = 10**9+7
ans = 0
for a in A:
    b = lcm//a
    ans += b
print(ans%MOD)

Measured memory_bytes: 6116
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll 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() {
string ans = "Yes";
	int H,W; cin >> H >> W;
	char A[H+2][W+2] = {'.'};
	FORq(i,1,H)
	{
		FORq(j,1,W)
		{
			cin >> A[i][j];
		}
	}

	FORq(i,1,H)
	{
		FORq(j,1,W)
		{
			if(A[i][j] == '#')
			{
				if(A[i-1][j] == '#' || A[i+1][j] == '#' || A[i][j-1] == '#' || A[i][j+1] == '#'){;}
				else {ans = "No"; break;}
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",(a * b) >> 1);
	return 0;
}


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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int sum = 0;
    int sample = 0;

    sample = min(K, A);
    sum += 1 * sample;
    K -= sample;

    sample = min(K, B);
    sum += 0 * sample;
    K -= sample;

    sample = min(K, C);
    sum += -1 * sample;
    K -= sample;

    cout << sum << endl;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> m;
    rep(i, N) {
        ll t; 
        cin >> t;
        m[t]++;
    }
    if (m.size() == N) {
        print("YES");
    } else print("NO");
    return 0;
}

Measured memory_bytes: 12800
#!/usr/bin/env python3


def main():
    S = input().strip()
    T = input().strip()
    move = S[-1]+S[:-1]
    j = True
    if move == T:
        print("Yes")
        j = False
        exit()
    while j:
        move = move[-1]+move[:-1]
        if move == T:
            print("Yes")
            j = False
        elif move == S:
            print("No")
            j = False


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1<<29);


long long calc_digit(long long N){
    long long res = 0;
    while(N){
        res++;
        N /= 10;
    }
    return res;
}

void solve(long long N){
    long long ans = INF;
    for(long long A = 1; A * A <= N; A++){
        if(N % A == 0){
            long long B = N / A;
            long long F = max(calc_digit(A), calc_digit(B));
            ans = min(ans, F);
        }
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;cin>>n;
    vector<int> x(n+1),y(n+1);for(int i=1;i<=n;i++)cin>>x[i]>>y[i];
    vector<int> a;
    double sum=0.0;
    double count =0.0;
    rep(i,n)a.push_back(i+1);
    do {
        count += 1.0;
        for (int i = 1; i < n; i++) {
            double len = sqrt((x[a[i-1]] - x[a[i ]]) * (x[a[i-1]] - x[a[i ]]) + (y[a[i-1]] - y[a[i ]]) * (y[a[i-1]] - y[a[i]]));
            sum += len;

        }
    }while (next_permutation(a.begin(), a.end()));
        double ave = sum / count;
        cout << setprecision(15) << ave << endl;



}

Measured memory_bytes: 3796
n,m = list(map(int,input().split()))
ans = min((m%3)*n, n, (n%3)*m, m)
for i in range(1, m):
    l = [n * i, (m - i) * (n // 2), -(m - i) * (-n // 2)]
    ans = min(ans, max(l) - min(l))
n,m = m,n
for i in range(1, m):
    l = [n * i, (m - i) * (n // 2), -(m - i) * (-n // 2)]
    ans = min(ans, max(l) - min(l))
print(ans)


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);  cin.tie(NULL);
    int n, x, rta, i;
    set<int> s1;
    set<int>::iterator it;
    bool f;
    set<int> pairs;

    cin >> n;
    rta = 0;
    for( i = 0; i < n; i++ ){
        cin >> x;
        s1.insert(x);
        if( i%2 == 0 ) pairs.insert(x);
    }

    it = s1.begin();
    f = true;
    while( it != s1.end() ){
        if( f && !pairs.count( *it ) ) rta++;
        f = !f;
        it++;
    }

    cout << rta << "\n";
}


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

using namespace std;

const int N = 100010;
const int MOD = 1000000007;

inline int add(int u, int v) {
	u += MOD;
	if (u >= MOD) {
		u -= MOD;
	}
	return u;
}

inline int mul(int u, int v) {
	return (long long)u * v % MOD;
}

inline int power(int u, int v) {
	int res = 1;
	while (v) {
		if (v & 1) {
			res = mul(u, res);
		}
		u = mul(u, u);
		v >>= 1;
	}
	return res;
}

inline int inv(int u) {
	return power(u, MOD - 2);
}

int n, m;
int fac[N * 2];

int c(int k, int n) {
	if (k < 0 || k > n) {
		return 0;
	}
	int foo = mul(fac[k], fac[n - k]);
	return mul(fac[n], inv(foo));
}

int main() {
	scanf("%d %d", &n, &m);	
	vector<pair<int, int> > div;
	for (int i = 2; i * i <= m; i++) {
		if (m % i == 0) {
			div.push_back(make_pair(i, 0));
			while (m % i == 0) {
				m /= i;
				div.back().second++;
			}
		}
	}
	if (m > 1) {
		div.push_back(make_pair(m, 1));
	}
	fac[0] = 1;
	for (int i = 1; i < N * 2; i++) {
		fac[i] = mul(fac[i - 1], i);
	}
	int res = 1;
	for (auto u : div) {
		res = mul(res, c(n - 1, n - 1 + u.second));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int keta = 0;
		long ans = 0;
		if(n % 2 == 1) {
			System.out.println(0);
		} else {
			long tmp = n;
			tmp /= 10;
			while(tmp != 0) {
				ans += tmp;
				tmp /= 5;
			}
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 21844
s = input().rstrip()
n = len(s)
for i, c in enumerate(s):
    if i + 1 < n and c == s[i + 1]:
        print(i + 1, i + 2)
        break
    if i + 2 < n and c == s[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)

Measured memory_bytes: 3188
import sys
x, k, d = map(int, input().split())

#偶数、奇数
isEven = (k%2 == 0)

#一番いい回数
div = abs(x//d)


#0,a,b
ans = 0
if k < div:
    if x > 0:
        # print("0")#消す
        print(abs(x-d*k))
    else:
        # print("1")#消す
        print(abs(x+d*k))
else:
    if x > 0:
        if (k-div) % 2 == 0:
            # print("A")#消す
            print(abs(x-d*div))
        else:
            # print("B")#消す
            hoge = x-d*div
            if hoge+d < abs(hoge-d):
                print(abs(hoge+d))
            else:
                print(abs(hoge-d))
    else:
        if (k-div) % 2 == 0:
            # print("C")#消す
            print(abs(x+d*div))
        else:
            # print("D")#消す
            hoge = x+d*div
            if hoge+d < abs(hoge-d):
                # print("E")#消す
                print(abs(hoge+d))
            else:
                # print("F")
                print(abs(hoge-d))

Measured memory_bytes: 9148
N = int(input())
a_list = list(map(int, input().split()))

fc = 0
oc = 0
tc = 0
for i in a_list:
    if i % 2 == 0 and i % 4 != 0:
        tc += 1
    elif i % 4 == 0:
        fc += 1
    else:
        oc += 1

if fc >= oc:
    print("Yes")
elif tc == 0 and (oc - fc == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll C;
  cin >> C;
  ll x[N],v[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> v[i];
  }
  ll right_mx[N];
  ll left_mx[N];
  ll right_mx_2[N];
  ll left_mx_2[N];
  ll now = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      now -= x[i];
    } else {
      now -= x[i] - x[i-1];
    }
    now += v[i];
    if (i == 0) {
      right_mx[i] = max(0LL,now - x[i]);
      right_mx_2[i] = max(0LL,now);
    } else {
      right_mx[i] = max(right_mx[i-1],now - x[i]);
      right_mx_2[i] = max(right_mx_2[i-1],now);
    }
  }
  now = 0;
  for (int i = N-1; i >= 0; i--) {
    if (i == N-1) {
      now -= (C - x[i]);
    } else {
      now -= x[i+1] - x[i];
    }
    now += v[i];
    if (i == N-1) {
      left_mx[i] = max(0LL,now - (C - x[i]));
      left_mx_2[i] = max(0LL,now);
    } else {
      left_mx[i] = max(left_mx[i+1],now - (C - x[i]));
      left_mx_2[i] = max(left_mx_2[i+1],now);
    }
  }
  ll ans = 0;
  ans = max(ans,left_mx_2[0]);
  ans = max(ans,right_mx_2[N-1]);
  for (int i = 0; i < N-1; i++) {
    ll res1 = right_mx_2[i] + left_mx[i+1];
    ll res2 = right_mx[i] + left_mx_2[i+1];
    ans = max({ans,res1,res2});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}



/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 1e5 + 9;

int main()
{
     IO;
	ll n,a,b;
	cin>>n>>a>>b;
	if(a > b) swap(a,b);
	if(a== b) return cout<<0,0;
	ll m = (a+b)/2;
	ll mva = a-1;
	ll nb = b - mva;
	ll ans = min(max(a-1 ,b-1), max(n-a ,n-b));
//	cout<<ans<<"\n";
	ll m2 = (nb+1)/2;
	ans = min(ans, nb - m2 + mva);
	//cout<<ans<<"\n";
	if(m - a == b-m){
		ans = min(ans, m -a);
	}
	//cout<<ans<<"\n";
	ll mvb = n- b;
	ll na = a + mvb;
	ll m3 = (n + na)/2;
	ans = min(ans, n - m3 + mvb);
	cout<<ans; 
	return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int n, a, b;
void solve() {
    cin >> n >> a >> b;

    if ((b - a - 1) % 2 == 1) cout << "Alice" << endn;
    else cout << "Borys" << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

class Solver {

    private double expect(int k) {
        return (0.5) * (k - 1) + 1.0;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        int[] pa = new int[N + 1];
        
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }

        for (int i = 0; i + 1 <= N; i++) {
            pa[i + 1] = pa[i] + p[i];
        }

        int max = Integer.MIN_VALUE;
        int idx = 0;
        for (int i = 0; i + K <= N; i++) {
            int diff = pa[K + i] - pa[i];
            //System.out.println(i + "," + diff);
            if (max < diff) {
                max = diff;
                idx = i;
            }
        }

        double score = 0.0;
        for (int i = idx; i < idx + K; i++) {
            score += expect(p[i]);
        }

        //System.out.println(idx + "," + score);
        System.out.println(score);
        return;
    }

}

Measured memory_bytes: 76332
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)cin >> arr[i];
	int dp[n];
	dp[0]=0;
	dp[1]=dp[0]+abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
	dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1152
class UnionFind:
    def __init__(self, n):
        self.par = [-1]*n
        self.size = [1]*n
        self.point = n*(n-1) // 2

    def root(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return False
        # size において rx>ry にする
        if self.size[rx] < self.size[ry]:
            rx, ry = ry, rx
        self.point -= self.size[rx]*self.size[ry]
        self.size[rx] += self.size[ry]
        # ryの親をrxに設定 (sizeにおいて "小さい方(ry)を大きい方(rx)に" つなげる)
        self.par[ry] = rx
        return True

    def is_same(self, x, y):
        rx, ry = self.root(x), self.root(y)
        return rx == ry

    def get_size(self, x):
        return self.size[self.root(x)]

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)

for a, b in AB:
    a, b = a-1, b-1
    uf.unite(a, b)

r = max(uf.size)

print(r)

Measured memory_bytes: 51676
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll 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()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  REP(i,SZ(s)){
    cout << s[i];
    if(i==3) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() { 
  int a;
  string s;
  cin>>a>>s;
  
  if(a>=s.size()){
    cout<<s<<endl;
    }
  if(a<s.size()){
    for(int i=0;i<a;i++){
      cout<<s.at(i) ;
      }
    cout<<"..."<<endl;
    }
  }

Measured memory_bytes: 3632
import itertools
import math

d, g = map(int, input().split(" "))

all = set()
for x in range(0, d):
    all.add(x)

pl = list()
for i in range(0, d):
    p, c = map(int, input().split(" "))
    pl.append((i, p, c))

ans = 100000000
for n in range(0, d + 1):
    for select in itertools.combinations(pl, n):
        full_sum = 0
        full_count = 0
        full_list = set()

        for fp, fn, fc in select:
            full_sum += (fp + 1) * 100 * fn + fc
            full_count += fn
            full_list.add(fp)
        
        if full_sum >= g:
            ans = min(ans, full_count)
            # print("full: %s rest: None score: %d ans: %d" % (str(full_list), full_sum, ans))

        elif len(all - full_list) > 0:
            rest = max(all - full_list)
            rest_n, rest_p, rest_c = pl[rest]

            if g - full_sum <= (rest_n + 1) * 100 * (rest_p - 1):
                ans = min(ans, full_count + math.ceil((g - full_sum) / ((rest_n + 1) * 100)))
                # print("full: %s rest: %d score: %d ans: %d" % (str(full_list), rest_n, full_sum + rest_n * (rest_p - 1), ans))
        

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,t,a,x,p=1;
    double tmp,min=100000;
    cin >> n >> t >> a;
    for(int i=1;i<=n;i++){
        cin >> x;
        tmp = abs(a-(t-x*0.006));
        if(min>tmp){
            min = tmp;
            p = i;
        }
    }
    cout << p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << in() - in() + 1 << "\n";
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	k := getNextInt(scanner)
	s := getNextString(scanner)
	if len(s) > k {
		fmt.Fprintln(writer, fmt.Sprintf("%s...", s[:k]))
		return
	}
	fmt.Fprintln(writer, s)
}


Measured memory_bytes: 1768
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int k;
    cin>>k;

    string s;
    cin>>s;

    int n=sz(s);

    if(n<=k)
        cout<<s;
    else
    {
        cout<<s.substr(0,k)<<"...";
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> Dice;
//---------------------------------------
void roll_n(Dice &dice);
void roll_e(Dice &dice);
void roll_s(Dice &dice);
void roll_w(Dice &dice);

//---------------------------------------

int main(void)
{
	Dice dice;
	int num;
	string rolling;
	
	for(int i = 0; i < 6; i++){
		cin >> num;
		dice.push_back(num);
	}
	cin >> rolling;
	
	for(int i = 0; i < rolling.size(); i++){
	
		switch(rolling[i]){
		case 'N' :
			 roll_n(dice);
			 break;
		case 'E' :
			 roll_e(dice);
			 break;
		case 'S' :
			 roll_s(dice);
			 break;
		case 'W' :
			 roll_w(dice);
			 break;
		}
	}
	
	cout << dice[0] << endl;
	
	
	return 0;
	
}
//-------------------------------------
void roll_n(Dice &dice)
{
	Dice copy = dice;
	
	dice[4] = copy[0];
	dice[5] = copy[4];
	dice[1] = copy[5];
	dice[0] = copy[1];
}

//--------------------------------------
void roll_e(Dice &dice)
{
	Dice copy = dice;
	
	dice[0] = copy[3];
	dice[2] = copy[0];
	dice[5] = copy[2];
	dice[3] = copy[5];
}

//--------------------------------------
void roll_s(Dice &dice)
{
	Dice copy = dice;
	
	dice[1] = copy[0];
	dice[5] = copy[1];
	dice[4] = copy[5];
	dice[0] = copy[4];
}

//--------------------------------------
void roll_w(Dice &dice)
{
	Dice copy = dice;
	
	dice[3] = copy[0];
	dice[5] = copy[3];
	dice[2] = copy[5];
	dice[0] = copy[2];
}
/*
Top  [0]
Front [1]
Right [2]
Left [3]
Back [4]
Bottom [5]
*/

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void IO()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve()
{
    int n,m;
    cin>>n>>m;
    if(m==n)
    {
        for(int i=0;i<m;++i)
        {
            cout<<n;
        }
        return;
    }
    if(n<m)
    {
        for(int i=0;i<m;++i)
        {
            cout<<n;
        }
        return;
    }
    for(int i=0;i<n;++i)
    {
        cout<<m;
    }
}

int main()
{
   // IO();
    int t=1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    vector<ll> a(n);
    vector<P> cb(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> cb[i].second >> cb[i].first;
    
    sort(a.begin(), a.end());
    sort(cb.begin(), cb.end());
    reverse(cb.begin(), cb.end());

    vector<ll> d(n, -1);
    for (int i = 0, j = 0; i < n && j < m; i++) {
        d[i] = cb[j].first;
        if (--(cb[j].second) == 0) j++;
    }

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > d[i]) sum += a[i];
        else sum += d[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 3328
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.charAt(0) == s.charAt(1) ||
                s.charAt(1) == s.charAt(2) ||
                s.charAt(2) == s.charAt(3) ){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }
    }
}

class io{
    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



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

int main()
{
	int n;
	cin >> n;
	int count = 0;
	int now = 1;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		if (a == now)
		{
			++count;
			now = a + 1;
		}
	}
	cout << (n - count == n?-1:n - count) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N, K;
  cin >> N >> K;

  vector<int> p;
  vector<int> m;
  for (int i = 0; i < N; i++)
  {
    int x;
    cin >> x;
    if (x < 0) m.push_back(-x);
    else if (x > 0) p.push_back(x);
    else K--;
  }

  reverse(m.begin(), m.end());
  
  int ans = INF;
  for (int i = 0; i <= K; i++)
  {
    int j = K - i;
    if (i > p.size() || j > m.size()) continue;
    int pp = 0;
    if (i > 0) pp = p.at(i - 1);
    int mm = 0;
    if (j > 0) mm = m.at(j - 1);
    chmin(ans, pp + mm + min(pp, mm));
  }

  cout << ans << endl;
}

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

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

  if(x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int main(int argc, const char * argv[]) {
    int i,n = 0;
    char w[11], t[1001];
    
    scanf("%s", w);
    
    do{
        scanf("%s",t);
        if(!strcmp(t,"END_OF_TEXT")) break;
        for(i=0;t[i]!='\0';i++)
            if(t[i]<91) t[i] += 32;
        if( !strcmp(w,t) ) n++;
    }while(1);
    
    printf("%d\n",n);
    
    return 0;
}


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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    ll ans=0;
    ll INF=1e+9+7;
    for(ll i=0;i<60;i++){
        ll d1=0;
        ll d2=0;
        for(int j=0;j<N;j++){
            if(A[j]&((ll)1<<i)) d1++;
            else d2++;
        }
        ll a = d1*d2%INF;
        ll b =((ll)1<<i)%INF;
        ans = (ans+a*b)%INF;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
n = int(raw_input())
x = map(int,raw_input().split())
x2 = sorted(x)

m1 = x2[n/2 - 1]
m2 = x2[n/2]

if m1 == m2:
  for a in range(n):
    print m1
  exit(0)

for a in x:
  if a <= m1:
    print m2
  else:
    print m1


Measured memory_bytes: 20060
# -*- coding: utf-8 -*-
# B

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

A, B, C, D = map(int, input().split())

for i in range(100):
    C -= B
    if C <= 0:
        print('Yes')
        sys.exit()
    A -= D
    if A <= 0:
        print('No')
        sys.exit()


Measured memory_bytes: 61724
divider = "#" * 20
input = Hash.new(0)
gets.to_i.times do
  b, f, r, v = gets.split.map!(& :to_i)
  input["#{b} #{f} #{r}"] += v
end
1.upto(4) do |i|
  1.upto(3) do |j|
    1.upto(10) do |k|
      print " " + input["#{i} #{j} #{k}"].to_s 
    end
    puts
  end
  if (i != 4) then 
  	puts divider
  end 
end 

Measured memory_bytes: 8748
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main(){
    int n,m;
    cin>>n>>m;
    (n==m)?puts("Yes"):puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/


int main()
{
	cin >> n >> m >> k;
	if (abs(n - m) < abs(n - k)) {
		cout << "A" << endl;
	} else {
		cout << "B" << endl;
	}
}


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

int N;
int sum[500010] = {0};

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        sum[a]++;
    }
    for(int i = 1; i < N; i++)
    {
        if(sum[i] != 0 && sum[i] != 2)
        {
            printf("0\n");
            return 0;
        }
    }
    int ans = 1;
    for(int i = 0; i < N / 2; i++)
    {
        ans *= 2;
        ans %= 1000000007;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 640
// Author : Chi
// created : 2020-05-24 Sunday

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//macros
#define ll 		    long long
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb          push_back
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define TEST1       solve();
#define mod         998244353
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//namespaces
using    namespace __gnu_pbds;
using    namespace std;

typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
void solve(){
    string a,b;
    cin>>a>>b;
    int l1=a.length();
    int l2=b.length();
    int dp[l1+1][l2+1];
    memset(dp,0,sizeof dp);
//    cout<<" ";
//    for(auto i:b)
//        cout<<" "<<i;
//    cout<<"\n";
    for(int i=1;i<=l1;i++){
//        cout<<a[i-1]<<" ";
        for(int j=1;j<=l2;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
//            cout<<dp[i][j]<<" ";
        }
//        cout<<"\n";
    }
    int i=l1;
    int j=l2;
    string ans;
    while(i>0&&j>0){
        if(a[i-1] == b[j-1]){
            ans=a[i-1]+ans;
            i--;
            j--;
            }
        else{
            if(dp[i-1][j] >= dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    cout<<ans;
}
// Driver Code
int main(){
    TEST1
    return 0;
}
/*
adsfasdfas
adfasdfsadgnf
afdsafda
*/


Measured memory_bytes: 35456
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
	double x[3], y[3];
	double a, b, c;
	double A[2], B[2], C[2];
	double px, py;
	double r;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
		A[0] = 2 * (x[1] - x[0]);
		B[0] = 2 * (y[1] - y[0]);
		C[0] = pow(x[0], 2) - pow(x[1], 2) + pow(y[0], 2) - pow(y[1], 2);
		A[1] = 2 * (x[2] - x[0]);
		B[1] = 2 * (y[2] - y[0]);
		C[1] = pow(x[0], 2) - pow(x[2], 2) + pow(y[0], 2) - pow(y[2], 2);
		px = ((B[0] * C[1]) - (B[1] * C[0])) / ((A[0] * B[1]) - (A[1] * B[0]));
		py = ((C[0] * A[1]) - (C[1] * A[0])) / ((A[0] * B[1]) - (A[1] * B[0]));
		a = sqrt(pow(x[1] - x[0], 2) + pow(y[1] - y[0], 2));
		b = sqrt(pow(x[2] - x[0], 2) + pow(y[2] - y[0], 2));
		c = sqrt(pow(x[2] - x[1], 2) + pow(y[2] - y[1], 2));
		r = (a * b * c) / sqrt((a+b+c) * (-a+b+c) * (a-b+c) * (a+b-c));
		printf("%.3lf %.3lf %.3lf\n", px, py, r);
	}
	return 0;
}

Measured memory_bytes: 1244
import Control.Monad
import Control.Applicative
import Data.List

solve :: [[Int]] -> String
solve (rc:cs) =
    let matrix = transpose $ map attachSumCell $ transpose $ map attachSumCell cs in
    unlines [unwords [show c | c<-y] | y<-matrix]
    where
    attachSumCell :: [Int] -> [Int]
    attachSumCell c = c ++ [sum c]

main =
    putStr =<< solve . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [[Int]]
    takeInputs = map (map read . words)

Measured memory_bytes: 8052
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip())
to4 = []
while N !=1 and N!=-1 and N!=0:
  #print(N)
  if N%2==0:
    to4.append("0")
    N = N//(-2)
  else:
    to4.append("1")
    N = int((N-1)/(-2))
  #print(to4[-1])

if N==1:
  to4.append("1")
elif N==0:
  to4.append("0")
else:
  to4.append("11")
to4 = to4[::-1]
ans = "".join(to4)
print(ans)

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

int main(){
  int N;
  cin >> N;
  
  vector<int> D(N);
  for (int i = 0; i < N; i++){
    cin >> D.at(i);
  }
  
  sort(D.begin(), D.end());
  
  int ans = D.at(N / 2) - D.at(N / 2 - 1);
  cout << ans << endl;
}

Measured memory_bytes: 3788
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    long[] fac, inv;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
        out.flush();
    }
    void solve(){
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        fac = new long[n+1]; inv = new long[n+1];
        fac[0] = 1; inv[0] = 1;
        for(int i=1;i<=n;i++) fac[i] = i*fac[i-1]%mod;
        inv[n] = power(fac[n],mod-2);
        for(int i=n-1;i>0;i--){
            inv[i] = (i+1)*inv[i+1]%mod;
        }
        long ans = 0;
        for(int i=0;i<=k;i++){
            // there are exactly i pair of adjacent blocks that have the same color
            // then we lose i blocks
            long tempN = n-i;
            long cur = m*power(m-1,tempN-1)%mod*comb(n-1,i)%mod;
            ans = (ans+cur)%mod;
        }
        ans %= mod;
        out.println(ans);
    }
    long comb(int n, int m){
        if(n<m ) return 0;
        return fac[n]*inv[m]%mod*inv[n-m]%mod;
    }
    long power(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
}



Measured memory_bytes: 39040
package main

import (
	"fmt"
)

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

	times := []int{a,b,c,d,e}

	lastVal := 10
	lastKey := -1
	for k,time := range times {
		if (time - 1) % 10 < lastVal {
			lastKey = k
			lastVal = (time - 1) % 10
		}
	}

	sum := 0
	for k2,time := range times {
		if lastKey == k2 {
			sum += time
		} else {
			sum += (time + 9) / 10 * 10
		}
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512