akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}
 
int main() {
    ll n, k;
    cin >> n >> k;

    rep(i, n) {
        ll a;
        cin >> a;
    }

    out(1 + ceil(n-k, k-1));
    re0;
}

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

using namespace std;

int N;
long long K;
vector<int> A;

vector<int> used;
vector<int> pred;
int find_cycle(int v) {
    used[v] = true;
    int u = A[v];
    pred[u] = v;
    if (used[u]) {
        return u;
    }
    return find_cycle(u);
}

int solve() {
    used.assign(N, false);
    pred.assign(N, -1);
    int s = find_cycle(0);

    auto count = K;
    int u = 0;
    for (; u != s && count > 0; u = A[u]) {
        count--;
    }
    if (count == 0) {
        return u;
    }

    vector<int> path;
    path.push_back(u);
    for (int v = A[u]; v != u; v = A[v]) {
        path.push_back(v);
    }
    if (path.size() == 0) {
        return u;
    }
    count %= path.size();
    int d = u;
    for (int i = 0; i < count; ++i) {
        d = A[d];
    }
    return d;
}

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

    cin >> N >> K;
    A.assign(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i]--;
    }
    cout << solve() + 1 << endl;

    return 0;
}

Measured memory_bytes: 6620
n = int(input())
a = list(map(int,input().split()))
suma = sum(a)
tmp = 0
for i in range(len(a)):
         tmp += a[i]
         if tmp >= suma//2:
                  break
print(min((abs((suma-tmp)-tmp)),abs((suma-(tmp-a[i]))-(tmp-a[i]))))


Measured memory_bytes: 26024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s;
    int q;
    bool flag = true;

    cin >> s >> q;

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

        if (t == 1)
        {
            flag = !flag;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;

            if (f == 1)
            {
                if (flag)
                {
                    s.insert(s.begin(), c);
                }
                else
                {
                    s.insert(s.end(), c);
                }
            }
            else
            {
                if (flag)
                {
                    s.insert(s.end(), c);
                }
                else
                {
                    s.insert(s.begin(), c);
                }
            }
        }
    }

    if (flag)
    {
        cout << s << endl;
    }
    else
    {
        for (int i = s.size() - 1; i >= 0; i--)
        {
            printf("%c", s[i]);
        }

        printf("\n");
    }
}

