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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

struct edge {
    int a, b, f, c;
};
const ll INF = 2e4;

int was[300];
vector<int> eds[300];
vector<edge> ed;
string st[300];
int n, m;
int s, t;

void add_edge(int a, int b, int c) {
    edge x;
    x.a = a, x.b = b, x.f = 0, x.c = c;
    eds[a].push_back(ed.size());
    ed.push_back(x);
    swap(x.a, x.b);
    x.c = 0;
    eds[b].push_back(ed.size());
    ed.push_back(x);
}


int dfs1(int v, int fl) {
    if (v == t)
        return fl;
    was[v] = 1;
    for (int e: eds[v]) {
        int u = ed[e].b;
        int go = ed[e].c - ed[e].f;
        if (go && !was[u]) {
            int x = dfs1(u, min(fl, go));
            if (x) {
                ed[e].f += x;
                ed[e ^ 1].f -= x;
                return x;
            }
        }
    }
    return 0;
}

int flow() {
    memset(was, 0, sizeof(was[0]) * (t + 1));
    return dfs1(s, INF);
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> st[i];
    s = n + m;
    t = s + 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (st[i][j] == 'S') {
                add_edge(s, i, INF);
                add_edge(s, j + n, INF);
            }
            else if (st[i][j] == 'T') {
                add_edge(i, t, INF);
                add_edge(j + n, t, INF);
            }
            else if (st[i][j] == 'o') {
                add_edge(i, j + n, 1);
                add_edge(j + n, i, 1);
            }
        }
    }
    ll ans = 0;
    while (true) {
        ll x = flow();
        ans += x;
        if (!x)
            break;
    }
    if (ans >= INF)
        cout << -1 << "\n";
    else
        cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 1452
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

int N;
int A;
int B;

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

  cin >> N >> A >> B;
  int a=0, b=0, c=0;
  REP(i, N) {
    int d; cin >> d;
    if(d <= A) a++;
    else if(B < d) c++;
    else b++;
  }

  cout << min({a, b, c}) << endl;
}


Measured memory_bytes: 256
// #ifdef DEBUG
// #define _GLIBCXX_DEBUG
// #endif
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define int long long

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

