akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define int ll
using namespace std;

const ll N = 1e5+1;
const ll MOD = 1e9+7;
const ll INF = 1e17;
ll dp[N];
int unboundedKnapsack(int W, int n, int val[], int wt[]) 
{ 
    // dp[i] is going to store maximum value 
    // with knapsack capacity i. 
    for(int i =0;i<=N;i++)dp[i]=INF; 
  	

    //int ans = 0; 
  	dp[0]=0;
    // Fill dp[] using above recursive formula 
    for (int i=0; i<=100000; i++) 
      for (int j=1; j<=n; j++) 
         if (wt[j] <= i) 
            dp[i] = min(dp[i], dp[i-wt[j]]+val[j]); 
  	ll ans = INF;
  	for(int i = W;i<=100000;i++)ans=min(ans,dp[i]);
  	return ans;
} 
signed main()
{
	ll h;
	cin>>h;
	ll n;
	cin>>n;
	ll a[n+1],b[n+1];
	for(int i =1;i<=n;i++)cin>>a[i]>>b[i];
	cout<<unboundedKnapsack(h,n,b,a)<<endl;
	//return 0;
	
}

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

int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if (x - r < 0 || y - r < 0 || x + r > W || y + r > H) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3080
//104 B - AcCepted 2018/08/05
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    string s; cin >> s;
    if (s[0]!='A') { cout << "WA" << endl; return 0; }
    int counter_c=0;
    for(int i=2 ; i<s.size()-1 ;++i){
        if(s[i]=='C') ++counter_c;
    }
    if (counter_c!=1) { cout << "WA" << endl; return 0; }
    sort(s.begin(),s.end());
    for(int i=2;i<s.size();++i){
        if(s[i]<'a' || s[i]>'z') { cout << "WA" << endl; return 0;}
    }
    cout << "AC" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num=0;
        int[] x=new int[101];
        int N = sc.nextInt();
        int T = sc.nextInt();
        int E = sc.nextInt();
        for(int i=1; i<=N; i++) {
        	x[i]=sc.nextInt();
        }
        for(int i=-E; i<=E; i++) {
        	for(int j=1; j<=N; j++) {
        		for(int k=1; k<1000; k++)
        		if(x[j]*k==T+i) num=j;
        	}
        }
        if(num == 0)	System.out.println("-1");
        else        System.out.println(num);
        
    }
}



Measured memory_bytes: 26804
// In God We Trust


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

# define INF 1 << 31 - 1

signed main(){
  string s;
  cin >> s;
  if (s == "SUN")
    cout << 7;
  if (s == "MON")
    cout << 6;
  if (s == "TUE")
    cout << 5;
  if (s == "WED")
    cout << 4;
  if (s == "THU")
    cout << 3;
  if (s == "FRI")
    cout << 2;
  if (s == "SAT")
    cout << 1;
  
}


Measured memory_bytes: 256
list = list(map(int, input().split()))
A = list[0]
B = list[1]
C = list[2]
D = list[3]

while A > 0 and B >0:
    C = C - B
    if C <= 0:break
    A = A - D

if A > 0: print("Yes")
else: print("No")

  

Measured memory_bytes: 9116
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	long long n, arr[100001][4], dp[100001][4];
	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> arr[i + 1][1] >> arr[i + 1][2] >> arr[i + 1][3];
	for (int i = -1; i < n; i++)
		for (int k = 0; k < 3; k++)
			dp[i + 1][k + 1] = 0;
	for (int i = 1; i <= n ; i++)
		for (int k = 1; k <= 3; k++)
			for (int z = 1; z <= 3; z++) {
				if (z == k) continue;
				dp[i][z] = max(dp[i][z], dp[i - 1][k] + arr[i][z]);
			}
	long long ans = 0;
	for (int i = 1; i <= 3; i++)
		ans = max(ans, dp[n][i]);
	cout << ans;
//	system("pause");
	return 0;
}

