akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H , W ;
  cin >> H >> W;
  string S;
  for (  int i =0; i < H; i++){
    string Sx;
    cin >> Sx;
    S += Sx;
  }
  for (int i = 0; i < H*W; i++){
    if (S.at(i) == '.') S.at(i) =  '0';
  }
  for (int i = 0; i < H*W; i++){
    if (S.at(i)=='#'){
      if(i==0){
        if(W>1){if(S.at(i+1) != '#' ) S.at(i+1)+=1 ;}
        if(H>1){if(S.at(i+W) != '#' ) S.at(i+W)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W+1) != '#' ) S.at(i+W+1)+=1 ;}
      }
      else if(i==W-1){
        if(W>1){if(S.at(i-1) != '#') S.at(i-1)+=1 ;}
        if(H>1){if(S.at(i+W) != '#' ) S.at(i+W)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W-1) != '#' ) S.at(i+W-1)+=1 ;}
      }
      else if(0<i&&i<W-1){
        if(W>1){if(S.at(i-1) != '#') S.at(i-1)+=1 ;}
        if(W>1){if(S.at(i+1) != '#') S.at(i+1)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W-1) != '#') S.at(i+W-1)+=1 ;}
        if(H>1){if(S.at(i+W) != '#') S.at(i+W)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W+1) != '#') S.at(i+W+1)+=1 ;}
      }
      else if(i==H*W-1){
        if(W>1){if(S.at(i-1) != '#') S.at(i-1)+=1 ;}
        if(H>1){if(S.at(i-W) != '#') S.at(i-W)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W-1) != '#') S.at(i-W-1)+=1 ;}
      }
      else if(i == H*W-W){
        if(W>1){if(S.at(i+1) != '#') S.at(i+1)+=1 ;}
        if(H>1){if(S.at(i-W) != '#') S.at(i-W)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W+1) != '#') S.at(i-W+1)+=1 ;}
      }
      else if(H*W-W<i&&i<H*W-1){
        if(W>1){if(S.at(i-1) != '#') S.at(i-1)+=1 ;}
        if(W>1){if(S.at(i+1) != '#') S.at(i+1)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W-1) != '#') S.at(i-W-1)+=1 ;}
        if(H>1){if(S.at(i-W) != '#') S.at(i-W)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W+1) != '#') S.at(i-W+1)+=1 ;}
      }
      else if(i%W==0){
        if(W>1){if(S.at(i+1) != '#') S.at(i+1)+=1 ;}
        if(H>1){if(S.at(i+W) != '#') S.at(i+W)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W+1) != '#') S.at(i+W+1)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W+1) != '#') S.at(i-W+1)+=1 ;}
        if(H>1){if(S.at(i-W) != '#') S.at(i-W)+=1 ;}
      }
      else if(i%W==W-1){
        if(W>1){if(S.at(i-1) != '#') S.at(i-1)+=1 ;}
        if(H>1){if(S.at(i+W) != '#') S.at(i+W)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W-1) != '#') S.at(i+W-1)+=1 ;}
        if(H>1){if(S.at(i-W) != '#') S.at(i-W)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W-1) != '#') S.at(i-W-1)+=1 ;}
      }
      else{
        if(W>1){if(S.at(i+1) != '#') S.at(i+1)+=1 ;}
        if(H>1){if(S.at(i+W) != '#') S.at(i+W)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W+1) != '#') S.at(i+W+1)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W+1) != '#') S.at(i-W+1)+=1 ;}
        if(H>1){if(S.at(i-W) != '#') S.at(i-W)+=1 ;}
        if(W>1){if(S.at(i-1) != '#') S.at(i-1)+=1 ;}
        if(H>1&&W>1){if(S.at(i+W-1) != '#') S.at(i+W-1)+=1 ;}
        if(H>1&&W>1){if(S.at(i-W-1) != '#') S.at(i-W-1)+=1 ;}
      }
    }
           
  }
  for(int i=0; i<H*W; i++){
    cout << S.at(i);
    if(i%W==W-1) cout << endl;
  }
}

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

int main() {
   int H, W;
   cin >> H >> W;
  vector<string> image(H);;
    for (int i = 0; i < (W+2); i++){
        cout<<"#";
   }
  cout<<endl;
  for(int i = 0; i < H; i++){
      cin >> image.at(i);
      cout << '#' + image.at(i) + '#' << endl;;
  }
    for (int i = 0; i < (W+2); i++){
        cout<<"#";
   }
  cout<<endl;
}


