akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


ll mod = 1e9+7;
int main(){
    int r,c,k;
    cin>>r>>c>>k;
    vector<vector<int>> kk(r,vector<int> (c,0));
    rep(i,k){
        int a,b,v;
        cin>>a>>b>>v;
        a--;b--;
        kk[a][b]=v;
    }
    vector<vector<vector<ll>> > dp(r+1,vector<vector<ll>> (c+1,vector<ll> (4,0)));
    rep(i,r){
        rep(j,c){
            int t = kk[i][j];
            ll m = max(max(max(dp[i][j+1][0],dp[i][j+1][1]),dp[i][j+1][2]),dp[i][j+1][3]);
            dp[i+1][j+1][0]=max(m,dp[i+1][j][0]);
            if(t==0) {
                dp[i+1][j+1][1]=dp[i+1][j][1];
                dp[i+1][j+1][2]=dp[i+1][j][2];
                dp[i+1][j+1][3]=dp[i+1][j][3];
            }
            else{
                dp[i+1][j+1][1]=max(max(m+t,dp[i+1][j][1]),dp[i+1][j][0]+t);
                dp[i+1][j+1][2]=max(dp[i+1][j][2],dp[i+1][j][1]+t);
                dp[i+1][j+1][3]=max(dp[i+1][j][3],dp[i+1][j][2]+t);
            }
        }
    }
    cout<<max(max(max(dp[r][c][0],dp[r][c][1]),dp[r][c][2]),dp[r][c][3])<<endl;
    return 0;
}

Measured memory_bytes: 671476
#include <bits/stdc++.h>
using namespace std;
struct RollingHash
{
  vector< unsigned > hashed, power;
  RollingHash(const string& s, unsigned _base = 1000000007)
  {
    _base = _base;
    int sz = s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
  
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = power[i] * _base;
    }
    for(int i = 0; i < sz; i++) {
      hashed[i + 1] = (hashed[i] + s[i]) * _base;
    }
  }
  unsigned get(int l, int r) // [l, r)
  {
    return((hashed[r] - hashed[l] * power[r - l]));
  }
};
 
int main()
{
  int N, M;
  scanf("%d %d", &N, &M);
  char S[300001];
  scanf(" %s", S);
  RollingHash hash1(S), hash2(S, 1e9+9);
  unordered_set< unsigned long long > poyo;
  int l = 0, r = 1;
  while(M--) {
    scanf("%s", S);
    if(S[0] == 'R') {
      if(S[1] == '+') ++r;
      else --r;
    } else {
      if(S[1] == '+') ++l;
      else --l;
    }
    poyo.insert((1ull * hash1.get(l, r) << 32ll) | hash2.get(l, r));
  }
  printf("%d\n", poyo.size());
}

Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[100000];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A + N);

    queue<ll> lq, rq;
    ll sw = 1;
    rep(i,N/2){
        if(sw){
            lq.emplace(A[i]);
            rq.emplace(A[N - i - 1]);
        }else{
            lq.emplace(A[N - i - 1]);
            rq.emplace(A[i]);
        }
        sw ^= 1;
    }

    ll ans = A[N - 1] - A[0], l = A[0], r = A[N - 1];
    while(!lq.empty()){
        ll lv = lq.front(), rv = rq.front();
        lq.pop(), rq.pop();
        ans += abs(l - lv) + abs(r - rv);
        l = lv, r = rv;
    }

    if (N & 1) ans += max(abs(l - A[N / 2]), abs(r - A[N / 2]));

    cout << ans << endl;

}

Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll res = 0;
  res = (N / K) * (N / K) * (N / K);
  if (K % 2 == 0) {
    ll x = (N - K/2) / K + (N >= K/2 ? 1 : 0);
    res += x * x * x;
  }


  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