Measured memory_bytes: 6528
mod = 10**9+7
mod2 = mod * 5

n, m = gets.to_s.split
n, m = n.to_i, m.to_i

A = $<.map &:to_i

if A.each_cons(2).any?{|a, b| b - a == 1 }
  p 0
  exit
end

stairs = [1] * (n+1)

A.each do |a|
  stairs[a] = 0
end

2.upto(n) do |i|
  next if stairs[i] == 0
  stairs[i] = stairs[i-1] + stairs[i-2]
  stairs[i] %= mod if stairs[i] > mod2
end

puts stairs[-1] % mod

Measured memory_bytes: 3836
import sys
def input():
    return sys.stdin.readline()[:-1]
N,K,L=map(int,input().split())
sys.setrecursionlimit(300000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         #root
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       #merge
        ra=self.ro(a-1)
        rb=self.ro(b-1)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       #same
        return self.ro(a)==self.ro(b)
    def rl(self):           #roots list
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          #len(roots)
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
up=uf(N)
for i in range(K):
    up.me(*map(int,input().split()))
ur=uf(N)
for i in range(L):
    ur.me(*map(int,input().split()))
l=[0]*N
from collections import defaultdict
for i in up.ul():
    d = defaultdict(int)
    for j in i:
        d[ur.ro(j)]+=1
    for j in i:
        l[j]=d[ur.ro(j)]
print(*l)

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

public class Main {
	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.next());
      	int x = Integer.parseInt(sc.next());
      	int cnt = 0;
      	int[] a = new int[n];
      	for (int i = 0; i < n; i++) {
          a[i] = Integer.parseInt(sc.next());
        }
      	Arrays.sort(a);
      	for (int i = 0; i < n; i++) {
          	if (i == n - 1) {
              if (x == a[i]) {
              	cnt++;
              }
            } else {
              if (x >= a[i]) {
            	x -= a[i];
              	cnt++;
              }
            }
        }
      	System.out.println(cnt);
    }
}


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

int main()
{
    ios::sync_with_stdio(false);
    ll x;cin>>x;
    ll a=100;
    ll n=0;
    while(a<x)
    {
        a*=1.01;
        n++;
        //cout<<a<<endl;
    }
    cout<<n<<endl;
}


