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

int main(){
    int n;
    cin >> n;
    int best[10] = {};
    for(int i = 1; i < 10; ++i) best[i] = -1e9;

    for(int x; n--; ){
        cin >> x;
        int tmp_best[10] = {};
        for(int j = 0; j < 10; ++j)
            tmp_best[j] = max(best[(j-x%10+10)%10] + x, best[j]);

        for(int j = 0; j < 10; ++j)
            best[j] = tmp_best[j]; }

    int rez = 0;
    for(int i = 1; i < 10; ++i) rez = max(rez, best[i]);
    cout << rez << endl; }


Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A, B, C = nl()

import sys
for i in range(B):
    if (A * (i+1)) % B == C:
        print('YES')
        sys.exit()

print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int 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;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n,m; cin >> n >> m;
    vl a(m); rep(i,m) cin >> a[i];
    ll s = 0;
    rep(i,m) s += a[i];
    if(n-s >= 0) cout << n-s << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<cstdio>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007

#define ARRAY_MAX 55

ll n,x,ans = 0;
ll p[ARRAY_MAX];
ll b[ARRAY_MAX];
ll cnt[ARRAY_MAX];

int main(){

    int x,y,s;
    while(cin >> x >> y >> s,x){
        int maxi = -1;
        for(int i = 1;i <= s;i++){
            for(int j = 1;j <= s;j++){

                int tmp1 = i*(100+x)/100;
                int tmp2 = j*(100+x)/100;
                if(tmp1+tmp2 == s){
                    tmp1 = i*(100+y)/100;
                    tmp2 = j*(100+y)/100;
                    maxi = max(maxi,tmp1+tmp2);
                }
            }
        }
        cout << maxi << endl;
    }


    return 0;
}


