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

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define modp(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

char S[100100];

int main(int argc, char* argv[])
{
	scanf("%s", S);
	int l = strlen(S);

	int count[3] = {};
	for(int i = 0; i < l; i++) count[S[i] - 'a']++;
	int m = iinf;
	for(int i = 0; i < 3; i++) m = min(m, count[i]);
	bool flag = true;
	for(int i = 0; i < 3; i++)
		if(count[i] > m + 1) flag = false;
	printf("%s\n", flag ? "YES" : "NO");

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>
#include <vector>
 
int main(int argc, char* argv[])
{
    std::vector<long> ans;

    long n;
    scanf("%ld", &n);

    if(n==0) {
        printf("0\n");
        return 0;
    }

    while(n != 0) {
        if( n % 2 == 0 ) {
            ans.push_back( 0 );
            n = n / (-2);
        }
        else {
            ans.push_back( 1 );
            n -= 1;
            n = n / (-2);
        }

    }

    long i;
    for(i=0; i<ans.size(); i++) {
        printf("%d", ans[(long)ans.size()-i-1]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

#define MAX_N 5000

int main(){
    int n, ans = 0, in, before;
    while(std::cin >> n, n){
        std::cin >> before;
        ans = before;
        for(int i = 1; i < n; ++i){
            std::cin >> in;
            before = std::max(in, before + in);
            ans = std::max(before, ans);
        }
        std::cout << ans << std::endl;
        ans = 0, before = 0;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364;

int main(){
	long long n,x; cin>>n>>x;
	long long a[n],ans=LINF;
	rep(i,n){
		cin>>a[i];
		ans=min(ans,abs(a[i]-x));
		a[i]-=x;
	}
	for(int i=ans;i>0;i--){
		bool flg=1;
		for(int j=0;j<n;j++){
			if(a[j]%i!=0){
				flg=0;
				break;
			}
		}
		if(flg){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main(){
	int  n,x;
	scanf("%d",&n);
	if(n*100%108 != 0){
		if( ((n*100/108+1)*108)/100 <= n)printf("%d\n",(n*100/108+1));
		else printf(":(\n");
	}else{
		printf("%d\n",n*100/108);
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int prev = -1;
    s += 'Q';
    forn (i, 0, s.size() + 1) {
        if (!good(s[i])) {
            if (prev != -1)
                ans = max(ans, i - prev);
            prev = -1;
        }
        if (prev == -1 && good(s[i]))
            prev = i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int x,y;
    while(true){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x < y){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
 
    return 0;
}


Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
long long num[200005];
map<long long,long long> m;
int main(){
	long long i,n,ans=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&num[i]);
		m[num[i]-i]++;
	}
	for(i=1;i<=n;i++){
		m[num[i]-i]--;
		ans+=m[-num[i]-i];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 27620
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e18;
const ll inf=1e18;
const double eps=1e-8;
const double pi=acos(-1);

ll dp[203040];
ll sum[203040];
int main(){
    TB
    mst(dp)mst(sum)
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    dp[n-1]=(s[n-1]-'0')%p;
    ll pp=10;
    if(p==2||p==5){
        ll sum=0;
        fd(s.length()){
            ll k=s[i]-'0';
            if(k%p==0) sum+=i+1;
        }
        cout<<sum<<'\n';
        return 0;
    }
    fx(0,s.length()-1){
        ll k=s[i]-'0';
        k=(k*pp)%p;
        dp[i]=(k+dp[i+1])%p;
        pp*=10;
        pp=pp%p;
        //deg(dp[i])
    }
    fd(s.length()){
        sum[dp[i]]++;
    }
    ll ans=0;
    fd(p){
        ans+=(sum[i]*(sum[i]-1)/2);
    }
    ans+=sum[0];
    cout<<ans<<'\n';
    return 0;
}


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

#define ll long long
#define ar array
#define endl "\n"

int main(){
    //
    //freopen("input.txt", "r", stdin);
    //
    ios::sync_with_stdio(0);
    cin.tie(0);

    int s, w;
    cin>>s>>w;
    if (w>=s){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }
}

Measured memory_bytes: 3632
n = gets.chomp.to_i
an = gets.chomp.split.map(&:to_i)
lcm = 1
an.each do |ai|
  lcm = lcm.lcm(ai)
end
ans = 0
an.each do |ai|
  ans += lcm / ai
end
puts ans % (1e9 + 7).to_i

Measured memory_bytes: 56888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    cin >> a;
    sort(all(a), greater{});
    int c = 0;
    for(int i = 0; i < N; i += 2)c += a[i];
    int sum = SUM(a);
    int d = sum - c;
    cout << c - d << endl;
}


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

int main(){
	int N;
	cin >> N;
	
	vector<int> Ass(N), Bss(N);
	
	for(int i = 0;i < N;i++){
		cin >> Ass.at(i);
	}
	
	bool flag = false;
	int cnt = 0;
	
	for(int j = 0;j < N+1;){
		Bss.at(j)++;
		int k = Bss.at(j);
		j = Ass.at(j)-1;
		cnt++;
		
		if(j==1){
			break;
		}
		else if(k>1){
			cnt = -1;
			break;
		}
		else{
			continue;
		}
	
	cout << cnt << endl;
	}
	
	cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;

const int N=200000;

int n,v[N+5];
ll sol=0;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    if(v[1]!=0)
    {
        puts("-1");
        return 0;
    }
    for(int i=2;i<=n;i++)
    {
        int lst=v[i-1];
        if(lst+1==v[i])
        {
            sol++;
            continue;
        }
        if(lst+1>v[i])
        {
            sol+=v[i];
            continue;
        }
        puts("-1");
        return 0;
    }
    cout<<sol;
    return 0;
}
/**



**/


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

int main()
{
    int N;
    cin >> N;
    map<int, int> A;
    rep(i, N)
    {
        int a;
        cin >> a;
        A[a - 1]++;
        A[a]++;
        A[a + 1]++;
    }
    //    int M = A.size();
    int ans = 0;
    for (auto x : A)
    {
        ans = max(ans, x.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    string ans = "Yes";
    if (N%2==1) ans = "No";    
    for (int i=0;i<N/2;i++){ 
        if (S[i]!=S[i+N/2]) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# B - Buffet
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

level = 0
for i in range(N):
    level += B[A[i] - 1]
    if i != 0 and A[i] == A[i - 1] + 1:
        level += C[A[i] - 2]

print(level)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[200000];
int cnt, xor2;
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int j = 0;
	for (int i = 0; i < n; i++) {
		cnt += a[i];
		xor2 ^= a[i];
		if (cnt == xor2)ans += i - j + 1;
		else {
			while (1) {
				xor2 ^= a[j];
				cnt -= a[j];
				j++;
				if (xor2 == cnt) {
					ans += i - j + 1;
					break;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
# input
n, m = map(int, input().split())
persons = []
checks = []
for i in range(n):
    point = tuple(map(int, input().split()))
    persons.append(point)
for i in range(m):
    point = tuple(map(int, input().split()))
    checks.append(point)

# print(persons)
# print(checks)
    
def get_distance(person, check):
    return abs(person[0] - check[0]) + abs(person[1] - check[1])
    
for i in range(n):
    min_distance = 10 ** 10
    min_distance_point_num = -1

    # calculate min distance from n to each m
    for j in range(m):
        distance = get_distance(persons[i], checks[j])
        if distance < min_distance:
            min_distance = distance
            min_distance_point_num = j + 1

    print(min_distance_point_num)


Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <limits>
#include <iomanip>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AProgrammingEducation {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;in>>n;
        if(n==1){
            out<<"Hello World"<<endl;
        } else {
            int a,b;in>>a>>b;
            out<<a+b<<endl;
        }
	}
};


int main() {
	AProgrammingEducation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

const int MAXN=2e3+1;

int n,x,y,ans[MAXN];

int main() {
	cin>>n>>x>>y;
	if(x>y) swap(x,y);
	for(int i=1,j,dis; i<n; ++i)
		for(j=i+1; j<=n; ++j) {
			if(i<=x) {
				if(j<=x) ++ans[j-i];
				else if(j<=y) ++ans[min(j-i,x-i+y-j+1)];
				else ++ans[min(x-i+j-y+1,j-i)];
			} else if(i<=y) {
				if(j<=y) ++ans[min(j-i,i-x+y-j+1)];
				else ++ans[min(j-i,i-x+1+j-y)];
			} else ++ans[j-i];
		}
	for(int i=1; i<n; ++i) cout<<ans[i]<<endl;
	return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n;
  cin >> n;
  FOR(i,1,3501)FOR(j,1,3501){
    int64 a = n * i * j;
    int64 b = 4 * i * j - n * (i + j);
    if(b > 0 && a % b == 0){
      cout << i << " " << j << " " << a/b << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3660
if __name__ == '__main__':
	s = input()
	K = int(input())

	subs = set()
	if len(s) <= 50:
		for f in range(len(s)):
			for t in range(f, len(s)+1):
				subs.add(s[f:t])
	else:
		for f in range(len(s)):
			for t in range(f, f+6):
				subs.add(s[f:t])

	l = list(subs)
	l.sort()
	print(l[K])


Measured memory_bytes: 4464
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();

    rep(loop, n) {
        string u = s[n-1] + s.substr(0, n-1);
        if(u == t) {
            out("Yes");
            re0;
        }
        s = u;
    }
    
    out("No");
    re0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;
string k;
int n,m,ans;

signed main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		ans+=k;
		cout<<ans<<endl;
	}
	else{
		ans+=a;
		k-=a;
		if(b>=k){
			cout<<ans<<endl;
		}
		else{
			k-=b;
			ans-=k;
			cout<<ans<<endl;
		}
	}
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int a, b;
    cin >> a >> b;
    if(a+b>=10) cout << "error" << endl;
    else cout << a+b << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,X,T,yu,t;
int main() 
{
    cin>>N>>X>>T;
	if (N<=X) cout<<T;
	  else{
	   yu=(N+X-1)/X; 
	   t=yu*T;
	   cout<<t;
     }
return 0;	
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 3005;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int dp[MX][MX];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    string S,T; cin >> S >> T;

    int N = sz(S);
    int M = sz(T);

    F0R(i,N+1) F0R(j,M+1) {
        if (i == 0 || j == 0) {
            dp[i][j] = 0; continue;
        }
        if (S[i-1] == T[j-1]) {
            dp[i][j] = dp[i-1][j-1]+1;
        } else {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

    string res = "";

    int i,j; i = N; j = M;
    while(i > 0 && j > 0) {
        if (S[i-1] == T[j-1]) {
            res = S[i-1]+res; i--,j--;
        } else if (dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }

    cout << res << "\n";
}


Measured memory_bytes: 35456
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	int A, B, C, X, sum,ans;
	ans = 0;
	cin >> A >> B >> C >> X;
	for (int i = 0; i <= A; i++) {
		sum = 0;
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				sum = 500 * i + 100 * j+50*k;
			
				if (sum == X)ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    ll A, B; cin >> A >> B;
    if (A % 2 == B % 2) {
        cout << (A+B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
 
    return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(a >= b)
    cout << "delicious" << endl;
  else if(a+x >= b)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

//**************Problem A**************
int main() {

	int X = 0;
	int A = 0;
	int B = 0;

	cin >> X >> A >> B;

	
	cout << (X - A) % B << endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (auto& x : h) cin >> x;
  sort(h.rbegin(),  h.rend());

  long long ans = 0;
  for (int i = k; i < n; i++) ans += h[i];
  cout << ans<< endl;
}

Measured memory_bytes: 1024
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    n = int(input())
    ts = map(int, input().split())

    total = 0
    pre = 0
    for t in ts:
        d = max(pre - t, 0)
        total += d
        pre = t + d

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 25204
H,W = map(int,input().split())

s = [input() for i in range(H)]

def draw(i,j):
	if j>0 and s[i][j-1] == "#":
		return "Yes"
	if j<W-1 and s[i][j+1] == "#":
		return "Yes"
	if i>0 and s[i-1][j] == "#":
		return "Yes"
	if i<H-1 and s[i+1][j] == "#":
		return "Yes"
	return "No"

ans = "Yes"
for i in range(H):
	for j in range(W):
		if s[i][j] == "#":
			ans = draw(i,j)
			if ans == "No":
				print(ans)
				exit()

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>

int main(){
	std::stack<int> st;

	//car's number
	int num = 0;

    //Until the end of input
	while(std::cin >> num){
        //if num = 0, output and delete
		if(num == 0){
			std::cout << st.top() << std::endl;
			st.pop();
        //if num != 0, input    
		} else {
			st.push(num);
		}
	}
}

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

double D[86411];
int N,L;

const double eps = 1e-8;

bool check(double x){
  double pr = (double)L;
  // printf("x = %.9lf\n",x);
  for(int i=0;i<86400;i++){
    pr = min( pr - D[i] + x ,(double)L);
    if( pr < -eps ) return false;
  } 
  double tmp = pr;
  for(int i=0;i<86400;i++){
    pr = min( pr - D[i] + x ,(double)L);
    if( pr < -eps ) return false;
  } 
  if( abs(tmp - pr) < eps ) return true; 
  return false;
}

int main(){
  while( cin >> N >>L && (N||L) ){

    for(int i=0;i<=86400;i++)
      D[i] = 0.0f;
   
    for(int i=0;i<N;i++){
      int s,t,u;
      cin>> s >> t >> u;
      for(int j=s;j<t;j++){
	D[j] = (double)u;
      }
    }


    double st = 0.0, ed = (double)1000000.0;
    for(int i=0;i<100;i++){
      double h = (st + ed)/2.0;
      if( check(h) ){
	ed = h;
      } else {
	st = h;
      }
    }
    printf("%.9lf\n",st);
  }
}

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

int main() {
  int N,K,ans,p;
  cin >>N>>K;
  p=N;
  ans=1;
  vector<int>a(K);
  for(int i=0;i<K;i++){
    cin>>a[i];
  }
  while(ans!=0){
    p=N;
    ans=0;
    while(p!=0){
      for(int i=0;i<K;i++){
        if(p%10==a[i]){
          ans++;
        }
      }
      p/=10;
    }
    N++;
  }
  cout<<N-1<<endl;
}

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

int main(){
    
    int n,ans=0;
    cin >> n;
    vi a(n+1),b(n),c(n-1);
    rep(i,0,n)cin >> a[i];
    rep(i,0,n)cin >> b[i];
    rep(i,0,n-1)cin >> c[i];
    a[n] = -1;

    rep (i,0,n){
        ans += b[a[i]-1];
        if(a[i]+1 == a[i+1]){
            ans += c[a[i]-1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007

int main(void){
  ll n;
  cin >> n;
  vector<ll> a;
  vector<int> b(n,0);
  rep(i,n){
    ll tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  ll num2=0,num1=0,num0=0;
  rep(i,n){
    if(a[i]%4==0){
      b[i]=2;
      num2++;
    }else if(a[i]%2==0){
      b[i]=1;
      num1++;
    }else{
      b[i]=0;
      num0++;
    }
  }
  if(num2+1<num0){
    cout << "No";
    return 0;
  }else if(num2+1==num0 && num1>=1){
    cout << "No";
  }else{
    cout<<"Yes";
  }
	return 0;
}

Measured memory_bytes: 1784
k = int(input())
combined = input().split(" ")
a = int(combined[0])
b = int(combined[1])
result = False

while True:
    if a % k == 0:
        result = True
        break
    if a == b:
        break
    a += 1

if result:
    print("OK")
else:
    print("NG")

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

typedef pair<int, int> pi;
typedef vector<pi> vpi;

int N, K;
vector<int> D;
vector<vpi> G;
vector<int> C;

void input_init(void) {
	cin >> N;
	D.resize(N + 1, 0);
	G.resize(N + 1);
	for (int id = 0; id < N - 1; ++id) {
		int a, b;
		cin >> a >> b;
		++D[a];
		++D[b];
		G[a].push_back(make_pair(b, id));
		G[b].push_back(make_pair(a, id));
	}
	K = *max_element(D.begin(), D.end());
	C.resize(N - 1, 0);
}

void paint(int u, int col) {
	for (int i = 0; i < (int)G[u].size(); ++i) {
		int v =  G[u][i].first;
		int id = G[u][i].second;
		if (C[id] != 0) continue;
		++col;
		if (col > K) col = 1;
		C[id] = col;
		paint(v, col);
	}
}

int main(void) {
	input_init();
	paint(1, 0);
	cout << K << '\n';
	for (int id = 0; id < N - 1; ++id)
		cout << C[id] << '\n';
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;

  string l = "", r = s;
  int ans = 0;
  rep(i, 0, n) {
    vector<int> lv(26, 0), rv(26, 0);
    rep(j, 0, (int)l.size()) lv[l[j] - 'a']++;
    rep(j, 0, (int)r.size()) rv[r[j] - 'a']++;
    int c = 0;
    rep(j, 0, 26) if (lv[j] && rv[j]) c++;
    chmax(ans, c);
    l += r[0];
    r = r.substr(1);
  }

  cout << ans << endl;
}


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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int A, B, K;
    cin >> A >> B >> K;
    int count = 0;
    for (int i = min(A, B); i > 0; --i) {
        if ((A % i == 0) && (B % i == 0)) {
            count++;
        }
        if (count == K) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
arr = n.times.map { gets.to_i }

min_v = arr[0]
max_p = -1e9
(1...n).each do |i|
  max_p = [max_p, arr[i] - min_v].max
  min_v = [min_v, arr[i]].min
end

p max_p


Measured memory_bytes: 8916
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = s_input()

    count = 0

    for s in n:
        count += int(s)

    print('Yes' if int(n)%count==0 else 'No')
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 77116
#include <bits/stdc++.h>
using namespace std;
#define int long long 

signed main(){
  int n,k;
  cin>>n>>k;
  int a[n]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }   
  for(int i=k;i<n;i++){
    if(a[i-k]<a[i]){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

 


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

int main(){
    int n;
    cin >>n;
    vector<int> a(n);
    int mx = -1;
    rep(i,n){
        cin >>a[i];
        mx = max(a[i],mx);
    }
    int mn = 9999999;
    for(int i = 0;i <= mx;i++){
        int sum = 0;
        for(int j = 0; j<n;j++){
           int tmp = pow(a[j]-i, 2); 
           sum += tmp;
        }
      
        mn = min(sum,mn);
    }
    cout <<mn<<endl;

}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;

int main(){
    ll n; cin >> n;
    vector<vpl> a(n);
    rep(i,n){
        ll t; cin >> t;
        rep(j,t){
            ll x,y; cin >> x >> y; x--;
            a[i].emplace_back(x,y);
        }
    }
    ll ans = 0;
    rep(bit,1<<n){
        bool flag = true;
        rep(i,n){
            for(auto j : a[i]){
                if(bit & (1<<j.first)){
                    if(bit & (1<<i)){
                        if(j.second==0) flag = false;
                    }
                }else{
                    if(bit & (1<<i)){
                        if(j.second==1) flag = false;
                    }
                }
                if(!flag) break;
            }
            if(!flag) break;
        }
        ll cnt = 0;
        if(flag){
            rep(i,n) if(bit&(1<<i)) cnt++;
        }
        chmax(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x[10], i, j, k, n, m;
    int high1, high2, high3;
    
    for(i=0; i<10; i++)
    {
        scanf("%d", &x[i]);
    }
    
    high1 = 0;
    high2 = 0;
    high3 = 0;
    
    for(i=0; i<10; i++)
    {
        if(high1 <= x[i])
        {
           high1 = x[i];
           n = i;
        }
    }

    x[n] = 0;
    printf("%d\n", high1);
    
    for(j=0; j<10; j++)
    {
        if(high2 < x[j] && x[j] <= high1)
        {
            high2 = x[j];
            m = j;
         }
    }
    
    x[m] = 0;
    printf("%d\n", high2);
    
    for(k=0; k<10; k++)
    {
        if(high3 < x[k] && x[k] <= high2)
        {
             high3 = x[k];
         }
    }
    
    printf("%d\n", high3);

    return 0;

}



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

int main() {
    ll N; cin >> N;
    ll a[10][10];
    for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) a[i][j] = 0;
    for (int i = 1; i <= N; ++i) {
        // 末尾と先頭を求める
        string s = to_string(i);
        ll head = (int)s[0] - '0';
        ll tail = (int)s[s.size() - 1] - '0';
        a[head][tail]++;
    }
    ll ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            ll cur_ans = a[i][j] * a[j][i];
            if (i != j) cur_ans *= 2;
            ans += cur_ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from fractions import gcd

def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    >>> factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


A, B = map(int, input().split())
cnt = 1
for num, pow in factorize2(gcd(A, B)):
    cnt += 1
print(cnt)



Measured memory_bytes: 65516
def main():
    N, M = map(int, input().split())
    l = []
    for _ in range(M):
        p, s = input().split()
        l.append((int(p), s))
    da = {}
    dp = {}
    p = 0
    a = 0
    for i in range(M):
        if l[i][0] in da:
            continue
        elif l[i][1] == 'AC':
            a += 1
            da[l[i][0]] = True
            if l[i][0] in dp:
                p += dp[l[i][0]]
        else:
            if l[i][0] in dp:
                dp[l[i][0]] += 1
            else:
                dp[l[i][0]] = 1
    print(a, p)
main()


Measured memory_bytes: 28136
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
{
    private static long[,] memo;
    static bool[] th;
    static void Main(string[] args)
    {
        var num = Input.num;
        var adj = Enumerable.Repeat(0, num).Select(v => new List<int>()).ToArray();
        for(var i=0; i < num - 1; i++)
        {
            var inp = Input.ar;
            adj[inp[0] - 1].Add(inp[1] - 1);
            adj[inp[1] - 1].Add(inp[0] - 1);
        }
        memo = new long[num, 2];
        th = new bool[num];
        dp(adj, 0);
        WriteLine((memo[0, 0] + memo[0, 1]) % Input.MOD);
    }
    private static void dp(List<int>[] adj,int index)
    {
        memo[index, 0] = 1;
        memo[index, 1] = 1;
        th[index] = true;
        foreach (var ad in adj[index])
            if (!th[ad])
            {
                dp(adj, ad);
                memo[index, 0] = (memo[ad, 0] + memo[ad, 1]) % Input.MOD * memo[index, 0] % Input.MOD;
                memo[index, 1] = memo[ad, 0] * memo[index, 1] % Input.MOD;
            }
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            while (true) {

                int[] a = NextInts();
                if (a[0] == -1 && a[1] == -1 && a[2] == -1) return;

                Println(rating(a[0], a[1], a[2]));

            }

        }

        public static string rating (int m, int f, int r) {

            if (m == -1 || f == -1) return "F";
            else if (m + f >= 80) return "A";
            else if (m + f >= 65 && m + f < 80) return "B";
            else if (m + f >= 50 && m + f < 65) return "C";
            else if (m + f >= 30 && m + f < 50) {
                if (r >= 50) return "C";
                else return "D";
            }

            return "F";

        }

        public static void Print (Object o) {
            Console.Write(o);
        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

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

        public static string[] NextStrings () {
            return Console.ReadLine().Split();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

        public static double NextDouble () {
            return double.Parse(Console.ReadLine());
        }

    }
}



Measured memory_bytes: 15904
l,r=map(int,input().split())
ans=10000000000
for i in range(l,r):
    for j in range(i+1,r+1):
        p=(i*j)%2019
        ans=min(p,ans)
        if(ans==0):
            break
    else:
        continue
    break
print(ans)

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>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  string s[n];
  rep(i,n){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  ll ans=0;
  map<string,ll> m;
  rep(i,n)m[s[i]]++;
    for (auto i=m.begin();i!=m.end();i++){
      ll x=i->second;
      ans+=x*(x-1)/2;
    }  
  cout << ans << endl;
return 0;}


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

int main(void) {
	int a, b;
	cin >> a >> b;

	if (a > b)
	{
		cout << "a > b" << endl;
	}
	else if (a < b)
	{
		cout << "a < b" << endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int mod = 1e9 + 7;
int pow_mod(int a, int b) {
    if (b == 0) return 1ll;
    int nim = pow_mod(a, b / 2);
    if(b % 2 == 0) {
        return (nim * nim) % mod;
    } else {
        return (a * (nim * nim % mod)) % mod;
    }
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    bool ans = true;
    if(n % 2 == 1 && a[0] != 0 ) ans = false;
    for(int i = n % 2; i < n; i += 2) {
        if(a[i] != a[i + 1]) {
            ans = false;
        }
    }
    if (!ans) {
        cout << "0\n";
    } else {
        cout << pow_mod(2ll, n / 2) << "\n";
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint n;std::cin>>n;
    std::vector<std::string>dp={"a"};
    for(int i=2;i<=n;i++){
        std::vector<std::string>new_dp;
        for(std::string s:dp){
            char max='a';
            for(char c:s)if(max<c)max=c;
            for(char c='a';c<=max+1;c++){
                new_dp.push_back(s+std::string(1,c));
            }
        }
        new_dp.swap(dp);
    }
    for(auto&&s:dp){
        std::cout<<s<<'\n';
    }
}


Measured memory_bytes: 8780
#include<cstdio>

using namespace std;

#define Fx(x) ((x)*(x))

int main(void){
	
	int d;
	while(scanf("%d", &d) != EOF){
		int ans = 0;
		
		for(int i = 1; i < 600/d; i++){
			ans += d * Fx(d*(i));
		}
		
		printf("%d\n",ans);
		
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int sum;
        int max;
        if(A>B) max =B;
        else max =A;
        if(N-(A+B)<0){
            sum = (A+B)-N;
            System.out.println(max +" "+sum);
        }
        else {
            sum = N-(A+B);
            System.out.println(max + " " + 0);
        }
    }
}

Measured memory_bytes: 21844