akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  int end=0, start=0;
  int ans=0;
  bool flag=true;
  for (int i = 0; i < N; i++) {
    if (s[i][0]=='B') start++;
    if (s[i][s[i].size()-1]=='A') end++;
    if ((s[i][0]=='B' && s[i][s[i].size()-1]!='A') || (s[i][0]!='B' && s[i][s[i].size()-1]=='A')) flag=false;
    for (int j = 0; j < s[i].size()-1; j++) {
      if (s[i][j]=='A' && s[i][j+1]=='B') ans++;
    }
  }

  ans += min(start, end);
  if (flag && start>0 && end>0) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 768
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

A = [[] for _ in range(N+1)]

for i, py in enumerate(PY):
    A[py[0]].append([py[1], i])

City = []
for i in range(N+1):
    A[i] = sorted(A[i])
    for j, a in enumerate(A[i]):
        pref = i
        city = j+1
        City.append([a[1], str(pref).zfill(6) + str(city).zfill(6)])

City = sorted(City)
for city in City:
    print(city[1])

Measured memory_bytes: 137632
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int,int> M;
  int ans = 0;
  REP(i,n){
    int a;
    cin >> a;
    M[a] ^= 1;
    if(M[a] == 1){
      ans++;
    }else{
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, m, m2 = 1, i;
  cin >> n >> m;
  
  for(i = 0; i < m; i++){
    m2 *= 2;
  }
  
  cout << 1900 * m * m2 + 100 * (n - m) * m2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int n, max = -1, max2 = -1, maxindex = -1;
	cin >> n;
	rep(i, n)
	{
		int x;
		cin >> x;
		if (x >= max)								// もし、maxが更新されたら
		{
			max2 = max;								// maxだった値を2番目に大きい数として記録
			max = x;								// maxを更新
			maxindex = i;						    // 何番目の値が最大値か記録
		}
		else if (x > max2) max2 = x;				// max未満でmax2より大きかった場合
	}
	if (max2 == -1) max2 = max;						// 2番目に大きい値がなかった場合
	rep(i, n)
	{
		if (i != maxindex) cout << max  << endl;
		else               cout << max2 << endl;	// 最大値が除かれた場合2番目に大きい値
	}
	return 0;
}

Measured memory_bytes: 3620
#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<=W)&&(y+r<=H)&&(0<=x-r)&&(0<=y-r)){
       printf("Yes\n");
    }
    else{
       printf("No\n");
    }

  return 0;
  }

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

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> a(X), b(Y), c(Z);
    for (int i = 0; i < X; i++)
        cin >> a[i];
    sort(a.begin(), a.end(), greater<long long>());
    for (int i = 0; i < Y; i++)
        cin >> b[i];
    sort(b.begin(), b.end(), greater<long long>());
    for (int i = 0; i < Z; i++)
        cin >> c[i];
    sort(c.begin(), c.end(), greater<long long>());

    vector<long long> v;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            for (int k = 0; k < Z; k++) {
                if ((i + 1) * (j + 1) * (k + 1) <= K)
                    v.push_back(a[i] + b[j] + c[k]);
                else
                    break;
            }
        }
    }
    sort(v.begin(), v.end(), greater<long long>());
    for (int i = 0; i < K; i++)
        cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 1404
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;

typedef long long lli;

const lli INF = 1LL<<60;
const int MAXN = 9;
const int MAXT = 10005;
const int MAXW = 10005;

int N, M, W, T;
map<string, pair<lli,lli> > item;
int X[MAXN], Y[MAXN];
vector<pair<string, lli> > citem[MAXN];

lli cost[1<<MAXN], adv[1<<MAXN], dp[MAXT];

inline lli dist(lli x1, lli y1, lli x2, lli y2) {
  return labs(x2-x1) + labs(y2-y1);
}