Measured memory_bytes: 3068
#include <cstdio>
#include <cstdlib>

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

    if(abs(a - c) <= d){
        printf("Yes\n");
    }else{
        if(abs(a - b) <= d && abs(b - c) <= d){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define INF 20000000010ll

long long minx = INF, maxx = -INF, miny = INF, maxy = -INF, x, y, n;

int main()
{
	scanf("%lld", &n);
	for (int i=1; i<=n; i++)
	{
		scanf("%lld%lld", &x, &y);
		minx = min(minx, x + y), maxx = max(maxx, x + y);
        miny = min(miny, x - y), maxy = max(maxy, x - y);
	}
	printf("%lld\n", max(maxx - minx, maxy - miny));
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = s.size();
    for(int i = 0; i < l; i++){
        s[i] += n;
        if(s[i] - 'A' >= 26) s[i] -= 26;
    }
    cout << s << endl;
}

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

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int x;
    int in;
    std::vector<int> a, b;
    std::cin >> x;
    for (int i = 0; i < x; i++) {
        std::cin >> in;
        a.push_back(in);
    }
    for (int i = 0; i < x; i++) {
        std::cin >> in;
        b.push_back(in);
    }
    int ame;
    int ameMax = 0;
    for(int i = 0; i < x; i++) {
        ame = 0;
        for (int j = 0; j < x; j++) {
            if (j < i)
                ame +=a[j];
            else if(i == j)
                ame += a[j]+b[j];
            else
                ame += b[j];
        }
        if (ame > ameMax)
            ameMax = ame;
    }
    std::cout << ameMax << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
	string a, b;
	cin >> a >> b;

	int n = atoi((a + b).c_str());
	for (int i = 0; i <= sqrt(n); i++) {
		if (i * i == n) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


int main(){
    int N; cin >> N;
    string S; cin >> S;
    vii dp(N+1, vi(N+1, 0));
    int res=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(S[i] == S[j]){
                dp[i+1][j+1]=min(dp[i][j]+1, j-i);
            }
            res=max(res, dp[i+1][j+1]);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 101180
from sys import exit

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

c = {}
for i in D:
    if i in c:
        c[i] += 1
    else:
        c[i] = 1

if c[0] != 1:
    print(0)
    exit()

result = 1
for i in range(1, max(D) + 1):
    if i not in c:
        print(0)
        exit()
    result = result * (c[i - 1] ** c[i]) % 998244353
print(result)

Measured memory_bytes: 18676
import itertools
K = int(input())
K_list = list(range(1, K + 1))
even_list = []
odd_list = []
for i in range(K):
    if K_list[i] % 2 == 0:
        even_list.append(K_list[i])
    elif K_list[i] % 2 == 1:
        odd_list.append(K_list[i])
result = list(itertools.product(even_list, odd_list))
print(len(result))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main(){
	int n; cin >> n;
	vector<long long int> t;

	REP(i, n){
		long long int x; cin >> x;
		t.push_back(x);
	}

	sort(t.begin(), t.end());
	t.erase( unique(t.begin(), t.end()), t.end() );

	long long int ans = t[0];
	
	FOR(i, 1, t.size()){
		ans = lcm(ans, t[i]);
	}

	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<tuple<int, int, int>> vc;
    rep(i,m)
    {
        int p,y;
        cin >> p >> y;
        vc.push_back(make_tuple(p, y, i));
    }
    sort(vc.begin(),vc.end());
    vector<pair<int,int>>ans(m);
    vector<int> counter(n+1,0);
    
    rep(i,m)
    {
        pair<int,int> temp_pair;
        counter[get<0>(vc[i])]++;
        temp_pair.first = get<0>(vc[i]);
        temp_pair.second = counter[get<0>(vc[i])];
        ans[get<2>(vc[i])] = temp_pair;
    }
    rep(i,m)
    {
        cout << setw(6) << setfill('0') << ans[i].first << setw(6) << setfill('0') << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  int cnt = 0;
  int i = 0;
  while(i < n){
    if(s.at(i) == 'R'){
      cnt++;
    }
    else{
      if(ans < cnt ) ans = cnt;
      cnt = 0;
    }
    ++i;
  }
  cout << max(cnt,ans) << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
   char c; cin >> c; cout << (char)(c + 1) << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<stdlib.h>
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) {
    return y == 0 ? x : gcd(y, x%y);
}
int main() {
    ll x, n;
    cin >> n >> x;
    ll t = gcd(x, n);
    ll u = n/t, v = 3*u-3;
    cout << t*v;
    return 0;
}

Measured memory_bytes: 3192
N = int(input())
x = []
for i in range(N):
    s, t = input().split()
    x.append([s, int(t)])

X = input()

count = False
ans = 0
for i in range(N):
    if count:
        ans += x[i][1]
    if x[i][0] == X:
        count = True

print(ans)


Measured memory_bytes: 3060
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  
  for (auto i=1; i<=9; ++i) {
  	if (N % i != 0) continue;
    auto remain = N / i;
    if (remain >= 1 && remain <= 9) {
    	std::cout << "Yes" << std::endl;
      	return 0;
    }
  }
  std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  long N; cin >> N;
  for (int s = sqrt(N); s > 0; --s) {
    if ((N / s) * s == N) {
      N /= s;
      break;
    }
  }
  int digits{0};
  while (N > 0) {
    ++digits;
    N /= 10;
  }

  cout << digits << "\n";
  return 0;
}


Measured memory_bytes: 256
import copy
n,m,x = map(int,input().split())
ca = [0]*n
for i in range(n):
    ca[i] = list(map(int,input().split()))
ans = 10**8

for i in range(1 << n):
    sum = 0
    result = [0]*m
    for j in range(n):
        if (i >> j) & 1 == 1:
            for k in range(m):
                result[k] += ca[j][k+1]
            sum += ca[j][0]
    if min(result) >= x and ans > sum:
        ans = copy.deepcopy(sum)

if ans == 10**8:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 69436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int n;
string s;
string t="0123456789";
 
ll string2ll(string s){
  stringstream ss;
  ss<<s;
  ll res;
  ss>>res;
  return res;
}
 
int main(){
  cin>>s;
  n=s.size();
  ll target=string2ll(s);
 
  ll key=1;
  for(int i=0;i<n;i++)key*=10LL;
 
 
  ll ans=-1;
  string ans2="";
   
  do{
    string tmp=t.substr(0,n);
    stringstream ss;
    ss<<tmp;
    ll num;
    ss>>num;
 
    ll mini=min( key - abs(num-target) , abs(num-target) );
    if( mini == ans ){
      ans2=min(ans2,tmp);
    }else if(mini>ans){
      ans=mini;
      ans2=tmp;
    }
     
  }while( next_permutation(t.begin(),t.end()) );
   
  cout<<ans2<<endl;
  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a
#define pr2(a,b)    cout<<a<<" "<<b
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;

string s;

ll Solves(){
	
	ll n,k,cnt=0,ans=0,x,y,q,sum=0,v,t,m,odd=-1,four=0,two=0;
	// PROCESSING IN HERE
	sc(s);
	if(le(s)>=4){
		if(s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I')cout<<"Yes";
		else cout<<"No"; 
	}
	else{
		cout<<"No";
	}
	
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	ll test;
//	sc(test);
//	fu(T,1,test)
	Solves();
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

int main() {
  ll n,k;
  cin >> n >> k;
  
  vector<ll> hp(n);
  rep(i, n)
    cin >> hp.at(i);
  sort(hp.begin(),hp.end());
  
  ll sum = 0;
  rep(i, n-k)
    sum += hp.at(i);
  
  cout << sum << endl;
}


Measured memory_bytes: 4820
from collections import deque
def gcm(a, b):
  if a < b:
    a = a+b
    b=a-b
    a = a-b
  if b == 0:
    return a
  else:
    r = a%b
    return b if r == 0 else gcm(b, r)
N = int(input())
A = list(map(int, input().split()))
L = deque([0])
for i in range(1, N):
  L.append(gcm(L[-1],A[i-1]))
R = deque([0])
for i in reversed(range(N-1)):
  R.appendleft(gcm(R[0],A[i+1]))
ans = 0
for i in range(N):
  ans = max(ans, gcm(L[i],R[i]))
print(ans)


Measured memory_bytes: 14436
use proconio::{input, marker::Usize1};

fn main() {
    input!(n: usize, uv: [(Usize1, Usize1); n - 1]);
    println!(
        "{}",
        (0..n).map(|i| (i + 1) * (n - i)).sum::<usize>()
            - uv.iter()
                .map(|&(u, v)| (u.min(v) + 1) * (n - u.max(v)))
                .sum::<usize>()
    );
}


Measured memory_bytes: 7712
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T[]readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?e[1..$]:[];return tp;}}
struct Stack(T){T[]e;auto push(T t){e~=t;}auto push(T[]ts){e~=ts;}T pop(){T tp=e[$-1];e=e.length>1?e[0..$-1]:[];return tp;}}
//END OF TEMPLATE

void main(){
    int n;
    n.scan;
    (n.to!(char[]).filter!(c=>c=='7').array.length>0?"Yes":"No").writeln;
}


Measured memory_bytes: 3648
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int g[3][n + 1];
    memset(g, 0, sizeof(g));
    for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= n; j++){
            cin >> g[i][j];
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int sum = 0;
        for(int j = 1; j <= i; j++){
            sum += g[1][j];
        }
        for(int j = i; j <= n; j++){
            sum += g[2][j];
        }
        ans = max(ans, sum);
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
def solve():
    N, K = map(int, input().split())
    h = [0 for _ in range(N)]
    for _ in range(K):
        d = int(input())
        A = map(int, input().split())
        for i in A:
            h[i-1] += 1
    print(h.count(0))




if __name__ == '__main__':
    solve()


Measured memory_bytes: 9112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll h,n,sum=0,x;
    cin>>h>>n;
    rep(i,0,n)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

#define N 100

int M[101][101], p[101], n;

int solve()
{
	int l, i, j, k;
	for (l = 2; l <= n; l++) {
		for (i = 1; i <= n - l + 1; i++) {
			j = i + l - 1;
			M[i][j] = 1 << 30;
			for (k = i; k < j; k++)
				M[i][j] = min(M[i][j], M[i][k] + M[k + 1][j] + p[i - 1] * p[k] * p[j]);
		}
	}
	return M[1][n];
}

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

	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i - 1] >> p[i];

	for (int i = 1; i <= n; i++) 
		M[i][i] = 0;

	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 1232
N, K = map(int, input().split())
nums = list(map(int, input().split()))
dict = {}
for num in nums:
  if num in dict.keys():
    dict[num] += 1
  else:
    dict[num] = 1
if len(dict.keys()) <= K:
  print(0)
else:
  sorted_list = sorted(dict.items(), key=lambda x: x[1])
  change = len(dict.keys()) - K
  ans = 0
  for i in range(change):
    ans += sorted_list[i][1]
  print(ans)
  

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

int main() {
  int n;
  cin>>n;
  set<int> s;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    s.insert(a);
  }
  if (s.size() ==n) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }

}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
class abcd
{
    public:
    ll day;
    ll vas;
};
bool fun1(abcd x,abcd y)
{
    return x.vas<y.vas;
}
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n,k;
    cin>>n>>k;
    ll h[n];
    rep(i,0,n)
    {
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    rep(i,2,n)
    {
        ll x=rem;
        rep(j,1,k+1 )
        {
            if( i >= j)
            x = min ( x , dp[i-j] + abs( h[i-j] - h[i] ) ) ;
        }
        dp[i]=x;
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
gets;s=gets;t=gets;n,m=s.size-1,t.size-1;(puts -1;exit)if s[0]!=t[0];e=n.lcm m;h={};n.times{|i|h[i*e/n]=s[i]};m.times{|i|w=h[i*e/m];(puts -1;exit)if w&&w!=t[i]};puts e

Measured memory_bytes: 11772
from operator import mul
from functools import reduce

def combinations_count(n, r):
    #r = min(r, n - r)
    if r > n:
        return 0
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

n = int(input())
A = list(map(int, input().split()))

d = dict()
for a in A:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1

if len(d) == n:
    for i in range(n):
        print(0)
    exit()

d1 = dict()
for a in d.keys():
    d1[a] = combinations_count(d[a], 2)

d2 = dict()
for a in d.keys():
    d2[a] = combinations_count(d[a] - 1, 2)

ans = []
d3 = dict()
s = sum(d1.values())
for a in A:
    if a not in d3.keys():
        ans.append(s - d1[a] + d2[a])
    else:
        ans.append(d3[a])

for a in ans:
    print(a)

Measured memory_bytes: 45060
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)

using namespace std;

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n,m, sum = 0;
    cin>>n>>m;
    vector<int> arr(n);
    tr(i,0,n-1){
        cin>>arr[i];
        sum += arr[i];
    }
    sort(arr.begin(), arr.end(),greater<>());
    int i = 0,cnt = 0;
    if(sum % (4*m) == 0){
        sum /= (4*m);
    } else {
        sum /= (4*m);
        sum++;
    }
    while (i < arr.size()) {
        if (arr[i] >= sum) {
            cnt++;
        }
        i++;
    }
    if (cnt >= m) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long n, dp[3030][3030];
string s;

int main() {
    cin >> n >> s;
    dp[1][1] = 1;
    for (int i = 2; i <= n; ++i) {
        for (int j = 2; j <= n; ++j) {
            (dp[i - 1][j] += dp[i - 1][j - 1]) %= mod;
        }
        for (int now = 1; now <= i; ++now) {
            int L, R;
            if (s[i - 2] == '<') L = 1, R = now - 1;
            else L = now, R = i;
            if (L <= R) {
                (dp[i][now] += dp[i - 1][R] - dp[i - 1][L - 1] + mod) %= mod;
            }
        }
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = (ans + dp[n][i]) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 71936
m = int(input())

if m == 1:
    print(0)
    exit()

l = []

for i in range(1, 40):
    p = i * (i+1) / 2
    l.append(p)

def check(n):
    num = 0
    i = 0
    while n >= l[i]:
        num += 1
        i += 1
    return num


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

primers = factorization(m)

ans = 0

for i in primers:
    ans += check(i[1])

print(ans)

Measured memory_bytes: 63456
#include <chrono>
#include <iostream>

int main() {
  using namespace std::literals::chrono_literals;

  for (long sec_input; std::cin >> sec_input;) {
    std::chrono::seconds sec{sec_input};
    std::cout
        << std::chrono::duration_cast<std::chrono::hours>(sec).count() << ':'
        << (std::chrono::duration_cast<std::chrono::minutes>(sec) % 1h).count()
        << ':' << (sec % 1min).count() << '\n';
  }
}



Measured memory_bytes: 3104
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int dis[1001][1001],n,p[1000001],dxy[4][2]={{0,-1},{-1,0},{0,1},{1,0}};bool vis[1001][1001];
void dfs(int r,int c)
{
	for(int i=0;i<4;++i)
	{
		int nx=r+dxy[i][0],ny=c+dxy[i][1];if(nx<=0||ny<=0||nx>n||ny>n||dis[nx][ny]<=dis[r][c]+!vis[r][c])continue;
		dis[nx][ny]=dis[r][c]+!vis[r][c];dfs(nx,ny);
	}
}
int main()
{
	scanf("%d",&n);for(int i=1;i<=n*n;++i)scanf("%d",p+i);
	for(int i=1,r=(i-1)/n+1,c=(i-1)%n+1;i<=n*n;++i,r=(i-1)/n+1,c=(i-1)%n+1)dis[r][c]=min(min(min(r-1,n-r),c-1),n-c);
	long long ans=0;
	for(int i=1;i<=n*n;++i)
	{
		int r=(p[i]-1)/n+1,c=(p[i]-1)%n+1;vis[r][c]=true;ans+=dis[r][c];
		dfs(r,c);
	}
	printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 20572
s = input()
a=0
b=0
c=0
for charas in s:
  if charas=='a':
    a += 1
  elif charas == 'b':
    b += 1
  else:
    c += 1
if max(a,b,c)-min(a,b,c)<= 1:
  print('YES')
else:
  print('NO')
        

Measured memory_bytes: 3188
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll n;
    cin >> n;
    
    map<ll, ll> mp;
    
    ll r = 0;
    ll a;
    rep(i, n) {
        cin >> a;
        mp[a-1]++;
        mp[a]++;
        mp[a+1]++;
    }
    
    for(auto i: mp) {
        r = max(r, i.second);
    }
    
    mes(r);
   
    
}


Measured memory_bytes: 9444
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int N;
vector<int> S(100010, 0);

int main(){
  cin >> N;
  rep(i, N){
    int A; cin >> A;
    S[A]++;
  }
  int a = 0, b = 0;
  rep(i, S.size()){
    if(S[i] == 0) continue;
    if(S[i] % 2) a++;
    else b++;
  }
  if(b % 2){
    cout << a + b - 1 << endl;
  }else{
    cout << a + b << endl;
  }


}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int n;
vector<int> g;

int dfs(int d, const vector<int> &v)
{
    if(v==g) return 0;

    int ret = n;

    vector<int> t(v);
    int z = g[d]-v[d];

    for(int i=d; i<n; ++i)
    {
        t[i] = (t[i]+z+10)%10;
        ret = min(ret,dfs(d+1,t)+(z!=0));
    }

    return ret;
}

int main()
{
    while(cin >>n,n)
    {
        string a,b;
        cin >>a >>b;

        vector<int> s(n);
        g.resize(n);

        rep(i,n)
        {
            s[i] = a[i]-'0';
            g[i] = b[i]-'0';
        }

        cout << dfs(0,s) << endl;
    }
    return 0;
}

Measured memory_bytes: 3008
import itertools


def read():
    N = int(input())

    return N,


def solve(N, ):
    for i in range(9):
        a = i + 1
        for j in range(9):
            b = j + 1
            if a*b==N:
                return "Yes"
            else:
                continue
    return "No"


            # for i in range(9):
            #     a = i + 1
            #
            #     b = N / a
            #
            #     if b == :
            #         continue
            #     if a * b == N:
            #         return "Yes"
            #     else:
            #         return "No"


if __name__ == '__main__':
    input = read()
    print(solve(*input))


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

const ll mod = 998'244'353;
ll freq[1000005], w[1000005];

ll modpow(ll b, ll p, ll m) {
	ll r = 1;
	for (; p; p >>= 1, b = b * b % m) if (p & 1) r = r * b % m;
	return r;
}

ll modinv(ll x) {
	return modpow(x, mod - 2, mod);
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	
	int n; read(n);
	rep(i, 0, n) {
		int t; read(t);
		freq[t]++;
	}

	rep(i, 1, 1000005) w[i] = modinv(i);
	rep(i, 1, 1000005) for (ll j = 2 * i; j < 1000005; j += i) {
		w[j] -= w[i];
		if (w[j] < 0) w[j] += mod;
		if (w[j] >= mod) w[j] -= mod;
	}

	ll ans = 0;
	rep(i, 1, 1000005) {
		ll sum1 = 0, sum2 = 0;
		for (ll j = i; j < 1000005; j += i) {
			sum1 = (sum1 + j * freq[j]) % mod;
			sum2 = (sum2 + j * j % mod * freq[j]) % mod;
		}
		ll con = (sum1 * sum1 % mod - sum2 + mod) % mod * modinv(2) % mod;
		ans += con * w[i] % mod;
	}
	
	ans %= mod;
	die(ans);
}


Measured memory_bytes: 15872
import sys
sys.setrecursionlimit(10**8)

n = int(input())
a = list(map(int, input().split()))

a_cs = [0] * (n + 1)
a_cs[-2] = a[-1]
for i in reversed(range(n - 1)):
    a_cs[i] = a[i] + a_cs[i + 2]
# print(a_cs)

d = {}


def func(i):
    if i == n:
        return 0
    if i == n - 1:
        return a[-1]
    if i in d:
        return d[i]

    m = n - i
    if m % 2 == 0:
        ans0 = a[i] + func(i + 2)
        ans1 = a_cs[i + 1]
        ans = max(ans0, ans1)
    else:
        ans0 = a[i + 0] + func(i + 2)
        ans1 = a[i + 1] + func(i + 3)
        ans2 = a_cs[i + 2]
        ans = max(ans0, ans1, ans2)

    d[i] = ans
    return ans


ans = func(0)

print(ans)


Measured memory_bytes: 197356
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
lint ncr(lint n, lint r, lint mod, vector<lint> &fact, vector<lint> &finv) {
  if(n < 0 || r < 0 || n-r < 0) return 0;
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, A, B, K;
  cin >> N >> A >> B >> K;
  vector<lint> fact(N+1);
  fact[0] = 1;
  FOR(i, 1, N+1) fact[i] = fact[i-1] * i % MOD;
  vector<lint> finv(N+1);
  finv[N] = power(fact[N], MOD-2, MOD);
  IFOR(i, 0, N) finv[i] = finv[i+1] * (i+1) % MOD;
  lint ans = 0;
  REP(i, N+1) {
    lint p = i;
    if(K-p*A < 0 || (K-p*A)%B != 0) continue;
    lint q = (K-p*A) / B;
    if(q < 0 || q > N) continue;
    ans = (ans + ncr(N, p, MOD, fact, finv) * ncr(N, q, MOD, fact, finv) % MOD) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cctype>
using namespace std;
 
int main(void){
    int i=0,a[26]={0};
    char ch;
    while( scanf("%c", &ch) != EOF ){
        if( isupper(ch) ) 
            ch = tolower(ch);
     
        if('a'<=ch && ch<='z') 
            ++a[ ch-'a' ];
     
        ++i;
    }
 
    for(int x=0; x<26; ++x)
        printf("%c : %d\n", 'a'+x, a[x]);
 
    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int L,R;
  cin >>L>>R;
  
  if(L/2019!=R/2019) cout << 0 << endl;
  else{
    int a=2020;
  	for(int i=(L%2019); i<=(R%2019); i++){
      for(int j=i+1; j<=(R%2019); j++){
    	a=min((i*j)%2019,a);
      }
    }
    cout << a << endl;
  }
  
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<li, li> pt;

#define fi first
#define se second
#define lson ((p<<1))
#define rson ((p<<1)+1)
#define mid ((L+R)>>1)
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, m, res, now, x, y;
vector<li> a[100007];
priority_queue<li> pq;

int main() {
    fastIO;
    cin >> n >> m;
    for(li i = 0; i < n; i ++) cin >> x >> y, a[x].push_back(y);
    for(li i = 1; i <= m; i ++) {
        for(auto j : a[i]) {
            pq.push(j);
        }
        if(!pq.empty()) res += pq.top(), pq.pop();
    }
    cout << res;

}


Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        while (true) {
            final int N = sc.nextInt();
            final int M = sc.nextInt();
            final int L = sc.nextInt();
            final int K = sc.nextInt();
            final int A = sc.nextInt();
            final int H = sc.nextInt();
             
            if(N == 0 && M == 0 && L == 0 && K == 0 && A == 0 && H == 0){
                break;
            }
             
            System.gc();
            
            Set<Integer> cool = new HashSet<Integer>(L);

             
            for(int i = 0; i < L; i++){
                cool.add(sc.nextInt());
            }
            cool.add(A);
            cool.add(H);
             
            int[][] adj = new int[N][N];
            
            final int max = Integer.MAX_VALUE / 128;
            
            for(int i = 0; i < N; i++){
        		for(int j = 0; j < N; j++){
        			adj[i][j] = i == j ? 0 : max;
        		}
            }
            
            for(int i = 0; i < K; i++){
                final int from = sc.nextInt();
                final int to = sc.nextInt();
                final int cost = sc.nextInt();
                 
                adj[from][to] = adj[to][from] = cost;
            }
            
            for(int k = 0; k < N; k++){
            	for(int i = 0; i < N; i++){
            		for(int j = 0; j < N; j++){
            			adj[i][j] = Math.min(adj[i][j], adj[i][k] + adj[k][j]);
            		}
            	}
            }
            
            for(int i = 0; i < N; i++){
            	for(int j = 0; j < N; j++){
            		if(!cool.contains(i) || !cool.contains(j)){
            			adj[i][j] = max;
            		}else if(adj[i][j] > M){
            			adj[i][j] = max;
            		}
            	}
            }
            
            for(int k = 0; k < N; k++){
            	for(int i = 0; i < N; i++){
            		for(int j = 0; j < N; j++){
            			adj[i][j] = Math.min(adj[i][j], adj[i][k] + adj[k][j]);
            		}
            	}
            }
            
            System.out.println(adj[A][H] >= max ? "Help!" : adj[A][H] + Math.max(0, adj[A][H] - M));
        }
 
        sc.close();
    }
 
}

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

int main(){
	double n, m;
	cin >> n >> m;
	vector<double> v(n);
	double summed = 0;
	for (int i = 0; i < n; ++i) { 
		cin >> v[i];
		summed += v[i];
	}
	double x = summed / (4*m);
	//cout << x << endl;
	//sort(v.rbegin(),v.rend());
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (v[i] < x) {
			continue;
		}else {
			cnt++;
		}
	}
	//cout << cnt << endl;
	if(cnt >= m)cout << "Yes";
	else cout << "No\n";
	
}



















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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)     cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)  cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG         cerr << __LINE__ << ": Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction
int A[1000000];
int main()
{
    //freopen("maxon.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n, k;
    sff(n, k);
    int source;
    for(int i = 1; i<=n; i++)
    {
        sf(A[i]);
        if(A[i] == 1)
            source = i;
    }
    int i = k;
    bool found = false;
    int ans = 1;
    while(i<n)
    {
        i+=(k-1);
        ans++;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 640
//バケット法

#include<cstdio>
#include<iostream>
#include<stdio.h>
#include<string>
#define N 10000
using namespace std;

char S[101010];


int main()
{
    scanf("%s",S);
    bool app[26];
    for(int i=0;i<26;i++)
    {
        app[i]=false;
    }
    for(int i=0 ; S[i]!='\0';i++)
    {
        app[S[i]-'a']=true;
    }

    for(int i=0;i<26;i++)
    {
        if(app[i]!=true)
        {
            printf("%c\n",(char)(i+'a'));
            return 0;
        }
    }
    cout<<"None";
    return 0;

}




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

using namespace std;

int DP[100010],K;
int arr[100010];

int solve(int pos) {
    if (DP[pos]!=-1) {
        return DP[pos];
    }
    DP[pos] = INT_MAX;
    for (int i=1;i<=K;i++) {
        if (pos-i>=0) {
            DP[pos]=min(DP[pos],solve(pos-i)+abs(arr[pos-i]-arr[pos]));
        }
    }
    return DP[pos];
}

int main () {
    int N;
    scanf("%d%d",&N,&K);
    for (int i=0;i<N;i++) {
        scanf("%d",&arr[i]);
        DP[i]=-1;
    }
    DP[0]=0;
    cout << solve(N-1);
    return 0;
}



Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    lli n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    for(int i=0; i<n-1; i++){
        lli llb = a +i*c, lub = a +i*d;
        lli rlb = b +(n-2-i)*c, rub = b +(n-2-i)*d;
        llb+=c; lub+=d;
        if(abs(llb+lub -(rlb+rub)) <= (lub-llb) +(rub-rlb)){
            cout << "YES" << endl;
            return 0;
        }
        llb-=c; lub-=d;
        rlb+=c; rub+=d;
        if(abs(llb+lub -(rlb+rub)) <= (lub-llb) +(rub-rlb)){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256