akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

const int INF = 1e9;

#define LLD_SPEC "%lld"

int n, k;
vector<vector<int>> g;

vector<vector<int>> dp;
vector<int> result;

void BuildResult(int v, int pr) {
    for (int u : g[v]) {
        if (u == pr) {
            continue;
        }

        BuildResult(u, v);
    }
    vector<int> buf[2];
    int curPtr = 0;
    buf[curPtr].assign(k + 1, -1);
    buf[curPtr][0] = 1;
    for (int u : g[v]) {
        if (u == pr) {
            continue;
        }

        int nxtPtr = 1 - curPtr;
        buf[nxtPtr] = buf[curPtr];

        for (int h1 = 0; h1 <= k; ++h1) {
            if (buf[curPtr][h1] == -1) {
                continue;
            }
            for (int h2 = 0; h2 < k; ++h2) {
                if (dp[u][h2] == -1) {
                    continue;
                }

                if (h1 + h2 + 1 > k) {
                    continue;
                }

                int newH = max(h1, h2 + 1);

                if (buf[nxtPtr][newH] == -1 || buf[curPtr][h1] + dp[u][h2] > buf[nxtPtr][newH]) {
                    buf[nxtPtr][newH] = buf[curPtr][h1] + dp[u][h2];
                }
            }
        }

        swap(curPtr, nxtPtr);
    }
    for (int h = 0; h <= k; ++h) {
        dp[v][h] = buf[curPtr][h];
    }
    for (int h = 0; h <= k; ++h) {
        if (dp[v][h] == -1) {
            continue;
        }
        int curResult = n - dp[v][h];
        if (result[v] == -1 || curResult < result[v]) {
            result[v] = curResult;
        }
    }
    for (int u : g[v]) {
        if (u == pr) {
            continue;
        }

        if (result[u] != -1) {
            if (result[v] == -1 || result[u] < result[v]) {
                result[v] = result[u];
            }
        }
    }
}

