akhauriyash/Code-Regression huggingface dataset:
h,w,m=gets.split.map &:to_i
bs=[]
sr=[0]*h
sc=[0]*w
m.times{
  i,j=gets.split.map &:to_i
  i-=1
  j-=1
  bs.push([i,j])
  sr[i]+=1
  sc[j]+=1
}
mri=[]
mr=0
sr.each_with_index{|e,i|
  next if e<mr
  if e>mr
    mr=e
    mri.clear
  end
  mri.push(i)
}
mci=[]
mc=0
sc.each_with_index{|e,i|
  next if e<mc
  if e>mc
    mc=e
    mci.clear
  end
  mci.push(i)
}
mrh={}
mch={}
mri.each{|i| mrh[i]=true }
mci.each{|i| mch[i]=true }
#p [sr,sc,bs]
#p [mr,mc,mrh,mch]
puts mr+mc-(bs.count{|(i,j)| mrh[i]&&mch[j] }==mri.size*mci.size ? 1 : 0)

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,m,v,p,i,j,remv,add,added,a[1000000],c=0;
	cin>>n>>m>>v>>p;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(i=n-p-1;i>=0;i--) {
		if(a[i]+m>=a[n-p]) {
			if(v-i-1<p) c++;
			else {
				remv=v-i-p;
				add=remv*m;
				for(j=i+1;j<=n-p;j++) {
					added=min(m,a[i]+m-a[j]);
					add-=added;
					if(added<=0) break;
					if(add<=0) break;
				}
				if(add>0) break;
				else c++;
			}
		} else break;	
	}
	cout<<c+p;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long count = 0;
  for (long long i = 0; i < N - 1; i++) {
    if (a[i] + a[i + 1] > x) {
      count += a[i] + a[i + 1] - x;
      a[i + 1] = x;
      a[i + 1] -= a[i];
      if (a[i + 1] < 0) {
        a[i + 1] = 0;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3960
s=list(input())
swi=1
if s[0]=="A":
    if "C" in s[2:-1]:
        s=s[1:]
        s.remove("C")
        swi=0
        for i in range(len(s)):
            if not s[i].islower():
                swi=1
print("AC" if swi==0 else "WA")

Measured memory_bytes: 8908
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    s = input().rstrip()
    t = input().rstrip()

    count = 0

    for i in range(len(s)):
        if s[i] != t[i]:
            count += 1

    print(count)


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 73556
var readline = require('readline');

var knapSack = async function(){
  let n,capacity;

  let val = []
  let weight = [];

  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
  });

  async function processLineByLine() {
    const rl1 = readline.createInterface({
      input: process.stdin,
      output: process.stdout,
      terminal: false
    });
    let index = 0;
    for await (const line of rl1) {
      let [one, two] = line.trim().split(" ").map(x => parseInt(x));
      if(!index){
        [n,capacity] = [one,two]
      } else {
        weight.push(one);
        val.push(two);
        // console.log(val);
      }
      index++;
      if(index === n+1){
        return;
      }
    }
  }

  await processLineByLine();

  let mem = [];

  for(let i = 0 ; i <= capacity ; i++){
    mem.push(0);
  }

  for(let i=1;i<= n ; i++){
    for(let j=capacity;j > 0;j--){
      let valWithoutItem = mem[j];
      let valWithItem = 0;
      if(weight[i-1] <= j){
        valWithItem = val[i-1] + mem[j - weight[i-1]];
      }
      mem[j] = Math.max(valWithItem, valWithoutItem);
    }
  }

  console.log(mem[capacity]);
};

knapSack();


Measured memory_bytes: 36680
#include "bits/stdc++.h"
    using namespace std;
    typedef long long ll;
     
    int main() {
    	ll n;
    	cin >> n;
     
    	vector<ll> A(n + 1), B(n + 1, 0), C;
    	for (ll i = 1; i <= n; i++)
    	{
    		cin >> A[i];
    	}
     
    	// iが大きい方から見ていく
    	for (ll i = n; i >= 1; i--)
    	{
    		if (B[i] % 2 == A[i]) { continue; }
     
    		// 偶奇が異なる場合に玉を入れる
    		C.push_back(i);
     
    		// i の約数にも玉を入れる
    		for (ll j = 1; j * j <= i; j++)
    		{
    			if (i % j > 0) { continue; }
    			if (j * j == i) { B[j] ++; }
    			else {B[j] ++; B[i/j] ++;}
    		}
    	}
    	
    	ll cnt = C.size();
    	for (ll i = 1; i <= n; i++)
    	{
    		if (B[i] % 2 != A[i]) { cnt = -1; break; }
    	}
     
    	cout << cnt << endl;
      	for (ll i = 0; i < C.size(); i++)
        {
          	if ( i > 0 ) { cout << " ";}
          	cout << C[i];
        }
      	cout << endl;
     
    	return 0;
    }

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

bool isok(ll T)
{
	if(M<2LL*T) return false;
	ll S_count=N+(M-2LL*T)/2;
	if(S_count>=T) return true;
	return false;
}

int main(void)
{
	cin>>N>>M;
	lef=1; rig=1e16;
	while(lef<=rig)
	{
		mid=(lef+rig)/2;
		if(isok(mid)) best=mid, lef=mid+1;
		else rig=mid-1;
	}
	cout<<best; return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
immutable int inf = mod;

void main(){
    int n = readln.chomp.to!int;
    auto a = new int[](n + 1);

    foreach(i ; 1 .. n + 1){
        readVars(a[i]);
    }

    auto dp = new int[](n + 1);
    auto ma = new int[](n + 1);
    ma[1 .. $] = inf;
    ma[0] = -1;

    foreach(i ; 1 .. n + 1){
        int j = nibutan(n, ma, a[i]) + 1;
        ma[j] = a[i];
        dp[i] = j;

        //writeln(ma);
    }

    int ans = dp.reduce!max;

    writeln(ans);
}

int nibutan(int n, int[] ma, int v){
    int btm = -1, top = n;

    while (top - btm > 1) {
        int mid = (top + btm) / 2;

        if (ma[mid] < v) {
            btm = mid;
        }
        else {
            top = mid;
        }
    }

    return btm;
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],sum[n];
    map<int,int>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum[i]=i+a[i];
    }
    sort(sum,sum+n);
    for(int i=0;i<n;i++){
        int x=0;
        while(i+x<n-1 && sum[i+x]==sum[i+x+1]){
            x++;
        }
        m.insert(make_pair(sum[i],x+1));
        i+=x;
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        if(binary_search(sum,sum+n,i-a[i]))ans+=m.at(i-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14492
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.next());
		String s = in.next();
		if(n % 2 != 0) {
			System.out.println("No");
		}else {
			int half = n / 2;
			String t1 = s.substring(0, half);
			String t2 = s.substring(half, n);
			if(t1.equals(t2)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>

using namespace std;

int n, sum;

int main()
{
    scanf("%d", &n);
    int m = n;
    while(n)
    {
        sum += n % 10;
        n /= 10;
    }
    if(m % sum == 0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
const int N=1e5+10;
void solve()
{
    VL visit(N,0);
    for(int i=2;i*i<=N;i++)
    {
        if(visit[i]==0)
        {
            for(int j=i;j<=N;j+=i)
            {
                visit[j]=1;
            }
            visit[i]=2;
        }

    
    }
    fr(i,2,N)
    {
        if(visit[i]==0)
            visit[i]=2;
    }
    VL pref(N,0);

    fr(i,2,N)
    {
        if(visit[i]==2)
        {
            if(visit[(i+1)/2]==2)
            {
                pref[i]=1;
            }
        }
    }
    fr(i,1,N)
    {
        pref[i]+=pref[i-1];
    }
    ll q;
    cin>>q;
    fr(i,0,q)
    {
        ll l,r;
        cin>>l>>r;
        cout<<pref[r]-pref[l-1]<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 4664
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
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()))

t = I()
for _ in range(t):
    n = I()
    a = LI()
    s = input()
    t = []
    for i, Ai in enumerate(a[::-1]):
        for Ti in t:
            if Ai ^ Ti < Ai: # msb(Ai) >= msb(Ti)
                Ai ^= Ti
        if Ai != 0 and s[n-i-1] == '0':
            t.append(Ai)
        elif Ai != 0 and s[n-i-1] == '1':
            print(1)
            break
    else:
        print(0)

Measured memory_bytes: 68800
N = int(input())
A = list(map(int, input().split()))

cumulative = [0]
for i in range(N):
    cumulative.append(cumulative[i] + A[i])
lst = []
for i in range(1, N):
    a = abs(cumulative[i] - (cumulative[-1] - cumulative[i]))
    lst.append(a)
#print(lst)
print(min(lst))

Measured memory_bytes: 99916
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

using namespace std;

int main()
{
    bool isLocked = true;
    vector<string> map;
    int N, M;
    cin >> N;
    
    map.clear();
    map.resize(N);
    for (int i = 0; i < N; ++i) {
        string id;
        cin >> id;
        map[i] = id;
    }
    
    cin >> M;
    for (int i = 0; i < M; ++i) {
        string id;
        cin >> id;
        auto itr = find(map.begin(), map.end(), id);
        if (itr != map.end()) {
            if (isLocked) {
                cout << "Opened by " << id << "\n";
            } else {
                cout << "Closed by " << id << "\n";
            }
            isLocked = !isLocked;
        } else {
            cout << "Unknown " << id << "\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int a, b, c;
    for (; n > 0; n--) {
        scanf("%d", &a);
        scanf("%d", &b);
        scanf("%d", &c);
        if (a * a + b * b == c * c || a * a + c*c == b*b || b*b + c*c == a*a) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1008
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
ll dp[ohara], dp_cou, need;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) {
    if (a[i] == b[i]) continue;
    if (b[i] < a[i])
      dp[dp_cou++] = a[i] - b[i];
    else
      ans++, need += b[i] - a[i];
  }
  sort(dp, dp + dp_cou);
  reverse(dp, dp + dp_cou);
  rep(i, dp_cou) {
    if (need <= 0) break;
    need -= dp[i];
    ans++;
  }
  if (need > 0) ans = -1;
  Cout(ans);
  return 0;
}

Measured memory_bytes: 8832
#include<iostream>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int ans=1;
	for(int i=1;i<=M/2;i++){
		if(M%i==0&&M/i>=N)ans=i;
	}
	if(N==1)ans=M;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    string S;
    long long K, n, i, count, ans=0, st, en, link=0, judge=1;

    cin >> S;
    cin >> K;

    n = S.size();

    if(n==1) judge = 1;
    else{
        for(i=0; i<n-1; i++){
            if(S[i]!= S[i+1]) judge = 0;
        }
    }

    if(judge == 1){
        ans = n*K/2;
    }

    else if(S[0]==S[n-1]){
        st = 0;
        while(S[st]==S[st+1]){
            st++;
        }
        link += st+1;

        en = n-1;
        while(S[en]==S[en-1]){
            en--;
        }

        link += n-en;

        count = 1;

        for(i=st+1; i<en-1; i++){
            if(S[i]==S[i+1]){
                count++;
            }
            else{
                ans += count/2;

                count = 1;
            }
        }
        ans += count/2;

        ans *= K;
        
        ans += link/2*(K-1);
        ans += (st+1)/2;
        ans += (n-en)/2;
    }

    else{
        count = 1;

        for(i=1; i<n; i++){
            if(S[i-1]==S[i]){
                count++;
            }
            else{
                ans += count/2;

                count = 1;
            }
        }

        ans += count/2;

        ans *= K;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using Int = long long;
const Int INF = 1 << 30;

int main() {

	Int A, B, C, X, Y;
	std::cin >> A >> B >> C >> X >> Y;

	Int ans = INF;
	Int c_limit = std::max(X, Y)*2;

	for (Int i = 0; i <= c_limit; i++) {
		Int a = X - i/2;//aを買う枚数
		if (a <= 0)a = 0;
		Int b = Y - i/2;//bを買う枚数
		if (b <= 0)b = 0;
		Int sum = a * A + b * B + i * C;
		if (sum <= ans)ans = sum;
	}

	std::cout << ans << std::endl;

}

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

int main(){
	int n, a = 0, b = 0, arr[] = {0, 1, 3};
	cin >> n;
	while(n--){
		string s, t;
		cin >> s >> t;
		a += arr[(s > t) + (s >= t)];
		b += arr[(s < t) + (s <= t)];
	}
	cout << a << ' ' << b << endl;
}

Measured memory_bytes: 3196
// file creato da gio il 2020-04-07 18:40:06.953635

#include <bits/stdc++.h>
#define FAST 

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define S second
#define F first
#define PB push_back
using namespace std;

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	long  a,b;
	cin >> a>>b;

	cout <<min(a%b,b-a%b);
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.141592653589793238
typedef long long ll;
using namespace std;
int main()
{
    double n;
    cin>>n;
    double ans=2*pi*n;
    cout<<setprecision(6)<<ans;
    return 0;
}

Measured memory_bytes: 3776
// Copyright 2020 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& e : A)cin >> e;
  bool ans = all_of(begin(A), end(A), [](int n) { return n % 2 != 0 || (n % 3 == 0 || n % 5 == 0); });
  cout << (ans ? "APPROVED" : "DENIED") << endl;
}



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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int main() {
    int n;

    scanf("%d", &n);

    if(n%2 == 0) printf("0.5\n");
    else {
    	int a = n/2;
    	printf("%.15lf\n", 1-(double)a/n);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int main(){
    int n,t;
    cin >> n >> t;
    vector<pair<int,int>> vp(n);
    rep(i,n){
        cin >> vp.at(i).first >> vp.at(i).second;
    }
    
    int mnt = INF;
    for(auto p:vp){
        if(p.second <= t){
            mnt = min(mnt,p.first);
        }
    }
    if(mnt < INF) cout << mnt << endl;
    else cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define PR pair<LL,LL>
const int N=20;
LL a[N];
vector< PR > vp[N][N];
PR calpr(PR u,PR v,LL t){
    LL num=u.sc+v.fr+t;
    return mp(u.fr+num,v.sc+num);
}
LL calval(PR t,LL u,LL v){
    return t.fr*u+t.sc*v;
}
void pus(int n,int l,int r,int u1,int v1,int u2,int v2){
    if (l>r) return;
    PR m1,m2;
    LL val1=1e18,val2=1e18;
    int len=r-l+1;
    for (int k=l;k<=r;k++){
        int l1=k-l,l2=r-k;
        for (auto u:vp[l1][l]) for (auto v:vp[l2][k+1]){
            PR t=calpr(u,v,a[k]);
            LL valt1=calval(t,u1,v1);
            if (valt1<val1) m1=t,val1=valt1;
            if (len>n-2) continue;
            LL valt2=calval(t,u2,v2);
            if (valt2<val2) m2=t,val2=valt2;
        }
    }
    vp[len][l].pb(m1);
    if (len==n-2) vp[len][l].pb(m2);
}
void work(int n){
    pus(n,1,n-2,1,2,1,3);
    pus(n,2,n-1,2,3,3,2);
    pus(n,3,n,  2,1,3,1);

    pus(n,1,n-1,1,2,0,0);
    pus(n,2,n,  2,1,0,0);

    pus(n,1,n,  1,1,0,0);
}
int main(){
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int n;cin>>n;
    for (int i=0;i<n;i++) scanf("%lld",a+i);
    LL ans=a[0]+a[n-1];n-=2;

    for (int i=1;i<=n;i++) vp[1][i].pb(mp(a[i],a[i])),vp[0][i].pb(mp(0,0));
    vp[0][n+1].pb(mp(0,0));

    for (int p=2;p<=n-3;p++){
        for (int i=1;i+p-1<=n;i++){
            int j=i+p-1;
            for (int k=i;k<=j;k++){
                int l1=k-i,l2=j-k;
                for (auto u:vp[l1][i]) for (auto v:vp[l2][k+1]){
                    vp[p][i].pb(calpr(u,v,a[k]));
                }
            }
        }
    }

    work(n);
    PR p=vp[n][1][0];
    ans+=p.fr+p.sc;
    cout<<ans<<endl;

    return 0;
}


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

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

Measured memory_bytes: 3616
import sys

S = sys.stdin.readline().strip()
ls = len(S)

if ls == 26 and list(S) == sorted(S, reverse=True):
    print(-1)
    sys.exit()

alpha = "abcdefghijklmnopqrstuvwxyz"
exists = set(S)
if ls < 26:
    for a in alpha:
        if a not in exists:
            print(S + a)
            sys.exit()
else:
    for i in range(ls):
        tmp = S[ls-1-i:] 
        if list(tmp) != sorted(tmp, reverse=True):
            break
    remain = []
    exists = set(S[:ls-i-1])
    last = S[ls-i-1]
    for a in alpha:
        if a not in exists:
            remain.append(a)

    for r in sorted(remain, reverse=True):
        if last < r:
            min_a = r
    # min_a = sorted(remain)[0]
    print(S[:ls-i-1] + min_a)

Measured memory_bytes: 9172
def d_no_need(N, K, A):
    card = sorted(A, reverse=True)
    s = 0  # カードの値の総和
    ans = 0  # 不必要なカードの枚数
    # Aのうち要素が大きいものから見ていったとき、
    # その要素を入れても総和がK未満のものだけ加えていく
    # 最後に連続して加えた要素の個数が解となる
    # (それら以外の要素の組み合わせでK以上にでき、かつ、
    #  それらの総和がK未満になるため)
    for a in card:
        if s + a < K:
            s += a
            ans += 1
        else:
            ans = 0
    return ans

N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_no_need(N, K, A))

Measured memory_bytes: 3572
#include <stdio.h>

int main()
{
  int n;

  scanf("%d", &n);

  long long int a=2, b=1, ans;

  if ( n == 1) {
    ans = b;
  } else { 
  for (int i=2; i <= n; i++) {
    ans = a+b;
    if( i % 2 == 0) {
      a = ans;
    } else {
      b = ans;
    }
    
  }
  }

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

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int h, w;
char g[444][444];
bool used[444][444];
ll black, white;

bool border(int i, int j)
{
	if (i < 1 || i > h || j < 1 || j > w) return false;
	else return true;
}

void count(int i, int j)
{
	used[i][j] = true;
	if (g[i][j] == '#') {
		black++;
		if (border(i + 1, j) && g[i + 1][j] == '.' && used[i + 1][j] == 0) count(i + 1, j);
		if (border(i - 1, j) && g[i - 1][j] == '.' && used[i - 1][j] == 0) count(i - 1, j);
		if (border(i, j + 1) && g[i][j + 1] == '.' && used[i][j+1] == 0) count(i, j + 1);
		if (border(i, j - 1) && g[i][j - 1] == '.' && used[i][j-1] == 0) count(i, j - 1);
	}
	else {
		white++;
		if (border(i + 1, j) && g[i + 1][j] == '#' && used[i + 1][j] == 0) count(i + 1, j);
		if (border(i - 1, j) && g[i - 1][j] == '#' && used[i - 1][j] == 0) count(i - 1, j);
		if (border(i, j + 1) && g[i][j + 1] == '#' && used[i][j + 1] == 0) count(i, j + 1);
		if (border(i, j - 1) && g[i][j - 1] == '#' && used[i][j - 1] == 0) count(i, j - 1);
	}
}

int main()
{
	cin >> h >> w;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			cin >> g[i][j];
		}
	}

	ll ans = 0;

	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			if (used[i][j] == 0 && g[i][j] == '#') {
				black = 0;
				white = 0;
				count(i, j);
				ans += (black * white);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int INF = 1e9 + 7;
#define MAX_V 401

struct edge {
  int to;
  int cost;
};

int V;
vector<edge> G[MAX_V];
int d[MAX_V][MAX_V];

void warshall_floyd() {
  for ( int i = 0; i < V; i++ ) {
    fill(d[i], d[i]+V, INF);
    d[i][i] = 0;
    for ( int j = 0; j < G[i].size(); j++ ) {
      edge e = G[i][j];
      d[i][e.to] = e.cost;
    }
  }

  for ( int k = 0; k < V; k++ ){
    for ( int i = 0; i < V; i++ ) {
      for ( int j = 0; j < V; j++ ) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  int s[h][w];
  V = 0;
  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) {
      char c;
      cin >> c;
      if ( c == '.' ) { s[i][j] = V++; } else { s[i][j] = -1; }
    }
  }

  for ( int i = 0; i < h; i++ ) {
    for ( int j = 0; j < w; j++ ) {
      if ( s[i][j] != -1 ) {
        edge e; e.cost = 1;
        if ( i-1 >= 0 && s[i-1][j] != -1 ) { e.to = s[i-1][j]; G[s[i][j]].push_back(e); }
        if ( i+1 < h  && s[i+1][j] != -1 ) { e.to = s[i+1][j]; G[s[i][j]].push_back(e); }
        if ( j-1 >= 0 && s[i][j-1] != -1 ) { e.to = s[i][j-1]; G[s[i][j]].push_back(e); }
        if ( j+1 < w  && s[i][j+1] != -1 ) { e.to = s[i][j+1]; G[s[i][j]].push_back(e); }
      }
    }
  }

  warshall_floyd();

  int ans = 0;
  for ( int i = 0; i < V; i++ ) {
    for ( int j = 0; j < V; j++ ) {
      ans = max(d[i][j], ans);
    }
  }

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


Measured memory_bytes: 4220
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

int N, M;

int main(){
  cin>>N>>M;
  double A[N];
  for(int i = 0; i < N; i++) cin>>A[i];
  
  int popular = 0;
  
  double sum = 0;
  
  for(int i = 0; i < N; i++) sum += A[i]; 
  
  sum /= (4 * M);
  
  for(int i = 0; i < N; i++){
    if(sum > A[i]) continue; 
    
    ++popular;
  }
  
  if(M <= popular) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
// In the name of Allah the Lord of the Worlds.

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

typedef long long ll;

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

    int n;
    long double sum = 0;
    cin >> n;
    priority_queue<long double>pq;
    for(int i=0;i<n;i++){
        long double in;
        cin >> in;
        pq.push(-in);
    }
    while(pq.size()>1){
        long double t1 = -pq.top();
        pq.pop();
        long double t2 = -pq.top();
        pq.pop();
        pq.push(-((t1+t2)/2.00));
    }
    cout << setprecision(14) << fixed << (long double)-pq.top() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))


ll f(ll x,ll y,ll a,ll b,ll t){
	ll dx=llabs(x-a);
	ll dy=llabs(y-b);
	return (dx+dy<=t)&&((dx+dy)%2==t%2);
}

int main(){
	ll n;
	scanf("%lld",&n);
	ll x=0,y=0,t=0;
	ll flag=1;
	rep(i,0,n){
		ll p,q,r;
		scanf("%lld%lld%lld",&p,&q,&r);
		flag&=f(x,y,q,r,p-t);
		t=p;
		x=q;
		y=r;
	}
	puts(flag?"Yes":"No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  uint64_t a, b, k;
  cin >> a >> b >> k;
  if(a >= k) {
    a -= k;
  } else {
    k -= a;
    a = 0;
    if(b >= k) {
      b -= k;
    } else {
      k -= b;
      b = 0;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    CUSUM_A = [0] * (N+1)
    CUSUM_B = [0] * (M+1)

    for i, a in enumerate(A):
        CUSUM_A[i+1] = CUSUM_A[i] + a

    for i, b in enumerate(B):
        CUSUM_B[i+1] = CUSUM_B[i] + b


    # Aの本をi冊, Bの本をj冊読む i:[0:N],j:[0,M]
    ans = 0
    j = M
    for i in range(N+1):
        # Aの本だけでK超えてたらBをいくら減らしてもだめ ここで場合分けしておくことでj>=0を保証できる (j=0のとき確実に読めるので)
        if CUSUM_A[i] > K:
            break

        SUM_VAL = CUSUM_A[i] + CUSUM_B[j]
        
        while SUM_VAL > K:
            j -= 1
            SUM_VAL = CUSUM_A[i] + CUSUM_B[j]
        
        ans = max(ans, i+j)
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 47376
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int x = scanner.nextInt();
    int y = scanner.nextInt();
    System.out.println(solve(a, b, c, x, y));
  }

  private static long solve(int a, int b, int c, int x, int y) {
    if (a + b < c * 2) {
      return x * a + y * b;
    }
    long res;
    if (x < y) {
      res = x * c * 2;
      y = y - x;
      x = 0;
    } else {
      res = y * c * 2;
      x = x - y;
      y = 0;
    }
    if (x == 0) {
      return res + y * Math.min(b, c * 2);
    }
    return res + x * Math.min(a, c *2);
  }
}


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

int main(){
  string s;
  cin >> s;

  if(s=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}

Measured memory_bytes: 3592
function maxHeapify(heap, size, id) {
    const left = id * 2;
    const right = id * 2 + 1;
    let largest = id * 2 <= size && heap[left] > heap[id] ? left : id;

    if(id * 2 + 1 <= size && heap[right] > heap[largest]) {
        largest = right;
    }

    if(largest !== id){
        const temp = heap[id];
        heap[id] = heap[largest];
        heap[largest] = temp;
        maxHeapify(heap, size, largest);
    }
}

function buildHeapify(heap, size) {
    let count = Math.floor(size / 2);
    while(count){
        maxHeapify(heap, size, count);
        count--;
    }
}

function main(_stdin){
    const stdin = _stdin.split('\n');
    const heapSize = parseInt(stdin.shift(), 10);
    const _heap = [null];
    const heap = _heap.concat(stdin.shift().split(' ').map(e => parseInt(e, 10)));
    let ans = '';

    buildHeapify(heap, heapSize);
    heap.forEach(e => {
        if (e) ans += ' ' + e;
    });
    console.log(ans)
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> taste(N);
  
  //testeにそれぞれの値を入力、合計値sum
  int sum = 0;
  for(int i=0; i<N; i++){
    taste[i]=L+i;
    sum += taste[i];
  }
  
  //最も０に近いtasteを求める
  int n = 0;
  int a = abs(taste[0]);
  for(int i=0; i<N; i++){
    if(a > abs(taste[i])){
      a = abs(taste[i]);
      n = i;
    }
  }
  
  //解答
  cout << sum - taste[n] << endl;
  
}

Measured memory_bytes: 256
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)&1)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n")
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n) rep(j,0,m) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const ll ooo=9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N=100005;
const double PI=acos(-1.0);
const double eps=1e-9;
int o(int x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

int a,b,c,d,e,f,t0,tt;
double ans=-1;

int main() {
    //file_put();

    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    rep(i,0,30)
    rep(j,0,30){
        if (100*a*i+100*b*j>f) break;
        if (i==0 && j==0) continue;
        int qq=f-(100*a*i+100*b*j);
    rep(p,0,qq) {
        if (100*a*i+100*b*j+c*p>f) break;
        int pp=f-(100*a*i+100*b*j+c*p);
    rep(q,0,pp)
    {
        int t=100*a*i+100*b*j+c*p+d*q;
        if (t>f) break;
        if (c*p+d*q>(ll)(a*i+b*j)*e) break;
        if (t && (c*p+d*q)/(double)t>ans) {
            ans=(c*p+d*q)/(double)t;
            t0=t;
            tt=c*p+d*q;
        }
    }
    }
    }
    cout<<t0<<" "<<tt<<endl;

    return 0;
}


Measured memory_bytes: 256
n,  = [int(v) for v in input().split()]
w_s = [int(v) for v in input().split()]

cand = []
for i in range(n - 1):
  g1 = w_s[:i+1]
  g2 = w_s[i+1:]
  s1 = sum(g1)
  s2 = sum(g2)
  diff = abs(s1 - s2)
  cand.append(diff)
  
print(min(cand))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N, C,K ;cin >> N >> C >> K;
    vector<ll> T(N);
    for (ll i = 0; i < N; i++) {
        cin >> T[i];
    }

    sort(ALL(T));

    ll prebus = T[0];
    ll waiting = 1;
    ll ans = 0;
    for (ll i = 1; i < N; i++) {
        if(T[i] > prebus + K){
            ans++;
            waiting = 1;
            prebus = T[i];
        }
        else if(waiting == C){
            ans++;
            waiting = 1;
            prebus = T[i];
        }
        else{
            waiting++;
        }
    }

    if(waiting > 0){
        ans++;
    }
    printf("%lld\n", ans);

}


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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 1000 * 1000 + 10; 
const int mod = 1000 * 1000 * 1000 + 7;



int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string s;
	cin>> s >> s;
	int n = s.size(), cnt = 0;
	for(int i = 0; i < n; i++) cnt += s[i] == 'R';
	cout<< (cnt > n - cnt ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
let to_list str =
  let rec doit i acc =
    if i < 0 then acc
    else doit (i - 1) (String.get str i :: acc)
  in
  doit (String.length str - 1) []

let calc_area lst =
  let rec doit i idxs acc = function
    | [] -> acc
    | '_' :: tl -> doit (i + 1) idxs acc tl
    | '\\' :: tl -> doit (i + 1) (i :: idxs) acc tl
    | '/' :: tl -> begin
        match idxs with
        | [] -> doit (i + 1) idxs acc tl
        | j :: js -> doit (i + 1) js (((j, i), i - j) :: acc) tl
      end
    | _ -> exit 1
  in
  doit 0 [] [] lst

let integrale lst =
  let rec doit acc = function
    | [] -> acc
    | [e] -> e :: acc
    | (((j1, i1), area1) as xs) :: ((((j2, i2), area2) :: tl) as ys) ->
        if j1 < j2 && i1 > i2 then doit acc (((j1, i1), area1 + area2) :: tl)
        else doit (xs :: acc) ys
  in
  doit [] lst

let () =
  let areas = integrale (calc_area (to_list (read_line ()))) in
  Printf.printf "%d\n" (List.fold_left (fun acc (_, n) -> acc + n) 0 areas);
  Printf.printf "%d" (List.length areas);
  List.iter (fun (_, n) -> Printf.printf " %d" n) areas;
  print_newline ()

Measured memory_bytes: 4504
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

vector<pair<ll, ll>> enum_divisors(long long N) {
    vector<pair<ll, ll>> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back({i, N / i});
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> en = enum_divisors(N);

    ll ans = INF;
    rep(i, en.size()) {
        ans = min(ans, abs(en[i].first - 1) + abs(en[i].second - 1));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()

min1=min2=int(1e15)
max1=max2=-int(1e15)

for i in range(n):
	x,y=invr()
	
	min1=min(min1,x+y)
	min2=min(min2,x-y)
	
	max1=max(max1,x+y)
	max2=max(max2,x-y)

ans=max(max1-min1,max2-min2)

print(ans)


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

#define MOD 1000000007

signed main(){
  Int n;
  cin>>n;
  vector<int> p(n+1);
  for(Int i=1;i<=n;i++) cin>>p[i];
  vector<vector<int> > G(n+1);
  for(Int i=1;i<=n;i++) G[p[i]].emplace_back(i);
  vector<vector<deque<int> > > dp(n+1);

  p.clear();

  vector<int> c(n+1,0),po(n+1,1);
  for(Int i=0;i<n;i++) po[i+1]=(Int)po[i]*2%MOD;
  
  function<void(int, int)> dfs=[&](int v,int d){
    c[d]++;
    dp[v].resize(2);
    
    int idx=-1;
    for(int u:G[v]){
      dfs(u,d+1);
      if(idx<0||dp[idx][0].size()<dp[u][0].size()) idx=u;
    }
    
    if(~idx) swap(dp[v],dp[idx]);

    if(G[v].size()>1u){
      dp[v].emplace_back(deque<int>(dp[v][0].size(),0));
      for(int u:G[v]){
	if(u==idx) continue;
	for(int i=0;i<(int)dp[u][0].size();i++){
	  vector<Int> t({dp[v][0][i],dp[v][1][i],dp[v][2][i]});
	  dp[v][0][i]=dp[v][1][i]=dp[v][2][i]=0;
	  for(int j=0;j<3;j++){
	    for(int k=0;k<2;k++){
	      dp[v][min(2,j+k)][i]+=t[j]*dp[u][k][i]%MOD;
	      dp[v][min(2,j+k)][i]%=MOD;
	    }
	  }
	}
      }
    
      for(int i=0;i<(int)dp[v][0].size();i++){
	dp[v][0][i]+=dp[v][2][i];
	dp[v][0][i]%=MOD;
	dp[v][2][i]=0;
      }
      dp[v].pop_back();
    }
    
    dp[v][0].emplace_front(1);
    dp[v][1].emplace_front(1);
    for(int u:G[v]) dp[u].clear();
  };
  dfs(0,0);
  int ans=0;
  for(int i=0;i<(int)dp[0][1].size();i++){
    ans+=(Int)dp[0][1][i]*po[n+1-c[i]]%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 490868
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
	if (a%b == 0) return b;
	return gcd(b, a%b);
}

int main() {
	ll x, y; cin >> x >> y;
	ll g = gcd(x, y);
	if (y == g) {
		cout << -1 << endl;
		return 0;
	}
	if (g == 1) {
		cout << x << endl;
		return 0;
	}
	cout << x*(y/g - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!

    var ans = 0
    var count = 0

    for (c in s) {
        if (c in "ACGT") {
            count++
        } else {
            ans = Math.max(ans, count)
            count = 0
        }
    }

    ans = Math.max(ans, count)

    println(ans)
}

Measured memory_bytes: 33812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> t(n),a(n),x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int max=1;
    for(int i=0;i<n;i++){
        if(t[i]==1&&max==1){
            x[i]=t[i];
        }
        else if(t[i]>max){
            x[i]=t[i];
            max=t[i];
        }
        else x[i]=-max;
    }
    max=1;
    for(int i=n-1;i>=0;i--){
        if(a[i]==1&&max==1){
            y[i]=a[i];
        }
        else if(a[i]>max){
            y[i]=a[i];
            max=a[i];
        }
        else y[i]=-max;
    }    
    for(int i=0;i<n;i++){
        if(x[i]!=y[i]&&x[i]>0&&y[i]>0){
            cout<<"0"<<endl;
            return 0;
        }
        if(x[i]>0&&y[i]<0&&x[i]>-y[i]){
            cout<<"0"<<endl;
            return 0;
        }
        if(y[i]>0&&x[i]<0&&y[i]>-x[i]){
            cout<<"0"<<endl;
            return 0;
        }
    }
    vector<int> p(n),q(n);
    max=1;
    for(int i=0;i<n;i++){
        if(t[i]==1&&max==1){
            p[i]=t[i];
        }
        else if(t[i]>max){
            p[i]=1;
            max=t[i];
        }
        else{
            p[i]=max;
        }
    }
    max=1;
    for(int i=n-1;i>=0;i--){
        if(a[i]==1&&max==1){
            q[i]=a[i];
        }
        else if(a[i]>max){
            q[i]=1;
            max=a[i];
        }
        else{
            q[i]=max;
        }
    }
    long long ans=1;
    for(int i=0;i<n;i++){
        ans*=min(p[i],q[i]);
        if(ans>1000000007)ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define Maxn 500010
int n;
long long p, q, c[Maxn], d[Maxn], Sig, Res, Tab;
int main()
{
    scanf("%d%lld%lld", &n, &p, &q);
    for (int i=1; i<=n; i++)
    {
        scanf("%lld", &c[i]); Sig+=c[i];
        d[i]=c[i]-(q-i+1)*p;
    }
    sort(d+1, d+n+1);
    Res = Sig;
    for (int i=1; i<=n; i++)
    {
        Sig-=d[i]; Tab+=p*((i-1)<<1);
        Res=max(Res, Sig+Tab);
    }
    printf("%lld\n", Res);
}



Measured memory_bytes: 11092