akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  set<int> s;
  vector<int> v;
  REP(i,6){
    int a;
    cin>>a;
    s.insert(a);
    v.push_back(a);
  }
  for(int i=1;i<=4;i++){
    if(count(v.begin(), v.end(), i)==3){
      P("NO");
      return 0;
    }
  }
  if(s.size()==3){
    P("NO");
  }else{
    P("YES");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    for(int i=1;;i++){
        int x;
        cin >> x;
        if(x==0) return 0;
        else cout << "Case " << i << ": " << x << endl;
    }
}


Measured memory_bytes: 3084
import java.util.Scanner;
import java.util.Arrays;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p[];
    p = new int[N];
    int n = 0;

    for(int i = 0;i < N;i++){
      p[i] = sc.nextInt();
    }


    for(int i = 0;i < N;i++){
      if(p[i] != i+1){
        n++;
      }
    }

    if(n > 2){
      System.out.println("NO");
    }else{
      System.out.println("YES");
    }




  }
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    vector<pair<pair<string,int>,int>> P(N);
    REP(i,N){
        string s;
        int p;
        cin >> s >> p;
        P[i] = make_pair(make_pair(s,-p),i);
    }
    sort(P.begin(), P.end());
    REP(i,N) cout << P[i].second + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,res=0;

