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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >  
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int N=n/2;
    cout<<arr[N]-arr[N-1]<<endl;
}

Measured memory_bytes: 4364
using System;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ');
        var min = 1000;
        int[] AA = new int[210];
        int[] count = new int[210];

        for(int i = 0; i < N; ++i)
        {
            AA[i] = int.Parse(A[i]);
            while(AA[i]%2 == 0 && AA[i] != 0)
            {
               AA[i] /= 2; 
               ++count[i];
            }

            if(min > count[i])
            {
                min = count[i];
            }
            // Console.WriteLine("count" + count[i] + ", ");
            // Console.WriteLine("min" + min);
        }
        Console.WriteLine(min);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

ll n, m, q;
ll a[55], b[55], c[55], d[55];
ll ans;

void saiki(ll now, ll num, ll v[]){
  if(now == n){
    ll sum = 0;
    rep(i, 0, q){
      if(v[b[i]]-v[a[i]] == c[i]) sum += d[i];
    }
    ans = max(ans, sum);
  }else{
    Rep(j, num, m){
      v[now] = j;
      saiki(now+1, j, v);
    }
  }
}

int main() {
  cin >> n >> m >> q;
  rep(i, 0, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }

  ans = 0;
  ll A[15];
  A[0] = 1;
  saiki(1, 1, A);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3436
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
//typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


void solve() {
	vector<string>v;
	int N; cin >> N;
	string P, Q;
	REP(i, N) {
		char x; cin >> x;
		P += x;
	}
	REP(i, N) {
		char x; cin >> x;
		Q += x;
	}
	int perm[10];
	int a = 0, b = 0;
	REP(i, N)perm[i] = i+1;
	int cnt = 0;
	do {
		string S;
		REP(i, N) {
			S += '0'+perm[i];
		}
		if (S == P)a = cnt;
		if (S == Q)b = cnt;
		cnt++;
	} while (next_permutation(perm, perm + N));;
	print(abs(a - b));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string S; cin >> S;
  string T; cin >> T;
  auto sub = T.substr(0, S.size());
  auto ans = S == sub;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e6 + 5;

void solve() {
    int sum = 0, tot = 0;
    for (int i=0;i<5;++i) {
        int x; cin >> x; sum += x;
        tot += i + 1;
    }
    cout << tot - sum << '\n';
}

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXN = 5 + 100;
const int MAXW = 5 + 100000;
int N,W;
ll memo[MAXN][MAXW];
int w[MAXN],v[MAXN];


ll dp(int i, int wleft) {
    if(i == N) {
        return 0LL;
    }
    ll& ans = memo[i][wleft];
    if(ans == -1) {
        ans = dp(1 + i, wleft);
        if(wleft - w[i] >= 0) {
            ans = max(ans, (ll)(v[i]) + dp(1 + i, wleft - w[i]));
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N >> W;
    foi(i,0,N) {
        cin >> w[i] >> v[i];
    }
    memset(memo, -1, sizeof memo);
    cout << dp(0,W) << '\n';
    return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
int n;
const int N=301;
double dp[N][N][N];
double val(int pr)
{
    return (double)n/pr;
}
double calc(int a,int b,int c)
{
    //printf("%i %i %i\n",a,b,c);
    int s=a+b+c;
    if(s==0)
        return 0;
    if(dp[a][b][c]!=-1)
        return dp[a][b][c];
    dp[a][b][c]=val(s);
    //printf("%f\n",dp[a][b][c]);
    if(a>0)
        dp[a][b][c]+=(double)a/s*calc(a-1,b,c);
    if(b>0)
        dp[a][b][c]+=(double)b/s*calc(a+1,b-1,c);
    if(c>0)
        dp[a][b][c]+=(double)c/s*calc(a,b+1,c-1);
    return dp[a][b][c];
}
int main()
{
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            for(int k=0;k<N;k++)
            {
                dp[i][j][k]=-1;
            }
        }
    }
    scanf("%i",&n);
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++)
    {
        int d;
        scanf("%i",&d);
        if(d==1)
            a++;
        if(d==2)
            b++;
        if(d==3)
            c++;
    }
    printf("%.10f\n",calc(a,b,c));
    return 0;
}


Measured memory_bytes: 213504
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int H, W;
int count[2];
int map[404][404];
bool used[404][404];

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

void dfs(int i, int j, int c){
  for (int k=0; k<4; k++){
    if (i+dy[k]>=0 && i+dy[k]<H && j+dx[k]>=0 && j+dx[k]<W){
      if (map[i+dy[k]][j+dx[k]]!=c && !used[i+dy[k]][j+dx[k]]){
	//printf("%d %d added\n", i+dx[k], j+dy[k]);
	count[1-c]++;
	used[i+dy[k]][j+dx[k]]=true;
	dfs(i+dy[k], j+dx[k], 1-c);
      }
    }
  }
}

int main(){
  scanf("%d", &H);
  scanf("%d", &W);
  std::string s;
  for (int i=0; i<H; i++){
    std::cin >> s;
    for (int j=0; j<W; j++){
      map[i][j]=(s[j]=='#')?1:0;
    }
  }
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      used[i][j]=false;
    }
  }
  long long ans = 0;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      //printf("=========\n");
      if (used[i][j]) continue;
      count[0]=0;
      count[1]=0;
      count[map[i][j]]++;
      used[i][j]=true;
      //printf("dfs(%d, %d) called\n", i, j);
      dfs(i,j,map[i][j]);
      //printf("count=%d,%d\n", count[0], count[1]);
      ans += (long long)count[0]*count[1];
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int r;
    cin >> r;
    if (r < 1200)
        puts("ABC");
    else if (r < 2800)
        puts("ARC");
    else
        puts("AGC");
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed  main()
{
  string a;
  cin>>a;
  if(a[0]=='Y' && a[1]=='A' && a[2]=='K' && a[3]=='I'){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}


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

/* initialize */
struct Node{
    int key;
    Node *parent, *left, *right;
};
Node *root, *NIL;
/* main */
void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x!=NIL){
        y = x;
        if (z->key < x ->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL){
        root = z;
    } else {
        if (z->key < y->key){
            y ->left = z;
        }else{
            y->right = z;
        }
    }
}

void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
};

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
};
Node * find(Node *u, int k){
    while ( u!= NIL && k != u->key){
        if ( k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}
int main() {
    int n;
    int x;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        if ( s == "insert"){
            scanf("%d", &x);
            insert(x);
        } else if  ( s == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (s == "find"){
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;

}


Measured memory_bytes: 21992
while True:
	try:
		nums = [0 for x in xrange(13)]
		hands = map(int,raw_input().split(','))
		for val in hands: nums[val-1] += 1
		if 4 in nums: print 'four card'
		else:
			if 3 in nums:
				if 2 in nums: print 'full house'
				else: print 'three card'
			else:
				if nums.count(2) == 2: print 'two pair'
				elif nums.count(2) == 1: print 'one pair'
				else:
					hands2 = ''
					for val in xrange(14): hands2 += str(nums[val%13])
					if '11111' in hands2: print 'straight'
					else: print 'null'
	except: break

Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
int n = 0, need[550], mid[550], ans[250500];
bool comp(int x, int y) { return need[x] < need[y];}
int tot[550];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> need[i], mid[i] = i, ans[need[i]] = i, tot[i] = 1;
	sort(mid + 1, mid + n + 1, comp);
	int p = 1;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j < mid[i]; j++)
		{
			while(ans[p]) p++;
			if(p > n * n) { cout << "No" << endl; return 0; }
			ans[p] = mid[i], tot[mid[i]]++;
		}
	}
	int q = 1;
	while(p <= n * n)
	{
		while(q < n and tot[mid[q]] == n) q++;
		if(not ans[p]) ans[p] = mid[q], tot[mid[q]]++;
		p++;
	}
	p = 1, memset(tot, 0, sizeof tot);
	for(int i = 1; i <= n * n; i++)
	{
		tot[ans[i]]++;
		if(p <= n and i == need[mid[p]])
		{
			if(tot[mid[p]] != mid[p]) { cout << "No" << endl; return 0; }
			p++;
		}
	}
	for(int i = 1; i <= n; i++)
		if(tot[i] != n) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
	for(int i = 1; i <= n * n; i++)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,k,mx=0,f=0;
    cin>>n>>k;
    vector<ll>v;
    for(int i=0; i<n; i++)
    {
        ll x,y;
        cin>>x;
        v.push_back(x);
        mx=max(mx,x);
    }
    sort(v.begin(),v.end());
    if(k==0)
    {
        cout<<mx<<endl;
        return 0;
    }
    ll l=1,r=mx;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        ll tot=0;
        for(int i=0; i<n; i++)
        {
            if(v[i]<=mid)
                continue;
            ll x=2,y=INT_MAX,ans=0;
            while(x<=y)
            {
                ll z=(x+y)>>1;
                int req=v[i]/z;
                if(v[i]%z)
                    req++;
                if(req<=mid)
                    y=z-1,ans=z;
                else
                    x=z+1;
            }
            tot+=ans-1;
        }
   //     cout<<mid<<" "<<tot<<endl;
        if(tot<=k)
            r=mid-1;
        else
            l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    };
} init;

