akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    vector<string> vec={"thu","fri","sat","sun","mon","tue","wed"};
    INT(n);
    out(vec[n%7]);
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli H,W,h,w;

int main(){
  cin >> H >> W >> h >> w;
  if(H%h == 0 && W%w == 0){
    cout << "No" << endl;
    return 0;
  }
  if(W%w != 0){
    vll s(W+1);
    for(lli i = w;i <= W;i += w){
      s[i] = s[i-w]-1;
    }
    s[W] = 1;
    for(lli i = W-w;i >= 0;i -= w){
      s[i] = s[i+w]+1;
    }
    for(lli i = 0;i <= W-w;i++){
      if(s[i] <= s[i+w]) s[i+w] = s[i]-1;
    }
    cout << "Yes" << endl;
    for(lli i = 0;i < H;i++){
      for(lli j = 0;j < W;j++){
        cout << s[j+1]-s[j] << (j == W-1 ? "\n" : " ");
      }
    }
  }else{
    vll s(H+1);
    for(lli i = h;i <= H;i += h){
      s[i] = s[i-h]-1;
    }
    s[H] = 1;
    for(lli i = H-h;i >= 0;i -= h){
      s[i] = s[i+h]+1;
    }
    for(lli i = 0;i <= H-h;i++){
      if(s[i] <= s[i+h]) s[i+h] = s[i]-1;
    }
    cout << "Yes" << endl;
    for(lli i = 0;i < H;i++){
      for(lli j = 0;j < W;j++){
        cout << s[i+1]-s[i] << (j == W-1 ? "\n" : " ");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1408
a, b, c = map(int, input().split())

L1 = a*b*(c//2)-a*b*(c-c//2)
L2 = a*(b//2)*c-a*(b-b//2)*c
L3 = (a//2)*b*c-(a-a//2)*b*c
L = [abs(L1), abs(L2), abs(L3)]
print(min(L))


Measured memory_bytes: 61956
n,k=map(int,input().split())#n面ダイス,k点
p=0
if n >= k:
    p+=(n-k+1)/n#サイコロを振った時点で超える確率


a=n+1 if n<k else k
for i in range(1,a):#iの目がでたとき
    p_tmp=(1/n)
    j=i
    while j<k:
        p_tmp*=0.5
        j*=2
    p+=p_tmp

print(p)


Measured memory_bytes: 38896
#include <stdio.h>
int main()
{
	int N, K;
	char S[11];
	scanf("%d%s%d", &N, S, &K);
	int i;
	for (i = 0; S[i] != '\0'; i++) {
		if (S[i] != S[K-1])S[i] = '*';
	}
	printf("%s\n", S);
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int n;
vector<ll> s;
vll sums;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n;
  s.resize(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  sums.resize(n + 1);
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < n; j += i) sums[i] += s[j];
  }

  ll ans = 0;
  if (n % 2 == 0) {
    ll sum = 0;
    for (auto &v : s) sum += v;
    ans = max(ans, sum);
  }
  for (int c = 1; c <= n; c++) {
    vector<ll> d;
    for (int k = 0; k * c < n; k++) {
      int a = n - 1 - c * k;
      int b = a - c;
      if (b <= 0 || b >= n || a <= 0 || a >= n) continue;
      if ((c * k - a) % c == 0) {
        int k2 = (c * k - a) / c;
        if (k2 < k && k2 >= 0) continue;
      }
      if (k == 0) {
        d.push_back(s[a]);
      } else {
        d.push_back(d[d.size() - 1] + s[a] + s[c * k]);
      }
      ans = max(ans, d[d.size() - 1]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2800
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
mo=10**9+7
n=10**5

#n,a,b=map(int,input().split())
n=int(input())
x=set()
for i in input().split():
    x.add(int(i))
ans=len(x) - (1 if (n-len(x))%2==1 else 0)
#x.sort()
print(ans)


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    LL N;
    cin>>N;
    V<LL> A(N);
    REP(i,N) cin>>A[i];

    REP(i,N){
        if(A[i] == 0){
            cout<<0<<endl;
            return 0;
        }
    }

    LL ans = 1;
    REP(i,N){
        if(A[i] <= 1000000000000000000/ans){
            ans *= A[i];
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3976
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse4,sse4.2,popcnt,abm,mmx,avx")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

vector<int> a, b, res;

int n;

map<int, int> cnt_a, cnt_b;

const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);

bool validate() {
  bool valid = true;
  for (int i = 0; i < n; ++i) {
    valid &= (a[i] != res[i]);
  }
  return valid;
}

bool solve() {
  res = b;
  for (int t = 0; t < 70; ++t) {
    rotate(begin(res), begin(res) + rng() % n, end(res));
    if (validate()) return true;
  }
  res = b;
  reverse(all(res));
  for (int t = 0; t < 70; ++t) {
    if (validate()) return true;
    shuffle(all(res), rng);
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif
  cin >> n;
  a.resize(n), b.resize(n), res.resize(n);
  cin >> a >> b;
  for (int x : b) ++cnt_b[x];
  for (int x : a) {
    ++cnt_a[x];
    if (cnt_b.count(x) && cnt_b[x] + cnt_a[x] > n) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (solve()) {
    cout << "Yes" << endl;
    cout << res << endl;
    return 0;
  }

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


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

int main(){
  
  int cost = 700;
  string s;
  
  cin >> s;
  
  for(int i = 0;i < 3;i++) if(s[i] == 'o') cost += 100;
  
  cout << cost << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin >> S;
  int N = S.size();
  unordered_set<char> st;
  for(int i = 0; i < N; ++i)
    st.insert(S[i]);
  if(N < 26){
    for(char i = 'a'; i != 'z'; i = char(i + 1)){
      if(st.count(i) == 0){
	cout << S + i << endl;
	return 0;
      }
    }
  }
  for(int i = 24; i >= 0; --i){
    if(S[i] < S[i + 1]){
      int j = 25;
      while(S[i] > S[j])--j;
      swap(S[i], S[j]);
      cout << S.substr(0,i+1) << endl;
      return 0;
    }
  }
  cout << -1 << endl; 
  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//int dxy[5] = {0, 1, 0, -1, 0};
// assign

vi num, ans;
int n, ans_max;
bool rejected;
string input;

void solve(string data);

signed main()
{
    while (cin >> n >> input, n) {
        ans_max = -1;
        solve(input);
        if (rejected) {
            cout << "rejected" << endl;
        } else if (ans_max == -1 ) {
            cout << "error" << endl;
        } else {
            cout << ans_max;
            for (int i : ans) {
                cout << " " << i;
            }
            cout << endl;
        }
    }
    return 0;
}

void solve(string data)
{
    int a = 0;
    if (!data.size()) {
        int tmp = 0;
        for (int i : num) {
            tmp += i;
        }
        if (tmp > ans_max && tmp <= n) {
            rejected = false;
            ans_max = tmp;
            ans = num;
        } else if (tmp == ans_max) {
            rejected = true;
        }
        return ;
    }
    rep(i, data.length()) {
        a *= 10;
        a += data[i] - '0';
        num.eb(a);
        solve(&data[i+1]);
        num.pop_back();
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  ll A;
  cin>>A;
  ll ans = 0;
  while(A>0){
    A/=2;
    ans++;
  }
  ll anstemp = 1;
  for(ll i = 0;i<ans;i++){
    anstemp *= 2;
  }
  cout << anstemp -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,A;
  A =1;
  cin>>N>>K;
  for(int i=0; i<N; i++){
    if(A<=K){
      A *=2;
    }
    else if(A>K){
      A += K;
    }
  }
  cout<<A<<endl;
}

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

const int mod = 1'000'000'000 + 7;

ll sum(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }

int main() {
  int n, k;
  cin >> n >> k;

  ll ans = 0;
  for (int i = k; i <= n + 1; i++) {
    ll _min = sum(0, i - 1);
    ll _max = sum(n - i + 1, n);
    ans += _max - _min + 1;
    ans %= mod;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#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 eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

const int mod=1e9+7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    int cnt[N+10];
    cnt[0]=0;
    cnt[1]=0;
    rep(i,N+5){
        cnt[i+2]=cnt[i+1]+i+1;
    }
    int ans=0;
    rng(i,K,N+2){
        ans+=cnt[N+1]-cnt[N+1-i]-cnt[i]+1;
        ans%=mod;
    }
    cout << ans << endl;
}

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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(const char* s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(char s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int64 s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    cout << "(";
    print(p.first, false);
    cout << ", ";
    print(p.second, false);
    cout << ")";

    if (endline) print();
}

template <typename T>
void print(T& t, bool endline = true) {
    cout << "[";
    for (auto it = t.begin(); it != t.end(); ++it) {
        if (it != t.begin()) cout << ", ";
        print(*it, false);
    }
    cout << "]";

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

bool c(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.first + a.second > b.first + b.second); 
}

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int count = 0;
    int ret = 0;

    char prev = s[0];
    int cur = 0;

    for(int i = 0; i < n; ++i) {
        if((i < n - 1) and ((s.substr(i, 2)) == "LR" or s.substr(i, 2) == "RL")) {
            count++;
        }

        if(s[i] == prev) {
            cur++;
        } else {
            ret += cur - 1;
            cur = 1;
            prev = s[i];
        }
    }

    ret += cur - 1;
    ret += min(k * 2, count);

    print(ret);

    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var A, B, C, X int
	var res int
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)
	fmt.Scan(&X)

	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				total := a * 500 + b * 100 + c * 50
				if total == X {
					res++
				}
			}
		}
	}

	fmt.Println(res)
	
}

Measured memory_bytes: 512
// A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200;

int n, dp[MAX_N][2];
char str[MAX_N];

int main()
{
	scanf("%s", str + 1), n = strlen(str + 1);
	for (int i = 1; i <= n; i++)
	{
		if (str[i] != str[i - 1])
			dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
		if (i >= 2)
		{
			dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1);
			dp[i][1] = dp[i - 2][0] + 1;
			if (i >= 4 && str[i] != str[i - 2] && str[i - 1] != str[i - 3])
				dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
		}
	}
	printf("%d\n", max(dp[n][0], dp[n][1]));
	return 0;
}

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

signed main(){
  int L,R;cin>>L>>R;
  if(R-L>3000){
    cout<<0<<endl;
    return 0;
  }
  int ans=3000;
  for(int i=L;i<=R;i++){
    for(int j=i+1;j<=R;j++){
      ans=min(ans,i*j%2019);
    }
  }
  cout<<ans<<endl;
}


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

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

  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int res = 0;
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        if (500 * i + 100 * j + 50 * k == x) res++;
      }
    }
  }

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


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,m,a,b,c=0,t=0;
  cin>>n>>m;
  vector<P> p(n);
  for(int i=0;i<n;i++){
    cin>>a>>b;
    p[i]=P(-a,-b);
  }
  sort(p.begin(),p.end());
  priority_queue<ll> pq;
  for(int i=0;i<n;i++){
    if(-p[i].first<=m){
      if(i==0) pq.push(p[i].second);
      else{
        if(p[i].first==p[i-1].first) t++;
        else t=0;
        if((ll)pq.size()-p[i].first<=m) pq.push(p[i].second);
        else{
          if(t-p[i].first<=m && pq.top()>p[i].second){
            pq.pop();pq.push(p[i].second);
          }
        }
      }
    }
  }
  while(!pq.empty()){
    c+=-pq.top();pq.pop();
  }
  cout<<c;
}

Measured memory_bytes: 2936
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<(a-c)/(b+c)<<endl;
}

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

using namespace std;

int main()
{
    uint32_t nn;
    uint32_t num_100;
    uint32_t num_10;
    uint32_t num_1;
    cin >> nn;

    num_100 = nn / 100;
    num_10 = (nn % 100) / 10;
    num_1 = ((nn % 100) % 10);

    if((num_100 == 7)   ||
       (num_10 == 7)    ||
       (num_1 == 7))
       {
           cout << "Yes" << endl;
           return 0;
       }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
from subprocess import*
call(('pypy3','-c',"""
r=range
M=10**9+7
n=input()
d=int(input())
dp=[[[0,0]for j in r(d)]for i in r(len(n)+1)]
dp[0][0][0]=1
for i,x in enumerate(map(int,n),1):
  for j in r(10):
    for k in r(d):
      dp[i][(j+k)%d][1]+=dp[i-1][k][1]
      dp[i][(j+k)%d][1]%=M
      if j<x:
        dp[i][(j+k)%d][1]+=dp[i-1][k][0]
        dp[i][(j+k)%d][1]%=M
      if j==x:
        dp[i][(j+k)%d][0]+=dp[i-1][k][0]
        dp[i][(j+k)%d][0]%=M
print(~-sum(dp[-1][0])%M)
"""))

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

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

const int MX = 2e5+5;
int n, a[MX];
stack<ii> rn;
stack<int> val;

void insert (int a, int b, int x) {
	if (a > b) return;

	while (rn.size() && rn.top().fi >= a) {
		rn.pop();
		val.pop();
	}

	if (rn.size() && rn.top().se >= a) {
		int t = rn.top().fi;
		rn.pop();
		rn.emplace(t, a - 1);
	}

	int ant = a;
	while (val.size() && val.top() == x) {
		ant = rn.top().fi;
		val.pop();
		rn.pop();
	}

	val.push(x);
	rn.emplace(ant, b);
}

bool esPos (int m) {
	while (rn.size()) rn.pop();
	while (val.size()) val.pop();

	rn.emplace(0, a[0]);
	val.push(1);

	for (int i = 1; i < n; i++) {
		if (a[i] > a[i-1]) {
			insert(a[i-1] + 1, a[i], 1);
		} else {
			while (rn.top().fi > a[i]) {
				rn.pop();
				val.pop();
			}

			if (rn.top().se > a[i]) {
				int t = rn.top().fi;
				rn.pop();
				rn.emplace(t, a[i]);
			}

			if (val.top() < m) {
				insert(a[i], a[i], val.top() + 1);
			} else {
				rn.pop();
				val.pop();

				if (rn.empty()) return 0;

				insert(rn.top().se, rn.top().se, val.top() + 1);
				insert(rn.top().se + 1, a[i], 1);
			}
		}
	}
	
	return 1;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}

	int i = 1, j = n, rep = 18;
	while (rep--) {
		int m = (i + j) / 2;
		if (esPos(m)) j = m;
		else i = m;
	}

	cout << j << endl;

	return 0;
}


Measured memory_bytes: 1024
# https://qiita.com/takayg1/items/7008e4c9584e42ae13c7

from collections import deque

N, M = (int(i) for i in input().split())

graph = [deque([]) for _ in range(N + 1)]
for _ in range(M):
    a, b = (int(i) for i in input().split())
    graph[a].append(b)
    graph[b].append(a)


seen = [-1] * (N + 1) 

def dfs(v):
    stack = [v]
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if seen[w] < 0:
                seen[w] = 0
                stack.append(w) 
        else:
            stack.pop()

ans = 0
for i in range(N):
    if seen[i + 1] < 0:
        dfs(i + 1)
        ans += 1

print(ans - 1)

Measured memory_bytes: 141668
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 998244353
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }


int LIS(vector<int>& v) {
	int N = v.size();
	vector<int> dp(N, INF);

	for (int i = 0; i < N; i++)
		* lower_bound(dp.begin(), dp.end(), v[i]) = v[i];

	int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	return ans;
}

int LDS(vector<int> v) {
	int N = v.size();
	rep(i, N) v[i] *= -1;
	vector<int> dp(N, INF);

	for (int i = 0; i < N; i++)
		* lower_bound(dp.begin(), dp.end(), v[i]) = v[i];

	int ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
	return ans;
}

signed main() {

	int N, A, B;
	cin >> N >> A >> B;

	if (A + B > N+1 || A * B < N) { cout << -1 << endl; return 0; }

	vector<int> v;

	//	B B-1 B-2 ... 2 1 
	//	B*2 B*2-1 ... B+2 B+1
	//  B*A B*A-1

	int del = A*B - N;
	int delg, delrem;
	if (B == 1) {
		delg = 0;
		delrem = 0;
	}
	else {
		delg = del / (B - 1);
		delrem = del % (B - 1);
	}
	for (int a = 0; a < A; a++) {
		if (a < delg) v.push_back(B * (a + 1));
		else if (a == delg) {
			for (int b = delrem; b < B; b++) v.push_back(B * (a + 1) - b);
		}else
			for (int b = 0; b < B; b++) v.push_back(B * (a + 1) - b);
	}


	vector<int> vals;
	for (int i = 0; i < v.size(); ++i) vals.push_back(v[i]);
	sort(vals.begin(), vals.end());
	vals.erase(unique(vals.begin(), vals.end()), vals.end());
	for (int i = 0; i < v.size(); ++i) {
		cout << 1 + lower_bound(vals.begin(), vals.end(), v[i]) - vals.begin() << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 12396
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def decrease(d, j):  # d:日にち, j:開催するコンテスト
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  # 貪欲でとった解を1度保存する
    global now
    for i in range(D):  # i+1日目
        ma = -INF
        ma_idx = None
        for j in range(26):  # 開催するコンテスト
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  # d日目のところをqに変更する
    d -= 1
    q -= 1
    c = ans[d]-1  # c:更新前
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]
ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()
rand = random.randint
for _ in range(10**5):
    d = rand(1, D)
    q = rand(1, 26)
    old = ans[d-1]
    old_score = score.copy()
    update(d, q)
    if sum(score) <= sum(old_score):
        score = old_score
        ans[d-1] = old

print(*ans, sep="\n")


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

void solve(int n, int m){
  vector<bool> num(8368791,false);
  ll cnt = m;
  while(true){
    if(num[cnt] == false){
      if(n == 0) break;
      n--;
      ll x = 2;
      while(x*cnt<8368791){
        num[cnt*x] = true;
        x++;
      }
    }
    cnt++;
  }
  cout << cnt << endl;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m,n;

  while(true){
    cin >> m >> n;
    if(n == 0 && m == 0) break;
    solve(n,m);
  }
  return 0;
}



Measured memory_bytes: 4156
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
X = int(input())

num = 100
ans = 0
while num<X:
    num = num*101//100
    ans += 1
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9152
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
 
c = Counter(A)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i]) * (c[i]-1) // 2
 
for i in A:
    ans = comb - (c[i]-1)
    print(ans)
  
  

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

int main () {

    string S;
    cin >> S;

    int left, right;
    if (S.size()%2 == 0) {
        left = S.size()/2 - 1;
        right = S.size()/2;
    }
    else {
        left = S.size()/2;
        right = S.size()/2;
    }

    int ans = 0;
    while (left >= 0 && right < S.size()) {
        if (S[left] != S[right]) {
            ans++;
        }
        left--;
        right++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///dp[i] = True if the first player wins
///// if there are i stones remaining
int main()
{
    int nstone,height;
    cin>>nstone>>height;
    vector<int>v(nstone);
    vector<bool>dp(height+1);
    for(int &x:v)cin>>x;
    for(int curr_height=0;curr_height<=height;curr_height++)
    	{
    		for(int x:v)
    		{
    			if(curr_height>=x and !dp[curr_height-x])
    				dp[curr_height]=1;
    		}
    	}

   cout<<(dp[height]?"First":"Second");
     		
}

Measured memory_bytes: 256
//---------- begin union_find ----------
#[allow(dead_code)]
mod union_find {
    pub struct UF {
        p: Vec<i32>,
    }
    impl UF {
        pub fn new(n: usize) -> UF {
            UF {p: vec![-1; n] }
        }
        pub fn init(&mut self) {
            for p in self.p.iter_mut() {
                *p = -1;
            }
        }
        pub fn root(&mut self, mut x: usize) -> usize {
            while self.p[x] >= 0 {
                let p = self.p[x] as usize;
                if self.p[p] >= 0 {
                    let q = self.p[p];
                    self.p[x] = q;
                    x = q as usize;
                } else {
                    x = p;
                }
            }
            x
        }
        pub fn same(&mut self, x: usize, y: usize) -> bool {
            self.root(x) == self.root(y)
        }
        pub fn unite(&mut self, x: usize, y: usize) -> Option<(usize, usize)> {
            let mut x = self.root(x);
            let mut y = self.root(y);
            if x == y {
                return None;
            }
            if self.p[x] > self.p[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.p[x] += self.p[y];
            self.p[y] = x as i32;
            Some((x, y))
        }
        pub fn parent(&self, x: usize) -> Option<usize> {
            let p = self.p[x];
            if p >= 0 {
                Some(p as usize)
            } else {
                None
            }
        }
        pub fn get_size(&mut self, x: usize) -> usize {
            let r = self.root(x);
            (-self.p[r]) as usize
        }
    }
}
//---------- end union_find ----------

use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        n: usize,
        p: [(Usize1, Usize1); n],
    }
    let w = 100_000;
    let mut dp = vec![(0usize, 1usize); 2 * w];
    for p in dp.iter_mut().take(w) {
        *p = (1, 0);
    }
    let mut u = union_find::UF::new(2 * w);
    for (x, y) in p {
        if let Some((a, b)) = u.unite(x, y + w) {
            dp[a].0 += dp[b].0;
            dp[a].1 += dp[b].1;
            dp[b] = (0, 0);
        }
    }
    let ans = dp.into_iter().map(|p| p.0 * p.1).sum::<usize>() - n;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 8608
<?php
while ($n = trim(fgets(STDIN))) {
    $score = array('a' => 0, 'b' =>0);
    for ($i = 0; $i < $n; $i++) {
        list($a_card, $b_card) = explode(' ', trim(fgets(STDIN)));
        if($a_card == $b_card) {
            $score['a'] += $a_card;
            $score['b'] += $b_card;
        } elseif($a_card > $b_card) {
            $score['a'] += $a_card + $b_card;
        } else {
            $score['b'] += $a_card + $b_card;
        }
    }
    echo implode(' ', $score).PHP_EOL;
}


Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d;
  
  if(a==b){
    d=c;
  }
  else if(a==c){
    d=b;
  }
  else{
    d=a;
  }
  
  cout<<d<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int n, v, a[N];
  int i, j;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }

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

  for(i=1;i<=n-1;i++){
    v = a[i];
    j = i - 1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

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



Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    public static void Solve()
    {
        int N = NextInt();
        Dictionary<Pair, long> d = new Dictionary<Pair, NX>();
        long ans = 0;
        for (int x = 1; x <= N; x++)
        {
            if (x <= 9)
            {
                if (!d.ContainsKey(new Pair(x, x))) d[new Pair(x, x)] = 0;
                d[new Pair(x, x)]++;
                continue;
            }
            string s = x.ToString();
            int a = int.Parse(s[0].ToString());
            int b = int.Parse(s[s.Length - 1].ToString());
            if (!d.ContainsKey(new Pair(a, b))) d[new Pair(a, b)] = 0;
            d[new Pair(a, b)]++;
        }
        foreach (var e in d.Keys)
        {
            if (!d.ContainsKey(new Pair(e.y, e.x))) continue;
            ans += d[e] * d[new Pair(e.y, e.x)];
        }
        Console.WriteLine(ans);
    }
    public static long GCD(long a, long b)
    {
        if (a < b) GCD(b, a);
        long d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(long a, long b)
    {
        return a / GCD(a, b) * b;
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 15532
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
#define rep(i,n) for(int i=0;i<n;i++)
using P=pair<int,int>;
int main(){
    int n,m;
    cin>>n>>m;
    vector<P>p(m);
    rep(i,m)cin>>p[i].first>>p[i].second;
    rep(x,1000){
        int keta=1;
        int nx=x/10;
        vector<int>d(1,x%10);
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx/=10;
        }
        if(keta!=n)continue;
        bool ok=true;
        reverse(d.begin(),d.end());
        rep(i,m){
            if(d[p[i].first-1]!=p[i].second)ok=false;
        }
        if(ok){
            cout<<x<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(list(input()))
def calc_black_cnt(maskR, maskC):
    cnt = 0
    for i in range(h):
        for j in range(w):
            if maskR>>i & 1 == 0 and maskC>>j & 1 == 0 and c[i][j] == '#':
                cnt += 1
    return cnt
ans = 0
for maskR in range(1<<h):
    for maskC in range(1<<w):
         if calc_black_cnt(maskR, maskC) == k:
                ans += 1
print(ans)

Measured memory_bytes: 9072
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};



int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> c(n);
    for (auto &&i : c) scanf("%d", &i);
    vector<int> used(k+1, -1);
    int cnt = 0;
    vector<int> num(n);
    for (int i = 0; i < n; ++i) {
        if(!c[i]) num[i] = cnt++;
        else{
            if(!~used[c[i]]) {
                used[c[i]] = cnt;
                num[i] = cnt++;
            }else {
                num[i] = used[c[i]];
            }
        }
    }
    vector<edge<int>> G;
    for (int i = 0; i < m; ++i) {
        int a, b, w;
        scanf("%d%d%d", &a, &b, &w);
        a = num[a-1]; b = num[b-1];
        G.emplace_back(a, b, w);
    }
    sort(G.begin(),G.end(), [](edge<int> a, edge<int> b){
       return a.cost < b.cost;
    });
    UnionFind uf(cnt);
    ll ans = 0, x = 0;
    for(auto &&e : G){
        if(x >= k-1) break;
        if(uf.unite(e.from, e.to)){
            ans += e.cost;
            x++;
        }
    }
    if(x == k-1){
        cout << ans << "\n";
    }else {
        puts("-1");
    }
    return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main()
{
    char str[81];
    int i,j,l;

    while(fgets(str,sizeof(str),stdin) != NULL){
        l = strlen(str);
        for(i = 0; i < 26; i++){
            if(strstr(str,"the") != '\0' || strstr(str,"this") !=  '\0' || strstr(str, "that") != '\0')
                break;
            else{
                for(j = 0; j < l; j++){
                    if(('a' <= str[j] && str[j] <= 'y') || ('A' <= str[j] && str[j] <= 'Y'))
                        str[j]++;
                    else if(str[j] == 'z')
                        str[j] = 'a';
                    else if(str[j] == 'Z')
                        str[j] = 'A';
                }
            }
        }
        printf("%s", str);
    }

    return 0;
}

Measured memory_bytes: 524
N,Q = map(int,input().split())
S = input()
l = [0] * Q
r = [0] * Q

for i in range(Q):
    l[i],r[i] = map(int,input().split())

cs = [0]*(N+1)
for i in range(N-1):
    if(S[i] == 'A' and S[i+1] == 'C'):
        cs[i+2] = cs[i+1] + 1
    else:
        cs[i+2] = cs[i+1]
for q in range(Q):
    print(cs[r[q]] - cs[l[q]])

Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  veci v(26,0);
  char x=1;
  while(x){
    x=0;
    cin>>x;
    if(v[x-97]){cout<<"no"<<endl;return 0;}
    v[x-97]=1;
  }
  cout<<"yes"<<endl;
}

Measured memory_bytes: 256
# 解法：累積和
N = int(input())
S = input()
pos = 0
minpos = 0
mini = 0
# (1)WWWWEE
# (2)EEEWWW
# (3)WEWEEE
for i in range(N):
    if S[i] == "W":
        pos += 1
    else:
        pos -= 1
    if pos < minpos:
        minpos = pos
        mini = i

s1 = S[0:mini].count("W")
s2 = S[mini + 1:N].count("E")
print(s1 + s2)

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

int main() {
  // 入力
  long int N, K;
  cin >> N >> K;
  
  long int n = N;
  long int count = 0;
  while(1) {
    count++;
    if (n < K) {
      break;
    } else {
      n = n / K;
    }
  }
  
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256