Measured memory_bytes: 900
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, K, Q;
vector<int> A;
int main()
{
    cin >> N >> K >> Q;
    A.resize(N);
    for (auto &val : A)
    {
        cin >> val;
    }
    ll result = LL_INF;
    for (int i = 0; i < N; i++)
    {
        const int X = A[i];
        vector<int> candidates;
        vector<int> tmp;
        for (int j = 0; j < N; j++)
        {
            if (A[j] >= X)
            {
                tmp.push_back(A[j]);
            }
            else if (A[j] < X)
            {
                int m = tmp.size();
                sort(tmp.begin(), tmp.end());
                for (int j = 0; j < m - K + 1; j++)
                {
                    candidates.push_back(tmp[j]);
                }
                tmp.clear();
            }
        }
        int m = tmp.size();
        sort(tmp.begin(), tmp.end());
        for (int j = 0; j < m - K + 1; j++)
        {
            candidates.push_back(tmp[j]);
        }
        tmp.clear();

        sort(candidates.begin(), candidates.end());
        if (candidates.size() >= Q)
        {
            result = min(result, (ll)candidates[Q - 1] - X);
        }
    }
    cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans = 0;
  fr(i,1,n+1) {
    int x = sum(i);
    if(x >= a && x <= b) ans+=i;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define N 100000
#define INF 1000000
#define MAXN 6
//---------------------

ll six[MAXN],nine[MAXN],cash[MAXN*2+1];
ll dp[N+1];
int main(){
	
	ll n;
	cin>>n;
	six[0]=6;
	nine[0]=9;
	cash[0]=6;
	cash[1]=9;
	REP1(i,MAXN) {
		six[i]=six[i-1]*6;
		nine[i]=nine[i-1]*9;
		cash[2*i]=six[i];
		cash[2*i+1]=nine[i];
	}
	cash[MAXN*2]=1;
	sort(cash,cash+MAXN*2+1);
	//REP(i,MAXN*2+1) cout<<cash[i]<<endl;
	REP(i,N+1) dp[i]=INF;
	dp[0]=0;
	REP1(i,N+1){
		REP(j,MAXN*2+1){
			ll mn=cash[j];
			if(i-mn<0) continue;
			dp[i]=min(dp[i],dp[i-mn]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
s = input()

if (s[k - 1] == 'A'):
    x = s[0:k - 1] + 'a' + s[k:n]
elif (s[k - 1] == 'B'):
    x = s[0:k - 1] + 'b' + s[k:n]
else:
    x = s[0:k - 1] + 'c' + s[k:n]
print(x)


Measured memory_bytes: 3060
// Fuwa Fuwa Time!

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;

namespace MATH
{
	inline int fpm(int x, int y)
	{
		int res = 1;
		for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
		return res;
	}

	const int n = (int) 3e6;

	int fac[n + 5], ifac[n + 5];

	inline int C(int N, int M) { return N < M ? 0 : (LL) fac[N] * ifac[N - M] % MOD * ifac[M] % MOD; }

	inline void init()
	{
		fac[0] = 1;
		for(int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
		ifac[n] = fpm(fac[n], MOD - 2);
		for(int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % MOD;
	}
}
using MATH::C;

int x[7], y[7];

inline void input()
{
	for(int i = 1; i <= 6; ++i) x[i] = read<int>();
	for(int i = 1; i <= 6; ++i) y[i] = read<int>();
}

inline int calc(int x0, int y0, int x1, int y1) { return C(x1 - x0 + y1 - y0 + 2, x1 - x0 + 1); }

inline int calc1(int x0, int y0) { return ((LL) calc(x[1], y[1], x0, y0) - calc(x[2] + 1, y[1], x0, y0) - calc(x[1], y[2] + 1, x0, y0) + calc(x[2] + 1, y[2] + 1, x0, y0)) % MOD; }
inline int calc2(int x0, int y0) { return ((LL) calc(x0, y0, x[6], y[6]) - calc(x0, y0, x[5] - 1, y[6]) - calc(x0, y0, x[6], y[5] - 1) + calc(x0, y0, x[5] - 1, y[5] - 1)) % MOD; }

inline void solve()
{
	int ans = 0;

	int res = (LL) calc1(x[3], y[3]) * calc2(x[3], y[3]) % MOD;
	(ans -= (LL) res * (x[3] + y[3]) % MOD) %= MOD;
	for(int i = x[3] + 1; i <= x[4]; ++i)
	{
		res = (LL) calc1(i, y[3] - 1) * calc2(i, y[3]) % MOD;
		(ans -= (LL) res * (i + y[3]) % MOD) %= MOD;
	}
	for(int i = y[3] + 1; i <= y[4]; ++i)
	{
		res = (LL) calc1(x[3] - 1, i) * calc2(x[3], i) % MOD;
		(ans -= (LL) res * (x[3] + i) % MOD) %= MOD;
	}

	res = (LL) calc1(x[4], y[4]) * calc2(x[4], y[4]) % MOD;
	(ans += (LL) res * (x[4] + y[4] + 1) % MOD) %= MOD;
	for(int i = x[3]; i < x[4]; ++i)
	{
		res = (LL) calc1(i, y[4]) * calc2(i, y[4] + 1) % MOD;
		(ans += (LL) res * (i + y[4] + 1) % MOD) %= MOD;
	}
	for(int i = y[3]; i < y[4]; ++i)
	{
		res = (LL) calc1(x[4], i) * calc2(x[4] + 1, i) % MOD;
		(ans += (LL) res * (x[4] + i + 1) % MOD) %= MOD;
	}

	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	MATH::init();
	input();
	solve();

	return 0;
}



Measured memory_bytes: 23680
def read():
    N, M = list(map(int, input().strip().split()))
    S = [-1] * M
    for i in range(M):
        inputs = list(map(int, input().strip().split()))
        S[i] = sw_to_seq(inputs[0], inputs[1:])
    P = list(map(int, input().strip().split()))
    return N, M, S, P


def sw_to_seq(k, s):
    s_seq = 0
    for i in range(k):
        bit = 1 << (s[i] - 1)
        s_seq += bit
    return s_seq


def count_sw_on(s_seq, i):
    sw_on = s_seq & i
    count = 0
    while sw_on > 0:
        count += (sw_on & 1)
        sw_on >>= 1
    return count


def solve(N, M, S, P):
    count_all_sw_on = 0
    for i in range(1 << N):
        num_sw_on = 0
        for j in range(M):
            if count_sw_on(S[j], i) % 2 == P[j]:
                num_sw_on += 1
        if num_sw_on == M:
            count_all_sw_on += 1
    return count_all_sw_on


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	string a;
	cin>>a;
	int l=0,r=a.size()-1,ans=0;
	while(l<r)
	{
		if(a[l]!=a[r]) ans++;
		l++;
		r--;
	}
	cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct lazysegtree{
	int n;
	vector<long>dat,lazy;
	lazysegtree(int n_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,0);
		lazy.assign(2*n-1,0);
	}
	void eval(int i,int l,int r)
	{
		if(lazy[i])
		{
			dat[i]+=lazy[i];
			if(r-l>1)
			{
				lazy[2*i+1]+=lazy[i];
				lazy[2*i+2]+=lazy[i];
			}
			lazy[i]=0;
		}
	}
	void update(int a,int b,long x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]+=x;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=max(dat[2*k+1],dat[2*k+2]);
		}
	}
	long query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return 0;
		else if(a<=l&&r<=b)return dat[k];
		else return max(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
int n,m;
vector<pair<int,int> >P[2<<17];
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,a;cin>>l>>r>>a;
		P[r].push_back(make_pair(l,a));
	}
	lazysegtree dp(n+1);
	for(int i=1;i<=n;i++)
	{
		dp.update(i,i+1,dp.query(0,i));
		for(int j=0;j<P[i].size();j++)
		{
			dp.update(P[i][j].first,i+1,P[i][j].second);
		}
	}
	cout<<dp.query(0,n+1)<<endl;
}

Measured memory_bytes: 20864
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int N;
    io >> N;
    vi A(N);
    for (int i = 0; i < N; i++)
        io >> A[i];

    ll cache = 1000;
    ll kabu = 0;

    bool up = false;
    for (int i = 0; i < N - 1; ++i)
    {
        if (up)
        {
            if (A[i] > A[i+1])
            {
                cache += kabu * A[i];
                kabu = 0;
                up = false;
            }
        }
        else
        {
            if (A[i] < A[i+1])
            {
                kabu = cache / A[i];
                cache -= kabu * A[i];
                up = true;
            }
        }
    }
    cache += kabu * A[N-1];

    io << cache << BR;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    
    cout << 'A' << s2[0] << 'C' << endl;

    return 0;
}

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

using namespace std;

int main(void){
  int K,N;
  cin >> K >> N;
  int tmp;
  int A[N],B[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N-1;i++){
    B[i] = A[i+1] - A[i];
  }
  B[N-1] = A[0] + K - A[N-1];
  int max=0;
  for(int i=0;i<N;i++){
    if(max < B[i]){
      max = B[i];
    }
  }

  cout << K - max << endl;

  return 0;
}


Measured memory_bytes: 1792
#標準入力
a,b,c = map(int,input().split())

#必要量を500で割った商を出力する
i = c // 500

#商が500で割り切れないなら個数を1足す
if c % 500 != 0:i += 1

#aよりb*2のほうが小さいなら1Lを買わないで500mlで個数を買った計算にしaの方が大きいなら両方を買う計算をする
if a >= b * 2:print(b * i)
elif a < b and c <= 1000:print(a)
else:print((i // 2) * a + (i % 2) * b)


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


using namespace std;


int main()
{long long int N;
cin>>N;
long long int A[N],P[N],S[N],C = 0;
for(int x = 0;x<N;x++){
    cin>>A[x];
    C+=A[x];
}
P[0]=A[0];
S[0]=C-P[0];
long long int M = 1000000000;
for(int x = 1;x<N;x++){
    P[x]=P[x-1]+A[x];
    S[x]=C-P[x];
    if(M>abs(P[x]-S[x])){
        M = abs(P[x]-S[x]);
    }
}
cout<<M<<"\n";
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    int N, L; cin >> N >> L;  
    int min_a;
    VI A;
    REP(i, N)
    {
        A.push_back(L+i);
    }
    SORT(A);
    if(A.front()*A.back()<=0) min_a = 0;
    else if (A.front()>0) min_a = A.front();
    else if (A.back()<0) min_a = A.back();
    cout << (L-1)*N + (N*(N+1))/2 - min_a << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s; cin>>s;
  for(int i=0;i<s.length()-1;i++){
    if(s[i]==s[i+1])
      return cout<<i+1<<" "<<i+2<<"\n", 0;
  }

  for(int i=0;i<s.length()-2;i++){
    if(s[i]==s[i+2])
      return cout<<i+1<<" "<<i+3<<"\n", 0;
  }

  cout<<"-1 -1\n";
  return 0;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())

n = ii()
a = iin()
l = [0 for i in range(n)]
for i in a:
    l[i-1] += 1
for j in l:
    print(j)


Measured memory_bytes: 26012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }

void yes() { cout << "Yay!\n"; }
void no() { cout << ":(\n"; }

int main() {
    init();

    int n; string s; cin >> n >> s;
    auto dp = vec<bool>(n + 1, 4, 1000);
    dp[0][0][0] = true;
    FOR(i, 0, n)FOR(j, 0, 4)FOR(k, 0, 1000) {
        if (!dp[i][j][k])continue;
        dp[i + 1][j][k] = true;
        if (j == 3)continue;
        dp[i + 1][j + 1][k * 10 + (s[i] - '0')] = true;
    }

    int ans = 0;
    FOR(i, 0, 1000)if (dp[n][3][i])++ans;
    cout << ans << "\n";
}


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

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = INT_MAX;
    for(int ab = 0; ab <= 201010; ab++){
        int cost = ab * C;
        int x = X - ab/2;
        int y = Y - ab/2;
        if(0 < x) cost += x*A;
        if(0 < y) cost += y*B;
        ans = min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

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

  int main()
{
   char b[4];
   scanf("%s",b);

   int i,a[4];
   for(i=0;i<4;i++)
    {
            if(b[i]=='0') a[i]=0;
            else if(b[i]=='1') a[i]=1;
            else if(b[i]=='2') a[i]=2;
            else if(b[i]=='3') a[i]=3;
            else if(b[i]=='4') a[i]=4;
            else if(b[i]=='5') a[i]=5;
            else if(b[i]=='6') a[i]=6;
            else if(b[i]=='7') a[i]=7;
            else if(b[i]=='8') a[i]=8;
            else if(b[i]=='9') a[i]=9;
    }
    if(a[0]+a[1]+a[2]+a[3]==7) {printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]+a[1]+a[2]-a[3]==7) {printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]+a[1]-a[2]+a[3]==7) {printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]+a[1]-a[2]-a[3]==7) {printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]-a[1]+a[2]+a[3]==7) {printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]-a[1]+a[2]-a[3]==7) {printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]-a[1]-a[2]+a[3]==7) {printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]);return 0;}
    if(a[0]-a[1]-a[2]-a[3]==7) {printf("%d-%d-%d-%d=7",a[0],a[1],a[2],a[3]);return 0;}
    return 0;
}



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

