akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll N, A, B;

int main() {
    cin >> N >> A >> B;
    ll ans;
    ll a = min(A, B), b = max(A, B);
    if (A % 2 == B % 2)
        ans = abs(A - B) / 2;
    else {
        ans = (a + b - 1) / 2;
        ans = min(ans, N - (a + b - 1) / 2);
    }

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


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

using namespace std;

int main ()
{
  	int N;
  	cin >> N;
  	vector<int> A(N);
  	for(int i = 0; i < N; i++){
      	cin >> A.at(i);
    }
  	sort(A.begin(), A.end());
  	cout << A.at(N - 1) - A.at(0);
  	return 0;
}


Measured memory_bytes: 256
Q,H,S,D = list(map(int,input().split()))
N = int(input())

if N%2 == 0:
	A = (N//2) * min(Q*8,H*4,S*2,D)
else:
	A = min(Q*4,H*2,S) + ((N-1)//2) * min(Q*8,H*4,S*2,D)

print(A)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
    
    while (1) {
        int m, n;
        cin >> m >> n;
        if (!(m || n))break;

        int now = 0;
        vector<bool> alive(m, true);
        int a_cnt = m;
        eFOR(i, 1, n) {
            string ans = to_string(i);
            if (i % 15 == 0)ans = "FizzBuzz";
            else if (i % 5 == 0)ans = "Buzz";
            else if (i % 3 == 0)ans = "Fizz";

            while (!alive[now])(++now) %= m;

            string in;
            cin >> in;
            if (a_cnt == 1)continue;
            if (in != ans) {
                alive[now] = false;
                a_cnt--;
            }
            (++now) %= m;
        }

        VI ret(m);
        int k = 0;
        FOR(i, 0, m)if (alive[i]) {
            ret[k++] = i + 1;
        }
        ret.resize(k);
        FOR(i, 0, k)cout << ret[i] << (i == k - 1 ? "\n" : " ");
    }
    
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX_N = 1e5+10;
int a[MAX_N];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) cin>>a[i];
    int ans = 0, flag = 0;
    for(int i = 1; a[i] != i; i = a[i]){
        ans++;
        if(a[i] == 2){
            flag = 1;
            break;
        }
        if(ans > n)break;
    }
    if(flag) cout<< ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	N := readInt()
	S := readString()

	dp := make([][]int, N+1)
	for i := 0; i < N + 1; i++ {
		dp[i] = make([]int, N+1)
	}

	for i := N - 1; i > -1; i-- {
		for j := N - 1; j > -1; j-- {
			if S[i] != S[j] {
				dp[i][j] = 0
			} else {
				dp[i][j] = dp[i+1][j+1] + 1
			}
		}
	}

	result := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			t := min(dp[i][j], j-i)
			result = max(result, t)
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 207872
#include <stdio.h>
#include <limits.h>

const int MAX = 5e5;
const int INF = INT_MAX;

void merge(int*, int, int, int);
void mergesort(int*, int, int);

int ans;

int main(){
  int n, i, a[MAX];

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

  mergesort(a, 0, n);

  for(i = 0 ; i < n ; i++){
    printf("%d%c" ,a[i], i != n-1 ? ' ':'\n');
  }
  printf("%d\n" ,ans);

  return 0;
}

void merge(int a[], int left, int mid, int right){
  int n1 = mid - left, n2 = right - mid;
  int L[n1+1], R[n2+1], i, j, k;

  for(i = 0 ; i < n1 ; i++){
    L[i] = a[left + i];
  }

  for(i = 0 ; i < n2 ; i++){
    R[i] = a[mid + i];
  }

  L[n1] = R[n2] = INF;

  for(i = 0, j = 0, k = left ; k < right ; k++, ans++){
    if(L[i] <= R[j]){
      a[k] = L[i++];
    }else{
      a[k] = R[j++];
    }
  }
}

void mergesort(int a[], int left, int right){
  int mid;

  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(a, left, mid);
    mergesort(a, mid, right);
    merge(a, left, mid, right);
  }
}




Measured memory_bytes: 5584
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll n, h;
    cin >> n >> h;
    vl a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    ll A = -1;
    rep(i, n) A = max(A, a[i]);
    vl s;
    rep(i, n) {
        if(b[i] > A) s.pb(b[i]);
    }
    sort(rall(s));
    REP(i, 1, s.size()) s[i] += s[i-1];
    auto calc = [&](ll m) {
        if(m == 0) return 0LL;
        if(m <= (ll)s.size()) return s[m-1];
        return (s.size() > 0 ? s.back() : 0) + (m - (ll)s.size())*A;
    };
    ll l = 0LL, r = 2e9;
    rep(i, 128) {
        ll m = (l + r) / 2;
        if(calc(m) >= h) r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  long int h[n];
  for(int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h, h + n);
  long int count = 0;
  for(int i = 0; i < n - k; i++) {
    count += h[i];
  }
  cout << count;
}

Measured memory_bytes: 1792
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = gete()

    print(s[:3])


if __name__ == "__main__":
    main()

Measured memory_bytes: 64720
package main

import (
	"fmt"
)

func main() {
	result := map[int]int{}

	result[read()] = 1
	result[read()] = 1
	result[read()] = 1

	if len(result) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func read() int {
	var v int
	fmt.Scan(&v)
	return v
}

Measured memory_bytes: 512
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int MIN(int a,int b){return a<b?a:b;}
int main(){
  char s[100010];
  int i,d[5]={};
  scanf("%s",s);
  for(i=0;s[i];i++)d[s[i]-'a']++;
  printf("%s\n",MAX(d[0],MAX(d[1],d[2]))-MIN(d[0],MIN(d[1],d[2]))>1?"NO":"YES");
  return 0;
}


Measured memory_bytes: 256
program c179

implicit none
integer :: n, a, z, c
real :: b

read *, n

z = 0

do a = 1, n
 b = real(n) / real(a)
 c = int(b)
 z = z + c
 if(a*c == n) then
  z = z - 1
 end if
end do

print *, z

end program c179

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var words = new HashSet<string>();
			string previousWord = null;
			var output = "Yes";
			for (int i = 0; i < n; i++)
			{
				var word = Console.ReadLine();
				if (!words.Add(word))
				{
					output = "No";
				}

				if (previousWord != null && previousWord.Last() != word.First())
				{
					output = "No";
				}
				previousWord = word;
			}
			Console.WriteLine(output);
			return;
		}
	}

}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n; cin >> h >> w >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    vector<vector<ll>> c(h,vector<ll>(w));
    ll cnt = 0;
    rep(i,n){
        rep(j,a[i]){
            ll ht = cnt/w;
            ll wt = cnt - ht*w;
            c[ht][wt] = i+1;
            cnt++;
        }
    }

    rep(i,h){
        if(i%2)reverse(all(c[i]));
    }

    print(c);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, m;
	cin >> n >> m;
	vector<vi> g(n);
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vi c(n, -1);
	c[0] = 0;
	queue<int> que;
	que.push(0);
	bool f = false;
	while (!que.empty())
	{
		int v = que.front();
		que.pop();
		for (auto u : g[v])
		{
			if (c[u] == -1)
			{
				c[u] = 1 - c[v];
				que.push(u);
			}
			else if (c[u] == 1 - c[v]) continue;
			else
			{
				f = true;
				break;
			}
		}
	}
	ll e;
	if (f) e = n * (n - 1) / 2;
	else
	{
		int a = 0;
		REP(i, n)
		{
			a += c[i];
		}
		e = a * (n - a);
	}
	cout << e - m << endl;
	return 0;
}

