akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N, M;
vector<Int> A, B;
_int used[2010][2010][2][2];
Int mem[2010][2010][2][2];
Int dfs(Int i, Int j, Int flag1, Int flag2){
  if(i >= N || j >= M) return flag1 == 0 && flag2 == 0;
  if(used[i][j][flag1][flag2]++) return mem[i][j][flag1][flag2];
  
  Int a = 0, b = 0, c = 0, d = 0;
  if(A[i] == B[j]) a = dfs(i + 1, j + 1, 0, 0);
  if(flag1 == 0) b = dfs(i + 1, j, 0, 1);
  if(flag2 == 0) c = dfs(i, j + 1, 1, 0);
  if(flag1 == 0 && flag2 == 0) d = dfs(i + 1, j + 1, 0, 0);
  return mem[i][j][flag1][flag2] = (a + b + c + d) % mod;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

 
  cin>>N>>M;
  A.resize(N), B.resize(M);
  cin>>A>>B;


  Int ans = dfs(0, 0, 0, 0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 189696
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str=sc.next();
        long output=0;
        long sub;
        for(int i=0;i<str.length();i++){
            sub=Integer.parseInt(str.substring(i,i+1));
            for(int j=0;j<str.length()-i;j++){
                output+=sub*Math.pow(10, j)*Math.pow(2, (str.length()-i-j-2<0?0:str.length()-i-j-2))*Math.pow(2, i);
            }
        }
        System.out.println(output);

    }
    
 
}

Measured memory_bytes: 21588
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let mut s = read_line().chars().map(|c|c.to_digit(36).unwrap()).collect::<Vec<u32>>();
	let mut t = read_line().chars().map(|c|c.to_digit(36).unwrap())
	.collect::<Vec<u32>>();
	t.sort_by(|a,b|b.cmp(a));
	s.sort();
	if t > s {
		println!("Yes");
	}else{
		println!("No");
	}
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/

int main(){
	ll a,b,x;
	sld(a) sld(b) sld(x)
	b = (b/x)*x;
	if(b < a){
        p(0) pn
        return 0;
	}else if(b == a){
        if(a %x == 0){
            p(1) pn 
            return 0;
        }
	}
	ll cha = b-a+1ll;
	ll all = cha/x;
	ll yu = cha%x;
	if(yu != 0){
        all ++;
	}
    pld(all) pn



    return 0;

}



Measured memory_bytes: 256
#include <stdio.h>

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