#define MAX 200000

int main(){
    int i, K, N, A[MAX], D[MAX];
    cin >> K >> N;
    for(i=0; i<N; i++) cin >> A[i];
    for(i=0; i<N; i++) {
        if(i < N-1) D[i] = A[i+1] - A[i];
        else D[i] = (K - A[i]) + A[0];
    }
    int maxDist = 0;
    for(i=0; i<N; i++) maxDist = max(maxDist, D[i]);

    cout << K - maxDist << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    string S;
	cin >> S;
	if(S == "KIHBR" || S == "AKIHBR" || S == "KIHABR" || S == "KIHBAR" || S == "KIHBRA" || S == "AKIHABR" || S == "AKIHBAR" || S == "AKIHBRA" || S == "KIHABAR" || S == "KIHABRA" || S == "KIHBARA" || S == "AKIHABAR" || S == "AKIHABRA" || S == "AKIHBARA" || S == "KIHABARA" || S == "AKIHABARA") {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

double calc_exp(int n) {
  double d = double(n);
  return (1 + d) / 2;
} 

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> P(n);
  vector<double> E(n);

  double max = 0;
  double e = 0;
  rep(i, n) {
    cin >> P[i];
    E[i] = calc_exp(P[i]);

    e += E[i];
    if (i >= k) {
      e -= E[i-k];
    }
 
    if (max < e) {
      max = e;
    }
  }
  printf("%.10f\n", max);
}


Measured memory_bytes: 2560
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-27 19:56:17
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    int a,b;cin >> a >> b;
    if((a+b)&1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
    // system("pause");
    return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
   string s;
   cin >> s;
   int a[] = {s[0] - '0', s[1] - '0', s[2] - '0', s[3] - '0'};

   for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
         for (int k = 0; k < 2; k++) {
            int sum = a[0];
            char x, y , z;
            if (i == 0)  {
               sum += a[1];
               x = '+';
            } else {
               sum -= a[1];
               x = '-';
            }
            if (j == 0)  {
               sum += a[2];
               y = '+';
            } else {
               sum -= a[2];
               y = '-';
            }
            if (k == 0)  {
               sum += a[3];
               z = '+';
            } else {
               sum -= a[3];
               z = '-';
            }
            if (sum == 7) {
               printf("%d%c%d%c%d%c%d=7\n", a[0], x, a[1], y, a[2], z, a[3]);
               return 0;
            }
         }
      }
   }

   return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