Measured memory_bytes: 6272
N=int(input())
b=list(map(int,input().split()))
c=len(b)
d=[]

for i in range(N):
  c = len(b)
  for j in range(c):
    if b[c-j-1]==c-j:
      d.append(b.pop(c-j-1))
      break
      
if b==[]:
  for num in d[::-1]:
    print(num)
else:
  print(-1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<limits.h>
#define NIL -1
static const int MAX = 500;
static const int INFTY = (1<<21);
int n, i, j, e, v, sum, u , minV;
main(){
 
  int M[MAX][MAX], key[MAX], L[MAX],A[MAX];
  
  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i = 0; i < n; i++){
    key[i] = INT_MAX;
    L[i] = NIL;
    A[i] = NIL;
  }
  
  key[0]=0;
  
  for(;;){
    
    u = NIL;
    
    minV = INT_MAX;
    
    for(i = 0;  i < n; i++){
      
      if(key[i] < minV && A[i] == NIL){
        
        u = i;
        
        minV = key[i];
        
      }
      
    }  
    if(u == NIL)break;
    
    A[u] = u; 
    
    for(v = 0; v < n; v++){
      if(M[u][v] < key[v] && A[v] == NIL){
        key[v] = M[u][v];
        L[v] = u;
      }
    }
  }
  
  sum = 0;
  
  for ( i = 0; i < n; i++ ){
    if ( L[i] != -1 ) sum +=M[L[i]][i];
  }
  
  printf("%d\n", sum);
  
  
  return 0;
}

