akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    A = np.array(LI())
    F = np.array(LI())

    A.sort()
    F.sort()
    F = F[::-1]

    # 時間tで感触できるか
    def can_complete(t):
        return np.maximum(0, A-t//F).sum() <= K

    # for j in range(20):
    #     print(can_complete(j))

    ng = -1
    ok = max(A)*max(F)
    while abs(ok-ng)>1:
        m = (ng+ok)//2
        if can_complete(m):
            ok = m
        else:
            ng = m
    print(ok)

if __name__ == '__main__':
    resolve()


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> p[i];
	}
	vector<int> sorted_p(p);
	sort(sorted_p.begin(), sorted_p.end());

	int differ_num = 0;
	for(int i = 0; i < n; ++i)
	{
		if(p[i] != sorted_p[i]) differ_num++;
	}
	cout << (differ_num <= 2 ? "YES" : "NO");
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3620
n = int(input())
cities = set()
scores = {}
scorelist = {}
sp = [[""]]*n
for i in range(n):
  sp[i] = input().split()
  s = sp[i][0]
  p = int(sp[i][1])
  if s in cities:
    scores[s][p] = i
    scorelist[s].append(p)
  else:
    scores[s] = {p:i}
    scorelist[s] = [p]
    cities.add(s)
citylist = list(cities)
citylist.sort()
for x in citylist:
  scorelist[x].sort(reverse = True)
  for i in range(len(scorelist[x])):
    print(scores[x][scorelist[x][i]]+1)
    

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		sc.nextLine();
		String str = sc.nextLine();
		sc.close();
		char[] strArray = str.toCharArray();
		
		int countLeft = 0;
		int countRight = 0;
		char left = '(';
		char right = ')';
		
		int indexRight = -1;
		boolean noMore = false;
		for (int i = 0; i < count; i++) {
			if (left == strArray[i]) {
				countLeft++;
				if (!noMore) {
					if (indexRight == -1 || indexRight < i) {
						indexRight = i;
					}
					boolean found = false;
					for (int j = indexRight + 1; j < count; j++) {
						if (right == strArray[j]) {
							found = true;
							indexRight = j;
							countLeft--;
							break;
						}
					}
					if (!found || indexRight == count - 1) {
						noMore = true;
					}	
				}
			}
		}
		
		int indexLeft = -1;
		noMore = false;
		for (int i = count - 1; i >= 0; i--) {
			if (right == strArray[i]) {
				countRight++;
				if (!noMore) {
					if (indexLeft == -1 || indexLeft > i) {
						indexLeft = i;
					}
					boolean found = false;
					for (int j = indexLeft - 1; j >= 0; j--) {
						if (left == strArray[j]) {
							found = true;
							indexLeft = j;
							countRight--;
							break;
						}
					}
					if (!found || indexLeft == 0) {
						noMore = true;
					}	
				}
			}
		}
		String result = str;
		for (int i = 0; i < countRight; i++) {
			result = "(" + result;
		}
		
		for (int i = 0; i < countLeft; i++) {
			result += ")";
		}
		
		System.out.println(result);
	}
}

Measured memory_bytes: 22100
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, x] = [int(input_raw[0]), int(input_raw[1])]
    A = []
    A_dic = {}
    input_raw = read_func().strip().split()
    for i in range(N):

        a = int(input_raw[i])
        A.append(a)
        if a in A_dic:
            A_dic[a] += 1
        else:
            A_dic[a] = 1
    A.sort()
    max_count = 0
    for i in range(N):
        count = 0
        x_tmp = x
        for j in range(i, N):
            if x_tmp - A[j] >= 0:
                if j < N - 1:
                    count += 1
                else:
                    if x_tmp == A[j]:
                        count += 1
            x_tmp -= A[j]
        #if x_tmp == 0:
        max_count = max(max_count, count)


    print max_count



if __name__ == '__main__':
    main()