int N;
int D[110000], n[110000], d[110000];
unordered_map<int, int> mp;
vint ans;
signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {cin >> D[i]; n[i] = 1; mp[D[i]] = i;};
    sort(D + 1, D + N + 1); reverse(D + 1, D + N + 1);
    for (int i = 1; i <= N - 1; i++) {
        int s = mp[D[i]];
        int t = mp[D[i] - N + 2 * n[s]];
        n[t] += n[s];
        d[t] += d[s] + n[s];
        ans.push_back(s); ans.push_back(t);
    }
    if (n[mp[D[N]]] != N || d[mp[D[N]]] != D[N]) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < 2 * (N - 1); i += 2) {
        cout << ans[i] << " " << ans[i + 1] << endl;
    }

}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in(), a = in(), b = in();
  int64_t ans = 0;
  for (int i = 1; i <= n; ++i) {
    int x = i;
    int d = 0;
    while (x) {
      d += x % 10;
      x /= 10;
    }
    if (a <= d && d <= b) {
      ans += i;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const int INF=0x3f3f3f3f;
int a[1000],n,m;
int main()
{
	int i,j,k,ans=0,mind=999999;
	cin>>n>>m;
	memset(a,0,sizeof(a));
	for(i=0;i<m;i++)
	{
		int x;
		cin>>x;
		a[x+100]=1;
	}
	for(i=0;i<=101;i++)
	{
		if(a[i+100]==0 && abs(i-n)<mind)
		{
			ans=i;
			mind=abs(i-n);
		}
	}
	for(i=0;i>=-100;i--)
	{
		if(a[i+100]==0 && abs(i-n)<mind)
		{
			ans=i;
			mind=abs(i-n);
		}
	}
	if(m==0)
	{
		cout<<n<<endl;
	}
	else
		cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	LL N;
	cin >> N;

	vector<LL> v(N);

	REP(i, N) {
		cin >> v[i];
	}

	BACKSORT(v);

	LL A = 0;
	LL B = 0;

	REP(i, N) {
		LL score = v[i];
		if (i % 2 == 0) {
			A += score;
		}
		else {
			B += score;
		}
	}
	cout << A - B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    double l,sug,vol=0;
    char token[100]={};
    fgets(token, sizeof(token), stdin);l=atoi(token);
    sug=l/3;
    vol=sug*sug*sug;
    printf("%f",vol);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	vector<int> v(3);
	v[0] = v[1] = v[2] = 0;
	for(int i = 0; i < S.length(); i++) {
		v[S[i] - int('a')]++;
	}
	bool ans = (*max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end())) <= 1;
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool same(string s) {
	rep(i,s.size()-1) {
		if(s[i+1] != s[i]) return false;
	}
	return true;
}
char change(char a, char b) {
	char c[3] = {'r', 'b', 'g'};
	rep(i,3) {
		if(a != c[i] && b != c[i]) return c[i];
	}
}
int bfs(string str) {
	queue<string> q;
	q.push(str);
	map<string, int> m;
	m[str] = 0;
	while(!q.empty()) {
		string s = q.front(); q.pop();
		if(same(s)) return m[s];
		rep(i,s.size()-1) {
			if(s[i+1] != s[i]) {
				string ns = s;
				ns[i+1] = ns[i] = change(ns[i+1],ns[i]);
				if(!m[ns]) {
					q.push(ns);
					m[ns] = m[s] + 1;
				}
			}
		}
	}
	return -1;
}
int main(){
	string s;
	while(cin >> s) {
		if(s =="0") break;
		int ret = bfs(s);
		if(ret == -1) cout << "NA" << endl;
		else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 2888
#include <atcoder/all>

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using namespace atcoder;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 998244353LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  using T = pair<lint, lint>;
  using E = pair<lint, lint>;
  auto f = [](T a, T b){ // return type T value
    return T((a.first + b.first) % MOD, (a.second + b.second) % MOD);
  };
  auto g = [](E b, T a){ // return type T value
    return T((a.first * b.first + a.second * b.second) % MOD, a.second % MOD);
  };
  auto h = [](E b, E a){ // return type E value
    return T(a.first * b.first % MOD, (a.second * b.first + b.second) % MOD);
  };
  auto ti = []() {
    return T(0, 0);
  };
  auto ei = []() {
    return E(1, 0);
  };

  int n, q; cin >> n >> q;
  vector<T> dat(n);
  for (int i = 0; i < n; i++) {
    lint a; cin >> a;
    dat[i] = T(a, 1);
  }

  lazy_segtree<T, f, ti, E, g, h, ei> sg(dat);
  
  for (int i = 0; i < q; i++) {
    int o; cin >> o;
    if (o == 0) {
      lint l, r, b, c; cin >> l >> r >> b >> c;
      sg.apply(l, r, E(b, c));
    } else {
      int l, r; cin >> l >> r;
      cout << sg.prod(l, r).first << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 35396
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process);
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        //string[] strs = new string[n];
        //int[][] arr = new int[n][];
        long count = 0;

        var dic = new Dictionary<string, int>();

        for (int i=0; i<n; i++) {
            List<int> list = new List<int>(10);
            string tmp = input.ReadLine();
            for (int j = 0; j < 10; j++) {
                int c = tmp[j];
                list.Add(c);
            }
            list.Sort();
            var buil = new StringBuilder();
            foreach (var x in list) {
                buil.Append(x);
                buil.Append(',');
            }
            var ary = buil.ToString();
            if (!dic.ContainsKey(ary)) dic[ary] = 1;
            else {
                count += dic[ary];
                dic[ary] += 1;
            }
        }
        return count;
    }
}

Measured memory_bytes: 33436
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>
#include <cstring>

using namespace std;

int main(){

    int n,cnt=0;
    cin >> n;
  
  	vector<int> a(n,0);

    for(int i=0;i<n;++i){
        cin >> a[i];
    }
  
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    a.push_back(-1);

    int mrk = 0;
    for(int i=1;i<=n;++i){
        if(a[i-1] > a[i]){
            if(i-mrk < a[i-1]) cnt += i-mrk;
            if(i-mrk > a[i-1]) cnt += i-mrk-a[i-1];
            mrk = i;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate
N,M = map(int,input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uni = UnionFind(N)
ab = []
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab.append((a,b))
ab = ab[::-1]
ans = []
for a,b in ab:
    if not uni.same(a,b):
        ans.append(uni.size(a)*uni.size(b))
    else:
        ans.append(0)
    uni.union(a,b)
ans = accumulate(ans[::-1])
for i in ans:
    print(i)
    


Measured memory_bytes: 104024
N = int(input())
x, y, h = zip(*(map(int, input().split()) for _ in range(N)))
def solve():
    for Cx in range(100 + 1):
        for Cy in range(100 + 1):
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy)
                    break
            if all(map(lambda i: h[i] == max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0), range(N))):
                print(Cx, Cy, H)
                return
solve()

Measured memory_bytes: 3064
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
using namespace std;

using ll = long long;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  return a*b / gcd(a, b);
}

#include <iostream>
#include <vector>
#include <map>

class Prime {
// n以下の素数を列挙する
public:
  const int n;
  vector<bool> is_prime;
  vector<int> primes;
  Prime(int size) : n(size), is_prime(n+1, true) {
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; ++i) {
      if (!is_prime[i]) continue;
      primes.push_back(i);
      int tmp = 2*i;
      while (tmp <= n) {
        is_prime[tmp] = false;
        tmp += i;
      }
    }
  }

  bool check(int x) { return is_prime[x]; }
};

struct PrimeFactorization {
  // n*n以下の数についての素因数分解
  const int n;
  Prime p;
  PrimeFactorization(int n) : n(n), p(n) {}

  map<int, int> calc(int a) {
    map<int, int> ret;
    int tmp = a;
    for (int i: p.primes) {
      if (i > tmp) break;
      int count = 0;
      while (tmp % i == 0) { 
        ++count;
        tmp /= i;
      }
      if (count > 0) ret[i] = count;
    }
    if (tmp > 1) ret[tmp] = 1;
    return ret;
  }
};


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n; cin >> n;
  bool pairwise = true;
  PrimeFactorization pf(1001);
  vector<bool> primes(1000001);

  int g = -1;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (g == -1) g = a;
    auto fact = pf.calc(a);
    for (auto it: fact) {
      if (!pairwise) break;
      int d = it.first;
      if (primes[d]) { 
        pairwise = false;
      }
      primes[d] = true;
    }
    if (g > 1) {
      g = gcd(a, g);
    }
  }
  bool setwise = (g == 1);
  if (pairwise) {
    cout << "pairwise coprime" << endl;
  }
  else if (setwise) {
    cout << "setwise coprime" << endl;
  }
  else {
    cout << "not coprime" << endl;
  }
}



Measured memory_bytes: 3784
#include<stdio.h>
#include<stdlib.h>

#define MAX 2000001
#define VMAX 10000
void CountingSort(int *,int *,int , int);

int main(){
  int n,*a,*b,i,max;

  scanf("%d",&n);
  if(n < 1 || 2000000 < n)exit(0);

  a = (int *)malloc((n+1)*sizeof(int));
  b = (int *)malloc((n+1)*sizeof(int));

  scanf("%d",&a[0]);
  max = a[0];
  for(i = 1; i < n; i++){
    scanf("%d",&a[i]);
    if(a[i] < 0 || 10000 < a[i])exit(0);
    if(max < a[i])max = a[i];
  }

  CountingSort(&a[0],&b[0],max,n);

  printf("%d",b[1]);
  for(i = 2; i <= n; i++){
    printf(" %d",b[i]);
  }
  printf("\n");
  
  return 0;
}

void CountingSort(int *a,int *b,int k,int n){
  int i,*c,j;
  
  c = (int *)malloc((k+1)*sizeof(int));
  
  for(i = 0; i <= k; i++){
    c[i] = 0;
  }
  
  for(j = 0; j < n; j++){
    c[a[j]]++;
  }

  for(i = 1; i <= k ; i++){
    c[i] = c[i] + c[i - 1];
    //printf("c[%d] = %d\n",i,c[i]);
  }

  for(j = n-1; 0 <= j; j--){
    b[c[a[j]]] = a[j];
    //printf("b[%d]= %d\n",c[a[j]],b[c[a[j]]]);
    c[a[j]]--;
  }
}



Measured memory_bytes: 17400
#include <iostream>

unsigned short calculate_area (const unsigned short* const radius)
{
	return (unsigned short)(3) * *radius * *radius;
}

int main (void)
{
	// variables for main process
	register unsigned short r;

	// STEP.01
	// read out the given data
	std::cin >> r;

	// STEP.02
	// output the answer of this task
	std::cout << calculate_area (&r) << std::endl;

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	long long ans;
	ans = k;
	for (int i = 0; i < n - 1; i++) {
		ans = ans*(k - 1);
	}
	cout << ans << endl;
	return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int check_string(string &S, int pos){
    vector<string> candidates;
    candidates.push_back("dream");
    candidates.push_back("dreamer");
    candidates.push_back("erase");
    candidates.push_back("eraser");

    if(S.size()-pos<=7){
        int res = S.size()-pos;
        if(res==7){
            if(S.substr(pos, 7)=="dreamer"){
                return 1;
            }else{
                return -1;
            }
        }
        if(res==5){
            if(S.substr(pos, 5)=="dream" || S.substr(pos,5)=="erase"){
                return 1;
            }else{
                return -1;
            }
        }
        if(res==6){
            if(S.substr(pos, 6)=="eraser" ){
                return 1;
            }else{
                return -1;
            }
        }
        /*
        for(int i=0;i<candidates.size();i++){
            if(S.substr(pos, candidates.at(i).size())==candidates.at(i)){
                if(res==candidates.at(i).size()){
                    return 1;
                }else{
                    return -1;
                }
            }
        }
        return -1;
        */
    }



    int flag = 0;
    for(int i=0;i<candidates.size();i++){
        if(S.substr(pos, candidates.at(i).size())==candidates.at(i)){
            int temp = check_string(S, pos+candidates.at(i).size());
            if(temp==1)flag=1;
        }
    }
    if(flag==1){
        return 1;
    }else{
        return -1;
    }

}

signed main(){
    string S; cin>>S;

    int top_pos = 0;
    int lnegth = S.size();

    int check = check_string(S,top_pos);
    if(check==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;

    }


    return 0;
}

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


int main() {
    int N;
    std::cin >> N;
    long long int max, box = 0;
    std::cin >> max;
    for (int i = 1; i < N; i++) {
        long long int a;
        std::cin >> a;
        if (a < max) {
            box += max - a;
        } else {
            max = a;
        }
    }
    std::cout << box << std::endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
int main(void){
    for(;;){
        int a,b;
        char op;
        cin >> a >> op >> b;
        if(op=='?')break;
        if(op=='+')cout << a+b << endl;
        if(op=='-')cout << a-b << endl;
        if(op=='*')cout << a*b << endl;
        if(op=='/')cout << a/b << endl;
        
    }
}
    



Measured memory_bytes: 3076
s=list(input().split())
n=int(s[0])
m=int(s[1])
c=int(s[2])
b=list(input().split())
a=[]
count=0
for i in range(n):
  a.append(list(input().split()))
for i in range(n):
  total=0
  for j in range(m):
    total=total+int(a[i][j])*int(b[j])
  if total+c>0:
    count+=1
print(count)
    

Measured memory_bytes: 38384
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

void solve(long long N, long long M, std::vector<std::vector<long long>> A) {
  rep(i, N) {
    rep(j, M) { A[i][j]--; }
  }

  vector<bool> checked(M);
  ll ans = INF;
  rep(i, M) {
    vector<int> sum(M);
    rep(j, N) {
      rep(k, M) {
        if (!checked[A[j][k]]) {
          sum[A[j][k]]++;
          break;
        }
      }
    }

    ll maxSum = 0;
    ll maxSumi = 0;
    rep(k, M) {
      if (sum[k] > maxSum) {
        maxSum = sum[k];
        maxSumi = k;
      }
    }

    if (ans > maxSum) {
      ans = maxSum;
    }

    checked[maxSumi] = true;
  }

  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      scanf("%lld", &A[i][j]);
    }
  }
  solve(N, M, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int):
    if N==M:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n=parse(Int,readline())
s=[]
for i=1:n
	push!(s,chomp(readline()))
end
f=0
for i=2:n
	if s[i-1][length(s[i-1])]!=s[i][1]
		f+=1
	end
	for j=1:i-1
		if s[i]==s[j]
			f+=1
		end
	end
end
println(f>0?"No":"Yes")


Measured memory_bytes: 165532
def solve(n,k,a):
    S=[0]*(n+1)
    S[0]=a[0]
    for i in range(0,n):
        S[i+1]=S[i]+a[i]
    ans=-S[k-1]
    for i in range(0,n-k+1):
        if ans<S[i+k]-S[i]:
            ans=S[i+k]-S[i]
    return ans
n,k=map(int,input().split())
while n>0:
    a=[int(input()) for _ in range(n)]
    ans=solve(n,k,a)
    print(ans) 
    n,k=map(int,input().split())


Measured memory_bytes: 13424
from collections import deque
from bisect import bisect_left, bisect_right

n, q = map(int, input().split())
list_x = deque()
list_y = deque()
memo_x = deque()
memo_y = deque()
x_now, y_now = n-1, n-1

ans = (n-2) ** 2

#que = [(1, i) for i in range(2, n)] + [(2, i) for i in range(2, n)]
for i in range(q):
    flg, x = map(int, input().split())
    if flg == 1:
        if x_now >= x:
            ans -= y_now - 1
            x_now = x - 1
            list_x.appendleft(x)
            memo_x.appendleft(y_now - 1)
        else:
            tmp = bisect_left(list_x, x) - 1
            ans -= memo_x[tmp]
    
    else:
        y = x
        if y_now >= y:
            ans -= x_now - 1
            y_now = y - 1
            list_y.appendleft(y)
            memo_y.appendleft(x_now - 1)
        else:
            tmp = bisect_left(list_y, y) - 1
            ans -= memo_y[tmp]

print(ans)

Measured memory_bytes: 25020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,i,j,k,s=0;
  cin>>n;
  i=n/500;
  s=i*1000;
  i=n%500;
  i=i/5;
  s+=i*5;
  cout<<s;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<ll, ll>;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n, ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2, mod) % mod);
	else
		return (x * pow(x, n - 1, mod) % mod);
}ll zero = 0;
signed main() {
	int n, k, q; cin >> n >> k >> q;
	vector<int>a(q);
	rip(i, q)cin >> a[i];
	vector<int>point(n, 0);
	rip(i, q)point[a[i] - 1]++;
	rip(i, n) {
		if (q - point[i] < k)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 4000
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a;
	string s;
	cin>>a>>s;
	cout<<(a>=3200?s:"red")<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
w = []
b = []
r = []
for i in range(n):
  s = input()
  w.append(m - s.count("W"))
  b.append(m - s.count("B"))
  r.append(m - s.count("R"))
ans = 3000
for i in range(1, n - 1):
  for j in range(i, n - 1):
    ans = min(ans, sum(w[:i]) + sum(b[i:j+1]) + sum(r[j + 1:]))
print(ans)



Measured memory_bytes: 5604
N = int(input())
A = list(map(int, input().split()))


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def gcd_arr(a):
    ans = a[0]
    for i, a_i in enumerate(a):
        ans = gcd(ans, a_i)
    return ans

print(gcd_arr(A))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair

vector <int> adj[100002];
int dp[100002],visited[199992];

void dfs(int u){
	visited[u]=1;
	for(int i=0;i<adj[u].size();i++){
		if(!visited[adj[u][i]]){
			dfs(adj[u][i]);
		}
		dp[u] = max(dp[u],dp[adj[u][i]]+1);
	}
}

int main(){
	int n,m,u,v;
	scanf("%d%d",&n,&m);

	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
	}

	for(int i=1;i<=n;i++){
		dp[i]=0;
		visited[i]=0;
	}

	for(int i=1;i<=n;i++){
		if(!visited[i]){
			dfs(i);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){	
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans );
	return 0;
}


Measured memory_bytes: 8576
L, R = gets.chop.split.map(&:to_i)

min_mod = 2019

for i in L..R-1
  for j in i+1..R
    if min_mod > i*j % 2019
      min_mod = i*j % 2019
    end
    if min_mod == 0
      puts 0
      exit
    end
  end
end

puts min_mod

Measured memory_bytes: 3836