int main(int argc, char *argv[])
{
	int i, n;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		int a, b, c;
		fscanf(stdin, "%d %d %d", &a, &b, &c);
		if (check(a, b, c)) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

int check(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a*a==b*b+c*c;
	} else if (b >=a && b >= c) {
		return b*b==a*a+c*c;
	} else {
		return c*c==a*a+b*b;
	}
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define int long long

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 3000 + 10, inf = 0x3f3f3f3f3f3f3f3f;

int N, A[Maxn], Dp[Maxn][Maxn];

inline void Solve ()
{
	for (int i = 1; i <= N; ++i)
	{
		if (N & 1) Dp[i][i] = A[i];
		else Dp[i][i] = -A[i];
	}
	for (int l = 2; l <= N; ++l)
	{
		int flag;
		if ((N - l + 1) & 1) flag = 1;
		else flag = -1;

		for (int i = 1; i + l - 1 <= N; ++i)
		{
			int j = i + l - 1;
			if ((N - l + 1) & 1)
			{
				Dp[i][j] = -inf;
				Chkmax(Dp[i][j], Dp[i + 1][j] + flag * A[i]);
				Chkmax(Dp[i][j], Dp[i][j - 1] + flag * A[j]);
			}
			else
			{
				Dp[i][j] = inf;
				Chkmin(Dp[i][j], Dp[i + 1][j] + flag * A[i]);
				Chkmin(Dp[i][j], Dp[i][j - 1] + flag * A[j]);
			}
//			printf("%lld %lld %lld %lld\n", i, j, Dp[i][j], flag);
		}
	}
	cout<<Dp[1][N]<<endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

main()
{
#ifdef hk_cnyali
	freopen("L.in", "r", stdin);
	freopen("L.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}

Measured memory_bytes: 70016
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long sum=0,now=0;
	long long ya=0,nowYa=0;
	string S;
	cin>>S;
	S[S.length()]='<';
	for(long long i=0;i<S.length();i++){
		if(S[i]=='<' && S[i+1]=='>'){
			now=now+1;
			sum+=now;
			ya=i+1;
			nowYa=now;
		}else if(S[i]=='>'){
			now=now-1;
			if(now==-1)sum+=i-ya;
			if(nowYa<=i-ya){sum++;nowYa++;}
			now=0;
		}else if(S[i]=='<'&&S[i+1]=='<'){
			now=now+1;
			sum+=now;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    // n >= 2* 10 ^ 5
    vector<pair<ll,ll>> b(n);

    for (ll i = 0; i < n; i++){
        b[i] = make_pair(i,a[i]);
    }

    sort(b.begin(),b.end(),[](const pair<long,long>& l,const pair<long,long>&  r){
        return l.second > r.second;
    });
    
    for (ll i = 0; i < n; i++)
    {
        ll ans = b[0].second;
        if (i==b[0].first) ans = b[1].second;
        cout << ans << endl;
    }


}


Measured memory_bytes: 6272
from decimal import Decimal, ROUND_CEILING

n = int(input())
ta_array = [[int(x) for x in input().split()] for y in range(n)]
res = 1
prev_t, prev_a = ta_array.pop(0)
for t, a in ta_array:
    res_a = Decimal(prev_a*res/a).quantize(Decimal(0.0), rounding=ROUND_CEILING)
    res_t = Decimal(prev_t*res/t).quantize(Decimal(0.0), rounding=ROUND_CEILING)
    res = max(res_a, res_t)
    prev_t = t
    prev_a = a
print(prev_t*res+prev_a*res)


Measured memory_bytes: 5460
#include <iostream>
#include <queue>
#include <cstring>
const int maxn=1010;
using namespace std;
struct Node {
	int x,y;
};
queue <Node> Q;
int a[maxn][maxn],d[maxn][maxn];
int vis[maxn][maxn];
int main(){
	memset(vis,0,sizeof(vis));
	memset(d,0,sizeof(d));
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,w;
	cin >> h>>w;
	for(int i=1;i<=h;i++){
		string s;
		cin >> s;
		for (int j=0;j<w;j++) {
			if (s[j] == '#'){
				a[i][j+1] = 1;
				Q.push((Node){i,j+1});
				vis[i][j+1] = 1;
			}else a[i][j+1] = 0;
			// a[i][j+1] = s[j]=='h'?1:0;

		}
	}

	int cnt = 0;
	while (!Q.empty()){
		Node p=Q.front();
		Q.pop();
		if (p.x>1 && !vis[p.x-1][p.y]){
			d[p.x-1][p.y] = d[p.x][p.y] + 1;
			Q.push((Node){p.x-1,p.y});
			vis[p.x-1][p.y] = 1;
		}
		if (p.y>1 && !vis[p.x][p.y-1]){
			d[p.x][p.y-1] = d[p.x][p.y] + 1;
			Q.push((Node){p.x,p.y-1});
			vis[p.x][p.y-1] = 1;
		}
		if (p.x<h && !vis[p.x+1][p.y]){
			d[p.x+1][p.y] = d[p.x][p.y] + 1;
			Q.push((Node){p.x+1,p.y});
			vis[p.x+1][p.y] = 1;
		}
		if (p.y<w && !vis[p.x][p.y+1]){
			d[p.x][p.y+1] = d[p.x][p.y] + 1;
			Q.push((Node){p.x,p.y+1});
			vis[p.x][p.y+1] = 1;
		}
	}
	int ans=0;
	// for (int i=1;i<=h;i++){
	// 	for (int j=1;j<=w;j++) ans=max(ans,d[i][j]),cout << d[i][j]<<' ';
	// 	cout << endl;
	// }
	for (int i=1;i<=h;i++)
		for (int j=1;j<=w;j++) ans=max(ans,d[i][j]);
	
	cout << ans;
}

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

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

	int a,b;
	
	cin >> a >> b;

	cout << max(a+b,max(a-b,a*b)) << '\n';

	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vecctor<ll>>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define all(v) v.begin(),v.end()



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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 ll mod = 998244353;



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vl l(n),r(n);
    rep(i,k){
        cin >> l[i] >> r[i];
    }

    ll dp[200000 + 5];
    ll dp_sum[200000 + 5];
    dp[0] = 1;
    dp_sum[0] = 0;
    dp_sum[1] = 1;
    for(int i = 1;i < n; ++i){
        rep(j,k){
            int ri = i-l[j],li = i-r[j];
            if(ri < 0)continue;
            li = max(0,li);
            dp[i] += dp_sum[ri+1]-dp_sum[li];
            dp[i] %= mod;
        }
        dp_sum[i+1] = dp_sum[i] + dp[i];
        dp_sum[i+1] %= mod;
    }
    ll ans = dp[n-1];
    cout << (ans%mod + mod)%mod << endl;

    return 0;
}

Measured memory_bytes: 9524
import java.util.Arrays;
import java.util.Scanner;

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

		String line = s.nextLine();
		int N = Integer.parseInt(line);

		line = s.nextLine();
		String[] str = line.split(" ");
		long[] A = new long[N];
		long sumA = 0;
		for (int i = 0; i < N; i++) {
			A[i] = Long.parseLong(str[i]);
			sumA += A[i];
		}

		line = s.nextLine();
		str = line.split(" ");
		long[] B = new long[N];
		long sumB = 0;
		for (int i = 0; i < N; i++) {
			B[i] = Long.parseLong(str[i]);
			sumB += B[i];
		}

		if (sumB > sumA) {
			System.out.println(-1);
			return;
		}

		int changeCnt = 0;
		long penaSum = 0L;
		long[] pena = new long[N];
		for (int i = 0; i < N; i++) {
			pena[i] = B[i] - A[i];
			if (pena[i] > 0) {
				changeCnt++;
				penaSum += pena[i];
			}
		}

		Arrays.sort(pena);

		for (int i = 0; i < N; i++) {
			if (penaSum <= 0)
				break;
			else {
				penaSum += pena[i];
				changeCnt++;
			}
		}

		System.out.println(changeCnt);
	}
}

Measured memory_bytes: 55956
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        System.out.println((a - 1) * (b - 1));
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

struct node {
	int id;
	int num;
};

bool operator<(const node &a, const node &b)
{
	return tie(a.num, a.id) < tie(b.num, b.id);
}

ostream &operator<<(ostream &os, const node &x)
{
	return os << "{" << x.num << ", " << x.id << "}";
}

int main()
{
	int K, T;
	cin >> K >> T;
	priority_queue<node> q;

	for (int i = 0; i < T; ++i) {
		int a;
		cin >> a;
		node x = { i + 1, a };
		q.push(x);
	}
	

	int last = -1;

	while (q.size() >= 2) {
		node x1 = q.top(); q.pop();
		node x2 = q.top(); q.pop();;

		if (x1.id == last) {
			last = x2.id;
			if (--x2.num > 0) {
				q.push(x2);
				
			}
			q.push(x1);
		}
		else {
			last = x1.id;
			if (--x1.num > 0) {
				q.push(x1);
			}
			q.push(x2);
		}
	}
	int ans = q.top().num - 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K,ans=0;
    cin>>N>>K;
    int h[N];
    for(int i=0;i<N;i++){
        cin>>h[i];
        if(h[i]>=K) ans++;
    }
    cout<<ans;
}


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

int main() {
    int N, K;
    int d = 1;
    cin >> N >> K;
    while (N >= K) {
    N = N / K;
    d++;
    }
    cout << d << endl;
    return 0;
}


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

int main() {
	int n,m;
	cin>>n;
	int i,max1=0,j;
	vector <string>v1,v2,v3;
	while(n--)
	  {
	  	string x;
	  	cin>>x;
	  	int sw=0;
	  	for(i=0;i<v3.size();i++)
	  	  {
	  	      if(x==v3[i])
	  	        {
	  	          sw=1;	
	  	        }
	  	  }
	      if(sw==0)
	         v3.push_back(x);
	  	v1.push_back(x);
	  }
	  cin>>m;
	while(m--)
	  {
	  	string x;
	  	cin>>x;
	  	int sw=0;
	  	for(i=0;i<v3.size();i++)
	  	  {
	  	     if(x==v3[i])
	  	       sw=1;
	  	  }
	  	if(sw==0)
	  	  v3.push_back(x);
	  	v2.push_back(x);
	  }  
	int a[v3.size()];
	for(i=0;i<v3.size();i++)
	  a[i]=0;
	for(i=0;i<v3.size();i++)
	  {
	  	for(j=0;j<v1.size();j++)
	  	  {
	  	  	if(v3[i]==v1[j])
	  	  	  ++a[i];
	  	  }
	  	for(j=0;j<v2.size();j++)
	  	  {
	  	  	if(v3[i]==v2[j])
	  	  	  --a[i];
	  	  }
	  	max1=max(max1,a[i]);  
	  }
	cout<<max1<<"\n";  
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  int N;in(N);
  set<int>s;
  map<int,int>m;
  rep(i,N){
    int t;
    if(i==0){
      cin>>t;
      if(t!=0){
        out(0);
        return;
      }
    }else{
      cin>>t;
      m[t]++;
      s.insert(t);
    }
  }
  cpp_int ans=1,pre=1,prem=1;
  for(auto e:s){
    if(e!=pre){
      out(0);
      return;
    }
    ans*=(cpp_int)pow(prem,m[e]);
    prem=m[e];
    pre++;
  }
  out(ans%998244353);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 9600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.next();
            out.println(s.equals("ABC") ? "ARC" : "ABC");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32324
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

typedef long long ll;
using namespace std;

const ll M = 1e9+7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for(ll t = k; t <= n+1; ++t){
        ll mn = (t)*(t-1)/2;
        ll mx = (n-t+1+n)*(t)/2;
        res += mx-mn + 1;
        res %= M;
    }
    cout << res << endl;
}




Measured memory_bytes: 3192
#include <iostream>
using namespace std;
#include "math.h"


int main(){
    double a,b; int h,m;
    cin>>a>>b>>h>>m;
    h = h*60 + m;
    h%=12*60;
    double x = (double)h* 1.0/12.0/60.0 * 2*3.141592653589793238;
    h%=60;
    double y = (double)h* 1.0/60.0 * 2*3.141592653589793238;
    if(x>y)swap(x,y);
    x = y-x;
    x = min(x, 2*3.141592653589793238-x);

    printf("%.12lf", sqrt(a*a+b*b-2.0*a*b*cos(x)));

}

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

using namespace std;

typedef long long ll;

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

// union-find tree with size(struct)
struct UnionFind{
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
	vector<int> size; // 連結成分のサイズ

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n);
		rank.resize(n);
		size.resize(n);
        for (int i = 0; i < n; ++i){
			par[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
    }

    int find(int x) {
        if (par[x] == x)  return x;

        int r = find(par[x]);
        return par[x] = r;
    }

    bool issame(int x, int y) {
        return find(x) == find(y);
    }

    bool unite(int x, int y) {
	    x = find(x);
		y = find(y);
	    if (x == y) return false;

	    if (rank[x] < rank[y]) swap(x, y);
	    if (rank[x] == rank[y]) ++rank[x];
	    par[y] = x;
		size[x] += size[y];
	    return true;
    }

	int getSize(int x){
		return size[find(x)];
	}

	int getRank(int x){
		return rank[find(x)];
	}
};

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

	int n, m;
	cin >> n >> m;

	UnionFind uf(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf.unite(a, b);
	}

	int ans = 0;
	rep(i, n){
		chmax(ans, uf.getSize(i));
	}

	cout << ans << endl;
}


Measured memory_bytes: 5556
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,m,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        n=5;
        ll a[n];
        FOR(i,0,n)  cin>>a[i];
        cin>>k;
        int fl=1;
        FOR(i,0,n)
        {
            FOR(j,0,n)
                if((a[j]-a[i])>k)
                    fl=0;
        }
        if(fl)
            cout<<"Yay!";
        else
            cout<<":("; 
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int wake = h1 * 60 + m1;
    int sleep = h2 * 60 + m2;
    int waking = sleep - wake;
    int ans = max(0, waking - k);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        var ab = Console.ReadLine().ToIntArray();
        long A = ab[0];
        long B = ab[1];

        if ((A + B) % 2 == 0)
        {
            Console.WriteLine((A + B) / 2);
            return;
        }

        Console.WriteLine("IMPOSSIBLE");
    }
    
}

