akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int n;
	cin >> n;
	vector<int>	V(n);
	rep(i, n)
		cin >> V.at(i);
	sort(V.begin(), V.end());
	int i;
	int ans;

	i = 0;
	ans = 0;
	while (i < n)
	{
		int a;
		int	cnt;

		a = V.at(i);
		cnt = 1;
		i++;
		while (i < n && V.at(i) == a)
		{
			i++;
			cnt++;
		}
		if (cnt % 2)
			ans++;
	}
	cout << ans << endl;
}
// END

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
//const ll MOD = 1e9+7;
const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e6;
mint fac[MAX_N+1];

void init(){
    fac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    init();
    mint m = M, ans = 0;
    rep2(i, 0, K){
        ans += comb(N-1, i)*(m-1).pow(N-i-1)*m;
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 11452
#include <vector> 
#include <queue>
#include <map>
#include <set>
#include <utility> //Pair
#include <algorithm>
#include <sstream> // istringstream>> ostring stream<<
#include <iostream>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (4) << f << endl; Prints x.xxxx
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <limits>
using namespace std;

//M lazy ;)
typedef long long ll;
typedef vector <int> vi;
typedef pair< int ,int > pii;
typedef istringstream iss;
typedef ostringstream oss;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(int i=0;i<n;++i)
#define fu(i,a,n) for(int i=a;i<n;++i)
#define fd(i,n,a) for(int i=n;i>=a;--i)
#define all(a)  a.begin(),a.end()
#define ESP (1e-9)

#define mems(s, n) memset(s, n, sizeof(s))
#define gi(n) scanf("%d",&n)
#define sii(n) scanf("%lld",&n)
#define gl(n) cin >> n
#define pi(n) printf("%d",n)
#define pll(n) printf("%lld",n)
#define ps printf(" ")
#define pn printf("\n")
#define dg(n,s); printf("%s %d",s,n)
#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()
#define MOD 100000007

template < class T > inline T max_(T a,T b) {return a > b ? a : b ;}
template < class T > inline T min_(T a,T b) {return a < b ? a : b ;}
template < class T > inline T gcd(T a,T b) {if(a < 0) return gcd(-a,b); if(b < 0)return gcd(a,-b); return (b == 0) ? a : gcd(b ,a % b);}
template < class T > inline T lcm(T a,T b) {if(a < 0) return lcm(-a,b); if(b < 0)return lcm(a,-b); return a * (b / gcd(a , b));}

#define L1 1000000000000LL
int one[1010];
int two[1010];
int L[1010][1010];
vector < int > ans;

void ip(ll &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {negative = true;
        c = getchar();}
    for (; (c>47 && c<58); c=getchar())
         number = number *10 + c - 48;
    if (negative) number *= -1;
}



    int main() {
        ll a, b, c;
        ip(a), ip(b), ip(c);
        if(abs(a-b)> abs(a-c)){
            cout<<"B";
        }
        else
            cout<<"A";
        return 0;
    }


Measured memory_bytes: 256
n,W=map(int,input().split())
wt=[0]*n
val=[0]*n
for x in range(n):
    va,wei=map(int,input().split())
    wt[x]=wei
    val[x]=va
    
def knapsack(n,W,wt,val):
    memo=[0]*(W+1)
    for w in range(1,W+1):
        for i in range(n):
            if wt[i]<=w:
                memo[w]=max(memo[w-wt[i]]+val[i],memo[w])                
    return memo[W]
print(knapsack(n,W,wt,val))


Measured memory_bytes: 5916
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#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 ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
    int A , B;
    cin >> A >> B;

    int ans = max( max(A+B,A-B), A*B);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<int,P> PP;

vector<PP> v;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main()
{
	
	int k,x;
	vector<int> v;
	cin >> k >> x;
	for(int ans = x -k + 1;ans<x+k;ans++){
		if(ans < -1000000 || ans > 1000000) continue;
		v.push_back(ans);
	}
	rep(i,v.size() - 1){
		cout << v[i] << " ";
	}
	cout << v[v.size() - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const int MAX = 2e5+5;
int N; ll K, A[MAX], F[MAX], SumA[MAX];
ll getCount(ll x) {
  ll cnt = 0LL;
  for(int i = 1; i <= N; ++i) {
    ll diff = A[i]*F[i]-x;
    if(diff <= 0) continue;
    cnt += (diff+F[i]-1)/F[i];
  }
  return cnt;
}
int main() {
  scanf("%d %ld", &N, &K);
  for(int i = 1; i <= N; ++i) scanf("%ld", &A[i]);
  for(int i = 1; i <= N; ++i) scanf("%ld", &F[i]);
  sort(A+1, A+N+1);
  sort(F+1, F+N+1, greater<>());
  ll l = -1, r = 1e12+1;
  while(r-l > 1) {
    ll m = (l+r)/2;
    //完食時間の最大値をm秒にするのに必要な修行回数
    if(getCount(m) <= K) r = m;
    else l = m;
  }
  printf("%ld\n", r);
}

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

double memo[100001];

double dfs(int i, int n, double p)
{
	if(i==1 || n-50==i) return p;
	return p+(1-p)*memo[i-1]+p*dfs(i-1,n,p/2);
}

int main()
{
	cout << setiosflags(ios::fixed) << setprecision(10);
	memo[1]=1.0;
	for(int i=1; i<=100000; i++)
		memo[i]=dfs(i,i,1.0);
		
	int N;
	while(cin >> N,N)
	{
		cout << memo[N] << endl;
	}
}

Measured memory_bytes: 1400
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean[] used = new boolean[26];
        String ans = "";
        for (int i = 0; i < s.length(); i++) {
            for (int j = s.charAt(i) - 'a' + 1; j < 26; j++) {
                if(!used[j]){
                    if(i != 0) ans = s.substring(0, i) + (char)(j + 'a');
                    else ans = String.valueOf((char)(j + 'a'));
                    break;
                }
            }
            used[s.charAt(i) - 'a'] = true;
        }
        for (int j = 0; j < 26; j++) {
            if(!used[j]){
                ans = s + String.valueOf((char)(j + 'a'));
                break;
            }
        }

        if(ans.equals("")) System.out.println(-1);
        else System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	int n,k;
	cin >> n >> k;
	vector <int> ans(n,0);
	for(int i =0; i< k;i++) {
		int d;
		cin >> d;
		int a[d];
		for(int j =0; j <d ; j ++) {
			cin >> a[j];
			ans[a[j]-1] = 1;
		}
	}
	int count =0;
	for(int i =0;i < n; i++) {
		if(ans[i] ==0) count++;
	}
	cout << count <<endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
bool used[100001];
vector<vector<int>> e;

void extend_path(vector<int>& path){
	bool f = false;
	while(!f){
		f = true;
		int t = path.back();
		for(int i = 0; i < e[t].size(); i++){
			if(used[e[t][i]] == false){
				f = false;
				path.emplace_back(e[t][i]);
				used[e[t][i]] = true;
				break;
			}
		}
	}
}

int main(){
	int n, m;
	cin >> n >> m;
	e = vector<vector<int>>(n + 1);
	vector<int> l, r, ans;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		e[a].emplace_back(b);
		e[b].emplace_back(a);
		if(i == 0){
			used[a] = true; used[b] = true;
			l.emplace_back(a);
			r.emplace_back(b);
		}
	}
	extend_path(l);
	extend_path(r);
	reverse(begin(l), end(l));
	ans = l;
	ans.insert(end(ans), begin(r), end(r));
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size() - 1; i++){
		cout << ans[i] << " ";
	}
	cout << ans.back() << endl;
	return 0;
}

Measured memory_bytes: 7348
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

struct C{
	int tx,ty,kx,ky;
	C(int tx,int ty,int kx,int ky):
	tx(tx),ty(ty),kx(kx),ky(ky) {}
};

int X,Y,tx,ty,kx,ky,m[51][51],dx[]={1,0,-1,0},dy[]={0,1,0,-1},d[51][51][51][51];

int bfs(int tx,int ty,int kx,int ky){
	queue<C> q;
	rep(i,X)rep(j,Y)rep(k,X)rep(l,Y)d[i][j][k][l]=INF;
	q.push(C(tx,ty,kx,ky));
	d[tx][ty][kx][ky]=0;
	while(!q.empty()){
		C c=q.front();q.pop();
		if(d[c.tx][c.ty][c.kx][c.ky]==100)return -1;
		if(c.tx==c.kx&&c.ty==c.ky)return d[c.tx][c.ty][c.kx][c.ky];
		rep(i,4){
			int ntx=c.tx+dx[i],nty=c.ty+dy[i],nkx=c.kx-dx[i],nky=c.ky-dy[i];
			if(ntx<0||ntx>=X||nty<0||nty>=Y||m[nty][ntx]){ntx=c.tx;nty=c.ty;}
			if(nkx<0||nkx>=X||nky<0||nky>=Y||m[nky][nkx]){nkx=c.kx;nky=c.ky;}
			if(d[ntx][nty][nkx][nky]==INF){
				q.push(C(ntx,nty,nkx,nky));
				d[ntx][nty][nkx][nky]=d[c.tx][c.ty][c.kx][c.ky]+1;
			}
		}
	}
	return -1;
}

int main(){
	while(cin>>X>>Y&&X){
		cin>>tx>>ty>>kx>>ky;
		tx--;ty--;kx--;ky--;
		rep(i,Y)rep(j,X)cin>>m[i][j];
		int ans=bfs(tx,ty,kx,ky);
		if(ans>=0)cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 26000
N, W = map(int, input().strip().split())

# wv = [list(map(int, input().split())) for i in range(N)]

dp=[[0]*(W+1) for _ in range(N+1)]

for i in range(1,N+1):
    w, v = map(int, input().strip().split())
    for j in range(W+1):
        if j-w<0:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j], dp[i-1][j-w]+v)
print(max(dp[-1]))

Measured memory_bytes: 119916
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
     
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;


struct pair_hash
{
	size_t operator()(const std::pair<ll, ll> &v) const 
    {
      
        return std::hash<ll>()(v.first) ^ std::hash<ll>()(v.second);
    }
};

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};

struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  

void solve()
{
	string s,t;

	cin >> s >> t;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
		{
			cout << "No" << endl;
			return;
		}
	}

	cout << "Yes" << endl;

}


