akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var k = nk[1];
        SegmentTree<int> segTree = new SegmentTree<int>(300001, 0, Max);
        for (int i = 0; i < nk[0]; i++)
        {
            var a = int.Parse(Console.ReadLine());
            segTree[a] = segTree.Query(Max(0, a - k), Min(300000, a + k)) + 1;
        }
        Console.WriteLine(segTree.Query(0, 300000));
    }
}


class SegmentTree<T>
{
    public int Size { get; private set; }
    T Identity;
    T[] Data;
    Func<T, T, T> Merge;
    int LeafCount;

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(int size, T identity, Func<T, T, T> merge)
    {
        Init(size, identity, merge);
        for (int i = 1; i < Data.Length; i++) Data[i] = identity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public SegmentTree(T[] elems, T identity, Func<T, T, T> merge)
    {
        Init(elems.Length, identity, merge);
        elems.CopyTo(Data, LeafCount);
        for (int i = elems.Length + LeafCount; i < Data.Length; i++) Data[i] = identity;
        for (int i = LeafCount - 1; i >= 1; i--) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private void Init(int size, T identity, Func<T, T, T> merge)
    {
        Size = size;
        Identity = identity;
        Merge = merge;
        LeafCount = 1;
        while (LeafCount < size) LeafCount <<= 1;
        Data = new T[LeafCount << 1];
    }

    public T this[int index]
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get { return Data[LeafCount + index]; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        set { Update(index, value); }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Update(int i, T x) { Data[i += LeafCount] = x; while (0 < (i >>= 1)) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x) { Data[i += LeafCount] = Merge(Data[i], x); while (0 < (i >>= 1)) Data[i] = Merge(Data[i << 1], Data[(i << 1) | 1]); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int l, int r)
    {
        T lRes = Identity, rRes = Identity;
        for (l += LeafCount, r += LeafCount; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1)
        {
            if ((l & 1) == 1) lRes = Merge(lRes, Data[l]); if ((r & 1) == 0) rRes = Merge(Data[r], rRes);
        }
        return Merge(lRes, rRes);
    }
}


Measured memory_bytes: 43420
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    cin >> N;
    ll ans = 1;
    queue<ll> As;
    rep(i, N) {
        ll A;
        cin >> A;
        if (A == 0) {
            cout << 0 << endl;
            return 0;
        }
        As.push(A);
    }
    rep(i, N) {
        ll A = As.front();
        As.pop();
        if (A >= 1000000000000000000/ans + 1) {
            cout << -1 << endl;
            return 0;
        }
        ans *= A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4348
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


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

    int pre = -999;
    rep(i, n){
        if (pre <= h[i] - 1){
            pre = h[i] - 1;
        } else if (pre <= h[i]){
            pre = h[i];
        } else {
            puts("No");
            return 0;
        }
    }

    cout << "Yes\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    string a, b, ans;
    cin >> a >> b;
    int c = a.compare(b);
    if (c > 0 && a.length() >= b.length())
    {
        ans = "GREATER";
    }
    else if (c == 0)
    {
        ans = "EQUAL";
    }
    else
    {
        ans = "LESS";
    }
    cout << ans << endl;
}

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

int main() {
	// your code goes here
	char ch;
	cin >> ch;
	if(ch>='A' && ch<='Z')
	    cout << "A";
	else
	    cout << "a";
	return 0;
}


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

using namespace std;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    set <int> s;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        if (s.find(a) != s.end())
            s.erase(a);
        else
            s.insert(a);
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (int (i)(0); (i)<(v.size()); ++(i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define all(v) (v).begin(), (v).end()

using namespace std;

int main(){
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) {
		cout << "Yay!\n";
	}
	else {
		cout << ":(\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;

//////////////////////////////
// ????????? (?????¨????????????????????????????????¨??°?????????2???????????????????????????????????????
int dfs(int u, int prev, int *cnt, int *prenum, int *lowest, vector< vector<int> > &v, vector<pi> &res){
  prenum[u] = lowest[u] = ++(*cnt);
  REP(i, v[u].size()){
    int next = v[u][i];
    if(prenum[next] == -1){
      lowest[u] = min(lowest[u], dfs(next, u, cnt, prenum, lowest, v, res));
      if(lowest[next] == prenum[next]) res.push_back(pi(min(u, next), max(u, next)));
    }
    else if(prev != next)
      lowest[u] = min(lowest[u], lowest[next]);
  }
  return lowest[u];
}
vector<pi> bridges(int V, int E, vector< vector<int> > &v){
  int prenum[V], lowest[V];
  memset(prenum, -1, sizeof(prenum));
  int tmp = 1;
  vector<pi> res;
  dfs(0, -1, &tmp, prenum, lowest, v, res);
  return res;
}
int main() {
	int v, e; cin >> v >> e;
	vector<vi> vvi(v);
	REP(i, e) {
		int a,b; cin >> a >> b;
		vvi[a].pb(b);
		vvi[b].pb(a);
	}
	vector<pi> ans = bridges(v, e, vvi);
	sort(ans.begin(), ans.end());
	REP(i, ans.size())
		cout << ans[i].first << ' '<< ans[i].second << endl;
	return 0;
}

Measured memory_bytes: 5240
import std.stdio : writeln, writefln;
import std.array;
import std.range;
import std.algorithm : filter;


void main(){
	delim = ",";
	bool f = false;
	
	while(hasNext){
		int n = next!int();
		double w = next!double();
		double h = next!double();
		
		if(w/(h*h)>=25){
			n.writeln;
			f = true;
		}
	}
	
	if(!f){
		"該当なし"w.writeln;
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 996
import java.util.HashMap;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
N = int(input())
h = list(map(int,input().split()))

count = 0
while h.count(0) != N:
    beforeWater = False
    for i in range(N):
        if h[i] > 0:
            if not beforeWater:
                count += 1
            h[i] = h[i] - 1
            beforeWater = True
        else:
            beforeWater = False

print(count)

Measured memory_bytes: 9056
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int H,W,h,w;
int main(void)
{
  cin >> H >> W;
  cin >> h >> w;
  cout << H*W - (h*W) - (w*H) + (h*w) << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, a);
    print(a + a * a + a * a * a);

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
 #include <string>
using namespace std; 
int main()
{    
    int h ; int w; cin>>h>>w;
    char multiarr[h][w];
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
           cin>>multiarr[i][j];
        }
    }
  char copyarr[h][w];
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
           copyarr[i][j]= multiarr[i][j];
        }
    }

    char toaddchar;
    // int countbomb=0;
    for (int i = 0; i < h; ++i)
    {
     for (int j = 0; j < w; ++j)
     {    int  countbomb=0;
        if(copyarr[i][j]=='.'){
                      
               if(0<=(i-1) && (i-1)<=h-1){
                if(0<=(j-1) && (j-1)<=w-1){
                  if(copyarr[i-1][j-1]=='#'){  countbomb++;}
                }
               }

               if(0<=(i-1) && (i-1)<=h-1){
                if(0<=(j) && (j)<=w-1){
                  if(copyarr[i-1][j]=='#'){ countbomb++;}
                }
               }

               if(0<=(i-1) && (i-1)<=h-1){
                if(0<=(j+1) && (j+1)<=w-1){
                  if(copyarr[i-1][j+1]=='#'){countbomb++;}
                }
               }

                if(0<=(i) && (i)<=h-1){
                if(0<=(j-1) && (j-1)<=w-1){
                  if(copyarr[i][j-1]=='#'){countbomb++;}
                }
               }
              if(0<=(i) && (i)<=h-1){
                if(0<=(j+1) && (j+1)<=w-1){
                  if(copyarr[i][j+1]=='#'){countbomb++;}
                }
               }
               if(0<=(i+1) && (i+1)<=h-1){
                if(0<=(j-1) && (j-1)<=w-1){
                  if(copyarr[i+1][j-1]=='#'){countbomb++;}
                }
               }
               if(0<=(i+1) &&  (i+1)<=h-1){
                if(0<=(j) && j<=w-1){
                  if(copyarr[i+1][j]=='#'){countbomb++;}
                }
               }
               if(0<=(i+1) && (i+1)<=h-1){
                if(0<=(j+1 ) && (j+1)<=w-1){
                  if(copyarr[i+1][j+1]=='#'){countbomb++;}
                }
               }


               

                toaddchar='0'+countbomb;
                multiarr[i][j]=toaddchar;
        }

  
       
     }

    }

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
           cout<<multiarr[i][j];
        }
        cout<<"\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll A, B;
	cin >> A >> B;
	if (A > 9 || B > 9) {
		cout << -1 << endl;
	}
	else {
		cout << A * B << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
pair<int, int>a[100010];
int b[100010] = {};
signed main() {
	int n, m;
	string s;
	cin >> n >> m >> s;
	b[0] = 0;
	rep(i, n) {
		if (s[i] == 'C'&&s[i - 1] == 'A')b[i+1] = b[i] + 1;
		else { b[i + 1] = b[i]; }
	}
	rep(i, m) {
		cin >> a[i].first >> a[i].second;
	}
	rep(i, m) {
		cout << b[a[i].second] - b[a[i].first] << endl;
	}
}

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

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input_count;
	int prime_count;
	int input;
	int cnt;
	int output[30];
	int prime_cnt;
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
	{
		if(is_prime1(cnt))
		{
			prime[prime_cnt] = cnt;
			prime_cnt++;
		}
	}
	
	/*Get, calculate input then save in output[]*/
	input_count = 0;
	while(scanf("%d", &input) != EOF)
	{
		prime_count = 0;
		if(input >= 2)
		{
			prime_count++;
		}
		for(cnt = 3; cnt <= input; cnt += 2)
		{
			if(is_prime2(cnt))
			{
				prime_count++;
			}
		}
		output[input_count] = prime_count;
		input_count++;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_count; cnt++)
	{
		printf("%d\n", output[cnt]);
	}
	
    return 0;
}

/*Test prime directly*/
int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1)
	{
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7)
	{
		return 1;
	}
	else if((prime1_input % 2) == 0)
	{
		return 0;
	}

	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
	{
		if(prime1_input % prime1_cnt == 0)
		{
			return 0;
		}
	}
	
	return 1;
}

/*Test prime with prime table*/
int is_prime2(int prime2_input)
{
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++)
	{
		if(prime[prime2_cnt] > sqrt(prime2_input))
		{
			break;
		}
		if(prime2_input % prime[prime2_cnt] == 0)
		{
			return 0;
		}
	}
	return 1;
}

Measured memory_bytes: 596
while True:
    S = input()
    S = int(S)
    if S >= 0 and S <= 86400:
        break
    
h = S//3600
m = (S-h*3600)//60
s = S-h*3600-m*60

print('{0}:{1}:{2}' .format(h, m, s)) 


Measured memory_bytes: 5592
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <sstream>
using namespace std;

void q87() {
	string inputs;
	for (; getline(cin,inputs);) {
		istringstream ss(inputs);
		stack<double> stk;
		string input;
		for (; getline(ss, input, ' ');) {
			if (input == "0" || atoi(input.c_str()) != 0) {
				stk.push((double)atoi(input.c_str()));
			}

			else {
				if (input == "+") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a + b);
				}
				else if (input == "-") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a - b);
				}
				else if (input == "*") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a * b);
				}
				else if (input == "/") {
					double b = stk.top(); stk.pop();
					double a = stk.top(); stk.pop();
					stk.push(a / b);
				}
			}
		}
		printf("%f\n",stk.top());
	}
}

