akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  if (K == 1)
    cout << 0 << endl;
  else
    cout << (N - K) << endl;
  return 0;
}


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

//args: tax,price
int tax(int t,int p){
  return p*(100+t)/100;
}

bool solver(){
  int x,y,s;
  int i,j;
  int ans=0;
  cin>>x>>y>>s;
  if(x==0&&y==0&&s==0)return false;
  for(i=1;i<s;i++){
    for(j=1;j<s;j++){
      if(tax(x,i)+tax(x,j)==s)ans=max(ans,tax(y,i)+tax(y,j));
    }
  }
  cout<<ans<<endl;
  return true;
}

int main(){
  while(solver()){}
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int A;
  map<int,int> m;
  for(int i=0;i<N;i++){
    cin >> A;
    m[A]=i+1;
  }
  int n=0;
  for(auto p : m){
    cout << p.second;
    if(n==N-1){
      cout << endl;
    }else{
      cout << " ";
    }
    n++;
  }
  return 0;
}


Measured memory_bytes: 5632
// Take care of mod becoming -ve

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define fro(i, s, e) for (auto i = s; i <= e; ++i)
#define int long long
#define ld long double
#define fr(i, n) for (auto i = 0; i < n; i++)
#define ff first
#define pf pop_front()
#define ss second
#define mp make_pair
#define vi std::vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define setbits(x) __builtin_popcountll(x)
#define zrbits(x) __builtin_ctzll(x)
#define vii std::vector<int, int>
#define tc    \
    int t;    \
    cin >> t; \
    while (t--)
#define FILE                          \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout)
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define inp(a) \
    int a;     \
    cin >> a;
