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

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

using namespace std;

typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t i32;
typedef int64_t i64;

int main() {
    fio;

    i32 h, w, k;
    cin >> h >> w >> k;
    vector<vector<i32>> mat(h, vector<i32>(w));
    for (i32 i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (i32 j = 0; j < w; j++) {
            mat[i][j] = s[j] == '#';
        }
    }

    i32 res = 0;
    i32 n = 1u << (u32) (h + w);
    for (u32 b = 0; b < n; b++) {
        i32 c = 0;
        for (i32 i = 0; i < h; i++) {
            if ((1u << (u32) (i + w)) & b) continue;
            for (i32 j = 0; j < w; j++) {
                if ((1u << (u32) j) & b) continue;
                c += mat[i][j];
            }
        }
        if (c == k) res++;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>


int main(void)
{
	char o[50+1], e[50+1];
	int i;

	while(scanf("%50s%50s", o, e)==2)
	{
		for(i=0;o[i];i++)
		{
			putchar(o[i]);
			if(e[i]) putchar(e[i]);
		}
		putchar('\n');
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t

#define N 1000010
bool p[N];

void solve(){
    int count = 0;
    int a,b,n;
    cin >> a >> b >> n;
    
    if( a == 0 && b == 0 && n == 0 )exit(0);
    
    //cout << a << " " << b << " " << n << " ";
    
    for(int i = 0 ; i < N ; i++){
        if( p[a+b*i] )
            count++;
        
        if( count == n ){
            //cout << count << " lll " << n << endl;
            cout << a+b*i << endl;
            return;
        }
    }
    
    return;
}

int main(void){
    for(int i = 0 ; i < N ; i++ )
        p[i] = true;
    
    p[0] = p[1] = false;
    for(int i = 2 ; i < N ; i++ ){
        if( p[i] ){
            for(int j = 2*i ; j < N ; j+= i){
                p[j] = false;
            }
        }
    }
    
    while(true)solve();
    return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;

vector<bool> seen;
vector<int> first_order; // 行きがけ順
vector<int> last_order; // 帰りがけ順
void dfs(const vector<vector<int>> &G,int v,int& ptr){
  first_order[v] = ptr++;

  // vを訪問済みにする
  seen[v] = true;

  // vから行ける各頂点next_vについて
  for(auto next_v:G[v]){
    if(seen[next_v]) continue;
    dfs(G,next_v,ptr);
  }

  last_order[v] = ptr++;
}

int main(){
  //頂点数
  int n;
  cin >> n;

  Graph G(n+1);
  //頂点番号、隣接頂点数、隣接頂点番号
  for(int i=1;i<=n;i++){
    int u,k;
    cin >> u >> k;
    for(int j=0;j<k;j++){
      int v;
      cin >> v;
      G[u].push_back(v);
    }
  }

  seen.assign(n+1,false);
  first_order.resize(n+1);
  last_order.resize(n+1);
  int ptr = 1;
  for(int i=1;i<=n;i++){
    if(seen[i]) continue;
    dfs(G,i,ptr);
  }

  // 各頂点vの行きがけ順、帰りがけ順を出力
  for(int v = 1;v<=n;v++){
    cout << v << " " << first_order[v] << " " << last_order[v] << endl;
  }
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  998244353
#define mod1 1000000009
#define var    int n,m,i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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

int n,m,a[200005];

int main()
{
    ll a,b,c,d,x,y;
    sfl(a);sfl(b);sfl(c);sfl(d);

    ll ans = max(b*d, a*c);
    if(d<=0)
    {
        ans = max(ans,d*a);
    }
    if(b<=0)
    {
        ans = max(ans,b*c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510

// find_by_order(int k) - returns k'th smallest element (0-indexed)
// order_of_key(int k) - returns number of elements strictly smaller than k.
// using namespace __gnu_pbds;
// #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>

const ll mod=1e9+7,N=1e5+5,INF = 1e18;

ll power(ll a,ll b)
{
    a = a%mod;
    ll result = 1;

    while(b)
    {
        if(b&1)
            result = (result*a)%mod;
        b >>= 1, a = (a*a)%mod;
    }
    return result;
}


/*

1. Make sure you're taking all the inputs.
2. In case of nested loops, remember to use different variables.
3. If in doubt, do int -> ll
4. Don't fight the question, try solving the next one.

*/



//  Don't code anything above this //




int main() 
{ 
    BOOST

    int n,l;
    cin>>n>>l;

    int ans = 0;
    int diff = 10000;
    int sum = (n*l) + (n*(n-1))/2 ;
    for(int i=l;i<=l+n-1;i++)
    {
        int diff_t = abs(i);
        if(diff_t < diff)
            ans = sum - i, diff = diff_t;
    }
    cout<<ans<<"\n";
    return 0;    
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()

    r = 1000
    t = []
    sf = True
    for i in range(n-1):
        if sf:
            if a[i] >= a[i+1]:
                continue
            t.append(a[i])
            sf = False
        else:
            if a[i] <= a[i+1]:
                continue
            t.append(a[i])
            sf = True

    if len(t) == 0:
        return r

    if t[-1] != a[-1]:
        t.append(a[-1])

    for i in range(len(t)//2):
        b = t[i*2]
        c = t[i*2 + 1]
        k = r // b
        r += (c-b) * k

    return r

print(main())





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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));

    ll sum=0;
    int i =0;
    ll count = 0;
    while(i<n)
    {
        count = 0;
        int x = a[i];
        while(i<n and x == a[i]){i++;count++;}
        if(count%2==1)sum++;
    }

    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())-1
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

cnt=0 
       
for i in T:
    left = 0
    right = n
    mid = (right + left) // 2
    while right >= left:
        
        if S[mid] == i:
            cnt+=1
            break
        elif i < S[mid]:
            right = mid-1
        else:
            left = mid + 1
        mid = (right + left) // 2
    
    
print(cnt)
        



Measured memory_bytes: 16712
#include<cstdio>

int main(){
  int N,A[100000];
  scanf("%d",&N);
  for(int i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  int even=0;
  int odd=0;
  for(int j=0; j<N; j++){
    if(j%2==0){
      even+=A[j];
    } else {
      odd+=A[j];
    }
  }
  
  for(int i=0; i<N; i++){
    int b;
    b=even-odd;

    if(i>0){
      printf(" ");
    }
    printf("%d",b);
    
    int tmp_even=even;
    int tmp_odd=odd;
    even=tmp_odd+A[i];
    odd=tmp_even-A[i];
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n;
	rl(n);
	VL h(n);
	fr(i,0,n)
	{
		rl(h[i]);
	}
	VL ans(n,0);
	fr(i,0,n)
	{
		ll one=INT_MAX;
		ll onef=0,twof=0;
		if(i-1>=0)
		{
			one=ans[i-1]+abs(h[i]-h[i-1]);
			onef=1;
		}
		ll two=INT_MAX;
		if(i-2>=0)
		{
			two=ans[i-2]+abs(h[i]-h[i-2]);
			twof=1;
		}
		if(onef&&twof)
			ans[i]=min(one,two);
		else if(onef)
			ans[i]=one;
		else if(twof)
			ans[i]=two;
		else
			ans[i]=0;
	}
	wl(ans[n-1]);
	NL;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] x = new int[N];
        int ans = 0;

        for(int i = 0; i < N; i++){
            x[i] = sc.nextInt();
        }
        
        for(int i = 0; i< N; i++){
            ans += 2 * Math.min(x[i] - 0, K - x[i]);
        }
        System.out.println(ans);
    }
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll A; cin >> A;
    char op; cin >> op;
    ll B; cin >> B;
    
    ll ans;
    if (op == '+') ans = A + B;
    else ans = A - B;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        char[] n2 = sc.next().toCharArray();

        if(n[0]==n2[2] && n[1]==n2[1] && n[2]==n2[0]){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}


Measured memory_bytes: 21460
class Array
  def warshall_floyd
    v = size

    dist = map(&:dup)

    v.times do |k|
      v.times do |i|
        v.times do |j|
          cost = dist[i][k] + dist[k][j]
          dist[i][j] = cost if dist[i][j] > cost
        end
      end
    end

    dist
  end
end

N, M, R = gets.chomp.split.map(&:to_i)
r = gets.chomp.split.map(&:to_i)
matrix = Array.new(N + 1) { Array.new(N + 1, Float::INFINITY) }

(1..N).each do |i|
  matrix[i][i] = 0
end

M.times do
  a, b, c = gets.chomp.split.map(&:to_i)

  matrix[a][b] = c
  matrix[b][a] = c
end

waf = matrix.warshall_floyd

ans = Float::INFINITY

r.permutation(R).each do |paths|
  dist = 0

  paths.each_cons(2) do |from, to|
    dist += waf[from][to]
  end

  ans = dist if ans > dist
end

puts ans


Measured memory_bytes: 2556
#define _GLIBCXX_DEBUG 
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

int main() {
  double l;
  cin >> l;
  double hen = l/3;
  printf("%.10lf\n", hen*hen*hen);
  //cout << hen*hen*hen << endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> L(N);
    REP(i, N) {
        cin >> L[i];
    }
    
    ll max = 1000000000;
    ll min = 0;
    ll now = (max + min) / 2;
    while (max - min > 1) {
        int cnt = 0;
        REP(i, N) {
            cnt += (L[i] + now - 1) / now - 1;
        }
        if (cnt <= K) {
            max = now;
        } else {
            min = now;
        }
        now = (max + min) / 2;
    }
    cout << max << endl;
    
    return 0;
}


Measured memory_bytes: 4764
N=int(input())
L = [int(i) for i in input().split()]

Ld = sorted(L, reverse=False)

L_other=0
for i in range(N-1):
  L_other += Ld[i]

if (Ld[N-1] < L_other):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b;
    cin >> a >> b;
    int ans=max(a+b,max(a-b,a*b));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
const long long int INF_dp = 1<<29; 
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi v;
Vi a,b;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n; v.resize(n);
    rep(i,n)v[i]=i+1;
    a.resize(n); b.resize(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll tmp = 0;
    ll tmpa=0,tmpb=0;
    bool cka,ckb;
    while (tmpa==0 || tmpb==0){
        tmp++;
        cka = true,ckb=true;
        rep(i,n){
            if(a[i]!=v[i] && cka)cka = false;
            if(b[i]!=v[i] && ckb)ckb = false;
        }
        next_permutation(all(v));
        if(cka)tmpa = tmp;
        if(ckb)tmpb = tmp;
    }
    print(abs(tmpa-tmpb));

    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

using namespace std;

int main(int argc, char* argv[]){
  string a;
  int c=0;
  cin >> a;
  for(int i=0; i<3; i++){
  	if(a[i] == '1'){
  		c ++ ;
  	}
  }
  cout << c << endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int a, b;
    cin >> a >> b;
    int c = b - a;
    int cc = (c * (c - 1)) / 2;
    cout << cc - a << endl;
    return 0;
}

Measured memory_bytes: 256
n,k,*v=map(int,open(0).read().split())
m=[]
r=range
for i in r(n+1):
 for j in r(min(k,n)-i+1):
  t=sorted(v[:i]+v[:~j:-1])
  while t and(k-i-j)*t[0]<0:t.pop(0);j+=1
  m+=sum(t),
print(max(m))

Measured memory_bytes: 3060
N = int(input())
X = input()

pop_X = sum(map(int,list(X)))
X_10 = int('0b'+X,2)

r_0 = X_10%(pop_X+1)
diff_0 = 1%(pop_X+1)

zero_flag = False
if pop_X == 1:
    zero_flag = True
else:
    r_1 = X_10%(pop_X-1)
    diff_1 = 1%(pop_X-1)

answer = []


for i in range(N)[::-1]:
    if X[i]=='0':
        r = (r_0+diff_0)%(pop_X+1)
    else:
        if zero_flag:
            answer.append(0)
            diff_0 = (diff_0*2)%(pop_X+1)
            continue
        else:
            r = (r_1-diff_1)%(pop_X-1)
    count = 1
    while True:
        if r == 0:
            break
        pop = sum(map(int,list(bin(r)[2:])))
        r = r % pop
        count += 1
        
    answer.append(count)
    diff_0 = (diff_0*2)%(pop_X+1)
    if zero_flag:
        continue
    diff_1 = (diff_1*2)%(pop_X-1)

for i in answer[::-1]:
    print(i)

Measured memory_bytes: 12544
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    stack<char> sta;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(sta.empty()){
            sta.push(s[i]);
        }
        else if(s[i]==sta.top()){
            sta.push(s[i]);
        }
        else{
            sta.pop();
            ans++;
        }
    }
    cout<<ans*2<<endl;
    return 0;
}




Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int x,y,i;
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0)break;
        if(x>y){
                i=x;
                x=y;
                y=i;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int sx, sy, tx, ty; std::cin >> sx >> sy >> tx >> ty;

  std::vector<char> C;
  for(int i=sy; i<ty; i++) C.push_back('U') ;
  for(int i=sx; i<tx; i++) C.push_back('R') ;

  C.push_back('U');
  for(int i=sx; i<=tx; i++)  C.push_back('L') ; 
  for(int i=sy; i<=ty; i++) C.push_back('D') ;
  C.push_back('R');

  for(int i=sx; i<tx; i++) C.push_back('R') ;
  for(int i=sy; i<ty; i++) C.push_back('U') ;

  C.push_back('R');
  for(int i=sy; i<=ty; i++)  C.push_back('D') ;
  for(int i=sx; i<=tx; i++) C.push_back('L') ;
  C.push_back('U');

  // debug
  /*
  struct P {
    int x;
    int y;
  };
  std::cout << "start" << std::endl;
  P cur = { sx, sy };
  std::vector<std::unordered_map<int, bool>> used(2001);
  for(auto&& c : C) {
    if ( c == 'U') cur.y++;
    if ( c == 'D') cur.y--;
    if ( c == 'R') cur.x++;
    if ( c == 'L') cur.x--;

    
    if ( used[cur.x+1000].count(cur.y) != 0 ) {
      std::cout << "Two times visted " << std::endl;
      return 0;
    }
    if ( !((cur.x == sx && cur.y == sy) || (cur.x == tx && cur.y == ty)) ) used[cur.x+1000][cur.y] = true;
    if ( cur.x == tx && cur.y == ty ) std::cout << "GOAL" << std::endl;
    if ( cur.x == sx && cur.y == sy ) std::cout << "Start" << std::endl;
  }
  */
  for(auto&& c : C) std::cout << c ;
  std::cout << std::endl;

  return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);

  ll total = 1;
  ll ans = 0;
  while (total < B) {
    ans++;
    total--;
    total += A;
  }

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

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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 A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<bitset>
#include<array>
#include<cmath>
using namespace std;

typedef array<double,3> P3;

P3 operator-(P3 p){
  return P3{-p[0],-p[1],-p[2]};
}

P3 operator+(P3 a,P3 b){
  return P3{a[0]+b[0],a[1]+b[1],a[2]+b[2]};
}

P3 operator-(P3 a,P3 b){
  return a+-b;
}

P3 operator*(P3 p,double d){
  return P3{p[0]*d,p[1]*d,p[2]*d};
}
  
P3 operator/(P3 p,double d){
  return p*(1/d);
}

double dot(P3 a,P3 b){
  return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
}

double abs(P3 p){
  return sqrt(dot(p,p));
}

P3 cross(P3 a,P3 b){
  return P3{a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]};
}
  
P3 closest_to_origin(P3 a,P3 b){
  P3 x=a-b;
  return b+x*-dot(b,x)/dot(x,x);
}

bool contains(P3 a,double ra,P3 b,double rb=0){
  return abs(a-b)+rb<=ra;
}
  
bool intersects(P3 p,double r,P3 a,P3 b){
  if(abs(a-p)<=r||abs(b-p)<=r)return true;
  double d=abs(a-b);
  P3 ma=a-p;
  P3 mb=b-p;
  P3 cp=closest_to_origin(ma,mb);
  return abs(cp)<=r&&abs(ma-cp)<=d&&abs(mb-cp)<=d;
}

int main(){
  for(int N,M,R;cin>>N>>M>>R,N;){
    P3 s[2000];
    double sr[2000];
    for(int i=0;i<N;i++){
      double x,y,z;
      cin>>x>>y>>z>>sr[i];
      s[i]=P3{x,y,z};
    }
    P3 t[15];
    double tb[15];
    for(int i=0;i<M;i++){
      double x,y,z;
      cin>>x>>y>>z>>tb[i];
      t[i]=P3{x,y,z};
    }
    double x,y,z;
    cin>>x>>y>>z;
    P3 e{x,y,z};
    bitset<2000> bb[15];
    for(int i=0;i<M;i++){
      for(int j=0;j<N;j++){
	bb[i][j]=intersects(s[j],sr[j],t[i],e)&&!(contains(s[j],sr[j],t[i])&&contains(s[j],sr[j],e));
      }
    }
    double m=-1;
    for(int i=0;i<1<<M;i++){
      bitset<2000> b;
      double c=0;
      for(int j=0;j<M;j++){
	if(i>>j&1){
	  b|=bb[j];
	  P3 te=t[j]-e;
	  c+=tb[j]/dot(te,te);
	}
      }
      if(b.count()<=R){
	m=max(m,c);
      }
    }
    cout.precision(9);
    cout<<fixed<<m<<endl;
  }
}

Measured memory_bytes: 1360
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

ll a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	ll a, b, n; cin >> a >> b >> n;
	ll ans=0;
	if (n < b-1) { cout << a * n / b - a * (n / b) << endl; return 0; }
	else {
		if (n % b == b - 1)c = n;
		else c = n / b * b + b - 1;
		cout << a * c / b - a * (c / b) << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  string S;
  cin >> S;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S.substr(i, 2) == "AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 504
import java.util.*;
import static java.lang.Math.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] X = new int[m];
        for(int i=0; i<m; i++){
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int[] a = new int[m-1];
        for(int i=0; i<m-1; i++){
            a[i] = X[i+1] - X[i]; 
        }
        Arrays.sort(a);
        int ans = 0;
        for(int i=0; i<m-n; i++){
            ans += a[i];
        }
        System.out.println(ans);
    }
}

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

int main()
{
    string str;
    str = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    vector<string> list;
    int start = 0;
    do {
        int first = str.find_first_of(',', start);
        int tmp_start, tmp_end;
        if (start == 0)
        {
            tmp_start = start - 1;
            tmp_end = start;
        }
        else
        {
            tmp_start = start;
            tmp_end = start + 1;
        }
        if (first == string::npos) {
            list.push_back(str.substr(tmp_start + 1, str.size() - 1 - start));
            break;
        }
        list.push_back(str.substr(tmp_start + 1, first - tmp_end));
        start = first + 1;
    } while (true);

    int k;
    cin >> k;

    cout << list.at(k - 1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int x, y, z;

//Nx % y == z;

int main() {
	while(~scanf("%d %d %d", &x, &y, &z)) {
		bool flag = 0;
		for(int i = 1; i < 1e8; i++) {
			if((x * i) % y == z) {
				flag = 1;
				break;
			}
			else continue;
		}
		if(flag) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int binary_search(const vector<ll>& a ,ll key){
    int ng=-1, ok=(int)a.size();
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(a[mid] >= key){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    return ok;
}


int main(){
    int n; cin>>n;
    vector<ll> s(n);
    forin(s, n);
    int q; cin>>q;
    vector<ll> t(q);
    forin(t, q);

    int cnt=0;
    rep(i, q){
        if(t[i] == s[binary_search(s, t[i])]) cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r * R <= N; r++) {
        for (int g = 0; r * R + g * G <= N; g++) {
            if ((N - r * R - g * G) % B == 0) {
                ans++;
            }
        }
    }

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


Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> a(N);
  cin >> a;
  vector<vector<int>> ans = vect(H, vect(W, 0));
  int idx = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < a[i]; j++) {
      int r = idx / W;
      int c = idx % W;
      if (r % 2 == 1) c = W - 1 - c;
      ans[r][c] = i + 1;
      idx++;
    }
  }
  for (auto r : ans) cout << r << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

using namespace std;

struct point{
    double x,y;
    point(){}
    point(double x,double y):x(x),y(y){}
    point operator + (point &p){
        return point(x+p.x,y+p.y);
    }
    point operator - (point &p){
        return point(x-p.x,y-p.y);
    }
    point operator * (double k){
        return point(x*k,y*k);
    }
    point operator / (double k){
        return point(x/k,y/k);
    }
};

typedef vector<point>polygon;

int cmp(point a,point b)
{
    if(a.x!=b.x){
        return a.x<b.x;
    }else{
        return a.y<b.y;
    }
}

double cross(point a,point b)
{
    return a.x*b.y-a.y*b.x;
}

#define eps (1e-10)
#define CLOCKWISE 1
#define COUNTER_CLOCKWISE -1
int ccw(point a,point b,point c)
{
    point base=b-a;
    point linshi=c-a;
    if(cross(base,linshi)<eps){
        return CLOCKWISE;
    }else{
        return COUNTER_CLOCKWISE;
    }
}

polygon andrewscanf(polygon s)
{
    int n=s.size();
    if(n<3){
        return s;
    }
    sort(s.begin(),s.end(),cmp);
    polygon u,l;
    u.push_back(s[0]);
    u.push_back(s[1]);

    l.push_back(s[n-1]);
    l.push_back(s[n-2]);
    for(int i=2;i<n;i++){
        for(int j=u.size();j>=2&&(ccw(u[j-2],u[j-1],s[i])!=CLOCKWISE);j--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }
    for(int i=n-3;i>=0;i--){
        for(int j=l.size();j>=2&&(ccw(l[j-2],l[j-1],s[i])!=CLOCKWISE);j--){
           // cout<<s[i].x<<" "<<s[i].y<<" "<<l[j-2].x<<" "<<l[j-2].y<<" "<<l[j-1].x<<" "<<l[j-1].y<<endl;
            l.pop_back();
        }
        l.push_back(s[i]);
    }
    reverse(l.begin(),l.end());
    for(int i=u.size()-2;i>=1;i--){
        l.push_back(u[i]);
    }
    return l;
}

bool cmp1(point A,point B)
{
    return (A.y<B.y||(A.y==B.y&&A.x<B.x));
}

int main()
{
    polygon s;
    point temp;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>temp.x>>temp.y;
        s.push_back(temp);
    }
    polygon res=andrewscanf(s);
    int len=res.size();
    printf("%d\n",len);
    polygon tempp=res;
    sort(tempp.begin(),tempp.end(),cmp1);
    int index;
    for(int i=0;i<res.size();i++){
        if(res[i].x==tempp[0].x&&res[i].y==tempp[0].y){
            index=i;
        }
    }
    for (int i = 0; i < res.size(); i++)
		printf("%d %d\n", int(res[(i + index) % res.size()].x),int(res[(i + index) % res.size()].y));
    return 0;
}



Measured memory_bytes: 10556
import java.util.Scanner;

public class Main {
	private int a[];
	private long sum;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0) break;
			
			a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = scan.nextInt();
			}
			
			
			this.sum = a[0];
			for (int i = 0; i < n; i++) {
				long sum = 0;
				for (int j = i; j < n; j++) {
					sum += a[j];
					this.sum = Math.max(this.sum, sum);
				}
			}
			System.out.println(this.sum);
		}
	}
	
	private void debug() {
		System.out.println();
	}

}

Measured memory_bytes: 26548
Q = $stdin.gets.chomp.to_i
L = 100000
primes = (0..L).map{|a| a}
primes[0] = nil
primes[1] = nil
(2..L).each_with_index { |a,i|
  next unless primes[i]
  (2*i).step(L,i) { |j| primes[j] = nil }
}

primes.compact!

def bs(arr, v)
  # find index of arr i = min{ i | arr[i] <= v } || arr.size
  mi,ma = 0,arr.size
  i = nil
  while true
    j = (mi+ma)/2
    break if i == j
    #p [v,mi,j,ma]
    i = j
    if arr[i] < v
      mi = i
    elsif arr[i] == v
      break
    else
      ma = i
    end
  end
  i
end

Like2017s = [0] + primes.select { |p|
  i = bs(primes,(p+1)/2)
  i < primes.size && primes[i] == (p+1)/2
}

#p Like2017s

Q.times {
  l,r = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
  li = bs(Like2017s, l)
  ri = bs(Like2017s, r)
  #p [r, ri, Like2017s[ri], l, li, Like2017s[li], ri - li]
  puts ri - li + (Like2017s[li] == l ? 1 : 0)
}


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

int	main() {
	int H, W, N;
	cin >>H >>W >>N;
	int sr, sc;
	cin >>sr >>sc;
	string S, T;
	cin >>S >>T;
	int L=0;
	int R=W;
	int U=0;
	int D=H;
	for (int i=N-1; i>=0; i--) {
		char C=T.at(i);
		if (i<N-1) {
			if ('U'==C) {
				D++;
				D=min(D, H);
			} else if ('D'==C) {
				U--;
				U=max(U, 0);
			} else if ('L'==C) {
				R++;
				R=min(R, W);
			} else {
				L--;
				L=max(L, 0);
			}
		}
		C=S.at(i);
		if ('U'==C) {
			U++;
		} else if ('D'==C) {
			D--;
		} else if ('L'==C) {
			L++;
		} else {
			R--;
		}
		if ((U==D)||(L==R)) {
			cout <<"NO" <<endl;
			return 0;
		}
	}
	if ((sr>U)&&(sr<=D)&&(sc>L)&&(sc<=R)){
		cout <<"YES" <<endl;
	} else {
		cout <<"NO" <<endl;
	}
	return 0;
}


Measured memory_bytes: 776
#include <iostream>

int main()
{
	int a, b, c, cnt = 0;
	std::cin >> a >> b >> c;

	for (int i = a; i <= b; i++) 
	{
		if (c % i == 0) cnt++;
	}
	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll h,a;
    in>>h>>a;
    cout<<(h-1+a)/a<<endl;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    cin >> h[0];
    int x = h[0] - 1;
    rep(i, 0, n - 1){
        cin >> h[i];
        if(x > h[i]){
            cout << "No" << endl;
            return 0;
        }else if(x == h[i]){
            continue;
        }else{
            x = h[i] - 1;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = input() # 1行, 単数

if N == 'ABC':
  print("ARC")
else:
  print("ABC")


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

using namespace std;

long long a[200005];
long long a_plus_i[200005];

int main() {
	long long n;
	cin >> n;
	for (long long i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] + i <= n && a[i] + i >= 1) {
			a_plus_i[a[i] + i] += 1;
		}
	}
	long long pairs = 0;
	for (long long j = 1; j <= n; j++) {
		if (j - a[j] >= 1 && j - a[j] <= n) {
			pairs += a_plus_i[j - a[j]];
		}
	}
	cout << pairs << "\n";
	return 0;
}


Measured memory_bytes: 6680
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           vin l(n);
           rep(i,0,n)cin>>l[i];
           int ans=0;
           sort(all(l));
           rep(i,0,n-2){
            rep(j,i+1,n-1){
             rep(k,j+1,n){
               //cout<<l[k]<<endl;
               if(l[i]==l[j]||l[j]==l[k])continue;
               if(l[k]<l[j]+l[i]){
                 ans++;
               }
             }
            }
           }
           cout<<ans<<endl;
           
}

Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll n, m, v, p; cin>>n>>m>>v>>p;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    sort(a.begin(), a.end());

    // (ng, ok]
    int ng = -1, ok = n - 1;
    while(ok - ng > 1){
        int mid = (ng + ok) / 2;

        ll base = a[mid] + m;

        if((n - p) <= mid){
            ok = mid;
            continue;
        }

        if(base < a[(n - p)]){
            ng = mid;
            continue;
        }

        // 上位 P - 1 問、a[mid] より低い mid 問、a[mid] に M 人が 1 票入れる
        ll rest = v - (p - 1) - mid - 1;

        ll sum = 0;
        for(int i=0; i<n; i++){
            if(mid < i && i <= n - p && a[i] < base){
                sum += base - a[i];
            }
        }

        if(sum < rest * m) ng = mid;
        else ok = mid;
    }

    cout << (n - ok) << endl;

    return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;

const int N = 2e5+1;

ll n, k, s;
ll a[N], bit[N];
map<ll, int> id;

void update(int p) {
	while(p <= s) {
		bit[p]++;
		p += p&(-p);
	}
}

int get(int p) {
	int curr = 0;
	while(p > 0) {
		curr += bit[p];
		p -= p&(-p);
	}
	
	return curr;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll sum, ans = 0;
	
	sum = 0;
	cin >> n >> k;
	fo(i, 1, n, 1) {
		cin >> a[i];
		sum += (a[i]-k);
		id.insert({sum, 0});	
	}
	s = sz(id);
	
	int cnt = 1;
	foa(i, id) {
		i.se = cnt;
		cnt++; 
	}
	
	sum = 0;
	fo(i, 1, n, 1) {
		sum += (a[i]-k);
		int temp = id[sum];
		ans += (sum >= 0) + get(temp);
		update(temp);
	}
	
	cout << ans;
}

Measured memory_bytes: 15872