int main() {
  while(cin >> N >> M >> W >> T) {
    item.clear();
    for(int i = 0; i < MAXN; ++i) citem[i].clear();

    for(int i = 0; i < M; ++i) {
      string S;
      lli V, P;
      cin >> S >> V >> P;
      item[S] = make_pair(V, P);
    }

    for(int i = 0; i < N; ++i) {
      int L;
      cin >> L >> X[i] >> Y[i];
      while(L--) {
        string R;
        lli Q;
        cin >> R >> Q;
        citem[i].push_back(make_pair(R, Q));
      }
    }

    // cost
    fill(cost, cost+(1<<MAXN), INF);
    for(int b = 1; b < (1<<N); ++b) {
      vector<int> id;
      for(int i = 0; i < N; ++i) {
        if(b & (1<<i)) id.push_back(i);
      }
      int num = id.size();
      do {
        lli tmp = dist(0, 0, X[id[0]], Y[id[0]]);
        for(int i = 0; i+1 < num; ++i) {
          tmp += dist(X[id[i]], Y[id[i]], X[id[i+1]], Y[id[i+1]]);
        }
        tmp += dist(X[id[num-1]], Y[id[num-1]], 0, 0);
        cost[b] = min(cost[b], tmp);
      } while(next_permutation(id.begin(), id.end()));
    }

    // adv
    fill(adv, adv+(1<<MAXN), 0);
    for(int b = 1; b < (1<<N); ++b) {
      vector<pair<int, int> > v;
      for(int i = 0; i < N; ++i) {
        if(b & (1<<i)) {
          for(int j = 0; j < citem[i].size(); ++j) {
            string &s = citem[i][j].first;
            lli p = citem[i][j].second;
            v.push_back(make_pair(item[s].first, item[s].second-p));
          }
        }
      }
      int num = v.size();
      lli dp[W+1];
      fill(dp, dp+W+1, 0);
      for(int i = 0; i <= W; ++i) {
        for(int j = 0; j < num; ++j) {
          if(i - v[j].first < 0) continue;
          dp[i] = max(dp[i], dp[i-v[j].first] + v[j].second);
        }
      }
      adv[b] = dp[W];
    }

    fill(dp, dp+T+1, 0);
    for(int i = 0; i <= T; ++i) {
      for(int b = 1; b < (1<<N); ++b) {
        if(i-cost[b] < 0) continue;
        dp[i] = max(dp[i], dp[i-cost[b]] + adv[b]);
      }
    }
    cout << dp[T] << endl;
  }
  return 0;
}

Measured memory_bytes: 1412
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    int n, k;
    readf("%s %s", &n, &k);
    readln;

    auto arr = readln.chomp.split.map!(to!int).array;
    
    arr.sort();
    
    auto ans = arr.take(k).sum;
    
    ans.writeln;
}

Measured memory_bytes: 2860
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	int r,c,a[100][100],sumfin=0;
	int sumi[100] = {};
	int sumj[100] = {};
	cin >> r >> c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> a[i][j];
			sumj[i] = sumj[i]+a[i][j];
		}
	}
	
	for(int i=0;i<c;i++){
		for(int j=0;j<r;j++){
			sumi[i] = sumi[i]+a[j][i];
		}
	}
	
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++)
			cout << a[i][j] <<" ";
		cout << sumj[i] << endl;
		sumfin += sumj[i];
	}
	for(int i=0;i<c;i++)
		cout << sumi[i] << " ";
	
	cout << sumfin << endl;

	return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main(){
    fast;
    string s;
    cin >> s;
    if(s[1] == 'B')
        cout << "ARC";
    else
        cout << "ABC";
    return 0;
}

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

char str[105][105];
char tmp[105];

int main() {
	/* freopen("input.in", "r", stdin);
	freopen("output.o", "w", stdout); */
	int h, w;
	scanf("%d %d", &h, &w);
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++) str[i][j] = '#';
	}
	for (int i = 1; i <= h; i++) {
		scanf("%s", tmp);
		int n = strlen(tmp);
		for (int j = 0; j < n; j++) str[i][j+1] = tmp[j];
	}
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++) printf("%c", str[i][j]);
		printf("\n");
	}
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
  if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int Len[55], Pat[55];

int rec(int level, int layer) {
  if (level == 0) {
    return 1;
  }

  if (layer <= 1) { // 1
    return 0;
  } else if (layer <= Len[level-1] + 1) { // 2
    return rec(level-1, layer-1);
  } else if (layer <= Len[level-1] + 2) { // 3
    // return Pat[level-1] + 1;
    return rec(level-1, layer-1) + 1;
  } else if (layer <= 2*Len[level-1] + 2) { // 4
    return Pat[level-1] + 1 + rec(level-1, layer - Len[level-1] - 2);
  } else { // 5
    return  2*Pat[level-1] + 1;
  }
}

