akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys,bisect
    input = sys.stdin.readline

    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    mod = 10**9+7

    a.sort()
    b.sort()
    
    if len(set(a)) != n or len(set(b)) != m:
        print(0)
        exit()
    res = 1

    for i in range(n*m,0,-1):
        k1 = bisect.bisect_left(a,i)
        k2 = bisect.bisect_left(b,i)

        if (n-k1)*(m-k2) < n*m-i+1:
            print(0)
            exit()
        if a[k1] == i and b[k2] == i:
            res = res*1
        elif a[k1] == i:
            res = res*(m-k2)%mod
        elif b[k2] == i:
            res = res*(n-k1)%mod
        else:
            res = res*((n-k1)*(m-k2)-(n*m-i))%mod

    print(res)





if __name__ == '__main__':
    main()

Measured memory_bytes: 42476
//
//  main_4.cpp
//  beginner20200412_1
//
//  Created by zer0 on 2020/04/12.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>
#include <string>

int main(int argc, const char * argv[]) {
    
    long long m, r=0, g=0, b=0;
    std::string s;
    std::cin >> m;
    std::cin >> s;
    
    for(int i=0; i<m; i++){
        if(s.substr(i, 1)=="R") {r++;}
        else if(s.substr(i, 1)=="G"){g++;}
        else {b++;}
    }
    
    long long all=r*g*b;
    long long sub=0;
    
    for(int i=0; i<m; i++){
        for(int j=i+1; j<m; j++){
            if(s[i]==s[j]) continue;
            int k=2*j-i;
            if(k >= m || s[i]==s[k] || s[j]==s[k]) continue;
            sub++;
        }
    }
    
    std::cout << all - sub;

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}


signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll l;
  cin >> l;
  long r;
  for(r = 1; r <= 19; r++){
    if(l < pow(2,r)){
      break;
    }
  }
  r--;
  vector<vector<ll>> ans;
  for(ll i = 1 ; i <= r ; i++){
    ans.push_back({i,i+1,0});
    ans.push_back({i,i+1,static_cast<ll>(pow(2,i-1))});
  }


  for(ll i = r ; i >= 1; i--){
    if(l - pow(2,i-1) >= pow(2,r) ){
      ans.push_back({i,r+1,l-static_cast<ll>(pow(2,i-1))});
      l -= pow(2,i-1);
    }
  }
  cout << r+1 << ' ' << ans.size() << "\n";
  for(auto each_ans : ans){
    cout << each_ans[0] << " " << each_ans[1] << " " << each_ans[2] << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Sushi {
	int t;
	int d;

	Sushi(int t, int d) {
		this.t = t;
		this.d = d;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		Sushi[] sushis = new Sushi[N];
		for (int i = 0; i < N; i++) {
			int t = Integer.parseInt(sc.get()) - 1;
			int d = Integer.parseInt(sc.get());
			sushis[i] = new Sushi(t, d);
		}

		Arrays.sort(sushis, Comparator.comparingInt((Sushi s) -> s.d).reversed());

		long valuation;
		long delicious = 0;

		BitSet exist = new BitSet(N + 1);
		PriorityQueue<Sushi> queue = new PriorityQueue<>(Comparator.comparingInt((Sushi s) -> s.d));
		for (int i = 0; i < K; i++) {
			Sushi sushi = sushis[i];
			int t = sushi.t;
			delicious += sushi.d;
			if (!exist.get(t)) {
				exist.set(t);
				continue;
			}
			queue.add(sushi);
		}
		valuation = exist.cardinality();
		
		if (K == N) {
			System.out.println(valuation * valuation + delicious);
			return;
		}

		BitSet st = new BitSet(N + 1);
		PriorityQueue<Sushi> standing = new PriorityQueue<>(Comparator.comparingInt((Sushi s) -> s.d).reversed());
		for (int i = K; i < N; i++) {
			Sushi sushi = sushis[i];
			int t = sushi.t;
			if (exist.get(t) || st.get(t)) {
				continue;
			}
			st.set(t);
			standing.add(sushi);
		}

		long max = valuation * valuation + delicious;
		while (!standing.isEmpty() && !queue.isEmpty()){
			valuation += 1;
			Sushi in = standing.remove();
			Sushi out = queue.remove();
			delicious -= out.d;
			delicious += in.d;

			max = Math.max(max, valuation * valuation + delicious);
		}

		System.out.println(max);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 46700
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 2019;



int main()
{
    ll L, R;
    cin >> L >> R;
    ll mn = inf;
    rep(i, L, L+3000) {
        if (i == R) break;
        rep(j, L+1, L+3000) {
            if (j == R+1) break;
            chmin(mn, ((i%MOD)*(j%MOD))%MOD);
        }
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextLong();
            var list = Input.LongList();
            // 初期符号は正
            long sum = list[0] <= 0 ? 1 : list[0];
            long count1 = sum - list[0];

            for (int i = 1; i < N; i++) {
                var nextSum = sum + list[i];
                if (sum > 0 && nextSum >= 0) {
                    count1 += nextSum + 1;
                    sum = -1;
                } else if (sum < 0 && nextSum <= 0) {
                    count1 += -nextSum + 1;
                    sum = 1;
                } else {
                    sum = nextSum;
                }
            }

            // 初期符号は負
            sum = list[0] < 0 ? list[0] : -1;
            long count2 = list[0] - sum;

            for (int i = 1; i < N; i++) {
                var nextSum = sum + list[i];
                if (sum > 0 && nextSum >= 0) {
                    count2 += nextSum + 1;
                    sum = -1;
                } else if (sum < 0 && nextSum <= 0) {
                    count2 += -nextSum + 1;
                    sum = 1;
                } else {
                    sum = nextSum;
                }
            }

            Console.WriteLine(Math.Min(count1, count2));
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(3);
	rep(i,3) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	while(a[0] != a[1] || a[1] != a[2]){
		if(a[0] != a[1]){
			a[0] += 2;
		}
		else{
			++a[0];
			++a[1];
		}
		sort(a.begin(), a.end());
		++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

//整数xの約数を列挙
void func(int x, vector<int> &fac) {
    while (fac.size())
        fac.pop_back();
    for (int i = 1; i * i <= x; i++) {
        if (x % i == 0) {
            if (i != x / i) {
                fac.push_back(i);
                fac.push_back(x / i);
            }
            else
                fac.push_back(i);
        }
    }
}

int main() {
    int n;  cin >> n;
    int *a = new int[n];
    map<int,int> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        m[a[i]]++;
    }
    sort(a, a+n);

    int tmp = 0;
    vector<int> fac;
    for (int i = 0; i < n; i++) {
        if (m[a[i]] > 1) {
            tmp++;
            continue;
        }

        func(a[i], fac);
        for (int j = 0; j < fac.size(); j++) {
            int *k = lower_bound(a, a+n, fac[j]);
            if (*k == fac[j] && fac[j] != a[i]) {
                tmp++;
                break;
            }
        }
    }

    cout << n - tmp << endl;

    return 0;
}

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

vector<bool> flg(1000001, true);
vector<bool> same(1000001, false);

void calc2(int n)
{
	int a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
//			printf("%d * ", a);
			flg[a] = false;
			n /= a;
		}
		else {
			a++;
		}
	}
//	printf("%d\n", n);
	flg[n] = false;
	return;
}

bool calc(int n)
{
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			if (flg[i] == false) {
				return false;
			}
			if (i*i != n) {
				if (flg[n / i] == false && i!=1) {
					return false;
				}
			}
		}
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	int *a = new int[n];
	bool oneflg = false;
	int i, j, k;
	int ans = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (flg[a[i]] == false) {
			same[a[i]] = true;
		}
		flg[a[i]] = false;
	}
	sort(a, a + n);
	if (a[0] == 1) {
		if (n == 1) {
			cout << 1 << endl;
		}
		else if (a[1] == 1) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
		return 0;
	}
	for (i = n - 1; i >= 0; i--) {
		if (same[a[i]] == true)continue;
		if (calc(a[i]) == true) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
set<int> s;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(s.count(x)){
			s.erase(x);
		}
		else s.insert(x);
		
	}
	cout<<s.size();
	return 0;
}


Measured memory_bytes: 4864
n = int(input())
a = []
b  =[]
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)

num = 0
for i in reversed(range(n)):
    a[i] += num
    p = a[i] % b[i]
    if p == 0:
        continue
    p = b[i] - p
    num += p

print(num)

Measured memory_bytes: 16368
#file a.py
lis = [int(input()) for x in range(5)]
k = int(input())

for _ in range(1,5):
    for x in range(5-_):
        ans_flag = lis[x] - lis[_]

        if abs(ans_flag) > k:
            flag = 0
        else:
            flag = 1

if flag == 0:
    print(':(')
else :
    print('Yay!')

Measured memory_bytes: 3060
import itertools
def solve(n, p, q):
    p = tuple(p)
    q = tuple(q)
    v = [i+1 for i in range(n)]
    for i, x in enumerate(itertools.permutations(v)):
        if p == x:
            a = i
        if q == x:
            b = i
    return abs(a-b)

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
print(solve(n, p, q))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long k,n;
    cin>>k>>n;
    long a[n];
    for(long i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int d=INT_MAX;
    int st,ed;
    st=min(k-(a[1]-a[0]),a[n-1]-a[0]);
    d=st;
    for(int i=1;i<n-1;i++)
    {
        if(d>(k-(a[i+1]-a[i])))
            d=k-(a[i+1]-a[i]);
        if(d>(k-(a[i]-a[i-1])))
            d=k-(a[i]-a[i-1]);
    }
    cout<<d;



}