char A[1002][1002];
int d[1002][1002];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    int sr,sc,fr,fc;
    cin>>sr>>sc>>fr>>fc;

    for(int i=1; i<=n; i++)
    for(int j=1; j<=m; j++)
        cin>>A[i][j],d[i][j]=oo;

    deque<array<int,2>>Q;
    Q.push_back({sr,sc});
    d[sr][sc]=0;

    int dr[] = {-1,1,0,0};
    int dc[] = {0,0,-1,1};

    while(!Q.empty()){
        int r = Q.front()[0];
        int c = Q.front()[1];
        Q.pop_front();

        for(int k=0; k<4; k++)
        {
            int R = r + dr[k];
            int C = c + dc[k];
            if(R < 0 || C < 0 || R > n || C > m || A[R][C]=='#' || d[R][C] <= d[r][c])continue;
            d[R][C] = d[r][c];
            Q.push_front({R,C});
        }

        for(int x=-2; x<=2; x++)
        for(int y=-2; y<=2; y++)
        {
            int R = r + x;
            int C = c + y;
            if(R < 0 || C < 0 || R > n || C > m || A[R][C]=='#' || d[R][C] <= d[r][c]+1)continue;
            d[R][C] = d[r][c] + 1;
            Q.push_back({R,C});
        }
    }

    if(d[fr][fc] > 1e8)d[fr][fc]=-1;
    cout<<d[fr][fc];
}


Measured memory_bytes: 8572
#include<bits/stdc++.h> 
using namespace std;
int main() 
{
	string s,t;
	cin>>s>>t;
	int shu=0;
	for(int i=0;i<=s.length();i++)
	if(s[i]!=t[i])
	shu++;
	cout<<shu;
	return 0; 
} 
	

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

#define INF 1e17
#define int long long