signed main() {
  int N, X;
  cin >> N >> X;

  Len[0] = Pat[0] = 1;
  for (int i = 1; i <= N; i++) {
    Len[i] = Len[i-1] * 2 + 3;
    Pat[i] = Pat[i-1] * 2 + 1;
  }

  cout << rec(N, X) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 10000000
int main(){
    ll h,w,ans=inf;
    cin>>h>>w;
    for(int i=1;i<w;i++){
        ll mi=inf,la=-inf;
        ll a,b,c;
        a=h*i;
        b=max((w-i)*(h/2),h*((w-i)/2));
        c=min((w-i)*(h/2+(h%2==0?0:1)),h*((w-i)/2+((w-i)%2==0?0:1)));
        mi=min(a,min(b,c));
        la=max(a,max(b,c));
        ans=min(ans,la-mi);
    }
    for(int i=1;i<h;i++){
        ll mi=inf,la=-inf;
        ll a,b,c;
        a=w*i;
        b=max((h-i)*(w/2),w*((h-i)/2));
        c=min((h-i)*(w/2+(w%2==0?0:1)),w*((h-i)/2+((h-i)%2==0?0:1)));
        mi=min(a,min(b,c));
        la=max(a,max(b,c));
        ans=min(ans,la-mi);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  int c[h][w];
  rep(i, h) rep(j, w) cin >> c[i][j];

  int dp[h + 1][w + 1];

  int ans = 0;

  rep(i, h) rep(j, w) {
    dp[i][j] = (c[i][j] + 1) % 2;
    if (dp[i][j]) ans = 1;
  }

  for (int i = 1; i < h; ++i) {
    for (int j = 1; j < w; ++j) {
      if (c[i][j])
        dp[i][j] = 0;
      else {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        ans = max(ans, dp[i][j]);
      }
    }
  }

  cout << ans * ans << '\n';

  return 0;
}



Measured memory_bytes: 18336
N, M = map(int, input().split())
A = [1 for k in range(N)]
B = [0 for k in range(N)]

ans = 0
B[0] = 1
for k in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    if B[x] == 1 and A[x] >= 2:
        A[x] -= 1
        A[y] += 1
        B[y] = 1
    elif B[x] == 1 and A[x] == 1:
        A[x] -= 1
        A[y] += 1
        B[x] = 0
        B[y] = 1
    else:
        A[x] -= 1
        A[y] += 1

print(B.count(1))

Measured memory_bytes: 4784
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>

using namespace std;
using llint = long long int;
#define int long long int

vector<int> vadd, vxor;

bool check(int first, int last)
{
  int add = vadd[last + 1] - vadd[first];
  int _xor = vxor[last + 1] ^ vxor[first];
  return add == _xor;
}

signed main()
{
  int n;
  cin >> n;
  vadd.reserve(n + 1);
  vxor.reserve(n + 1);
  vadd.push_back(0);
  vxor.push_back(0);
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    vadd.push_back(vadd.back() + x);
    vxor.push_back(vxor.back() ^ x);
  }

  int ans = 0;
  int add = 0;
  int _xor = 0;
  int last = 0;
  for (int first = 0; first < n; first++)
  {
    if (check(first, last))
    {
      last++;
      while (last < n && check(first, last))
      {
        last++;
      }
      last--;
      ans += last - first + 1;
    }
    else
    {
      while (!check(first, last))
      {
        last--;
      }
      ans += last - first + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

using int_t = int;

int main() {
    int N, X;
    scanf("%d %d", &N, &X);
    int costSum = 0;
    int costMin = numeric_limits<int>::max();
    for (int i = 0; i < N; i++) {
        int cost;
        scanf("%d", &cost);
        costMin = min(cost, costMin);
        costSum += cost;
    }
    X -= costSum;
    printf("%d", N + X / costMin);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
n = STDIN.gets.to_i
m = []
n.times.each {
  as = STDIN.gets.split(' ').map { |x| x.to_i }
  a = as[0]
  xs = as.drop(2)
  m[a] = []
  for x in xs
    m[a][x] = 1
  end
}

for i in 1..n
  for j in 1..n
    x = if m[i][j].nil? then 0 else 1 end
    print x.to_s
    print " " if j != n
  end
  print "\n"
end

Measured memory_bytes: 8828
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int N;
  cin >> N;
  int i = 1;
  while((i<<1)<=N) i=i<<1;
  cout << i << "\n";

}

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

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

x = 30 * h + 0.5 * m
y = 6 * m % 360

kaku = min(abs(x-y), 360 - abs(x-y))

ans = math.sqrt(a**2 + b**2 - 2*a*b * math.cos(math.radians(kaku)))

print (ans)


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

int main(){

    ll n;
    cin >> n;
    string t;
    string in="MARCH";
    vector<ll> cnt(5,0);

    rep(i,n){
        cin >> t;
        rep(j,5){
            if(in[j]==t[0]){
                cnt[j]++;
            }
        }
    }

    ll ans=0;

    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout << ans  << endl;


    return 0;
}

Measured memory_bytes: 256
n,m=[int(j) for j in input().split()]
s=input()[::-1]
l=[]
for i in range(n+1):
    if s[i]=="0":
        l.append(i)
import bisect
ans=[]
c=0
while True:
    if c+m>=n:
        ans.append(n-c)
        break
    p=bisect.bisect_right(l,c+m)-1
    ans.append(l[p]-c)
    if l[p]-c==0:
        print(-1)
        exit()
    c=l[p]
    if c==n:
        break
print(*ans[::-1])




Measured memory_bytes: 52608
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int a;
string s;

int main() {
	cin >> a >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
signed main(){
  char s[4]={};

  for(int i=0;i<4;i++)
    cin>>s[i];
  
  if(s[0]=='Y' && s[1]=='A' && s[2] == 'K' && s[3] == 'I')
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
 
    return(0);
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

q = []
for e in p:
  q.append((e + 1) / 2)

ans = 0
for e in q[0:k]:
  ans += e
anses = [ans]

for i in range(n - k):
  ans -= q[i]
  ans += q[k + i]
  anses.append(ans)

print(max(anses))


Measured memory_bytes: 25060
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)

a = []
memo = []


# 相手がi番目を引いたときにだせる最大/最小のスコア
def dfs(turn, i):
    global memo, a
    if memo[turn][i] != -1:
        return memo[turn][i]

    ans = 0 if turn == 0 else INF
    for j in range(i + 1, len(a)):
        if j == len(a) - 1:
            s = abs(a[j] - a[i])
        else:
            s = abs(dfs(1 - turn, j))

        # X
        if turn == 0:
            ans = max(ans, s)
        # Y
        else:
            ans = min(ans, s)

    memo[turn][i] = ans
    return ans


def solve2(N, Z, W):
    global a, memo
    a = [W] + a
    memo = [[-1] * len(a) for _ in range(2)]
    return dfs(0, 0)


def solve(N, Z, W):
    global a
    ans = abs(a[-1] - W)
    if len(a) > 1:
        ans = max(ans, abs(a[-2] - a[-1]))
    return ans


def main():
    global a
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    print(solve2(N, Z, W))


if __name__ == '__main__':
    main()


Measured memory_bytes: 48728
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll sum;
ll x;
int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    sum ^= a[i];
  }
  if(!sum){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main() {
	int n;
	int q;
	int query;
	int t;
	int x;

	cin >> n >> q;

	stack<int> S[n];

	for (int i = 0; i < q; i++) {
		cin >> query >> t;

		if (query == 0) {
			cin >> x;
			S[t].push(x);
		}
		else if (query == 1) {
			if(S[t].size() != 0)
				cout << S[t].top() << endl;
		}
		else {
			if(S[t].size() != 0)
				S[t].pop();		
		}	
	}
}




Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct edge{ int to,cost; };
vector<int> dikstra(int s,vector<vector<edge>> G){
  typedef pair<int, int> P;
  const int INF = 1LL << 60;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(G.size(),INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  return d;
}

signed main(){

  int n, m, s, t; cin >> n >> m >> s >> t;
  s--, t--;
  vector<vector<edge>> yen(n), snu(n);
  for(int i = 0; i < m; i++){
    int u, v, a, b; cin >> u >> v >> a >> b;
    u--, v--;
    yen[u].push_back({v, a});
    yen[v].push_back({u, a});
    snu[u].push_back({v, b});
    snu[v].push_back({u, b});
  }

  auto dp = dikstra(s, yen);
  auto dp2 = dikstra(t, snu);

  vector<int> ans(n);
  int res = 1LL << 60;
  for(int i = n-1; i >= 0; i--){
    res = min(res, dp[i] + dp2[i]);
    ans[i] = res;
  }

  for(int i = 0; i < n; i++){
    cout << (int)1e15 - ans[i] << endl;
  }

  return 0;
}


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

int main(void){
	int n;
	int t=0;
	long long int a[100010]={0};
	bool p[100010]={0};
	cin >> n;

	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(int i=0; i<n; i++){
		if(a[i]==a[i+1]){i++;continue;}
		else t++;
	}

	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=100000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return (v[(size / 2) - 1] + v[size / 2]) / 2;
}


int main(){
    ll a,b;
    cin>>a>>b;
    if(a>12) cout<<b;
  else if(a<6) cout<<0;
    else cout<<b/2;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

i64 a, b, c;

int main() {
    cin >> a >> b >> c;
    i64 ans = (i64)1 << 62;
    ans = min(ans, a * b * (c-c/2*2));
    ans = min(ans, a * c * (b-b/2*2));
    ans = min(ans, b * c * (a-a/2*2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from bisect import *
N=int(input())
A=[int(input()) for _ in range(N)]
B=[int(input()) for _ in range(N)]
A=sorted(A)
B=sorted(B)
ans=1
mod=10**9+7
for a,b in zip(A,B):
  if a>b:
    a,b=b,a
  ans*=(bisect_right(A,b)-bisect_left(A,a))
  ans%=mod
print(ans)

Measured memory_bytes: 12244
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(list(map(int,input().split())))
if H%2 == 1:
    endGrid=(H-1,W-1)
else:
    endGrid=(H-1,0)

answer = []
def move(i,j):
    if (i,j) == endGrid:
        return()
    if i%2 == 0:
        if j<W-1:
            #print(movingOdd)
            answer.append(" ".join(map(str,[i+1,j+1,i+1,j+2])))
        else:
            answer.append(" ".join(map(str,[i+1,j+1,i+2,j+1])))
            #print(movingOdd)
    else:
        if j>0:
            answer.append(" ".join(map(str,[i+1,j+1,i+1,j])))
            #print(movingOdd)
        else:
            answer.append(" ".join(map(str,[i+1,j+1,i+2,j+1])))
            #print(movingOdd)
            
evenraw = True
movingOdd = False
for i in range(H):
    if evenraw:
        j = 0
        while j < W:
            #print(i,j,movingOdd,"right")
            if movingOdd:
                if a[i][j]%2 == 0:
                    move(i,j)
                else:
                    movingOdd = False
            else:
                if a[i][j]%2 == 1:
                    move(i,j)
                    movingOdd = True
            j += 1
        evenraw = False
    else:
        j = W-1
        while j >= 0:
            #print(i,j,movingOdd,"left")
            if movingOdd:
                if a[i][j]%2 == 0:
                    move(i,j)
                else:
                    movingOdd = False
            else:
                if a[i][j]%2 == 1:
                    move(i,j)
                    movingOdd = True
            j -= 1
        evenraw = True


print(len(answer))
for ans in answer:
    print(ans)


Measured memory_bytes: 16380
num,jump=map(int,input().split())
height=list(map(int,input().split()))

dp=[10**9]*(num)
dp[0]=0

for i in range(1,num):
    for j in range(1,min(i,jump)+1):
        dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]))

print(dp[-1])


Measured memory_bytes: 52448
// https://atcoder.jp/contests/dp/tasks/dp_b
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main()
{
    int n,k;
    cin >> n >> k;
    ll height[n];
    for(int i=0 ; i<n ; i++)
        cin >> height[i];
    ll dp[n];
    for(int i=0 ;i<n ; i++)
        dp[i] = 1e15;
    dp[0] = 0;

    for(int i=1 ; i<n ; i++)
    {
        for(int j=i-1 ; j>=max(0,(i-k)) ; j--)
            dp[i] = min(dp[i],dp[j] + abs(height[i] - height[j]));
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 5180
<?php
list($X, $N) = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

$hun = range(0, 200);
$P = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

$_P = array_diff($hun, $P);
sort($_P);

$min_abs = $X;
$ans = 0;

foreach ($_P as $p) {
    if (abs($X - $p) < $min_abs) {
        $min_abs = abs($X - $p);
        $ans = $p;
    }
}


/*
for ($i = 0; $i <= 100; $i++) {
    if ($X + $i)
}*/

echo $ans;

Measured memory_bytes: 16132
import java.io.BufferedInputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //System.setIn(Main.class.getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a+b+c >= 22) System.out.println("bust");
        else System.out.println("win");
    }

    private static int solve(String s, int n) {
        return n;
    }

    private static int nextInt(Scanner sc) {
        return Integer.valueOf(sc.nextLine());
    }
}

Measured memory_bytes: 23636
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];

        boolean hasZero = false;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            if (A[i] == 0) hasZero = true;
        }
        if (hasZero) {
            System.out.println(0);
            return;
        }

        long now = 1;
        for (int i = 0; i < N; i++) {
            int dNow = digit(now);
            int dA = digit(A[i]);
            int lNow = mostLeftNum(now, dNow);
            int lA = mostLeftNum(A[i], dA);
            int dl = digit(lNow*lA);
            //System.out.println("# "+dNow+ " "+dA+" "+dl);
            if (dNow + dA + dl >= 19) {
                System.out.println(-1);
                return;
            }
            now *= A[i];
        }

        System.out.println(now > 1_000_000_000_000_000_000L ? -1 : now);
    }

    private static int digit(long n) {
        int ret = 0;
        while (n > 0) {
            n /= 10;
            ret++;
        }
        return ret-1;
    }

    private static int mostLeftNum(long n, int d) {
        long x = 1;
        for (int i = 0; i < d; i++) {
            x *= 10;
        }
        return (int)(n/x);
    }
}


Measured memory_bytes: 61428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

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

}
int main(){
  
  ll a,b,x;
  cin>>a>>b>>x;
  double h=(2*x)/(a*b*1.0);
  
  double pi=4.0*atan(1.0);//π
 
  double unit_r=180.0/pi;//ラジアンから弧度法
  
  double atan(double t);
  
   if(h<=a){
    
    printf("%0.10lf\n",1.0*atan(b/h)*unit_r);
     
   }
   else{
     printf("%0.10lf\n",1.0*atan((2*b*pow(a,2)-2*x)/pow(a,3))*unit_r);
    
  }
  
}
    


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 510000;
const int MOD = 1000000007;

int main() {
	string s;
	ll k;
	cin>>s>>k;
	map<string,ll>a;
	for(int i=0;i<s.size();i++){
		string t="";
		for(int j=0;j<k;j++){
			if(j+i>=s.size()){
				continue;
			}
			t+=s[j+i];
			a[t]++;
		}
	}
	ll sum=0;
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
    	if(sum==k-1){
        std::cout << itr->first ;
        }// キーを表示
        sum++;
    }	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
int main(){
    long long int q,h,s,d,n,min1,min2;
    cin >> q >> h >> s >> d >> n;
    min1=min(4*q,min(2*h,s));
    min2=min(min1*2,d);
    cout << (n/2)*min2+(n%2)*min1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> list = new ArrayList<>();

    for(int i = 0; i < n; i++){
        list.add(sc.nextInt());
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i < j){
                sum += list.get(i)*list.get(j);
            }
        }
    }
    System.out.println(sum);
    

    

    }
}