int main() {
	q87();
	return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  string S;
  cin >> S;
  int y = stoi(S.substr(0,4));
  int m = stoi(S.substr(5,2));
  int d = stoi(S.substr(8,2));
  int last[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
  string ans = "TBD";
  if(y < 2019) ans = "Heisei" ;
  if(y == 2019 && m == 4) ans = "Heisei";
  if(y == 2019 && m <= 3) ans = "Heisei";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i,j,k,l,n,cnt;
    while(scanf("%d",&n)==1){
        cnt = 0;
        for(i=0;i<=9;i++)
            for(j=0;j<=9;j++)
                for(k=0;k<=9;k++)
                    for(l=0;l<=9;l++)
                        if(n==(i+j+k+l))cnt++;
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1024
import sys
n=int(input())
s=input()
frac=[0]*(n+1)
for i in range(1,n+1):
    k=i
    frac[i]=frac[i-1]
    while k%2==0:
        k//=2
        frac[i]+=1

ans=0
for i in range(n):
    if int(s[i])==2 and frac[n-1]-frac[i]-frac[n-1-i]==0:
        ans^=1

if ans==1: print(1)
elif "2" in s: print(0)
else:
    ans=0
    for i in range(n):
        if int(s[i])==3 and frac[n-1]-frac[i]-frac[n-1-i]==0:
            ans^=1
    print(ans*2)


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

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

    double ans = 0.0;

    if (d != 0) {
        ans = (n - d) * 2 * (m - 1) / pow(n, 2);
        cout << fixed << setprecision(10) << ans << endl;
    }
    else if (d == 0) {
        ans = (m - 1) / n;
        cout << fixed << setprecision(10) << ans << endl;
    }
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int a,b,c,n,ans=0;
  cin>>a>>b>>c>>n;
  for(int i=0;i<=n/a;i++){
    for(int j=0;j<=n/b;j++){
        if((n-i*a-j*b)%c==0 && (n-i*a-j*b)>=0) ans++;
    }
  }
  
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int w, h, n;
  scanf("%d %d %d", &w, &h, &n);

  int i, xl=0, xr=w, yd=0, yu=h;
  for (i=0; i<n; i++) {
    int x, y, a;
    scanf("%d %d %d", &x, &y, &a);

    if (a==1 && xl<x) xl=x; 
    else if (a==2 && xr>x) xr=x; 
    else if (a==3 && yd<y) yd=y; 
    else if (a==4 && yu>y) yu=y; 
  }

  int W=(xr-xl), H=(yu-yd);
  printf("%d\n", W<=0 || H<=0 ? 0: W*H);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool used[50];
typedef pair<int,int>P;
int dx[]={-1,1};
int main(){
  int n,m;
  cin>>n>>m;
  int a[n+2];
  a[0]=0,a[n+1]=m;
  r(i,n)cin>>a[i+1];
  sort(a,a+n);
  int ans=0;
  r(i,n+2){
    ans+=min((m-a[i])*2,a[i]*2);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int w,h,n;
	cin>>w>>h>>n;
	pii a(0,0),b(h,w);
	rep(i,n){
		int x,y,z;
		cin>>x>>y>>z;
		if(z==1){
			maxs(a.S,x);
		}
		else if(z==2){
			mins(b.S,x);
		}
		else if(z==3){
			maxs(a.F,y);
		}
		else{
			mins(b.F,y);
		}
	}
	cout<<max(b.F-a.F,0)*max(b.S-a.S,0)<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n;
    cin >> n;

    for (ll i = n; i <= (n * 2); i++)
    {
        int flag = 1;
        for (int j = 2; j <= (i / 2); j++)
        {
            if (i % j == 0)
            {
                flag = 0;
                break;
            }
        }

        if (flag == 1)
        {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

unsigned long long gcd(unsigned long long m, unsigned long long n) {
    unsigned long long temp;
    if(m<n) {
        temp = m;
        m = n;
        n = temp;
    }
    
    unsigned long long r;
    while((r = m % n) != 0) {
        m = n;
        n = r;
    }
    
    return n;
}

unsigned long long lcm(unsigned long long x, unsigned long long y) {
    return x / gcd(x, y) * y;
}

int main(void){

    int a, b;
    cin >> a >> b;
    
    cout << lcm(a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define ill long long
#define rep(i,a,b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ill> v(n);
  rep(i,0,n) cin >> v[i];
  sort(v.begin(), v.end());
  ill sum = 0;
  rep(i, 0, n) {
    rep(j, i, n) {
      rep(k, j, n) {
        if(v[i] != v[j] && v[j] != v[k] && v[i] + v[j] > v[k]) sum++;
      }
    }
  }
  cout << sum << "\n";
}

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

double d,n,m;
int main(){
	cin >> n >> m >> d;
	if(d!=0) printf("%.10f\n",2*(n-d)*(1/n)*(1/n)*(m-1));
	else printf("%.10f\n",n*(1/n)*(1/n)*(m-1));
//	cout <<  << endl;
}

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int i, j;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	vi c(h*w);
	int k = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < a[i]; j++) {
			c[k] = i + 1;
			k++;
		}
	}
	bool flag = true;
	for (i = 0; i < h; i++) {
		if (flag) {
			for (j = 0; j < w; j++) {
				cout << c[i*w + j] << " ";
			}
		}
		else {
			for (j = w - 1; j >= 0; j--) {
				cout << c[i*w + j] << " ";
			}
		}
		cout << endl;
		flag = !flag;
	}
}

Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// N:
var N int
var node [][]int
var dist1 []int
var dist2 []int
var u, v int

func dfs1(x, p, cnt int) {
	if len(node[x]) == 1 {
		dist1[x] = cnt
	}
	for _, e := range node[x] {
		if e == p {
			continue
		}
		dfs1(e, x, cnt+1)
	}
}

func dfs2(x, p, cnt int) {
	if len(node[x]) == 1 {
		dist2[x] = cnt
	}
	for _, e := range node[x] {
		if e == p {
			continue
		}
		dfs2(e, x, cnt+1)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	N, u, v = getInt(), getInt()-1, getInt()-1
	node = make([][]int, N)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		node[f] = append(node[f], t)
		node[t] = append(node[t], f)
	}

	dist1 = make([]int, N)
	dist2 = make([]int, N)
	dfs1(v, -1, 0)
	dfs2(u, -1, 0)
	// out(dist1)
	// out(dist2)

	ans := 0
	for i := 0; i < N; i++ {
		if dist1[i] > dist2[i] {
			// diff := dist1[i] - dist2[i]
			// out(dist1[i], dist2[i], diff)
			ans = max(ans, dist1[i]-1)

		}
	}
	out(ans)
}


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

using namespace std;

#define pb push_back
#define sz size()

map<int, int >M[100010];
std::vector<int> g[100010];
std::vector< pair<int,int> > inp;
std::vector<int> p;

void dfs(int u, int p = 0, int c = 0) {

    M[u][p] = M[p][u] = c;

    int col = 1;

    for(auto v : g[u]) {
        if(v == p) continue;

        if(c == col) col++;

        dfs(v, u, col);

        col++;
    }
}

int main() {

    int n, m, x, y;
    cin >> n;

    for(int i = 0; i < n - 1; i++){
        cin >> x >> y;
        inp.pb({x, y});
        g[x].pb(y);
        g[y].pb(x);
    }
    p.resize(n);
    iota(p.begin(), p.end(), 1);

    sort(p.begin(), p.end(), [&](int x, int y){
        return (int)g[x].sz > (int)g[y].sz;
    });

    dfs(p[0]);

    cout << g[p[0]].sz << endl;

    for(int i = 0; i < n - 1; i++){
        cout << M[inp[i].first][inp[i].second] << endl;
    }

    return 0;
}

Measured memory_bytes: 21236
<?php
# 入力
fscanf(STDIN, "%d", $n);
$d = array_map('intval', explode(' ', trim(fgets(STDIN))));

sort($d);
$i = $n / 2 - 1;
if ($d[$i] === $d[$i + 1]) {
    echo '0'.PHP_EOL;
} else {
    echo ($d[$i + 1] - $d[$i]).PHP_EOL;
}
?>

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

int main(){
    string N;
    cin >> N;
    int cnt = 0;
    for(int i=0;i<N.size();i++){
        if(N[i]=='2'){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let n:u32 = read();

    for i in n..1000 {
        let s:Vec<char> = i.to_string().chars().collect();
        //debug!(s);
        if s[0] == s[1] && s[1] == s[2] {
            println!("{}", i);
            return ();
        }
    }

}


Measured memory_bytes: 4352
#include <stdio.h>

int main() {
	int N, A, B; scanf("%d%d%d",&N,&A,&B);
	int ans = N;
	for (int i = 0; i < N; i++) {
		int t; scanf("%d",&t);
		if (A <= t && t < B) ans--;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
			B[i]=sc.nextInt();
		}
		
		Queue<Integer> pq = new PriorityQueue<Integer>((i1,i2)->i2-i1);
		
		int C[][] =  new int[N][2];
		for(int i=0;i<N;i++) {
			C[i][0]=A[i];
			C[i][1]=B[i];
		}
		Arrays.sort(C,(c1,c2)->c1[0]-c2[0]);//Aの昇順に並んでいる
		
		long ans = 0;
		int j=0;
		for(int i=1;i<=M;i++) {
			while(j<N && C[j][0]<=i) {
				pq.offer(C[j][1]);
				j++;
			}
			if(!pq.isEmpty()) ans += pq.poll();
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 64716
//Weakness disgust me
#include<bits/stdc++.h>                   
#pragma GCC optimize("O3")
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i < (n); ++i)
#define repB(i, a, n)  for(int i = a; i <=(n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define vec(i, a)  for( auto i=a.begin();i != a.end(); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265358979
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;

const ll MOD = 1e9 + 7;
using namespace std;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ;return x ;}
#define in  freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define dark_lord in out 
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{    
    #ifndef ONLINE_JUDGE
    dark_lord
    #endif
    fast
    ll t=1;
    //cin>>t;
    while(t--)
    {    
    	string s,ans;
    	cin>>s;
    	ans=s.substr(0,3);
    	cout<<ans;

    }


    #ifndef ONLINE_JUDGE
	time
	#endif
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;

vector<int> a;
int n, k;

bool cut(int len){
	int res = 0;
	for (auto it: a){
		res += (it-1)/len;
	}
	return res<=k;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n>>k;
	a.resize(n);
	for (int i = 0; i < n; i++){
		cin>>a[i];
	}
	int l = 0, r = 1e9+5;
	while (r-l > 1){
		int mid = r + l; mid /= 2;
		if (cut(mid)){
			r = mid;
		}else{
			l = mid;
		}
	}
	cout<<r<<'\n';
	return 0;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,abs(n-k))<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> ypi(m);
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    ypi[i] = make_pair(y, make_pair(p, i + 1));
  }

  sort(all(ypi));
  vector<pair<string, string>> ans(m + 1);
  vector<int> number(100005, 1);
  rep(i, m) {
    string pre = "";
    string p;
    p = to_string(ypi[i].second.first);
    rep(j, 6   - p.size()) pre += "0";
    pre += p;
    string bk = "";
    string y;
    y = to_string(number[ypi[i].second.first]);
    number[ypi[i].second.first]++;
    rep(j, 6 - y.size()) bk += "0";
    bk += y;

    ans[ypi[i].second.second] = make_pair(pre, bk);
  }
  loop(i, 1, m + 1) { cout << ans[i].first << ans[i].second << endl; }

  return 0;
}


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


int main() {
    string S;
    cin >> S;

    for (int i = 0; i < S.size(); i += 2) {
        if (S[i] == 'h' && S[i + 1] ==  'i') {

        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 764
p = []

n,m = map(int,input().split())
a = list(map(int,input().split()))
for t in a:
  p.append([t,1])
for i in range(m):
  b,c = map(int,input().split())
  p.append([c,b])
p.sort(reverse = 1)

s = 0 
c = 0
for z in p:
  if c+z[1]<n:
    c += z[1]
    s += z[1]*z[0]
  else:
    s += (n-c)*z[0]
    break
print(s)
  

Measured memory_bytes: 34628
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#pragma GCC optimize ("O3")
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef long double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 188;
const int SIZE = SIZE2;
const LL p = 7 + 1e9;
const LL INF = 1LL << 61;
const long double EPS = 1e-7;
//ut N, M, K, L=0,R=1, H, W, Q, D, T;
ut N,A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
//LL A[SIZE][SIZE];
string s;
bool atob(LL a,LL b) {
	FOR(i, a, b) {
		if (s[i] == '#') {
			return false;
		}
		if (s[i+1] == '#') {
			i++;
		}
	
	}
	return true;
}
bool revable(LL a,LL b) {
	FOR(i, a, b+1) {
		if (i and s.size() != i + 1 and s[i] == s[i + 1] and s[i] == s[i - 1] and s[i] == '.') {
			return true;
		}
	}
	return false;
}
LL solve() {
	cin >> N >> A >> B >> C >> D >> s;
	A--;
	B--;
	C--;
	D--;
//	cout << atob(A, C) << " " << atob(B, D) << " " << endl;
	return atob(A, C) and atob(B, D) and (C < D or revable(B,D));
}
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	YesNo;
//	solve();
	//	cin >> N;
	return 0;
}


Measured memory_bytes: 592
import sys
from math import sqrt, floor

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def main():
    a, b, n = MI()

    if b - 1 <= n:
        print((a * (b - 1)) // b)
    else:
        print((a * n) // b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    ll r, d, x;
    cin >> r >> d >> x;
    ll ans = 0;
    ans = x;
    REP(i, 10) {
        ans = r*ans - d;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
s = input()
t = input()

def num_of_match(a,b):
    l = len(a)
    return sum([a[i] == b[i] for i in range(l)])


t_len = len(t)
nom_list = []
finish_flg = False
for i in range(len(s) - len(t) + 1):
    s_sub = s[i:i + t_len]
    nom = num_of_match(s_sub, t)
    num_mod = t_len - nom
    if num_mod == 0:
        print(0)
        finish_flg = True
        break
    else:
        nom_list.append(num_mod)

if not finish_flg:
    print(min(nom_list))



Measured memory_bytes: 9140
import math
a,b,x = map(float,input().split())

c = (2*b-(2*x)/(a*a))/a
d = (a*b*b)/(2*x)
if x/a >= a*b/2:
  result = math.degrees(math.atan(c))
else:
  result = math.degrees(math.atan(d))
print(result)

Measured memory_bytes: 3188
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let b:usize = read();
    let mut ans = 0;
    for i in a..=b {
        if i/10000 == i % 10 && (i / 1000)%10 == (i / 10)%10 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main()
{
	int a, n, i, j, k=2,m=0, flag = 0,cnt;
	int arr[50001] = { 0,0,1 }, sum[10000] = {0};

	for (a = 3; a <= 50000; a += 2)
	{
		for (i = 2; i <= sqrt(a); i++)
		{
			if (a%i == 0)
			{
				flag = 1;
				break;
			}
		}
		if (flag)
		{
			flag = 0;
		}
		else
		{
			arr[a] = 1;
		}
	}

	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}

		cnt = 0;
		for (i = 2; i<=n/2; i++)
		{
			if (arr[i] == 1 && arr[n - i] == 1)
			{
				++cnt;
			}
		}

		sum[m] = cnt;
		++m;
		
	}

	for (i = 0; i < m; i++)
	{
		printf("%d\n", sum[i]);
	}

	return 0;
}


Measured memory_bytes: 844
/* ITP1_9_D */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = br.readLine();
      int q = Integer.parseInt(br.readLine());

      for(int i = 0; i < q; i++){
        String[] order = br.readLine().split(" ");
        String operation = order[0];
        int a = Integer.parseInt(order[1]);
        int b = Integer.parseInt(order[2]) + 1;
        StringBuilder sb = new StringBuilder();

        switch(operation){
          case "print":
            sb.append(str.substring(a,b));
            System.out.println(sb);
            break;
          case "reverse":
            StringBuilder sub = new StringBuilder(str.substring(a, b));
            sb.append(str);
            sb.replace(a, b, sub.reverse().toString());
            str = sb.toString();
            break;
          case "replace":
            sb.append(str);
            sb.replace(a, b, order[3]);
            str = sb.toString();
            break;
          default:
            break;
        }
      }
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 25064
object Main {
  def binarySearch(arr: Array[Int], value: Int): Int = {
    var i = 0
    var j = arr.length
    var half = (i+j)/2
    if (arr.isEmpty) return 0
    while (i != half) {
      if (arr(half) >= value) {
        j = half
      } else {
        i = half
      }
      half = (i+j)/2
    }
    if (j-1 >= 0 && arr(j-1) >= value) j-1 else j
  }

  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val A = new Array[Int](N)
    val B = new Array[Int](N)
    for (i <- 0 until N) A(i) = sc.nextInt
    for (i <- 0 until N) B(i) = sc.nextInt

    var res = 0
    for (i <- (0 to 29).reverse) {
      val (higher, lower) = (1<<(i+1), 1<<i)
      for (j <- 0 until N) {
        A(j) = A(j) % higher
        B(j) = B(j) % higher
      }
      java.util.Arrays.sort(B)
      var loc_sum = 0
      for (k <- 0 until N) {
        if (lower-A(k) >= 0) {
          loc_sum += binarySearch(B, higher-A(k)) - binarySearch(B, lower-A(k))
        } else {
          loc_sum += binarySearch(B, higher-A(k))
          loc_sum += binarySearch(B, higher) - binarySearch(B, higher + lower - A(k))
        }
      }
      res += lower*(loc_sum&1)
    }

    println(res)
  }
}


Measured memory_bytes: 111768