int main() {
    scanf("%d%d", &n, &k);
    g.resize(n);
    for (int i = 0; i + 1 < n; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dp.assign(n, vector<int>(k + 1, -1));
    result.assign(n, -1);
    BuildResult(0, -1);

    printf("%d\n", result[0]);

    return 0;
}

Measured memory_bytes: 16256
N, K = map(int, input().split())
A = list(int(a) for a in input().split())

def can_cut(n):
    tmp = 0
    for a in A:
        tmp += ((a + n - 1) // n) - 1
    if tmp <= K:
        return True
    else:
        return False

l = 0
r = max(A) + 1
while l+1 < r:
    m = (l + r) // 2
    if can_cut(m):
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 30884
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    __uint128_t ans = 1;
    vector a(n,0LL);
    for (int i=0; i<n; i++) cin >> a[i];

    if (any_of(a.begin(), a.end(), [](const int64& x){return x == 0LL;})) {
        cout << 0 << endl;
        return 0;
    }

    for (int i=0; i<n; i++) {
        ans *= a[i];
        if (ans > 1000000000000000000LL) {
            ans = -1;
            break;
        }
    }

    cout << (int64)ans << endl;
}

Measured memory_bytes: 3628
from fractions import gcd
N,M=map(int,input().split(' '))
S=input()
T=input()
G=gcd(N,M)
L = N*M//G
ln = list(range(0,L,(N//G)))
lm = list(range(0,L,(M//G)))
for i,j in zip(ln,lm):
    if i>=N or j>=M:
        break
    if S[i] != T[j]:
        print(-1)
        exit()
print(L)

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

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

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int N;
  ll cnt = 0;
  cin >> N;

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      int c = N - i * j;
      if (c > 0) cnt++;
      else break;
    }
  }

  cout << cnt << endl;
  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  string w;
  map<string,int> mp;
  rep(i,N) {
    cin >> w;
    sort(w.begin(),w.end());
    mp[w]++;
  }
  ll ans=0;
  for(auto p : mp){
    ll count = p.second;
    ans += count * (count-1) / 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 12800
#include <iostream>
#include <utility>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdint>
#include <algorithm>

using namespace std;

int main(int argc,char** argv) {
    int n,a[100001];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    sort(a,a+n);
    a[n] = -1;
    int prev = -1,cnt = 0;
    vector<int> s;
    for(int i = 0;i <= n;i++){
        if(prev != a[i]) {
            prev = a[i];
            if(cnt > 0) s.push_back(cnt);
            cnt = 0;
        }
        else {
            cnt++;
        }
    }
    int sum =0;
    for(auto e:s) sum += e;
    int res = 0;
    if(sum % 2 == 0) {
        res = n - sum;
    }
    else {
        res = (n - sum) - 1;
    }
    cout << res << endl;
}


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

const double EPS = 1e-10;
const ll INF = 10000000000;
const ll MOD = 1000000007;

ll x_1, x_2, y_1, y_2;
int n;
ll X[200000], Y[200000];
P point[200000];
ll dp[200010];

int main(){
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    x_2 -= x_1; y_2 -= y_1;
    cin >> n;
    rep(i,n+10) dp[i] = INF;
    rep(i,n) cin >> X[i] >> Y[i];
    rep(i,n) {
        X[i] -= x_1;
        Y[i] -= y_1;
    }
    if(x_2 < 0) {
        x_2 *= -1;
        rep(i,n) X[i] *= -1;
    }
    if(y_2 < 0) {
        y_2 *= -1;
        rep(i,n) Y[i] *= -1;
    }
    rep(i,n) point[i] = P(X[i], Y[i]);
    sort(point, point+n);
    dp[0] = -1;
    rep(i,n) {
        if(point[i].first < 0 || point[i].first > x_2 || point[i].second < 0 || point[i].second > y_2) {
            continue;
        }
        int st = 0, en = n+9, mid;
        while(en-st > 1) {
            mid = (st+en)/2;
            if(dp[mid] > point[i].second) {
                en = mid;
            } else {
                st = mid;
            }
        }
        dp[en] = point[i].second;
    }
    long double ans = (x_2+y_2)*100.0;
    for(int i = 1; i <= n; i++) {
        if(dp[i] == INF) break;
        ans = ans-20.0+PI*5.0;
    }
    if(y_2 <= n+2 && dp[y_2+1] != INF) {
            ans = ans+20.0-PI*5.0;
            ans = ans-20.0+PI*10.0;
    }
    else if(x_2 <= n+2 && dp[x_2+1] != INF) {
            ans = ans+20.0-PI*5.0;
            ans = ans-20.0+PI*10.0;
    }
    printf("%.15Lf\n", ans);
}
































Measured memory_bytes: 8064
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


bool is_prime(const unsigned n) {
	switch (n) {
	case 0: // fall-through
	case 1: return false;
	case 2: // fall-through
	case 3: return true;
	} // n > 3 が保証された

	if (n % 2 == 0) return false;
	if (n % 3 == 0) return false;
	// 2と3の倍数でないので6の倍数ではないことが保証された

	if (n % 6 != 1 && n % 6 != 5) return false;
	// 6の倍数前後の数(素数かもしれない数)であることが保証された

	// 6の倍数前後の数を使って試し割りをする
	for (unsigned i = 5; i*i <= n; i += 6) {
		if (n%i == 0) return false; // 6n-1
		if (n % (i + 2) == 0) return false; // 6n+1
	}

	return true;
}


signed main() {
	int x;

	cin >> x;

	while (true)
	{
		if (is_prime(x) == true)break;
		x++;
	}

	cout << x << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prime[100101];
bool expo[100101];

int pref[100101] ;
void SieveOfEratosthenes( )
{

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

    for (int p=2; p*p<=100100; p++)
    {

        if (prime[p] ==false)
        {

            for (int i=p*p; i<=100100; i += p)
                prime[i] = true;
        }
    }
    expo[0] = true ;
    expo[1] = true ;
    for (int i=2; i<=100100; i++)
       {
           if(!prime[i])
           {
               int r = (i+1)/2;
               if(prime[r])
               expo[i] = true;

           }
           else expo[i] = true;
       }
   for(int i=2; i<=100100; i++)
   {
       if(!expo[i])
        pref[i] = pref[i-1] + 1 ;
       else pref[i] = pref[i-1] ;
   }

}

int main()
{

    SieveOfEratosthenes();
       int n ;
    cin >> n;
    while(n--)
    {
        int lf , rt ;
        cin >> lf >> rt ;
        cout << pref[rt] - pref[lf-1]  << endl;
    }



    return 0;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll W,H,x,y,T=0;
    cin>>W>>H>>x>>y;
    if(2*x==W && 2*y==H)T=1;
    cout<<fixed<<setprecision(15)<<1.*H*W/2<<" "<<T<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long S = 1000000000000000;
int main(){
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  vector<vector<pair<int, int>>> E1(n), E2(n);
  for (int i = 0; i < m; i++){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    E1[u].push_back(make_pair(a, v));
    E1[v].push_back(make_pair(a, u));
    E2[u].push_back(make_pair(b, v));
    E2[v].push_back(make_pair(b, u));
  }
  vector<long long> d1(n, S);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> Q1;
  Q1.push(make_pair(0, s));
  while (!Q1.empty()){
    long long c = Q1.top().first;
    int v = Q1.top().second;
    Q1.pop();
    if (d1[v] == S){
      d1[v] = c;
      for (auto P : E1[v]){
        int w = P.second;
        if (d1[w] == S){
          Q1.push(make_pair(d1[v] + P.first, w));
        }
      }
    }
  }
  vector<long long> d2(n, S);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> Q2;
  Q2.push(make_pair(0, t));
  while (!Q2.empty()){
    long long c = Q2.top().first;
    int v = Q2.top().second;
    Q2.pop();
    if (d2[v] == S){
      d2[v] = c;
      for (auto P : E2[v]){
        int w = P.second;
        if (d2[w] == S){
          Q2.push(make_pair(d2[v] + P.first, w));
        }
      }
    }
  }
  vector<long long> sum(n);
  for (int i = 0; i < n; i++){
    sum[i] = d1[i] + d2[i];
  }
  for (int i = n - 2; i >= 0; i--){
    sum[i] = min(sum[i], sum[i + 1]);
  }
  for (int i = 0; i < n; i++){
    cout << S - sum[i] << endl;
  }
}

Measured memory_bytes: 18844
N = int(input())
T = [0] + [int(i) for i in input().split()]
M = int(input())
D = [[int(i) for i in input().split()] for j in range(M)]
 
for p,x in D:
  tmp = T[p]
  T[p] = x
  print(sum(T))
  T[p] = tmp

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

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

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int N;
	cin >> N;
	
	int sum = N*(1+N)/2;
	
	cout << sum << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N ;
  vector <int> L(N);
  for (int i=0 ; i<N ; i++) cin >> L.at(i) ;
  sort (L.begin(), L.end());
  int count = 0;
  for (int i=0 ; i<N ; i++) {
    for (int j=i+1 ; j<N ; j++) {
      for (int k=j+1 ; k < N ; k++) {
        if (L.at(i)!=L.at(j)&&L.at(j)!=L.at(k)&&L.at(i)!=L.at(k)&&L.at(i)+L.at(j)>L.at(k)) count ++;
      }
    }
  }
  cout << count << endl;       
}


Measured memory_bytes: 3632
# https://bbbbruno.qrunch.io/entries/UnudQ5pXQeONVdKT?ref=qrunch

O = gets.chomp
E = gets.chomp
ans = ""  # 配列ではない空を渡しておく

O.length.times do |i|
  ans += O[i]
  # O.length 順番が後なら
  if i < E.length
    ans += E[i]
  end
end

puts ans

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

using namespace std;

namespace {
    int N;
    vector<vector<int>> F;
    vector<vector<int>> P;

    template<typename T>
    istream& operator>>(istream& is, vector<T>& xs) {
        for (auto& x : xs) {
            is >> x;
        }
        return is;
    }

    void input() {
        cin >> N;
        F.resize(N, vector<int>(10, 0));
        cin >> F;
        P.resize(N, vector<int>(11, 0));
        cin >> P;
    }

    int profit(int bit) {
        int p = 0;
        for (int i = 0; i < N; i++) { // shop-i
            int c = 0;
            for (int j = 0; j < 10; j++) { // time-j
                if ( (bit & (1 << j)) and F[i][j] ) {
                    // both shop-i and shop-joi opens
                    c++;
                }
            }
            p += P[i][c];
        }
        return p;
    }

    void solve() {
        int ans = INT_MIN;
        for (int bit = 1; bit < (1 << 10); bit++) {
            ans = max(ans, profit(bit));
        }
        cout << ans << endl;
    }
}

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



Measured memory_bytes: 256
//
//  main.cpp
//  vjudge
//
//  Created by Sudipto Mondal on 7/9/20.
//  Copyright © 2020 Sudipto Mondal. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    long long int a,b;
    cin>>a>>b;
    
    if((a+b)==3){
        cout<<"3"<<endl;
    }else if((a+b)==5){
        cout<<"1"<<endl;
    }else{
        cout<<2<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}


int main()
{
    int A = inputValue();
    int B = inputValue();

    int ans = A - B * 2;
    if(ans < 0){
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

n = I()
A = IR(5)
m = min(A)
print(4+ceil(n/m))

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

const int MOD =1000000007;
vector<int> hen[100000];
int oya[100000];
void bfs(int x){
    for(int i=0;i<hen[x].size();i++){
        if(oya[hen[x][i]]==-2){
            oya[hen[x][i]]=x;
            bfs(hen[x][i]);
        }
    }
}
signed main() {
 int n,u,v;
 cin>> n>>u>>v;u--;v--;
int a,b;
for(int i=0;i<n-1;i++){
    cin>>a>>b;
    hen[a-1].push_back(b-1);
    hen[b-1].push_back(a-1);

}
fill(oya,oya+n,-2);
oya[u]=-1;
bfs(u);
int ans=0,k=0,w=v;


while(w!=u){
    w=oya[w];
   // cerr<<w;
    k++;
}
//cerr<<k<<endl;
if(k%2){
    ans+=k/2;
    k/=2;
    while(k){
        v=oya[v];
        k--;
    }
    u=oya[v];
    int used[n];
    fill(used,used+n,-1);
    used[u]=0;used[v]=0;
    queue<int>que;
    que.push(u);
    while(!que.empty()){
        u=que.front();
        for(int i=0;i<hen[u].size();i++){
            if(used[hen[u][i]]==-1){
                used[hen[u][i]]=used[u]+1;
                que.push(hen[u][i]);
            }
        }
        que.pop();
    }
    int ans2=ans;
    for(int i=0;i<n;i++)ans2=max(ans2,ans+used[i]);
    cout<<ans2;
    return 0;
}
ans+=k/2 -1;
    k/=2;
    while(k){
        v=oya[v];
        k--;
    }
    u=oya[v];
    int used[n];
    fill(used,used+n,-1);
    used[u]=0;used[v]=0;
    queue<int>que;
    que.push(u);
    while(!que.empty()){
        u=que.front();
        for(int i=0;i<hen[u].size();i++){
            if(used[hen[u][i]]==-1){
                used[hen[u][i]]=used[u]+1;
                que.push(hen[u][i]);
            }
        }
        que.pop();
    }
    int ans2=ans+1;
    for(int i=0;i<n;i++)ans2=max(ans2,ans+used[i]+1);
    cout<<ans2;


    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n,sum,ans = (1 << 20);cin >> n;vector<int> x(n);
	rep(i, n) {
		cin >> x[i];
	}
	rep(i, 101) {
		sum = 0;
		rep(j, n) {
			sum += pow(x[j] - i, 2);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        final int YEAR = 2019;
        
        if(L <= YEAR && R >= YEAR) {
            System.out.println(0);
        } else {
            long min = YEAR;
            for (int i = L; i < R; i++) {
                for (int j = i+1; j <= R; j++) {
                    long ijmod = ((long)i*j)%YEAR;
                    min = Math.min(min, ijmod);
                    if(ijmod == 0) {
                        i=R;
                        j = R;
                    }
                }
            }
            System.out.println(min);
        }

    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
const int mod = 998244353; //1e9+7;
struct Mint {
   int val;
   Mint inv() const {
       int tmp, a = val, b = mod, x = 1, y = 0;
       while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
       return Mint(x);
   }
public:
   Mint() :val(0) {}
   Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
   int mtoi() { return this->val; }
   Mint pow(ll t) { Mint res = 1; while(t){if(t&1)res *= *this;*this *= *this;t >>= 1;}return res; }
   Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
   Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
   Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
   Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
   bool operator==(const Mint& x) const { return val == x.val; }
   bool operator!=(const Mint& x) const { return val != x.val; }
   bool operator<(const Mint& x) const { return val < x.val; }
   bool operator<=(const Mint& x) const { return val <= x.val; }
   bool operator>(const Mint& x) const { return val > x.val; }
   bool operator>=(const Mint& x) const { return val >= x.val; }
   Mint operator+(const Mint& x) const { return Mint(*this) += x; }
   Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
   Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
   Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx) {
       Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
       Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
   }
   Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
   Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
   Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
//template end



int main(){
   string s; cin>>s;
   int n=s.size();
   vector<int> a(s.size()),idx;
   rep(i,0,n-1)if(s[i+1]!=s[i])idx.push_back(i);
   rep(i,0,n){
      if(s[i]=='L'){
         int it=lower_bound(ALL(idx),i)-idx.begin(); it--;
         if((idx[it]-i)%2)a[idx[it]+1]++;
         else a[idx[it]]++;
      }
      else{
         int it=lower_bound(ALL(idx),i)-idx.begin();
         if((idx[it]-i)%2)a[idx[it]+1]++;
         else a[idx[it]]++;
      }
   }
   rep(i,0,n)printf("%d ",a[i]);
   return 0;
}


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

using namespace std;
int n,l,minn;
int main()
{
    int ans=1;
    minn=500;
    scanf("%d%d",&n,&l);
    ans=ans+l-1;
    minn=min(minn,abs(ans));
    int sum=ans;
    for(int i=2;i<=n;i++)
    {
        ans+=1;
        sum+=ans;
        minn=min(minn,abs(ans));
    }
    if(ans<minn)
        minn=-minn;
    printf("%d\n",sum-minn);
    return 0;
}

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


int main()
{
	int i, j, k,l,m;
	i, j, k, l, m = 0;

		cin >> i>> j>> k;
		l = i;
		m = j - k + 1;
		if (i + k >= j) { for (i; i <= j; i ++) { cout << i << " "; } }
		else { for (i; i < l + k; i++) { cout << i << " "; } }
	if (i > j - k) { for (i; i <= j; i++){cout << i << " "; }}
	else { for (m; m <= j; m++){cout << m << " "; } }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long A, B, C, K;
long long result;

int main() {
    cin >> A >> B >> C >> K;
    
    result += min(A, K);
    K -= min(A, K);

    K-= min(B, K);

    result -= min(C, K);

    cout << result << '\n';

    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
int main()
{
int a,b,c,d,e;
	scanf("%d%d",&a,&b);
    c=a+b;
    d=c/2;
    e=c%2;
    if(e==0){
    printf("%d\n",d);
	}
    else
    	printf("%d\n",d+1);
}

Measured memory_bytes: 256
# solution
n, m = map(int, input().split())
strs = str(input())
count = 0
for i in range(n):
    if strs[i:i+2] == 'LL' or strs[i:i+2] == 'RR':
        count += 1
print(min((count + 2*m), n-1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A==B) {
    cout << A+B << endl;
  }
  else {
    if (A>B) {
      cout << 2*A-1 << endl;
    }
    else {
      cout << 2*B-1 << endl;
    }
  }
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<int> se;
  while (n--) {
    int a;
    cin >> a;
    se.insert(a);
  }
  cout << se.size() << '\n';
}



Measured memory_bytes: 7692
from collections import defaultdict

N,K=map(int,input().split())
dd=defaultdict(int)
for i in range(N):
    a,b=map(int,input().split())
    dd[a]+=b
l=sorted(dd.keys())
i=0
for ai in l:
    i+=dd[ai]
    if i>=K:
        print(ai)
        break

Measured memory_bytes: 50392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int fx[100000], fy[100000];
int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x, y;
    FOR(i, n) {
        cin >> x >> y;
        if (!(x && y))continue;
        chmax(fx[x - 1], y);
        chmax(fy[y - 1], x);
    }
    FOR1(i, w)chmax(fx[w - i - 1], fx[w - i]);
    FOR1(i, h)chmax(fy[h - i - 1], fy[h - i]);
    int ans = INF;
    FOR(i, w)chmin(ans, i + fx[i]);
    FOR(i, h)chmin(ans, i + fy[i]);
    cout << ans << endl;
}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s2;
	s1="";
	s2="";
	long long n,i,j;
	j=0;
	cin>>s;
	n=s.length();
	for (i=0;i<n/2;i++)
	{
		s1=s1+s[i];
		s2=s2+s[n-i-1];
		if (s1[i]!=s2[i])
		{
			j++;
		}
	}
	cout<<j<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int a[250], L, N, sum = 0;
	cin >> N >> L;
	int min =  abs (L);
	for (int i = 0; i < N; i++) {
		a[i] = L + i ;
		sum = sum + a[i];
		if (abs (a[i]) <abs (min) ){
			min = a[i];
		                     }

	                            }
	cout << sum - min << endl;
	
		return 0;
	}

Measured memory_bytes: 256
var
	x, y : integer;
begin
	readln(x,y);
	if (x>y) and (y<>1) then
		writeln('Alice')
	else if (y>x) and (x<>1) then
		writeln('Bob')
	else if (x>y) and (y=1) then
		writeln('Bob')
	else if (y>x) and (x=1) then
		writeln('Alice')
	else
		writeln('Draw');
end.

Measured memory_bytes: 128
const main = (input) => {
  input = input.split(' ');
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  const X = parseInt(input[2], 10);
  
  if (A<=X&&A+B>=X) {
    console.log("YES");
  }else{
    console.log("NO");
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
int n,k,q,sz[100005],hv[100005],vs[100005],hd[100005],dp[100005],cn[100005],id[1000005];
vector<int>g[100005];
void dfs(int v,int p){
    sz[v]=1;
    hv[v]=-1;
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=p){
            dfs(g[v][i],v);
            sz[v]+=sz[g[v][i]];
            if(hv[v]==-1||sz[hv[v]]<sz[g[v][i]])hv[v]=g[v][i];
        }
    }
}
void dfs1(int v,int d,int p,int h){
    hd[k]=h;
    cn[k]=cn[h];
    id[v]=k;
    vs[k]=v;
    dp[k++]=d;
    if(hv[v]!=-1)dfs1(hv[v],d+1,v,h);
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=p&&g[v][i]!=hv[v]){
            cn[k]=id[v];
            dfs1(g[v][i],d+1,v,k);
        }
    }
}
int lca(int u,int v){
    u=id[u];v=id[v];
    while(hd[u]!=hd[v]){
        if(dp[hd[u]]>dp[hd[v]])u=cn[u];
        else v=cn[v];
    }
    return vs[min(u,v)];
}
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int m;
        scanf("%d",&m);
        for(int j=0;j<m;j++){
            int a;
            scanf("%d",&a);
            g[i].push_back(a);
            g[a].push_back(i);
        }
    }
    dfs(0,-1);
    dfs1(0,0,-1,0);
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%d\n",lca(a,b));
    }
}



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

unsigned int GCD(unsigned int, unsigned int);

int main() {
  unsigned int a, b, gcd, lcm;
  while(cin >> a >> b) {
    gcd = GCD(a,b);
    lcm = a/gcd*b;
    cout << gcd << " " << lcm << endl;
  }
}

unsigned int GCD(unsigned int a, unsigned int b) {
  unsigned int c;
  do {
    if (a > b) {
      c = a %= b;
    } else {
      c = b %= a;
    }
  } while (c != 0);
  return a != 0 ? a : b;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q?w:-w;
}
const int S=1<<19|1;
const int N=40;
int f[S],g[S],to[S][N];
int ban[N][N];
int main()
{
	int n=gi()-1,m=gi(),lim=gi(),i,t,s,a,b,c;
	const int mod=1e9+7;
	
	while (lim--)
		a=gi()-1,b=gi()-1,c=gi(),ban[a][b]|=1<<!c;

	for (s=0;s<1<<n;s++)
		for (i=0;i<n;i++)
			if (s>>i&1) to[s][i]=s;
			else {
				to[s][i]=s|1<<i;
				for (t=i+1;t<n;t++)
					if (s>>t&1) {
						to[s][i]^=1<<t;
						break;
					}
			}
	
	f[0]=1;
	for (t=0;t<m;t++) {
		for (i=0;i<n;i++) {
			memset(g,0,4*(1<<n));
			for (s=0;s<1<<n;s++)
				if (f[s]) {
					if (~ban[t][i]&1)
						if (!(s>>i&1))
							(g[s]+=f[s])%=mod;
					if (~ban[t][i]&2)
						(g[to[s][i]]+=f[s])%=mod;
				}
			memcpy(f,g,4*(1<<n));
		}
	}
	int ans=0;
	for (s=0;s<1<<n;s++) (ans+=f[s])%=mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 86272
# coding: utf-8
# Your code here!
N = input()
countA = 0
countB = 0
for n,i in enumerate(list(N)):
    if (n % 2 == 0 and i == "1") or (n % 2 == 1 and i == "0") :# 010101 にしたいとき
        countA+=1
    if(n % 2 == 0 and i == "0") or (n % 2 == 1 and i == "1"):# 101010  にしたいとき
        countB+=1
#print(countB,countA)
print(min(countB,countA))
        

Measured memory_bytes: 3956
#include<stdio.h>
int main(void)
{
    int n,a[200000],i,min=0,temp;
    scanf("%d",&n);
    temp=n;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[min]>a[i])
                min=i;
        if(a[min]<a[i]) {
            temp--;
        }
    }
    printf("%d",temp);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

ll a[3];

void find(int left) {
    if (left == 0) {
        if (a[0] < a[1] && a[1] < a[2]) {
            cout << "Yes\n";
            exit(0);
        }
        return;
    }
    for (int i = 0; i < 3; i++) {
        a[i] *= 2;
        find(left - 1);
        a[i] /= 2;
    }
}
int main()
{
    fastInp;

    for (int i = 0; i < 3; i++) cin >> a[i];

    ll k;
    cin >> k;

    find(k);

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 998244353;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
// ll dp[N];
int n, k;
int l[N], r[N]; 
struct SegTree{
    vector <ll> tree;
    int n;
    ll DEFAULT_VALUE = 0; // merge(a, DEFAULT_VALUE) = a
    void build(const vector <ll> &a, int v, int cl, int cr) {
        if(cl == cr)
            tree[v] = a[cl];
        else{
            int md = cl + cr >> 1;
            build (a, v * 2, cl, md);
            build(a, v * 2 + 1, md + 1, cr);
            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
        }
    }
    SegTree(vector <ll>& a) {
        n = (int)a.size();
        a.insert(a.begin(), -1);
        tree.resize(4 * n + 10);
        build(a, 1, 1, n);
    }
    ll merge(ll a, ll b){
        return (a + b) % MOD;
    }
    
    // [l, r]
    ll get(int v, int cl, int cr,const int l,const int r) {
        if(l > r)  
            return DEFAULT_VALUE;
        if(l == cl && r == cr)
            return tree[v];
        int md = cl + cr >> 1;
        return merge(get(v * 2, cl, md, l, min(r, md)), 
               get(v*2 + 1, md + 1, cr, max(l, md + 1), r));
    }
    ll get(int l, int r) {
        if(r < 1)
            return 0;
        l = max(1, l);
        return get(1, 1, n, l, r) % MOD;
    }
    void update(int v, int cl, int cr, int pos, ll nval) {
        if(cl == cr){
            tree[v] = (tree[v] + nval) % MOD;
        }
        else{
            int md = cl + cr >> 1;
            if(pos <= md)
                update (v*2, cl, md, pos, nval);
            else    
                update (v*2 + 1, md + 1, cr, pos, nval);
            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
        }
    }
    void update(int pos, ll nval) {
        update(1, 1, n, pos, nval);
    }
    
};
void solve(){
    cin >> n >> k;
    vector <ll> dp(n);
    dp[0] = 1;
    for(int i = 1; i <= k; ++i)
        cin >> l[i] >> r[i];
    SegTree s(dp);
    assert(dp.size() == n + 1);
        
    for(int i = 2; i <= n; ++i) {
        for(int j = 1; j <= k; ++j) {
            int left = i - r[j];
            int right = i - l[j];
            ll ans = s.get(left, right);
            s.update(i, ans);
        }
    }
    cout << s.get(n, n) % MOD << '\n';
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 11020
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    char n[4];
    for(ll i=0;i<4;++i){
        cin>>n[i];
    }
    sort(n,n+4);
    bool t=false;
    if(n[0]-'0'==1){
        if(n[1]-'0'==4){
            if(n[2]-'0'==7){
                if(n[3]-'0'==9){
                    t=true;
                }
            }
        }
    }
    if(t==true){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

int main() {
        int N =5;
        vector<int>             v(N);

        rep(i, N) {
                cin >> v.at(i);
                if (v.at(i) < 40) v.at(i) = 40;
        }

        int sum = accumulate(v.begin(), v.end(), 0);
        cout << sum / v.size() << endl;
        return 0;
}



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

int main()
{
	int64_t n, m;
	cin >> n >> m;
	vector<int64_t> as(m);
	for (auto &&a : as)
	{
		cin >> a;
	}

	int64_t sum = accumulate(as.begin(), as.end(), int64_t(0));

	cout << max<int64_t>(-1, n - sum) << endl;

	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    for(int i = 1; i < 10; i++){
        if(N%i == 0 && N/i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
program main
integer :: n,k,d,ans = 0
integer,allocatable :: a(:),sn(:)

read(*,*)n,k
allocate(a(n),sn(n))
sn = 0
a = 0

do i = 1,k
read(*,*)d
read(*,*)a(1:d)
do j = 1,d
if (sn(a(j)) == 0) ans = ans + 1
sn(a(j)) = sn(a(j)) + 1
end do
end do

write(*,*) n - ans

end program main

Measured memory_bytes: 2856
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;


int main(){
    int n;
    cin >> n;
    int N = n*n;
    Graph G(N);
    for(int i=0; i<2*n*(n-1); i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    Graph H(n, vector<int>(n, -1));
    vector<int> used(N, 0);
    for(int i=0; i<N; i++){
        if(G[i].size() == 2){
            H[0][0] = i;
            used[i] = 1;
            break;
        }
    }

    for(int i=0; i<n-1; i++){
        for(auto &&k : G[H[0][i]]){
            if(G[k].size() <= 3 && !used[k]){
                H[0][i+1] = k;
                used[k] = 1;
                break;
            }
        }
    }

    for(int j=0; j<n-1; j++){
        for(int i=0; i<n; i++){
            for(auto &&k : G[H[j][i]]){
                if(used[k]) continue;
                H[j+1][i] = k;
                used[k] = 1;
            }
            if(H[j+1][i] == -1){
                cout << "!" << H[j][i] << endl;
            }
        }
    }

    for(int j=0; j<n; j++){
        for(int i=0; i<n; i++){
            cout << H[j][i]+1 << (i==n-1 ? "\n":" ");
        }
    }

}



Measured memory_bytes: 3656
/*
 © 2020-08-15 21:07:12 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli x, k, d; cin >> x >> k >> d;
  x = labs(x);
  lli foo = x / d;
  if(k < foo) cout << labs(x - k * d) << ENDL;
  else if((k - foo) % 2 == 0) cout << labs(x - foo * d) << ENDL;
  else if(k >= foo + 1) cout << labs(x - (foo + 1ll) * d) << ENDL;
  else cout << x << ENDL;
  return 0;
}


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //

// #include <atcoder/all>
// using namespace atcoder;



// --------- library end - //



int main(){


  string s = is();
  ll sz = SZ(s);
  if (s[sz-1]!='s') cout << s + "s" << endk;
  else cout << s + "es" << endk;


  

}



Measured memory_bytes: 3632
s = input()
t = input()
n,m = len(s),len(t)

dp = [[0]*(m+1) for _ in range(n+1)]

for i in range(n+1):
    for j in range(m+1):
        if i != n and j != m and s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + 1)
        if i != n:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j != m:
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])
ans = ""
i = n
j = m
while i > 0 or j > 0:
    if i > 0 and dp[i][j] == dp[i-1][j]:
        i -= 1
    elif j > 0 and dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans
print(ans)


Measured memory_bytes: 116700
s = input()
n = len(s)
min_t = float('inf')
for i in range(n):
    target = s[i]
    pre = -1
    max_t = 0
    for j in range(n):
        if s[j] == s[i]:
            max_t = max(max_t, j-pre-1)
            pre = j
    max_t = max(max_t, n - pre-1)
    if max_t < min_t:
        min_t = min(min_t, max_t)
print(min_t)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
using namespace std;

int n;
int d[10000], m[100][100], p[100];
int c[10000];


void prim(){
  d[0] = 0;
  p[0] = -1;

  while(1){
    int mincost = 10000, u;
    for(int i = 0; i < n; i++){
      if(c[i] != 2 && mincost > d[i]){
        mincost = d[i];
        u = i;
      }
    }

    if(mincost == 10000) break;

    c[u] = 2;

    for(int i = 0; i < n; i++){
      if(c[i] != 2 && m[u][i] >= 0){
        if(m[u][i] < d[i]){
          d[i] = m[u][i];
          p[i] = u;
          c[i] = 1;
        }

      }
    }
  }
}

int main(){

  cin >> n;

  for(int i = 0; i < n; i++){
    c[i] = 0;
    d[i] = 2000;
    for(int j = 0; j < n; j++){
      cin >> m[i][j];
    }
  }

  prim();

  int sum = 0;
  for(int i = 0; i < n; i++) sum += d[i];
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3124
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

func parseProblem() scorer {
	d := scanInt(sc)
	v := 26
	cs := make([]int, v)
	for i := 0; i < v; i++ {
		cs[i] = scanInt(sc)
	}
	ss := make([][]int, d)
	for i := range loop0(d) {
		ss[i] = make([]int, v)
		for j := range loop0(v) {
			ss[i][j] = scanInt(sc)
		}
	}
	return scorer{
		d: d, v: v,
		cs: cs, ss: ss,
	}
}

type scorer struct {
	// 0-indexed
	d, v int
	cs   []int
	ss   [][]int // [<d][<v]
}

func (scr scorer) receiveInput(sc *bufio.Scanner) []int {
	satisfaction := 0
	lasts := make([]int, scr.v)
	results := make([]int, scr.d)
	for day := range loop0(scr.d) {
		tipe := scanInt(sc) - 1
		satisfaction += scr.ss[day][tipe]
		lasts[tipe] = day + 1
		for cType := range loop0(scr.v) {
			satisfaction -= scr.cs[cType] * (day + 1 - lasts[cType])
		}
		results[day] = satisfaction
	}
	return results
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

func resolve(scor scorer) {
	for _, r := range scor.receiveInput(sc) {
		fmt.Println(r)
	}
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2104