halfPos = -(-N//2)

qPos = halfPos // 2

q3Pos = qPos + halfPos

for m in range(1, M+1):
  if m % 2:
    print(qPos-m//2, qPos+m//2+1)
  else:
    print(q3Pos-m//2, q3Pos+m//2)

Measured memory_bytes: 70032
n = int(input())

a,b,c,d = 0,0,0,0
for _ in range(n):
    t = input()
    if t=='AC':
        a += 1
    elif t=='WA':
        b += 1
    elif t=='TLE':
        c += 1
    elif t=='RE':
        d += 1

print('AC x {}'.format(a))
print('WA x {}'.format(b))
print('TLE x {}'.format(c))
print('RE x {}'.format(d))


Measured memory_bytes: 69828
s = gets.to_i
def f(n)
  if n%2==0
    return n/2
  else
    return 3*n+1
  end
end
i = 1
ary = [s]
while i > 0 do
  ary << f(ary[i-1])
  if ary.uniq.size != ary.size
    break
  else
    i += 1
  end
end
puts i+1

Measured memory_bytes: 14284
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    // 入力
    Scanner sc = new Scanner(System.in);
    int m1 = sc.nextInt();
    int d1 = sc.nextInt();
    int m2 = sc.nextInt();
    int d2 = sc.nextInt();
    //   出力
    if(m1 == m2)
      System.out.print(0);
    else
      System.out.print(1);
  }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int n;
double r;
vector<pair<int,int> > vec; 
set<pair<int,int> > visited;
set<pair<int,int> > exist;

int main(){
  
  scanf("%d%lf", &n,&r);

  for(int i=0;i<n;i++){
    double x,y;
    scanf("%lf%lf", &x, &y);
    if(x >= 0) x += r;
    if(y >= 0) y += r;
    vec.push_back({x/r, y/r});
    exist.insert(vec[i]);
  }

  int ans = 0;

  int dx[8] = {0,0,1,-1,1,1,-1,-1};
  int dy[8] = {1,-1,0,0,1,-1,1,-1};
  
  for(int i=0;i<n;i++){
    if(visited.find(vec[i]) != visited.end())
      continue;

    ans++;

    queue<pair<int,int> > que;
    que.push(vec[i]);
    while(que.size()){
      auto p = que.front();
      que.pop();
      
      if(visited.find(p) != visited.end()) continue;
      visited.insert(p);
      
      for(int j=0;j<8;j++){
        if(exist.find({p.first + dx[j], p.second + dy[j]}) != exist.end())
          que.push({p.first + dx[j], p.second + dy[j]});
      }
    }
  }

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



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

using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = max(b * d, a * c);
    ll y = max(a * d, b * c);
    cout << max(x, y);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    // int t;
    // cin >> t;
    // while (t--)
        solve();
       
    return 0;
}


Measured memory_bytes: 3652
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) { new Main(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int n, k, r, s, p;
	char[] str;
	int[][] dp;
	
	Main() {
		n = in.nextInt();
		k = in.nextInt();
		r = in.nextInt();
		s = in.nextInt();
		p = in.nextInt();

		str = in.next().toCharArray();
		ArrayList<Character>[] round = new ArrayList[k];
		for (int i = 0; i < k; i++)
			round[i] = new ArrayList<>();
		for (int i = 0; i < n; i++)
			round[i % k].add(str[i]);

		int ans = 0;
		dp = new int[4][n];
		for (int i = 0; i < 4; i++)
			Arrays.fill(dp[i], -1);
		for (int i = 0; i < k; i++)
			ans += dp(0, i);

		out.println(ans);
		out.close();
	}

	int dp(int last, int idx) {
		if (idx + k >= n) {
			if (str[idx] == 'r') {
				if (last != 3)
					return p;
				return 0;
			}
			else if (str[idx] == 's') {
				if (last != 1)
					return r;
				return 0;
			}
			else if (str[idx] == 'p') {
				if (last != 2)
					return s;
				return 0;
			}
		}
		if (dp[last][idx] != -1)
			return dp[last][idx];

		int max = -1;
		if (str[idx] == 'r') {
			if (last != 3)
				max = max(max, p + dp(3, idx + k));
			max = max(max, dp(1, idx + k));
			max = max(max, dp(2, idx + k));
		}
		else if (str[idx] == 's') {
			if (last != 1)
				max = max(max, r + dp(1, idx + k));
			max = max(max, dp(2, idx + k));
			max = max(max, dp(3, idx + k));
		}
		else if (str[idx] == 'p') {
			if (last != 2)
				max = max(max, s + dp(2, idx + k));
			max = max(max, dp(1, idx + k));
			max = max(max, dp(3, idx + k));
		}
		
		return dp[last][idx] = max;
	}
	
	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }

		void intArr(int sz, int[] x) { for (int i = 0; i < sz; i++) x[i] = nextInt(); }
		void longArr(int sz, long[] x) { for (int i = 0; i < sz; i++) x[i] = nextLong(); }
		void doubleArr(int sz, double[] x) { for (int i = 0; i < sz; i++) x[i] = nextDouble(); }
	}
}



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

