akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        while(true){
            int s = 0;
            int n = scan.nextInt();
            int x = scan.nextInt();
            
            if(n == 0){
                break;
            }
            
            for(int i = 1; i <= n; ++i){
                for(int j = i + 1; j <= n; ++j){
                    for(int k = j + 1; k <= n; ++k){
                        if(i + j + k == x){
                            ++s;
                        }
                    }
                }
            }
            
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 26480
import sys, heapq
from collections import defaultdict
def input():
	return sys.stdin.readline()[:-1]

class DijkstraList():
	#隣接リスト版
	#同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ
	def __init__(self, adj, start):
		self.list = adj
		self.start = start
		self.size = len(adj)

	def solve(self):
		#self.dist = [float("inf") for _ in range(self.size)]
		self.dist = defaultdict(lambda :10**30)
		self.dist[self.start] = 0
		#self.prev = [-1 for _ in range(self.size)]
		self.q = []
		self.cnt = 0

		heapq.heappush(self.q, (0, self.start))

		while self.q and self.cnt < self.size:
			u_dist, u = heapq.heappop(self.q)
			if self.dist[u] < u_dist:
				continue
			for v, w in self.list[u]:
				if self.dist[v] > u_dist + w:
					self.dist[v] = u_dist + w
					#self.prev[v] = u
					heapq.heappush(self.q, (self.dist[v], v))
			self.cnt += 1
		return

	def distance(self, goal):
		return self.dist[goal]

n, m = map(int, input().split())
cost = [10**30 for _ in range(n)]
edges = defaultdict(list)
for _ in range(m):
	p, q, t = map(int, input().split())
	edges[p-1 + t * n].append((q-1 + t * n, 0))
	edges[q-1 + t * n].append((p-1 + t * n, 0))
	if len(edges[p-1 + t * n]) == 1:
		edges[p-1 + t * n].append((p-1 + 0 * n, 0))
		edges[p-1 + 0 * n].append((p-1 + t * n, 1))
	if len(edges[q-1 + t * n]) == 1:
		edges[q-1 + t * n].append((q-1 + 0 * n, 0))
		edges[q-1 + 0 * n].append((q-1 + t * n, 1))

d = DijkstraList(edges, 0)
d.solve()
res = d.distance(n-1)
if res > 10**20:
	print(-1)
else:
	print(res)

Measured memory_bytes: 213820
package main

import (
	"fmt"
)

func main() {
	var N string
	fmt.Scan(&N)
	if N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin >> s;
    reverse(s.begin(),s.end());
    long long lol[2019] = {0},p=1,ans=0,t=0;
    lol[0]=1;
    for(char c:s){
        t = (t + (c-'0')*p)%2019;
        ans+=lol[t];
        p = (p*10)%2019;
        lol[t]++;
    }
    cout << ans;
}

Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    ll n, q; cin >> n >> q;
    ll a[100010]; rep(i,0,n) cin >> a[i];
    ll sum = 0;
    int j = 0, ans = INF;
    rep(i,0,n) {
        if(sum < q) {
            sum += a[i];
        }
        
        if(sum >= q) {
            while(sum >= q && j != n) {
                ans = min(ans, i-j+1);
                sum -= a[j++];
            }
        }
    }
    if(ans == INF) ans = 0;
    cout << ans << endl;
    return 0;
}

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