signed main(){
    int n,i;
    while(1){
        cin>>n;
        if(n==0)break;
        vector<string> s(n);
        for(i=0;i<n;i++)cin>>s[i];
        
        int big=-INF;
        int small=INF;
        
        for(i=0;i<n-1;i++)
            if(s[i]=="x"&&s[i+1]!="x"){
                if(i%2)big=max(big,(long long)stoi(s[i+1])+1);
                if(i%2==0)small=min(small,(long long)stoi(s[i+1])-1);
            }else if(s[i+1]=="x"&&s[i]!="x"){
                if(i%2)small=min(small,(long long)stoi(s[i])-1);
                if(i%2==0)big=max(big,(long long)stoi(s[i])+1);
            }else if(s[i]!="x"&&s[i+1]!="x"){
                if(i%2 && stoi(s[i])<=stoi(s[i+1])){
                    cout<<"none"<<endl;
                    goto END;
                }
                if(i%2==0 && stoi(s[i])>=stoi(s[i+1])){
                    cout<<"none"<<endl;
                    goto END;
                }
            }else{
                cout<<"none"<<endl;
                goto END;
            }
        
        
       // cout<<"ans"<<big<<" "<<small<<endl;
        if(big==small)cout<<big<<endl;
        else if(big<small)cout<<"ambiguous"<<endl;
        else cout<<"none"<<endl;
    END:;
    }
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    string s;cin >> s;
    ll ans = 0;
    int n = s.size();
    vector<int> num(n);
    rep(i,n){
        num[i] = s[i] - '0';
    }
    for(int bit=0;bit<(1<<(n-1));bit++){
        ll tmp = num[0];
        for(int i=0;i<(n-1);i++){
            if(bit&(1<<i)){
                ans += tmp;
                tmp = 0;
            }
            tmp = tmp * 10 + num[i+1];
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int n, m, cnt = 0, sz[200005] = {0};
bool v[200005] = {0};
vector < vector <int> > g(200005);

void dfs (int pos) {
	v[pos] = true;
	sz[cnt]++;
	for (int x = 0; x < g[pos].size(); x++) {
		if (!v[g[pos][x]]) {
			dfs (g[pos][x]);
		}
	}
}

int main () {
	fastCin;
	cin >> n >> m;
	for (int x = 0; x < m; x++) {
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans = 0;
	for (int x = 1; x <= n; x++) {
		if (!v[x]) {
			cnt++;
			dfs (x);
			ans = max (ans, sz[cnt]);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 20212
n,m=map(int,input().split())
p=[]
for i in range(1,m+1):
    a=list(map(int,input().split()))
    a.append(i)
    p.append(a)
    
p.sort()

for i in range(m):
    if i==0 or p[i][0] != p[i-1][0]:
        cnt=1
    else:
        cnt+=1
    p[i].append(cnt)

p.sort(key= lambda x: x[2])

for i in range(m):
    print("{:06}{:06}".format(p[i][0],p[i][3]))

Measured memory_bytes: 35464
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int rates[8];
    rates[0] = 0;
    rep(i,7) rates[i+1] = rates[i]+400;
    
    int n;cin >> n;
    int color[8] = {0};
    int wildcard = 0;
    rep(i,n) {
        int r;cin >> r;
        
        if(r>=3200) {
            wildcard++;
            continue;
        }
        per(j,8) {
            if(r>=rates[j]) {
                color[j]++;
                break;
            }
        }
    }
    int ans = 0;
    rep(i,8) if(color[i]>=1) ans++;
    cout << ((ans==0&&wildcard>=1)?1:ans) << " " << ans+wildcard << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = Next()

ju= False
for i in n:
    if i == '7':
        ju = True
        break
if ju:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9132
weights, values = [], []

n, w = list(map(int, input().split()))
for _ in range(n):
    w_c, v_c = list(map(int, input().split()))
    weights.append(w_c)
    values.append(v_c)

dp = [[0 for i in range(w + 1)] for i in range(n + 1)]
for i in range(len(values) + 1):
    for j in range(w + 1):
        if i == 0 or j == 0: 
            dp[i][j] = 0
        elif weights[i - 1] <= j:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weights[i - 1]] + values[i - 1])
        else:
            dp[i][j] = dp[i - 1][j]
    
print(dp[-1][-1])


Measured memory_bytes: 217940
sx,sy,tx,ty=list(map(int,input().split()))
dx=tx-sx
dy=ty-sy
ans='U'*dy+'R'*dx +'D'*dy+'L'*dx
ans+="L"+"U"*(dy+1)+"R"*(dx+1)+"D"
ans+="R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(ans)

Measured memory_bytes: 3060
from collections import deque
S = input()
s = list(S)
d = deque()
for i in range(len(s)):
    d.append(s[i])
Q = int(input())
p = [[0 for i in range(3)]for j in range(Q)]
x = 1
for i in range(Q):
    p[i] = list(map(str,input().split()))
def add(s,x,f,c):
    if x ==1:
        if f == 1:
            s.appendleft(str(c))
        else:
            s.append(str(c))
    else:
        if f == 1:
            s.append(str(c))
        else:
            s.appendleft(str(c))
for i in range(Q):
    if int(p[i][0]) == 1:
        x = -x
    else:
        add(d,x,int(p[i][1]),p[i][2])
if x == 1:
    print(''.join(d))
else:
    d.reverse()
    print(''.join(d))

Measured memory_bytes: 45556
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  N,K = parseMap(split(readline()))
  A = parseMap(split(readline()))
  #sc = zeros(BigInt,N)
  #tmp = 1
  #for i in 1:K
  #  tmp *= A[i]
  #end
  #sc[K] = tmp
  #for i in K+1:N
  #  sc[i] = div(sc[i-1]*A[i],A[i-K])
  #end

  for i in K+1:N
      if A[i] > A[i-K]
      #if sc[i] > sc[i-1]
        println("Yes")
      else
        println("No")
      end
  end
end
main()


Measured memory_bytes: 276600
#include <stdio.h>
int search(int a[],int n,int key){
    int i=0;
    a[n]=key;
    while(a[i]!=key) i++;
    return i!=n;
}
int main() {
    int i,n,a[10000+1],q,key,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        if(search(a,n,key)) sum++;
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 2052
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
#define N 200001
int n,k;
int main(){
    while (scanf("%d",&k)!=EOF){
        printf("%d\n",k/2*((k+1)/2));
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define P 998244353
#define N_MAX 300000

long fac[N_MAX+1];
long inv[N_MAX+1];
long finv[N_MAX+1];

long comb(long n, long k){
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
    fac[0] = 1;
    finv[0] = 1;
    fac[1] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
        fac[i] = (fac[i-1]*i)%P;
        inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
        finv[i] = (finv[i-1]*inv[i])%P;
    }
}

int main(){
    long N, A, B, K;
    cin >> N >> A >> B >> K;
    init();
    long ans = 0;
    for(int na = 0; na <= N; na++){
        long nb = (K-A*na)/B;
        if((K-A*na)%B == 0 && nb <= N && nb >= 0){
            //cout << na << ' ' << nb << endl;
            ans = (ans + comb(N, na)*comb(N, nb))%P;
        }
    }
    cout << ans << endl;
}

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

int main() {
 string O, E;
 cin >> O >> E;
 
 vector<char> pass(O.size()+E.size());
 
 for (int i = 0; i < O.size()+E.size(); i++){
   if(i%2 == 0)
   pass.at(i) = O.at(i/2);
   else
   pass.at(i) = E.at(i/2);
 }
 for (int i = 0; i < O.size()+E.size(); i++){
   if(i == O.size()+E.size()-1)
   cout << pass.at(i) << endl; 
   else
   cout << pass.at(i);
 }
}

Measured memory_bytes: 256
import math
a,b=map(int, input().split())
a_min = math.ceil(a/0.08)
a_max = math.ceil((a+1)/0.08)-1
b_min = math.ceil(b/0.1)
b_max = math.ceil((b+1)/0.1)-1

if max([a_min,b_min]) >= min([a_max,b_max]):
  print(-1)
else:
  print(max([a_min,b_min]))


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

#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define sz(x) ((int)(x).size())
#define endl "\n"
#define INF 0x20202020
#define EPS 1e-9
#define PI 3.1415926535897932384626
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

ll powmod(ll a, ll b) {
    ll res = 1;
    a %= MOD;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % MOD;
        a = a * a % MOD;
    }
    return res;
}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> si;

class C {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        string str;
        cin >> str;
        int k;
        cin >> k;
        int n = str.length();
        vs subset;
        rep(i, 0, n) {
            rep(j, 1, k + 1) { //each sub max k+1
                if (i + j - 1 < n)
                    subset.pb(str.substr(i, j));
            }
        }
        sort(all(subset));
        subset.erase(unique(all(subset)), subset.end());
        cout << subset[k - 1] << endl;
    }
};


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


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
int main() {
  int n;
  while(cin>>n&&n) {
    P a[n];
    for(int i=0;i<n;i++)cin>>a[i].F>>a[i].S;
    sort(a,a+n,greater<P>());
    int x=-a[0].F,y=a[0].F;
    for(int i=0;i<n;i++)x+=a[i].F,y+=a[i].S;
    int m=max(0,a[0].F-x);
    int dp[m+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<n;i++)for(int j=m-a[i].S;j>=0;j--)dp[j+a[i].S]|=dp[j];
    for(int i=m;!dp[i];i--)x++;
    cout<<x+y<<endl;
  }
  return 0;
}


Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(k+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        vector<ll> sum(k+2, 0);
        for(int j = 0; j <= k; j++) sum[j+1] = sum[j] + dp[i][j];
        for(int j = 0; j <= k; j++) dp[i+1][j] = sum[j+1]-sum[max(0, j-a[i])], dp[i+1][j] %= MOD;
    }
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 80256
#include <stdio.h>

int main()
{
  int i, j;
  int n, m;
  int all_v = 0, count = 0;
  int a[100];
  
  scanf("%d%d", &n, &m);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
    all_v += a[i];
  }
  for(i = 0; i < n; i++){
  	if(4 * m * a[i] >= all_v){
      count++;
  	}
  }
  if(count >= m){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    
    
    public static void main(String[] args)  {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            while((line=br.readLine())!=null){if(line.isEmpty())break;
                line=line.replaceAll("apple", "xyzxyzzzyxxxxzxzaa2b");
                line=line.replaceAll("peach",
                        "apple");
                line=line.replaceAll("xyzxyzzzyxxxxzxzaa2b","peach");
                System.out.println(line);
                

            }
        }catch(Exception e){}
        
    }
}

Measured memory_bytes: 17068
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

vector<ll> func(const ll v, int base) {
    string ret;
    ll n = v;
    vector<ll> vec;
    while (n >= base) {
      vec.push_back(n%base);
      n /= base;
    }
    vec.push_back(n);
    return vec;;
}
int main() {
  ll N;
  cin >> N;
  ll n = 26;
  ll r = 1;
  ll tmp = N;
  while (N > n) {
    r ++;
    n = n + pow(26, r);
    tmp -= pow(26, r - 1);
  }
  N = tmp;
  N -= 1;
  vector<ll> vec = func(N, 26);
  const char table[] = "abcdefghijklmnopqrstuvwxyz";
  string ret = "";
  for (auto i = 0;i < r;i ++) {
    if (i >= vec.size()) {
      ret += "a";
      continue;
    }
    ret += table[vec[i]];
  }
  std::reverse(ret.begin(), ret.end());
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL read() {
    LL k = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k * f;
}
int main() {
    int a = read(), b = read();
    cout << max(max(a + b, a - b), a * b);


    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                bool[] baseTable = new bool[3];

                int outCnt = 0, point = 0;

                while (outCnt < 3)
                {
                    string input = Console.ReadLine();

                    switch (input)
                    {
                        case "HIT":
                            if (baseTable[2])
                            {
                                point++;
                                baseTable[2] = false;
                            }
                            if (baseTable[1])
                            {
                                baseTable[2] = true;
                                baseTable[1] = false;
                            }
                            if (baseTable[0])
                            {
                                baseTable[1] = true;
                                baseTable[0] = false;
                            }
                            baseTable[0] = true;
                            break;
                        case "OUT":
                            outCnt++;
                            break;
                        case "HOMERUN":
                            var onBase = baseTable.Where(b => b == true).Count();
                            point += onBase + 1;
                            baseTable = new bool[3];
                            break;
                    }
                }
                sb.AppendLine(point.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9516
r,c = gets.split.map { |e|e.to_i}

table = []
r.times {
  data  = gets.split.map { |e| e.to_i }
  data << data.inject { |sum, i| sum += i }
  table << data
}
table << []
for i in 0..r-1
  for j in 0..c
    if table[r][j].nil? 
      table[r][j] = table[i][j]
    else
      table[r][j] += table[i][j]
    end
  end
end

for tb in table
  puts tb.join(" ")
end

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    ll A[n], T[n];
    for(int i = 0; i < n; i++)
    {
        cin >> T[i] >> A[i];
    }
    ll t, a;
    for(int i = 0; i < n; i++)
    {
        if(i == 0){
            t=T[i]; a=A[i];
            ans = t+a;
        }
        else
        {
            ll c;
            if(a/A[i]>t/T[i]){
                c=a/A[i];
                if(!(A[i]*c>=a && T[i]*c>=t))c++;
            }
            else
            {
                c=t/T[i];
                if(!(A[i]*c>=a && T[i]*c>=t))c++;
            }
            a = A[i]*c;
            t = T[i]*c;
            ans = a+t;
        }
    }
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
parent=[]

def bfs(G,s,t,parent):
    N = len(G)
    visited=[False for u in range(N)]
    cola = deque()
    parent[s]=-1
    visited[s]=True
    cola.append(s)
    while cola:
        u = cola.popleft()
        for v in range(N):
            if(visited[v]==False and G[u][v]):
                cola.append(v)
                visited[v]=True
                parent[v]=u
    return visited[t]
    


def MAX_FLOW(G,s,t):
    global parent
    maxflow=0
    u,v=0,0
    GR=G
    while bfs(GR,s,t,parent):
        pathFlow=float("inf")
        v=t
        while v!=s:
            u=parent[v]
            pathFlow=min(pathFlow,GR[u][v])
            v=parent[v]
        v=t
        while v!=s:
          u=parent[v]
          GR[u][v]-=pathFlow
          GR[v][u]+=pathFlow
          v=parent[v]
        maxflow+=pathFlow
    return maxflow
        
        

def main():
    global parent
    D=[int(x) for x in sys.stdin.readline().strip().split()]
    V,E=D[0],D[1]
    G=[[0 for u in range(V)]for v in range(V)]
    for l in range(E):
        u,v,c= [int(x) for x in sys.stdin.readline().strip().split()]
        G[u][v]=c
    parent=[-1 for i in range(V)]
    print(MAX_FLOW(G,0,V-1))
main()



Measured memory_bytes: 6092
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define repl(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef unsigned long long ull;
//typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const ll N=(ll)(1e6+1);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
ll inv(int x){return binpow(x, MOD - 2);}
ll divide(ll x, ll y){return mul(x, inv(y));}
ll fact[N];
void precalc(){fact[0] = 1;for(ll i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
ll C(ll n, ll k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================
/*I adj[200005];
int vis[200005];
int tot=0;
void dfs(int node)
{
    tot++;
    vis[node]=1;
    for (auto x : adj[node])
    {
        if (vis[x]==0)
        {
            dfs(x);
        }
    }
}*/

int main() {
//#ifdef _DEBUG
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
IOS;

double d,t,s;
cin>>d>>t>>s;
double tot=d/s;
if(tot>t)
{
    cout<<"No"<<endl;
}
else
{
    cout<<"Yes"<<endl;
}
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time_start		 time_t start, end; time(&start); 
#define time_end		 time(&end);double time_taken=double(end-start);cout <<"\n"<< time_taken*1000<<" ms";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2}; 
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}




int solve()
{
	ll n;
	sll(n);
	vll v(n);
	forr(i,0,n) sll(v[i]);
	
	forn(i,n-1,0) if(v[i]<v[i-1]) v[i-1]--;
	
	forr(i,0,n-1) if(v[i]>v[i+1]) return printf("No"),0;
	
	printf("Yes");
	
   	return 0;
}
	
 
int main()
{

//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();

}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 1152
def conversion(a):
    num = ord(a) - 97
    return num
c = [] #バケット法用
b = [] #数字に変換したリスト
a = list(input())
ans = 0
#文字列を数字に変換
for i in a:
    b.append(conversion(i))


#バケット法
for i in range(26):
    c.append(0)
for i in b:
    c[i] = 1

#存在しない数字を探す
for i in c:
    if i == 0:
        break
    else:
        ans += 1

#答えをアルファベットに変換

if ans == 26:
    print("None")
else:
    print(chr(ans + 97))


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 998244353;

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

	string a, b; cin >> a >> b;

	int n = a.size(), m = b.size();

	int ans = m;
	for(int i = 0; i <= n-m; i++){
		int aux = 0;
		for(int j = 0; j < m; j++){
			if(a[i+j] != b[j]) aux++;
		}
		ans = min(ans, aux);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3648
var s,r,g,b,n,t:Longint;
begin
read(r,g,b,n);
if r>g then begin
	t:=r;
	r:=g;
	g:=t;
end;
if r>b then begin
	t:=r;
	r:=b;
	b:=t;
end;
if r=1 then begin
	t:=n;
	while t>=0 do begin
		inc(s,t div g+1);
		dec(t,b);
	end;
	writeln(s);
	exit;
end;
t:=n;
while True do begin
if t<0 then begin
dec(n,b);
t:=n;
if t<0 then begin
writeln(s);
exit;
end;
end;
if t mod r=0 then inc(s);
dec(t,g);
end;
end.

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

public class Main {
    public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	}
}


Measured memory_bytes: 59704
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){

    LL L,R;cin >> L >> R;

    vector<LL> vec;
    for(LL i = L;i <= R;i++){
        vec.push_back(i);
        if(vec.size() >= 3000)break;
    }
    LL ans = LINF;
    for(int i = 0;i < vec.size()-1;i++){
        for(int j = i+1;j < vec.size();j++){
            ans = min(ans, (vec.at(i)*vec.at(j))%2019);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
n, k = get_ints()
count = [False]*n
for i in range(k):
    d = int(input())
    li = get_array()
    for i in li:
        count[i-1] = True
ans = 0
for i in count:
    if i is False:
        ans += 1
print(ans)

# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Measured memory_bytes: 67548
L=input().split( )
l=len(L)
I=[0 for i in range(l)]
#構造体やクラスとしての実装を
for i in range(l):
    if str.isnumeric(L[i])==True:
        I[i]=int(L[i])
    else:
        I[i]=L[i]
S=["" for i in range(l)]

def push(M,x,top):
    top+=1
    M[top]=x
    return(M,top)


def pop(M,top):
    temp=M[top]
    M[top]=""
    top-=1
    return(M,top,temp)


def operator(a,b,x):
    if x=="+":
        return(a+b)
    elif x=="-":
        return(a-b)
    elif x=="*":
        return(a*b)

top=-1
for i in range(l):
    if str.isdigit(L[i])==True:
        top=push(S,I[i],top)[1]
        #print(S,top)
    else:
        temp1=pop(S,top)[2]
        S=pop(S,top)[0]
        top=pop(S,top)[1]
        #print(top,temp1)
        temp2=pop(S,top)[2]
        S=pop(S,top)[0]
        top=pop(S,top)[1]
        #print(top,temp2)
        #print(temp2,temp1,I[i])
        top+=1
        S[top]=operator(temp2,temp1,I[i])
        #print(S,S[top],top)
print(S[0])



Measured memory_bytes: 5616
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            ulong L = Convert.ToUInt64(input[0]);
            ulong R = Convert.ToUInt64(input[1]);

            ulong min = ulong.MaxValue;
            for (ulong i = L; i < R; i++)
            {
                for (ulong j = i + 1; j <= R; j++)
                {
                    ulong mod = i * j % 2019;
                    if (mod == 0)
                    {
                        Console.WriteLine(0);
                        return;
                    }
                    min = Math.Min(min, mod);
                }
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n;
    while(cin>>n, n){
        char c[n];
        vector<int> cnt(30, 0);
        for(int i=0; i<n; i++){
            cin>>c[i];
        }

        int cmax=0, sc_cmax=0;
        for(int i=0; i<n; i++){
            cnt[c[i]-'A']++;

            int maxid;
            for(int i=0; i<26; i++){
                if(cmax<cnt[i]){
                    cmax=cnt[i];
                    maxid=i;
                }
            }

            for(int i=0; i<26; i++){
                if(i==maxid) continue;
                
                chmax(sc_cmax, cnt[i]);
            }

            if(cmax > sc_cmax+n-(i+1)){
                cout << (char)(maxid+'A') << " " << i+1 << endl;
                break;
            }

            if(i==n-1){
                cout << "TIE" << endl;
            }
        }
    }
}


Measured memory_bytes: 3028
import itertools
import numpy as np

N, M, Q = map(int, input().split())
grid = []
for i in range(Q):
    array = list(map(int, input().strip().split()))
    grid.append(array)

l = np.arange(1, M + 1)
max = 0
temp = 0

for c in itertools.combinations_with_replacement(l, N):
    for d in grid:
        if c[d[1]-1] - c[d[0]-1] == d[2]:
            temp += d[3]
    if max < temp:
        max = temp
    temp = 0

print(max)

Measured memory_bytes: 27140
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q);
    REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    int nm = N+M-1;
    vector<int> v(N);
    int ans = 0;
    REP(i, 1<<nm){
        if(__builtin_popcount(i) == N-1){
            if(i&1) continue;
            int tmp = 0;
            int id = 0;
            REP(j, nm){ //0だったらカウント，1だったら代入して数列を作成
                if(i&(1<<j)) v[id++] = tmp;
                else tmp++; 
            }
            v[id] = tmp;
            int tmpans = 0;
            REP(j, Q){
                if(v[b[j]-1]-v[a[j]-1]==c[j]) tmpans += d[j];
            }
            chmax(ans, tmpans);
        }
    }
    pr(ans);
}

Measured memory_bytes: 3636
defmodule Main do
  def main do
    x = IO.gets("") |> String.trim() |> String.to_integer()
    risi(100, x, 0)
    |> IO.puts()
  end

  def risi(sum, x, count) when sum >= x, do: count
  def risi(sum, x, count), do: risi(trunc(sum * 1.01), x, count + 1)
end
  

Measured memory_bytes: 30824
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL c,i,j,k=300000,m,n,q,v,w,x,y,z,a[1000005],b[1000005];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>v>>w>>m;
	for(;i++<v;)cin>>a[i];
	for(i=0;i++<w;)cin>>b[i];
	for(i=0;i++<m;)
	{
		cin>>x>>y>>c;
		k=min(k,a[x]+b[y]-c);
	}
	sort(a,a+v+1);
	sort(b,b+w+1);
	cout<<min(k,a[1]+b[1]);
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <math.h>

int main(void){
  int a=0,b=0,h=0,m=0;
  double rad=0.0;
  double ans=0.0;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  scanf("%d",&m);

  rad=h*30.0+(double)m*30.0/60.0;
  rad=(double)m*360.0/60.0-rad;
  rad=rad/180.0*3.141592653589793;
  
  ans=sqrt((a*a+b*b)-(2*a*b*cos(rad)));
  
  printf("%.10lf",ans);
}

Measured memory_bytes: 2596