Measured memory_bytes: 13396
N, M = list(map(int, input().split()))
P = {}
lines = []
for i in range(M):
    p, y = list(map(int, input().split()))
    lines.append((p,y))
    if p in P.keys():
        P[p].append(y)
    else:
        P[p] = [y]

for p, y in P.items():
    tmp = y[:]
    tmp.sort()
    #print(tmp)
    P[p] = {}
    for i in range(len(tmp)):
        P[p][tmp[i]] = i

for line in lines:
    p, y = line
    ans = ('00000'+str(p))[-6:] + ('00000'+(str(P[p][y]+1)))[-6:]
    print(ans)

Measured memory_bytes: 54532
N, M = map(int, input().split())
E = [[] for _ in range(N+1)]
for _ in range(M):
    u, v = map(int, input().split())
    E[u].append(v)
Closed = [[False]*(N+1) for _ in range(3)]
S, T = map(int, input().split())
st = [(S, 0)]
Closed[0][S] = True
ans = 0
while len(st):
    st_new = []
    for v, n in st:
        if v==T and n==0:
            print(ans // 3)
            exit()
        n1 = (n+1)%3
        Cl = Closed[n1]
        for u in E[v]:
            if not Cl[u]:
                st_new.append((u, n1))
                Cl[u] = True
    st = st_new
    ans += 1

print(-1)


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , m;
    cin >> n >> m;
    priority_queue<int> pq;
    int x;
    loop(i,n){
        cin >> x;
        pq.push(x);
    }

    while(m--){
        int u = pq.top();
        pq.pop();
        pq.push(u / 2);
    }

    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
import numpy as np
L, R = list(map(int, input().split(' ')))
x = []
x.append(L % 2019)
for i in range(L+1, R+1):
    m = i % 2019
    if x[0] == m:
        break
    x.append(m)
    
min_v = 2018
for i in range(0, len(x)-1):
    tmp = np.amin(np.mod([x[i]*x[j] for j in range(i+1, len(x))], 2019))
    if tmp < min_v:
        min_v = tmp

print(min_v)

Measured memory_bytes: 12392
#include <stdio.h>

int main(void) {
  
  char str[1000];
  
  scanf("%s", str);
  
  if(str[0] == 'A') {
    printf("T\n");
  } else if(str[0] == 'T') {
    printf("A\n");
  } else if(str[0] == 'G') {
    printf("C\n");
  } else {
    printf("G\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);

char S[55],T[55];


int main()
{
    cin>>S>>T;
    int len1 =strlen(S);
    int len2 =strlen(T);

    int temp = 0;
    int max1 = 0;

    for(int i = 0;i<len1;i++)
        if(S[i]=='?')
            temp++;
        else if(temp>max1)
        {
            max1 =temp;
            temp =0;

        }

     int Ti = 0,Timax = -1;
     int flag = 0;
    for(int i = 0;i<len1;i++){
        flag = 0;
        int Si= i;
        while(T[Ti]==S[Si]||S[Si]=='?'){
            if(Ti==len2-1)
                {
                    if(S[Si]!='?')
                    flag = 1;
                    Timax = Si;
                    break;
                }
            Ti++;Si++;
        }
        if(flag == 1)
            break;
        Ti = 0;
    }

    if(Timax==-1)
        cout<<"UNRESTORABLE"<<endl;
    else{
        int Timax2 = Timax - len2 +1;
        Ti = 0;
        for(int i = 0;i<len1;i++){
            if(i>=Timax2&&i<=Timax){
                cout<<T[Ti++];
            }
            else if(S[i]!='?')
                cout<<S[i];
            else
                cout<<'a';
        }
        cout<<endl;
    }




   return 0;
}


Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
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 a[Max];
ll k,A,B;
void solve(){
	string s;
	cin>>s;
	int i=0,k=sz(s)-1;
	while(i<k){
		if(s[i]!=s[k])A++;
		i++,k--;
		
	}
	cout<<A;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main()
{
	char b, pair;
	
	cin >> b;
	
	switch (b) {
	case 'A':
		pair = 'T';
		break;
	case 'C':
		pair = 'G';
		break;
	case 'G':
		pair = 'C';
		break;
	case 'T':
		pair = 'A';
		break;
	}
	
	cout << pair << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#pragma comment(linker, "/STACK:36777216")

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "A"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int main() {
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, X;
  cin >> n >> X;
  vi b(n), l(n), u(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &b[i], &l[i], &u[i]);
  }
  vi x(n, 0);
  ll res = 0;
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += -ll(l[i]) * ll(b[i]);
  }
  vl total(n);
  for (int i = 0; i < n; ++i) {
    total[i] = ll(b[i]) * l[i] + ll(X - b[i]) * u[i];
  }
  vector<pair<ll, int> > totals;
  for (int i = 0; i < n; ++i) {
    totals.push_back(MP(total[i], i));
  }
  sort(totals.rbegin(), totals.rend());
  vi index(n);
  for (int i = 0; i < n; ++i) {
    index[totals[i].second] = i;
  }
  int first_unused = 0;
  while (sum < 0 && first_unused < n) {
    if (sum + totals[first_unused].first <= 0) {
      res += X;
      sum += totals[first_unused].first;
      ++first_unused;
    }
    else {
      break;
    }
  }
  ll init_sum = sum;
  ll result = res + X;
  for (int i = 0; i < n; ++i) {
    ll cur_sum = init_sum;
    ll curres = res;
    int fu = first_unused;
    if (index[i] < fu) {
      cur_sum -= totals[index[i]].first;
      curres -= X;
      while (cur_sum < 0 && fu < n) {
        if (cur_sum + totals[fu].first <= 0) {
          curres += X;
          cur_sum += totals[fu].first;
          ++fu;
        }
        else {
          break;
        }
      }
    }
    ll left = -cur_sum;
    ll need;
    if (ll(l[i]) * b[i] >= left) {
      need = (left + l[i] - 1) / l[i];
    }
    else {
      need = b[i] + (left - ll(l[i]) * b[i] + u[i] - 1) / u[i];
    }
    curres += need;
    if (curres < result) {
      result = curres;
    }
  }
  cout << result << endl;
  return 0;
}


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

const long long D = (long long)(1e9) + 7;

long long ext_gcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = ext_gcd(b, a % b, y, x);
    y -= a/b * x;
    return d;
}

long long inv_mod(long long a, long long mod) {
    long long x, y;
    ext_gcd(a, mod, x, y);
    x %= mod;
    if (x < 0) { x += mod; };
    return x;
}

long long calc_combi(long long n, long long r) {
    if (r == 0) { return 1; }
        long long a = 1, b = 1;
        for (int i = 1; i <= r; i++) {
            a = (a * (n - i + 1)) % D;
            b = (b * i) % D;
        }
        return a * inv_mod(b, D) % D;
}

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

    for (int i = 1; i <= k; i++) {
        int sep = n - k + 1;
        long long red_combi = calc_combi(sep, i);
        long long blue_combi = calc_combi(k-1, i-1);
        long long result = (red_combi * blue_combi) % D;
        cout << result << endl;
    }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>a>>b;
    if((a+b)%2==0)Cout((a+b)/2);
    else Cout("IMPOSSIBLE");
    return 0;
}


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()

ll gcd(ll a, ll b){
   if(b == 0) return a;
   
   return gcd(b, a % b);
}

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}
using namespace std;


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

   int a,b,c; cin >> a >> b >> c;
   int five = 0, seven = 0;
   if(a == 5) five++;
   if(b == 5) five++;
   if(c == 5) five++;

   if(a == 7 || b == 7 || c == 7) seven++;
   
   if(five == 2 && seven == 1) cout << "YES";
   else cout << "NO"; 
   return 0;
}


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

