akhauriyash/Code-Regression huggingface dataset:
from itertools import accumulate

n,k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**10
for i in range(n-k+1):
    ans = min(ans, x[i+k-1] - x[i] + min(abs(x[i]), abs(x[i+k-1])))
print(ans)


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

int main(){
  string S, T;
  cin >> S >> T;

  int cnt = 0;
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) != T.at(i)) cnt += 1; 
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3916
def core(s, t):
  result = len(t)
  for start in range(len(s) - len(t) + 1):
    diff = 0
    for i in range(len(t)):
      if t[i] != s[start + i]:
        diff += 1
    result = min([diff, result])
  
  return result
if __name__ == "__main__":
  strings = [input() for i in range(2)]
  print(core(strings[0], strings[1]))


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int,int> P;


int main() {
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int group = 0;
    char prev = ' ';
    rep(i, n) {
        if(s[i] == prev) continue;
        else {
            prev = s[i];
            group++;
        }
    }
    rep(i, k) {
        if(group == 1) {
            break;
        }
        else {
            group = max(1, group-2);
        }
    }
    cout << n-group << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)
	{
		int d=a;
		a=b;
		b=d;
	}
	if(a>c)
	{
		int d=a;
		a=c;
		c=d;
	}
	if(b>c)
	{
		int d=b;
		b=c;
		c=d;
	}
	if(a+b+c==5||a+b+c==7||(a+b==5&&c==7)||(a+b==5&&c==5)||(a+b==7&&c==5)||(a+b==7&&c==7)||(a==5&&b==5&&c==7)||(a==5&&c==5&&b==5))
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	
 } 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

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 (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;


int main() {

	ll N;
	cin >> N;

	ll amax = pow(10, 7), ans = 0;

	vector<ll> sum(amax);
	ll i = 1, tmp = 0;

	while (tmp < N) {
		sum[i] = sum[i -1] + i;
		tmp = sum[i];
		i++;
	}

	ll key1, key2= 0;

	rep(i, N + 1) {
		if (N == sum[i]) {
			key1 = i;
			break;
		}
		else if (sum[i] > N) {
			key1 = i;
			key2 = sum[i] - N;
			break;
		}
	}

	repl(i, 1, key1 + 1) {
		if (i != key2) {
			cout << i << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 81400
#include <bits/stdc++.h>
using namespace std;
int awa(int x){
	int s=0;
	while(x>=500){
		x-=500; 
		s+=1000;
	}
	while(x>=5){
		x-=5;
		s+=5;
	}
	return s;
}
int main(){
	int x;
	cin>>x;
	cout<<awa(x);
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
const int INF = (1 << 30)-1;

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

  int n; cin >> n;
  int dp[101010] = {};
  rep(i, 101010) dp[i] = INF;
  dp[0] = 0;

  for(int i = 1; i <= n; i++) {
    int tmp_6 = 1;
    while(true) {
      if(i-tmp_6 < 0) break;
      dp[i] = min(dp[i], dp[i-tmp_6]+1);
      tmp_6 *= 6;
    }

    int tmp_9 = 1;
    while(true) {
      if(i-tmp_9 < 0) break;
      dp[i] = min(dp[i], dp[i-tmp_9]+1);
      tmp_9 *= 9;
    }
  }

  cout << dp[n] << '\n';
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  int x[100005],y[100005],h[100005];
  for (int i=0; i<n; i++) {
    cin>>x[i]>>y[i]>>h[i];
  }
  for (int cx=0; cx<=100; cx++) {
    for (int cy=0; cy<=100; cy++) {
      int H;
      for (int i=0; i<n; i++) {
	if (h[i]>0) {
	  H=abs(x[i]-cx)+abs(y[i]-cy)+h[i];
	  break;
	}
      }
      bool flag=true;
      for (int i=0; i<n; i++) {
	if (h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),0)) {
	  flag=false;
	  break;
	}
      }
      if (flag) {
	cout<<cx<<' '<<cy<<' '<<H<<endl;
	return 0;
      }
    }
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (char)(c + 1);
    return 0;
    int n, m, z = 0;
    string s[22] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> s[i], s[i] = '#' + s[i] + '#';
    for (int i = 0; i <= m + 1; i++) s[0] += '#', s[n + 1] += '#';
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (s[i][j] == '.') {
        for (int k = 1; k <= n; k++) for (int l = 1; l <= m; l++) if (s[k][l] == '.') {
            int d[22][22] = {};
            d[i][j] = 1;
            queue<pii> q;
            q.push({i, j});
            while (!q.empty()) {
                int x = q.front().first, y = q.front().second;
                q.pop();
                if (s[x - 1][y] == '.' && !d[x - 1][y]) d[x - 1][y] = d[x][y] + 1, q.push({x - 1, y});
                if (s[x + 1][y] == '.' && !d[x + 1][y]) d[x + 1][y] = d[x][y] + 1, q.push({x + 1, y});
                if (s[x][y - 1] == '.' && !d[x][y - 1]) d[x][y - 1] = d[x][y] + 1, q.push({x, y - 1});
                if (s[x][y + 1] == '.' && !d[x][y + 1]) d[x][y + 1] = d[x][y] + 1, q.push({x, y + 1});
            }
            if (d[k][l]) z = max(z, d[k][l] - 1);
        }
    }
    cout << z;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
 
int main(void){
    ll a,b,c,d;
    string s,t;
 
    cin >> a >> b;//>> c >> d;
    //cin >> s >> t;

    if (a + b >= 10) cout << "error";
    else cout << a+b;
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    l = [[0, 0] for _ in range(N)]

    for i in range(N):
        l[i] = list(map(int, input().split()))

    l.sort()

    ans = 0

    for i, j in l:
        for _ in range(j):
            if M < 1:
                print(ans)
                return 0
            else:
                M -= 1
                ans += i

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 27820
using System;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            if (a > b)
                Console.WriteLine("a > b");
            else if (a < b)
                Console.WriteLine("a < b");
            else
                Console.WriteLine("a == b");
        }
    }
}



Measured memory_bytes: 15932
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int dp[3005][3005];

int main () {
  int n, t;
  cin >> n >> t;
  vector<pii> p(n);
  rep(i,n) {
    cin >> p[i].fi >> p[i].se;
  }
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,n) {
    rep(j,t) {
      chmax(dp[i+1][j], dp[i][j]);
      int nj = j+p[i].fi;
      if (nj < t) chmax(dp[i+1][nj], dp[i][j]+p[i].se);
    }
    int now = dp[i][t-1]+p[i].se;
    chmax(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
const int MAXN = 8005;
Mint fac[MAXN], invfac[MAXN];
Mint binom(ll a, ll b) {
	if (b < 0) return 0;
	if (b > a) return 0;
	return fac[a] * invfac[b] * invfac[a - b];
}
const int ZERO = 2000;
Mint G[4005][4005];
int main() {
	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = fac[i - 1] * i;
	invfac[MAXN - 1] = 1 / fac[MAXN - 1];
	for (int i = MAXN - 2; i >= 0; --i)
		invfac[i] = invfac[i + 1] * (i + 1);
	int n;
	scanf("%d", &n);
	vector<int> A(n), B(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &A[i], &B[i]);
		G[ZERO - A[i]][ZERO - B[i]]++;
	}
	for (int a = 0; a < 4005; ++a)
		for (int b = 0; b < 4005; ++b) {
			if (a) G[a][b] += G[a - 1][b];
			if (b) G[a][b] += G[a][b - 1];
		}
	Mint ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += G[A[i] + ZERO][B[i] + ZERO];
		ans -= binom(2 * (A[i] + B[i]), 2 * A[i]);
	}
	ans /= 2;
	printf("%d\n", ans.val);
}


Measured memory_bytes: 64512
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

//グラフ理論用変数
//vector<vector<llong> > graph(N);


int main(){
    llong X,Y;
    cin >> X >> Y;

    for(int i=0; i<=100; i=i+2){
        for(int j=0; j<=100; j=j+4){
            if(Y==(i+j) && X==(i/2+j/4)){
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3104
icase=0
if icase==0:
    bpmax=0
    x=int(input())
    for b in range(1,32):
        for p in range(2,10):
            bp=b**p
            if bp<=x:
                bpmax=max(bpmax,bp)
            else:
                break
    print(bpmax)        
            

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n; cin >> n;
    vector<lint> a(n); repeat(i, n) cin >> a[i];
    vector<lint> s(n, 0); s[0] = a[0]; repeat(i, n-1) s[i+1] += s[i] + a[i+1];
    
    lint ans = numeric_limits<lint>::max();
    repeat_from_to(i, 0, n-2) {
        lint snuke = s[i];
        lint raccoon = s[n-1] - snuke;
        ans = min(ans, abs(snuke - raccoon));
    }
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 3328
/*  ex4_1
    Rikuta  */

#include <stdio.h>
#include <math.h>
int main(void){
    int tree_number,monitor_range,ans;

    //入力受け取り
    scanf("%d %d",&tree_number,&monitor_range);

    //答えの計算　一人の監視員が見れる最大幅が2*monitor_range+1であり，少数は繰り上げるので
    ans=ceil((float)tree_number/(2*monitor_range+1));

    //答えの出力
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("substrcmp.in", "r", stdin);
       // freopen("substrcmp.out", "w", stdout);
#endif
}

void solve(){
    int n;
    cin >> n;
    vi nums(n);
    for(int &i:nums)
        cin >> i;
    int ans = INFLL;
    for(int i=0; i<101; i++){
        int beta_ans = 0;
        for(int j=0; j<n; j++){
            beta_ans += (nums[j]-i)*(nums[j]-i);
        }
        ans = min(ans, beta_ans);
    }
    cout << ans << endl;
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    char c; std::cin >> c;
    std::string ans("A");
    if('a' <= c && c <= 'z') ans = "a";
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] ints = new int[n];
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i ++){
            ints[i] = scanner.nextInt();
            if (map.containsKey(ints[i]))
                map.put(ints[i], map.get(ints[i])+ 1);
            else
                map.put(ints[i], 1);
        }
        long sum = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()){
            for (int i = 1; i < entry.getValue(); i ++)
                sum += i;
        }
        for (int i = 0; i < n; i ++)
            System.out.println(sum - map.get(ints[i]) + 1);
    }
}


Measured memory_bytes: 108588
from collections import deque
s = deque(list(input()))
q = int(input())
hanten = 0
for i in range(q):
  nyuuryoku = input().split()
  n = nyuuryoku[0]
  if len(nyuuryoku) == 1:
    hanten += 1
    continue
  else:
    f = int(nyuuryoku[1])
    c = nyuuryoku[2]
    if hanten%2 == 0:
      if f ==1:
        s.appendleft(c)
      else:
        s.append(c)
    else:
      if f == 1:
        s.append(c)
      else:
        s.appendleft(c)
if hanten%2 == 1:
  s.reverse()
ans = "".join(s)
print(ans)
  

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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<vector<int> > data(n+1, vector<int>(m+1));
  int sum = 0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<=m; j++) {
      if (j != m) { 
        cin >> data.at(i).at(j);
        sum += data.at(i).at(j);
      }
      else {
        data.at(i).at(j) = sum;
        sum = 0;
      }
    }
  }
  
  for (int j=0; j<=m; j++) {
    for (int i=0; i<=n; i++) {
      if (i != n) {
        sum += data.at(i).at(j);
      }
      else {
        data.at(i).at(j) = sum;
        sum = 0;
      }
    }
  }
  
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=m; j++) {
      if (j != m) cout << data.at(i).at(j) << " ";
      else cout << data.at(i).at(j) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3176
N,M = map(int, input().split())
X = [int(i) for i in input().split()]

if N >= M:
    print(0)
    exit()


X.sort()
L = [X[i+1] - X[i] for i in range(len(X)-1)]
L.sort()

print(sum(L[:(M-N)]))

Measured memory_bytes: 13840
fun solve(S: String) {
    val s = S.split("")
    val n = S.length
    var ans = "Yes"
    for (i in 1..(n - 1) / 2) {
//        println(i.toString() + " " + s[i])
//        println(((n - 1) / 2 - i + 1).toString() + " " + s[(n - 1) / 2 - i + 1])
//        println((i + ((n - 1) / 2 + 1)).toString() + " " + s[i + ((n - 1) / 2 + 1)])
//        println()
        if (s[i] != s[(n - 1) / 2 - i + 1] || s[i] != s[i + ((n - 1) / 2 + 1)]) {
            ans = "No"
            //break
        }
    }
    println(ans)
}

fun main() {
    val S = readLine()!!
//    val N = readLine()!!.toInt()
//    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(S)
}

Measured memory_bytes: 39816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,q=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0)
		{
			
		}
		else
		{
			q+=i;
		}
	}
	cout<<q;
} 