int main(void){
  string w;
  int i;
  cin >> w;
  for(i = 0; i < 26; i++){
    if(count(w.begin(), w.end(), 'a'+i)%2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]
score = sum(S)
if score % 10 != 0:
    print(score)
    exit()
R = [s for s in S if s % 10 != 0]
if len(R) == 0:
    print(0)
    exit()
print(score - min(R))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll ans = floorl(a*min(b-1,n)/b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

bool mycmp(tuple<string,int,int> a, tuple<string,int,int> b) {
	if (get<0>(a) == get<0>(b))
		return get<1>(a) > get<1>(b);
	return get<0>(a) < get<0>(b);
}

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

	int n;
	cin >> n;
	vector<tuple<string,int,int>> r(n);
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		r[i] = make_tuple(s, p, i+1);
	}
	sort(all(r), mycmp);
	for (auto x : r) cout << get<2>(x) << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  int flg = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a < 0) flg ^= 1;
    b[i] = abs(a);
  }
  sort(all(b));
  b[0] *= 1 - 2 * flg;
  ll ans = 0LL;
  rep(i, n) ans += b[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N, M = map(int, input().split())
S = input()
T = input()


def gcd(a, b):
    # type: (int, int) -> int
    "最大公約数を計算する．0とか負の数が入るとヤバい"
    if b%a == 0:
        return a
    return gcd(b%a, a)


d = gcd(N, M)
n = N // d
m = M // d


for i in range(d):
    if S[i*n] != T[i*m]:
        print(-1)
        exit()
print(n*m*d)


Measured memory_bytes: 40176
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let lr = (0..n)
        .map(|_| (sc.read(), sc.read()))
        .collect::<Vec<(i64, i64)>>();

    let mut left = lr
        .iter()
        .enumerate()
        .map(|(i, &(l, _))| (l, i))
        .collect::<Vec<(i64, usize)>>();
    left.sort();
    left.reverse();
    let left = left.iter().map(|&(_, i)| i).collect::<Vec<_>>();
    let mut right = lr
        .iter()
        .enumerate()
        .map(|(i, &(_, r))| (r, i))
        .collect::<Vec<(i64, usize)>>();
    right.sort();
    let right = right.iter().map(|&(_, i)| i).collect::<Vec<_>>();

    let ans1 = solve(&left, &right, &lr);
    let ans2 = solve(&right, &left, &lr);
    println!("{}", cmp::max(ans1, ans2));
}