Measured memory_bytes: 3652
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int a, b; cin >> a >> b;
	if(a <= b){
		cout << a << endl;
	}
	else{
		cout << a-1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3616
import sys

scan = sys.stdin.readline
n, m = map(int, scan().split(' '))
ans = [0] * n
ac = 0
for i in range(m):
    q, r = map(str, scan().strip('\n').split(' '))
    if r == 'AC':
        if ans[int(q) - 1] >= 0:
            ans[int(q) - 1] = -ans[int(q) - 1] - 1
            ac += 1
    else:
        if ans[int(q) - 1] >= 0:
            ans[int(q) - 1] += 1

wa = -sum(filter(lambda x: x < 0, ans)) - ac
print(ac, wa, sep=' ')

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<P> prime_factorize(ll n){
    vector<P> res;

    for(ll a=2; a*a<=n; ++a){
        if(n%a != 0) continue;
        ll ex = 0; // 指数

        while(n%a==0){
            ++ex;
            n /= a;
        }

        // vectorにpairをpush_back()する時、make_pair()にしないと怒られる
        res.push_back(P(a, ex));
    }

    // 最後にnが残った時
    if(n != 1) res.push_back(P(n,1));
    return res;
}


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

    vector<P> v;
    v = prime_factorize(n);

    ll ans = 0;
    for(auto &x : v ){
        int b = 1;
        x.second -= b;
        ans++;
        while( (x.second-(b+1)) >= 0 ){
            b++;
            x.second -= b;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
void solve() {
  char c;
  cin >> c;
  c++;
  cout << c << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int h,w;cin>>h>>w;
    VS s(h);
    REP(i,h){
        cin>>s[i];
    }

    VI dx = {-1, 0, 1,-1, 1,-1, 0, 1};
    VI dy = {-1,-1,-1, 0, 0, 1, 1, 1};
    
    REP(i,h){
        REP(j,w){
            if(s[i][j] != '.'){
                continue;
            }
            int num=0;
            REP(k,8){
                int x = i+dx[k];
                int y = j+dy[k];
                if(x<0 || y<0 || x>=h || y>=w){
                    continue;
                }
                if(s[x][y] == '#'){
                    num++;
                }
            }
            s[i][j] = num+'0';
        }
    }
    REP(i,h){
        cout<<s[i]<<endl;
    }
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

#define ll long long
#define mod 1000000007
#define IO_fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
    IO_fast
    long n;
    cin >> n;
    string str;
    cin >> str;
    long redcount = 0, answer = 0;
    for(int i = 0 ; i<str.size() ; i++){
        if(str[i]=='R') redcount++;
    }
    for(int i = 0 ; i<redcount ; i++){
        if(str[i]=='W') answer++;
    }
    cout << answer << endl;
}

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

int main(){
    int n, m, cnt = 0;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c;
            cin >> c;
            if(c == '#') cnt++;
        }
    }
    if(cnt == (n + m - 1)) cout << "Possible";
    else cout << "Impossible";
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main{
	
	void solve() {
		int P = nextInt();
		int Q = nextInt();
		int R = nextInt();
		out.println(Math.min(Math.min(P + Q, Q + R), P + R));
	}
	
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 1e5 + 7;

int fl = 0;
int used[N];
int c[N];
vector<int> g[N];

void dfs(int cur, int cl) {
	used[cur] = 1;
	c[cur] = cl;
	for (auto t : g[cur]) {
		if (!used[t]) {
			dfs(t, cl ^ 1);
		} else if (c[cur] == c[t]) {
			fl = 1;
		}
	}
}

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

	int n, m;
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int cnt_all = 0;
	int cnt_c = 0;
	int cnt_1 = 0;
	for (int i = 0; i < n; i++) {
		if (g[i].empty()) {
			cnt_1++;
		} else if (!used[i]){
			fl = 0;
			dfs(i, 0);
			if (!fl) cnt_c++;
			cnt_all++;
		}
	}
	cout << (cnt_all) * (cnt_all) + (cnt_c) * (cnt_c) + 2 * cnt_1 * (n - cnt_1) + cnt_1 * cnt_1 << endl;
}

Measured memory_bytes: 13184
#!/usr/bin/env python3
#CODEFESTIVAL2017 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
que = deque(s)
ans = 0
while que:
    l,r = que[0],que[-1]
    if l == r:
        if len(que) == 1:
            break
        que.popleft()
        que.pop()
        continue
    if l == 'x':
        que.append('x')
        ans += 1
        continue
    if r == 'x':
        que.appendleft('x')
        ans += 1
        continue
    print(-1)
    quit()
print(ans)


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

#define int long long

int32_t main() {
	int n , x ; cin >> n >> x ;
	int l[n] ;
	for(int i = 0 ; i < n ; i++) cin >> l[i] ;
	int d = 0 , count = 0 ;
	while(d <= x && count <= n){
		d += l[count++];
	}
	cout << count << endl ;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>

using namespace std;

int main() {
	int a,d,n;

	//ifstream fin("in.txt");

	//fin >> a >> d >> n;
	cin >> a >> d >> n;

	int prime[100000];
	int ite = 4;
	prime[0] = 2;
	prime[1] = 3;
	prime[2] = 5;
	prime[3] = 7;

	int i,j;
	for(i = 11; i < 1000000; i++) {
		if(i%2==0 || i%3==0 || i%5== 0 || i%7 == 0) goto NOT_PRIME;
		for(j = 0; j < ite; j++) {
			if(i%prime[j]==0) {
				goto NOT_PRIME;
			}
			if(prime[j]*prime[j] > i) break;
		}

		prime[ite] = i;
		ite++;

		NOT_PRIME:
		;
	}

	while(!(a==0&&d==0&&n==0)) {
		int count = 0;
		int primeCount = 0;
		while(1) {
			int arrNumber = a+count*d;
/*
			for(i = 0; i < ite; i++) {
				if(prime[i] == arrNumber) {
					primeCount++;
					break;
				}
			}
*/

			int max = ite;
			int min = 0;
			while(1) {
				if(max-min<=1) {
					if(prime[max]==arrNumber || prime[min]==arrNumber) {
						primeCount++;
					}
					break;
				}
				int half = (max+min)/2;
				if(arrNumber<prime[half]) max = half;
				else if(arrNumber>prime[half]) min = half;
				else {
					primeCount++;
					break;
				}
			}

			if(primeCount >= n) {
				cout << arrNumber << endl;
				break;
			}
			count++;
		}

		//fin >> a >> d >> n;
		cin >> a >> d >> n;
	}
	return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int ans = n;
    bool have[n];
    for(int i=0;i<n;i++){
        have[i] = false;
    }
    for(int i=0;i<k;i++){
        int d;
        cin >> d;
        for(int j=0;j<d;j++){
            int a;
            cin >> a;
            a--;
            have[a] = true;
        }
    }
    for(int i=0;i<n;i++){
        if(have[i]){
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(void){

    int n, d, count = 0;

    cin >> n >> d;

    while(1){
        if(n > 0){
            n -= 2 * d + 1;
            count++;
        }else{
            break;
        }
    }

    cout << count << endl;


    return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
#define next asdnext
#define prev asdprev
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, W;
string s[330];
int match[330][330], dp[330][330];
int dfs(int h0, int h1, int x0, int x1) {
    if (h0 == 0 || h1 == 0) { return 0; }
    if (dp[h0][h1] != -1) { return dp[h0][h1]; }
    dp[h0][h1] = min(dfs(h0 - 1, h1, x0, x1), dfs(h0, h1 - 1, x0, x1));
    match[h0][h1] = match[h0 - 1][h1 - 1] + (s[h0 - 1][x0] == s[h1 - 1][x1]);
    dp[h0][h1] += match[h0][h1];
    return dp[h0][h1];
}
signed main() {
    cin >> H >> W;
    rep(i, H) { cin >> s[i]; }
    int ans = 0;
    for (int i = 0; i < W - 1; i++) {
        rep(j, 330)rep(k, 330) { dp[j][k] = -1; }
        ans += dfs(H, H, i, i + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define vi vector<int>
#define pb push_back
#define vli vector<long long int>
#define mp make_pair 
#define pii pair<int,int>
int main()
{ // int a[3]={0};
  string s;
  cin>>s;
  s.pb('S');
  int i,t=0,m=0;
  for(i=0;i<s.size();i++)
  {if(s[i]=='R')
    t++;
   else {
     m=max(t,m);
     t=0;
   }
  
  }
   cout<<m;
}


Measured memory_bytes: 3572
#include <string>
#include <iostream>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    for (int h = 0; h < H + 2; h++) {
        for (int w = 0; w < W + 2; w++) {
            if (w == W + 1) {
                cout << "#" << endl;
            } else if (w == 0 || h == 0 || h == H + 1) {
                cout << "#";
            } else {
                string s;
                cin >> s;
                cout << s;
                w += W - 1;
            }
        }
    }

    return 0;
};


Measured memory_bytes: 256
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<bitset>
#include<queue>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define int long long
const int N = 5 * 100*1000 + 7;

int test;

int n;

int res;

int fpow(int a,int b){
    if (b == 0)
        return 1;

    int x = fpow(a,b/2);

    x *= x;
    x %= mod;

    if (b % 2 == 0)
        return x;
    else
        return (x*a)%mod;   
}

int digit(int x){
    int y = 0;

    while(x){
        x/=10;
        y++;
    }

    return y;
}

int gcd(int a,int b){
    if (b == 0)
        return a;

    return gcd(b,a%b);
}

int nww(int a,int b){
    return (a*b)/gcd(a,b);
}

void cor(){
    while(res < 0){
        res += mod;
    }
    while(res >= mod){
        res -= mod;
    }
}

void check(){
    int sum = 50;

    FOR(i,8,49){
        int res = 0, x = sum/i, y = sum - (sum/i)*i;

        if (y == 0){
            x--;
            y = i;
        } 

        int total = sum - y;

        if (i == 8)
            debug(x,y,total);

        while(x){
            while(total < sum){
                total += i+1;
            }

            if (total == sum){
                debug(i,x);
            }

            x--;
            total -= i;
        }
    }
}

void solve()
{   
    cin >> n;

    int r = 0,sum = 0;

    for(int l = 1; l < 1000*1000*10; l++){
        while(sum < n){
            r++;
            sum += digit(r);
        }

        res += (sum == n);
        sum -= digit(l);
    }

    FOR(i,8,n){
        if (n%i == 0){
            res += fpow(10,i) - fpow(10,i-1) - n/i + 1;

            cor();
        }

        if (i == n)
            break;

        int ile = n/i;
        int x = n-(n/i)*i;

        if (x == 0){
            x += i;
            ile -= 1;
        }

        ile -= x;

        if (ile > 0)
            res += ile/(i+1) + (ile%(i+1)!=0);

        cor();
    }

    cout << res%mod;

    return;
}

int32_t main()
{
    boost

    // check();
    solve();

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    bool flag=true;
    if(s[2]!=s[3])flag=false;
    if(s[4]!=s[5])flag=false;
    if(flag)cout << "Yes";
    else cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map &:to_i
B = gets.split.map &:to_i

init = A.inject(:+)

N.times do |i|
  if B[i] <= A[i]
    A[i] -= B[i]
  else
    B[i] -= A[i]
    A[i] = 0
    if B[i] <= A[i+1]
      A[i+1] -= B[i]
    else
      A[i+1] = 0
    end
  end
end

result = A.inject(:+)

puts init - result


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

vector<int> graph[100005];
int color[100005];

int parent[200005];
int gsize[200005];
bool odd[200005];

int getparent(int t)
{
	return t == parent[t] ? t : parent[t] = getparent(parent[t]);
}

void merge(int a, int b)
{
	a = getparent(a), b = getparent(b);
	parent[a] = b;
}

bool dfs(int t, int col = 1)
{
	color[t] = col;
	for (int nxt : graph[t])
	{
		if (color[nxt] == 0)
		{
			if (dfs(nxt, col ^ 3)) return true;
		}
		else
		{
			if (color[nxt] == col) return true;
		}
	}
	return false;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);

	for (int i = 1; i <= n; i++)
	{
		parent[i] = i;
	}

	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		merge(a, b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	for (int i = 1; i <= n; i++)
	{
		if (color[i] == 0 && dfs(i))
			odd[getparent(i)] = true;
	}

	vector<int> og, eg;

	for (int i = 1; i <= n; i++)
	{
		gsize[getparent(i)]++;
	}

	long long ans = n * 1ll * n;
	int sum = 0;

	for (int i = 1; i <= n; i++)
	{
		if (getparent(i) == i)
		{
			if (gsize[i] == 1) continue;

			if (odd[i]) og.push_back(gsize[i]);
			else eg.push_back(gsize[i]);
			sum += gsize[i];
		}
	}

	for (int t : og) ans -= t * 1ll * sum - (int)(og.size() + eg.size());
	for (int t : eg) ans -= t * 1ll * sum - (int)(og.size() + eg.size());

	ans += (long long)eg.size() * eg.size();


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

Measured memory_bytes: 8064
#include <iostream>
using namespace std;
int main()
{
  long long int c=0,i,j,k,l,x,n;
  string s;
  cin>>n;
  cin>>s;
  for(i=0;i<s.length()-2;i++)
  {
      if(s[i]=='A'&& s[i+1]=='B' && s[i+2]=='C')
      {
          c++;
      }
  }
  cout<<c;
}


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

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

    int tmp = n;
    int sumdigits = 0;
    while (tmp > 0) {
        sumdigits += tmp % 10;
        tmp = tmp / 10;
    }
    if (n % sumdigits == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;

int main(){
	string s;
	cin>>s;
	int pos1 = 0, pos2 = 0;
	bool ok = 0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='A' and !ok){
			pos1 = i+1;
			ok = 1;
		}
		if(s[i]=='Z' and ok){
					pos2 = i+1;
							
				}
	}
	cout<<(abs(pos1 - pos2) + 1);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxx = 1e6 + 7;
const ll mod = 1e9 + 7;
const ll base = 311;
const ll base1 = 113;
ll t, T, n, m, k, tong, r, ans, mx, mn, x, y;
string s, s1, s2, ss;
ll a[maxx], b[maxx], pw[maxx], pw1[maxx], st[maxx], st1[maxx];
bool check(ll v)
{
    if(v < 2)return false;
    for(int i = 2; i <= v / i; i ++)
        if(v % i == 0)return false;
    return true;
}
ll hs(ll hh[maxx], ll pw[maxx], ll i, ll j)
{
    return (hh[j] - hh[i-1] * pw[j - i + 1] + maxx * maxx) % maxx;
}
struct mm
{
    ll val;
    ll pos;
};
mm c[maxx];
bool lf(const mm &x, const mm &y)
{
    return (x.val < y.val) || (x.val == y.val && x.pos < y.pos);
}
void sol()
{
    cin >> n >> k;
    ans = 0;
    b[0] = 0;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        a[i] %= k;
        b[i] = b[i-1] + a[i];
    }
    c[0].val = 0;
    c[0].pos = 0;
    for(int i = 1; i <= n; i ++)
    {
        //
        //if(b[i] == i)++ans;
        c[i].val = (b[i] - i + k) % k;
        c[i].pos = i;
      //cout << c[i].val <<" ";
    }
    //cout << '\n';
    sort(c, c+1+n, lf);
    for(int i = 0; i <= n; i ++)
    {
        t = 1;
        queue<ll> st;
        st.push(c[i].pos);
        while(c[i].val == c[i+1].val && i + 1 <= n)
        {
            ++i;
            while(!st.empty() && c[i].pos - st.front() >= k)
            {
                --t;
                st.pop();
            }
            st.push(c[i].pos);
            ans += t;
     //       cout << t<<" ";
            ++t;
        }
    }
    cout <<ans;

}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    sol();
}
/*
using namespace std;
const ll maxn=3e5+1;
const ll maxx=1e13;
const ll mod=1e9+7;
const ll mod1=998244353;

//vector <ll> adj[maxn];
set<ll> adj1[maxn];
//vector<ll> ans;
//bool kt[maxn];
ll n,m,e,k;
ll d=0;
set<ll> pt;
set<ll> adj[maxn];
ll cnt=0;
void dfs(ll u)
{
    cnt++;
    pt.erase(pt.find(u));
    ll pre=0;
    auto it=pt.begin();
    while (it!=pt.end())
    {
        it=pt.upper_bound(pre);
        while (adj[u].find(*it)!=adj[u].end()&&it!=pt.end())
        {
            it++;
        }
        if ( it!=pt.end() )
        {
            pre=*it;
            dfs(*it);
        }
    }
}
int main()
{
    // freopen("test.txt","r",stdin);
    // freopen("CHEMIST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    for (int i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].insert(y);
        adj[y].insert(x);


    }
    for (int i=1;i<=n;i++)pt.insert(i);
    vector<ll> ans;
    for (int i=1;i<=n;i++)
    {
        if (pt.find(i)!=pt.end())
        {
            cnt=0;
            dfs(i);
            ans.pb(cnt);
        }
    }
    sort(all(ans));
    cout <<ans.size()<<endl;
    for (auto p:ans)
    {
        cout <<p<<" ";
    }

}
*/


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int a, b, c;
    cin >> a >> b >> c;

    if (min(a,b) <= c && c <= max(a,b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a, b;

	cin >> a >> b;

	cout << 6 - a - b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       string s;
       cin>>s;
       if(s=="RRR")
        cout<<"3";
       else if(s=="SSS")
        cout<<0;
       else if(s=="RRS"||s=="SRR")
        cout<<"2";
       else
        cout<<1; 
   }
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int e;
  while(cin >> e, e) {
    int m = 1e9;
    for(int y = 0; y * y <= e; y++) {
      for(int z = 0; z * z * z <= e; z++) {
        int x = e - y * y - z * z * z;
        if(x >= 0) m = min(m, x + y + z);
      }
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 1e9 + 5;
int main() {
    int n, w;
    cin>>n>>w;
    vector<int> weight(n), value(n);
    int maxVal = 0;
    for (int item = 0; item < n; item++) {
        cin>>weight[item];
        cin>>value[item];
        maxVal += value[item];
    }
    vector<vector<int> > minWeight(n+1, vector<int>(maxVal+1));
    // for value 0
    for (int numItem = 0; numItem <=n; numItem++) {
        minWeight[numItem][0] = 0;
    }
    // for 0 items
    for (int val = 1; val <= maxVal; val++) {
        minWeight[0][val] = INF;
    }
    for (int val = 1; val <= maxVal; val++) {
        for (int item = 1; item <=n; item++) {
            minWeight[item][val] = minWeight[item-1][val];
            if (value[item - 1] <= val) {
                minWeight[item][val] = min ( minWeight[item][val], minWeight[item - 1][val - value[item - 1]] + weight[item - 1]);
            }
        }
    }
    int ans = 0;
    for (int val = maxVal; val > 0; val--) {
        if (minWeight[n][val] <= w) {
            ans = val;
            break;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


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

bitset<10> f[100];
int p[100][11];

int main(void){
    int n;
    cin>>n;
    rep(i,n)rep(j,10) {
        bool bit;
        cin>>bit;
        f[i][j] = bit;
    }
    rep(i,n)rep(j,11) cin>>p[i][j];

    int res = -(1e9);
    rep(mask,1<<10)if(mask){
        int sum = 0;
        rep(i,n) sum += p[i][(bitset<10>(mask) & f[i]).count()];
        res = max(res,sum);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define rept(i,a,b) for(i=a; i<b; ++i)
#define maX(a,b)    ( (a) > (b) ? (a) : (b))
#define miN(a,b)    ( (a) < (b) ? (a) : (b))
#define pb(a) push_back(a)
#define bigPrime 1000000007
using namespace std;

int main()
{   
    fip;   
    int i;
    string s;
    cin>>s;
    reptUsual( (s.size()-1))
    {
        if(s[i]==s[i+1])
        {
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359
using namespace std;

int main()
{
  int n, a; cin >> n;
  vector<int> count(n);
  rep(i, n) count[i] = 0;
  rep(i, n-1) {
    cin >> a;
    count[a-1]++;
  }
  rep(i, n) cout << count[i] << endl;
  return 0;
}


Measured memory_bytes: 4008
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

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

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	char str[17];
	scanf("%s", str);
	for(int i = 11; i >= 4; i--)	str[i + 1] = str[i];
	str[4] = ' ';
	printf("%s\n", &str);
	return 0;
}


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

int main() {
  int K,A,B;
  cin>>K>>A>>B;
  if(A%K==0){
    cout <<"OK"<<endl;
  }
  else if(B>= A+ K-A%K){
    cout <<"OK"<<endl;
  }
  else{
    cout <<"NG"<<endl;
  }
}



Measured memory_bytes: 3512
fun readList() = readLine()!!.split(" ").map(Integer::parseInt)
fun main(args:Array<String>){
  val N = readLine()!!.toInt()
  val P = readList()
  val Q = Array(N){it}
  Q.sortBy{-P[it]}
  var answer = 0L
  val maxes = sortedSetOf<Int>(-1,N)
  var L0:Int
  var L1:Int
  var R0:Int
  var R1:Int
  for(i in Q){
    L0 = -1
    L1 = -1
    R0 = N
    R1 = N
    L1=maxes.lower(i)
    if(L1!=-1)L0=maxes.lower(L1)
    R0=maxes.higher(i)
    if(R0!=N)R1=maxes.higher(R0)
    answer += P[i].toLong()*((L1-L0)*(R0-i)+(i-L1)*(R1-R0))
    maxes += i
  }
  println(answer)
}


Measured memory_bytes: 82092
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace std;

string dte;

int main(){
	//IO("input.txt", "output.txt");
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	cin >> dte;
	for(int i = 0; i < 7; i++)
		if(arr[i] == dte) cout << 7 - i << "\n";
	return 0;
}


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

int main() {
	int64_t a,b,c,d;
	cin >> a >> b >> c >> d;
	int64_t e,f,g,h;
	e = a*c;
	f = a*d;
	g = b*c;
	h = b*d;
	int64_t j,k,l;
	j = max(e,f);
	k = max(g,j);
	l = max(h,k);
	cout << l << endl;

}
	

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long ll;
ll len;
string str;
bool nine = true;
int main(void){
    // Your code here!
    cin >> str;
    len = str.length();
    for (ll i = 1; i < len; i++) {
        if (str[i] != '9') nine = false;
    }
    cout << (len - 1) * 9 + str[0] - (nine ? '0' : '1') << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	for( i = 1; i <= 9; i++ )
	{
		for( j = 1; j <= 9; j++ )
		{
			printf( "%dx%d=%d\n", i, j, i*j );
		}
	}
	
	return 0;
}

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

int main()
{
    int a,b,flag;
    cin>>a;
    for(int i=1; i<=9; i++)
    {
        if(a>=i && a%i==0)
        {
            b=a/i;
            if(b>=1 && b<=9)
            {
                //cout<<b<<endl;
                flag=1;
                break;
            }
            flag=0;
        }
        else if(a<=i && i%a==0)
        {
            b=i/a;
            if(b>=1 && b<=9)
            {
                flag=1;
                break;
            }
            flag=0;
        }
        flag=0;
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// factorial
long long fact(int n) {
    if (n == 1) return fac[n] = 1;
    if (fac[n]) return fac[n];
    return fac[n] = (fact(n - 1) * n) % MOD;
}

int main() {
    int n;
    cin >> n;
    vector<int> zxz(10, 0);
    vector<int> mxn(100, 0);
    COMinit();
    repeat(i, 1, n + 1) {
        string s = to_string(i);
        int a = (s[0] - '0');
        int b = (s.back() - '0');
        if (s[0] == s.back()) {
            zxz[a]++;
        } else if (i % 10 != 0) {
            int idx = 10 * a + b;
            mxn[idx]++;
        }
    }
    ll ans = 0;
    repeat(i, 1, 10) {
        // debug(i);
        // debug(zxz[i]);
        ans += zxz[i] + COM(zxz[i], 2) * 2;
    }
    repeat(i, 10, 100) {
        string s = to_string(i);
        // debug(i);
        // debug(mxn[i]);
        if (i % 10 == 0)
            continue;
        else {
            int a = (s[0] - '0');
            int b = (s.back() - '0');
            int idx_1 = a * 10 + b;
            int idx_2 = b * 10 + a;
            ans += mxn[idx_1] * mxn[idx_2];
        }
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if (A*B > C*D) {
        cout << A*B << endl;
    }else{
        cout << C*D << endl;
    }
    return 0;
}


Measured memory_bytes: 256