template<typename A,typename B>
ostream &operator<<(ostream&os,const pair<A,B>& p){
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

typedef complex<double> point;

// template<typename T,std::size_t N>
// struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
// template<typename T>
// struct _v_traits<T,1> {using type = std::vector<T>;};
// template<typename T,std::size_t N=1>
// using vec = typename _v_traits<T,N>::type;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

    while(true){
        int h,w;
        cin >> h >> w;
        if(h == 0 and w == 0) return 0;

        int sz = h*h + w*w;
        map<int,pair<int,int> > size_to;

        pair<int,int> opt;
        int opt_sz2 = 10000000;
        for(int nh=1;nh<=150;nh++){
            for(int nw=nh+1;nw<=150;nw++){
                int sz2 = (nh*nh+nw*nw);
                bool is_ok = ((sz < sz2) or
                              ((sz == sz2) and (h < nh)));
                if(is_ok and sz2 < opt_sz2){
                    opt_sz2 = sz2;
                    opt = make_pair(nh,nw);
                }
            }
        }
        cout << opt.first << " " << opt.second << endl;

    }
    return 0;
}

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

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int extgcd(int a, int b, int &x, int &y) {
  int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

int main() {
    while(true){
        int a, b, d;cin >> a >> b >> d;
        if(a == 0) break;
        int g = gcd(a, b);
        a /= g;b /= g;d /= g;

        int x, y;
        extgcd(a, b, x, y);
        
        int ans_x = d*x;int ans_y = d*y;
        x *= d;
        y *= d;
        //cout << ans_x << " " << ans_y << endl;

        for(int k=1;;k++){
            int cx = x+k*b;
            int cy = y-k*a;
            if(abs(cx)+abs(cy) > abs(ans_x)+abs(ans_y)){
                break;
            }else if(abs(cx)+abs(cy) == abs(ans_x)+abs(ans_y)){
                if(abs(cx)*a+abs(cy)*b > abs(ans_x)*a+abs(ans_y)*b){
                    break;
                }else{
                    ans_x = cx;
                    ans_y = cy;
                }
            }else{
                ans_x = cx;
                ans_y = cy;
            }
        }
        for(int k=-1;;k--){
            int cx = x+k*b;
            int cy = y-k*a;
            if(abs(cx)+abs(cy) > abs(ans_x)+abs(ans_y)){
                break;
            }else if(abs(cx)+abs(cy) == abs(ans_x)+abs(ans_y)){
                if(abs(cx)*a+abs(cy)*b > abs(ans_x)*a+abs(ans_y)*b){
                    break;
                }else{
                    ans_x = cx;
                    ans_y = cy;
                }
            }else{
                ans_x = cx;
                ans_y = cy;
            }
        }
        cout << abs(ans_x) << " " << abs(ans_y) << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  if (a % 2 == b % 2) {
    cout << abs(a - b) / 2 << '\n';
  } else {
    if (a > b) swap(a, b);
    cout << min(a - 1, n - b) + 1 + (b - a) / 2;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
h,w=map(int,input().split())
li=[]
for i in range(h):
  li.append(list(input()))
ll=[]
for i in li:
  if "#" in i:
    ll.append(i)
ll=np.array(ll).T.tolist()

out=[]
for i in ll:
  if "#" in i:
    out.append(i)
out=np.array(out).T.tolist()
for i in out:
  for j in i:
    print(j,end="")
  print()

Measured memory_bytes: 27536
N, X, Y = [int(i) for i in input().split()]

p = []

for i in range(1, N):
    for j in range(i+1, N+1):
        if j<=X:
            p.append(j-i)
        elif j<=Y:
            if i <= X:
                p.append(min(j-i, X-i+1+Y-j))
            else:
                p.append(min(j-i, i-X+1+Y-j))
        else:
            if i <= X:
                p.append(j-i-(Y-X)+1)
            elif i <=Y:
                p.append(min(j-i, i-X+1+j-Y))
            else:
                p.append(j-i)
    
import collections
c = collections.Counter(p)
for k in range(1,N):
    print(c[k])
            

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

int main()
{
    string arr;
    cin>>arr;
    int counter=0;
    for(int i=0,j=arr.size()-1;i<j;i++,j--)
    {
        if(arr[i]!=arr[j])counter++;
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 256
h,w = gets.split.map &:to_i
n = gets.to_i
a = gets.split.map &:to_i

c = Array.new(h){Array.new(w,0)}

x = 0
y = 0

a.each_with_index do |a, i|
  a.times do
    c[y][x] = i + 1
    x += 1
    if x >= w
      x = 0
      y += 1
    end
  end
end
h.times do |h|
  next if h.even?
  c[h].reverse!
end

h.times do |h|
  puts c[h].join(" ")
end


Measured memory_bytes: 2428
n,x=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(n-1):
    q=a[i+1]
    if a[i]>x:
        count+=a[i]-x
        a[i]=x
    if a[i]+a[i+1]>x:
        count+=a[i]+a[i+1]-x
        a[i+1]=q-(a[i]+a[i+1]-x)
print(count)

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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int find(char str[]){

    /* your task */
long long key,i,h;
key =getKey(str);
for(i=0;;i++){
  h=(h1(key)+i*h2(key))%M;
  if(strcmp(H[h],str)==0)return 1;
  else if(strlen(H[h])==0)return 0;
}
return 0;
}

int insert(char str[]){
    /* your task */
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
      h=(h1(key)+i*h2(key))%M;
      if(strcmp(H[h],str)==0)return 1;
      else if(strlen(H[h])==0){
        strcpy(H[h],str);
        return 0;
      }
    }
    return 0;
    }

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15460
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0,a,x,m=1000;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>a;
		x-=a;
		ans++;
		if(a<m)
			m=a;
	}
	if(x>0)
	ans+=x/m;
	cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String input = br.readLine();
    String[] split = input.split(" ");
    int n = Integer.parseInt(split[0]);
     int m = Integer.parseInt(split[1]);
    
    if(m==n) {
      System.out.println("Yes");
    }
    else {
       System.out.println("No");
    }
  }
}

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

bool is_acgt(char c){
	return c=='A'||c=='C'||c=='G'||c=='T';
}

int main()
{
	string s;
	int mx{0},cnt{0};
	cin>>s;
	for(auto x:s){
		if(is_acgt(x))
			mx=max(mx,++cnt);
		else
			cnt=0;
	}
	cout<<mx;
	cin.get();
	cin.get();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <utility>
#include <cmath>

int resolve(int digits, const std::list<std::pair<int, int> >& constraints) {
    std::vector<int> vals(digits, 0); 
    std::vector<int> binded(digits, 0); 

    for (const auto& p: constraints) {
        if (p.first == 1 && p.second == 0 && digits == 1) { 
            return 0;
        }
        else if (p.first == 1 && p.second == 0) { 
            return -1;
        }
        else if (!binded[p.first - 1]) {
            binded[p.first - 1] = 1;
            vals[p.first - 1] = p.second;
        }
        else if (vals[p.first - 1] == p.second) {
            continue;
        }
        else {
            return -1;
        }
    }
    if (!vals[0] && digits > 1) {
        vals[0] = 1;
    }

    int res = 0;
    for (int i = digits, j = 0; i > 0; -- i, ++j) {
        res += vals[j] * pow(10, i - 1);
    }

    return res;
}

int main(int argc, char const* argv[])
{
    std::string str;

    getline(std::cin, str, ' ');
    int n = std::stoi(str);

    getline(std::cin, str);
    int m = std::stoi(str);

    std::list<std::pair<int, int> > sc_list;
    std::string line;
    std::string elem;
    while ( getline(std::cin, line) ) {
        std::stringstream ss(line);
        int s, c;
        getline(ss, elem, ' ');
        s = std::stoi(elem);

        getline(ss, elem);
        c = std::stoi(elem);

        sc_list.push_back({s, c});
    }

    std::cout << resolve(n, sc_list) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = LMIIS()
    H = LMIIS()
    if N <= K :
        print(0)
        return
    H.sort(reverse=True)
    print(sum(H[K:]))
    return

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 82256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N, M;
    vector<pair<int, int>> v;
    cin >> N >> M;
    
    for(int i = 1; i*i <= M; ++i){
        if (M % i == 0){
            v.push_back(make_pair(i, M/i));
            v.push_back(make_pair(M/i, i));
        }
    }
    sort(v.begin(), v.end());
    int k = lower_bound(v.begin(), v.end(), make_pair(N, 0)) - v.begin();
    cout << v[k].second << endl;
}


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


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Time()	cerr <<'\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define SZ(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define fo(i,k,n) for(ll (i)=(k);(i)<(n);(i)++) 
#define ar array
// no change 

const ll MOD = 1e9+7;   // it is an prime...

template<typename T,typename L>
T power(T a, L b);				// to find reverse modulo its power(a,MOD-2);
template < typename T ,typename L> 
L coefficient(T n, T k);  // computing nCk

//const int MxN = 1e9+5;



void solve(){
	int n; 
	cin >> n;
	ll  ans ;
	cin >> ans;
	
	vi v(n);
	v[0] = ans;
	for(int i = 1;i<n;i++){
		cin >> v[i];
		ans ^=v[i];
	}
	
	debug() << imie(ans);
	for(int i = 0;i< n;i++){
		cout << (ans^v[i]) << " ";
	}
	








}
int main() {	
	FASTER;
	int T = 1;
	//cin >> T;		//cmt if one test case
	while(T--)solve();
}


template<typename T,typename L>
T power(T a, L b){
	
	T result = 1;
	while(b){
		if(b&1) result = (result% MOD * a%MOD) % MOD;
	   	a = (a%MOD * a%MOD) % MOD;
   		b/=2;	   
	}
	return result;
}

template < typename T ,typename L> 
L coefficient(T n, T k){  // computing nCk
	k = min(k,(n-k));
	L res = 1;
	for(T i = 0; i< k;i++){
		res *= (n-i);
		res /= (i+1);

	}
	return res;
}


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

int n, a[100], ans, idx;

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

	sort(a, a+n);

	while(ans%10==0){
		if(a[idx]%10==0){
			idx++;
		}
		else{
			ans -= a[idx];
			break;
		}
		
		if(idx==n){
			ans = 0;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <random>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1, 0);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(26 + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        ans -= c[t[i]] * (i - last[t[i]]) * (i - last[t[i]] - 1) / 2;
        last[t[i]] = i;
    }

    for (int i = 1; i <= 26; i++)
    {

        ans -= c[i] * (d - last[i] + 1) * (d - last[i]) / 2;
    }

    return ans;
}

int main(void)
{
    random_device seed_gen;
    mt19937 rand(seed_gen());
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    double BestScore = scoring(BestT);
    double score;

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1, 1);

    double T0 = 1e6;
    double T1 = 1e2;
    double TL = 1980;

    ll count = 0;

    while (1)
    {
        ll msec;

        msec = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        score = scoring(t);

        double p = exp((score - BestScore) / T);

        if (p > 0.5)
        {
            BestT = t;
            BestScore = score;
        }

        count++;
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }
}


Measured memory_bytes: 4500
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> s;
    rep(i,s.size()){
        if(i%2){
            if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
                continue;
            no;
            return 0;
        }
        else{
            if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D' )continue;
            no;
            return 0;
        }
    }
    yes;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
const int inf = 1e9+5;
int op(int a,int b){
  return max(a,b);
}
int e(){
  return -inf;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,q;
  cin >> n >> q;
  vector<int> a(n+1,-inf);
  for(int i = 1; i <= n; ++i) cin >> a[i];
  segtree<int,op,e> seg(a);
  while(q--){
    int t,l,r,pos,val;
    cin >> t;
    if(t == 1){
      cin >> pos >> val;
      seg.set(pos,val);
    }
    else if(t == 2){
      cin >> l >> r;
      cout << seg.prod(l,r+1) << '\n';
    }
    else{
      cin >> pos >> val;
      int ans = seg.max_right(pos,[&val](int x)->bool{return x < val;});
      cout << ans << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 6112
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pii = pair<int, int>;

int W, H, R;

const int MAXN = 1024;
char M[MAXN][MAXN];

const int MAXA = MAXN * MAXN;
int  COST[MAXA];

int calcIndex(int x, int y) { return x + y * W; }
int toX(int index) { return index % W; }
int toY(int index) { return index / W; }

int main()
{
    cin >> H >> W;

    rep(y, H) { cin >> M[y]; M[y][W] = 0; }

    priority_queue< pii, vector<pii>, greater<pii> > Q;

    fill(COST, COST + MAXA, -1);

    rep(y, H)
    rep(x, W)
    {
        if (M[y][x] != '#') { continue; }

        const int index = calcIndex(x, y);

        Q.push(pii(0, index));
        COST[index] = 0;
    }

    while(!Q.empty())
    {
        const auto current = Q.top();
        Q.pop();

        const int x = toX(current.second);
        const int y = toY(current.second);

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

        rep(i, 4)
        {
            const int xx = x + dx[i];
            const int yy = y + dy[i];

            if (xx < 0 || W <= xx) { continue; }
            if (yy < 0 || H <= yy) { continue; }

            const int index = calcIndex(xx, yy);
            if (COST[index] != -1) { continue; }

            COST[index] = current.first + 1;
            Q.push(pii(COST[index], index));
        }
    }

    int ans = 0;

    rep(i, MAXA)
    {
        ans = max(ans, COST[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15340
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	ans := 0
	for i := 1; i <= N; i++ {
		if i%3 != 0 && i%5 != 0 {
			ans += i
		}
	}

	fmt.Fprintln(wtr, ans)
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;

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

	int n, l;
	string a[101];
	cin >> n >> l;
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);
	for(int i=0; i<n; i++) {
		cout << a[i];
	}
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define int unsigned long long
#define endl '\n'
using namespace std;
typedef long long ll;

signed main() 
{
	int n;
	cin >> n;
	pair <int, int> p[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> p[i].second >> p[i].first;
	sort(p + 1, p + n + 1);
	
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += p[i].second;
		if (sum > p[i].first) {cout << "No"; return 0;}
	}
	cout << "Yes";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define RG register
#define ll long long
#define rhl (1000000007)

using namespace std;

int f[5005][5005],n,m,ans;
char s[5005];

int main(){
  cin>>n,scanf("%s",s),m=strlen(s),f[0][0]=ans=1;
  for (RG int i=0;i<n;++i)
    for (RG int j=0;j<n;++j)
      (f[i+1][max(0,j-1)]+=f[i][j])%=rhl,(f[i+1][j+1]+=2LL*f[i][j])%=rhl;
  for (RG int i=1;i<=m;++i) ans=1LL*ans*500000004%rhl;
  cout<<1LL*ans*f[n][m]%rhl; return 0;
}


Measured memory_bytes: 98048
import java.util.Scanner;
public class Main {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       String S = sc.nextLine();
       if (S.toUpperCase() == S) {
         System.out.println("A");
       } else if (S.toLowerCase() == S) {
         System.out.println("a");
       }
   }
}

Measured memory_bytes: 35828
#include <iostream>

#define INF 1000000007

using namespace std;

int main()
{
    int n, T;
    cin >> n >> T;
    int min = INF;

    for (int i=0; i<n; i++){
        int c, t;
        cin >> c >> t;
        if (t<=T && c<min) min = c;
    }
    if (min==INF){
        cout << "TLE" << endl;
    }
    else{
        cout << min << endl;
    }
}


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

int main() {
    string s,t;cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    
    if(s < t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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

int main(){	
	int x, y;
	cin >> x >> y;
	while(!(x == 0 && y == 0)){
		if (x < y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
}


Measured memory_bytes: 3056
program ms
  integer :: N
  integer,allocatable :: H(:)

  integer :: i,zti
  logical :: ok 

  read(*,*) N
  allocate(H(N))
  read(*,*) H
  ok=.true.
  if(N.gt.1) then
     zti=H(1)
     do i=2,N
        if(H(i).gt.(zti+1)) then
           zti=H(i)-1
        elseif(H(i).lt.zti) then
           ok=.false.
        else
        endif
     enddo
  endif

  if(ok) then
     write(*,'(a)') 'Yes'
  else
     write(*,'(a)') 'No'
  endif

end program ms



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  vector<int> ans;
  string s;
  cin>>s;
  REP(i,s.size()){
    if(s[i]=='0'){
      ans.push_back(0);
    }else if(s[i]=='1'){
      ans.push_back(1);
    }else{
      if(ans.size()>0){
        ans.pop_back();
      }
    }
  }
  
  REP(i,ans.size()){
    cout<<ans[i];
  }
  return 0;
}



Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

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

S = sum(A)
L = []
for s in range(1, S+1):
    if s > math.sqrt(S) + 1:
        break
    if S % s == 0:
        L.append(S//s)
        L.append(s)
L.sort(reverse = True)

for l in L:
    T = [a%l for a in A]
    T.sort()
    ans = False
    R = []
    r = 0
    for t in T:
        r += t
        R.append(r)
    #print(l, R)
    for i in range(N):
        #print(i, R[-1])
        if R[i] > K:
            break
        if R[N-1] == l*(N-i-1):
            ans = True
            break
        
    if ans:
        print(l)
        break


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll A[N];
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        if(i==0) sum += abs(A[i]);
        else{
            sum += abs(A[i]-A[i-1]);
            if(i==N-1) sum += abs(A[i]);
        }
    }
    ll out = 0;
    rep(i,N){
        if(i==0) out = sum-(abs(A[i]-0)+abs(A[i]-A[i+1]))+abs(0-A[i+1]);
        else if(i<N-1) out = sum-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1]))+abs(A[i-1]-A[i+1]);
        else out = sum-(abs(A[i]-A[i-1])+abs(A[i]-0))+abs(A[i-1]-0);
        cout << out << endl;
    }
    return 0;
}


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

int main(){

  vector<pair<int,pair<int,int> > > s;

  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      s.push_back(make_pair(i*i+j*j,make_pair(i,j)));
    }
  }
  sort(s.begin(),s.end());
  
  while(true){
    int h,w;
    cin>>h>>w;

    if(h==0&&w==0)break;

    int total=w*w+h*h;
    int tmp=total;
    int ans_h=0;
    int ans_w=0;

    for(int i=0;i<=150*150;i++){
     

	if(h==s[i].second.first&&w==s[i].second.second){
	  cout<<s[i+1].second.first<<" "<<s[i+1].second.second<<endl;
	  break;
	}
    }
  }
  return 0;
}

Measured memory_bytes: 3248
#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(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi ans(n,0);
    rep(i,n-1) {
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }
    rep(i,n) cout << ans[i] << endl;
}


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

using namespace std;
typedef long long ll;
//#define int ll
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FOR(i, a, b) for (int i = a; i < b; ++i)

typedef pair<int, int> pii;
typedef pair<double, int> pdi;

const int INF = 1000 * 1000 * 1000 + 10;
const ll INFLL = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;

    vector<int> a(n);
    for (int &t : a)
        cin >> t;

    int cnt = 0;

    for (int i = 1; i < n - 1; ++i) {
        vector<int> b = {a[i - 1], a[i], a[i + 1]};
        sort(ALL(b));

        if (a[i] == b[1])
            cnt++;
    }

    cout << cnt;
}

Measured memory_bytes: 256
local children={}
for s,L,M,R in io.read():gmatch"(()R+()L+())"do
    for i=L,M-2 do
        table.insert(children,0)
    end
    local left=M-L
    local right=R-M
    table.insert(children, (left+1)//2+right//2)
    table.insert(children, left//2+(right+1)//2)
    for i=M+1,R-1 do
        table.insert(children,0)
    end
end
print(table.concat(children," "))

Measured memory_bytes: 3148
import sys
sys.setrecursionlimit(10**5)
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))


def egcd(a: int, b: int):
    """
    A solution of ax+by=gcd(a,b). Returns
    (gcd(a,b), (x, y)).
    """
    if a == 0:
        return b, 0, 1
    else:
        g, x, y = egcd(b % a, a)
        return g, y - (b // a) * x, x


def modinv(a: int, m: int):
    """
    Returns a^{-1} modulo m.
    """
    g, x, y = egcd(a, m)
    if g > 1:
        raise Exception('{}^(-1) mod {} does not exist.'.format(a, m))
    else:
        return x % m


def modpow(a: int, n: int, m: int):
    """
    Returns a^n mod m. (-inf < n < inf)
    """
    if a in [-1, 0, 1]:
        if a == -1:
            return 1 if n & 1 == 0 else m - 1
        else:
            return a

    x, k = (a % m, n) if n >= 0 else (modinv(a, m), -n)

    ret = 1
    while k > 0:
        if k & 1 == 1:
            ret = ret * x % m
        x *= x
        k = k >> 1

    return ret


mod = 998244353

N, M, K = geta(int)

if M == 1:
    print(0 if K < N - 1 else 1)
    exit()

a = M * modpow(M - 1, N - 1, mod) % mod
ans, k = a, 1
mi = modinv(M - 1, mod)

for k in range(1, K + 1):
    a = a * (N - k) * mi * modinv(k, mod) % mod
    ans = (ans + a) % mod

print(ans)


Measured memory_bytes: 88904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,t=0;
    scanf("%d%d%d",&a,&b,&c);
    if(a==7) t++;
    if(b==7) t++;
    if(c==7) t++;
    if(t==1)
    printf("YES");
    else
    printf("NO");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define MIN(a,b) ((a) > (b) ? (b) : (a))
#define ABS(a) ((a) > 0 ? (a) : -(a))
using namespace std;
int main()
{
    int n, a, b, c;
    int l[10];
    scanf("%d %d %d %d", &n, &a, &b, &c);
    for (int i = 0; i < n; i++) {
	scanf("%d", l + i);
    }
    std::sort(l, l+n);
    int ans = 1 << 30;
    do {
	for (int i = 1; i <= n; i++) {
	    for (int j = i+1; j <= n; j++) {
		for (int k = j + 1; k <= n; k++) {
		    int aa = 0;
		    int bb = 0;
		    int cc = 0;
		    int sum = 0;
		    for (int p = 0; p < i; p++) {
			aa += l[p];
		    }
		    sum += ABS(aa - a) + (i-1) * 10;
		    for (int p = i; p < j; p++) {
			bb += l[p];
		    }
		    sum += ABS(bb - b) + (j-i-1) * 10;
		    for (int p = j; p < k; p++) {
			cc += l[p];
		    }
		    sum += ABS(cc - c) + (k-j-1) * 10;
		    ans = MIN(sum, ans);
		}
	    }
	}
    } while (std::next_permutation(l, l+n));

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from math import log2

ROUND = 10 ** 5
LOG = 33#int(log2(ROUND))

def main():
    S = input()
    N = len(S)
    to = []
    for _ in range(LOG):
        l = [0] * N
        to.append(l)
    
    for i in range(N):
        to[0][i] = i + 1 if S[i] == "R" else i - 1
    
    for i in range(1, LOG):
        for j in range(N):
            to[i][j] = to[i - 1][to[i - 1][j]]

    a = []
    for i in range(LOG):
        if ROUND>>i & 1:
            a.append(i)

    ans = [0] * N
    for j in range(N):
        now = j
        for i in a:
            now = to[i][now]
        ans[now] += 1

    L = [str(i) for i in ans]
    print(" ".join(L))
    return

if __name__ == '__main__':
    main()

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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n), bs(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	for (auto &b : bs)
	{
		cin >> b;
	}
	if (accumulate(as.begin(), as.end(), int64_t(0)) < accumulate(bs.begin(), bs.end(), int64_t(0)))
	{
		cout << -1 << endl;
		return 0;
	}
	vector<int64_t> ds(n);
	for (int i = 0; i < n; i++)
	{
		ds[i] = as[i] - bs[i];
	}
	sort(ds.begin(), ds.end());
	int64_t ans = 0;
	for (int64_t i = 0, j = n - 1, tmp = 0; i <= j; i++)
	{
		if (0 <= ds[i])
		{
			break;
		}
		while (i < j && 0 <= ds[j] && tmp < -ds[i])
		{
			tmp += ds[j];
			ans++;
			j--;
		}
		if (-ds[i] <= tmp)
		{
			tmp += ds[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		int maxCount = 0;
		int count = 0;
		for (char c : s.toCharArray()) {
			if (c == 'A'
					|| c == 'T'
					|| c == 'C'
					|| c == 'G') {
				count++;
			} else {
				if (maxCount < count) {
					maxCount = count;
					count = 0;
				}
			}
		}
		if (maxCount < count) {
			maxCount = count;
			count = 0;
		}
		System.out.println(maxCount);


	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep2(i, N, M) for (int i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq ;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(a, max(b, c)) - min(a,min( b, c));

	return 0;
}



Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())

        if N % 2 == 0:
            print(1 / 2)
        else:
            print((N // 2 + 1) / N)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38384
#include<iostream>
#include<set>
#include<vector>

using namespace std;

int ANS = 0;
int N, M;
// vector<vector<int>>* GRAPH;

void solve(int cur, set<int> traversed, vector<vector<int>>& GRAPH) {
    if (traversed.count(cur) != 0) {
        return;
    } else {
        traversed.insert(cur);
    }

    if (traversed.size() == N) {
        ANS++;
        return;
    }

    for (int i = 0; i < N; ++i) {
        if (GRAPH[cur][i] == 1) {
            // is connected
            solve(i, traversed, GRAPH);
        }
    }

}

int main(void) {

    // init
    cin  >> N >> M;
    // GRAPH = new vector<vector<int>>(N, vector<int>(N, -1));
    vector<vector<int>> GRAPH(N, vector<int>(N,-1));

    // Create Graph
    int a, b;
    for (int i = 0; i < M; ++i) {
        cin >> a >> b;
        GRAPH[a-1][b-1] = 1;
        GRAPH[b-1][a-1] = 1;
    }

    // dfs
    auto traversed = set<int>();
    solve(0, traversed, GRAPH);

    cout << ANS << endl;

// 

return 0;

}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll X, Y;
    cin >> X >> Y;
    ll now = X;
    int ans = 0;
    while(now <= Y) {
        now *= 2;
        ans++;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

int main(){
    int n,m;    cin>>n>>m;
    int food[m+1]={0};

    for(int i=0;i<n;i++){
        int k;  cin>>k;
        for(int j=0;j<k;j++){
            int a;  cin>>a;
            food[a]++;
        }
    }

    int ans=0;

    for(int i=1;i<=m;i++){
        if(food[i]==n)ans++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *   created: 09 June 2019  14:03:36
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

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

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		string s;
		cin>>s;
		rep(i,1,s.size()){
			if(s[i]==s[i-1]){
				cout<<"Bad";
				return 0;
			}
		}
		cout<<"Good";
	}	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)
 
 
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
p = 10**9 + 7
 
 
xsum = 0
for i in range(n-1):
    xsum = (xsum + (x[i+1] - x[i]) * (i+1) * (n-i-1)) % p
 
ysum = 0
for j in range(m-1):
    ysum = (ysum + (y[j+1] - y[j]) * (j+1) * (m-j-1)) % p
 
 
ans = (xsum * ysum) % p
print(ans)

Measured memory_bytes: 84196
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0
for i in range(n):
	if a[i] >= b[i]:
		ans += b[i]
	else:
		ans += a[i]
		x = b[i] -a[i]
		if x >= a[i+1]:
			ans += a[i+1]
			a[i+1] = 0
		else:
			ans += x
			a[i+1] = a[i+1] -x
print(ans)

Measured memory_bytes: 19116
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	d := int(s[len(s)-1] - '0')
	switch d {
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	default:
		fmt.Println("hon")
	}
}


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

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

    vector<int> v = {};
    int n = 0;

    cin >> n;
    int i = 0;
    int t = 0;

    while (i < n && cin >> t)
    {
        v.push_back(t);
        ++i;
    }

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

    cout << v.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;

ll k;
ll a[100000];

ll ch(ll num){
    for(int i = 0;i < k;i++)num = num / a[i] * a[i];
    return num;
}

int main(void){
    cin >> k; for(int i = 0;i < k;i++)cin >> a[i];
    ll lb = 1;
    ll rb = 100000000000000;
    ll mid;
    ll temp = 0;
    while(rb - lb > 1){
        mid = (lb + rb)/2;
        if(ch(mid) > 2)rb = mid;
        if(ch(mid) < 2)lb = mid;
        if(ch(mid) == 2){temp = mid; break;}
    }
    if(temp == 0)printf("-1\n");
    else{
        lb = 1;
        ll MIN = temp;
        while(MIN - lb > 1){
            mid = (lb + MIN)/2;
            if(ch(mid) == 2)MIN = mid;
            else lb = mid;
        }
        rb = 100000000000000;
        ll MAX = temp;
        while(rb - MAX > 1){
            mid =(MAX + rb)/2;
            if(ch(mid) == 2)MAX = mid;
            else rb = mid;
        }
        printf("%lld %lld\n", MIN, MAX);
    }
	return 0;
}

Measured memory_bytes: 1024