int main()
{
	solve();

	return 0;
}




Measured memory_bytes: 3632
// https://atcoder.jp/contests/arc062/tasks/arc062_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a1 = 1, a2 = 1;
    cin >> n;
    REP(i, n) {
        ll b1, b2;
        cin >> b1 >> b2;
        ll m1 = a1 / b1 + (a1 % b1 ? 1 : 0);
        ll m2 = a2 / b2 + (a2 % b2 ? 1 : 0);
        a1 = b1 * max(m1, m2);
        a2 = b2 * max(m1, m2);
    }
    cout << a1 + a2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool p = s.at(0) =='R';
  bool q = s.at(1) =='R';
  bool r = s.at(2) =='R';
  if(p and q and r){
    cout << "3" << endl;
  }else if((p and q) or( q and r)){
    cout << "2" << endl;
  }else if(p or q or r){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }
}


Measured memory_bytes: 3632
#include <stdio.h>

int solve(int, int);

int n,A[50];

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}



Measured memory_bytes: 2052
use std::io;

fn main() {
    let x: u128= parse_line();
    let mut money: u128 = 100;
    let mut answer: u128 = 0;
    loop {
        answer += 1;
        money += money / 100;

        if money >= x {
            println!("{}", answer);
            break
        }
    }
}

#[allow(dead_code)]
fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}




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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   ll n;
   cin >> n;
   map<ll, ll> m;
   for (ll i = 0; i < n; i++) {
      ll x;
      cin >> x;
      m[x]++;
   }

   vector<ll> v;
   for (auto x : m) {
      v.push_back(abs(x.second - x.first));
   }

   // for (ll x : v) {
   //    cout << x << " ";
   // } cout << endl;


   ll ans = 0;
   for (auto x : m) {
      // cout << x.first << ", " <<  x.second << endl;
      ll a = x.second - x.first;
      if (a >= 0) {
         ans += a;
      } else {
         ans += x.second;
      }
      // ans += max(x.second - x.first, x.second);
   }
   // for (auto itr = m.rbegin(); itr != m.rend(); ++itr) {
   //    ans += abs(itr->second - itr->first);
   // }

   cout << min(n, ans) << endl;

   return 0;
}