Measured memory_bytes: 3636
#include <cstdio>

int cs[7] = {0};
int main(){
	int n;
	double h;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%lf",&h);
		if(h < 165){
			cs[1]++;
		}
		else if(h >= 185){
			cs[6]++;
		}
		else{
			cs[(int)((h-155)/5)]++;
		}
	}
	for(int i = 1; i <= 6; i++){
		printf("%d:",i);
		for(int j = 0; j < cs[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
#define TIME (chrono::steady_clock::now().time_since_epoch().count())
const int MXN = 2e5+5;
int pots[MXN];
int p;

int pot(int a, int n)
  {
  if(n == 0)return 1;
  if(n % 2 == 0)return pot(a * a % p, n/2);
  return pot(a, n-1) * a % p;
  }

int main()
{
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n >> p;
  pots[0] = 1; FOR(i, 1, n)pots[i] = pots[i-1] * 10 % p;

  string s;
  cin >> s;

  if(p == 2 || p == 5)
    {
    LL res = 0;
    REP(i, n)
      {
      if((s[i]-'0') % p == 0)
        res += i+1;
      }
    cout << res << endl;
    return 0;
    }

  int hasz = 0;
  map<int, int> cnt;
  cnt[0]++;

  LL res = 0;
  REP(i, n)
    {
    hasz = (hasz * 10 + s[i] - '0') % p;

    int pt = pots[n-i-1];
//    debug(I(n-i-1), hasz, I(hasz*pt), pt, pot(pt, p-2), hasz * pot(pt, p-2) % p);

    res += cnt[hasz * pt % p];
    cnt[hasz * pt % p]++;
    }
  cout << res << endl;
}

Measured memory_bytes: 1684
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string O, E, s;

  std::cin >> O >> E;

  std::reverse(ALL(O));
  std::reverse(ALL(E));

  while (! O.empty()) {
    s.push_back(O.back());

    O.pop_back();

    if (! E.empty()) {
      s.push_back(E.back());

      E.pop_back();
    }
  }

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
  ll n, k; cin >> n >> k;
  vector<ll> arr(n);
  for(int i = 0;i < n;i++){
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  ll ans = 0;
  for(int i = 0;i < k;i++){
    ans = ans + arr[i];
  }
  cout << ans;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  //#define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  int32_t main()
  { 
    
    IOS
    int a,b,k;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
      if(i%k==0)
      {
        cout<<"OK";
        return 0;
      }

    }
    cout<<"NG";
    return 0;
  }
    

Measured memory_bytes: 3640
n,k = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9+7
plus = []
minus=[]
for i in A:
    if i>=0:
        plus.append(i)
    else:
        minus.append(i)
ok = False
if len(plus)>0:
    if n==k:
        ok = (len(minus)%2==0)
    else:
        ok = True
else:
    ok = (k%2==0)
ans = 1
if not ok:
    A.sort(key=abs)
    for i in range(k):
        ans *= A[i]
        ans %= mod
else:
    plus.sort()
    minus.sort(reverse=True)
    if k%2 == 1:
        ans *= plus.pop()
    P = []
    while len(plus) >= 2:
        P.append((plus.pop())*(plus.pop()))
    while len(minus) >= 2:
        P.append((minus.pop())*(minus.pop()))
    P.sort(reverse=True)
    for i in range(k//2):
        ans *= P[i]
        ans %= mod
print(ans)

Measured memory_bytes: 33308
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

const ll mod = 1e9 + 7;

void decompPrimepair(ll n, vector<pll> &ans)
{
  ll check = 0;
  while (n % 2 == 0)
  {
    check++;
    n /= 2;
  }
  ans.push_back(pll{2, check});

  ll m = sqrt(n);
  ll i = 3;
  while (true)
  {
    if (n == 1)
    {
      break;
    }
    if (i > m)
    {
      ans.push_back(pll{n, 1});
      break;
    }
    if (n % i == 0)
    {
      ll check = 0;
      while (n % i == 0)
      {
        check++;
        n /= i;
        m = sqrt(n);
      }
      ans.push_back(pll{i, check});
    }
    i += 2;
  }
}

ll power_ll_p(ll a, ll b, ll p)	//F_pでのべき
{
  if (b > p)
  {
    b %= (p - 1);//位数p-1
  }
  if (b == 0)
  {
    return 1;
  }
  if (b % 2 == 0)
  {
    ll t = power_ll_p(a, b / 2, p);
    return t * t % p;
  }
  else
  {
    return a * power_ll_p(a, b - 1, p) % p;
  }
}

ll extgcd(ll a, ll b, ll&x, ll&y)
{
  if (b == 0)
  {
    x = 1;
    y = 0;
    return a;
  }
  else
  {
    ll q = a / b;
    ll g = extgcd(b, a - q * b, x, y);
    ll z = x - q * y;
    x = y;
    y = z;
    return g;
  }
}

//modp逆元
ll inversemod(ll a, ll p)
{
  ll x, y;
  extgcd(a, p, x, y);
  x %= p;
  if (x < 0)
  {
    x += p;
  }
  return x;
}

int main()
{
  int n;
  cin >> n;
  ll a[10010], copy[10010];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    copy[i] = a[i];
  }
  sort(a, a + n);
  vector<pll> v(0);
  decompPrimepair(a[0], v);
  for (int i = 1; i < n; i++)
  {
    int size = v.size();
    for (int j = 0; j < size; j++)
    {
      ll check = 0;
      ll p = v[j].first;
      while (a[i] % p == 0)
      {
        check++;
        a[i] /= p;
      }
      v[j].second = max(check, v[j].second);
    }
    vector<pll> u(0);
    decompPrimepair(a[i], u);
    v.insert(v.end(), u.begin(), u.end());
  }

  ll l = 1;
  int size = v.size();
  for (int j = 0; j < size; j++)
  {
    l *= power_ll_p(v[j].first, v[j].second, mod);
    l %= mod;
  }
  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans += inversemod(copy[i], mod);
    ans %= mod;
  }
  ans *= l;
  ans %= mod;
  cout << ans << "\n";
}

Measured memory_bytes: 1020
require 'prime'

N, D = $<.gets.chomp.split.map(&:to_i)
X = $<.read.split(?\n).map {|x| x.split.map(&:to_i)}

def integer?(a, b, d)
  sum =
    Array
      .new(d) {|i| (a[i] - b[i]) ** 2}
      .reduce(:+)

  Prime.prime_division(sum).all? {|prime, count| count % 2 == 0}
end

X
  .combination(2)
  .count {|a, b| a != b && integer?(a, b, D)}
  .tap(&method(:puts))

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define int long long
#define inf (int)(3e18)
#define mod (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int mod_pow(int x,int y,int z){
	int res=1;
	while(y>0){
		if(y&1)res*=x;
		x*=x;x%=z;
		y>>=1;
		res%=z;
	}
	return res;
}
struct mat{
	int m;
	vector<vector<int>>ma;
	mat(int x,int y,int z){
		m=z;
		ma.resize(x);
		rep(i,x)ma[i].resize(y);
		rep(i,x)rep(j,y)ma[i][j]=0;
	}
	mat operator*(mat a){
		assert(ma[0].size()==a.ma.size());
		mat res(ma.size(),a.ma[0].size(),m);
		rep(i,ma.size()){
			rep(j,a.ma[0].size()){
				rep(k,a.ma.size()){
					res.ma[i][j]+=ma[i][k]*a.ma[k][j]%m;
					res.ma[i][j]%=m;
				}
			}
		}
		return res;
	}
	mat pow(int x){
		assert(ma.size()==ma[0].size());
		mat res(ma.size(),ma.size(),m),me(ma.size(),ma.size(),m);
		rep(i,ma.size())res.ma[i][i]=1;
		me.ma=ma;
		while(x>0){
			if(x&1)res=res*me;
			me=me*me;
			x>>=1;
		}
		return res;
	}
};
int l,a,b,m;
signed main(){
	cin>>l>>a>>b>>m;
	mat ans(1,3,m),rui(3,3,m);
	ans.ma={{0,a%m,1}};
	rui=rui.pow(0);
	for(int i=1;i<=18;i++){
		int ma=mod_pow(10,i,inf)-1,mi=mod_pow(10,i-1,inf)-1;
		if(ma<a)continue;
		if(mi>=a+b*(l-1))continue;
		ma=min(ma,a+b*(l-1));
		int ko=(ma-a)/b+1;
		if(mi>=a)ko-=(mi-a)/b+1;
		mat x(3,3,m);
		x.ma[0]={mod_pow(10,i,m),0,0};
		x.ma[1]={1,1,0};
		x.ma[2]={0,b%m,1};
		rui=rui*x.pow(ko);
	}
	ans=ans*rui;
	cout<<ans.ma[0][0]<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 A, B, C, K;
  std::cin >> A >> B >> C >> K;
  std::cout << (K <= A ? K : K <= A + B ? A : 2 * A + B - K) << std::endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>

template<typename T>inline void read(T &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
}

namespace Good_problem
{
	typedef long long ll;
	const int N=101000,M=N*4;
	int begin[N],next[M],to[M];
	int n,m,e;
	ll A,B,C;
	void add(int x,int y,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		if(k)add(y,x,0);
	}
	int col[N];
	bool dfs(int p,int x)
	{
		if(col[p])return col[p]==x;
		col[p]=x;

		bool ret=1;
		for(int i=begin[p],q;i;i=next[i])
			if(!dfs(q=to[i],3-x))ret=0;
		return ret;
	}
	void initialize()
	{
		read(n),read(m);
		for(int i=1,u,v;i<=m;i++)
			read(u),read(v),add(u,v);
	}
	void solve()
	{
		initialize();
		A=B=C=0;
		for(int i=1;i<=n;i++)
			if(!col[i])
			{
				if(!dfs(i,1))B++;
				else if(begin[i])A++;
				else C++;
			}
		printf("%lld\n",2*A*A+2*A*B+B*B+2*n*C-C*C);
	}
}

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


Measured memory_bytes: 6912
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;
vector<int> g[MAX];
vector<PII> G[MAX];
int C[MAX];
bool can = true;

vector<int> A;
void dfs(int v, int c)
{
	if (C[v] != -1)
	{
		if (C[v] != c) can = false;
		return;
	}

	C[v] = c;
	A.push_back(v);
	FOR(i, 0, SZ(G[v]))
	{
		int to = G[v][i].first;
		int type = G[v][i].second;
		int c1 = c;
		if (type == 0) c1 = (c1 + 1) % 3;
		if (type == 1) c1 = (c1 + 2) % 3;
		
		dfs(to, c1);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(MP(b, 0));
		G[b].push_back(MP(a, 1));
	}

	LL ans = 0;
	FILL(C, -1);
	FOR(k, 0, n)
	{
		if (C[k] == -1)
		{
			A.clear();
			can = true;
			dfs(k, 0);

			if (!can)
			{
				ans += SZ(A) * (LL)SZ(A);
				continue;
			}

			LL CNT[3] = { 0 };
			FOR(i, 0, SZ(A))
			{
				int v = A[i];
				CNT[C[v]]++;
			}

			if (CNT[0] == 0 || CNT[1] == 0 || CNT[2] == 0)
			{
				LL cnt = 0;
				FOR(i, 0, SZ(A))
				{
					int v = A[i];
					cnt += SZ(G[v]);
				}

				cnt /= 2;
				ans += cnt;
				continue;
			}

			FOR(i, 0, 3)
			{
				ans += CNT[i] * CNT[(i + 1) % 3];
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 15224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

map<string,int> ma;
int mai = 1;
int s_i(string s){
	if(ma[s])return ma[s];
	return ma[s]=mai++;
}
priority_queue<int> pqpq;
vector< priority_queue<int> > data(1);
void push_data(string s,int w){
	int ind = s_i(s);
	if(data.size()==ind){
		data.push_back(pqpq);
	}
	data[ind].push(-w);
}
int pop_data(string s){
	int res = -1;
	if(ma[s]==0)return -1;
	if(data[s_i(s)].size()){
		res = -data[s_i(s)].top();
		data[s_i(s)].pop();
	}
	return res;
}


int main () {
	int n;
	cin >> n;
	FOR(i,0,n){
		string s;
		int w;
		cin >> s >> w;
		push_data(s,w);
	}

	int noww = -1;
	cin >> n;
	bool no = false;
	FOR(i,0,n){
		string s;
		cin >> s;
		if(!no)while(1){
			int w = pop_data(s);
			if(w>noww){
				noww = w;
				break;
			}
			if(w==-1){
				no = true;
				break;
			}
		}
	}
	if(no){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 23264
#include<bits/stdc++.h>
#define MN 500000
#define mod 1004535809
#define mod2 1000000009
using namespace std;
inline int read()
{
	int x=0,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();}
	return x*f;
}
char s[MN+5];
int n,b[MN+5],pw[MN+5],pw2[MN+5],ha[MN+5],ha2[MN+5],ans;
inline int gh(int l,int r){return (ha[r]-1LL*ha[l-1]*pw[r-l+1]%mod+mod)%mod;}
inline int GH(int l,int r){return (ha2[r]-1LL*ha2[l-1]*pw2[r-l+1]%mod2+mod2)%mod2;}
bool Match(int l,int r,int L,int R){return gh(l,r)==gh(L,R)&&GH(l,r)==GH(L,R);}
int main()
{
    scanf("%s",s+1);n=strlen(s+1);pw[0]=pw2[0]=1;
    for(int i=1;i<=n;++i) 
        pw[i]=31LL*pw[i-1]%mod,pw2[i]=37LL*pw2[i-1]%mod2,
        ha[i]=(31LL*ha[i-1]+s[i])%mod,ha2[i]=(37LL*ha2[i-1]+s[i])%mod2;
    int all=1;
    for(int i=2;i<=n;++i) all&=(s[i]==s[i-1]);
    if(all) return 0*printf("%d\n1",n);
    for(int i=1;i<=n;++i)
        for(int j=i<<1;j<=n;j+=i)
            if(Match(j-2*i+1,j-i,j-i+1,j)) b[j]=1;
            else break;
    for(int i=1;i<=n;++i)
        for(int j=n-(i<<1)+1;j>=1;j-=i)
            if(Match(j,j+i-1,j+i,j+2*i-1)) b[j-1]=1;
            else break;
    if(!b[n]) return 0*puts("1\n1");
    for(int i=1;i<n;++i) if(!b[i]) ++ans;
    printf("2\n%d",ans);
	return 0;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define ll long long 
#define endl '\n'
#define inf INT_MAX

int main()
{
	int t;
	map<string, int>mp;
	string ch;
	
	cin >> t;
	int mx = 0;
	while(t--)
	{
		cin >> ch;
		mp[ch]++;
		mx = max(mx,mp[ch]);
	}
	vector<string>v;
	for(auto it : mp)
	{
		if(it.second == mx) v.push_back(it.first);
	}
	sort(v.begin(),v.end());
	for(int i = 0; i < (int)v.size(); i++) cout << v[i] << endl;
	return 0;
	
}


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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   for(int i=0;i<N;i++){
      cin >> A.at(i);
   }
   vector<int> B(N);
   for(int i=0;i<N;i++){
      cin >> B.at(i);
   }
   vector<int> C(N-1);
   for(int i=0;i<N-1;i++){
      cin >> C.at(i);
   }

   int count=0;
   int j=-2;

   for(int i=0;i<N;i++){
      if(j+1==A.at(i)-1)
         count+=C.at(j);
      j=A.at(i)-1;
      count+=B.at(j);
   }
   cout << count << endl;
}

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

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      ret.push_back(i);
      if(i != 1 && i*i != n) {
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

bool isprime(ll x) {
  ll i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> vec = enum_div(n);
  ll ans = LLONG_MAX;
  rep(i, vec.size()) {
    ll m = vec.at(i) + n/vec.at(i) - 2;
    ans = min(ans, m);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
class Node
  attr_accessor :key, :parent, :left, :right

  def initialize(key)
    @key = key
    @parent = -1
    @left = nil
    @right = nil
  end

  def add_left(left)
    @left = left
    @left.parent = self
  end

  def add_right(right)
    @right = right
    @right.parent = self
  end

end


class BinaryTree
  attr_accessor :root

  def initialize()
    @root = nil
  end

  def insert(key)
    # 初回登録
    unless @root
      @root = Node.new(key)
      return
    end

    # 2回目以降
    #   xが挿入先にあたる. ので, nilになるまで探す.
    #   xの親がyで, yにadd_xxxxを実行する.
    x, y = @root, nil
    while x
      y = x
      if key < x.key
        x = x.left
      else
        x = x.right
      end
    end
    if key < y.key
      y.add_left(Node.new(key))
    else
      y.add_right(Node.new(key))
    end
  end

  def find(key)
    x = @root
    while x
      return 'yes' if x.key == key
      if key < x.key
        x = x.left
      else
        x = x.right
      end
    end
    'no'
  end

  def pre
    # 行きがけ順探索(左上から順に)
    @list = []
    traverse(@root, :pre)
    @list
  end

  def in
    # 通りがけ順探索
    @list = []
    traverse(@root, :in)
    @list
  end

  def post
    # 帰りがけ順探索(左下から順に)
    @list = []
    traverse(@root, :post)
    @list
  end

  private
  def traverse(node, type)
    @list << node.key if type == :pre
    traverse(node.left, type) if node.left
    @list << node.key if type == :in
    traverse(node.right, type) if node.right
    @list << node.key if type == :post
  end
end


n = gets.to_i
cmds = []
n.times do
  stdin = gets.chomp
  if stdin.match(/print/)
    cmds << [stdin, nil]
  else
    cmd, key = stdin.split
    cmds << [cmd, key.to_i]
  end
end

tree = BinaryTree.new
cmds.each do | cmd, key |
  if cmd.match(/insert/)
    tree.insert(key)
  elsif cmd.match(/find/)
    puts tree.find(key)
  else
    puts " #{tree.in.join(' ')}"
    puts " #{tree.pre.join(' ')}"
  end
end


Measured memory_bytes: 195440
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF (1LL<<60)
typedef long long Int;
inline void cmin(Int &a, Int b) { if (a > b) a = b; }

int N, M, L, K[2048], S[200000];
Int sum[200000], dp[2048][2048];

inline Int cost(int a, int b) { return (sum[K[b]+1]-sum[K[a]]) / L; }

int main() {
    scanf("%d%d%d", &N, &M, &L);
    rep (i, N) scanf("%d", K+i);
    rep (i, M) scanf("%d", S+i);
    rep (i, M) sum[i+1] = sum[i] + S[i];
    rep (i, 2048) rep (j, 2048) dp[i][j] = INF;
    rep (i, N) K[i]--;
    sort(K, K+N);
    dp[1][0] = cost(0, 1);
    for (int i = 2; i < N; i++) {
        rep (j, i) {
            cmin(dp[i][i-1], dp[i-1][j] + cost(j, i));
            cmin(dp[i][j], dp[i-1][j] + cost(i-1, i));
        }
    }
    Int ans = INF;
    rep (i, N) cmin(ans, dp[N-1][i] + cost(i, N-1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34000
#include<set>
#include<map>
#include<queue>
#include<ctime>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>    
using namespace std;
#define LL long long
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
char str[MAXN+5];
int main(){
	int n,r=0,g=0,ans=0;
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1;i<=n;i++){
		if(str[i]=='g'){
			if(r<g) ans++,r++;
			else g++;
		}
		else{
			if(r<g) r++;
			else ans--,g++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, m;

vvi v;

bitset <11> p;

void read() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    vector <int> temp;
    for(int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      temp.pb(s);
    }
    v.pb(temp);
  }
  for(int i = 0; i < m; ++i) {
    bool x;
    cin >> x;
    if (x)
      p[i] = 1;
    else p[i] = 0;
  }
}

void solve() {
  int sol = 0, l = (1 << n);
  for(int i = 1; i <= l; ++i) {
    bitset <11> activated;
    for(int j = 0; j < n; ++j)
      if ((1 << j) & i) {
        //bulb[j] = !bulb[j];
        activated[j] = true;
      }
    vector <int> bulb(m);
    for(int j = 0; j < n; ++j)
      if (activated[j])
        for(int k = 0; k < m; ++k)
          for(auto x : v[k])
            if (x == j + 1)
              ++bulb[k];
    bool good = 1;
    for(int j = 0; j < m && good; ++j)
      if (bulb[j] % 2 != p[j])
        good = 0;
    if (good)
      ++sol;
  }
  cout << sol;
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		Console.ReadLine();
		var s = Console.ReadLine();
		
		int j = 0;
		int i = 0;
		for(; ;i++)
		{
			var q = s.IndexOf("ABC", j);
			if(q == -1) break;
			j = q + 1;
		}
		Console.WriteLine(i);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13280
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    K = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    a_ord = ord("a")
    z_index = ord("z") - a_ord

    s_ord = [ord(s) - a_ord for s in S]
    for i, s in enumerate(s_ord):
        if z_index + 1 - s > K or s == 0:
            continue
        else:
            s_ord[i] = 0
            K -= z_index - s + 1

    mod = ord("z") - a_ord + 1
    if K > 0:
        K = K % mod
        s_ord[-1] = (s_ord[-1] + K) % mod

    print("".join([chr(x + a_ord) for x in s_ord]))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """xyz
4"""
        output = """aya"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """a
25"""
        output = """z"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """codefestival
100"""
        output = """aaaafeaaivap"""
        self.assertIO(input, output)


Measured memory_bytes: 60848