Measured memory_bytes: 256
N, M = input().split()
N= int(N)
M = int(M)
itemList = list(map(int, input().split()))
itemList.sort()
index = -1
answer = True
for i in range(M):
  if itemList[index] < (sum(itemList)*(1/(4*M))):
    answer = False
    break
  index -= 1
  
if answer:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e5+69, INF=2e9+6969;

int qq;

int main()
{
	ll a,b,c;
	cin >> a >> b;
	char xd;
	cin >> xd >> c;
	ll ans = a*(b*100+c);
	ans/=100LL;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>
int main(void)
{
	int A;
	int B;
	int C;
	
	scanf("%d %d %d", &A, &B, &C);
	
	if((C == A + B) || (C <= A + B)){
		printf("Yes\n");
	}
	
	else{
		printf("No\n");
	}
	
	return(0);
}

Measured memory_bytes: 128
from math import sqrt

x = int(input()) - 1
if x in (1, 2):
    print(x+1)
    exit()

while True:
    x += 1
    
    if x % 6 != 1 and x % 6 != 5:
        continue
    
    x_sqrt = int(sqrt(x))
    for a in range(2, x_sqrt+1):
        if x % a == 0:
            break
    else:
        print(x)
        break


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            if (x.charAt(0) == 'A') {
                out.println('T');
            }
            if (x.charAt(0) == 'T') {
                out.println('A');
            }
            if (x.charAt(0) == 'C') {
                out.println('G');
            }
            if (x.charAt(0) == 'G') {
                out.println('C');
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

int main() {
    long long n, m, ret = 1;
    std::cin >> n >> m;
    const auto mod = 1000000007ll;

    std::vector<long long> fact(101010), inv(101010);
    fact[0] = 1;
    for (auto i = 1; i <= 101010 - 1; i++) fact[i] = fact[i - 1] * i % mod;
    inv[101010 - 1] = inverse(fact[101010 - 1], mod);
    for (auto i = 101010 - 1; i > 0; i--) inv[i - 1] = inv[i] * i % mod;

    // std::deque<long long> ps;
    auto lim = std::sqrt(m);
    // auto m2 = m;
    for (auto i = 2ll; i <= lim;) {
        if (m % i == 0) {
            auto e = 0ll;
            while (m % i == 0) {
                m /= i;
                e++;
            }

            ret = ret * fact[e + n - 1] % mod * inv[e] % mod * inv[n - 1] % mod;
        }

        if (i == 2) i = 3;
        else i += 2;
    }
    if (m > 1) {
        // sqrt(m)より大きい素因数の指数は1
        ret = ret * n % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

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

inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1) res = (res * x);
        x = (x * x), p >>= 1;
    }
    return res;
}
inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}

