akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
//#define abs Abs
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int SMOD = 1000000007;
const int NMOD = 1000000009;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
ll Abs(ll x){return (x<0 ? -x : x);}
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct xyz{
    xyz(){
        cin.tie(0), ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
    };
}xyzzy;


signed main(){
    int a, b;
    cin >> a >> b;
    cout <<(double)a/b fin;


  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[405];
ll memo[405][405];
ll dfs(int l, int r) {
    if (r <= l) return 0;
    if (memo[l][r] != -1) return memo[l][r];
    ll sum = 0;
    loops(i, l, r) sum += a[i];
    ll res = inf;
    loop(i, l, r) {
        mins(res, dfs(l, i) + dfs(i + 1, r) + sum);
    }
    return memo[l][r] = res;
}

void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];
    fillArray(memo, -1);
    cout << dfs(0, n - 1) << endl;
}

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


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

int main(void) {
    int N,a,ru,ld;
    int lastsum = 0;
    int maxsum = 0;
    cin >> N;
    vector<vector<int>> A(2,vector<int>(N));
    vector<vector<int>> sum(2,vector<int>(N));
    for(int i=0;i<2;i++) {
        for(int j=0;j<N;j++) {
            cin >> A[i][j];
        }
    }

    for(int i=0;i<N;i++) {
        sum[0][i] = lastsum + A[0][i];
        lastsum = sum[0][i];
    }

    lastsum = 0;
    for(int i=N-1;i>=0;i--) {
        sum[1][i] = lastsum + A[1][i];
        lastsum = sum[1][i];
    }

    for(int i=0;i<N;i++) {
        lastsum = sum[0][i] + sum[1][i];
        if(maxsum < lastsum) {
            maxsum = lastsum;
        }
    }

    cout << maxsum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int A = sc.nextInt();

	int B = sc.nextInt();

	int figure = 1;

	int ans = 0;

	while(figure < B){

	figure += A-1;

	ans++;	

  }

	System.out.println(ans);

 }
}

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