fn solve(left: &Vec<usize>, right: &Vec<usize>, lr: &Vec<(i64, i64)>) -> i64 {
    let n = lr.len();
    let mut ans = 0;
    let mut left_iter = left.iter();
    let mut right_iter = right.iter();
    let mut used = vec![false; n];
    let mut cur = 0;
    while let Some(&index) = left_iter.next() {
        if used[index] {
            continue;
        }
        used[index] = true;
        let (left, right) = lr[index];
        if cur < left {
            ans += left - cur;
            cur = left;
        } else if right < cur {
            ans += cur - right;
            cur = right;
        }

        while let Some(&index) = right_iter.next() {
            if used[index] {
                continue;
            }
            used[index] = true;
            let (left, right) = lr[index];
            if cur < left {
                ans += left - cur;
                cur = left;
            } else if right < cur {
                ans += cur - right;
                cur = right;
            }
            break;
        }
    }
    ans + cur.abs()
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i <= (n + 3) / 4; i++) {
        for (int j = 0; j <= (n + 6) / 7; j++) {
            if (4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			string S = Console.ReadLine();
			int len = S.Length;
			string ans = "";

			for (int i = 0; i < len; i++)
			{
				ans += (char)((S[i] + N - 'A') % 26 + 'A') + "";
			}
			Console.WriteLine(ans);
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 46040
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
string str;
int main()
{
  getline(cin,str);
  int k = str.size();
  for(int i = 0;i < k;i++){
    if(str[i]=='p'&&str[i+1]=='e'&&str[i+2]=='a'&&str[i+3]=='c'&&str[i+4]=='h'){
      str[i] ='a';
      str[i+1]='p';
      str[i+2]='p';
      str[i+3]='l';
      str[i+4]='e';
    }else if(str[i]=='a'&&str[i+1]=='p'&&str[i+2]=='p'&&str[i+3]=='l'&&str[i+4]=='e'){
      str[i]='p';
      str[i+1]='e';
      str[i+2]='a';
      str[i+3]='c';
      str[i+4]='h';
    }
  }
  cout <<str<<endl;
  return 0;
}

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

int main(void) {
    int a, b, c, d, l, r;
    cin >> a >> b >> c >> d;
    l=a+b;
    r=c+d;
    if(l>r)
        cout << "Left" << endl;
    else if(l<r)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, q; std::cin >> n >> q;
  string s; std::cin >> s;
  vi cnt(n);
  rep(i, n-1) {
    if (s[i] == 'A' && s[i+1] == 'C') cnt[i]++;
  }
  srep(i, 1, n) cnt[i] += cnt[i-1];
  rep(i, q) {
    int l, r; std::cin >> l >> r;
    --l, --r;
    int ans = cnt[r];
    if (r+1 < n && s[r] == 'A' && s[r+1] == 'C') ans--;
    if (l > 0) ans -= cnt[l-1];
    std::cout << ans << "\n";
  }
}


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

int main(){
	int S;
	cin>>S;
	
	int a,b,c,d;
	d=S%10;
	c=(S/10)%10;
	b=(S/100)%10;
	a=S/1000;
	
	int X,Y;
	X=a*10+b;
	Y=c*10+d;
	
	if(1<=X&&X<=12&&1<=Y&&Y<=12){
		cout<<"AMBIGUOUS"<<endl;
		return 0;
	}
	else if(0<=X&&X<=99&&1<=Y&&Y<=12){
		cout<<"YYMM"<<endl;
		return 0;
	}
	else if(1<=X&&X<=12&&0<=Y&&Y<=99){
		cout<<"MMYY"<<endl;
		return 0;
	}
	else
		cout<<"NA"<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    ll sum = 0;
    for(int i=0; i<N; i++){
        if(i%2==0){
            sum+=A[i];
        }
        else{
            sum-=A[i];
        }
    }
    ll p = sum/2;
    cout << 2*p << " ";
    for(int i=1; i<N; i++){
        cout << 2*(A[i-1]-p) << " ";
        p = A[i-1]-p;
    }
}

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

int main(){
    string s,t;
    string S,T;
    int i,j;
    char r;
    cin >> s >> t;
    vector<char> a(s.size()),b(t.size());
    REP(i,s.size()){
        a.at(i)=s.at(i);
    }
    REP(i,t.size()){
        b.at(i)=t.at(i);
    }
    REP(i,s.size()){
        for(j=1;j+i<s.size();j++){
            if(a.at(i)>a.at(i+j)){
                r=a.at(i+j);
                a.at(i+j)=a.at(i);
                a.at(i)=r;
            }
        }
    }
    REP(i,t.size()){
        for(j=1;j+i<t.size();j++){
            if(b.at(i)<b.at(i+j)){
                r=b.at(i+j);
                b.at(i+j)=b.at(i);
                b.at(i)=r;
            }
        }
    }
    REP(i,a.size()){
        s.at(i)=a.at(i);
    }
    REP(i,b.size()){
        t.at(i)=b.at(i);
    }
    //cout << s << t << endl;
    if(s<t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> mx(N,inf);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        chmin(mx[a],b);
    }
    int line = mx[0];
    int cnt = 0;
    for(int i=1; i<N; i++){
        if(line == i){
            cnt++;
            line = mx[i];
        }else{
            chmin(line,mx[i]);
        }
    }
    cout << cnt << enld;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;
LL gcd(LL a,LL b){
	if(a < b) swap(a,b);
	return b == 0 ? a : gcd(b,a % b);
}

int main(){
    //ios_base::sync_with_stdio(false);
	LL n,m;
	while(~scanf("%lld%lld",&n,&m)){
		LL ans = gcd(n,m);
		printf("%lld %lld\n",ans,n / ans * m);
	}


    return 0;
}

Measured memory_bytes: 3144
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var s = ReadLine();
        WriteLine($"{s.Substring(0, 4)} {s.Substring(4)}");
    }
}


Measured memory_bytes: 13140
#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int n,x[4],y[4];
	int c[4][4];
	while(cin >> n, n) {
		rep(k,n) {
			rep(i,4) {
				cin >> x[i];
			}
			rep(i,4) {
				cin >> y[i];
			}
			rep(i,4) {
				rep(j,4) {
					c[i][j] = x[i]*y[j];
				}
			}
			cout <<	c[0][0]-c[1][1]-c[2][2]-c[3][3] << " "
				 << c[0][1]+c[1][0]+c[2][3]-c[3][2] << " "
				 << c[0][2]-c[1][3]+c[2][0]+c[3][1] << " "
				 << c[0][3]+c[1][2]-c[2][1]+c[3][0] << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <string>
#include <tuple>

std::vector<size_t> dp(std::vector<std::pair<int, int>> const& magic) {
  size_t inf = 1e9;
  std::vector<size_t> res(100001, inf);
  res[0] = 0;
  for (size_t i = 0; i < res.size(); ++i) {
    for (size_t j = 0; j < magic.size(); ++j) {
      // if (i + magic[j].second >= res.size()) continue;
      size_t ni = std::min(i+magic[j].second, res.size()-1);
      res[ni] = std::min(res[ni], res[i] + magic[j].first);
    }
  }
  for (size_t j = res.size(); j-- > 1;)
    res[j-1] = std::min(res[j-1], res[j]);
  return res;
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<size_t> hp(n);
  for (auto& hi: hp) scanf("%zu", &hi);

  size_t m;
  scanf("%zu", &m);
  std::vector<std::pair<int, int>> magic_s, magic_a;  // {mp, damage}
  for (size_t i = 0; i < m; ++i) {
    char tg;
    int mp, dmg;
    scanf("%*s %d %c%*s %d", &mp, &tg, &dmg);
    if (tg == 'S') {
      magic_s.emplace_back(mp, dmg);
    } else if (tg == 'A') {
      magic_a.emplace_back(mp, dmg);
    } else {
      assert(false);
    }
  }

  std::vector<size_t> dp_s = dp(magic_s);
  std::vector<size_t> dp_a = dp(magic_a);
  size_t res = 1e9;
  for (size_t i = 0; i <= 100000; ++i) {
    size_t cur = dp_a[i];
    for (size_t j = 0; j < n; ++j) {
      if (hp[j] <= i) continue;
      cur += dp_s[hp[j] - i];
    }
    res = std::min(res, cur);
  }
  printf("%zu\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 4004
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;


string S;
long long N, L, a, b, i, j, Ans = 0, c, d;
long long judge1, judge2, judge3;
int main() {
	cin >> a >> b >> c >> d;
	L = c * d;

	judge2 = b / c - a / c;
	if (a%c == 0)
		judge2 += 1;
	judge3 = b / d - a / d;
	if (a%d == 0)
		judge3 += 1;
	long long tmp;

	if (c < d) {
		tmp = c;
		c = d;
		d = tmp;
	}
	long long r;
	r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}
	L = L / d;

	judge1 = b / L - a / L;
	if (a%L == 0)
		judge1 += 1;

	//	cout << judge1 << endl << judge2 << endl << judge3;
	Ans = b - a - (judge2 + judge3 - judge1) + 1;

	cout << Ans << endl;
	return 0;
}


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

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int count = 0;
		int test = 0;
	    char sli[];
	    char pli[];
	    //int count[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    //count = new int[p.length()];
	    
	    for(int i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(int i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(int i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				//System.out.println(sli[j+i]+ "=="+ pli[j]);
				if(sli[j+i] == pli[j]){
		        	
					count++;
					//System.out.println(count);
					//System.out.println((s.length())/2);
					//System.out.println(p.length());
		        	
				}
				else{
					
					count = 0;
				
				}
				
				//System.out.println("!");	
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	}

}

Measured memory_bytes: 26084
N, MOD = int(input()), 10**9+7
dp = [[[[0]*4 for i in range(4)] for j in range(4)] for k in range(N+1)]
A, G, C, T = 0, 1, 2, 3

# 初期化
for i in range(4):
    for j in range(4):
        for k in range(4):
            if k == A and j == G and i == C: continue
            if k == A and j == C and i == G: continue
            if k == G and j == A and i == C: continue
            dp[3][k][j][i] = 1

for index in range(4,N+1):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if k == A and j == G and i == C:
                        continue
                    if k == G and j == A and i == C:
                        continue
                    if l == A and j == G and i == C:
                        continue
                    if l == A and k == G and i == C:
                        continue
                    if k == A and j == C and i == G:
                        continue
                    dp[index][k][j][i] += dp[index-1][l][k][j]
                    dp[index][k][j][i] = dp[index][k][j][i]%MOD
                    
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][k][j][i]
            ans %= MOD
print(ans)





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

int main(){
  int N;
  cin>>N;
  
  while(true){
    int n=N;
    int a,b,c;
    
    a=n%10;
    n/=10;
    b=n%10;
    n/=10;
    c=n;
    
    if(a==b && b==c && c==a){
      cout<<N;
      break;
    }
    
    N++;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> v(n, 0);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    sum += v[i];
  }
  int cnt = n;
  x -= sum;
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    if(x / v[i] > 0){
      cnt += x / v[i];
      x -= (x / v[i]) * v[i];
    }
    else{
      break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > a;
    for(int i = 0;i < n;i++)
    {
      int A;
      cin >> A;
      a.push_back(make_pair(A,i+1));
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++)
    {
      cout << a[i].second << " ";
    }
    cout << endl;
}


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

#define int long long

int n, a[200010];

signed main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];

    }
    sort(a + 1, a + 1 + n);

    for(int i = 1; i < n; i++)
    {
        if(a[i] == a[i + 1])
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


Measured memory_bytes: 1792
#incited numpy source code from 'https://atcoder.jp/contests/abc155/submissions/10155744'

import numpy

n,k=map(int,input().split())
arr=list(map(int,input().split()))
nc=0
zc=0
pc=0
for i in range(n):
  if arr[i]<0:
    nc+=1
  elif arr[i]==0:
    zc+=1
  else:
    pc+=1
ncc=nc*pc
zcc=zc*(nc+pc)+(zc*(zc-1))//2
pcc=(nc*(nc-1))//2+(pc*(pc-1))//2
if ncc<k<=(ncc+zcc):
  print(0)
else:
  arr=numpy.array(arr,dtype=int)
  ms=numpy.msort(numpy.abs(arr[arr<0]))
  ps=numpy.msort(arr[arr>0])
  if k<=ncc:
    k=ncc-k
    l=0
    r=10**18+1
    while r-l!=1:
      mid=(l+r)//2
      cnt=numpy.searchsorted(ps,mid//ms,side='right')
      if cnt.sum()>k:
        r=mid
      else:
        l=mid
    print(-r)
  elif k<=(ncc+zcc):
    print(0)
  else:
    l=0
    r=10**18+1
    k-=(ncc+zcc)
    while r-l!=1:
      mid=(l+r)//2
      cnt1=numpy.searchsorted(ps,mid//ps,side='right')
      dup1=ps**2<=mid
      cnt2=numpy.searchsorted(ms,mid//ms,side='right')
      dup2=ms**2<=mid
      if (cnt1.sum()-dup1.sum()+cnt2.sum()-dup2.sum())//2>=k:
        r=mid
      else:
        l=mid
    print(r)

Measured memory_bytes: 32324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int mod_pow(int x, int y, int m = mod) {
	int res = 1;
	x %= m;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod ;
}
signed main() {
	int n,a,b;cin>>n>>a>>b;
	int ans=mod_pow(2,n)-1;
	ans-=comb(n,a);ans=(ans+mod)%mod;
	ans-=comb(n,b);ans=(ans+mod)%mod;
	cout<<ans<<endl;
}



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


int main(){
int i,a,t;
cin>>a;
while(a!=0){
t=0;
while(t<9){
//  if(a==0)
//         break;

    cin>>i;
    a=a-i;
    t++;
}
cout<<a<<'\n';
cin >> a;

}
 return 0;

}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	s := nextString()

	if s[0] == s[1] && s[1] == s[2] {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 640
require 'matrix'
loop do
  s = gets.chomp.chop
  break if s == ''
  
  s.gsub!(/([A-Z)][a-z]*)(?![a-z\d])/, '\11')
  s.gsub!(/\((.+?)\)(\d*)/){
    as, n = $1, $2
    as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * n.to_i}"}
  }
  atoms = s.scan(/[A-Z][a-z]?/).uniq
  l = s.split('->')[0].count('+') + 1
  molecules = s.split(/\->|\+/)
  m = molecules.size - 1
  n = atoms.size
  
  a = Matrix.build(n, m){|y, x|
    molecules[x].scan(/#{atoms[y]}(\d+)/).map{ |d|
      x < l ? d[0].to_i : -d[0].to_i
    }.reduce(:+).to_r
  }
  
  b = [0] * n
  atoms.each do |atom|
    molecules[-1].scan(/(#{atom})(\d+)/).each{ |a, k|
      b[atoms.index(a)] = k.to_r
    }
  end

  ans = a.lup.solve(b).to_a[0,m] + [1.to_r]
  lcm = ans.map(&:denominator).reduce(&:lcm)
  puts ans.map{|x| (x * lcm).to_i} * ' '
end

Measured memory_bytes: 10132
#include<iostream>
#include<stdio.h>
using namespace std;
int main(void){
  int N;
  cin>>N;
  char temp;
  bool flag=false;
  for (int i=0;i<N;i++){
    cin>>temp;
    if (temp=='Y'){
      flag=true;
    }
  }
  if (flag) cout<<"Four";
  else cout<<"Three";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'

/*
	For Debugging we have define TRACE.
*/

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif  

const int N = 1e7 + 5;
int a[N];
int reach [10000001];

void solve(){

	int l,r,d;
	cin>>l>>r>>d;
	int cnt = 0;
	for(int i=l;i<=r;i++){
		if(i%d == 0) cnt++;
	}
	cout<<cnt;

}
 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    IOS;

    solve();


}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>
 
using namespace std;
 
int main()
{
    long long int N, C, K;
    if (scanf("%lld%lld%lld", &N, &C, &K) < 3) return 0;
 
    long long int lateT = 0;
    long long int busCnt = 0;
    long long int busPsn = 0;
 
    vector<long long int> vi;
 
    for (int i = 0; i < N; i++)
    {
        long long int T;
 
        if (scanf("%lld", &T) < 1) return 0;
 
        vi.push_back(T);
    }
 
    sort(vi.begin(), vi.end());
 
    for (int i = 0; i < N; i++)
    {
        if (0 < busPsn && K < vi[i] - lateT)
        {
            busCnt++;
            busPsn = 0;
            lateT = vi[i];
        }
        else if (busPsn == 0)
        {
            lateT = vi[i];
        }
 
        busPsn++;
 
        if (C == busPsn)
        {
            busCnt++;
            busPsn = 0;
        }
        else if (i == N - 1)
        {
            busCnt++;
        }
    }
 
    printf("%lld\n", busCnt);
    return 0;
}

Measured memory_bytes: 1400
using System;
using static System.Console;
using System.Linq;

class Program
{
    public static void Main()
    {
        string s = ReadLine();
        string t = ReadLine();

        char[] s2 = s.ToArray();
        char[] t2 = t.ToArray();

        Array.Sort(s2);
        Array.Sort(t2); Array.Reverse(t2);

        string s3 = new string(s2);
        string t3 = new string(t2);

        if (s3.CompareTo(t3) < 0)
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 13532
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0, b = 0;
    rep(i, n) if(s[i] == 'R') r++; else b++;
    string yes = "Yes", no = "No";
    if(r > b) cout << yes << '\n';
    else cout << no << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
using namespace std;

const int NMAX = 100010;
vector <int> adia[NMAX];
int dp[NMAX];
bool taken[NMAX];
int grad[NMAX];

void get_sortop(int nod)
{
    taken[nod] = 1;
    dp[nod]++;
    for (auto i : adia[nod]) {
        dp[i] = max(dp[i], dp[nod]);
        grad[i]--;
        if (grad[i] == 0)
            get_sortop(i);
    }
}

int main()
{
    int n, m, a, b;
    scanf("%d%d", &n, &m);

    while (m--) {
        scanf("%d%d", &a, &b);
        adia[a].push_back(b);
        grad[b]++;
    }

    for (int i = 1; i <= n; i++)
        if (!grad[i] && !taken[i])
            get_sortop(i);

    int ans = 0;

    for (int i = 1; i <= n; i++)
        ans = max(ans, dp[i]);

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


    return 0;
}


Measured memory_bytes: 9728
k,s = map(int, input().split())

l = 0

if s <= k:
  l = int((s+2)*(s+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs; }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

ll modpow(ll a, ll n, ll p) {
  ll res = 1;
  while (n) {
    if (n&1) res = res * a % p;
    a = a * a % p;
    n >>= 1;
  }
  return res;
}

constexpr ll MOD = 1e9+7;

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) {
    cin >> a[i];
  }

  modint<MOD> ans = 0;

  rep(i, n) {
    ans += a[i]%MOD*(n-1);
  }

  rep(i, 60) {
    ll cnt = 0;
    rep(j, n) {
      if (a[j] & 1LL<<i) cnt++;
    }
    ans -= modpow(2, i+1, MOD)*(cnt*(cnt-1)/2);
  }

  cout << ans.a << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (ll i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    string N,S,A;
    ll K;
    ll ans=INF;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>K;
    int a,cnt=1;
    cin>>a;
    REP(i,10){
        if(a==i&&cnt<K){cin>>a;cnt++;}
        else if(a!=i){A+=to_string(i);}
    }
    DEB(A)END
    for(int i=stoi(N);i<stoi(N)*10+10;i++){
        string T=to_string(i);
        bool ok=true;
        for(auto x:T){
            bool f=true;
            DEB(x)END
            for(auto y:A){
                DEB(y)
                if(x==y)f=false;
            }
            if(f){ok=false;break;}
            END
        }
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   long int m,d1,m2,d2;
   cin>>m>>d1>>m2>>d2;

   if(m == 2)
      cout<<(d1 == 28);
  else if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
      cout<<(d1 == 31);
  else
    cout<<(d1 == 30);

   return 0;
}

Measured memory_bytes: 256
ds = []
total_time = 0
for i in range(5):
    d = int(input())
    if d % 10 == 0:
        total_time += d
    else:
        total_time += (d // 10 + 1) * 10
        ds.append(d % 10)
if len(ds) > 0:
    total_time = total_time - 10 + sorted(ds)[0]
print(total_time)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
 
signed main(){

    string s;
    cin >> s;
    if(s.size() < 3){
        cout << 0 << endl;
        return 0;
    }
    int cnta = 0;
    int ans = 0;
    for(int i = 0;i < s.size()-1;i++){
        if(s[i] == 'A')cnta++;
        else{
            if(cnta == 0)continue;
            else{   
                if(s[i] == 'B' && s[i+1] == 'C'){
                    ans += cnta;
                    i++;
                }else{
                    cnta = 0;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc034.contest.atcoder.jp/tasks/agc034_b

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[][][] mem = new int[4][3][10];
    int n = sc.nextInt(),b,f,r,v;
    for(int i = 0;i < 4;i++){
      for(int j = 0;j < 3;j++){
        for(int k = 0;k < 10;k++){
          mem[i][j][k]=0;
        }
      }
    }
    for(int i=0;i < n;i++){
      b = sc.nextInt();
      f = sc.nextInt();
      r = sc.nextInt();
      v = sc.nextInt();
      mem[b-1][f-1][r-1] += v;
    }
    for(int i = 0;i < 4;i++){
      for(int j = 0;j < 3;j++){
        for(int k = 0;k < 10;k++){
          System.out.print(" " + mem[i][j][k]);
        }
        System.out.println("");
      }
      if(i != 3)System.out.println("####################");
    }
    sc.close();
  }
}


Measured memory_bytes: 29468
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {

    string A,S,C;
    cin >> A>>S>>C;
    
    cout << 'A'<<S[0]<<'C' << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};

int main() {
    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.size(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    tmp = x%y
    while not tmp == 0:
        x = y
        y = tmp
        tmp = x%y
    return y
N = int(input())
A = list(map(int,input().split()))
hp = A[0]
for i in A:
    hp = gcd(hp,i)
print(hp)

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

int main() {
  int N;
  int64_t D;
  cin >> N >> D;
  int cnt = 0;
  for (int i; i < N; i++) {
    int64_t X, Y;
    cin >> X >> Y;
    if (X * X + Y * Y <= D * D) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N,u,v;
	cin >> N >> u >> v;
	u--;v--;
	vector<ll> A(N-1),B(N-1);
	vector<ll> G[N];
	FOR(i,0,N-1){
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}

	vector<ll> disu(N,INF),disv(N,INF);
	queue<ll> d,id,cl;
	id.push(u);
	d.push(0);
	disu[u] = 0;
	while(d.size()){
		ll ID = id.front();
		ll XX = d.front();
		id.pop();d.pop();
		for(auto nex:G[ID]){
			if(disu[nex]==INF){
				disu[nex] = XX+1;
				id.push(nex);
				d.push(XX+1);
			}
		}
	}


	d=cl;id=cl;
	id.push(v);
	d.push(0);
	disv[v] = 0;
	while(d.size()){
		ll ID = id.front();
		ll XX = d.front();
		id.pop();d.pop();
		for(auto nex:G[ID]){
			if(disv[nex]==INF){
				disv[nex] = XX+1;
				id.push(nex);
				d.push(XX+1);
			}
		}
	}

	ll ans = 0;
	FOR(i,0,N){
		if(G[i].size()==1 && (disu[i]<disv[i])){
			ans = max(ans,disv[i]);
		}
	}

	cout << ans-1 << endl;
}

Measured memory_bytes: 9728