const int N = 100100;

int n, a[N][3], dp[N][3], ans;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	for (int i = 0; i < 3; i++)
		dp[1][i] = a[1][i];
	for (int i = 2; i <= n; i++)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + a[i][2];
	}
	for (int i = 0; i < 3; i++)
		ans = max(ans, dp[n][i]);
	cout << ans;
}

Measured memory_bytes: 2560
s = raw_input()

nen = s[0:4]
tuki = s[5:7]
date = s[8:10]
nen = int(nen)
tuki = int(tuki)
date = int(date)


if nen <= 2019 and tuki <= 4 and date <= 30:
    print 'Heisei'
else:
    print 'TBD'

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    string s;
    cin >> s;
    int n = s.size()/2;
    string a = s.substr(0,n);
    reverse(all(s));
    string b = s.substr(0,n);
    int ret = 0;
    rep(i,0,n) {
    	if(a[i] != b[i]) {
    		ret++;
    	}
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b) cout <<c << endl;
  else if(b==c)cout << a << endl;
  else if(c==a)cout << b << endl;
  
  
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}



int main()
{
     int h,w;
     cin>>h>>w;
     int n;
     cin>>n;
     int a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     vector<int> x,y;
     int ans[h][w];
     for(int i=0;i<h;i++)
     {
          if(i%2){
               for(int j=w-1;j>=0;j--){
                    x.push_back(i);y.push_back(j);
                   // cout<<x.back()<<" "<<y.back()<<"\n";
               }
          }
          else
          {
               for(int j=0;j<=w-1;j++){
                    x.push_back(i);y.push_back(j);
                    //cout<<x.back()<<" "<<y.back()<<"\n";
               }
          }
     }
     int k=0;
     for(int i=0;i<n;i++)
     {
          for(int j=0;j<a[i];j++){
               ans[x[k]][y[k]]=i+1;k++;
          }
     }
     for(int i=0;i<h;i++){
          for(int j=0;j<w;j++)cout<<ans[i][j]<<" ";
          cout<<"\n";
     }

}















 














 
 

















Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