int main() {

	ll N;
	cin >> N;
	deque<int> v;
	while(N > 0) {
		int a = ((N - 1) % 26) + 1;
		v.push_front(a);
		N = (N - a) / 26;
	}
	for (auto it = v.begin(); it != v.end(); it++) {
		cout << char(*it + 96);
	}
	cout << endl;

	return(0);
}


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

int main(){
    int n;
    int a[101],b[101];
    int sa;
    char s[101];
    while(1){
        cin >> n;
        if(n == 0) break;
        cin >> s;
        for(int i=0;i<n;i++){
            cin >> a[i] >> b[i];
            a[i]--;
            b[i]--;
        }
        for(int i=n-1;i>=0;i--){
            sa = b[i] - a[i];
            while(sa--){
                if(s[a[i]] == 'z') s[a[i]] = 'a';
                else s[a[i]]++;
                if(s[b[i]] == 'z') s[b[i]] = 'a';
                else s[b[i]]++;
            }
            swap(s[a[i]],s[b[i]]);
        }
        cout << s << endl;
    }
}

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

int sums(int a) {
  int sum = 0;
  int dig;
  while (a) {
    dig = a % 10;
    sum += dig;
    a /= 10;
  }
  return sum;
}

int nums(string s) {
  int sum = 0;
  for (int i = 0; i < (int)s.size();i++) {
    sum += (int)(s[i]-'0');
    if (i + 1 == (int)s.size()) continue;
    sum *= 10;
  }
  return sum;
}