#define ps(x, y) fixed << setprecision(y) << x
#define mkarr(arr, n, type) type *arr = new type[n];
#define endl "\n"
#define rev(i, e, s) for (auto i = e; i >= s; --i)
const int mod = 1000000007;
#define min_pq priority_queue<int, std::vector<int>, greater<int>>
#define printclock cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
using namespace std;
const int N = 100005;
const int inf = 1000000000000000000;
#define fit(s, x) memset(s, x, sizeof(s));
#define out(x) cout << x << "\n"
#define deb(x) cout << #x << x << "\n"
#define pi 3.14159265358979323846264338327950
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    PBDS;
// Use __gcd(a,b) for gcd
// find(all(x),key) to get the iterator and its index is obtained by find(all(x),key)-x.begin()
// find_if(iterator_first,iterator_last,unary function) returns first iterator if any element corresponding to unary function exists and if no such element is found it retrurns the last iterator
/*For example:
find_if(all(x),isodd) for x being a vector{10,25,40,55}; *it returns 25*/
/*search(all(v1),all(v2),pred) searches for all the elements of v2 present in v1 based on pred function the iterator correspond
to the first element of sequence if it exists and if not then th elast iterator is obtained.*/
//use substr(size_t pos,size_t len) for the substrings
// iota(forward itr,backwrd itr,val) can be used for consecutive numbers
int power(int a, int b)
{
    long long ans = 1;
    while (b > 0)
    {
        if (b & 1LL)
        {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        b = (b >> 1LL);
    }
    return ans;
}
int a[305];
ld p[3005];
int n,k,m;
string s, t;
ld dp[3005][3005];
vector<int>graph[N];
int st[4*N];
pii dir[]={{1,0},{0,1}};
int32_t main()
{
    fio;
    cin>>n>>k;
    vector<int>a(n);
    for(auto&x:a)cin>>x;
    vector<bool>dp(k+1);
    for(int stones=0;stones<=k;stones++){
        for(auto x:a){
            if(x<=stones && !dp[stones-x]){
                dp[stones]=true;
            }
        }
    }
    out((dp[k]?"First":"Second"));
    printclock;
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int i,n,k;
    string a;
    cin>>n>>a;
    if(n&1)
    {
        cout<<"No";
        return 0;
    }
    string b=a.substr(0,n/2),c=a.substr(n/2,n/2);
    if(b==c)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n; cin >> n;
	vector<int> p(n), q(n);
	rep(i, n) {
		cin >> p[i];
		q[i] = p[i];
	}
	sort(all(q));
	int result = 0;
	rep(i, n) {
		if (p[i] != q[i]) result++;
	}
	if (result == 0 || result == 2) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
    return;
}

int main() {
    solve();
    return 0;
}



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

int main(){
    int M,K;
    cin >> M >> K;
    if (M == 0){
        if (K == 0){
            cout << "0 0" << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    else if (M == 1){
        if (K == 0){
            cout << "0 0 1 1" << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    else{
        int m = 1;
        rep(i,M){
            m *= 2;
        }
        if (K >= m){
            cout << -1 << endl;
        }
        else{
            vector<int> ans(0);
            rep(i,m){
                if (i != K) ans.push_back(i);
            }
            ans.push_back(K);
            for (int i = m - 1; i >= 0; i--){
                if (i != K) ans.push_back(i);
            }
            ans.push_back(K);
            rep(i,2 * m){
                cout << ans[i] << " ";
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 4324
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int dx[4] = {0, 1, 0, -1};
    const int dy[4] = {1, 0, -1, 0};
    int w, h;  // x,y
    while (cin >> w >> h, w + h) {
        int n;
        cin >> n;
        vector<int> x1(n), y1(n), x2(n), y2(n);
        vector<int> x, y;
        x.push_back(0);
        x.push_back(w);
        y.push_back(0);
        y.push_back(h);
        REP(i, 0, n) {
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
            x.push_back(x1[i]);
            x.push_back(x2[i]);
            y.push_back(y1[i]);
            y.push_back(y2[i]);
        }
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());
        x.erase(unique(x.begin(), x.end()), x.end());
        y.erase(unique(y.begin(), y.end()), y.end());
        REP(i, 0, n) {
            x1[i] = lower_bound(x.begin(), x.end(), x1[i]) - x.begin();
            x2[i] = lower_bound(x.begin(), x.end(), x2[i]) - x.begin();
            y1[i] = lower_bound(y.begin(), y.end(), y1[i]) - y.begin();
            y2[i] = lower_bound(y.begin(), y.end(), y2[i]) - y.begin();
        }

        w = x.size();
        h = y.size();
        auto mp = make_v(h, w, 0);
        REP(i, 0, n) {
            mp[y1[i]][x1[i]]++;
            mp[y1[i]][x2[i]]--;
            mp[y2[i]][x1[i]]--;
            mp[y2[i]][x2[i]]++;
        }
        REP(i, 0, h) {
            REP(j, 0, w - 1) {
                mp[i][j + 1] += mp[i][j];
            }
        }
        REP(j, 0, w) {
            REP(i, 0, h - 1) {
                mp[i + 1][j] += mp[i][j];
            }
        }

        function<void(int, int)> rec = [&](int x, int y) {
            if (mp[y][x] != 0) return;
            mp[y][x] = -1;
            REP(k, 0, 4) {
                int nx = x + dx[k], ny = y + dy[k];
                if (nx < 0 || nx >= w - 1 || ny < 0 || ny >= h - 1) continue;
                rec(nx, ny);
            }
        };

        /*
        REP (i, 0, h) {
            REP (j, 0, w) {
                cout << mp[i][j] << " \n"[j + 1 == w];
            }
        }
        //*/

        int ans = 0;
        REP(i, 0, h - 1) {
            REP(j, 0, w - 1) {
                if (mp[i][j] == 0) {
                    ans++;
                    rec(j, i);
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 10124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<vector<int>> a(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n; cin >> n;
    int num;
    for (int i = 0; i < n; i++) {
        cin >> num;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == num) a[i][j] = -1;                
            }
        }
    }
 
    bool win = false;
 
    if (a[0][0] == -1 && a[0][1] == -1 && a[0][2] == -1) win = true;
    if (a[1][0] == -1 && a[1][1] == -1 && a[1][2] == -1) win = true;
    if (a[2][0] == -1 && a[2][1] == -1 && a[2][2] == -1) win = true;
 
    if (a[0][0] == -1 && a[1][0] == -1 && a[2][0] == -1) win = true;
    if (a[0][1] == -1 && a[1][1] == -1 && a[2][1] == -1) win = true;
    if (a[0][2] == -1 && a[1][2] == -1 && a[2][2] == -1) win = true;
 
    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) win = true;
    if (a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1) win = true;
 
    if (win	) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
// Shabdan Batyrkulov
 
using namespace std;
 
#define MAX 1007
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define ll long long
#define ld long double
#define vi vector <int>
#define pii pair <int, int>
#define OK puts("OK");
 
const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
                  
int main () {     
	string s;  cin >> s;
	map <char, int> mp;
	for (int i = 0; i < s.size(); i++) {
		if (mp[s[i]]) {
			puts("no");
			return 0;
		}
		mp[s[i]] = 1;          
	}     
	puts("yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
double git(int x)
{
	double ans=1;
	int c=1;
	while(c<x)
	{
		c*=2;
		ans/=2;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	cout << fixed << setprecision(12);
	double sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=git((k+i)/(i+1));
	}
	cout << sum/n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

bool isprime(int x){
    if(x == 2)
        return true;
    if(x < 2 || x % 2 == 0)
        return false;
    int i = 3;
    while(i <= sqrt(x)){
        if(x % i == 0)
            return false;
        i = i + 2;
    }
    return true;
}

int main(){
    int n,integer[10001] = {},count = 0;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&integer[i]);
        if(isprime(integer[i]))
            count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2748
import numpy as np
from sys import stdin
N,T=[int(x) for x in stdin.readline().rstrip().split()]

a=[]
for i in range(N):
    a.append([int(x) for x in stdin.readline().rstrip().split()])

flag=0
cost=1000
for data in a:
    if data[0] <= cost and data[1] <= T:
        cost=data[0]
        flag=1
if flag == 0:
    print("TLE")
else:
    print(cost)

Measured memory_bytes: 12452
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();

    ArrayList<Integer> a = new ArrayList<Integer>(n);
    ArrayList<Integer> b = new ArrayList<Integer>(n-1);

    for (int i=0 ; i<n ; i++){
      a.add(0);
    }
    for (int i=0 ; i<n-1 ; i++){
      b.add(sc.nextInt());
    }

    int p = 0;
    //処理
    for (int i=0 ; i<n-1 ; i++){
        if(i == 0){
            a.set(i, b.get(i));
        }else{
            if(b.get(i) < b.get(i-1)){
                a.set(i, b.get(i));
            }
        }
        a.set(i+1, b.get(i));
        p += (int)a.get(i);
    }
    System.out.println(p+(int)a.get(n-1));
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#define int long long

using namespace std;

int n,a[200005],s[200005],sum[200005],t[200005],v[200005];

int kk1(int o) 
{
	if(o==0) return 2;
	return o%2!=0;
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
		s[i]=min(s[i-1]+kk1(a[i]),sum[i]);
	for(int i=1;i<=n;i++)
		t[i]=min(t[i-1]+(a[i]%2==0),s[i]);
	for(int i=n-1;i>=1;i--)
		v[i]=min(v[i+1]+kk1(a[i+1]),sum[n]-sum[i]);
	int ans=1e17;
	for(int i=1;i<=n;i++) ans=min(ans,t[i]+v[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cmath>

using namespace std;


int main() {

  int n;

  int prime[11000];
  int ans;

  prime[0]=prime[1]=0;

  for(int i=2;i<=10000;i++) prime[i]=1;

  for(int i=2;i<=sqrt(10000);i++) {

    if(prime[i]==1) {

      for(int j=2*i;j<=10000;j+=i) {

	prime[j]=0;

      }

    }

  }

  //for(int i=0;i<=10000;i++) if(prime[i]==1) cout << i << " ";

  while(cin >> n) {

    ans=0;

    for(int i=1;i<=n;i++) {

      if(prime[i]==1 && prime[n+1-i]==1) ans++;

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007
#define max(p,q)((p)>(q)?(p):(q))
ll powe(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
ll n;
ll d1[212345],d2[212345];
ll c[212345];
char s[1010];

int main(){
  scanf("%lld",&n);
  int maxi=0,count=0;
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&d1[i],&d2[i]);
    if(d1[i]==d2[i]) count++;
    else count=0;
    maxi=max(maxi,count);
  }

  if(maxi>=3) puts("Yes");
  else puts("No");

  
  return 0;
}


Measured memory_bytes: 1664
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[]args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
       String isSafe = "";
    
       int [] a = new int [2];
     
       
       String  lines = br.readLine();    
    
       String[] strs = lines.trim().split("\\s+");
      
       for (int i = 0; i < strs.length; i++) {
       a[i] = Integer.parseInt(strs[i]);
       }

       if(a[1]>=a[0]){
           isSafe = "unsafe";
       }
       else{
           isSafe = "safe";
       }
       System.out.println(isSafe);
    }catch (Exception e) {
    }
    
}}

Measured memory_bytes: 25548
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, X;
	cin >> X >> N;
	VLL P(701, 0);
	for (LL n = 0; n < N; n++) {
		LL p;
		cin >> p;
		P[p+300]++;
	}
	LL ans = -1e9;
	for (LL n = -300; n <= 300; n++) {
		if (P[n + 300] != 0)continue;
		if (abs(X - ans) > abs(n - X))ans = n;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3168
N = int(input())
L = list(map(int,input().split()))

ans = 0

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            A,B,C = L[i],L[j],L[k]
            if A != B and B != C and C != A and A+B+C - max(A,B,C) > max(A,B,C):
                ans += 1

print(ans)

Measured memory_bytes: 68320
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define endl '\n'
using namespace std;
const int N=1e6+100,mod=1e9+7;
ll par[N];
ll dp[N];
int32_t main(){
    ll n;
    cin >> n;
    dp[1]=n;
    par[1]=n;
    dp[2]=n*n%mod;
    par[2]=par[1]+dp[2];
    par[2]%=mod;
    for (int i=3;i<=n;i++){
        dp[i]=par[max((ll)0,i-3)]+dp[i-1];
        dp[i]+=n-i+2;
        dp[i]+=(n-1)*(n-1)%mod;
        par[i]+=dp[i]+par[i-1];
        par[i]%=mod;
        dp[i]%=mod;
    }
    cout << dp[n];
}


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

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

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
     int N;
     cin >> N;
     vector<string>s(N);
     REP(i, N){
        cin >> s.at(i);
        sort(all(s.at(i)));
     }
     sort(all(s));
    ll cnt = 0;
    ll tmp = 0;
        REP(i, N - 1){
            if(s.at(i) == s.at(i + 1)){
             tmp++;
             cnt += tmp;
            } else {
             tmp = 0;
         }

     }
    print(cnt);
}

Measured memory_bytes: 7296
package main

import (
	"fmt"
)

func prime(n int) []bool {
	tab := make([]bool, n)

	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			tab[i] = false
		} else {
			tab[i] = true
		}
	}
	tab[0] = false
	tab[2] = true

	for i := 3; i < n; i += 1 {
		for j := 2; i * j < n; j += 1 {
			tab[i * j] = false
		}
	}

	return tab
}

func main() {
	var x int
	fmt.Scanf("%d", &x)

	tab := prime(110000)

	for i := x; ; i++ {
		if tab[i] {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "NO" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void add_edge(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0){
        used[v]=true;
        for(auto E : G[v]){
            if(!used[E.to]){
                dfs(E.to);
            }
        }
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    graph g(N+M);
    rep(i,N){
        ll k; cin>>k;
        rep(j,k){
            ll l; cin>>l; --l;
            g.add_edge(i,N+l);
        }
    }
    g.dfs(0);
    rep(i,N){
        if(g.used[i]==false) dame;
    }
    cout<< "YES" <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 8948
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



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

    int N;
    cin >> N;
    vector<int> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    int Q;
    cin >> Q;
    vector<int> T(Q);
    for(int i = 0; i < Q; i++) cin >> T[i];

    map<int,int> Se, Te;
    for(int s : S) Se[s]++;
    for(int t : T) Te[t]++;
    
    int count = 0;
    for(auto p : Te){
        count+= min(Se[p.fi], p.se);
    }
    cout << count << endl;
}



Measured memory_bytes: 3268
n,k = map(int,input().split())
a = list(map(int,input().split()))#消化コスト
f = list(map(int,input().split()))#食べにくさ
a.sort(reverse = True)
f.sort()
top = 10**13
bot = -1
def ok(x):
    res = 0
    for i in range(n):
        res += max(0,a[i] - (x//f[i]))
    return res <=k
while top - bot > 1:
    mid = (top + bot) //2
    if ok(mid):top = mid
    else:bot = mid
print(top)

Measured memory_bytes: 119500
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    sort(ALL(A));
    auto it = unique(ALL(A));
    A.erase(it, A.end());
    p(A.size());
    
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N] = {};
    int b[N] = {};
    int max = 0;
    int max2 = 0;
    for (int i = 0;i < N;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b + N);
    max = b[N - 1];
    max2 = b[N - 2];
    for (int i = 0;i < N;i++){
        if(a[i] != max){
            cout << max << endl;
        }
        else cout << max2 << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD (int) 1e9+7

int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i, n){
        cin >> h[i];
    }
    for (int i = n-1; i >= 0 ; i--)
    {
        if(h[i]>=h[i-1]){
            continue;
        }else{
            if(h[i-1]-h[i]<=1){
                h[i-1]--;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
inline bool chmin (int& a, int b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
class low_link_tree {
	int n;
	int tmr;
	int rt = 0;
	vector<int> ord;
	vector<int> low;
	set<int> atc;
	set<pair<int, int>> bdg;
	vector<vector<int>> grh;
public:
	low_link_tree (
		vector<vector<int>> const& grh
	)
	: n(grh.size())
	, ord(n, -1)
	, low(n, -1)
	, grh(grh)
	{
		dfs(0, 0);
	}
	void dfs (
		int crr
	,	int prt
	) {
		int cnt = 0;
		ord[crr] = low[crr] = tmr++;
		for (int nxt : grh[crr]) {
			if (ord[nxt] == -1) {
				cnt++;
				dfs(nxt, crr);
				chmin(low[crr], low[nxt]);
				if (crr != rt && ord[crr] <= low[nxt]) atc.insert(crr);
				if (ord[crr] < low[nxt]) bdg.emplace(crr, nxt);
			}
			if (nxt != prt) chmin(low[crr], ord[nxt]);
		}
		if (crr == rt && cnt > 1) atc.insert(crr);
	}
	auto const &order() {return ord;}
	auto const &low_link() {return low;}
	auto const &articulation_points() {return atc;}
	auto const &bridges() {return bdg;}
};
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> grh(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		grh[s].push_back(t);
		grh[t].push_back(s);
	}
	auto atc = low_link_tree(grh).articulation_points();
	for (auto it = atc.begin(); it != atc.end(); it++) {
		cout << *it << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 4816
#include<stdio.h>

int main(){
    int N,M;
    scanf("%d %d", &N, &M);
    int a[N];
    int i,j,ans = 0;
    double sum = 0;
    
    for(i = 0;i < N;i++){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    for(i = 0;i < N;i++){
        if(a[i] >= sum / (4 * M))ans++;
    }
    if(ans >= M)printf("Yes");
    else printf("No");
    return 0;
}

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

using namespace std;

int main ()
{
  int N, X;
  cin >> N >> X;
  vector<int> v;
  for (int i = 0; i < N; i++) {
    int l;
    cin >> l;
    v.push_back(l);
  }

  vector<int> vd;
  vd.push_back(0);
  for (int i = 1; i <= N; i++) {
      int D = vd.at(i - 1) + v.at(i - 1);
      vd.push_back(D);
  }

  int count = 0;
  for (const auto& d: vd) {
    if (X >= d){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;
    cin>>n;
    ll fac=1ll;
    for(ll i=1ll;i<=n;i++){
        fac=(fac*i)%mod;
    }
    string s;
    cin>>s;
    char B='B',W='W';
    
    ll num=0;
    ll tmp=1;
    for(ll i=0;i<(2*n);i++){
        if(s[i]==B){
            if(num%2==0){
                num++;
            }
            else{
                tmp=(tmp*num)%mod;
                num--;
            }
        }
        else{
            if(num%2==0){
                tmp=(tmp*num)%mod;
                num--;
            }
            else{
                num++;
            }
        }
    }
    if(num==0) 
    cout<<(fac*tmp)%mod<<endl;
    else
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
# conding: utf

from logging import getLogger, StreamHandler, NullHandler, DEBUG, INFO
logger = getLogger(__name__)
#handler = StreamHandler()
handler = NullHandler()
logger.setLevel(DEBUG)
handler.setLevel(DEBUG)
logger.addHandler(handler)
logger.propagate = False

g_field = []
g_count = 0
g_W = -1
g_H = -1

OFFSETS = [(1,0), (-1,0), (0,1), (0,-1)]


if __name__ == "__main__":
    while True:
        g_W, g_H = [int(s) for s in input().strip().split()]

        if g_W == 0 and g_H == 0:
            break
        
        g_field = []
        for _ in range(g_H):
            row = list(input().strip())
            g_field.append(row)
        g_count = 0

        for y in range(g_H):
            for x in range(g_W):
                if g_field[y][x] == "@":
                    start_x = x
                    start_y = y
                    break

        #dfs(start_x, start_y)
        # bfs
        queue = [(start_x, start_y)]
        
        while len(queue) > 0:
            x, y = queue.pop()

            g_count += 1
            g_field[y][x] = "-"

            for dx, dy in OFFSETS:
                logger.debug("diff: {} {}".format(dx, dy))
                new_x = x + dx
                new_y = y + dy

                if new_x < 0 or new_x >= g_W:
                    continue
                if new_y < 0 or new_y >= g_H:
                    continue
                new_tile = g_field[new_y][new_x]
                if new_tile == "#" or new_tile == "-":
                    continue
                if (new_x, new_y) in queue:
                    continue
                
                logger.debug("{}, {}".format(new_x, new_y))
                queue.append((new_x, new_y))

        print(g_count)



Measured memory_bytes: 7220
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  long long n;
  while(cin>>n&&n){
    string ans="";
    while(n>0){
      ans+=n%8+'0';
      n/=8;
    }
    for(int i=ans.size()-1;i>=0;i--){
      if(ans[i]>='4')ans[i]++;
      if(ans[i]>='6')ans[i]++;
      cout<<ans[i];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
 
#define N 200005

int ar[N][2],br[N],taken[N] ;
char s[N];
vector<int> adj[N],v;

int main() {

    //#ifdef forthright48
    //freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	//#endif

    int n,m,x,y;

    cin >> n >> m;

    scanf(" %s",s+1);
    //printf("DD %s\n",s);

    for(int i = 1; i <= m; i++) {
        scanf("%d %d",&x,&y);

        ar[x][ s[y]-'A' ]++;
        ar[y][ s[x]-'A' ]++;

        //adj[x][ keep[x]++ ] = y; adj[y][ keep[y]++ ] = x;

        adj[x].pb(y);
        adj[y].pb(x);
    }

    int cnt = 0;

    for(int i = 1; i <= n; i++) {
        if(!ar[i][0] || !ar[i][1]) {
            //br[++cnt] = i;
            v.pb(i);
            taken[i] = 1;
        }
    }

    for(int i = 0; i < SZ(v); i++) {
        x = v[i];

        for(int j = 0; j < SZ(adj[x]); j++) {
            y = adj[x][j];

            ar[y][ s[x]-'A' ]--;
            
            if(!ar[y][ s[x]-'A' ] && !taken[y]) {
                v.pb(y);
                taken[y] = 1;
            }
        }
    }

    cnt = SZ(v); //dump(cnt);

    if(cnt < n) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
string s,a;
int main()
{
    cin>>s;
    for(int i=s.size()-1;i>=0;i--)
    {
    	
    	if(s[i]=='b')
    	a=a+'d';
    	if(s[i]=='d')
    	a=a+'b';
    	if(s[i]=='p')
    	a=a+'q';
    	if(s[i]=='q')
    	a=a+'p';
	}
	if(a==s)
	cout<<"Yes";
	else
	cout<<"No";
    return 0;
}


Measured memory_bytes: 696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true){
			int n = stdIn.nextInt();
			if(n==0) return;
			int[] step = new int[n];
			for(int i=0;i<n;i++){
				String s = stdIn.next();
				if(s.equals("lu")){
					step[i] = 1;
				}
				else if(s.equals("ru")){
					step[i] = 2;
				}
				else if(s.equals("ld")){
					step[i] = 3;
				}
				else if(s.equals("rd")){
					step[i] = 4;
				}
			}
			boolean groundLeft = true;
			boolean groundRight = true;
			boolean nextGround = false;
			int cnt = 0;
			for(int i=0;i<n;i++){
				if(step[i]==1){
					groundLeft = false;
				}
				else if(step[i]==2){
					groundRight = false;
				}
				else if(step[i]==3){
					groundLeft = true;
				}
				else if(step[i]==4){
					groundRight = true;
				}
				if(nextGround&&groundLeft&&groundRight){
					cnt++;
					nextGround = false;
				}
				else if(!nextGround&&!groundLeft&&!groundRight){
					cnt++;
					nextGround = true;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 26940
#include <stdio.h>
int main() {
    char s[11],t[12];	
    scanf("%s ",&s);	
    scanf("%s ",&t);
  
    int i;
    for (i = 0;s[i] != '\0';i++){
        if (s[i] != t[i]){
            printf("No");
            return 0;
        }
    }
 
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

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

    map<string, int> mp;

    // 青いカード
    rep(i, N) {
        string s; cin >> s;
        if (mp.find(s) == mp.end()) {
            mp.insert(make_pair(s, 1));
        } else {
            mp[s]++;
        }
    }

    int M; cin >> M;

    // 赤いカード
    rep(i, M) {
        string t; cin >> t;
        if (mp.find(t) == mp.end()) {
            mp.insert(make_pair(t, -1));
        } else {
            mp[t]--;
        }
    }

    int ans = -100;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        int value = iter -> second;
        ans = max(ans, value);
    }

    if (ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
N = min([R - L , 2019])
m = 2018
if N == 1:
  m = (R*L)%2019
for i in range(N):
  for j in range(N - i):
    M = ((L + i)*(L + N - j))%2019
    if M < m:
      m = M
print(m)      

Measured memory_bytes: 3060
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    int a,b;
    cin >> a >> b;
    printf("100 100\n");
    string  s;
    rip(i,50,0){
        s += '#';
    }
    rip(i,100,50){
        s += '.';
    }
    vector<string> ans(100,s);
    rip(i,a-1,0){
        ans[i%50*2][i/50*2] = '.';
    }
    rip(i,b-1,0){
        ans[i%50*2][99 - i/50*2] = '#';
    }
    rip(i,100,0){
        cout << ans[i] << endl;
   }
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void){
    int A,B;
    cin>>A>>B;
    if((A*B)%2==0){
        cout<<"Even"<<endl;
    }
    else{
        cout<<"Odd"<<endl;
    }



}


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

int sum(int n){
    int S = 0;
    while (n > 0){
        S += n % 10;
        n /= 10;
    }
    return S;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;

    int total = 0;
    for (int i = 1; i <= N; ++i){
        int S = sum(i);
        if (S >= A && S <= B) total += i;
    }

    cout << total << endl;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &h[i])
	}
	answer := findMinCosts(h, k)
	fmt.Println(answer)
}

func findMinCosts(h []int, k int) int {
	var dp [10001]int
	unreachable := 10000000000

	for i := 0; i < 10001; i++ {
		dp[i] = unreachable
	}

	dp[h[0]] = 0

	for i := 1; i < len(h); i++ {
		minCost := unreachable
		for j := 0; j < k && j < i; j++ {
			if abs(h[i]-h[i-j-1])+dp[h[i-j-1]] < minCost {
				minCost = abs(h[i]-h[i-j-1]) + dp[h[i-j-1]]
			}
		}
		dp[h[i]] = minCost
	}

	return dp[h[len(h)-1]]
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> dp(100005, vector<int>(3, -1)), input;
  
int main()
{
    int n, a, b, c;
    long long int ans;
    cin >> n;
    input.push_back({-1, -1, -1});
    for(int i=0;i<n;i++)
    {
        cin >> a >> b >> c;
        input.push_back({a, b, c});
    }
    dp[0][0]=dp[0][1]=dp[0][2] =0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+input[i][j];
        }
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
    return(0);
}

Measured memory_bytes: 12340
#include<stdio.h>

int main(void)
{
   int n,m,x,i,a[10000];
   x=0;
   scanf("%d%d",&n,&m);
   for(i=0; i<m; i++){
      scanf("%d",&a[i]);
      x+=a[i];
   }
   if(x>n){
      printf("-1\n");
   }
   else{
      printf("%d\n",n-x);
   }
   return 0;
}


Measured memory_bytes: 1736
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

DP = [0 for i in range(N)]
pre = ["" for i in range(K)]
ans = 0

def Plus(s):
    if s =="s":
        return R
    elif s=="r":
        return P
    elif s=="p":
        return S
    else:
        return 0

for i in range(K):
    pre[i] = T[i]
    ans += Plus(pre[i])

for i in range(1,N//K+1):
    for j in range(K):
        if K*i+j >= N:
            break

        if pre[j] == T[K*i+j]:
            pre[j] = ""
        else:
            pre[j] = T[K*i+j]
            ans += Plus(pre[j])
print(ans)

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

using namespace std;

const int inf = 2e9;

int main() {
    int x, n; scanf("%d %d", &x, &n);
    int ans = inf, diff = inf;
    if (n == 0) {
        printf("%d\n", x);
        return 0;
    }

    set <int> st;
    for (int i = -200; i <= 200; i++) st.insert(i);
    // set <int> st;
    for (int i = 1; i <= n; i++) {
        int p; scanf("%d", &p);
        auto it = st.find(p);
        if (it != st.end()) st.erase(it);
    }

    for (auto p : st) {
        if (diff > abs(p - x)) {
            diff = abs(p - x);
            ans = p;
        }
    }

    printf("%d\n", ans);
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,x; cin>>n>>m>>x;
	vector<vector<int>>ca(n,vector<int>(m+1));
	for(auto&&i:ca)for(auto&&j:i)cin>>j;
	int64_t ans=INT64_MAX;
	for(int i=0;i<(1<<n);++i){
		vector<int64_t>v(m,0); int64_t cost=0;
		for(int j=0;j<n;++j){
			if(i&(1<<j)){
				cost+=ca.at(j).at(0);
				for(int k=1;k<=m;++k){
					v.at(k-1)+=ca.at(j).at(k);
				}
			}
			if(all_of(v.begin(),v.end(),[=](auto a){return a>=x;})){
				ans=min(ans,cost);
			}
		}
	}
	cout<<(ans!=INT64_MAX?ans:-1)<<"\n"s;
}

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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256