bool compare(std::pair<int,int> x, std::pair<int,int> y){
    return (x.first != y.first) ? x.first > y.first : x.second < y.second;
}

int n = 0, m = 0;
int main(void){
    int i = 0;
    int j = 0;
    std::vector< std::pair<int,int> > votes;

    int v = 0;
    while(std::cin >> n >> m){
        if(n==0 && m ==0) break;

        votes.resize(m);
        votes.clear();

        for(i=0; i<m; ++i){
            votes[i].first = 0;
            votes[i].second = i+1;
        }

        for(i=0; i<n; ++i){
            for(j=0; j<m; ++j){
                std::cin >> v;
                if(v == 1){
                    votes[j].first += 1;
                }
            }
        }

        std::sort(votes.begin(), votes.begin() + m, compare);
        for(i=0; i<m; ++i){
            std::cout << (i==0 ? "" : " ") << votes[i].second;
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<string>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define rep(i,n)  FOR(i,0,n)
int N,L;

vector<string> S;

int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> N >> L;

    string s;
    rep(i,N) {
        cin >> s;
        S.push_back(s);
    }
    sort(S.begin(),S.end());
    rep(i,N) cout << S[i];
    cout << endl;

    return 0;
}



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

int main() {
    int H, W;
    cin >> H >> W;
    
    int A[H][W];
    for ( int y = 0; y < H; y++ ) {
        for ( int x = 0; x < W; x++ ) {
            cin >> A[y][x];
        }
    }
    
    int B[W];
    for ( int x = 0; x < W; x++ ) {
        cin >> B[x];
    }
    
    for ( int y = 0; y < H; y++ ) {
        int ans = 0;
        for ( int x = 0; x < W; x++ ) {
            ans += A[y][x]*B[x];
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3128
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}

string s;

void input(){
    cin>>s;
}
void src(){
    auto ss=duplicator(String_to_vector_char(s));
    cout<<(none_of(ss.begin(),ss.end(),[](auto x)->bool{return(x.first==x.second);})? "Good":"Bad");
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
   // ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
s = input()
f = 1
for i in range(0, len(s), 2):
	if s[i] not in ['R', 'U', 'D']:
		f = 0
		break

for i in range(1, len(s), 2):
	if s[i] not in ['L', 'U', 'D']:
		f = 0
		break

if f:
	print ('Yes')
else:
	print ('No')


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#define DEBUG
#ifdef DEBUG
#define dprintf      printf
#define dbg
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#else
#define dprintf      (1)?0:printf
#define dbg          (1)?0:
#define dloop(i,s,g) if(0)
#define drep(i,n)    if(0)
#endif

#define INF  0x7fffffff
#define LINF 0x7fffffffffffffff
#define PI   3.141592653578979323846264338

#define X    first
#define Y    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())

//typedef long long           int;
typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

signed main(void)
{
  char s[1024]={};
  char t[1024]={};
  int n;
  cin>>n;
  int i;
  int c;
  rep(i,n)
    cin>>s[i];
  cin>>c;
  rep(i,n)
    if(s[i]=='0'&&c)
      t[i]=s[i]+1,c--;
    else
      t[i]=s[i];
  for(i=n-1;i>=0;i--)
    if(s[i]=='1'&&c)
      t[i]=s[i]-1,c--;
  rep(i,n)
    cout<<t[i];
  puts("");
  return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
int main()
{
    int N, M;
    scanf("%d %d", &N, &M);
    double T = M*1900 + (N - M)*100;
    double R = 1.0;
    int i;
    for (i = 0; i < M; i++)
        R /= 2;
    printf("%.0lf", T/R);
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	int n,k;
	cin >> n;
	ll ans = 0;
	FOR(i,0,n){
		cin >> k;
		ans += k-i-1;
	}
	cout << ans << endl;
}



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

int store[107];

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

    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> store[i];
        sum += store[i];
    }

    double mid = (double)sum / N;

    int af_mid;
    if (ceil(mid) - mid > mid - floor(mid)) af_mid = floor(mid);
    else af_mid = ceil(mid);


    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(af_mid - store[i]) * abs(af_mid - store[i]);
    }

    cout << ans << endl;
}

/*
8
-3 14 -15 92 65 -35 89 79
=18282
*/


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

int main(){
    ll N,A,B; cin >> N >> A >> B;
    ll l = B-A-1;
    ll res = 0;
    if(l%2){
        res = l/2+1;
    }else
    {
        res = min(A-1,N-B) + (B-A-1)/2 + 1;
    }
    cout << res << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define N 1010

int n,ans;
int a[N];

int main()
{
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	if (a[1]!=a[2]) {ans+=a[2]-a[1]; a[0]+=ans;}
	if ((a[2]-a[0])&1) ans+=(a[2]-a[0]+1)/2+1;
	else ans+=(a[2]-a[0])/2;
	printf("%d\n",ans);
	//scanf("%d",&n);
	//for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

var N, M int
var S, T map[string]int

func main() {
	fmt.Scanf("%d", &N)

	S = make(map[string]int, N)

	for i := 0; i < N; i++ {
		var s string
		fmt.Scanf("%s", &s)
		S[s]++
	}

	fmt.Scanf("%d", &M)

	T = make(map[string]int, M)

	for i := 0; i < M; i++ {
		var t string
		fmt.Scanf("%s", &t)
		T[t]++
	}

	ans := 0
	for k, _ := range S {
		ans = Max(ans, S[k]-T[k])
	}

	fmt.Println(ans)
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 512
import java.util.*;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method astub
	    	Scanner sc = new Scanner(System.in);
	    while(true){
	    	int stime = 0; 
	    	int t = sc.nextInt();
	    	if(t==0) break;
	    	int n = sc.nextInt();
	    	for (int i=0;i<n;i++){
	    		int time_s = sc.nextInt();
	    		int time_f = sc.nextInt();
	    		stime += time_f - time_s;
	    	}
	    if(stime >= t) System.out.println("OK"); 
	    else System.out.println(t-stime);
	    }
	}
}

Measured memory_bytes: 31388