int main()
{
  string x;
  int a, b;
  cin >> x >> a >> b;
  int ans = 0;

  for (int i = 1; i <= nums(x); i++) {
    int ni = sums(i);
    if (a <= ni && ni <= b) ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		String[] fiz = new String[10001];
		for (int i = 1; i <= 10000; i++) {
			if (i % 15 == 0)
				fiz[i] = "FizzBuzz";
			else if (i % 5 == 0)
				fiz[i] = "Buzz";
			else if (i % 3 == 0)
				fiz[i] = "Fizz";
			else
				fiz[i] = String.valueOf(i);
		}
		while (true) {
			int m = scanner.nextInt();
			int n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			boolean[] player = new boolean[m + 1];
			int at = 1;
			int out = 0;
			for (int i = 1; i <= n; i++) {
				String str = scanner.next();
				if (out + 1 == m)
					continue;
				if (!str.equals(fiz[i])) {
					player[at] = true;
					out++;
				}
				while (true) {
					at = at == m ? 1 : at + 1;
					if (!player[at])
						break;
				}
			}
			boolean flag = false;
			for (int i = 1; i <= m; i++) {
				if (!flag) {
					if (!player[i]) {
						System.out.print(i);
						flag = true;
					}
				} else {
					if (!player[i]) {
						System.out.print(" " + i);
					}
				}
			}
			System.out.println();

		}
	}
}