Measured memory_bytes: 7412
#include<iostream>
#include<cstdio>
#include<map> 
#include<vector>
using namespace std;

int a[10];
int main()
{
	int l,r;
	cin>>l>>r;
	int sum=0;
	for (int i=l;i<=r;i++)
	{
		int t=i;
		int j=0;
		while (t!=0)
		{
			j++;
			a[j]=t%10;
			t/=10;
		}
		if (a[1]==a[5]&&a[2]==a[4]) sum++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
using namespace std;
main(){
  int m,n;
  while(cin>>n,n){
    int a[10][10],s[10],b,c,d;
    bool q[10];
    r(i,10){q[i]=0;s[i]=0;r(j,10){
      if(i==j)a[i][j]=0;
      else a[i][j]=INF;
    }}
    while(n--){
      scanf("%d%d%d",&b,&c,&d);
      a[c][b]=a[b][c]=d;
      q[c]=1;q[b]=1;
    }
    r(k,10)r(i,10)r(j,10){
      a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
    }
    r(i,10)if(q[i])r(j,10){
      if(q[j]&&a[i][j]!=INF)s[i]+=a[i][j];
    }
    int p=0,ss=1<<29;
    r(i,10){
      if(q[i]&&ss>s[i]){
        ss=s[i];
        p=i;
      }
    }
    cout<<p<<' '<<ss<<endl;
  }
}

Measured memory_bytes: 3220
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<vector>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
struct st{int rate,way,num;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
vector<int> es[25];
signed main(){
    int n;cin>>n;
    int num=0;
    string s;
    bool ge=true;
    cout<<num<<endl;
    int le,ri,mi;
    le=0;ri=n-1;
    cin>>s;
    if(s=="Vacant"){
        return 0;
    }else if(s=="Female")ge=false;
    rep(i,0,20){
        if(mi==(le+ri)/2)mi=(le+ri)/2+1;
        else mi=(le+ri)/2;
        cout<<mi<<endl;
        cin>>s;
        if(s=="Vacant")break;
        else if(s=="Female"){
            if((ge&&mi%2==1)||(!ge&&mi%2==0))le=mi;
            else ri=mi;
        }else {
            if((ge&&mi%2==0)||(!ge&&mi%2==1))le=mi;
            else ri=mi;
        }
    }
    return 0;
}

Measured memory_bytes: 852
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		
		int len = S.length();
		int cnt = 0;
		for(int i=0;i<len/2;i++) {
			if(S.charAt(i)==S.charAt(len-1-i))continue;
			cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


char a[55][55];

int main(){FIN

    vector<P> a, b;
    ll n;cin>>n;
    REP(i,n){
        ll x,y; cin>>x>>y;
        a.push_back(make_pair(y,x));
    }
    REP(i,n){
        ll x,y; cin>>x>>y;
        b.push_back(make_pair(x,y));
    }
    VSORTR(a); VSORT(b);
    ll ans=0;
    vll b_mark(n,0);
    vll a_mark(n,0);
    REP(i,n){
        REP(j,n){
            if(b[i].second > a[j].first && b[i].first > a[j].second && b_mark[i]==0 && a_mark[j]==0){
                b_mark[i]=1;
                a_mark[j]=1;
                ans++;
                continue;
            }
        }

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

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

int main() {
	int n, a, b;
	long long ans = 1000;
	cin >> n >> a;
	while (n-- > 1) {
		cin >> b;
		if (b > a) ans += (ans / a) * (b - a);
		a = b;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3612
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=b){
		for(int i=0;i<b;i++)cout<<a;
		return 0;
	}
	else{
		for(int i=0;i<a;i++)cout<<b;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
# import math
# import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
S = stdin.readline().rstrip().split()[0]
N = len(S)
# print(N)
B = []
one_zero = "1"
for i, s in enumerate(S):
  B.append(s==one_zero)
  if one_zero=="1":
    one_zero = "0"
  else:
    one_zero = "1"

one = sum(B)
zero = N -one
if one < zero:
  print(one)
else:
  print(zero)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,p; cin >> n >> p;
    string s;cin >> s;
    ll ans = 0;
    if(p == 2 || p == 5){
        rep(i,n){
            ll t = s[i] - '0';
            if(t % p == 0)ans += i+1;
        }

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

    vector<ll> ten(n,1);
    reps(i,n-1) ten[i] = ten[i-1] * 10 % p;
    map<ll,ll> map_;
    ll now = 0;
    map_[0] = 1;
    reverse(all(s));
    rep(i,n){
        ll t = s[i] - '0';
        now = (now + t * ten[i]) % p;
        ans += map_[now]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2564
r, c = map(int, input().split())

list_2d = []
for i in range(r):
    list_1d = [int(x) for x in input().split()]
    list_2d.append(list_1d)
    
for i in range(r):
    sum_r = sum(list_2d[i])
    list_2d[i].append(sum_r)

list_2d_last = []
for i in range(c):
    sum_c = 0
    for k in range(r):
        sum_c += list_2d[k][i]
    list_2d_last.append(sum_c)
    
list_2d.append(list_2d_last)
list_2d[r].append(sum(list_2d[r]))

for a in list_2d:
    print(*a)


Measured memory_bytes: 6244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if (a + b > c + d)
            System.out.println("Left");
        else if (a + b == c + d)
            System.out.println("Balanced");
        else
            System.out.println("Right");
    }
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

ll a,b;

int main(){
  cin >> a>>b;
  if(b<0){
    if((a-b)%2==0){
      cout << "Negative" <<endl;
    }else{
      cout <<"Positive" <<endl;
    }
  }else if(a<0&&b>0){
    cout <<"Zero" <<endl;
  }else if(a==0||b==0){
    cout <<"Zero" <<endl;
  }else{
    cout << "Positive" <<endl;
  }
}


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

int main(){

    int k,x,i;
    cin >> k >> x;

    if(k==0)
        cout << "0" << endl;
    else{
        for(i=x-k+1;i<=x+k-1;i++)
            cout << i << " ";
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
n=int(input())
a=0
li=[]
for i in range(n):
    lis=input().split(' ')
    li.append(lis)
for i in range(n-2):
    if li[i][0]==li[i][1]:
        if li[i+1][0]==li[i+1][1]:
            if li[i+2][0]==li[i+2][1]:
                a+=1
if a!=0:
    print('Yes')
else:
    print('No')

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

int n, m=50000, mi;
double cx, cy, d, mx, p=1.0, x[55], y[55];
double f(double p, double q) {return p*p + q*q;}

int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) {
		cin >> x[i] >> y[i];
		cx += x[i]; cy += y[i];
	}
	cx /= n; cy /= n;
	while(m--) {
		mx = f(cx - x[0], cy - y[0]);
		mi = 0;
		for(i=1; i<n; i++) {
			d = f(cx - x[i], cy - y[i]);
			if(d > mx) mx = d, mi = i;
		}
		cx += (x[mi] - cx) * p;
		cy += (y[mi] - cy) * p;
		p *= 0.999;
	}
	printf("%.9f", sqrt(mx));
	return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=924844033;


typedef long double D;
typedef complex<long double> P;

template<typename D=long double,typename P=complex<long double>>
struct Geometry{
    const D EPS=1e-9;
    
    P project(P vec,P x){return vec*(x/vec).real();}
    
    P project(P p1,P p2,P x){return p1+project(p2-p1,x-p1);}
    
    P reflect(P vec,P x){return vec*conj(x/vec);}
    
    P reflect(P p1,P p2,P x){return p1+reflect(p2-p1,x-p1);}
    
    D dot(P p1,P p2){return p1.real()*p2.real()+p1.imag()*p2.imag();}
    
    D cross(P p1,P p2){return p1.real()*p2.imag()-p1.imag()*p2.real();}
    
    D area(const vector<P> &poly){
        D ans=0;
        for(int i=2;i<poly.size();i++){ans+=cross(poly[i-1]-poly[0],poly[i]-poly[0]);}
        return ans/2;
    }
    
    vector<P> convexhull(vector<P> pts){
        vector<P> ret;
        sort(pts.begin(),pts.end(),[](P a,P b){return (a.real()<b.real() || (a.real()==b.real() && a.imag()<b.imag()));});
        for(auto &I:pts){
            if(!ret.empty() && I==ret.back()){continue;}
            while(ret.size()>=2 && cross(ret.back()-ret[ret.size()-2],I-ret.back())<-EPS){ret.pop_back();}
            ret.push_back(I);
        }
        reverse(pts.begin(),pts.end());
        for(auto &I:pts){
            if(!ret.empty() && I==ret.back()){continue;}
            while(ret.size()>=2 && cross(ret.back()-ret[ret.size()-2],I-ret.back())<-EPS){ret.pop_back();}
            ret.push_back(I);
        }
        if(ret[0]==ret.back()){ret.pop_back();}
        return ret;
    }
};



int main(){
    Geometry<D,P> G;
    ll n;
    cin>>n;
    vector<P> A(n);
    for(auto &I:A){
        D x,y;
        cin>>x>>y;
        I={x,y};
    }
    cout<<fixed<<setprecision(1)<<G.area(A)<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(c-a) <= d){
        cout << "Yes" << endl;
    }else if(abs(b-a) <= d && abs(c - b) <= d){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int q = sc.nextInt();
    long[] s = new long[a];
    long[] t = new long[b];
    long[] x = new long[q];
    for(int i = 0; i < a; i++){
      s[i] = sc.nextLong();
    }
    for(int i = 0; i < b; i++){
      t[i] = sc.nextLong();
    }
    for(int i = 0; i < q; i++){
      x[i] = sc.nextLong();
    }
    for(int i = 0; i < q; i++){
      System.out.println(solve(s, t, x[i]));
    }
  }
  
  public static long solve(long[] a, long[] b, long x){
    long sum1;
    int i = binarySearch(a, x);
    
    long tmp1 = 0;
    tmp1 = Math.abs(x - a[i]);
    int ti = binarySearch(b, a[i]);
    long tp = Math.abs(a[i] - b[ti]);
    if(ti - 1 >= 0){
      tp = Math.min(tp, Math.abs(a[i] - b[ti-1]));
    }
    tmp1 += tp;

    long tmp2 = Long.MAX_VALUE;
    if(i - 1 >= 0){
      tmp2 = Math.abs(x - a[i-1]);
      ti = binarySearch(b, a[i-1]);
      tp = Math.abs(a[i-1] - b[ti]);
      if(ti - 1 >= 0){
        tp = Math.min(tp, Math.abs(a[i-1] - b[ti-1]));
      }
      tmp2 += tp;
    }
    sum1 = Math.min(tmp1, tmp2);

    long sum2;
    i = binarySearch(b, x);
    tmp1 = Math.abs(x - b[i]);
    ti = binarySearch(a, b[i]);
    tp = Math.abs(a[ti] - b[i]);
    if(ti - 1 >= 0){
      tp = Math.min(tp, Math.abs(a[ti-1] - b[i]));
    }
    tmp1 += tp;

    tmp2 = Long.MAX_VALUE;
    if(i - 1 >= 0){
      tmp2 = Math.abs(x - b[i-1]);
      ti = binarySearch(a, b[i-1]);
      tp = Math.abs(a[ti] - b[i-1]);
      if(ti - 1 >= 0){
        tp = Math.min(tp, Math.abs(a[ti-1] - b[i-1]));
      }
      tmp2 += tp;
    }
    
    sum2 = Math.min(tmp1, tmp2);

    return Math.min(sum1, sum2);
  }
  
  public static int binarySearch(long[] a, long x){
    int i = Arrays.binarySearch(a, x);
    if(i >= 0){
      return i;
    }else{
      i = ~i;
      if(i == a.length){
        return i - 1;
      }
      return i;
    }
  }
}

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


char S[3][128];
int n[3];
int p = 0;
char ans;

int main(void) {
  cin >> S[0] >> S[1] >> S[2];

  n[0] = n[1] = n[2] = 0;
  while(n[p] < strlen(S[p])) {
    p = S[p][n[p]++] - 'a';
  }

  ans = 'A' + p;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import math
A , B, H, M = map(int, input().split())
long = (M * 360) / 60
short = (H * 60 + M) * 360 / (12 * 60)
deg = short - long

E = A**2 + B**2 - 2 * A * B * math.cos(math.radians(deg))
print(math.sqrt(E))


Measured memory_bytes: 9496
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, w, weight[110], value[110], dp[110][100100];

int main() {
    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(j - weight[i] >= 0) dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct edge {
    int to;
    ll cost;
};
using Graph = vector<vector<edge>>;
Graph G;

int k;
ll d[100001];

void dfs(int v, int p){
    for(auto e : G[v]){
        if(e.to == p) continue;
        d[e.to] = d[v] + e.cost;
        dfs(e.to, v);
    }
}


int main(){
    int n;
    cin >> n;
    G.assign(n+1, vector<edge>());
    rep(i, n-1){
        int u, v;
        ll c;
        cin >> u >> v >> c;
        G[u].push_back(edge{v, c});
        G[v].push_back(edge{u, c});
    }


    int q;
    cin >> q >> k;

    dfs(k, -1);

    rep(i, q){
        int x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }
}

Measured memory_bytes: 14336
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int k = scanner.nextInt();
        int max = Math.max(c, Math.max(a, b));
        int sum = a+b+c-max;

        for(int i = 0; i < k; i++) {
        	max = max * 2;
        }
        System.out.println(sum+max);
    }

	private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

int f(int x){
    if(x % 2) return 3*x + 1;
    else return x / 2;
}

signed main(){
    int s;
    cin >> s;
    vi a(1000001);

    a[1] = s;
    for(int i = 2; i <= 1000001; i++){
        a[i] = f(a[i-1]);
    }

    for(int i = 1; i <= 1000001; i++){
        if(a[i] == 4 || a[i] == 2 || a[i] == 1){
            cout << i+3 << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 10000000000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())
ll mod = 1e9 + 7;

ll bigmod(ll base, ll power)
{

    if (power == 0)
        return 1;
    ll x = bigmod(base, power / 2);

    if (power % 2 == 0)
        return (x * x) % mod;
    return (x * x * base) % mod;
}

int main()
{
    ll a,b,c,d,m;
    cin>>a>>b>>c>>d;
    m = a*c;
    m = max(m,b*c);
    m = max(m,a*d);
    m = max(m,b*d);
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;


int lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

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

int main()
{
    string S;
    cin >> S;
    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vector<P> cb;
    rep(i, m) {
        int b, c;
        cin >> b >> c;
        cb.emplace_back(make_pair(c, b));
    }
    sort(all(a));
    sort(all(cb), greater<P>());
    auto it = a.begin();
    rep(i, m) {
        int c = cb[i].first;
        int b = cb[i].second;
        rep(j, b) {
            if (it == a.end()) {
                break;
            }
            if (*it < c) {
                *it = c;
            }
            ++it;
        }
    }
    cout << accumulate(all(a), 0ll) << endl;
}


Measured memory_bytes: 1784
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int a, b;
    cin >> a >> b;
    int tap = 1;
    int ans = 0;
    for(int i = 0;;i++){
        if(tap >= b) break;
        tap += a - 1;
        ans++; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

A = [[] for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(int(input())):
        A[i].append(list(map(int, input().split())))
#A

X = list(range(1, N+1))

n = N
ans = 0
for bit in range(2**n):
    Pick = []
    for j in range(n):
        mask = 1 << j
        if bit & mask:
            Pick.append(X[j])
#    print()
#    print(Pick)
    flag = True
    for pick in Pick:
        for xy in A[pick]:
            x = xy[0]
            y = xy[1]
            if y == 1 and x in Pick:
                flag *= True
            elif y == 0 and not(x in Pick):
                flag *= True
            else:
                flag *= False
#            print(x, y, flag)
#        print(pick, flag)
    if flag == True:
        ans = max(ans, len(Pick))
print(ans)                    

Measured memory_bytes: 74424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=100000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 200023;
int T;
ll n;
ll x;
ll y;


int main(int argc, char const *argv[])
{
#ifdef indiewar
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    cin >> T;
    T =1;
    while(T--)
    {
        cin >> n;
        cin >> x >> y;
        ll s = x + y;
        if(n <= s)
        {
            cout << min(n,x) << endl;
        }
        else 
        {
            ll t = n / s;
            n -= t*s;
            cout << t*x+min(n,x) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static bool[,] graph = new bool[8, 8];
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var list = new List<KeyValuePair<int, int>>();
            for(var i=0;i<M;i++)
            {
                var ab = Sarray();
                list.Add(new KeyValuePair<int, int>(ab[0],ab[1]));
            }
            var sl = list.OrderBy(x => x.Value).ToArray();
            var ans = 0;
            var lg = 0;
            for (var i=0;i<M;i++)
            {
                if(lg<=sl[i].Key)
                {
                    ans++;
                    lg = sl[i].Value;
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 26928
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << 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; }

int N,H,ans,maxi;

int main(){
    cin>>N;
    rep(i,N){
        cin>>H;
        if(H>=maxi){
            ans++;
            maxi=H;
        }
    }
    out(ans);
}


Measured memory_bytes: 384
import sys
import bisect

readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort()
    C.sort()

    ans = 0
    for b in B:
        tmpa = bisect.bisect_left(A, b)
        tmpc = N - bisect.bisect_right(C, b)
        ans += tmpa*tmpc
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] charArr = str.toCharArray();
        for (int i = 0; i < charArr.length; i++){
            if (charArr[i] != charArr[charArr.length - 1 - i]){
                System.out.println("No");
                return;
            }
        }
        for (int j = 0; j <= (charArr.length - 2) / 2; j++){
            if (charArr[j] != charArr[(charArr.length - 2) / 2 - j]){
                System.out.println("No");
                return;
            }
        }
        int count = 0;
        for (int k = (charArr.length + 3) / 2 - 1; k < charArr.length; k++){
            if (k == charArr.length - 1 - count){
                break;
            }
            if (charArr[k] != charArr[charArr.length - 1 - count]){
                System.out.println("No");
                return;
            }
            count++;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23380
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<functional>
#include<cassert>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

int main(void) {
	int a, b;
	cin >> a >> b;
	int c = a - 2 * b;
	if (c < 0) {
		cout << 0;
	}
	else {
		cout << c;
	}
}

Measured memory_bytes: 256
import itertools as it

MOD = 10**9 + 7
N = int(input())
a = list(map(int, input().split()))
s = list(it.accumulate(a))
ans = 0
for i in range(N - 1):
    ans += s[i] * a[i + 1]
    ans %= MOD
print(ans)

Measured memory_bytes: 101892