Measured memory_bytes: 5204
def count_div(num, mod):
    cnt = 0
    r = 0
    while r == 0:
        q, r = divmod(num, mod)
        if r == 0:
            num = q
            cnt += 1

    return cnt

n = int(input())
a = [int(v) for v in input().split()]

ans = 0
for v in a:
    ans += count_div(v, 2)
print(ans)

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s.at(i)=='R')
        {
            tmp++;
        }
        else
        {
            tmp = 0;
        }
        ans = max(tmp,ans);
    }
    
    

    cout << ans << endl;
}


Measured memory_bytes: 3616
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

const long mod = 1_000_000_007;

void main(){
	long h = read.to!long;
	long w = read.to!long;
	long k = read.to!long;
	
	// 解説見て考えた
	// HWK(K + 1)(K - 1)P(N - 2, K - 2) / 3 + P(H + W, K)K(K + 3) / 2
	
	long a = h * w; a %= mod;
	a *= k, a %= mod;
	a *= k + 1, a %= mod;
	a *= k - 1, a %= mod;
	a *= perm(h + w - 2, k - 2), a %= mod;
	a *= inv(3), a %= mod;
	
	long b = perm(h + w, k);
	b *= k, b %= mod;
	b *= k + 3, b %= mod;
	b *= inv(2), b %= mod;
	
	long ans = a + b; ans %= mod;
	
	ans.writeln;
}

// mod p における乗法逆元
long inv(long x){
	assert(x > 0);
	assert(x < mod);
	static long[] _inv = [0, 1];
	while(x >= _inv.length){
		_inv ~= _inv[mod % $] * (mod - mod / _inv.length) % mod;
	}
	return _inv[x];
}

// 順列 P
long perm(long n, long k){
	long ans = 1;
	for(long i = 0; i < k; i ++){
		ans *= n - i;
		ans %= mod;
	}
	return ans;
}

/*

交差点の個数で捉えると、1回の切断のスコアは
 (交差点の個数) + (割線の本数) + 1
と読み替えられる

長さKの操作列のうちのi回目である場合、そのスコアは
 (i回目での交差点の個数) + i + 1

よって、長さKの操作列のスコアは
 = Σ[i] (i回目での交差点の個数) + K(K + 3) / 2

求めるものは、P(N, K)種類ある操作列すべてにわたる和

 Σ[操作列]( Σ[i] (i回目での交差点の個数) + K(K + 3) / 2 )

 = Σ[操作列]( Σ[i] Σ[交差点](i回目以前に登場? 1: 0) + K(K + 3) / 2 )
 
 = Σ[交差点]( Σ[操作列, i](i回目以前に登場? 1: 0) ) + Σ[操作列]( K(K + 3) / 2 )

前半を求めるために、縦線aと横線bの交わる交差点に注目する

aの登場する位置、bの登場する位置を同じa、bで表すとしたとき、
「a < b <= i となるような操作列およびiのとり方が何通りあるか」
である

それは
・ＡとＢと(K - 2)個の□を並べ、そのうちの１個を黒く塗ったとき
　黒よりも右側にＡもＢもない場合の数
と考えればよく、
それは 2(1 + 3 + 6 + 10 + 15) のような形の和である。
 
つまり Σ[i in [1, K - 1]]( i(i + 1) / 2 ) であり
 K(K + 1)(K - 1) / 3
さらに□に文字をはめると考えると、 K(K + 1)(K - 1)P(N - 2, K - 2) / 3

交差点はHW個あるので、先程の前半と言っていたものは

 HWK(K + 1)(K - 1)P(N - 2, K - 2) / 3

求めるものは

 HWK(K + 1)(K - 1)P(N - 2, K - 2) / 3 + P(H + W, K)K(K + 3) / 2

たとえば
H = 2, W = 1, K = 2のとき

 P(2 + 1, 2) 2 (4 - 4 + 3) 2 1 / 3(2 + 1)(2 + 1 - 1) + P(2 + 1, 2) 2 5 / 2
 = 6 2 3 2 1 / 3 3 2 + 6 2 5 / 2
 = 4 + 30
 = 34

*/


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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3564
using System;
using System.Linq;

class P
{
    static void Main()
    {
        Console.WriteLine(Enumerable.Repeat(0, int.Parse(Console.ReadLine())).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).OrderByDescending(x => x[0] + x[1]).Select((x, y) => new Tuple<long[], int>(x, y)).Aggregate(0L, (x, y) => y.Item2 % 2 == 0 ? x + y.Item1[0] : x - y.Item1[1]));
    }
}


Measured memory_bytes: 25396
N,M= map(int,input().split())
A= list(map(int,input().split()))
summ=sum(A)
A.sort(reverse=True)