Measured memory_bytes: 69648
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		for(int i=X;i<10000000;i++) {
			int x = i;
			if(x>=4&&x%2==0)continue;
			for(int j=2;j<Math.sqrt(X);j++) {
				if(x%j==0) {
					x/=j;
					break;
				}
			}
			if(x==i) {
				System.out.println(x);
				return;
			}
		}
	}
}

Measured memory_bytes: 21716
using System;

namespace ABC121 {
  class ProblemC {
    static void Main(string[] args) {
      string[] str1 = System.Console.ReadLine().Split(' '), str2;
      int n = int.Parse(str1[0]), m = int.Parse(str1[1]);
      Tuple<int, int>[] ab = new Tuple<int, int>[n];
      for (int i = 0; i < n; i++) {
        str2 = System.Console.ReadLine().Split(' ');
        ab[i] = Tuple.Create<int, int>(int.Parse(str2[0]), int.Parse(str2[1]));
      }

      long cost = 0L;
      int rest = m, j = 0;
      Array.Sort(ab);
      while (rest > 0) {
        if (rest > ab[j].Item2) {
          cost += (long)ab[j].Item1 * (long)ab[j].Item2;
          rest -= ab[j].Item2;
        } else {
          cost += (long)ab[j].Item1 * (long)rest;
          rest = 0;
        }
        j++;
      }
      System.Console.WriteLine(cost);
    }
  }
}