Measured memory_bytes: 1232
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

def dfs (d,sum,s)
  if(d == 4 and sum == 7)
    puts s+"=7"
    exit
  elsif d==4
    return
  end
  dfs(d+1,sum+@t[d],s+"+#{@t[d]}")
  dfs(d+1,sum-@t[d],s+"-#{@t[d]}")
end
@t = gets.chomp.split("").map &:to_i
dfs(1,@t[0],"#{@t[0]}")


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

int main(){
    int N;
    cin>>N;
    int P[N],Q[N];
    rep(i,N)cin>>P[i];
    rep(i,N)cin>>Q[i];
    int A[N];
    rep(i,N)A[i]=i+1;
    int p=0,q=0;
    int j=0;
    int a=0,b=0;
    do{
        rep(i,N){
            if(A[i]==P[i])p++;
            if(A[i]==Q[i])q++;
        }
        if(p==N)a=j;
        if(q==N)b=j;
        j++;
        p=0;
        q=0;
    }while(next_permutation(A,A+N));
    cout << abs(a-b) <<endl;
    return 0;
}

Measured memory_bytes: 3576
S = input().strip()
L = []
R = []
Q = int(input())
flag = 0
for _ in range(Q):
    q = list(input().split())
    if len(q)==1:
        flag = 1-flag
    else:
        F = q[1]
        C = q[2]
        if flag==0 and F=="1":
            L.append(C)
        elif flag==0 and F=="2":
            R.append(C)
        elif flag==1 and F=="1":
            R.append(C)
        elif flag==1 and F=="2":
            L.append(C)
L = "".join(L)
R = "".join(R)
if flag==1:
    S = S[::-1]
    R = R[::-1]
    S = R+S+L
else:
    L = L[::-1]
    S = L+S+R
print(S)

Measured memory_bytes: 91540
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
sumA = [0]
for i in range(N):
	sumA.append(sumA[-1] + A[i])

import bisect
def num_shakes(border):
	ret = 0
	for i in range(N):
		if A[i] + A[-1] < border:
			continue
		rest = border - A[i]
		j = bisect.bisect_left(A, rest)
		ret += N - j
	return ret
l,r = A[0]*2, A[-1]*2 + 1 
while r - l > 1:
	p = (l + r)//2
	if num_shakes(p) >= M:
		l = p
	else:
		r = p
m = num_shakes(r)
ans = l * (M-m)
for i in range(N):
	if A[i] + A[-1] < r:
		continue
	rest = r - A[i]
	j = bisect.bisect_left(A, rest)
	ans += A[i] * (N - j) + (sumA[-1] - sumA[j])
print(ans)

Measured memory_bytes: 14268
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    long long int x,y,num,ans,n;
    cin >> n;
    while(n--){
        cin >> x >> y;
        num = sqrt(x*y);
        if( sqrt(x*y)==num ){
            num*=2;
            if(x==y)    num++;
            cout << num-3 << endl;
        }
        else{
            ans = num;
            ans*=2;
            if(num*(num+1) < x*y)   ans++;
            cout << ans-2 << endl;
        }
    }
}

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

using i64 = int64_t;