cnt=0
for num in A:
  if num >= summ/(4*M):
    cnt+=1
  else:
    break

if cnt>=M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

vector<int> g[1001];
int c[1010][1010];
vector<int> ans;

void dfs(int s,int cnt,int f){
    for(int t:g[s]){
        if(c[f][t]>cnt){
            c[f][t]=cnt;
            dfs(t,cnt+1,f);
        }
    }
}

void dfs2(int s,int f){
    ans.push_back(s);
    int to=-1;
    int mi=1e6;
    for(int t:g[s]){
        if(t==f)return;
        if(mi>c[t][f]){
            mi=c[t][f];
            to=t;
        }
    }
    dfs2(to,f);
}

int main(){
    int n,m; cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
    }
    for(int i=0;i<1001;i++){
        for(int j=0;j<1001;j++){
            c[i][j]=1e9;
        }
    }
    for(int i=0;i<n;i++){
        dfs(i,1,i);
    }
    int mi=1e9; int s=-1;
    for(int i=0;i<n;i++){
        if(mi>c[i][i]){
            mi=c[i][i];
            s=i;
        }
    }
    if(s==-1){
        cout << -1 << endl;
        return 0;
    }
    dfs2(s,s);
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        cout << ans[i]+1 << endl;
    }
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    int a,b,ans = 0; cin >> a >> b;
    
    for(int i = a;i<=b;i++){
        string s = to_string(i);
        int n = s.size();
        bool ok = true;
        for(int j=0;j<n/2;j++){
            if(s[j] != s[n-j-1]){
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}

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

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

ll W[2],H[2],X[2],Y[2];
ll R;

ll field[2][600][600];
ll dist[2][600][600];

ll dx[] = {0,1,0,-1};
ll dy[] = {-1,0,1,0};

bool check(){
    ll sum = 0;
    for (int k = 0;k < 2;k++){
        for (int i = 0;i < 600;i++){
            for (int j = 0;j < 600;j++){
                dist[k][i][j] = -1;
            }
        }
        for (int i = 1;i <= H[k];i++){
            for (int j = 1;j <= W[k];j++){
                dist[k][i][j] = INT_MAX;
            }
        }
        queue<P> que;
        que.push(P(Y[k],X[k]));
        dist[k][Y[k]][X[k]] = field[k][Y[k]][X[k]];
        while(que.size()){
            P p = que.front(); que.pop();
            int cy = p.first, cx = p.second;
            for (int i = 0;i < 4;i++){
                int ny = cy+dy[i];
                int nx = cx+dx[i];
                int cost = max(field[k][ny][nx],dist[k][cy][cx]);
                if( dist[k][ny][nx] > cost){
                    dist[k][ny][nx] = cost;
                    que.push(P(ny,nx));
                }
            }
        }
    }
    return sum >= R;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
    cin >> R;
    if(R == 0) break;

    for (int k = 0;k < 2;k++){
        cin >> W[k] >> H[k] >> X[k] >> Y[k];
        for (int i = 1;i <= H[k];i++){
            for (int j = 1;j <= W[k];j++){
                cin >> field[k][i][j];
            }
        }
    }

    check();

    map<int,int> cnt[2];

    for (int k = 0;k < 2;k++){
        //cin >> W[k] >> H[k] >> X[k] >> Y[k];
        for (int i = 1;i <= H[k];i++){
            for (int j = 1;j <= W[k];j++){
                cnt[k][dist[k][i][j]]++;
            }
        }
    }

    vector<P> sum[2];

    sum[0].push_back(P(0,0));
    sum[1].push_back(P(0,0));

    for (int k = 0;k < 2;k++){
        for(auto&& i:cnt[k]){
            sum[k].push_back(P(sum[k][sum[k].size()-1].first+i.second,i.first));
        }
    }

    int ans = INT_MAX;

    for (int i = 0;i < sum[0].size();i++){
        ll now = sum[0][i].first;
        //cout << sum[0][i].first << " " << sum[0][i].second << endl;
        ll rem = R-now;
        ll idx = lower_bound(sum[1].begin(),sum[1].end(),P(rem,0))-sum[1].begin();
        //cout << idx << endl;
        if(idx == sum[1].size()) continue;
        //cout << rem << " " << sum[1][idx].first << endl;
        if(sum[1][idx].first+now >= R){
            ans = min(ans,sum[0][i].second+sum[1][idx].second);
        }
    }

    cout << ans << endl;}

    return 0;

}


Measured memory_bytes: 25940
#include<stdio.h>

int c = 0;

void merge(int[], int, int, int);
void mergeSort(int[], int, int);

int main(){

  int i, n, S[500000];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    scanf("%d",&S[i]);
  mergeSort(S, 0, n);
  for(i = 0 ; i < n-1 ; i++)
    printf("%d ", S[i]);
  printf("%d\n",S[i]);
  printf("%d\n",c);
  
  return 0;
}

void merge(int A[],int left,int mid,int right){

  int n1, n2;
  int i, j, k;
  int R[260000], L[260000];

  n1 = mid - left;
  n2 = right - mid;
  for(i = 0 ; i < n1 ; i++)
    L[i] = A[left+i];
  for(i = 0 ; i < n2 ; i++)
    R[i] = A[mid + i];
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  j = 0;
  for(k = left ; k < right ; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i += 1;
    }
    else{
      A[k] = R[j];
      j += 1;
    }
    c++;
  }
}