const ll INF = 1e15;
map<char, bool> MP;

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

    string s;
    cin >> s;

    int len = s.size();
    string res = "";

    if (len == 26){
        string temp = s;
        next_permutation(all(s));

//        string temp1, temp2;
//        temp1 = temp;
//        temp2 = s;
//        trace(temp1);
//        trace(temp2);

        if (s[0] == 'a' && temp[0] != 'a'){
            cout << -1 << endl;
        }
        else{
            for (int i = 0; i < len; i++){
                if (s[i] == temp[i]){
                    res += s[i];
                }
                else{
                    res += s[i];
                    break;
                }
            }

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


    for (int i = 0; s[i]; i++){
        MP[s[i]] = true;
    }

    res = s;

    for (char ch = 'a'; ch <= 'z'; ch++){
        if (!MP[ch]){
            res += ch;
            break;
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
import Control.Applicative

import Data.Char
    (isAlphaNum, toLower)
    
type Problem = (String, String)

type Result = Int

solve :: Problem -> Result

solve (word, text)
    = length $ filter (== word) list where
        lower = map toLower text
        list = map (filter isAlphaNum) $ words lower

output :: Result -> String

output
    = show
    
input :: IO Problem

input
    = do
        word <- getLine
        text <- inputText []
        return (word, text)
        
inputText :: String -> IO String

inputText text
    = do
        line <- getLine
        if line == "END_OF_TEXT"
            then return text
            else inputText $ text ++ " " ++ line

main :: IO ()

main
    = putStrLn.output =<< solve <$> input

Measured memory_bytes: 3948
_ = gets
x, y = 0, 0
gets.chomp.each_char do |c|
  dx, dy =
    (?A..?M) === c ? [0, 1] :
    (?N..?Z) === c ? [0, -1] :
    (?a..?m) === c ? [1, 0] :
                     [-1, 0]
  x += dx
  y += dy
end
s = (x < 0 ? ?z * -x : ?a * x) + (y < 0 ? ?Z * -y : ?A * y)
p s.size
puts s


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() const { return m_val; }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
      *this *= rhs.inv();
      return *this;
    }
    constexpr modint pow(ll n) const {
      if (n == 0) return 1;
      modint o = pow(n >> 1);
      o *= o;
      if (n & 1) o *= *this;
      return o;
    }
    constexpr modint inv() const {
      return pow(m_mod - 2);
    }
    friend ostream& operator<<(ostream& os, const modint &a) { os << a.val(); return os; }
};

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  ll x = 0, y = 0, z = 0;
  auto count = [&](ll i) {
    ll c = 0;
    if (x == a[i]) ++c;
    if (y == a[i]) ++c;
    if (z == a[i]) ++c;
    return c;
  };

  auto add = [&](ll i) {
    if (x == a[i]) {
      ++x;
      return;
    }
    if (y == a[i]) {
      ++y;
      return;
    }
    if (z == a[i]) {
      ++z;
      return;
    }
  };

  modint ans(1);
  for (ll i = 0; i < n; ++i) {
    ans *= count(i);
    add(i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e18;
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

ll N,ans,offset,a,b;
vi V;

int main(){
  cin>>N;
  for (int i=1;i<=N;++i){
    cin>>a>>b;
    ans += a;
    if (a <= b){
      offset += (b-a);
    }else V.pb(b);
  }
  if (offset == 0){
    cout<<0;
    return 0;
  }
  ans -= *min_element(ALL(V));
  cout<<ans;
}

Measured memory_bytes: 512
W, H, N = map(int, input().split())
xya = []
for _ in range(N):
  xya.append( list( map(int, input().split() ) ) )
  
W_0 = H_0 = 0
  
for i in range(N):
  
  if xya[i][2] == 1:
        if W_0 < xya[i][0]:
            W_0 =  xya[i][0]
    
  elif xya[i][2] == 2:
        if W > xya[i][0]:
            W = xya[i][0]
    
  elif xya[i][2] == 3:
        if H_0 < xya[i][1]:
            H_0 = xya[i][1]
    
  elif xya[i][2] == 4:
        if H > xya[i][1]:
            H = xya[i][1]
    
  if (W - W_0 <= 0) or (H - H_0 <= 0):
    break
    
print(max([(W - W_0)*(H - H_0), 0]))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

bool isA(string s){
	int n = 0;
	if(s.at(n)!='>' || s.at(++n)!='\'' ||s.at(++n)!='=') return false;
	int cnt = 1;
	for(;s.at(++n)=='='; cnt++);
	if(s.at(n)!='#') return false;
	for(int i=0; i<cnt; i++){
		if(s.at(++n)!='=') return false;
	}
	if(s.at(++n)!='~' || s.size()>n+1) return false;
	return true;
}

bool isB(string s){
	int n = 0;
	if(s.at(n)!='>' || s.at(++n)!='^' || s.at(++n)!='Q' || s.at(++n)!='=') return false;
	while(true){
		if(s.at(++n)=='Q'){
			if(s.at(++n)!='=') return false;
		}
		else break;
	}
	if(s.at(n)!='~' || s.at(++n)!='~' || s.size()>n+1) return false;
	return true;
}

int main(){
	string S;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>S;
		if(isA(S)) puts("A");
		else if(isB(S)) puts("B");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1188
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arrS = sc.next().toCharArray();
		char[] arrT = sc.next().toCharArray();
		for (int i = 0; i <= n; i++) {
		    boolean flag = true;
		    for (int j = 0; i + j < n; j++) {
		        if (arrS[i + j] != arrT[j]) {
		            flag = false;
		            break;
		        }
		    }
		    if (flag) {
		        System.out.println(i + n);
		        return;
		    }
		}
	}

}


Measured memory_bytes: 23636
n = int(input())
h = [int(_) for _ in input().split()]

ans = 'Yes'
for i in reversed(range(n)):
    h_i = h[i]
    if i == 0:
        h_i_left = 0
    else:
        h_i_left = h[i-1]
    diff = h_i_left - h_i
    if diff > 1:
        ans = 'No'
        break
    elif diff == 1:
        if i != 0:
            h[i-1] = h[i-1] - 1
    else:
        continue

print(ans)

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

int main(){
    int n;
    cin >> n;
    while(n >= 10){
        n %= 10;
    }
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << endl;
    }
    else if(n == 3){
        cout << "bon" << endl;
    }
    else{
        cout << "pon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

immutable inf = 101101101;

long k;

void main() {
    scan(k);

    int n = 50;

    auto ans = new long[](n);
    ans[] += n - 1 + k / n;

    foreach (i ; 0 .. n) {
        if (i < k % n) {
            ans[i] += n - k % n + 1;
        }
        else {
            ans[i] -= k % n;
        }
    }

    writeln(n);
    writefln("%(%s %)", ans);
}




void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main() {
	int n;
	cin >> n;
	set<string> tmp1;
	for (int i = 0; i < n; ++i) {
		string tmp2, str;
		cin >> tmp2 >> str;
		if (tmp2 == "find") {
			if (tmp1.count(str)) cout << "yes";
			else cout << "no";
			cout << endl;
		}
		else tmp1.insert(str);
	}
}


Measured memory_bytes: 32016
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    sm = sum(A)
    agg = 0
    idx = 0
    mid = sm / 2
    shrink_cnt = sm - N
    while agg < mid and idx < N-1:
        
        agg += A[idx]
        idx += 1
    
    oneleft = agg
    oneright = sm - oneleft 
    twoleft = agg-A[idx-1]
    tworight = sm - twoleft
    ans = min(abs(oneleft-oneright), abs(twoleft-tworight))

    print(int(ans))

if __name__ == '__main__':
    solve()

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

int n, m, q, a[55], b[55], c[55], d[55], A[15], ans;

int read() {
    int x = 0, f = 1; char s;
    while((s = getchar()) < '0' || s > '9') if(s == '-') f = -1;
    while(s >= '0' && s <= '9') {x = (x << 1) + (x << 3) + (s ^ 48); s = getchar();}
    return x * f;
}

void dfs(const int now, const int lim) {
    if(now == n + 1) {
        int res = 0;
        for(int i = 1; i <= q; ++ i)
            if(A[b[i]] - A[a[i]] == c[i]) res += d[i];
        ans = max(ans, res);
        return;
    }
    for(int i = lim; i <= m; ++ i)
        A[now] = i, dfs(now + 1, i);
}

int main() {
    n = read(), m = read(), q = read();
    for(int i = 1; i <= q; ++ i) a[i] = read(), b[i] = read(), c[i] = read(), d[i] = read();
    dfs(1, 1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3664
S = input()
op_cnt = len(S) -1

for i in range(2 ** op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = '+'
    formula = ''
    for a, b in zip(S, op + ['']):
        formula += a + b
    if eval(formula) == 7:
        print(formula + '=7')
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll attack (ll h){
    if (h<=1){
    return 1;
    }
    return attack(h/2)*2+1;
    

}


int main(){
    ll h=0;
    cin>>h;
    cout<<attack(h);
    
}

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

int main() {
	
	int n, t;
	cin >> n >> t;
	vector<tuple<int, int, int>> p(n);
	rep(i, n){
		int c, t;
		cin >> c >> t;
		p[i] = make_tuple(t, c, i + 1);
	}
	sort(all(p));
	
	const int INF = 1001001;
	int min = INF;
	rep(i, n){
		if(get<0>(p[i]) > t){
			break;
		}else{
			if(min > get<1>(p[i])){
				min = get<1>(p[i]);
			}
		}
	}
	
	if(min == INF){
		puts("TLE");
	}else{
		cout << min << endl;
	}
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<ll, ll> oddCounts;
    map<ll, ll> evenCounts;
    for (int i = 0; i < N; i++)
    {
        ll v;
        cin >> v;
        if (i % 2)
        {
            evenCounts[v]++;
        }
        else
        {
            oddCounts[v]++;
        }
    }
    vector<pll> oddSortCounts;
    vector<pll> evenSortCounts;
    for (auto odd : oddCounts)
    {
        oddSortCounts.emplace_back(odd.second, odd.first);
    }
    sort(oddSortCounts.begin(), oddSortCounts.end(), greater<pll>());
    for (auto even : evenCounts)
    {
        evenSortCounts.emplace_back(even.second, even.first);
    }
    sort(evenSortCounts.begin(), evenSortCounts.end(), greater<pll>());
    pll oddBest = oddSortCounts.at(0);
    pll evenBest = evenSortCounts.at(0);
    ll answer = 0;
    if (oddBest.second == evenBest.second)
    {
        ll oddNextCount, evenNextCount;
        if (oddSortCounts.size() >= 2)
        {
            oddNextCount = oddSortCounts.at(1).first;
        }
        else
        {
            oddNextCount = 0;
        }
        if (evenSortCounts.size() >= 2)
        {
            evenNextCount = evenSortCounts.at(1).first;
        }
        else
        {
            evenNextCount = 0;
        }
        answer = min(N - oddBest.first - evenNextCount, N - evenBest.first - oddNextCount);
    }
    else
    {
        answer = N - oddBest.first - evenBest.first;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 8824
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i,intial,n) for(int i=intial; i<(n) ; i++)
#define REP(i,intial,n) for(int i=intial; i<=(n) ; i++)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define MP make_pair
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

LL big_mod(LL n, LL p)
{
    if(p==0) return 1;
    if(!(p&1))
    {
        LL r = big_mod(n,p/2) % MOD;
        return ( (r%MOD) * (r%MOD) ) % MOD;
    }
    else return ( ( n%MOD) * (big_mod(n,p-1) %MOD)) % MOD;
}
long long gcd(long long a, long long b) {
  while (b != 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
  int a,b;
  while(cin>>a>>b)
  {
      if((a+b)%3==0 || a%3==0 || b%3==0) cout<<"Possible"<<endl;
      else cout<<"Impossible"<<endl;
  }

}



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

int main(){
  ll A, B, C;
  cin >> A >> B >> C;
  if(A + B + C < 22){
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, h[105]{}, ans=0;
    cin >> n;
    REP(i,n) cin >> h[i+1];
    REP(i,n) ans += max(0,h[i+1]-h[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
void main() {
	auto N = readAs!ulong;
	ulong res = 1;
	foreach(i; 0..N) {
		auto b = readAs!ulong;
		res = res / gcd(res, b) * b;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int maxm = maxn*2;
const int inf = 0x3f3f3f3f;

int n,a[105];
int main() {
    scanf("%d",&n);
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int ans = inf;
    for(int i = -200;i<=200;i++) {
        int sum = 0;
        for(int j = 1;j<=n;j++) {
            sum += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans,sum);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc147/tasks/abc147_d"

#include<bits/stdc++.h>
#define ll long long
#define p (ll)(1e9+7)

using namespace std;

ll XORSUM (vector<ll>&V,ll n)
{
    ll s,i,j,m;
    s = i = 0;

    while(i < 61)
    {
        m = 0;
        for(j=0;j!=n;j++)
        {
            if(V[j]&1)
                m++;

            V[j] = V[j]>>1;
        }

        s = (s+(((m*(n-m))%p)*((((ll)1)<<i)%p))%p)%p;
        i++;
    }

    return s;
}

int main()
{

    ll n;
    cin>>n;

    ll i;
    vector<ll>V;
    for(i=0;i!=n;i++)
    {
        ll x;
        cin>>x;

        V.push_back(x);
    }

    cout<<XORSUM(V,n);      // define

    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;


ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b; //あまりが0ならそれが、最大公約数
}

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    ll a,b;
    cin >> a >> b;
    ll res;
    res = a * b / euclidean_gcd(a, b);


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


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

int main(){
  int N;
  cin>>N;
  vector<string>S(N);
  vector<int>C(4);
  
  for(int j=0; j<N; j++) cin>>S[j];
  
  
  for(int i=0; i<N; i++){
    if(S[i]=="AC"){
      C[0]++;
    }
    else if(S[i]=="WA"){
      C[1]++;
    }
    else if(S[i]=="TLE"){
      C[2]++;
    }
    else{
      C[3]++;
    }
  }
  cout<<"AC"<<" "<<"x"<<" "<<C[0]<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<C[1]<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<C[2]<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<C[3]<<endl;
}



Measured memory_bytes: 6432
#include "bits/stdc++.h"
using namespace std;

int main (){
	int a[6000],i = 0;
	while(1){
		cin >>a[2 * i] >> a[2 * i + 1];
		if(a[2*i] == 0 && a[2*i+1] == 0) break;
		if(a[2 * i] > a[2 * i + 1]){
			swap(a[2*i],a[2*i+1]);
		}
		i++;
	}
	for(int b = 0;b < i;b++){
		printf("%d %d\n",a[2*b],a[2*b+1]);
	}


return 0;
}

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

using namespace std;
using ll = long long;

#define x first
#define y second
typedef pair<int, int> point;
const int N = 3e5 + 5;

ll w, h;
int n;
point a[N];
vector<pair<int, int> > s[2];
ll val[2];
ll ans;

bool cmp(point a, point b) {
	return a.x < b.x;
}

ll st[4 * N], lz[4 * N];

void pushDown(int id, int l, int r) {
	if (lz[id] != 0) {
		st[id] += lz[id];
		if (l < r) {
			lz[id << 1] += lz[id];
			lz[id << 1 | 1] += lz[id];;
		}
		lz[id] = 0;
	}
}
void update(int id, int l, int r, int i, int j, ll x) {
	pushDown(id, l, r);
	if (l > j || r < i || i > j) {
		return;
	}
	if (l >= i && r <= j) {
		lz[id] += x;
		pushDown(id, l, r);
		return;
	}
	int mid = (l + r) >> 1;
	update(id << 1, l, mid, i, j, x);
	update(id << 1 | 1, mid + 1, r, i, j, x);
	st[id] = max(st[id << 1], st[id << 1 | 1]);
}
ll get(int id, int l, int r, int i, int j) {
	pushDown(id, l, r);
	if (l > j || r < i || i > j) {
		return 0;
	}
	if (l >= i && r <= j) {
		return st[id];
	}
	int mid = (l + r) >> 1;
	return max(get(id << 1, l, mid, i, j), get(id << 1 | 1, mid + 1, r, i, j));
}

void solve() {
	sort(a + 1, a + 1 + n, cmp);
	for (int i = 1; i <= 4 * n; i++) {
		st[i] = lz[i] = 0;
	}
	
	for (int j = 0; j <= 1; j++) {
		s[j].clear();
		s[j].push_back({0, 0});
	}
	
	for (int i = 1; i <= n; i++) {
		ans = max(ans, a[i].x - a[i - 1].x + h);
		ans = max(ans, get(1, 1, n, 1, i - 1) + a[i].x - a[i - 1].x);
		if (a[i].y <= h/2) {
			val[0] = h/2 - a[i].y;
			val[1] = h - h/2;
		} else {
			val[0] = h/2;
			val[1] = a[i].y - h/2;
		}
		for (int j = 0; j <= 1; j++) {
			int ptr = s[j].size() - 1;
			while (s[j].size() > 1 && s[j][ptr].x > val[j]) {
				update(1, 1, n, s[j][ptr - 1].y + 1, s[j][ptr].y, val[j] - s[j][ptr].x);
				s[j].pop_back();
				ptr = s[j].size() - 1;
			}
			s[j].push_back({val[j], i});
			update(1, 1, n, i, i, val[j]);
		}
		update(1, 1, n, 1, i, a[i].x - a[i - 1].x);
	}
	
	ans = max(ans, max(ans, w - a[n].x + h));
	ans = max(ans, st[1] + w - a[n].x);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> w >> h >> n;
	for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;
	
	solve();
	for (int i = 1; i <= n; i++) {
		swap(a[i].x, a[i].y);
	}
	swap(w, h);
	solve();
	
	cout << ans * 2;
}


Measured memory_bytes: 26944
N, M = map(int, input().rstrip().split())
S = list(map(int, input().rstrip().split()))
S = [-x for x in S]
import heapq
heapq.heapify(S)

for i in range(M):
    val = int(heapq.heappop(S) / 2)
    heapq.heappush(S, val)
print(-sum(S))


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int cnt = 0;

bool dfs(vector<int> &A, set<int> &S, set<int> &seen, int k) {
    cnt++;
    if (cnt>100000) return false;
    seen.insert(k);
    if (S.count(k)) return true;
    else {
        rep(i,A.size()) {
            if (cnt>100000) break;
            if (A[i]>k) {
                int next = A[i] - k;
                if (!seen.count(next)) {
                    if (dfs(A,S,seen,next)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
}

int main(){
    int N,K;
    cin >> N >> K;
    set<int> S,seen;
    vector<int> A;
    rep(i,N) {
        int a;
        cin >> a;
        if(!S.count(a)) {
            A.push_back(a);
            S.insert(a);
        }
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());

    bool tf = dfs(A,S,seen,K);

    if (tf) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 17056
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    vector<int> Nums;
    int now=1,cnt=0;
    rep(i,n){
        if(s[i]==(char)('0'+now)) cnt++;
        else{
            Nums.pb(cnt);
            now=1-now;
            cnt=1;
        }
    }
    if(cnt) Nums.pb(cnt);
    if(Nums.size() % 2==0) Nums.pb(0);
    int add=2*k+1;
    int left=0,right=0,tmp=0,ans=0;
    for(int i=0;i<Nums.size();i+=2){
        int nextleft = i;
        int nextright = min((int)i+add,(int)Nums.size());
        while(nextleft>left){
            tmp-=Nums[left];
            left++;
        }
        while(nextright>right){
            tmp+=Nums[right];
            right++;
        }
        ans =max(ans,tmp);
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include <iomanip>
#include<string>
using namespace std;
int main()
{
  // 入力
  int n, k;
  cin >> n >> k;
  
  long double p = 0;
  
  for (int i = 1; i <= n; i++) {
    int point = i;
    long double pn = 1;
  	while (point < k) {
    	point *= 2;
      	pn /= 2;
    }
    p += pn;
  }
  
  // 出力
  cout << setprecision(12) << p / n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, e;
  cin >> n >> e;
  e /= 1000;
  rep(x, n+1){
    if(x*10 > e) continue;
    rep(y, n+1){
      if(x*10+y*5>e) continue;
      int z = e - 10*x - 5*y;
      if(x+y+z == n){
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

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

int main(){
    
    int a;
    int b;
    
    cin >> a >> b;
    
    if (a > b) {
        cout << "a > b"  << endl;
    
    } else if (a < b) {
        cout << "a < b"  << endl;
    
    } else if (a == b) {
        cout << "a == b"  << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    int r, d, x;

    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        int x2 = r * x - d; 
        cout << x2 << endl;
        x = x2;
    }
}

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

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

int main() {

    int i;
    char s[101]={0};
    int ans;

    scanf("%s", s);

    ans = strlen(s);

    for(i = 0; i < ans; i++) {
        printf("x");
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
S = [1]+list(map(lambda x:-1 if x == "L" else 1, input()))+[-1]

happy = 0
for i in range(1, N+1):
  if S[i] == S[i+S[i]]:
    happy += 1
rl_inner = 0
for i in range(1, N):
  if S[i] == 1 and S[i+1] == -1:
    rl_inner += 1
rl_outer = (1 if S[1] == -1 else 0) + (1 if S[N] == 1 else 0)
if rl_inner+rl_outer > 1:
  happy += min(rl_inner, K)*2
  if rl_inner < K and rl_outer > 1:
    happy += 1
elif rl_inner == 1:
  happy += 1
print(happy)




Measured memory_bytes: 4768
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
signed main(){
  ll n,a,b,sum,cun=0,t;
  cin>>n>>a>>b;
  for(ll i=1;i<=n;i++){
    sum = 0;
    t = i;
    while(t>0){
      sum += t % 10;
      t /= 10;
    }
    if(a<=sum && b>=sum){
      cun += i;
    }
  }
  cout<<cun<<"\n";
  return 0;
}

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

int main() {
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
	    cout<<"Yes"<<endl;
	    return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<pair<int,int>> v[n];
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        v[i].resize(a);
        for(int j=0;j<a;j++)
        {
            scanf("%d%d",&v[i][j].first,&v[i][j].second);
            v[i][j].first--;
        }
    }
    int res=0;
    for(int mask=0;mask<(1<<n);mask++)
    {
        vector<int> t(n,0);
        for(int i=0;i<n;i++) t[i]=((mask>>i)&1);
        bool ok=1;
        for(int i=0;i<n;i++)
        {
            if(t[i]==0) continue;
            for(pair<int,int> a:v[i]) if(t[a.first]!=a.second) ok=0;
        }
        if(ok) res=max(res,__builtin_popcount(mask));
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
import numpy as np

L, R = map(int, input().split())

if R - L >= 2019:
    ans = 0
elif L % 2019 > R % 2019:
    ans = 0
else:
    X =[]
    l = L % 2019
    r = R % 2019
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            X.append(i*j)
    X_np = np.array(X)
    X_np_mod = X_np % 2019
    ans = min(X_np_mod)

print(ans)

Measured memory_bytes: 124628
#include<iostream>
using namespace std;
int main(){
	long long a=2,b=1,c=3,n;
	cin>>n;
	if(n==1){
		cout<<b;
		return 0;
	}
	if(n==2){
		cout<<c;
		return 0;
	}
	for(int i=3;i<=n;i++){
		a=b;
		b=c;
		c=a+b;
	}
	cout<<c;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
f = False
xx = 0
xA = 0
Bx = 0
BA = 0
A = 0
B = 0
for i in range(N):
  S = input()
  for i in range(len(S) - 1):
    if S[i] == "A" and S[i + 1] == "B":
      ans += 1
  if S[0] == "B":
    if S[-1] == "A":BA += 1
    else:Bx += 1
  else:
    if S[-1] == "A":xA += 1
if xA != 0 and Bx != 0:
  ans += BA + 1
  xA -= 1
  Bx -= 1
elif xA != 0:
  ans += BA
  xA -= 1
elif Bx != 0:
  ans += BA
  Bx -= 1
else:
  if BA >= 2:
    ans += BA - 1
ans += min(Bx,xA)
print(ans)

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int S=0, M=0;
  for (int i = 0; i < N; ++i) {
    int p;
    cin >> p;
    S += p;
    M = max(M, p); // 大きい方を出力する
  }
  int ans = S - M / 2;
  cout << ans << endl; 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
	bool operator<(const B& b) const { return cost < b.cost; }
	bool operator>(const B& b) const { return cost > b.cost; }
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	ans += b / c;
	ans += b / d;
	ans -= (a - 1) / c;
	ans -= (a - 1) / d;
	ans -= b / (c * d / gcd(c, d));
	ans += (a - 1) / (c * d / gcd(c, d));
	cout << (b - a + 1) - ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI l(2*n);
	rep(i,2*n) cin>>l[i];

	sort(l.rbegin(), l.rend());
	
	
	ll ans=0;
	rep(i,n) ans += l[2*i+1];
	cout << ans<<endl;
	return 0;
}


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

int i,j,k,w,n,x,y,z,ans[50];

int main(){
	scanf("%d",&w);
	for(i=1;i<=w;i++)ans[i]=i;
	scanf("\n%d",&n);
	for(i=0;i<n;i++){
		scanf("\n%d,%d",&x,&y);
		z=ans[x];
		ans[x]=ans[y];
		ans[y]=z;
	}
	for(i=1;i<=w;i++)printf("%d\n",ans[i]);
	
	return 0;
}

Measured memory_bytes: 0
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
#[allow(non_snake_case, unused_variables)]
fn main() {
    let mut A: Vec<u32> = (0..3).map(|_| read()).collect();
    A.sort();
    A.reverse();
    println!("{}", A[0]-A[2]);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool maze[110][110];

int main() {
    int a,b;
    cin >> a >> b;
    if (a == 0 || b == 0) {
        cout << "1 1" << endl;
        if (a == 0) {
            cout << "#" << endl;
        } else {
            cout << "." << endl;
        }
        return 0;
    }
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 100; j++) {
            maze[i][j] = 1;
        }
    }
    a--;
    b--;
    for (int i = 0; i < 50; i+=2) {
        for (int j = 0; j < 100; j+=2) {
            if (a > 0) {
                maze[i][j] = 0;
                a--;
            } else {
                break;
            }
        }
        if (a <= 0) break;
    }
    for (int i = 99; i >= 50; i-=2) {
        for (int j = 0; j < 100; j+=2) {
            if (b > 0) {
                maze[i][j] = 1;
                b--;
            } else {
                break;
            }
        }
        if (b <= 0) break;
    }
    cout << "100 100" << endl;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (maze[i][j]) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3628