constexpr i64 M = 12721;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> a[i][j];
        }
    }
    vector<vector<int>> b(h, vector<int>(w));
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> b[i][j];
        }
    }

    vector<vector<deque<bool>>> dp(h, vector<deque<bool>>(w, deque<bool>(M)));
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            for(int k=0;k<=M;++k){
                if(!dp[i][j][k])continue;
                if(j+1 < w){
                    dp[i][j+1][abs(k+abs(a[i][j+1]-b[i][j+1]))] = true;
                    dp[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))] = true;
                }
                if(i+1 < h){
                    dp[i+1][j][abs(k+abs(a[i+1][j]-b[i+1][j]))] = true;
                    dp[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))] = true;
                }
            }
        }
    }

    int ans = M;
    for(int k=0;k<=M;++k){
        if(dp[h-1][w-1][k]){
            ans = k;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 85760
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    if a[i] < b[i]:
        ans += a[i]
        b[i] = b[i] - a[i]
        a[i] = 0
        if a[i+1] < b[i]:
            ans += a[i+1]
            b[i] = b[i] - a[i+1]
            a[i+1] = 0
        else:
            ans += b[i]
            a[i+1] = a[i+1] - b[i]
    else:
        ans += b[i]
        a[i] = a[i] - b[i]

print(ans)

Measured memory_bytes: 82020
def main():
  
  n=int(input())
  num=[int(i) for i in input().split()]
  c1,c2,c3=0,0,0
  
  for i in range(n):
    if num[i]==1:
      c1+=1
    elif num[i]==2:
      c2+=1
    else:
      c3+=1
  a=c1+c2+c3+1
  b=c2+c3+1
  c=c3+1
  
  dp=[[[0]*a for _ in range(b)] for _ in  range(c)]
  
  for i in range(c):
    for j in range(b-i):
      for k in range(a-i-j):
        tmp=i+j+k
        if tmp==0:
          continue
        else:
          dp[i][j][k]=n/tmp
          if i>0:
            dp[i][j][k]+=i*dp[i-1][j+1][k]/tmp
          if j>0:
            dp[i][j][k]+=j*dp[i][j-1][k+1]/tmp
          if k>0:
            dp[i][j][k]+=k*dp[i][j][k-1]/tmp
  print(dp[c3][c2][c1])
             
if __name__=='__main__':
  main()

Measured memory_bytes: 491912
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << "\n"; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cins(string, 3, s);
    For(i, 3) Reverse(s[i]);
    int i = 0;
    while(!s[i].empty()){
        int j = s[i].back() - 'a';
        s[i].pop_back();
        i = j;
    }
    Cout(string{(char)('A' + i)});
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
 
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
 
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main(void){
    int N,M,C;
    cin>>N>>M>>C;
    vector<ll> B(M);
    for (int i=0;i<M;i++) cin>>B[i];
    vector<vector<ll>> A(N,vector<ll>(M));
    ll ans = 0;
    for (int i=0;i<N;i++) {
        for (int j=0;j<M;j++) {
            cin>>A[i][j];
        }
        ll ss = C;
        for (int j=0;j<M;j++) {
            ss += A[i][j] * B[j];
        }
        if (ss>0) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    double a,b;
    int64_t n;
    cin>>a>>b>>n;
    int64_t x;
    if(n>=b){
        x = b-1;
    }
    else{
        x = n;
    }
    int64_t ans = floor(a*x/b) - a*floor(x/b);
    cout<<ans<<endl; 

}

Measured memory_bytes: 3720
#include<cstdio>
#include<algorithm>
#include<climits>
using namespace std;
#define N 100000
#define INF INT_MAX
int n,l[N],dp[N],r=0;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&l[i]),dp[i]=INF;
	for(int i=0;i<n;i++)
		*lower_bound(dp,dp+n,l[i])=l[i];
	printf("%d\n",lower_bound(dp,dp+n,INF)-dp);
	return 0;
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) {
        cout << "No";
    } else {
        string s1 = s.substr(0, n / 2);
        string s2 = s.substr(n / 2, n / 2);
        if (s1 == s2) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double


int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;

    LD sa = 0.5*(h*60 + m) - 6*m;

    LD kaku = abs(min(sa,360 - sa));
    LD ans = pow(a,2) + pow(b,2) - 2*a*b*cos(sa * M_PI / 180.0);
    cout << fixed << setprecision(16) << sqrt(ans) << endl;
    return 0;
}

Measured memory_bytes: 4160
N, Q = map(int, input().split())
S = input()

ac_cnt = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        ac_cnt[i] = ac_cnt[i-1] + 1
    else:
        ac_cnt[i] = ac_cnt[i-1]

for _ in range(Q):
    l, r = map(int, input().split())
    ans = ac_cnt[r-1] - ac_cnt[l-1]
    print(ans)

Measured memory_bytes: 77348
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    ll p;
    cin >> n >> p;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    ll i = 2;
    ans = 1;
    while(p > 1){
        cnt = 0;
        while(p % i == 0){
            p /= i;
            cnt++;
            if(cnt >= n){
                ans *= i;
                cnt = 0;
            }
        }
        i++;
        if(i > sqrt(p)){
            break;
        }
    }
    cout << ans << endl;
}


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