int main(){
	int n;
	cin >> n;
	if(n % 2 != 0){
		cout << "No" << endl;
		return 0;
	}
	string s1,s2;
	cin >> s1;
	int len = s1.size();
	for(int i=0;i<len / 2;i++){
		s2[i] = s1[i];
		//cout << s2[i] << " ";
	}
	int fg=0;
	for(int i=0;i<len/2;i++){
		//cout << s1[i + (len / 2)] << " " << s2[i];
		if(s1[i+(len / 2)] != s2[i]){
			fg=1;
		}
	}
	if(fg){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){

    int a , b , c;

    cin >> a >> b >> c;

    int d;

    if(a > b){
        
        d = a;

        a = b;

        b = d;

    }

    else{
        
        if(b > c){

            d = b;

            b = c;

            c = d;

        }

    }

    if(b > c){

        d = b;

        b = c;

        c = d;

    }

    if(a > b){

        d = a;

        a = b;

        b = d;

    }    

    cout << a << " " << b << " " << c << endl;

return 0;

}

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

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n,k;
	long long a ;
	cin >> n >> k;
	if (n%k == 0) cout << '0';
	else {
		a = min(n%k, k - n%k);
		cout << a;
	}

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x-r<0 || y-r<0 || W<x+r || H<y+r){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;

ll arr[100005];
int memo[100005];

int main()
{
    int n;
    cin >> n;
    
    memset (memo,0,sizeof(memo));
    int ans = 1;
    int track = 2;
    //if track = 0 it means that it is increasing, track = 1 means it is decreasing track = 2 is neutral
    for (int i = 1; i <= n; i++){
        cin >> arr[i];
        if (i >= 2){
          if (track == 2 && arr[i] != arr[i-1]){
            if (arr[i] > arr[i-1])
              track = 0;
            else
              track = 1;
          }
          else if (track != 2){
            if (arr[i] > arr [i-1] && track == 1){
              ans++;
              track = 2;
            }
            else if (arr[i] < arr [i-1] && track == 0){
              ans++;
              track = 2;
            }
          }
        }
    }
    
    
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D,i,j,sum;scanf("%d",&D);
  pair<int,vector<int>> ans;
  pair<int,int> k;
  int c[26],l[26],s[D][26],down[26],output[D];
  fill(l,l+26,-1);
  for(i=0;i<26;i++) scanf("%d",&c[i]);
  for(i=0;i<D;i++){
    for(j=0;j<26;j++){
      scanf("%d",&s[i][j]);
      down[j] = (i-l[j])*c[j];
    }
    sum = accumulate(down,down+26,0);
    ans = make_pair(-1000000000,vector<int>());
    for(j=0;j<26;j++){
      if(s[i][j]-sum+down[j] > ans.first){
        ans.first = s[i][j]-sum+down[j];
        ans.second = vector<int>({j});
      }
      else if(s[i][j]-sum+down[j] == ans.first){
        ans.second.push_back(j);
      }
    }
    k = make_pair(-1,-1);
    for(j=0;j<ans.second.size();j++){
      if(down[ans.second[j]] > k.first){
        k.first = c[ans.second[j]];
        k.second = ans.second[j];
      }
    }
    l[k.second] = i;
    output[i] = k.second;//0-indexed
  }
  const clock_t limit = CLOCKS_PER_SEC/10*19;
  int total,d,q,old,difo,difn,Plus,Minus;
  while(clock() < limit){
    d = rand() % D;q = rand() % 26;
    if(output[d] == q) continue;
    total = 0;
    old = output[d];
    difo = difn = 1;Plus = Minus = 0;
    for(j=d-1;j>=0 && output[j]!=q;j--) difn++;
    for(j=d-1;j>=0 && output[j]!=old;j--) difo++;
    total += s[d][q];total -= s[d][old];
    for(j=d;j<D && output[j]!=q;j++) Plus += difn;
    for(j=d;j<D && (j==d || output[j]!=old);j++) Minus += difo;
    total += c[q]*Plus;total -= c[old]*Minus; 
    if(total > 0){
      output[d] = q;
    }
  }
  for(i=0;i<D;i++) printf("%d\n",output[i]+1);
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}



int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,l;cin>>n>>l;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  vector<ll>ret;
  vector<P>b(n-1);
  rep(i,0,n-1){
    b[i]=MP(a[i]+a[i+1],i);
  }
  sort(ALLR(b));
  //cout<<b[0].fi spa b[0].se<<endl;
  if(b[0].fi<l)cout<<"Impossible"<<endl;
  else{
    cout<<"Possible"<<endl;
    ll x=b[0].se;
    vector<ll>ret;
    rrep(i,x+1,0)ret.PB(i+1);
    rep(i,x+1,n-1)ret.PB(i+1);
    reverse(ALL(ret));
    rep(i,0,n-1)cout<<ret[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 4084
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;

int main() {
    int N;cin>>N;
    vi P(N),Q(N);
    for (int i = 0; i < N; i++)cin>>P[i];
    for (int i = 0; i < N; i++)cin>>Q[i];
    if(P>Q)swap(P,Q);
    int ans=0;
    while(P<Q){
        next_permutation(P.begin(),P.end());
        ans++;
    }
    cout<<ans<<endl;
}

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

typedef long long int lli;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;

#define INF 1000000000
#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define foreach(v,c) for(typeof((c).begin()) v=(c).begin();v!=(c).end();++v)
#define all(a) a.begin(),a.end()
#define in(a,b) ((b).find(a)!=(b).end())
#define fill(a,v) memset(a,v,sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
#define pb push_back

int dp[110000];
int h[110000];
int n, k;
int main(){
  fastIO
  cin>>n>>k;
  for(int i = 0; i < n; i++){
    cin>>h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i = 2; i < n; i++){
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
    for(int j = max(i - k, 0); j <= i - 1; j++){
      dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
  }
  cout<<dp[n - 1]<<endl;
}

Measured memory_bytes: 1024
n = int(input())
h = list(map(int, input().split()))

cost = [9999999999] * n
cost[0] = 0

for x in range(n):
    if x + 1 < n:
        cost[x + 1] = min(cost[x + 1], cost[x] + abs(h[x + 1] - h[x]))
    
    if x + 2 < n:
        cost[x + 2] = min(cost[x + 2], cost[x] + abs(h[x + 2] - h[x]))

print(cost[n - 1])


Measured memory_bytes: 13924
#include<bits/stdc++.h> 
using namespace std;
long long n,a[100010],ans;
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        ans+=a[i]/2;
        a[i]%=2;
        if(a[i]&&i<n&&a[i+1]){
            ans++;
            a[i]--;
            a[i+1]--;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int a, b, c;
	cin >> a >> b >> c;

	if(c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3648
N, M, X = map(int, input().split())
AC = [[0 for i in range(M + 1)] for j in range(N)]
for i in range(N):
  AC[i] = list(map(int, input().split()))
x = 2 ** N
ans = -1
for i in range(x):
  p = i
  A = [0] * M
  summ = 0
  for j in range(N):
    y = p // (2 ** (N - j - 1))
    p = p -  (y * (2 ** (N - j - 1)))
    if y == 1 :
      summ = summ + AC[j][0]
      for k in range(M):
        A[k] = A[k] + AC[j][k + 1]
  tip = 0
  for j in range(M):
    if A[j] < X:
      tip = 1
  if tip == 0:
    if (ans == -1):
      ans = summ
    elif summ < ans:
      ans = summ
print(ans)

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

bool includePic(string A[], string B[], int Ar, int Ac, int m){
  int B_row, B_column;
  for(B_row = 0; B_row < m; B_row++){
    for(B_column = 0; B_column < m; B_column++){
      if(B[B_row][B_column] != A[Ar+B_row][Ac+B_column]) return false;
    }
  }
  return true;
}

int main(void){
  int n, m, A_row, A_column, B_row;
  cin >> n >> m;
  string A[n] = {}, B[m] = {};
  for(A_row = 0; A_row < n; A_row++){
    cin >> A[A_row];
  }
  for(B_row = 0; B_row < m; B_row++){
    cin >> B[B_row];
  }

  for(A_row = 0; A_row < n-m+1; A_row++){
    for(A_column = 0; A_column < n-m+1; A_column++){
      if(includePic(A, B, A_row, A_column, m)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=2005;
char s[maxn];
int a[maxn],b[maxn],c[2][maxn],n,ans=1e9;
struct info{
	int x,y;
}d[maxn];
inline bool operator < (const info &a,const info &b){
	return a.x>b.x;
}
inline void solve(int f){
	rep(l,0,n-1){
		int tot=0,res=0,k=1e9,maxi=0;
		rep(i,0,n-1){
			int pos;
			if(!f)pos=(i+l)%n;
			else pos=(i-l+n)%n;
			if(a[i]){
				if(!b[pos])d[++tot]=(info){c[!f][i],c[f][i]},res++;
			}else{
				if(b[pos])res++;
			}
		}
		d[++tot].x=0;
		sort(d+1,d+1+tot);
		rep(i,1,tot){
			k=min(k,2*(d[i].x+maxi));
			maxi=max(maxi,d[i].y-l);	
		}ans=min(ans,res+k+l);
	}
}
int main(){
	scanf("%s",s);
	n=strlen(s);
	rep(i,0,n-1)a[i]=s[i]-'0';
	scanf("%s",s);
	rep(i,0,n-1)b[i]=s[i]-'0';bool flag=0;
	rep(i,0,n-1)flag|=b[i];
	rep(i,0,n-1)if(a[i]){
		if(!flag){
			puts("-1");
			return 0;
		}
		rep(j,0,n-1)if(b[(i+j)%n]){c[0][i]=j;break;}
		rep(j,0,n-1)if(b[(i-j+n)%n]){c[1][i]=j;break;}
	}
	solve(0);
	solve(1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

ll n, m;
vector<ll> a;
vector<pll> bc;

int main(){
  cin >> n >> m;
  REP(i, n) {
    ll ai;
    cin >> ai;
    a.push_back(ai);
  }
  sort(a.begin(), a.end());

  REP(i, m) {
    ll b, c;
    cin >> b >> c;
    bc.push_back(pii(c, b));
  }

  sort(bc.begin(), bc.end(), greater<pll>());

  ll bc_idx = 0;
  REP(i, n) {
    if (bc_idx >= bc.size()) break;

    a[i] = max(a[i], bc[bc_idx].first);
    bc[bc_idx].second--;
    if (bc[bc_idx].second == 0) {
      bc_idx++;
    }

#ifdef DEBUG
    cout << a[i] << " ";
#endif
  }

  ll output = 0;
  REP(i, n) {
    output += a[i];
  }
  cout << output << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

int N, K, t[100001], d[100001];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++)    cin >> t[i] >> d[i];

    vector<P> p(N);
    for(int i=0;i<N;i++)    p[i] = P(d[i], t[i]);
    sort(p.begin(), p.end(), greater<P>());

    map<int, int> cnt;
    for(int i=0;i<K;i++){
        cnt[ p[i].second ]++;
    }

    ll ans = cnt.size() * cnt.size();
    for(int i=0;i<K;i++)    ans += p[i].first;

    priority_queue<P, vector<P>, greater<P>> q1;
    priority_queue<P> q2;
    for(int i=0;i<K;i++)    q1.push(p[i]);
    for(int i=K;i<N;i++)    q2.push(p[i]);

    ll res = ans;
    while(q1.size() && q2.size()){
        P p1 = q1.top();
        q1.pop();
        if(cnt[ p1.second ] <= 1)   continue;

        while(q2.size()){
            P p2 = q2.top();
            q2.pop();
            if(cnt[ p2.second ] >= 1)   continue;

            cnt[ p1.second ]--;
            cnt[ p2.second ]++;
            if(cnt[ p1.second ] == 0)   cnt.erase(p1.second);

            res += p2.first - p1.first + (2 * cnt.size() - 1);
            ans = max(ans, res);
            break;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 7668
import sys
n, y = map(int, input().split())
a = 0
while a <= n:
  for i in range(n-a+1):
    b = i
    c = n - a- b
    if a*10 + b*5 + c == y/1000:
      print(a, b, c)
      sys.exit()
  if a == n:
    print(-1, -1, -1)
  a += 1

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		int n=s.nextInt(),x=s.nextInt(),ar[]=new int[n],init[]=new int[n];
		for(int i=0;i<n;i++) {
			ar[i]=s.nextInt();
			init[i]=ar[i];
		}
		ar[0]=Math.min(ar[0],x);
		for(int i=1;i<n;i++) {
			ar[i]=Math.min(ar[i], x-ar[i-1]);
		}
		long res=0;
		for(int i=0;i<n;i++)
			res+=init[i]-ar[i];
		System.out.println(res);
	}
}


Measured memory_bytes: 58988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll inf = 1LL<<59;

int N, M, R;
vector<vector<ll>> d(210, vector<ll>(220, inf));
vector<int> r(10, -1);
bool seen[210];
ll ans = inf;

void floyd(){
    for(int k=1; k<=N; k++){
        for(int i=1; i<=N; i++){
            if(d[i][k] == inf) continue;
            for(int j=1; j<=N; j++){
                if(d[k][j] == inf) continue;

                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}

void dfs(int now, ll cost){
    bool all_visit = true;
    for(int i=0; i<R; i++) if(seen[r[i]] == false) all_visit = false;
    if(all_visit == true) ans = min(ans, cost);

    // -----------------
    
    for(int i=0; i<R; i++){
        if(now == -1){
            seen[r[i]] = true;
            dfs(r[i], 0);
            seen[r[i]] = false;
        } else if(seen[r[i]] == false && d[now][r[i]] != inf){
            seen[r[i]] = true;
            dfs(r[i], cost+d[now][r[i]]);
            seen[r[i]] = false;
        }
    }
}

int main(){
    cin >> N >> M >> R;
    for(int i=0; i<R; i++) cin >> r[i];
    for(int i=0; i<M; i++){
        int a, b; ll c;
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = c;
    }

    floyd();

    dfs(-1, 0);

    cout << ans << endl;

}

Measured memory_bytes: 640
C = []
3.times{C << gets.chomp.split(" ").map(&:to_i)}

s0 = C[0][0] + C[1][1] + C[2][2]
s1 = C[0][1] + C[1][2] + C[2][0]
s2 = C[0][2] + C[1][0] + C[2][1]

puts s0 == s1 && s1 == s2 ? 'Yes' : 'No'


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int A, B, K;
cin >> A >> B >> K;
// print(((B - A) + 1) / 2);
// print(K);
if(((B - A) + 1) / 2 < K){
    for(int i = A; i <= B; i++){ 
         print(i);
    }
return 0;
}


int f_e = A + K - 1, s_s = B - K + 1;

for(int i = A; i <= f_e ; i++){ 
     print(i);
}

for(int i = s_s; i <= B ; i++){ 
     print(i);
}


}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int a[31]={}; //????????°???????????????2^i???????????????a[i]??¨??????
long long c[31]={}; //m^(a^i)???1000000007??§?????£?????????
int main(){
	long long m,n;
	cin >> m >> n; //?????°??¨?????°???????????????
	int max=0,e=n;
	for(int i=30; i>=0; i--){
		a[i]=e/(long long)pow(2,i); //????????°???????????????2^i???????????????a[i]?????£??\
		e=e%(long long)pow(2,i);
		if(a[i]==1 && max==0) max=i; //????????°??§??????????????????
	}
	long long b=m;
	int l=0;
	while (l<max){
		c[l]=b;
		b=b*b;
		l++;
		if(b>1000000007) b=b%1000000007;
	}
	for(int i=0; i<max; i++){
		if(a[i]==1) b=b*c[i];
		if(b>1000000007) b=b%1000000007;
	}
	cout << b << endl;
}

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

int main(void){
  vector<int> input(3);
  cin >> input[0] >> input[1] >> input[2];
  sort(input.begin(), input.end());

  if(input[0] == 5 && input[1] == 5 && input[2] == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    d=[int(input()) for i in range(N)]
    print(len(set(d)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
def binSearch(array, num):
    n = len(array)
    l = -1
    r = n

    while l + 1 < r:
        m = (l + r) // 2
        if num <= array[m]:
            r = m
        else:
            l = m

    return r


n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
c.sort()

ans = 0
for i in range(len(b)):
    a_idx = binSearch(a, b[i])
    c_idx = binSearch(c, b[i] + 1)
    ans += a_idx * (n - c_idx)
print(ans)


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  set<int> s;
  int n; cin>>n;
  while (n--) {
    int x; cin>>x;
    if (s.count(x)) s.erase(x); else s.insert(x);
  }
  cout<<s.size()<<endl;
  

  return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long long LL;
const int MOD=1e9+7;
const int N=200005;

LL fac[N],inv[N];

LL C(int n,int m) {
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}

int main(void) {
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	rep(i,2,N-1) {
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
	}
	rep(i,2,N-1) inv[i]=inv[i-1]*inv[i]%MOD;
	int n,m,a,b; scanf("%d%d%d%d",&n,&m,&a,&b);
	LL ans=0;
	rep(i,1,n-a) {
		ans=(ans+C(b+i-2,i-1)*C(n+m-i-b-1,n-i)%MOD)%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

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

string S, T;

int main(void){
    
    cin >> S >> T;
    
    int s = S.size();
    for(int i = 0; i < s; ++i){
        string temp;
        temp.push_back(S[s - 1]);
        S = temp + S;
        if(S.substr(0, s) == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

	// 素因数分解 pair.firstで素数、pair.secondで対応する指数
	vector<pair<long long, long long> > prime_factorize(long long n) {
		vector<pair<long long, long long> > res;
		for (long long p = 2; p * p <= n; ++p) {
			if (n % p != 0) continue;
			int num = 0;
			while (n % p == 0) { ++num; n /= p; }
			res.push_back(make_pair(p, num));
		}
		if (n != 1) res.push_back(make_pair(n, 1));
		return res;
	}

	const int MAX = 210000;

	//二項係数を求める前処理 テーブルを作る　O(n)
	// facは階乗
	long long fac[MAX], finv[MAX], inv[MAX];
	void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < MAX; i++) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = mod - inv[mod%i] * (mod / i) % mod;
			finv[i] = finv[i - 1] * inv[i] % mod;
		}
	}

	// 二項係数計算
	ll COM(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
	}
}

int main() {

	int n;
	cin >> n;
	COMinit();
	vector<string> s(n);
	rep(i, n) cin >> s[i];

	rep(i, n) {
		sort(allof(s[i]));
	}
	sort(allof(s));

	vector<ll> num(n, 0);

	rep(i, n - 1) {
		Rep(j, i + 1, n) {
			bool same = true;
			rep(k, 10) {
				if (s[i][k] != s[j][k]) {
					same = false;
					break;
				}
			}
			if (same) num[i]++;
			else break;
		}
		i += num[i];
	}

	ll ans = 0;

	rep(i, n - 1) {
		ans += ((num[i] + 1) * num[i]) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12928
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s[] = new String[n];
		for (int i = 0; i < n; ++i)
			s[i] = sc.next();
		sc.close();
		int ans = 0;
		Arrays.sort(s);
		ans = 1;
		String st = s[0];
		for(int i = 1; i < n; ++i){
			String tmp = s[i];
			if(!st.equals(tmp)){
				st = tmp.substring(0);
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 69816
import sys
readline = sys.stdin.readline

import numpy as np

dp = np.full(10 ** 5 + 1, 10 ** 10, dtype = int)
dp[0] = 0

N,W = map(int,readline().split())
for i in range(N):
  w,v = map(int,readline().split())
  np.minimum(dp[v:], dp[:-v] + w, out = dp[v:])

for i in range(len(dp) - 1, -1, -1):
  if dp[i] <= W:
    print(i)
    break

Measured memory_bytes: 28480
n = input()
p = 2019
t = 1
y = 0
c = p*[0]

for x in map(int,n[::-1]):
  y+=t*x
  y%=p
  c[y]+=1
  t*=10
  t%=p

print(sum(i*(i-1)//2 for i in c)+c[0])

Measured memory_bytes: 9248
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int>a(N); rep(i, 0, N)cin >> a[i];
	sort(all(a));
	int l = -1, r = N;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		if (a[mid] >= K) {
			r = mid;
			continue;
		}
		int f[5500]; memset(f, 0, sizeof(f));
		f[0] = 1;
		rep(i, 0, N) {
			if (i == mid)continue;
			rrep(j, a[i], K)chmax(f[j], f[j - a[i]]);
		}
		if (count(f + K - a[mid], f + K, 1) > 0)r = mid;
		else l = mid;

	}
	cout << l + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  string s;unsigned int k;cin>>k>>s;
  if(k<s.size()){
  for(unsigned int i=0;i<k;i++){
    cout << s.at(i);
  }
    cout << "..."<<endl;
  }else{
    for(unsigned int i=0;i<s.size();i++){
    cout << s.at(i);
  }
  }
}

Measured memory_bytes: 3628
#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 MOD 1000000007

int main()
{
    Fast;

    ll n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    s[k-1]=s[k-1]-'A'+'a';
    cout<<s;
}


Measured memory_bytes: 256
<?php

$answer = 0;

//input
$n=intval(trim(fgets(STDIN)));
for($i=0;$i<$n;++$i){
    $p = intval(trim(fgets(STDIN)));

    $prices[] = $p;
    $answer += $p;
}

$answer -= max($prices)/2;

echo $answer;

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#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 each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  VAR(ll, K);
  rep(i, 0, (int)S.length()) {
    if (S[i] != '1') {
      if (i > K - 1) {
        print(1);
      } else {
        print(S[i]);
      }
      return;
    }
  }
  print(1);
}


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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong
#define be(x) x.begin(), x.end()
typedef pair<int, int> P;


signed main(){
	string s;
	cin >> s;
	if(s <= "2019/04/30")
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int n,m;
vector<bool> vis(50);
vector<vector<bool>> graph(50,vector<bool>(50,0));

void dfs(int x){
  if(vis[x]) return;
  vis[x]=1;
  REP(i,n){
    if(graph[x][i]){
      dfs(i);
    }
  }
  return;
}

int main()
{
  cin>>n>>m;
  REP(i,m){
    int a,b;
    cin>>a>>b;
    graph[a-1][b-1]=1;
    graph[b-1][a-1]=1;
  }

  int ans=0;
  REP(i,n){
    REP2(j,i+1,n){
      if(graph[i][j]){
        REP(k,n) vis[k]=0;
        graph[i][j]=0;
        graph[j][i]=0;
        dfs(0);
        bool f=1;
        REP(k,n){
          if(vis[k]==0) f=0;
        }
        if(f==0) ans++;
        graph[i][j]=1;
        graph[j][i]=1;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
	int value;
    struct node* prev,* next;
}Node;
Node* head;
void Init()
{
    head=(Node*)malloc(sizeof(Node));
    head->next=head;
    head->prev=head;
}

Node* FindNode(int x)
{
	Node*temp=head->next;
	while(temp!=head&&temp->value!=x)
        temp=temp->next;
    return temp;
}
void Insert(int x)
{
	Node*temp=(Node*)malloc(sizeof(Node));
    temp->value=x;
    head->next->prev=temp;
    temp->next=head->next;
    head->next=temp;
    temp->prev=head;
}

void Delete(Node*temp)
{
	if(temp==head)
        return ;
	temp->next->prev=temp->prev;
	temp->prev->next=temp->next;
    free(temp);
}

void DeleteFirst()
{
    Delete(head->next);
}
void DeleteLast()
{
	Delete(head->prev);
}
void DeleteValue(int x)
{
    Delete(FindNode(x));
}
void PrintList()
{
    Node*temp=head->next;
    int flag=0;
    while(1)
    {
        if(temp==head)
            break;
        else
        {
            if(flag++>0)
                printf(" ");
            printf("%d",temp->value);
            temp=temp->next;
        }
    }
    printf("\n");
}
int main()
{
	int n;
	int i;
	scanf("%d",&n);
	char str[12];
	int x;
	Init();
    /*
	while(n--)
	{
		scanf("%s%d",str,&x);
		if(str[0]=='i'){Insert(x);}
		else if(str[0]=='d'&&str[6]=='F')DeleteFirst();
		else if(str[0]=='d'&&str[6]=='L')DeleteLast();
		else if(str[0]=='d'){Delete(FindNode(x));}
	}
    */

	for(i = 0; i < n; i++) {
        scanf("%s %d", str, &x);
        if (str[0] == 'i') {
            Insert(x);
        }
        else if(str[0] == 'd') {
            if(str[6] == 'F')
                DeleteFirst();
            else if(str[6] == 'L')
                DeleteLast();
            else
                //DeleteValue(x);
                Delete(FindNode(x));
        }
    }
    /*
    Node* temp=head->next;
    while(temp->next!=head)
    {
        printf("%d ",temp->value);
        temp=temp->next;
    }
    printf("%d\n",temp->value);
    */
    PrintList();
	return 0;
}

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

using namespace std;

#define MAX 100

char data[MAX][MAX/2][MAX];
int plen, cnum, width, cspace, page;
int x, y;
string ss;

void init(){
  page = 0;
  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX/2 ; j++){
      for(int k = 0 ; k < MAX ; k++){
        data[i][j][k] = '.';
      }
    }
  }
}

bool check(){
  bool ok = true;
  if(ss.empty()) return ok;

  for(int i = 0 ; i < plen ; i++){
    for(int j = 0 ; j < cnum*width+cspace*(cnum-1) ; j++){
      if(data[i][j][page] != '.') return ok;
    }
  }
  return !ok;
}

void change(){
  y++;
  if(x == cnum){
    x = y = 0;
    page++;
  }else if(y == plen){
    y = 0;
    x++;
    if(x == cnum){
      x = y = 0;
      page++;
    }
  }
}

void insert(string &str){
  int size = str.size(), start;
  int end, p = 0;
  bool flg = true;

  while(flg){
    start = x*(width+cspace);
    if(size - p <= width){
      end = start + size - p;
      flg = false;
    }else{
      flg = true;
      end = start + width;
    }
    for(int i = start ; i < end ; i++, p++){
      if(p == size){ 
        flg = false;
        break;
      }
      data[y][i][page] = str[p];
    }
    change(); 
  }
}

void print(){
  if(!check()) page--;
  for(int k = 0 ; k <= page ; k++){
    for(int i = 0 ; i < plen ; i++){
      for(int j = 0 ; j < cnum*width+cspace*(cnum-1) ; j++){
        cout << data[i][j][k];
      }
      cout << endl;
    }
    cout << '#' << endl;
  }
  cout << '?' << endl;
}

int main(){
  string str;
  while(cin >> plen && plen){
    init();
    cin >> cnum >> width >> cspace;

    cin.ignore();
    x = y = 0;
    while(getline(cin,str), str != "?"){
      ss = str;
      if(str.empty()){
        change();
      }else{
        insert(str);
      }
    }
    print();
  }

  return 0;
}

Measured memory_bytes: 1700
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class CFennecVsMonster {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, K; in >> N >> K;
	    int H[N];
	    REP(i, N) {
	        in >> H[i];
	    }
	    sort(H, H+N);
	    ll ans = 0;
	    REP(i, N - K) {
	        ans += H[i];
	    }
	    out << ans << '\n';
	}
};


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

	CFennecVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100000

struct Point{
    typedef double Type;
    
    Type x,y;
    
    Point(Type X,Type Y){
        x = X;
        y = Y;
    }
    
    bool operator< (const Point &B) const{
        return x==B.x ? y < B.y : x < B.x;
    }
};

/* ConvexHull(??????) */

bool ccw(Point &base,Point &A,Point &B){
    return (A.x-base.x)*(B.y-base.y) - (A.y-base.y)*(B.x-base.x) >= 0; //double?????? -EPS
}

vector<Point> ConvexHull(vector<Point> s){
    vector<Point> upper,lower;
    int n = (int)s.size();
    
    if(n<3) return s;
    
    sort(s.begin(),s.end());
    
    upper.push_back(s[0]);
    upper.push_back(s[1]);
    lower.push_back(s[n-1]);
    lower.push_back(s[n-2]);
    
    for(int i=2;i<n;i++){
        for(int m = (int)upper.size();m>=2 && ccw(upper[m-2],upper[m-1],s[i]); m--){
            upper.pop_back();
        }
        upper.push_back(s[i]);
    }
    
    for(int i=n-3;i>=0;i--){
        for(int m = (int)lower.size();m>=2 && ccw(lower[m-2],lower[m-1],s[i]); m--){
            lower.pop_back();
        }
        lower.push_back(s[i]);
    }
    
    reverse(lower.begin(),lower.end());
    for(int i=(int)upper.size()-2;i>=1;i--) lower.push_back(upper[i]);
    
    return lower;
}

int calc(int n){
    double x,y;
    
    //scanf("%d",&n);
    
    vector<Point> vec,ans;
    
    for(int i=0;i<n;i++){
        scanf("%lf,%lf",&x,&y);
        vec.push_back(Point(x,y));
    }
    
    ans = ConvexHull(vec);
    
    printf("%d\n",n-(int)ans.size());
    
    return 0;
}

int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        calc(n);
    }
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

const int MAX_M = 8;

typedef pair<int, int> P;
typedef pair<int, vector<bool> > PM;

int n, m;

int solve(vector<P> g) {
  int ans = 0;
  stack<PM> st;
  vector<bool> checked;
  for(int i = 0; i < n; i++) checked.push_back(false);
  checked[0] = true;
  st.push(make_pair(0, checked));

  while(!st.empty()) {
    PM pm = st.top();
    st.pop();

    bool isAll = true;
    for (int i = 0; i < n; i++) {
      if (!pm.second[i]) {
        isAll = false;
        break;
      }
    }

    if (isAll) {
      ans++;
      continue;
    }

    for (int i = 0; i < m; i++) {
      vector<bool> cp_checked1;
      if (g[i].first == pm.first && !pm.second[g[i].second]) {
        for(int i = 0; i < n; i++) cp_checked1.push_back(pm.second[i]);
        cp_checked1[g[i].second] = true;
        st.push(make_pair(g[i].second, cp_checked1));
      }

      vector<bool> cp_checked2;
      if (g[i].second == pm.first && !pm.second[g[i].first]) {
        for(int i = 0; i < n; i++) cp_checked2.push_back(pm.second[i]);
        cp_checked2[g[i].first] = true;
        st.push(make_pair(g[i].first, cp_checked2));
      }
    }
  }
  return ans;
}

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

  vector<P> g;

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g.push_back(make_pair(a-1, b-1));
  }

  int ans = solve(g);
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int B[100001];
int N;
int A[100001];
int main(){
    REP(i,100000){
        B[i]=0;
    }
    cin>>N;
    REP(i,N){
        cin>>A[i];
        B[A[i]]++;
    }
    int i=0;
    int j=99999;
    while(i<=j){
        if(i>=100000)break;
        if(j<0)break;
        if(B[i]<=1){
           i++;
           continue;
        }
        if(B[j]<=1){
           j--;
           continue;
        }
        if(i==j){
           B[i]=B[i]%2;
           break;
        }
        B[i]--;
        B[j]--;
    }
    /*REP(i,10){
        cout<<B[i]<<endl;
    }*/
    int ans=0;
    REP(i,100000){
        ans+=B[i];
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

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

  string a;
  rep(i, s.size()) {
    if (s[i] == 'B') {
      if (!a.empty()) {
        a.pop_back();
      }
    } else {
      a += s[i];
    }
  }

  std::cout << a << std::endl;
  return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 200005

using namespace std;

vector<ll>graph[sz];

ll visited[sz],level[sz];

int main()
{
    ll n,m,u,v;

    scanf("%lld %lld",&n,&m);

    for(ll i=1; i<=m; i++)
    {
        scanf("%lld %lld",&u,&v);

        graph[u].push_back(v);
        graph[u].push_back(v);
    }

    queue<ll>q;

    memset(visited,0,sizeof(visited));

    visited[1]=1;
    level[1]=0;

    q.push(1);

    ll flag=0,kk=0;

    while(!q.empty())
    {
        u=q.front();
        q.pop();

        for(ll i=0; i<graph[u].size(); i++)
        {
            v=graph[u][i];

            if(!visited[v])
            {
                visited[v]=1;
                level[v]=level[u]+1;
                q.push(v);
            }

            if(v==n)
            {
                if(level[v]==2)
                {
                    flag=1;

                    break;
                }

                else
                {
                    kk=1;
                    break;
                }
            }
        }

        if(kk==1||flag==1)
            break;
    }

    if(flag==1)
        printf("POSSIBLE\n");

    else
        printf("IMPOSSIBLE\n");

    return (0);
}


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

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				// vector<int> v = {a[i], a[j], a[k]};
				// sort(v.begin(), v.end());
				// ans += (v[0] + v[1] > v[2]);
				if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
				ans += (max({a[i], a[j], a[k]}) < a[i] + a[j] + a[k] - max({a[i], a[j], a[k]}));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3192
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[] a=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] b=new long[s[0]+1],c=new long[s[0]+1];
		b[1]=a[0];
		c[1]=a[0]>0?a[0]:0;
		for(int i=1;i<s[0];i++){
			b[i+1]+=a[i]+b[i];
			c[i+1]+=(a[i]>0?a[i]:0)+c[i];
		}
		long ans=long.MinValue;
		for(int i=s[1];i<=s[0];i++){
			ans=Math.Max(Math.Max(ans,b[i]-b[i-s[1]]+c[i-s[1]]+c[s[0]]-c[i]),c[i-s[1]]+c[s[0]]-c[i]);
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 30812
#include<stdio.h>

int main(void){
	
	int a,b,c;
	
	scanf("%d %d %d\n",&a,&b,&c);
	
	if( (a<b)&&(b<c) ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
	
}

Measured memory_bytes: 584