Measured memory_bytes: 3052
#include<iostream>
using namespace std;
int main(){
	long x,a,b,w;
	cin>>x;
	cin>>a;
	cin>>b;
	w=x-a;
	for(int i=0;;i++){
		w=w-b;
		if(w<0){
			cout<<w+b<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define DEBUG
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,a=big;cin>>n;
	for(int i=0;i<5;i++){
		llint b;cin>>b;
		mineq(a,b);
	}
	cout<<4+(n+a-1)/a<<endl;
}

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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int k, x; cin >> k >> x;
	int end = x + k;
	for (int start = x - ( k - 1); start < end; start++)
	{
		cout << start << " ";
	}
	return 0;
}

Measured memory_bytes: 3580
def insertionSort arr, n, g
    for i in g ... n
        v = arr[i]
        j = i - g
        while j >= 0 && arr[j] > v
            arr[j + g] = arr[j]
            j -= g
            @count += 1
        end
        arr[j + g] = v
    end
end
  
def shellSort arr, n
    @count = 0
  
    g = []
    interval = 1
    begin
        g << interval
        interval = g.last * 3 + 1
    end while interval < n
    g.reverse!
    m = g.length
  
    for i in 0 ... m
        insertionSort(arr, n, g[i])
    end
  
    puts m
    puts g.join(" ")
    puts @count
end
  
n = gets.to_i
arr = Array.new(n)
n.times{|i| arr[i] = gets.to_i}
shellSort(arr, n)
puts arr

Measured memory_bytes: 16572
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

template <typename Monoid> struct SegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while (sz < n)
      sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) { seg[k + sz] = x; }

  void build() {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1)
        L = f(L, seg[a++]);
      if (b & 1)
        R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const { return seg[k + sz]; }

  template <typename C>
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while (a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if (check(nxt))
        a = 2 * a + type;
      else
        M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }

  template <typename C> int find_first(int a, const C &check) {
    Monoid L = M1;
    if (a <= 0) {
      if (check(f(L, seg[1])))
        return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) {
        Monoid nxt = f(L, seg[a]);
        if (check(nxt))
          return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template <typename C> int find_last(int b, const C &check) {
    Monoid R = M1;
    if (b >= sz) {
      if (check(f(seg[1], R)))
        return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for (b += sz; a < b; a >>= 1, b >>= 1) {
      if (b & 1) {
        Monoid nxt = f(seg[--b], R);
        if (check(nxt))
          return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

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

  int n, q;
  cin >> n >> q;
  SegmentTree<int> seg(
      n, [](int a, int b) { return a + b; }, 0);
  REP(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      seg.update(x, seg[x] + y);
    } else if (com == 1) {
      cout << seg.query(x, y + 1) << '\n';
    }
  }

  return 0;
}


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

string s;
long kekka = 0,sum = 0;
void dfs(long i,long num){
  if(i == s.size()){
    kekka += num;
    //cout << num << endl;
    return;
  }
  for(long j = 0;j <= 1;j++){
    if(j == 0){
       dfs(i+1,num*10 + (s.at(i) - '0'));
    }
    else{
      sum += num;
      kekka += sum;
      //cout << num << endl;
      dfs(i+1,0);
      sum -= num;
    }
  }
  return;
}

int main(){
  cin >> s;
  dfs(0,0);
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
#define MOD 1000000007
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
typedef long long ll;
typedef long double ld;
const int MAX = 2e5 + 5;
const int MAXN = 105;

// vector<ll> primes;
// void seive() {
//     vector<int> v(MAX);
//     for (int i = 2; i * i < MAX; i++) {
//         if (v[i] == 0) {
//             for (int j = i * i; j < MAX; j += i) v[j] = 1;
//         }
//     }
//     primes.pb(2);
//     for (int i = 3; i < MAX; i += 2) if (v[i] == 0) primes.pb(i);
// }
// ll pw(ll a, ll n) {
//     ll rs = 1;
//     while (n) {
//         if (n & 1) rs = rs * a;
//         n >>= 1;
//         a = a * a;
//     }
//     return rs;
// }
// bool isPrime(ll n) {
//     for (int i = 2; i * i <= n; i++) {
//         if (n % i == 0) return false;
//     }
//     return true;
// }
vector<int> a(MAX),b(MAX);
vector<int> g[MAX];
int main() {
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for printing output from output.txt
    freopen("output1.txt", "w", stdout);
#endif
    // int t;
    // cin >> t;
    // while (t--) {
    // }
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int sum[200005];
    int k,n;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&sum[i]);
    }
    sort(sum,sum+n);
    ll ans=0;
    for(int i=0;i<n-k;i++){
        ans+=sum[i];
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
s = [0 for i in range(n)]
s[0] = a[0]
for i in range(1, n):
  s[i] = s[i-1]^a[i]

MOD = 10**9+7
dp = [[not j for i in range(1<<20)] for j in range(2)]
cnt = [0 for i in range(1<<20)]
z = 0
for i in range(n):
  if s[i]==0:
    z += 1
  dp[0][s[i]] = (dp[0][s[i]]+dp[1][s[i]]*(z-cnt[s[i]])%MOD)%MOD
  dp[1][s[i]] = (dp[1][s[i]]+dp[0][s[i]])%MOD
  cnt[s[i]] = z

if s[n-1]:
  print(dp[0][s[n-1]])
else:
  ans = pow(2, z-1, MOD)
  for i in range(1, 1<<20):
    ans = (ans+dp[1][i])%MOD
  print(ans)


Measured memory_bytes: 74556
S= input()
u = int(S[:2])
l = int(S[2:])
YYMM = False
MMYY = False
if 1<=l<=12:
    YYMM = True
if 1<=u<=12:
    MMYY = True
if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <stdio.h>


int main() {
	char op;
	int a, b;
	int A[100] = {};
	int i = 0;
	for (;;) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')break;
		else if (op == '+') {
			A[i] = a + b;
			i++;
		}
		else if (op == '-') {
			A[i] = a - b;
			i++;
		}
		else if (op == '*') {
			A[i] = a * b;
			i++;
		}
		else if (op == '/') {
			A[i] = a / b;
			i++;
		}
	}
	for (int j = 0; j < i; j++) {
		printf("%d\n", A[j]);
	}
	

	return 0;
}

Measured memory_bytes: 2668
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T & a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	vt n;
	cin >> n;
	vector<vt> h(n);
	rep(i, n) cin >> h.at(i);
	vector<vt> dp(n, INF);
	dp.at(0) = 0;
	dp.at(1) = abs(h.at(0) - h.at(1));
	if (n == 2) {
		cout << dp.at(1);
		return 0;
	}
	reps(i, 2, n) {
		chmin(dp.at(i), dp.at(i - 1) + abs(h.at(i - 1) - h.at(i)));
		chmin(dp.at(i), dp.at(i - 2) + abs(h.at(i - 2) - h.at(i)));
	}
	cout << dp.at(n - 1);
	return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
from fractions import gcd
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

a,b=map(int,input().split())
g=gcd(a,b)
ass=prime_factor(g)
print(len(ass)+1)


Measured memory_bytes: 5048
/**
 *  author: sourav rakshit
 *  created: 22.08.2020 17:41:36
**/

#include <bits/stdc++.h>
using namespace std;

#define ar array
#define all(x) begin(x), end(x)
#define len(x) (int)(x).size()
#define fast ios::sync_with_stdio(false), cin.tie(nullptr)
#ifdef LOCAL
#define log(x) cerr<<"[ " << #x << " : " << (x) << " ]\n";
#else
#define log(x) (void)0x30
#endif

using ll = long long;

int32_t main() {
    fast; 
    int tt = 1;
    while(tt--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int& i : arr) cin >> i;
        ll sum = 0;
        for(int i=1; i<n; i++) {
            if(arr[i] < arr[i-1]) {
                sum += abs(arr[i-1] - arr[i]);
                arr[i] = arr[i-1];
            }
        }
        cout << sum << '\n';
    }
#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
}



Measured memory_bytes: 3972
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	if(2*n<=m)
	{
		long long  sum=n;
		m=m-2*n;
		sum+=m/4;
		printf("%lld\n",sum);
	}
	else 
	{
		printf("%lld\n",m/2);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>

using u128 = __uint128_t;
using u64 = unsigned long long int;
using s64 = long long int;
using u32 = unsigned int;

constexpr u32 mod = 1000000007;

int n;

u32 pow2(int n){
  if(n == 0) return 1;
  u64 r = 2;
  u32 x = 1U << (31-__builtin_clz(n));
  while(x != 1){
    r = r * r % mod;
    x >>= 1;
    if(n & x){
      r <<= 1;
      if(r >= mod) r -= mod;
    }
  }
  return r;
}

int main(){

  scanf("%d", &n);

  using quot = std::pair<u64, u64>;
  std::vector<quot> vp, vn;
  int zero2 = 0;

  for(int i = 0; i < n; i++){
    s64 a, b;
    scanf("%lld%lld", &a, &b);
    if(a == 0 && b == 0) zero2++;
    else if(b != 0 && (a == 0 || (a^b) >= 0)){
      vp.emplace_back(std::abs(a), std::abs(b));
    }
    else {
      vn.emplace_back(std::abs(b), std::abs(a));
    }
  }

  auto comp = [](const quot &a, const quot &b){ return (u128) a.first * b.second < (u128) b.first * a.second; };
  
  std::sort(vp.begin(), vp.end(), comp);
  std::sort(vn.begin(), vn.end(), comp);

  auto equiv = [](const quot &a, const quot &b){ return (u128) a.first * b.second == (u128) b.first * a.second; };


  std::vector<std::pair<quot, u32> > vpp, vnn;
  quot prev = {1, -1};
  for(auto const &x: vp){
    if(equiv(x, prev)) vpp.back().second++;
    else{
      vpp.emplace_back(quot(x.first, x.second), 1);
      prev = x;
    }
  }
  prev = {1, -1};
  for(auto const &x: vn){
    if(equiv(x, prev)) vnn.back().second++;
    else{
      vnn.emplace_back(quot(x.first, x.second), 1);
      prev = x;
    }
  }

  u64 ans = 1;
  auto ip = vpp.begin(), in = vnn.begin();
  while(ip != vpp.end() && in != vnn.end()){
    if(equiv(ip->first, in->first)){
      ans = ans * (pow2(ip->second) + pow2(in->second) + mod - 1) % mod;
      ++ip, ++in;
    }
    else if(comp(ip->first, in->first)){
      ans = ans * pow2(ip->second) % mod;
      ++ip;
    }
    else {
      ans = ans * pow2(in->second) % mod;
      ++in;
    }
  }
  while(in != vnn.end()){ ans = ans * pow2(in->second) % mod; ++in; }
  while(ip != vpp.end()){ ans = ans * pow2(ip->second) % mod; ++ip; }

  ans = (ans + zero2 + mod - 1) % mod;
  printf("%llu\n", ans);

  return 0;
}


Measured memory_bytes: 12616
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

#include <vector>
#include <stack> // s.top()
#include <queue> // s.front()
using namespace std;

typedef long long llong;
typedef vector<int> vecint;
typedef vector<llong> vecllong;
typedef pair<llong, llong> P;

#define INF10 10000000000
#define EPS 1e-10

bool pairComp(const P& firstElof, const P& secondElof) {
	return firstElof.second > secondElof.second;
}

llong Adouble[50];
llong score1[50];
llong score0[50];
llong Kdouble[50];

int devv(llong ipt) {
	llong x = ipt;
	int cnt = 0;
	while (x>0) {
		if (x % 2 == 1)Adouble[cnt]++;
		cnt++;
		x /= 2;
	}
	return 0;
}

int devk(llong k) {
	llong x = k;
	int cnt = 0;
	while (x>0) {
		if (x % 2 == 1)Kdouble[cnt]++;
		cnt++;
		x /= 2;
	}
	return 0;
}


int main() {
	int N;
	llong K;
	vecllong ans;
	cin >> N >> K;
	devk(K);
	for (int i = 0; i < N; i++) {
		llong ipt;
		cin >> ipt;
		devv(ipt);
	}
	llong deb = 1;
	for (int i = 0; i < 50; i++) {
		score0[i] += deb * Adouble[i];
		score1[i] += deb * (N - Adouble[i]);
		deb *= 2;
	}
	llong mx = 0;
	llong base = 0;
	for (int i = 49; i >= 0; i--) {
		if (Kdouble[i] == 0) {
			base += score0[i];
		}
		else {
			llong tmp = base;
			for (int j = i; j >= 0; j--) {
				if (j == i)tmp += score0[j];
				else tmp += max(score0[j], score1[j]);
			}
			mx = max(mx, tmp);
			base += score1[i];
		}
	}
	mx = max(base, mx);

	cout << mx << endl;






	return 0;
}

Measured memory_bytes: 384
#include   <cstdio>
#include  <cstring>
#include <iostream>
//#include<windows.h>
//#define csy Sleep(5)
using namespace std;
const int cat[] = {100, 101, 102, 103, 104, 105};

int n, f[100010];

int main() {
	scanf("%d", &n), f[0] = f[100] = f[101] = f[102] = f[103] = f[104] = f[105] = 1;
	for (int i = 106; i <= n; i++) {
		bool B = 0;
		for (int j = 0; j < 6 && !B; j++) {
			if (f[i - cat[j]]) f[i] = 1, B = 1;
		}
	}
	if (f[n]) printf("1\n");
	else printf("0\n");
	return 0;
}

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

int main() {
  int n, T;
  cin >> n >> T;
  vector<int> c(n), t(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> t[i];
  }

  int res = (1 << 21);
  for (int i = 0; i < n; i++) {
    if (t[i] <= T) { res = min(res, c[i]); }
  }
  if (res == (1 << 21)) {
    cout << "TLE" << endl;
  } else {
    cout << res << endl;
  }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li a,b;
    cin>>a>>b;
    cout<<a*(a-1)/2+b*(b-1)/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
int N;
double X[30],Y[30],Z[30],cx,cy,cz;
double sq(double x) { return x*x; }
double distance2(int i) { return sqrt(sq(X[i]-cx)+sq(Y[i]-cy)+sq(Z[i]-cz)); }
int longest() { 
	double max = 0; int max_i;
	for (int i=0; i<N; ++i)
		if (distance2(i) > max){
			max=distance2(i);
			max_i=i;
		}
		return max_i;
}
int main() {
	while (scanf("%d",&N) && N) {
		for (int i=0; i<N; ++i) scanf("%lf%lf%lf", X+i, Y+i, Z+i);
		cx = cy = cz = 0.5;
		for (double d=0.5; d>1e-8; d/=2) {
			for (int t=0; t<100; ++t) {
				int i = longest();
				cx += (X[i]-cx)*d;
				cy += (Y[i]-cy)*d;
				cz += (Z[i]-cz)*d;
			}
		}
		printf("%.5f\n", distance2(longest()));
	}
}

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

class Array
{
    protected:
        int *array, length;
    
    public:
        Array() : array(nullptr), length(0)
        {

        }

        void Setlength() {
            scanf("%d", &length);
        }

        void SetArray() {
            array = (int *)malloc((length + 1) * sizeof(int));
            for(int i=1; i<=length; ++i) 
                scanf("%d", &array[i]);
        }

        void PrintArray() {
            for(int i=1; i<=length; ++i) {
                if(i-1)
                    printf(" ");

                printf("%d", array[i]);
            }
            printf("\n");
        }

        void DeleteArray() {
            delete(array);
        }
};

class Partition : public Array
{
    private:
        int i, standard;

    public:
        Partition() : i(0), standard(0)
        {

        }

        void swap(int *a, int *b) {
            int tmp;
            tmp = *a;
            *a = *b;
            *b = tmp;
        }

        void partition() {
            standard = array[length];

            for(int j=1; j<length; ++j) {
                if(array[j] <= standard) {
                    ++i;
                    swap(&array[i], &array[j]);
                }
            }
            swap(&array[i+1], &array[length]);
        }

        void sort() {
            Setlength();
            SetArray();
            partition();

            for(int j=1; j<=length; ++j) {
                if(j-1)
                    printf(" ");

                if(j == i+1) 
                    printf("[%d]", array[j]);
                
                else
                    printf("%d", array[j]);
            }
            printf("\n");
        }

};

int main() {
    Partition _part;
    _part.sort();

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  ll s=0;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=s*a[i];
    ans%=1000000007;
    s+=a[i];
    s%=1000000007;
  }
  
  cout << ans << endl;
  
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> ABC(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> ABC[i][j];
    }
  }
  vector<vector<int>> dp(N + 1, vector<int>(3, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + ABC[i][j]);
      }
    }
  }
  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << '\n';
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int k, a, b;
  cin >> k >> a >> b;
  if (dup(a,k)*k <= b) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, N, A;
  cin >> H >> N;
  
  for(int i = 0;i < N;i++) {
  cin >> A;
  H = H - A;
  }
  
  if(H > 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int m[100];

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

  string str;
  cin >> str;

  EACH(t, str) {
    m[t - 'a']++;
  }

  REP(i, 26) {
    if (m[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return (0);
    }
  }

  cout << "None\n";
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
  int N; cin>>N;
  ll a[N]; CINA(a,N);
  bool win_second = true;
  REP(i,N){
    if(a[i]%2==1){ win_second=false; break;} //「全部偶数」の押し付けあい
  }
  cout << (win_second?"second":"first") << "\n";
  
}

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

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

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






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,ans=1;
  cin>>n;
  while(ans<=n){
    ans*=2;
  }
  cout<<ans/2<<endl;
}
///////////////////////////

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
vector<ll> val[4];
vector<ll> ps[4];
ll ans, n, W, w[111], v[111];

ll gv(ll cnt_0, ll cnt_1, ll cnt_2, ll cnt_3)
{
	return ps[0][cnt_0]+ps[1][cnt_1]+ps[2][cnt_2]+ps[3][cnt_3];
}

int main(void)
{
	cin>>n>>W; ll i, j, k, l;
	for(i=1 ; i<=n ; i++) cin>>w[i]>>v[i];
	for(i=1 ; i<=n ; i++) val[w[i]-w[1]].push_back(v[i]);
	for(i=0 ; i<=3 ; i++) if(val[i].size()) sort(val[i].begin(),val[i].end());
	for(i=0 ; i<=3 ; i++) if(val[i].size()) reverse(val[i].begin(),val[i].end());
	for(i=0 ; i<=3 ; i++)
	{
		ll cc=0; ps[i].push_back(0);
		for(j=0 ; j<val[i].size() ; j++)
		{
			cc+=val[i][j];
			ps[i].push_back(cc);
		}
	}
	for(i=0 ; i<=n && i<=val[0].size() ; i++)
	{
		for(j=0 ; i+j<=n && j<=val[1].size() ; j++)
		{
			for(k=0 ; i+j+k<=n && k<=val[2].size() ; k++)
			{
				for(l=0 ; i+j+k+l<=n && l<=val[3].size() ; l++)
				{
					ll weight=i*w[1]+j*(w[1]+1)+k*(w[1]+2)+l*(w[1]+3);
					if(weight>W) continue;
					ans=max(ans,gv(i,j,k,l));
				}

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

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int total = 0;
        for (int i = 0; i < m; i++) {
            total += sc.nextInt();
        }
        if (total > n) {
            System.out.println(-1);
        } else {
            System.out.println(n - total);
        }
    }
}

Measured memory_bytes: 46424
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <ctype.h>
const int bufSize = 1e6;
using namespace std;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
const int maxn = 3e5 + 100;
int n, m, k;
int row[maxn], col[maxn];
bool vis[maxn];
bitset<maxn> bs;
vector<int> v[maxn];
int main()
{
    read(n), read(m), read(k);
    for (int i = 1; i <= k; ++i) 
    {
        int x, y;
        read(x), read(y), row[x]++, col[y]++, v[x].push_back(y);
    }
    int maxx = 0,maxy = 0;
    for (int i = 1; i <= n; ++i) maxx = std::max(maxx, row[i]);
    for (int i = 1; i <= m; ++i) maxy = std::max(maxy, col[i]);
    for (int i = 1; i <= m; ++i) if (col[i] == maxy) bs.set(i);
    int ans = maxx + maxy - 1;
    for (int i = 1; i <= n; ++i)
        if (row[i] == maxx)
        {
            bitset<maxn> ts;
            for (vector<int>::iterator it = v[i].begin(); it != v[i].end(); ++it) ts.set(*it);
            ts.flip();
            if ((ts & bs).any())
            {
                ans = maxx + maxy;
                break;
            }
        }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 23036
#include <iostream>

int main() {

  int N, X;
  int L[100] = {}, D[101] = {};

  std::cin >> N >> X;
  int counter = 0;

  for (int i=0; i<N+1; i++) {
    std::cin >> L[i];
    if (D[i]<=X) {
      counter++;
    } else {
      break;
    }
    D[i+1] = D[i] + L[i];
  }

  std::cout << counter << std::endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
using namespace std;

int main() {
  double n;
  cin>>n;
  double  wa=0.0000000;
  vector<double>vec(n);
  vector<double>vek(n);
  for(int i=0;i<n;i++) {
    double a;
    cin>>a;
    vec.at(i)=a;
    wa+=a;
  }
  double hei=wa/n;
  for(int i=0;i<n;i++) {
    double g=vec.at(i);
    vek.at(i)=abs(hei-g);
    vec.at(i)=abs(hei-g);
  }
  sort(vek.begin(),vek.end());
  for(int i=0;i<n;i++) {
    if(vek.at(0)==vec.at(i)) {
      cout<<i<<endl;
      break;
    }
  }
}

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

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1100000;
int sa[N], sb[N], fa[N], fb[N], a[N], b[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    if (n == 1 && m == 1){
        cout << 1;
        return 0;
    }
    if (n == 1){
        cout << m - 2;
        return 0;
    }
    if (m == 1){
        cout << n - 2;
        return 0;
    }
    cout << (n - 2) * (m - 2);
}


Measured memory_bytes: 256
from operator import mul

N, M, C = map(int, input().split())  # 複数数値入力
B = list(map(int, input().split()))

A = [0]*N
for i in range(N):
    A[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
    if sum([x * y for (x, y) in zip(A[i], B)]) + C > 0:
        ans += 1

print(ans)


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

int main() {
  int a,b,x; cin>>a>>b>>x;
  if(a<=x&&x<=a+b){cout<<"YES"<<endl;}
  else cout<<"NO"<<endl;

  }


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<time.h>
typedef unsigned int uint;
typedef long long ll;

int main()
{
    int i, j, n, k,q,a[100000],b[100001];
    scanf("%d %d %d", &n, &k, &q);
    for (i = 1; i <= n; i++)
    {
        b[i]=k-q;
    }
    for (i = 0; i < q;i++)
    {
        scanf("%d", &a[i]);
        b[a[i]]++;
    }
    for (i = 1; i <= n; i++)
    {
        if(b[i]>0)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}

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

ll N, X, D;

ll gcd( ll a, ll b ){
	if ( a < b )
		return gcd( b, a );
	
	int k = a / b;
	if ( a - k * b == 0 )
		return b;
	return gcd( b, a - k * b );
}




/*
	どのようにとっても S+T は1通りなので
	(S-T)の通り = ((S+T) + (S-T))の通り
	            =  (2S)の通り
	            =   Sの通り
	
	S が a個の要素を取った場合
		Sの取りうる値は aX + bD の形
		S = f(a,b) = aX + bD とする
	
	a,b の値は
		0 <= a <= N
		bmin(a) <= b <= bmax(a)
			bmin は 0..N-1 の数列の先頭a個の合計
			bmax は 0..N-1 の数列の末尾a個の合計
	
	X, D を gcd(X,D)で割って互いに素にしておく
	全てのa について b の通りと、重複するかどうかを調べる
	
	   (a,b) と (a-cD,b+cX) が重複する
	
	D == 0 の場合
	X == 0 の場合

	X < 0
	-X = Y
	D=3
		0個取った場合のSの範囲    0     ～ 0
		0+D個取った場合のSの範囲  -DY  + (3..297)D
		0+2D個取った場合のSの範囲 -2DY +  (15..685)D
		
		0
		(3..300-3)-Y
		(15..600-15)-2Y

*/



int main(){
	cin >> N >> X >> D;
	if ( D < 0 ){
		D = -D;
		X = -X;
	}
	
	ll g = (X == 0 || D == 0) ? (max(abs(X),abs(D))) : gcd(abs(X),abs(D));
	if ( g != 0 ){
		X /= g;
		D /= g;
	}
	
	
	ll result = 0;
	vector<ll> bmin(N+1);
	vector<ll> bmax(N+1);
	vector<ll> Smin(N+1);
	vector<ll> Smax(N+1);
	
	if ( D == 0 ){
		if ( X == 0 ){
			result = 1;
		}
		else {
			result = N+1;
		}
	}
	else {
		for ( ll a = 0; a <= N; a++ ){
			bmin[a] = a*(a-1)/2;
			bmax[a] = a*(N-1) - bmin[a];
			Smin[a] = a*X+bmin[a]*D;
			Smax[a] = a*X+bmax[a]*D;
			
			ll count = 0;
			// b の取りうる値は bmin[a]～bmax[a] だが、以前のaで既にカウントした分を除く必要がある
			if ( a-D >= 0 && a != 0 ){
				if ( Smax[a-D] < Smax[a] ){
					if ( Smax[a-D] < Smin[a] ){
						count += (Smax[a]-Smin[a]) / D + 1;
					}
					else {
						count += (Smax[a]-Smax[a-D]) / D;
					}
				}
				if ( Smin[a-D] > Smin[a] ){
					if ( Smin[a-D] > Smax[a] ){
						count += (Smax[a]-Smin[a]) / D + 1;
					}
					else {
						count += (Smin[a-D]-Smin[a]) / D;
					}
				}
				Smax[a] = max( Smax[a], Smax[a-D] );
				Smin[a] = min( Smin[a], Smin[a-D] );
			}
			else {
				count = bmax[a]-bmin[a]+1;
			}
			
			//cout << " a=" << a << " bmin=" << bmin[a] << " bmax=" << bmax[a] << " Smin=" << Smin[a] << " Smax=" << Smax[a] << " count=" << count << " ";
			//cout << "  aX+bD = " << (a*X+bmin[a]*D) << " .. " << (a*X+bmax[a]*D) << endl;
			result += count;
		}
	}
	
	
	cout << result << endl;
	
	return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main () {
  char A, B, C, D;
  cin >> A >> B >> C >> D;
  int num;
  vector<int> ans(3);
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < 2; j++) {
      for(int k = 0; k < 2; k++) {
        int num = A - '0';
        if (i == 0) num += B - '0';
        else num -= B - '0';
        if (j == 0) num += C - '0';
        else num -= C - '0';
        if (k == 0) num += D - '0';
        else num -= D - '0';
        if (num == 7) {
          ans.at(0) = i, ans.at(1) = j, ans.at(2) = k;
          break;
        }
      }
    }
  }
  vector<char> sub(3);
  for(int i = 0; i < 3; i++) {
    if(ans.at(i) == 0) sub.at(i) = '+';
    else sub.at(i) = '-';
  }
  cout << A << sub.at(0) << B << sub.at(1) << C << sub.at(2) << D << "=7" << endl;
  return 0;
}


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

using namespace std;

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 20;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e9) return 10;
  if (x >= (long long)1e8) return 9;
  if (x >= (long long)1e7) return 8;
  if (x >= (long long)1e6) return 7;
  if (x >= (long long)1e5) return 6;
  if (x >= (long long)1e4) return 5;
  if (x >= (long long)1e3) return 4;
  if (x >= (long long)1e2) return 3;
  if (x >= (long long)1e1) return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus) x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char* s) {
  if (pt_out > buf_size - 32) flush();
  for (int i = 0; s[i] != 0; ++i) print(s[i]);
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int ct = 0;
  for (int i = 0; i < N; ++i) {
    int l, r;
    scan(l);
    scan(r);
    if (l == r) {
      ct++;
      if (ct >= 3) {
        println("Yes");
        return 0;
      }
    } else {
      ct = 0;
    }
  }
  println("No");
  return 0;
}

Measured memory_bytes: 3632
m = 2019

def compute(L, R):
    global m
    #print("L={}, R={}".format(L, R))
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            v = i * j % 2019
            if v < m:
                m = v

            #print("({}, {})".format(i, j))
            if m == 0:
                return


L, R = list(map(int, input().rstrip().split()))
compute(L, R)
print(m)



Measured memory_bytes: 2940