#include <iostream>

#include <string>
#include <vector>
#include <algorithm>

#define rep(index,num) for(int index=0;index<num;++index)

using namespace std;

double W,H;
double x,y;

int main(){
  std::cin >> W >> H >> x >> y;
  if(x >= 0.5*W) x = W - x;
  if(y >= 0.5*H) y = H - y;

  printf("%.6lf ",0.5*W*H);
  if(x == 0.5*W && y == 0.5*H) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B;
  cin>>A>>B;
  if(A+B>=10)
    cout<<"error";
  else
    cout<<A+B;
  }


Measured memory_bytes: 384
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]

inf=10**6
    
def dfs(cur,a,b,c):
    if cur==N:
        if min(a,b,c)>0:
            return abs(A-a)+abs(B-b)+abs(C-c)-30
        else:
            return inf
    else:
        ret0=dfs(cur+1,a,b,c)
        ret1=dfs(cur+1,a+l[cur],b,c)+10
        ret2=dfs(cur+1,a,b+l[cur],c)+10
        ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> v(N);
    rep(i,N){
        cin >> v[i];
    }
    vector<vector<ll>> dp(N+1,vector<ll>(N+1));
    rep(i,N){
        rep(j,N){
            cmax(dp[i+1][j+1], dp[i][j+1]);
            cmax(dp[i+1][j+1], dp[i][j] + v[i]);
        }
    }
    ld Mave = 0;
    ll rec_i = -1;
    REP(i,A,B+1){
        if(Mave < ld(dp[N][i])/ld(i)){
            rec_i = i;
            Mave = ld(dp[N][i])/ld(i);
        }
    }
    cout << setprecision(30) << Mave << endl;
    sort(v.rbegin(), v.rend());
    ll sum = 0;
    ll c = v[A-1];
    ll chose = 0;
    rep(i,A){
        if(c == v[i]){
            chose++;
        }
    }
    ll cand = 0;
    REP(i,0,N){
        if(c == v[i]){
            cand++;
        }
    }
    ll ans = 0;
    if(c == v[0]){
        ans = 0;
        ll tmp = 1;
        rep(i, A){
            tmp *= (cand-i);
            tmp /= (i+1);
        }
        REP(i, A, B+1){
            ans += tmp;
            tmp *= (cand-i);
            tmp /= (i+1);
        }
        cout << ans << endl;
        return 0;
    }
    ll tmp = 1;
    rep(i,chose){
        tmp *= (cand-i);
        tmp /= (i+1);
    }
    ans = tmp;
    cout << ans << endl;
}

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

// int main() {
// 	// your code goes here
// 	int r;
// 	cin>>r;
// 	for(int i=0;i<r;++i)
// 	{
// 	    int temp=1;
// 	    for(int j=1;j<r-i;++j)
// 	    cout<<" ";
// 	    for(int k=0;k<=i;++k)
// 	    {
// 	        cout<<"  "<<temp;
// 	        temp=temp*(i-k)/(k+1);
// 	    }
// 	    cout<<endl<<endl;
// 	}
// 	cout<<endl;
// 	return 0;
// }

int main()
{
    int n;
    long long x;
    vector<long long>vec(n);
    cin>>n>>x;
    for(int i=0;i<n;++i)
    {
        long long a;
        cin>>a;
        vec.push_back(a);
    }
    sort(vec.begin(),vec.end());
    long long ans=0,chca=x;
    for(int i=0;i<n;++i)
    {
        chca-=vec.at(i);
        if(chca>=0)
        ans++;
        else
        break;
    }
    if(chca>0)
    cout<<ans-1;
    else
    cout<<ans;
    return 0;
}

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