int main(){
	cin>>n;
	int s=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		res+=s*x;
		s+=x;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
def daruma_drop(ls):
  if max(ls)==0:
    return 0
  
  can_drop = min(ls)
  dropped = [ v - can_drop for v in ls ]
  devided = []
  b_idx = -1
  for i in range(len(dropped)+1):
    if i==len(dropped):
      if b_idx!=-1:
        devided.append(dropped[b_idx:])
      break
    
    if b_idx==-1 and dropped[i]!=0:
      b_idx = i
      continue
    
    if b_idx!=-1 and dropped[i]==0:
      devided.append(dropped[b_idx:i])
      b_idx = -1
      continue
  
  return can_drop + sum(map(daruma_drop, devided))
  
n = int(input())
hs = list(map(int, input().split(' ')))
print(daruma_drop(hs))

Measured memory_bytes: 3188
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# 入力の受け取り
n,m = map(int,input().split())
# 配列入力の受け取り
lights = [list(map(int,input().split())) for _ in range(m)]
lightflg = list(map(int,input().split()))

ans = 0
for switch_bits in range(0,1<<n):
    allflg = True
    for i in range(m):
        flg = lightflg[i]
        on_count = 0
        for switch in lights[i][1:]:
            switch -= 1
            if switch_bits>>switch & 1:
                on_count += 1
        if on_count%2 != flg:
            allflg = False
            break
    if allflg:
        ans += 1

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while (1) {
        if (b >= c) {
            cout << "Yes\n";
            return 0;
        }
        c -= b;
        if (d >= a) {
            cout << "No\n";
            return 0;
        }
        a -= d;
    }
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int H,W,i,j;
	while(1) {
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		for (i=1; i<=H; i++) {
			for (j=1; j<=W; j++) {
				if(i==1 || i==H || j==1 || j==W) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
// Boudy is 32
// Tsunami is :gift_heart:
// Yassora is :sparkling_heart:
// Zetamoo is :heartbeat:
// Nour is Mo7nk
// Pillow is habd
// Lulu ...... meen Lulu?!!!
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

// watch this
using ll = long long;
//typedef long long LL;
#define ll long long
#undef ll

const int mxN = 100010;

long long get(long long X) {
	if (X % 4 == 3 || X <= 0)
		return 0;
	return X ^ get(X - 1);
}

int main(int argc, char** argv) {
#ifdef ONLINE_JUDGE	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
//	freopen("highways.in", "r", stdin);
//	freopen("highways.out", "w", stdout);
#endif

	long long L, R;
	cin >> L >> R;
	cout << (get(R) ^ get(L - 1)) << '\n';
	return 0;
}


Measured memory_bytes: 256
m, d = map(int, input().split())

cnt = 0

for mon in range(1, m + 1):
  for day in range(1, d + 1):
    d10 = day // 10
    d1 = day % 10
    if d1 >= 2 and d10 >= 2 and d1 * d10 == mon:
      cnt += 1
    
print(cnt)

Measured memory_bytes: 39664
#include <stdio.h>
int main(void)
{
    int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
    if (e - a > k)
    {
        printf(":(\n");
    }
    else
    {
        printf("Yay!\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

#define MAXN 100000
int N;
long long a[MAXN];

int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
  long long res = 0;
  long long cont = 0;
  for(int i = 0; i <= N; ++i) {
    if(i < N && a[i]) cont += a[i];
    else {
      res += cont / 2;
      cont = 0;
    }
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
  char N;
  char ans;
  cin >> N;
  if(N == 'A'){
    ans = 'T';
  }else if(N == 'T'){
    ans = 'A';
  }else if(N == 'G'){
    ans = 'C';
  }else if(N == 'C'){
    ans = 'G';
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

struct S {
    int s,t,x;
};

void solve() {
    int n,q;
    cin >> n >> q;
    set<int> se;
    vector<S> ss(n);
    //VI s(n), t(n), x(n);
    REP(i,0,n) cin >> ss[i].s >> ss[i].t >> ss[i].x;
    sort(all(ss), [](auto &l, auto &r) {return l.x < r.x;}); // (N logN)
    VI d(q);
    REP(i,0,q) cin >> d[i];
    REP(i,0,n) {
        se.insert(-ss[i].x + ss[i].s);
        se.insert(-ss[i].x + ss[i].t);
    }
    REP(i,0,q) se.insert(d[i]);
    map<int,int> mapping;
    int len = se.size();
    // O(N+Q)
    int i = 0;
    for (auto it = se.begin(); it != se.end(); ++it) {
        //mapping[*it] = distance(se.begin(), it);
        mapping[*it] = i++;
    }

    //set<int> se;
    se.clear();
    VVI imos(len);
    VI col(len, 1'000'000'000);
    REP(i,0,n) {
        int l = -ss[i].x + ss[i].s, r = -ss[i].x + ss[i].t;
        imos[mapping[l]].push_back(i+1);
        imos[mapping[r]].push_back(-(i+1));
        //cerr << i << ": " << l << " " << r << ", " << mapping[l] << " " << mapping[r] << endl;
    }
    // O(N logN + max(N,Q))
    REP(i,0,len) {
        for (auto &v: imos[i]) {
            //cerr << i << ": " << v << endl;
            if (v > 0) se.insert(v);
            else se.erase(-v);
        }
        if (!se.empty()) {
            //cerr << i << ": " << *se.begin() << endl;
            col[i] = min(col[i], *se.begin());
        }
    }
    //REP(i,0,len) dump(col[i]);
    
    REP(i,0,q) {
        int pos = col[mapping[d[i]]];
        //dump(mapping[d[i]]);
        if (pos == 1'000'000'000) {
            cout << -1 << endl;
        } else {
            cout << ss[pos-1].x << endl;
        }
    }
    
}

int main() {
    solve();
    
    return 0;
}

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

int main()
{
	int N, M, X;
	scanf("%d%d%d", &N, &M, &X);
	int A[M];
	int i, j, k;
	for (i = 0; i < M; i++)
		scanf("%d", &A[i]);

	int left = 0, right = 0;
	for (i = X; i > 0; i--) {
		for (j = 0; j < M; j++) {
			if (A[j] == i) {
				left += 1;
				break;
			}
		}
	}
	for (i = X; i < N + 1; i++) {
		for (j = 0; j < M; j++) {
			if (A[j] == i) {
				right += 1;
				break;
			}
		}
	}

	if (left < right)
		printf("%d\n", left);
	else
		printf("%d\n", right);

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX_LIMIT 100000
#define mp 
#define pb push_back
#define bb back
#define CHARS_TOTAL 256
#define e endl
/* For counting number of digits, directly do floor(log10(n)+1)*/
using namespace std;

ll power(ll x, unsigned ll y)  //Power in O(logn)
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
} 
int main(){
     string str,str1;
     ll c=0;
     ll i;
     cin>>str>>str1;
     for(i=0;str[i];i++){
         if(str[i]==str1[i]){
             c++;
         }
     }
     cout<<c<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer a = Integer.parseInt(sc.next());
        Integer b = Integer.parseInt(sc.next());

        // 主処理
        String strA = "";
        for (int i = 0; i < b; i++) {
            strA += a;
        }
        String strB = "";
        for (int i = 0; i < a; i++) {
            strB += b;
        }

        String[] arr = new String[]{strA, strB};
        Arrays.sort(arr);

        String result = arr[0];

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

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

  int a, b, c;
  cin >> a >> b >> c;
  int abc = a + b + c;
  if (abc <= 21) {
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }

  return 0;
};


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

int main(){
  int n,cou  = 0;
  cin >> n;
  for(int i = 0; n + 1 > i; i++)
    if(i%2)cou++;
  
  cout << 1.0*cou/n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int countNoOfTwos(int N){
    int noTwos = 0;
    while(N){
        if(N%2==0){
            noTwos++;
            N = N / 2;
        }else{
            break;
        }
    }
    return noTwos;
}
int main(){
    int N;
    cin>>N;
    int finNo,finMax = INT_MIN;
    for(int i=1;i<=N;i++){
        if(finMax < countNoOfTwos(i)){
            finMax = countNoOfTwos(i);
            finNo = i;
        }
    }
    cout<<finNo<<endl;
}

Measured memory_bytes: 3536
#include <iostream>
#include <map>
using namespace std;
 
typedef pair<int, int> ii;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, t;
	cin >> n;

	map<int, int> cnt;
	while (n--) {
		cin >> t;
		cnt[t]++;
	}

	int a = 0, b = 0;
	for (auto it = cnt.rbegin(); it != cnt.rend(); ++it) {
		if (it->second >= 2) {
			if (it->second >= 4) {
				if (a == 0) {
					a = it->first;
					b = it->first;
				}
				else b = it->first;
				break;
			}
			else {
				if (a == 0) a = it->first;
				else {
					b = it->first;
					break;
				}
			}
		}
	}

	cout << (long long)a * b;
}

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

int main() {
	int A,B;
  	cin >> A >> B;
  	
  	string s;
  	cin >> s;
  
  	bool can = true;
  	
  	for(int i = 0; i < A; i++) {
    	if(s.at(i) == '-') can = false;
    }
  
  	if(s.at(A) != '-') can = false;
  
  	for(int i = A + 1; i < A + B + 1; i++) {
    	if(s.at(i) == '-') can = false;
    }
  
  	if(can) {
    	cout << "Yes" << endl;
    }else {
    	cout << "No" << endl;
    }
  	
}

Measured memory_bytes: 256
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int INF = 1e9 + 7;
int _;

int main() {
	INIT
	ll n, k, last;
	cin >> n >> k;
	ll m = min(n % k, abs(n % k - k));
	cout << m;

	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc094/tasks/abc094_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, x;
  string r;

  cin >> a >> b >> x;

  r = x <= a + b && a <= x ? "YES" : "NO";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

  int ct = 0;
  int mx = 0;
  rep(i,3){
    if(s[i] == 'R') ct++;
    else{
      chmax(mx, ct);
      ct = 0;
    }
  }

  chmax(mx, ct);

  cout << mx << endl;

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int M, N;
int P[10000], C[500], E[500];

int dp[501][10001];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> M >> N;
  rep(i, M) cin >> P[i];
  rep(i, N) cin >> C[i] >> E[i];

  sort(P, P + M); reverse(P, P + M);
  rep(i, M-1) P[i+1] += P[i];

  fill(dp[0], dp[501], inf);
  dp[0][0] = 0;
  rep(i, N) rep(j, M+1) {
    dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    dp[i+1][min(j+C[i], M)] = min(dp[i+1][min(j+C[i], M)], dp[i][j] + E[i]);
  }

  int ans = 0;
  rep(i, M) ans = max(ans, P[i] - dp[N][i+1]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 42360
#include<bits/stdc++.h>
using namespace std;
int n, q;

bool bsearch(vector<int> s, int target) {
  int left = 0;
  int right = s.size();

  while (left != right) {
    int mid = (left+right)/2;
    if (s.at(mid) == target) {
      return true;
    } else if (s.at(mid) > target) {
      right = mid;
    } else {
      left = mid+1;
    }
  }
  return false;
}

int main() {
  cin >> n;
  vector<int> s(n);

  for(int i=0; i<n; i++) cin >> s.at(i);
  cin >> q;
  sort(s.begin(), s.end());
  int ans = 0;
  for(int i=0; i<q; i++) {
    int m; cin >> m;
    if (bsearch(s, m)){
      ans+=1;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3468
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s;cin >> s;

  if(s[0] == s[1] && s[1] == s[2])
    cout << "Yes";
  else if(s[1] == s[2] && s[2] == s[3])
    cout << "Yes";
  else
    cout << "No";



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
n,m,l=map(int,input().split())
a=[]
b=[]
c=[[0 for i in range(l)] for j in range(n)]
#print(c)
#for i in range(n):
#    la=list(map(int,input().split()))
#    a.append(la)
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]
#for i in range(m):
#    lb=list(map(int,input().split()))
#    b.append(lb)
for i in range(n):
    for j in range(l):
        tmp=0
        for k in range(m):
            tmp=tmp+a[i][k]*b[k][j]
        c[i][j]=tmp

#print(c)
for i in range(n):
    print(' '.join(str(c[i][j]) for j in range(l)))


Measured memory_bytes: 6888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
const int MAXN = 102;
int main(){
    int X,N;cin >> X >> N;
    bool p[MAXN];
    rep(i,MAXN)p[i] = true;
    rep(i,N) {
        int a;cin >> a;
        p[a] = false;
    }
    int i;
    for(i=X;i<=101;i++){
        if(p[i])break;
    }
    int j;
    for(j=X;j>=0;j--) {
        if(p[j])break;
    }
    int tmp;
    if(abs(X-i)>=abs(X-j))tmp = j;
    else tmp = i;
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    a,b,c = map(int, input().split())

    for i in range(100):
        if (a*(i+1))%b == c:
            print('YES')
            return
    print('NO')


if __name__ == '__main__':
    main()


Measured memory_bytes: 62976
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e5+2;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    string s;
    cin>>s;
    int a[]={1,-1};
    lp(i,0,2)
        lp(j,0,2)
            lp(k,0,2)
                if(s[0]-'0'+(s[1]-'0')*a[i]+(s[2]-'0')*a[j]+(s[3]-'0')*a[k]==7)
                    return cout<<s[0]<<(a[i]==1?"+":"-")<<s[1]<<(a[j]==1?"+":"-")<<s[2]<<(a[k]==1?"+":"-")<<s[3]<<"=7",0;
}


Measured memory_bytes: 3660
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(2);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    string a;
    cin >> a;
    int n = a.size();
    while(n--)
    {
        cout << 'x';
    }
    return 0;
}

Measured memory_bytes: 256
import math
import sys
from itertools import permutations
input = sys.stdin.readline

n=int(input())
arr=list(input())
if arr[-1]=='\n':
	arr.pop()

countW=0
for i in range(n):
	if arr[i]=='W':
		countW+=1

ans=0
for i in range(n-countW):
	if arr[i]=='W':
		ans+=1

print(ans)

Measured memory_bytes: 73072
n=int(input())
s=input()
ans=0
for i in range(1,n):
  s1=s[:i]
  s2=s[i:]
  li1=set([s1[j] for j in range(len(s1))])
  li2=set([s2[j] for j in range(len(s2))])
  ans = max(ans,len(li1 & li2))
print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  
  for (int i = 0; i < N; i++){

    int x = 0;
    cin >> x;
    
    int tmpA = x * 2;
    
    int tmpB = (K-x) * 2;

    if(tmpA<tmpB){
      sum += tmpA;
    }else{
      sum += tmpB;
    }

  }

  cout << sum << endl;

}


Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
ans = 'Yes'

if s[a]!='-':
  ans = 'No'
else:
  s = s.replace('-', '')
  if len(s)!=a+b:
    ans = 'No'
  if not all([i in '0123456789' for i in s]):
    ans = 'No'

    
print(ans)

Measured memory_bytes: 3060
var card={};
var a="123,234,345,456,567,678,789,111,222,333,444,555,666,777,888,999".split(",");
for(var i=0;i<a.length;i++){
   for(var j=0;j<a.length;j++){
      for(var k=0;k<a.length;k++){
         card[a[i]+a[j]+a[k]]=true;
         card[(a[i]+a[j]).split("").map(Number).sort(function(a,b){return a-b;}).join("")+a[k]]=true;
         card[a[k]+(a[i]+a[j]).split("").map(Number).sort(function(a,b){return a-b;}).join("")]=true;
         card[(a[i]+a[j]+a[k]).split("").map(Number).sort(function(a,b){return a-b;}).join("")]=true;
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var t=arr.shift()-0;
for(var i=0;i<t;i++){
   var n=arr.shift().split(" ").map(Number);
   var c=arr.shift().split(" ");
   var rgb={R:[],G:[],B:[]};
   c.forEach(function(v,i){
      rgb[v].push(n[i]);
   });
   var str="";
   for(var k in rgb){
      rgb[k].sort(function(a,b){return a-b;});
      if(rgb[k].length==3)str+=rgb[k].join("");
      else if(rgb[k].length==6)str+=rgb[k].join("");
      else if(rgb[k].length==9)str+=rgb[k].join("");
   }
   console.log((card.hasOwnProperty(str))?1:0);
}

Measured memory_bytes: 21192
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int h, m, s;
    int oh, om, os;

    void run(){
	while(sc.hasNext()){
	    h = sc.nextInt(); 
	    m = sc.nextInt();
	    s = sc.nextInt(); 
	    oh = sc.nextInt();
	    om = sc.nextInt();
	    os = sc.nextInt();

	    solve();
	}
    }

    int ah, am, as;

    void solve(){
	while(s>os){
	    os += 60;
	    om--;
	}
	while(m>om){
	    om += 60;
	    oh--;
	}
	ah = oh-h;
	am = om-m;
	as = os-s;

	System.out.println(ah+" "+am+" "+as);
    }
}
	    

Measured memory_bytes: 17176
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    vector<int> W(N), E(N);
    W[0] = 0;
    E[N - 1] = 0;
    int j = N - 1;
    rep(i, N - 1)
    {
        if (S[i] == 'W')
        {
            W[i + 1] = W[i] + 1;
        }
        else
        {
            W[i + 1] = W[i];
        }
    }
    for (int i = N - 1; i > 0; i--)
    {
        if (S[i] == 'E')
        {
            E[i - 1] = E[i] + 1;
        }
        else
        {
            E[i - 1] = E[i];
        }
    }
    int min = 10000000;
    rep(i, N)
    {
        if (min > W[i] + E[i])
        {
            min = W[i] + E[i];
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

struct SegmentTree{
    private:
        int n;
        vector<ll> node; //セグ木の持つデータの型を入力
        ll e = 0; //単位元
    public:
        ll F(ll a,ll b){
            return max(a,b);//二項演算
        }

        void init(vector<ll> v) {
            int sz = v.size();
            n = 1; while(n < sz) n *= 2;
            node.resize(2*n-1, e);

            rep(i,sz) node[i+n-1] = v[i];
            per(i,n-1) node[i] = F(node[2*i+1], node[2*i+2]);

            //rep(i,2*n-1) cout << node[i] << endl;
        }

        void update(int x,ll val){
            x += n-1;
            node[x] = val;
            while(x > 0) {
                x =(x-1)/2;
                node[x]=F(node[2*x+1],node[2*x+2]);
            }
        
        }

        ll get(int a, int b, int k=0, int l=0, int r=-1) {
            if(r < 0) r = n;
            if(r <= a || b <= l) return e;
            if(a <= l && r <= b) return node[k];

            ll vl = get(a, b, 2*k+1, l, (l+r)/2);
            ll vr = get(a, b, 2*k+2, (l+r)/2, r);
            return F(vl, vr);
        }
};

int n;
vector<ll> as,as_,bs;


void solve(){
    cin >> n;
    rep(i,n){
        ll a;
        cin >> a;
        as.push_back(a); 
        as_.push_back(a);
    }
    sort(as_.begin(),as_.end());
    rep(i,n){
        bs.push_back(lower_bound(as_.begin(),as_.end(),as[i])-as_.begin());
        //cout << bs[i] << endl;
    }
    ll m=as_.size();
    vector<ll> S;
    S.resize(m,0);
    SegmentTree s;s.init(S);
    rep(i,n){
        ll k=s.get(bs[i],m);
        s.update(bs[i],k+1);
    }
    ll ans=0;
    rep(i,m){
        ans=max(ans,s.get(i,i+1));
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 6380
S = input()

if 1 <= int(S[0:2]) <= 12:
  if 1 <= int(S[2:4]) <= 12:
    print('AMBIGUOUS')
  elif int(S[2:4]) == 0:
    print('MMYY')
  elif 13 <= int(S[2:4]) <= 99:
    print('MMYY')
elif int(S[0:2]) == 0:
  if 1 <= int(S[2:4]) <= 12:
    print('YYMM')
  elif int(S[2:4]) == 0:
    print('NA')
  elif 13 <= int(S[2:4]) <= 99:
    print('NA')
elif 13 <= int(S[0:2]) <= 99:
  if 1 <= int(S[2:4]) <= 12:
      print('YYMM')
  elif int(S[2:4]) == 0:
    print('NA')
  elif 13 <= int(S[2:4]) <= 99:
    print('NA')
  

Measured memory_bytes: 9236
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int x,y,id;
}a[200010];
struct edge
{
	int u,v,d;
	bool operator < (const edge &e) const
	{
		return d<e.d;
	}
}g[300010];
int cmpx(node a,node b)
{
	return a.x<b.x;
}
int cmpy(node a,node b)
{
	return a.y<b.y;
}
int n,m,fa[200010];
int find(int x)
{
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
int main()
{
	int ans=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		fa[i]=i;
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmpx);
	for (int i=1;i<n;i++) g[++m]=(edge){a[i].id,a[i+1].id,a[i+1].x-a[i].x};
	sort(a+1,a+n+1,cmpy);
	for (int i=1;i<n;i++) g[++m]=(edge){a[i].id,a[i+1].id,a[i+1].y-a[i].y};
	sort(g+1,g+m+1);
	for (int i=1;i<=m;i++)
		if (find(g[i].u)!=find(g[i].v))
		{
			ans+=g[i].d;
			fa[fa[g[i].u]]=fa[g[i].v];
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 5888
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)


l = 0
r = 2 * 10 ** 9 + 10 ** 6
while r - l > 1:
    m = (r + l) // 2
    cnt = ((A + m - 1) // m).sum()
    if cnt <= N + K:
        r = m
    else:
        l = m

print(r)

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

int main(void){
    int n,q;
    ll k;
    cin>>n>>k>>q;
    int x[n];
    rep(i,n) x[i]=k;
    int y[q];
    rep(i,q) {
    cin>>y[i];
    x[y[i]-1]++;
    }
    rep(i,n) if(x[i]>q){
        cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main(){
    int n;
    cin >> n;
    VEC(ll, a, n);
    sort(ALL(a));

    if(n % 2 == 0){
        int l = 0, r = n - 1;
        ll sum = 0;
        rep(i, n - 2){
            if(i % 2 == 0){
                sum += (2 * a[r]);
                r--;
            }
            else {
                sum -= (2 * a[l]);
                l++;
            }
        }
        sum += (a[r] - a[l]);
        cout << sum << endl;
    }
    else {
        int l = 0, r = n - 1;
        ll res = 0;
        ll sum = 0;
        //端がマイナス
        rep(i, n - 2){
            if(i % 2 == 0){
                sum += (2 * a[r]);
                r--;
            }
            else {
                sum -= (2 * a[l]);
                l++;
            }
        }
        sum -= (a[r] + a[l]);
        res = sum;

        //端がプラス
        sum = 0;
        r = n - 1;
        l = 0;
        rep(i, n - 2){
            if(i % 2 == 1){
                sum += (2 * a[r]);
                r--;
            }
            else {
                sum -= (2 * a[l]);
                l++;
            }
        }
        sum += (a[r] + a[l]);
        res = max(res, sum);
        cout << res << endl;
    }
}

Measured memory_bytes: 1024
from string import ascii_lowercase


def main():
    string = input()
    count = {}
    for lowercase in ascii_lowercase:
        count[lowercase] = 0
    for s in string:
        count[s] += 1
    answer = True
    for c in count.values():
        if c % 2:
            answer = False
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()



Measured memory_bytes: 3772
var 
	i,j,k,sum: longint;
    loop,loop_2,loop_3,ans: integer;
begin
	read(loop,loop_2,loop_3,ans);
	for i := 0 to loop do begin
        for j:= 0 to loop_2 do begin
            for k:= 0 to loop_3 do begin
               	if (i * 500 + j * 100 + k * 50 = ans) then inc(sum); 
            end;
        end; 
     end;
     writeln(sum);
 end.

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<int>() { 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 };
            var K = ReadInt();
            Console.WriteLine(list[K - 1]);
        }


        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int INF = 1<<30;

int N;
int w[2001], b[2001];
int costw[2001][2001], costb[2001][2001];
int bit[4002], bitC[4002];
int dp[2001][2001];

int sum( int i )
{
  int s = 0;

  while( i > 0 )
  {
    s += bit[i];
    i -= i & -i;
  }

  return s;
}

void add( int i, int x )
{
  while( i <= 2*N )
  {
    bit[i] += x;
    i += i & -i;
  }
}

int main()
{
  std::cin >> N;

  std::fill( (int*)dp, (int*)(dp+N+1), INF );

  rep( i, 2*N )
  {
    std::string c;
    int a;

    std::cin >> c >> a;

    if( c == "B" )
      b[a] = i+1;
    else
      w[a] = i+1;
  }

  repi( j, 0, N+1 )
  {
    if( j > 0 )
      add( w[j], 1 );
    //std::cout << "put: " << w[j] << std::endl;

    rep( i, 2*N+1 )
      bitC[i] = bit[i];

    repi( i, 0, N+1 )
    {
      if( i > 0 )
        add( b[i], 1 );
     /* std::cout << "put: " << b[i] << std::endl;
      repi( k, 1, 2*N+1 )
        std::cout << sum(k)-sum(k-1) << (k==2*N?'\n':' ');
      */
      if( i > 0 )
        costb[i-1][j] = sum( 2*N+1 )-sum( b[i] );
      if( j > 0 )
        costw[i][j-1] = sum( 2*N+1 )-sum( w[j] );
    }

    rep( i, 2*N+1 )
      bit[i] = bitC[i];
  }

 /* std::cout << "costb[i][j]" << std::endl;
  rep( i, N+1 ) rep( j, N+1 )
    std::cout << costb[i][j] << (j==N?'\n':' ');
  
  std::cout << "costw[i][j]" << std::endl;
  rep( i, N+1 ) rep( j, N+1 )
    std::cout << costw[i][j] << (j==N?'\n':' ');
*/
  dp[0][0] = 0;

  repi( i, 0, N+1 ) repi( j, 0, N+1 ) 
  {
    if( i > 0 )
      dp[i][j] = std::min( dp[i][j], dp[i-1][j]+costb[i-1][j] );
    
    if( j > 0 )
      dp[i][j] = std::min( dp[i][j], dp[i][j-1]+costw[i][j-1] );
  }

  /*std::cout << "dp[i][j]" << std::endl;
  rep( i, N+1 ) rep( j, N+1 )
    std::cout << dp[i][j] << (j==N?'\n':' ');
*/

  std::cout << dp[N][N] << std::endl;

  return 0;
}

Measured memory_bytes: 47232
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
 string s;
  int i;
  cin>>s;
  for(i=0;i<3;i++)
  {if(s[i]==s[i+1]){cout<<"Bad"<<endl;return 0;}}
  cout<<"Good"<<endl;
  
}
 

Measured memory_bytes: 3584
#include<stdio.h>

/*
N-1回、C以上D以下の数を足すか、引いて、AをBにできれば良い。
すなわち、あるi=0,1,...,N-1が存在して、
C*i - D*(N-1-i) <= B-A <= D*i - C*(N-1-i)
とできれば良い。ちょっと変形して、

(C+D)*i - D*(N-1) <= B-A <= (C+D)*i - C*(N-1)
C*(N-1) <= (C+D)*i - (B-A) <= D*(N-1)
となるような i が存在するかを調べればよい。
*/

int main(void){
	long long N,A,B,C,D, M1,M2,i;
	int ans;

	scanf("%lld %lld %lld %lld %lld", &N,&A,&B,&C,&D);
	M1 = C*(N-1);
	M2 = D*(N-1);
	ans = 0;
	for(i=0;i<N;i++){
		if(M1 <= (C+D)*i - (B-A) && (C+D)*i - (B-A) <= M2){
			ans = 1;
		}
	}
	if(ans == 0){
		printf("NO\n");
	}else{
		printf("YES\n");
	}
}

Measured memory_bytes: 128
#include<cstdio>

int wtf(int l, int r, int x) {
	int mid = (l + r) / 2;
	if (l == r) return mid;
	if (1ll * mid * (mid + 1) / 2 >= x) return wtf(l, mid, x);
	else return wtf(mid + 1, r, x);
}

int n;

int main() {
	scanf("%d", &n);
	printf("%d\n", wtf(1, n, n));
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> A[i][j];
    }
  }
  vector<bool> row_removed(H, true);
  vector<bool> col_removed(H, true);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (A[i][j] == '#') {
        row_removed[i] = false;
        col_removed[j] = false;
      }
    }
  }
  for (int i = 0; i < H; ++i) {
    if (row_removed[i]) continue;
    for (int j = 0; j < W; ++j) {
      if (col_removed[j]) continue;
      cout << A[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

void Main() {
    // input
    int N;
    cin >> N;
    int X[N+1];
    for (int i = 1; i <= N; i++) {
        cin >> X[i];
    }


    // translate
    u_int32_t ans = UINT32_MAX;
    for (int P = 1; P <= 100; P++) {
        u_int32_t sum = 0;
        for (int i = 1; i <= N; i++) {
            sum += (X[i] - P) * (X[i] - P);
        }
        
        ans = min(ans, sum);
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(void) {
  long long n;
  scanf("%lld", &n);
  if (n <= 9) {
    printf("%lld\n", n);
    return 0;
  }
  long long x = 9;
  while (x * 10 + 9 <= n) {
    x = x * 10 + 9;
  }
  long long y = x + 1;
  while (x + y <= n) {
    x = x + y;
  }
  int sum = 0;
  while (x) {
    sum += x % 10;
    x /= 10;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
while 1:
    n=input()
    if n==0: break
    d=[map(int,raw_input().split()) for i in range(n)]
    w=max([sum([d2[0] for d2 in d if d2[1]<=d1[1]<d2[2]]) for d1 in d])
    print "OK" if w<151 else "NG"

Measured memory_bytes: 4236
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;

int main(){

        int n; cin>>n;
        vector<int> a(n); rep(i,n) cin>>a[i];
        sort(a.begin(),a.end());
        int mx = a.back();
        int mn = a.front();
        int neerM = mn;
        for (int i = 1; i < n-1; i++) {
                if(abs((double)mx/2 - a[i]) < abs((double)mx/2 - neerM)) neerM = a[i];
        }
        cout << mx << " " << neerM << endl;
        return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	int a,b,c,i;
	int count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

#define MOD 1000000007
#define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    ll X;
    cin >> X;
    ll m = 100;
    for (int i = 0; i < 4000; ++i) {
        m = (ll)(m * 1.01);
        // print(i, m);
        if (m >= X) {
            cout << i + 1 << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define pii pair<int,int>
#define vii vector<int,int>
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define MOD 1000000007
ll a[3001] ;
ll dp[3001][3001] ;

ll fun(int s,int e){
	if(s>e) return 0 ;
	if(s==e) return a[s] ;
	if(dp[s][e] != -1)
	return dp[s][e] ;
//	dp[s][e] = max(min(fun(s-1,e-1)+a[s]-a[e],fun(s-2,e)+a[s]-a[s-1]), min(fun(s-1,e-1)+a[e]-a[s],fun(s,e-2)+a[e]-a[e-1])) ; 
	ll x =min(fun(s+1,e-1)+a[s]-a[e], fun(s+2,e)+a[s]-a[s+1]);
	ll y =min(fun(s+1,e-1)+a[e]-a[s], fun(s,e-2)+a[e]-a[e-1]);
	dp[s][e]=max(x,y);
	return dp[s][e] ;
}

int main(){
	fast ;
	int N ;
	cin >> N ;
	F(i,1,N) cin >> a[i] ;
	ms(dp,-1) ;
	cout << fun(1,N) << endl ;

}


Measured memory_bytes: 70784
#include <stdio.h>
#include <iostream>
#define G 10*10*10*10*10+1
int main(){
  char *a,*z;
  int j=0;
  z=new char[G];
  a=new char[G];
  scanf("%s",a);
  for(int i=0;i<G;i++){
    if(a[i]=='\0'){
      z[j]=a[i];
      break;
    }
    if((i+1)%2==1){
      z[j]=a[i];
      j++;
    }
  }
  printf("%s\n",z);
  return 0;
}

Measured memory_bytes: 384