Measured memory_bytes: 20280
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        Deque<String> deq = new ArrayDeque<String>(300100);
        String str = scanner.next();
        for(char c : str.toCharArray()) {
            deq.add(String.valueOf(c));
        }
        int query = scanner.nextInt();
        boolean reverse = false;
        for(int i = 0; i < query; i++) {
            if(scanner.nextInt() == 1) {
                reverse = !reverse;
                continue;
            }
            if(!reverse) {
                if(scanner.nextInt() == 1) {
                    deq.addFirst(scanner.next());
                } else {
                    deq.addLast(scanner.next());
                }
            } else {
                if(scanner.nextInt() == 1) {
                    deq.addLast(scanner.next());
                } else {
                    deq.addFirst(scanner.next());
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        if(reverse) {
            while(!deq.isEmpty()) {
                sb.append(deq.pollLast());
            }
        } else {
            while(!deq.isEmpty()) {
                sb.append(deq.pollFirst());
            }
        }
        System.out.println(sb.toString());
        
    }
}

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

using namespace std;

int A[100005];
int N[200005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n, k, q;
	cin >> n >> k >> q;
	for (int i = 0; i < n; ++i) {
		N[i] = k;
	}
	for (int i = 0; i < q; ++i) {
		cin >> A[i];
		N[A[i] - 1]++;
	}
	for (int i = 0; i < n; ++i) {
		if (N[i] - q > 0) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

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

using namespace std;

int a, b;
int arr[110][110];

int main() {
    int i, j;

    scanf("%d%d",&a,&b);
    for (i=0;i<50;i++) for (j=0;j<100;j++) arr[i][j] = 1;
    a--; b--;

    i = j = 0;
    for (;a;a--) {
        arr[i][j] = 0;
        j += 2;
        i += j/100*2;
        j %= 100;
    }
    i = 51; j = 0;
    for (;b;b--) {
        arr[i][j] = 1;
        j += 2;
        i += j/100*2;
        j %= 100;
    }
    printf("100 100\n");
    for (i=0;i<100;i++) {
        for (j=0;j<100;j++) printf("%c",arr[i][j]?'#':'.');
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

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

    ll n,q;
    cin >> n >> q;
    
    string str;
    cin >> str;

    vector<ll> a(q),b(q);
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i];
    }

    vector<ll> sum(n+1,0);

    for(int i = 2; i < n+1; i++){
        sum[i] = sum[i-1];
        if(str[i-1] == 'C' && str[i-2] == 'A'){
            sum[i]++;
        }
    }

    for(int i = 0; i < q; i++){
        cout << sum[b[i]] - sum[a[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 3408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
int n,m,s,answer;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&s);
        if(s<=m/2) answer+=s*2;
        else answer+=(m-s)*2;
	}
	printf("%d\n",answer);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    int ans = 0;
    int mn = n+1;
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        if (a[i] < mn){
            mn = a[i];
            ans++;
        }
    }
    printf("%d",ans);


}


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

typedef long long int LLI;

LLI gcd(LLI a, LLI b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (b) {
    LLI t = a;
    a = b;
    b = t % b;
  }
  return a;
}

int main() {
  LLI N, M;
  string n, m;
  cin >> N >> M >> n >> m;

  LLI g = gcd(N, M);
  LLI a = N / g;
  LLI b = M / g;
  LLI l = a * b * g;

  LLI s = l / N;
  LLI t = l / M;
  bool success = true;
  for (LLI i = 0; i < N; ++i) {
    LLI p = s * i;
    if (!(p % t)) {
      LLI j = p / t;
      if (n[i] != m[j]) {
        success = false;
        break;
      }
    }
  }

  if (success) {
    cout << l << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];

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

    double ave = 1. * sum / n;

    int min_index = n;
    double distance_min = 1 << 10;
    for(int i = n-1; i >= 0; i--){
        if((ave-a[i])*(ave-a[i]) <= distance_min*distance_min){
            distance_min = (ave-a[i] < 0)?a[i]-ave:ave-a[i];
            min_index = i;
        }
    }

    cout << min_index << endl;

    return 0;
}


Measured memory_bytes: 888