const int N=20000010,mod=998244353;
int n,A,B,jc[N],inv[N],ans;

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int C(int a,int b)
{
	if (a<b||b<0) return 0;
	return 1ll*jc[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
	jc[0]=1;
	for (int i=1; i<N; i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[N-1]=quickmi(jc[N-1],mod-2);
	for (int i=N-1; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	scanf("%d%d%d",&n,&A,&B),ans=0;
	if (A==0&&B==0) return puts("1"),0;
	for (int i=0; i<=A&&i+B<n; i++)
		ans=(ans+1ll*(C(B+i-1,i)-C(B+i-1,i-1)+mod)*C(A-i+n-B-i-1,A-i))%mod;
	if (A+B==n) ans=(ans+1ll*(C(B+A-1,A)-C(B+A-1,A-1)+mod))%mod;
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 156544
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int sum=0;
	int ma = -1000;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		sum+=a;
		ma = max(ma,a);
	}
	sum-=ma;
	if(sum>ma)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
 } 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <functional>
using namespace std;

int main() {
  int A,B;
  cin >> A >> B;
  cout << max(max(A,B)+max(A,B)-1,max(A,B)+min(A,B)) << endl;
}


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 max = 0;
		for(int i=0;i<N;i++){
			int tmp = sc.nextInt();
			if(max < tmp)max=tmp;
			else if(max-2>=tmp){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
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 trace(...)
#endif

int32_t main()
{
    fast;
    int n ; cin >> n ; 
    int four = 0 , two = 0 , odd = 0 ; 
    rep(i,1,n) {
        int x ; cin >> x ; 
        if(x % 4 == 0) {
            four += 1 ; 
        }
        else if(x % 2 == 0) {
            two += 1 ; 
        }
        else odd += 1 ; 
    }
    if(two == 0 && odd <= four + 1) {
        cout << "Yes\n" ; return 0 ; 
    }
    if(odd > four) {
        cout << "No\n" ; 
        return 0 ; 
    }
    if(two == 1 && four == 0) {
        cout << "No\n" ; return 0 ; 
    }
    cout << "Yes\n" ; 
    return 0;
}


Measured memory_bytes: 256
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    h = list(reversed(Input()))
    val = 0
    ans = 0
    for i in range(1, n):
        if h[i-1] <= h[i]: val += 1
        else: val = 0
        ans = max(ans, val)
        
    print(ans)
main()

Measured memory_bytes: 20704
#include<iostream>
using namespace std;
int max(int *p,int N){
  int top=1;
  for(int i=2;i<=N;i++){
    if(p[top]<p[i]) top = i;
  }
  return top;
}
int main(){
  int N,R,L,d,t,x,old=1,oldt=0;
  cin >> N >> R >> L;
  int pt[N+1],ptime[N+1];
  for(int i=0;i<=N;i++) pt[i]=ptime[i]=0;
  for(int i=0;i<R;i++){
    cin >> d >> t >> x;
    ptime[old] += t-oldt;
    oldt = t;
    pt[d] += x;
    if(x>=0){
      if(pt[old]<pt[d]) old = d;
      if(pt[old]==pt[d]&&old>d) old = d; 
    }else if(old==d) old = max(pt,N);
  }
  ptime[old] += L- oldt;
  cout << max(ptime,N) << endl;
  return 0;
}

Measured memory_bytes: 1940
#include<stdio.h>
#include<string.h>
int main(void)
{
  int i,a,n;
  char s[100];

   scanf("%s",s);
   n=strlen(s);
   for (i=1;i<n-2;i++);
      a=i+1-1;
   printf("%c%d%c\n",s[0],a,s[n-1]);
   return 0;
}



Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int[] a = new int[h];
        for (int i = 0; i < h; i++) {
            a[i] = sc.nextInt();
        }

        buildMaxHeap(a);

        StringBuilder sb = new StringBuilder("");
        for (int i = 0; i < h; i++) {
            sb.append(' ').append(a[i]);
        }
        System.out.println(sb);
    }

    public static void buildMaxHeap(int[] a) {
        int h = a.length;
        for (int i = h / 2; i >= 0; i--) {
            maxHeapify(a, i);
        }
    }

    public static void maxHeapify(int[] a, int i) {
        int h = a.length;

        int left = i * 2 + 1;
        int right = left + 1;

        int largest;

        if (left < h && a[left] > a[i]) {
            largest = left;
        } else {
            largest = i;
        }

        if (right < h && a[right] > a[largest]) {
            largest = right;
        }

        if (largest != i) {
            int temp = a[i];
            a[i] = a[largest];
            a[largest] = temp;
            maxHeapify(a, largest);
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }

    int sum = 0;
    int ans = 0;
    for (auto u: mp){
        sum += u.second-1;
        ans++;
    }

    if(sum%2!=0){
        ans--;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

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

    int cnt = 0;
    bool begin = false;
    bool ok = false;

    for (size_t i=0; i<N; i++) {
        int D1, D2;
        cin >> D1 >> D2;
        if (D1 == D2) {
            if(!begin) {
                begin = true;
            }
            ++cnt;
            if (cnt >= 3) {
                ok = true;
                break;
            }
        }
        else {
            begin = false;
            cnt = 0;
        }
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3676
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

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

bool isEven(string s) {
	int n = s.size();
	if (n % 2 == 1) return false;
	else {
		string t = "";
		rep(i, n / 2) t += s[i];
		string u = "";
		rep(i, n / 2) u += s[i + n / 2];
		if (t == u) return true;
		else return false;
	}
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	for (int i = 1; i < n; i++) { //末尾からi文字消す
		string now = "";
		rep(j, n - i) now += s[j];
		if (isEven(now)) {
			ans = n - i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    int n=a/k;
    if(a%k==0 || (n+1)*k<=b) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

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

    for(int i = l; i < l + min(2019, distance); i++){
        for(int j = max(i + 1, int(r - 2019)); j < r+1; j++){
            ans = min(ans, int((long(i)*long(j)) % 2019));
            if(ans == 0)
                break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second 
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 65;
const double EPS = 1e-8;
#define double long double

struct Point {
	double x, y;
	Point operator - (Point p) const {
		return {x - p.x, y - p.y};
	}
	double dist(Point p) const {
		double dx = x - p.x, dy = y - p.y;
		return sqrt(dx * dx + dy * dy);
	}
};

struct Line {
	double a, b, c;
};

struct Circle {
	Point c;
	double r;
	int contain(Point p) {
		return c.dist(p) <= r + EPS;
	}
};

// Circle-line intersection, line:ax+by+c=0
vector<Point> CL_intersection(Circle cir, Line li) {
	// li.pton(); // To Ax+By+C=0
	Point o = cir.c;
	li.c += li.a*o.x + li.b*o.y; // Shift w.r.t. cir.c
	
	vector<Point> res;
	double r = cir.r, a = li.a, b = li.b, c = li.c;
	double x0 = -a*c/(a*a+b*b), y0 = -b*c/(a*a+b*b);
	if (c*c > r*r*(a*a+b*b)+EPS) {
		return res; // No point
	}
	else if (abs(c*c - r*r*(a*a+b*b)) < EPS) {
		res.push_back({x0 + o.x, y0 + o.y}); // 1 point
	}
	else {
	    double d = r*r - c*c/(a*a+b*b);
	    double mult = sqrt (d / (a*a+b*b));
	    double ax, ay, bx, by;
	    ax = x0 + b * mult;
	    bx = x0 - b * mult;
	    ay = y0 - a * mult;
	    by = y0 + a * mult;
	    res.push_back({ax + o.x, ay + o.y}); // 2 points
	    res.push_back({bx + o.x, by + o.y});
	}
	return res;
}

// Circle-circle intersection
vector<Point> CC_intersection(Circle a, Circle b) {
	if (a.c.x == b.c.x && a.c.y == b.c.y && a.r == b.r) {
		return vector<Point>(); // coincide, inf points
	}
	Point o = a.c;
	b.c = b.c - o; // Shift
	a.c = {0.0, 0.0};
	
	double x2 = b.c.x, y2 = b.c.y, r1 = a.r, r2 = b.r;
	Line li = {-2*x2, -2*y2, x2*x2 + y2*y2 + r1*r1 - r2*r2}; // Ax+By+C = 0
	vector<Point> res = CL_intersection(a, li);
	for (Point &p : res) {
		p.x += o.x;
		p.y += o.y;
	}
	
	return res;
}

int n, k, c[MAXN];
Point ps[MAXN];
Circle cir[MAXN];

int check(double ti) {
	vector<Point> test;
	for (int i = 0; i < n; i++) {
		double r = ti / c[i];
		cir[i] = {ps[i], r};
		test.push_back((Point){ps[i].x - r, ps[i].y});
		for (int j = 0; j < n; j++) {
			vector<Point> all = CC_intersection(cir[i], cir[j]);
			for (Point p : all) {
				test.push_back(p);
			}
		}
	}
	
	int mx = 0;
	for (Point p : test) {
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += cir[i].contain(p);
		}
		mx = max(mx, cnt);
	}
	
	return mx >= k;
}

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

	cin >> n >> k;
	double l = 0.0, r = 0.0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y >> c[i];
		ps[i] = {(double) x, (double) y};
		r += ps[i].dist({0.0, 0.0}) * c[i];
	}
	
	double ans = r;
	for (int round = 0; round < 100; round++) {
		double m = (l + r) / 2.0;
		if (check(m)) {
			ans = m;
			r = m;
		}
		else {
			l = m;
		}
	}
	
	cout << fixed << setprecision(20) << ans << '\n';

	return 0;
}

Measured memory_bytes: 568
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
#define mod 998244353
using namespace std;



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

    int n;
    cin>>n;
    int arr[n],ans[n];
    int x=0,all;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(i!=0)x = x^arr[i];
    }
    ans[0] = x;
    all = x^arr[0];
    for(int i=1;i<n;i++){
        ans[i] = all^arr[i];
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }

}

Measured memory_bytes: 4656
s = input()
K = int(input())

S = list(s)
answer = []

for i in range(len(S)):
    if S[i] == '1':
        answer.append(S[i])
    else:
        answer.append(S[i])
        break

if K <= len(answer):
    print(answer[K-1])
else:
    print(answer[-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	map<pair<int, int>, LL> mp;
	LL eq = 0;
	inc(i, n) {
		IN(string, s);
		reverse(ALL(s));
		int d = 0;
		inc(i, SI(s)) { if(s[i] == '.') { d = i; } }
		reverse(ALL(s));
		{
			string t;
			RF(c, s) { if(c != '.') { t += c; } }
			s = t;
		}
		LL a = stoll(s);
		assert(a > 0);
		int c2 = -d, c5 = -d;
		while(a % 2 == 0) { a /= 2; c2++; }
		while(a % 5 == 0) { a /= 5; c5++; }
		mp[{ c2, c5 }]++;
		if(c2 >= 0 && c5 >= 0) { eq++; }
	}
	
	LL ans = 0;
	RF(x, mp) {
	RF(y, mp) {
		auto [a, b] = x.FI;
		auto [A, B] = y.FI;
		if(a + A >= 0 && b + B >= 0) { ans += x.SE * y.SE; }
	}
	}
	OUT((ans - eq) / 2);
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
int main() {
	int m, next_angle;
	double x = 0.0, y = 0.0;
	double prev_angle = M_PI_2;
	while (1) {
		scanf(" %d,%d", &m, &next_angle);
		if (m == 0 && next_angle == 0)
			break;
		x -= m * cos(prev_angle);
		y += m * sin(prev_angle);
		prev_angle += (double)next_angle * M_PI / 180;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

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

int main(){
    string S, T;
    cin >> S >> T;

    if(S.size() == T.size()){
        cout << "No" << endl;
    }
    else if(S == T.erase(S.size(), 1)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3576
sx,sy,tx,ty=map(int,raw_input().split())
dx=tx-ty;dy=ty-sy
ans=[]
for i in xrange(sx,tx):
    ans.append("R")
for i in xrange(sy,ty):
    ans.append("U")
for i in xrange(sx,tx):
    ans.append("L")
for i in xrange(sy,ty):
    ans.append("D")
ans.append("D")
for i in xrange(sx,tx+1):
    ans.append("R")
for i in xrange(sy,ty+1):
    ans.append("U")
ans.append("L")
ans.append("U")
for i in xrange(sx,tx+1):
    ans.append("L")
for i in xrange(sy,ty+1):
    ans.append("D")
ans.append("R")
print("".join(ans))

Measured memory_bytes: 12400
#include <stdio.h>
int main(){
  int N,M,X,Y;
  scanf("%d",&N);
  scanf("%d",&M);
  scanf("%d",&X);
  scanf("%d",&Y);
  int x[N],y[M];
  int xMax=-1000,yMin=1000;
  for(int i=0;i<N;i++){
    scanf("%d",&x[i]);
    if(x[i]>xMax)xMax=x[i];
  }
  for(int i=0;i<M;i++){
    scanf("%d",&y[i]);
    if(y[i]<yMin)yMin=y[i];
  }
  if((X-Y)<0){
    for(int i=X+1;i<=Y;i++){
      if(xMax<i&&yMin>=i){
        printf("No War\n");
        return 0;
      }
    }
  }
  printf("War\n");
  return 0;
}


Measured memory_bytes: 256