Measured memory_bytes: 22484
#include <stdio.h>
#include <string.h>

main()
{
	int n,cou,t=0,h=0;
	
	char T[101],H[101];
	
	scanf("%d",&n);
	
	for(cou=0;cou<n;cou++){
		scanf("%s %s",T,H);
		
		if(strcmp(T,H)==0){t++;h++;}
		if(strcmp(T,H)< 0){h+=3;}
		if(strcmp(T,H)> 0){t+=3;}
	}
	
	printf("%d %d\n",t,h);
	
	return 0;
}

Measured memory_bytes: 604
<?php

while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$args[] = $value;
		if (count($args) >= 2) {
			break;
		}
	}
	if (count($args) >= 2) {
		break;
	}
}

$a = (int)$args[0];
$b = (int)$args[1];

$result = $a * $b - $a - $b + 1;
echo $result;

Measured memory_bytes: 4856
a = int(input())
if a >= 1800:
  print('1')
elif a >=1600:
  print('2')
elif a >=1400:
  print('3')
elif a>=1200:
  print('4')
elif a >= 1000:
  print('5')
elif a >=800:
  print('6')
elif a>=600:
  print('7')
else:
  print('8')

Measured memory_bytes: 9096
#include <stdio.h>
#include<string.h>

int main(void) {
  char a[1001];
  scanf("%s",a);
  
  int b=strlen(a);

  if(a[b-1]=='s')
  {printf("%s\n",strcat(a,"es"));}
  else
  {
    printf("%s\n",strcat(a,"s"));
  }
  return 0;
}

Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    FAST();
    ll n,i,j,k,a,b;
  map<ll,ll>m;
  m[1]=1;
  m[3]=1;
  m[5]=1;
  m[7]=1;
  m[8]=1;
  m[10]=1;
  m[12]=1;
  m[4]=2;
  m[6]=2;
  m[9]=2;
  m[11]=2;
  m[2]=3;
  cin>>a>>b;
  if(m[a]==m[b])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n),b(n);
    rep(i,n)cin>>a.at(i)>>b.at(i);
    int cnt=0;
    reverse(all(a));
    reverse(all(b));
    rep(i,n){
        a.at(i)+=cnt;
        if(a.at(i)%b.at(i)!=0){
            cnt+=b.at(i)-a.at(i)%b.at(i);
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1792
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <climits>
#include <queue>
#include <assert.h>

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

#define int long long

using namespace std;

int group(int x)
{
    if (x == 2) return 1;
    else if (x == 4 || x == 6 || x == 9 || x == 11) return 2;
    else return 3;
}

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int x, y;

    cin >> x >> y;
    if (group(x) == group(y)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

typedef pair<int, int> iPair;

int main() {
	int n; cin >> n;
	vector<iPair> j( n );
	
	REP( i, n ) cin >> j[i].first;

	int sum = 0;
	REP( i, n ) {
		cin >> j[i].second;
		if( j[i].first > j[i].second ) {
			sum += j[i].first - j[i].second;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________
template <typename T = long long, const int sz = 5 * 10000000> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO<int> io;
int n, m, k,i;
constexpr int MAX = 1e9 + 1;
constexpr int N = 200010;
int a[N], b[N];
int nn,now,ans;
main() {
    n = io.read(), m = io.read(), k = io.read();
    nn = n;
    rep(i, n) {
        a[i + 1] = io.read() + a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while(*io.now && *io.now <= 32) io.now++;
                while('0' <= *io.now and *io.now <= '9') io.now++;
            }
            break;
        }
    }
    rep(i, m) {
        b[i + 1] = io.read() + b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = nn;
    ans = now;
    for(i = 1; i <= m; i++) {
        while(b[i] + a[now] > k) now--;
        ans = max(ans, i + now);
    }
    io.write(ans);
}


Measured memory_bytes: 7884
#include<iostream>
#include<queue>
#include<vector>
#include<set>
using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;
    priority_queue<pair<int,int>> pq;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        pq.push({x, -i});
    }
    vector<ll> ans(n, 0);
    set<int> inds;
    int bef;
    while(!pq.empty()){
        int now = pq.top().first;
        if(!inds.empty()){
            ans[*inds.begin()] += (ll)(bef-now)*(int)(inds.size());
        }
        while(!pq.empty() && pq.top().first == now){
            inds.insert(-pq.top().second);
            pq.pop();
        }
        bef = now;
    }
    ans[0] += (ll)bef*n;
    for(int i = 0; i < n; i++)  cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 8692
#include<stdio.h>

int main(){
  int n,k,a[100000],mina=100001,minp=0,ans=0,cnt=0;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(mina>a[i]){
      mina=a[i];
      minp=i;
    }
  }
  ans=k;
  cnt=1;
  while(ans<n){
    ans+=k-1;
    cnt++;
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 512
using System;
class Program
{
	static void Main(string[] args)
	{
		string input = Console.ReadLine();

        int count = 0;
        for (int i = 0; i < 3; i++) 
        {
            int value = int.Parse(input[i].ToString()); 
            if (value == 1) {
                count++;
            }
        }

        //出力
		Console.WriteLine(count);
	}
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;


int main() {
    int N,x;
    cin >> N >> x;
    int a[110];
    for(int i=0;i<N;i++){
        cin >> a[i]; 
    }
    sort(a,a+N);
    int cnt =0;
    for (int j=0;j<N;j++){
        x -= a[j];
        cnt++;
        if(x>0) cnt += 0;
        else if(x==0) cnt=cnt;
        else {
            cnt--;
            break;
        }
    }
    if(x>0) cout << cnt-1 <<endl;
    else cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())

G = defaultdict(list)

AB = []
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a, b
    G[a].append(b)
    G[b].append(a)
    AB.append((a, b))

# print(f'{G=}')


def f(a, b):
    S = set([])
    Q = [1]
    while True:
        QQ = []
        for q in Q:
            S.add(q)
            for j in G[q]:
                if q == a and j == b:
                    continue
                if q == b and j == a:
                    continue
                if j not in S:
                    QQ.append(j)
        if len(QQ) == 0:
            break
        Q = QQ
        # print(f'{QQ=}')
    # print(f'{a=}, {b=}, {S=}')
    return 1 if len(S) != N else 0


cnt = 0
for a, b in AB:
    cnt += f(a, b)

# print(f'{cnt=}')
print(cnt)


Measured memory_bytes: 9472
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx         exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x)/log(base));
}
string k; ll d,n, dp[10005][105][2];
ll cc(ll ind,ll sum, ll p)
{
	if(ind==n && sum==0) return 1;
	if(ind>=n && sum!=0) return 0;
	if(dp[ind][sum][p]!=-1) return dp[ind][sum][p];
	ll x = (p==1)?9:(k[ind]-'0');
	ll ans=0;
	repi(i,0,x)
	{
		ans = ( ans + cc(ind+1, (sum+i)%d, (p==1) || (i < (k[ind]-'0'))) )%mod;
	}
	return dp[ind][sum][p] = ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	cin>>k;
    	cin>>d;
    	n=k.size();
    	repi(i,0,n)
    	{
    		repi(j,0,d)
    		{
    			dp[i][j][0]=-1; dp[i][j][1]=-1;
			}
		}
    	cout<<(cc(0,0,0)-1+mod)%mod;
	}
	return 0;
}

Measured memory_bytes: 20748
N = int(input())

A = list(map(int, input().split()))

M = [0] * N

for n in range(N):
    if n % 2 == 0:
        M[0] += A[n]
    else:
        M[0] -= A[n]

for m in range(1, N):
    M[m] = 2*A[m-1] - M[m-1]

print(" ".join(str(x) for x in M))


Measured memory_bytes: 84324
import math

prime = [True] * 55555
prime[0] = False
prime[1] = False

for i in range(2, int(math.sqrt(len(prime))) + 1):
    if prime[i]:
        j = i * 2
        while j < len(prime):
            prime[j] = False
            j += i

n = int(input())
ans = []

for i in range(2, len(prime)):
    if prime[i] and i % 10 == 1:
        ans.append(str(i))
    if len(ans) >= n:
        break
print(' '.join(ans))


Measured memory_bytes: 3444
#include <iostream>
int a[100010];
bool h[100010];
using namespace std;

int main()
{
	int n,m,f=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(a[x]<=a[y]) h[x]=1;
		if(a[y]<=a[x]) h[y]=1;
	}
	for(int i=1;i<=n;i++)
		if(!h[i]) f++;
	cout<<f<<endl;
}

Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
ll a[N];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for(int i = 0; i < 62; i++) {
        int cnt = 0;
        for(int j = 0; j < n; j++) {
            if((a[j] >> i) & 1) cnt++;
        }
        for(int j = 0; j < n; j++) {
            if((a[j] >> i) & 1) cnt--;
            ll ex = n - j - 1 - cnt;
            if((a[j] >> i) & 1) {
                ans += (1LL << i) % MOD * ex;
            } else {
                ans += (1LL << i) % MOD * cnt;
            }
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
  int n;
  int K[1500] = {0};
  int P[1500] = {0};
  cin >> n;
  for(int i = 1; i <= n; i++){
      cin >> K[i] >> P[i];
  }

  for(int i = 1; i <= n; i++){
      int x = K[i]%P[i];
      if(x == 0){
          cout << P[i] << endl;
      }
      else{
          cout << x << endl;
      }
  }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int K, X;

    cin >> K >> X;

    for (int i = X - (K - 1); i <= X + K - 1; i++)
    {
        cout << i;
        if (i != X + K - 1)
        {
            cout << " ";
        }
    }
    cout << endl;
    

    return 0;
}

Measured memory_bytes: 256
S =str(input())
if len(S) % 2 == 1:
    a = 1
    b = int((len(S) - 1) / 2)
    while True:
        if b - a < 0:
            break
        if S[b] == S[b + a] and S[b] == S[b - a]:
            a = a + 1
        else:
            break
    c = a + b
    print(c)
else:
    d = 0
    e = int(len(S) / 2 - 1)
    f = S[e]
    if S[e + 1] == f:
        d = d + 1
    while True:
        if e - d < 0:
            break
        if S[e - d] == f and S[e + d + 1] == f:
            d = d + 1
        else:
            break
    g = d + e + 1
    print(g)

Measured memory_bytes: 3188