void mergeSort(int A[],int left,int right){

  int mid = 0;
  
  if((left + 1) < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4520
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	string S, T;
	cin >> S >> T;

	int s, t;
	vector<int> to(26, -1), back(26, -1);
	for(int i=0; i<S.size(); i++){
		s = S[i] - 'a';
		t = T[i] - 'a';
		if(to[s] != -1 || back[t] != -1){
			if(to[s] != t || back[t] != s){
				cout << "No" << endl;
				return 0;
			}
		}
		to[s] = t;
		back[t] = s;
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 776
#include<stdio.h>

int main(void){

long int a,b,c,k,n,max;

scanf("%ld%ld%ld",&a,&b,&c);
scanf("%ld",&k);

if(a <= b)  max = b;
else max = a;

if(max <= c ) max = c;

n = max;

for(int i = 0; i < k; i++) n *= 2;

printf("%ld",a+b+c+n-max);
return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    char a[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];

    int rmh[h] = {0}, rmw[w] = {0};
    rep(i, h) {
        bool rm = true;
        rep(j, w) if (a[i][j] == '#') rm = false;
        if (rm) rmh[i] = 1;
    }

    rep(i, w) {
        bool rm = true;
        rep(j, h) if (a[j][i] == '#') rm = false;
        if (rm) rmw[i] = 1;
    }

    rep(i, h) {
        if (!rmh[i]) {
            rep(j, w) if (!rmw[j]) cout << a[i][j];
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<int>> RGB(3);
    rep(i, N)
    {
        if (S[i] == 'R')
        {
            RGB[0].push_back(i);
        }
        if (S[i] == 'G')
        {
            RGB[1].push_back(i);
        }
        if (S[i] == 'B')
        {
            RGB[2].push_back(i);
        }
    }
    ll ans = 0;
    ans = RGB[0].size() * RGB[1].size() * RGB[2].size();
    rep(i,N){
        repX(j,N,i+1){
            if(S[i]==S[j])continue;
            int k = j*2-i;
            if(k >= N || S[k] == S[i] || S[k] == S[j])continue;
            ans --;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
const int MAXN=1e5+1e4;
vector<int> G[MAXN];
int dp[MAXN];
int dfs(int u)
{
    if (dp[u]!=-1) return dp[u];
    dp[u]=0;
    for (int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        dp[u]=max(dfs(v)+1,dp[u]);
    }
    return dp[u];
}
int main()
{
    int n,m;
    cin >> n >>m;
    for (int i=0;i<m;i++)
    {
        int x,y;
        cin >>x >> y;
        --x,--y;
        G[x].push_back(y);
    }
    memset(dp,-1,sizeof(dp));
    for (int i=0;i<n;i++)
    {
        dfs(i);
    }
    cout << *max_element(dp,dp+n) << endl;
    return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>

int main(void){
	int a,b,c,d;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	 if(b>c){
		d=b;
		b=c;
		c=d;
	 }
	if(a>b){
		d=a;
		a=b;
		b=d;
	} if(b>c){
		d=b;
		b=c;
		c=d;
	} if(a>c){
		d=a;
		a=c;
		c=d;
	} 
	printf("%d %d %d\n",a,b,c);
	return 0;
}
	

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, a[MAXN];
main() {
    N = read();
    for(int i = 1; i <= N; i++) a[i] = read();
    sort(a + 1, a + N + 1);
    int mn = 0, mx = 0, num;
    a[0] = -1;
    for(int i = 1; i <= N; i++) 
        if(a[i] != a[i - 1]) {
            if(!mn) mn = a[i];
            else if(!mx) mx = a[i], num = i - 1;
            else {puts("No"); return 0;}
        }
    if(!mx) {
        if((mn == N - 1) || (mn * 2 <= N)) puts("Yes");
        else puts("No");
    } else {
        if((mx == mn + 1) && (2 * (mx - num) <= N - num) && (mx - num > 0)) puts("Yes");
        else puts("No");
    }
}

Measured memory_bytes: 640
gets
a = gets.chomp.split(" ").map(&:to_i)
c1 = a.count {|i| i % 2 != 0}
c2 = a.count {|i| i % 2 == 0 && i % 4 !=0 }
c4 = a.count {|i| i % 4 == 0}

if c2 > 0 && c1 <= c4 || c2 == 0 && c1 <= c4 + 1
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.

int main(){   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI n,i,j;cin>>n;
      double a[n+1];
      fo(i,1,n+1) cin>>a[i];
      double dp[n+1];  //  dp[i] is probabilty of getting exactly i heads
      dp[0]=1;
      fo(i,1,n+1){
        dp[i]=a[i]*dp[i-1];
        rfo(j,i-1,-1){   //  j is number of heads
          dp[j]*=1-a[i];
          if(j!=0) dp[j]+=dp[j-1]*a[i];
        }
      }
      double ans=0;
      fo(i,n/2+1,n+1) ans+=dp[i];
      cout<<fixed<<setprecision(10)<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.LinkedHashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String[] arrayStr = sc.next().split("");

	    Set<String> linkedHashSet = new LinkedHashSet<String>();

	    for (int i = 0; i < arrayStr.length; i++) {
	    	
	    linkedHashSet.add(arrayStr[i]);
	    
	    }
	    
	    Object[] strings_after = linkedHashSet.toArray();
	    
	    if(strings_after.length == 2 ) {
	    	
	    	System.out.println("Yes");
	    	
	    } else {
	    	
	    	System.out.println("No");
	    }

	  }

}


Measured memory_bytes: 21844
import bisect

n=int(input())
arr=list(map(int,input().split()))
acum=[0]
for i in range(n):
  acum.append(acum[-1]+arr[i])
ans=10**18
for i in range(2,n-1):
  suma=acum[i]
  sumb=acum[n]-suma
  posa=bisect.bisect_right(acum,suma//2)
  diffa=10**18
  if posa>=2:
    mina=min(acum[posa-1],acum[i]-acum[posa-1])
    maxa=max(acum[posa-1],acum[i]-acum[posa-1])
    diffa=maxa-mina
  if posa!=i:
    tmina=min(acum[posa],acum[i]-acum[posa])
    tmaxa=max(acum[posa],acum[i]-acum[posa])
    tdiffa=tmaxa-tmina
    if tdiffa<diffa:
      diffa=tdiffa
      mina=tmina
      maxa=tmaxa
  posb=bisect.bisect_right(acum,suma+sumb//2)
  diffb=10**18
  if posb>=i+2:
    minb=min(acum[posb-1]-acum[i],acum[n]-acum[posb-1])
    maxb=max(acum[posb-1]-acum[i],acum[n]-acum[posb-1])
    diffb=maxb-minb
  if posa!=n+1:
    tminb=min(acum[posb]-acum[i],acum[n]-acum[posb])
    tmaxb=max(acum[posb]-acum[i],acum[n]-acum[posb])
    tdiffb=tmaxb-tminb
    if tdiffb<diffb:
      diffb=tdiffb
      minb=tminb
      maxb=tmaxb
  ans=min(ans,max(maxa,maxb)-min(mina,minb))
print(ans)

Measured memory_bytes: 112816
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        a: [u64;n]
    }

    let mut v = a;
    let mut cnt = 0;
    'outer: loop {
        for i in 0..n {
            if v[i] % 2 == 0 {
                v[i] /= 2;
            } else {
                break 'outer;
            }
        }
        cnt += 1;
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
import sys

f_i = sys.stdin

n = int(f_i.readline())

adj = [[]] * n
for x in f_i:
    x = list(map(int, x.split()))
    adj[x[0]] = [c_v for c_v in zip(x[3::2], x[2::2])]

import heapq

def dijkstra():
    PQ = [(0, 0)]
    isVisited = [False] * n
    distance = [999900001] * n

    distance[0] = 0
    
    while PQ:
        uc, u = heapq.heappop(PQ)

        if uc > distance[u]:
            continue

        isVisited[u] = True
        
        for vc, v in adj[u]:
            if isVisited[v] == True:
                continue
            t_cost = distance[u] + vc
            if t_cost < distance[v]:
                distance[v] = t_cost
                heapq.heappush(PQ, (t_cost, v))

    for v, d in enumerate(distance):
        print(v, d)


dijkstra()

Measured memory_bytes: 70260
def main():
    N = int(input())
    S = [int(input()) for _ in range(N)]
    S.sort()
    total = sum(S)
    if total % 10 != 0:
        print(total)
    else:
        for s in S:
            if s % 10 != 0:
                print(total - s)
                return
        print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1000000)

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

vis_N = [-1]*(N+1)
count = 0
vis_N[1] = 1

def search(a):
    global count,vis_N,vis_Nij
    #print(count,vis_N)
    if sum(vis_N)+1 == N:
        count = count + 1
        return# count#print(count,"A",i)
    
    for i in range(M):
        if (P[i][0] == a and vis_N[P[i][1]] == -1) or (P[i][1] == a and vis_N[P[i][0]] == -1):
            if P[i][0] == a:
                nxt = P[i][1]
            else:
                nxt = P[i][0]
            #vis_N[a] = 1
            vis_N[nxt] = 1
            search(nxt)
            vis_N[nxt] = -1
    
    return# count

search(1)
print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main ()
{
	int n, h, m, s;
	
	scanf("%d", &n );
	h = n/3600;
	m = (n - h * 3600 )/60;
	s = n - h * 3600 - m * 60 ;
	printf("%d:%d:%d\n",h ,m ,s);
	return 0;

} 



Measured memory_bytes: 2756
import sys
import numpy as np

#%% Smart Solution

input = sys.stdin.readline

H, W = map(int, input().split())

status = np.full((H, W), H*W, dtype=int)
for i in range(H):
    for j, c in enumerate(input()):
        if c == "#":
            status[i,j] = 0


for h in range(1, H):
    status[h, :] = np.minimum(status[h, :], status[h-1, :] + 1)
for h in range(0, H-1)[::-1]:
    status[h, :] = np.minimum(status[h, :], status[h+1, :] + 1)
for w in range(1, W):
    status[:, w] = np.minimum(status[:, w], status[:, w-1] + 1)
for w in range(0, W-1)[::-1]:
    status[:, w] = np.minimum(status[:, w], status[:, w+1] + 1)

print(np.max(status))

Measured memory_bytes: 22332
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string C = "Christmas";
  string E = " Eve";
  
  int dig = 0;
  
  cin >> dig;
  cout << C ;
  
  for(int i = 0;i < (25-dig);i++)
    cout << E;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    int n=0;
    char s[10001];
    scanf("%d%s",&n,s);
    for(int i=0;i<strlen(s);i++){
        s[i]+=n;
        if(s[i]>'Z'){
            s[i]-=26;
        }
    }
    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque
import copy
import math
import numpy as np

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def divisor_sub(p, q):
    a = []
    for i in xrange(0, q + 1):
        a.append(p ** i)
    return a

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff

def divisor(n):
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    if N == 1:
        print M
        exit()
    if is_prime(M):
        print 1
        exit()
    div_list = divisor(M)
    div_list.sort(reverse = True)

    for num in div_list:
        if M % num == 0 and M/num >= N:
            print num
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 16120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> g[100005];
int main() {
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> v(n,-1);
  queue<int> q;
  auto push = [&](int u,int c){
    if(v[u]!=-1)return;
    v[u]=c;
    q.push(u);
  };
  push(0,0);
  push(n-1,1);
  while(!q.empty()){
    int s = q.front(); q.pop();
    for(int t:g[s]) push(t,v[s]);
  }
  int c = 0;
  rep(i,n) if(v[i]==0) ++c;
  bool ans = c > n-c;
  cout << (ans?"Fennec":"Snuke") << endl;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
 
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
 
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;
#define N 2 
int getMin(int x, int y) { return (x<y)? x: y; } 

signed main() {
 
	fastio();
	//#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string n;
	int k;
	cin>>n;
	cin>>k;
	vector<int> dp(k,0),dp1(k,0);
	dp1[0]=1;
	int res=0;
	for(int i=0;i<n.length();i++)
	{
		vector<int> new_dp(k,0),new1_dp(k,0);
		for(int a=0;a<=9;a++)
		{
			for(int j=0;j<k;j++)
			{
				new_dp[(a+j)%k]+=dp[j];
				new_dp[(a+j)%k]%=MOD;
				if(a<(n[i]-'0'))
					new_dp[(a+j)%k]+=dp1[j],new_dp[(a+j)%k]%=MOD;
			}
		}
		res+=(n[i]-'0');
		res%=k;
		new1_dp[res]=1;
		dp=new_dp;
		dp1=new1_dp;
		//cout<<dp[0]<<" "<<dp1[0]<<endl;
	}
	if(res==0)
		dp[0]+=1;
	cout<<(dp[0]-1+MOD)%MOD;
	return 0;

 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a[111];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int ret = 999999999;
	for(int i = -100; i <= 100; i++) {
		int sum = 0;
		for(int j = 0; j < n; j++) sum += (a[j] - i) * (a[j] - i);
		ret = min(ret, sum);
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	std::string S; std::cin >> S;
	if (S == "ABC")std::cout << "ARC";
	else std::cout << "ABC";

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 3600
s=input()
t=input()
n = len(s)
ans = 10**9
for i in range(n):
    v = 0
    for j in range(len(t)):
        if j+i >= n: break
        if s[j+i] != t[j]: v+=1
    else:
        ans = min(ans,v)

print(ans)

Measured memory_bytes: 73404
#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
    return 0<=a&&a<=5000;
}
int main(){
    while(cin>>n&&n){
        int x[5000],y[5001],an=0;
        for(int i=0;i<n;i++)cin>>x[i]>>y[i],p[x[i]][y[i]]=1;
        for(int i=0;i<n;i++)
            for(int j=i;j<n;j++){
                int dx=x[i]-x[j],dy=y[i]-y[j];
                int x1=x[i]-dy,y1=y[i]+dx,x2=x[j]-dy,y2=y[j]+dx;
                int x3=x[i]-dy,y3=y[i]+dx,x4=x[j]+dy,y4=y[j]-dx;
                if(c(x1)&&c(y1)&&p[x1][y1]&&c(x2)&&c(y2)&&p[x2][y2])
                    an=max(an,dx*dx+dy*dy);
                if(c(x3)&&c(y3)&&p[x3][y3]&&c(x4)&&c(y4)&&p[x4][y4])
                    an=max(an,dx*dx+dy*dy);
            }
        cout<<an<<endl;
    }
    return 0;
}

Measured memory_bytes: 22624
s = int(input())

a = int(s**0.5) + 1
b = int(s**0.5)
c = a**2 - s
d = s - b**2


ans_list = [0]*6

if d != 0:
    if c > d:
        ans_list = [0,1,b,0,d,b+1]
    else:
        ans_list = [0,0,a,1,c,a]
elif d == 0:
    ans_list = [0,0,b,0,0,b]

print(*ans_list)

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
using namespace std;
#define ll long long 
const int maxn=300010;
const ll tim=1000010;
int n,m,tot;
struct node{
    int p,v;
};
node h[maxn],l[maxn];
bool operator < (const node &a,const node &b){
    return a.v<b.v;
}
int ra,rb; int ans=0;
set<ll> s;
int main(){
    scanf("%d%d%d",&n,&m,&tot);
    for (int i=1;i<=n;++i) h[i].p=i;
    for (int j=1;j<=m;++j) l[j].p=j;
    for (int i=1;i<=tot;++i){
        scanf("%d%d",&ra,&rb);
        h[ra].v++; l[rb].v++;
        s.insert((ll)ra*tim+rb);
    }
    sort(h+1,h+1+n); sort(l+1,l+1+m);
    int tmp=h[n].v;
    for (int j=1;j<=m;++j){
        ans=max(ans,tmp+l[j].v+(s.count((ll)h[n].p*tim+l[j].p)?-1:0));
    }
    tmp=l[m].v;
    for (int i=1;i<=n;++i){
        ans=max(ans,tmp+h[i].v+(s.count((ll)h[i].p*tim+l[m].p)?-1:0));
    }
    cout<<ans;
}

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

int main() {
	int n,m,i,j;
	cin >> n;
	vector<int> x(n+1);
	for(i=0; i<n; i++){
		cin >> x[i];
	}
	x[n]=2020;
	cin >> m;
	for(j=0; j<m; j++){
		cin >> i; i--;
		if(x[i]+1<x[i+1]){
			x[i]++;
		}
	}
	for(i=0; i<n; i++){
		cout << x[i] << endl;
	}
}


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

int main(){
  int N;
  int a[100];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  sort(a, a+N);
  int Alice = 0;
  int Bob = 0;
  for(int i = 0; i < N; i++){
    if(i%2 == 0){
      Alice += a[N-i-1];
    }
    else{
      Bob += a[N-i-1];
    }
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rp(i, s, e) for(int i = s; i < e; i++)

long double distance(int p1[2], int p2[2]){
	return sqrt(pow(p1[0]-p2[0], 2) + pow(p1[1]-p2[1], 2));
}

int factorial(int n){
	if(n==1)
		return 1;
	return n*factorial(n-1);
}

int main() {
	int n;
	cin >> n;
	int permu[n], point[n][2];
	long double total = 0;
	rp(i, 0, n){
		permu[i] = i;
	}
	rp(i, 0, n){
		cin >> point[i][0] >> point[i][1];
	}

	do{
		rp(i, 0, n-1){
			total += distance(point[permu[i]], point[permu[i+1]]);
		}
	}while(next_permutation(permu, permu+n));
	
	cout << setprecision(10) << total/factorial(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 998244353
#define PI 3.14159265358979323846
#define N 300005
using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
  // cin>>t;
    //int c=0;
    while(t--) {
        ll i,n;
        cin>>n;
        for(i=0;i<n;i++)
            cout<<"ACL";
    }

}


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

int main(){
  int n,t; cin>>n>>t;
  bool flag = 0;
  int ans=1000;
  for(int i=0; i<n; i++){
    int c,time; cin>>c>>time;
    if(time<=t){
      flag = 1;
      ans = min(ans,c);
    }
  }
  if(flag) cout << ans << endl;
  else cout << "TLE" << endl;
}

Measured memory_bytes: 384