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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m; cin>>n>>m;
    vector<vector<ll>> s(m);
    rep(i,m){
        ll k; cin>>k;
        rep(j,k){
            ll a; cin>>a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<ll> p(m);
    rep(i,m) cin>>p[i];

    ll ans=0;
    for(int bit=0;bit< (1<<n); bit++){
        bool ok=true;
        rep(i,m){
            ll cnt=0;
            for(auto on:s[i]){
                if(bit&(1<<on)) cnt++;
            }
            if(cnt%2!=p[i]) ok=false;
        }
        if(ok) ++ans;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N, H; cin >> N >> H;
    ll Ma = -1;
    vector<ll> a(N), b(N);
    for(int i=0; i<N; i++){
        cin >> a[i] >> b[i];
        Ma = max(Ma, a[i]);
    }

    sort(b.begin(), b.end(), greater<ll>());
    int ans = 0;

    for(int i=0; i<N && Ma<=b[i]; i++){
        H -= b[i];
        ans++;
        if(H <= 0) break;
    }

    if(H > 0){
        ans += (H-1)/Ma + 1;
    }

    cout << ans << endl;
}

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

int main() {
  string s;
  set<char> t;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    t.insert(s[i]);
  }
  if (s.size() == t.size()) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}


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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

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

#define rep1(i,n) for(ll (i)=1;(i)<=(n);++i)

#define rrep(i,n) for(ll (i)=(n)-1;(i)>=(0);--i)

#define rrep1(i,n) for(ll (i)=(n);(i)>=(1);--i)

#define pb push_back

#define fr first

#define sc second

ll N;

ll a[100000],b[100000];

vector<ll> v;

P p[100000];

ll cnt;

ll ans;

ll res;



int main()

{

	ll x,y;
 cin>>x>>y;
 cout<<(x+y)%24<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    string t;
    cin >> t;
    string s;
    ll ans = 0;
    int len = t.size();
    for(char c : t)
    {
        if(c == '1' and !s.empty() and s.back() == '1')
        {
            s.pop_back();
            ans += len;
            len -= 2;
        }
        else
            s.push_back(c);
    }

    int z = 0, one_cnt = 0;
    rep(i,0,s.size())
    {
        if(s[i] == '0')
            z++;
        if(s[i] == '1')
        {
            if(one_cnt)
                z--;
            ans += len - 2 * one_cnt - (z + 1) / 2;
            one_cnt++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<pair<ll, int> > A(N);
  rep(i, N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(all(A), greater<pair<ll, int> >());
  A.push_back(make_pair(0, -1));
  vector<ll> ans(N);
  int mi = A[0].second;
  rep(i, N) {
    mi = min(mi, A[i].second);
    ans[mi] += (i + 1) * (A[i].first - A[i+1].first);
  }
  rep(i, N)
    cout << ans[i] << endl;
  return 0;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

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

  bool ok = true;
  for (int i = 0; S[i]; ++i) {
    if (i&1) {
      ok &= S[i] != 'R';
    }
    else {
      ok &= S[i] != 'L';
    }
  }

  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
s=gets.chomp
t=gets.chomp
gcd=n.gcd(m)
sdis=n/gcd
tdis=m/gcd
gcd.times do |i|
  snum=i*sdis
  tnum=i*tdis
  if s[snum]!=t[tnum]
    puts -1
    exit
  end
end
puts n*m/gcd


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

using lint = long long;


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, q;
    cin >> n >> q;
    const int S = 1<<18;
	vector<lint> seg(2*S), lazy(2*S);
    // for (int i = 1; i <= n; ++i)
    // 	seg[i+S] = i;
    int h = __builtin_clz(1)-__builtin_clz(S);
    auto apply = [&](int v, int delta, int len) {
		seg[v] += 1ll * delta * len;
		if (v < S) lazy[v] += delta;
	};
	auto push = [&] (int v) {
		for (int s = h, len = 1<<(h-1); s > 0; --s, len /= 2) {
			int i = v >> s;
			if (lazy[i]) {
				apply(2*i, lazy[i], len);
				apply(2*i+1, lazy[i], len);
				lazy[i] = 0;
			}
		}
	};
	auto climb = [&](int v) {
		for(int len = 2; v /= 2; len *= 2) {
			seg[v] = seg[2*v] + seg[2*v+1];
			seg[v] += lazy[v] * len;
		}
	};

	auto update = [&](int l, int r, int delta) {
		push(l + S), push(r + S - 1);
		for (int a = l+S, b = r+S, len = 1; a < b; a /= 2, b /= 2, len *= 2) {
			if (a & 1) apply(a++, delta, len);
			if (b & 1) apply(--b, delta, len);
		}
		climb(l + S), climb(r + S - 1);
	};

	auto query = [&](int l, int r) {
		push(l + S), push(r + S - 1);
		lint res = 0;
		for (int a = l+S, b = r+S; a < b; a /= 2, b /= 2) {
			if (a & 1) res += seg[a++];
			if (b & 1) res += seg[--b];
		}
		return res;
	};
    // for (int i = S; i; --i) seg[i] = (seg[2*i] + seg[2*i+1]);
    while(q--) {
    	int op, l, r;
    	cin >> op >> l >> r;
    	--l, --r;
    	if (op) {
    		cout << query(l, r+1) << '\n';
    	}
    	else {
    		int v;
    		cin >> v;
    		update(l, r+1, v);
    	}
    	// for (int i = 0; i < n; ++i) {
	    // 	cout << query(i, i+1) << ' ';
	    // }
	    // cout << endl;
    }
    
}


Measured memory_bytes: 11016
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, M;
vector<pair<ll, ll>> v;
map<ll, ll> mp;
ll ans;
int main() {
	cin>>N>>M;
	REP(i,0,N){
		ll A;
		cin>>A;
		mp[A]++;
	}
	REP(i,0,M){
		ll B, C;
		cin>>B>>C;
		mp[C]+=B;
	}
	for(auto m:mp){
		v.emplace_back(m.first, m.second);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(auto pr: v){
		if(N==0) break;
		ll now = min(pr.second, N);
		N -= now;
		ans += now * pr.first;
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 18544
S = list(input())

min_diff = 753
for i in range(len(S)-2):
    if abs(753-int(S[i]+S[i+1]+S[i+2])) < min_diff:
        min_diff = abs(753-int(S[i]+S[i+1]+S[i+2]))

print(min_diff)

Measured memory_bytes: 3060
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define mod 998244353
#define INF LLONG_MAX
#define pb push_back
#define mp make_pair
#define endl '\n'
#define rep(i, s, n) for(int i = s; i < n; i++)
#define Rep(i, n, s) for(int i = n; i > s; i--)
#define repl(i, s, n) for(ll i = s; i < n; i++)
#define Repl(i, n, s) for(ll i = n; i > s; i--)
#define x first
#define y second
using namespace std;
typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

ll factorial[300005];

void cal() {
	factorial[0] = 1;
	rep(i, 1, 300005) {
		factorial[i] = (factorial[i - 1] * i) % mod;
	}
}

ll binpow(ll a, ll b) {
	if(b == 0) return 1;
	ll x = binpow(a, b >> 1);
	x *= x; x %= mod;
	if(b % 2) return (x * a) % mod;
	else return x;
}

ll bindiv(ll a, ll b) {
	ll inv = binpow(b, mod - 2);
	return (a * inv) % mod;
}

ll C(ll k, ll n) {
	ll x = (factorial[k] * factorial[n - k]) % mod;
	return bindiv(factorial[n], x);
}

signed main() {
	fastio;
	cal();
	ll n, a, b, k; cin >> n >> a >> b >> k;
	vll ans;
	rep(i, 0, n + 1) {
		ll c = k - a * i;
		c /= b;
		if(c <= n && c >= 0 && a * i + b * c == k) {
			ans.pb(mp(i, c));
		}
	}
	ll res = 0;
	rep(i, 0, ans.size()) {
		res = (res + C(ans[i].x, n) * C(ans[i].y, n)) % mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch SqrtInequality | diff SqrtInequality.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address SqrtInequality.cpp && ./a.out

/*
 
 3/15/2020
 
 22:47-22:52 WA
 
 */

LL a,b,c;

bool solve() {
  if(c-a-b<=0) return false;
  return 4*a*b<(c-a-b)*(c-a-b);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>a>>b>>c;
  cout<<(solve()?"Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
vector<int> fr[36];
char s[100005],s2[100005];
int n,i,poz,ture;
bool ok;
int main()
{
    cin>>s;
    n=strlen(s);
    for(i=0;i<n;i++)
        fr[s[i]-'a'].push_back(i);
    cin>>s2;
    n=strlen(s2);
    for(i=0;i<n;i++)
    {
        if(fr[s2[i]-'a'].empty())
        {
            cout<<-1;
            return 0;
        }
    }
    poz=-1;
    for(i=0;i<n;i++)
    {
        ok=false;
        auto npoz=upper_bound(fr[s2[i]-'a'].begin(), fr[s2[i]-'a'].end(), poz);
        if(npoz==fr[s2[i]-'a'].end())
        {
            ture++;
            poz=fr[s2[i]-'a'][0];
        }
        else
        {
            poz=fr[s2[i]-'a'][npoz-fr[s2[i]-'a'].begin()];
        }
    }
    cout<<ture*strlen(s)+poz+1;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int MAX_C = 2010;
long long Com[MAX_C][MAX_C] = {0};

int main(){
  int a, b, c, K; cin >> a >> b >> c >> K;
  int sum = a+b+c;
  rep(i, K){
    sum += max({a, b, c})*pow(2, i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>


typedef unsigned char       u1;
typedef unsigned short      u2;
typedef unsigned long int   u4;
typedef char                s1;
typedef short               s2;
typedef long int            s4;

#define MIN_CHAR (2)
#define MAX_CHAR (100)

typedef struct {
    u4 num;
    u1 string[MAX_CHAR];
} STRING;

static STRING S;
static STRING T;

int main (void) {
    u4 i, j;
    u4 num = 0;
    u1 *ch;
    u1 matched = 0;
    u4 cnt;

    // 入力
    scanf("%s", S.string);
    scanf("%s", T.string);
    

    // 処理
    ch = S.string;
    while(*(ch++) != '\0') {
        num++;
    }
    S.num = num;
    T.num = num;

    for (i = 0; i < S.num; ++i) {
        cnt = 0;
        for (j = 0; j < S.num; ++j) {
            if (S.string[(i + j) % S.num] == T.string[j]) {
                ++cnt;
            }
        }
        if (cnt == S.num) {
            matched = 1;
            break;
        }
    }

    // 出力
    if (matched) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	b := make([]int, n)
	for i := range b {
		b[i] = scanInt()
	}

	d := 0
	ac, bc := 0, 0
	for i := 0; i < n; i++ {
		d += b[i] - a[i]
		if a[i] > b[i] {
			bc += a[i] - b[i]
		} else if a[i] < b[i] {
			ac += (b[i] - a[i] + 1) / 2
		}
	}
	if d >= max(ac, bc) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strArray[] = str.split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		int c = Integer.parseInt(strArray[2]);

		if (a < b) {// a<b
			if (b < c) {// a<b<c
				System.out.println(a + " " + b + " " + c);
			} else {
				if (a < c) {// a<c<b
					System.out.println(a + " " + c + " " + b);
				} else {// c<a<b
					System.out.println(c + " " + a + " " + b);
				}
			}
		} else {// b<a
			if (a < c) {// b<a<c
				System.out.println(b + " " + a + " " + c);
			} else {
				if (b < c) {// b<c<a
					System.out.println(b + " " + c + " " + a);
				} else {// c<b<a
					System.out.println(c + " " + b + " " + a);
				}
			}
		}
	}
}

Measured memory_bytes: 24132
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string taro;
	string hanako;
	int tarop = 0;
	int hanakop = 0;
	int i = 0;
	int n =0;

	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> taro >> hanako;
		if (taro > hanako)
		{
			tarop = tarop + 3 ;
		}
		else if (taro < hanako)
		{
			hanakop = hanakop + 3;
		}
		else
		{
			tarop = tarop + 1;
			hanakop = hanakop + 1;
		}
	}
	cout << tarop << " " << hanakop << endl;

	return 0;
}


Measured memory_bytes: 3156
while True:
    try:
        A=list(map(int,input().split()))
        B=list(map(int,input().split()))
        C=[]
        for i in range(4):
            if B[i]==A[i]:
                C.append("h")
            elif B[i] in A:
                C.append("b")
            else:
                pass
        H=C.count("h")
        B=C.count("b")
        print(H,B)
    except:
        break


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n, k, ans;
  cin >> n >> k;

  if(k % 2 == 1){
    ll num = 0;
    REP(i, n){
      if((i+1)%k==0)
        num++;
    }
    ans = pow(num, 3);
  }
  else{
    ll numRemain, numNR;
    numRemain = numNR = 0;
    REP(i, n){
      if((i+1)%k==0)
        numNR++;
      if((i+1)%k==k/2)
        numRemain++;
    }
    ans = pow(numNR, 3) + pow(numRemain, 3);
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define endl '\n';
const int maxn=2e5+5;
const int MOD=998244353;

ll factorial[maxn];

ll power(ll a, ll b){                 
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y)%MOD;
        }
        y = (y*y)%MOD;
        b /= 2;
    }
    return x%MOD;
}   
 
ll modular_inverse(ll n){              
    return power(n, MOD-2);
}
 
ll nCr(ll n, ll k){
    ll flag= ((factorial[n])*(modular_inverse(factorial[k])))%MOD;
    return (flag*modular_inverse(factorial[n-k]))%MOD;
}

int32_t main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	int ans=0;
	factorial[0]=1;
    for (int i = 1; i < maxn; ++i)        
    {
        factorial[i] = (i*factorial[i-1])%MOD;
    }

    for (int i = 0; i < k+1; ++i)
    {
    	int curr = nCr(n-1,i);
    	curr = (curr*power(m-1,n-1-i))%MOD;
    	ans = (ans + curr)%MOD;
    }
    ans = (ans*m)%MOD;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5256
#include <stdio.h>

int inc(int x,int y, int d[10][10]){
  if (x<0||y<0||x>=10||y>=10) return -1;
  else{
    inc_(x,y,d);
    return 0;
  }
}
int inc_(int x,int y,int d[10][10]){
  d[x][y]++;
  return 0;
}
int main(void){
  int d[10][10];
  int x,y,size;
  int i,j,c,m;
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      d[i][j] = 0;
    }
  }
  c = 0;
  m = 0;
  while(scanf("%d,%d,%d",&x,&y,&size) != EOF){
    if (size==3){
      inc(x,y-2,d);
      inc(x,y+2,d);
      inc(x-2,y,d);
      inc(x+2,y,d);
      for(i=-1;i<2;i++){
        for(j=-1;j<2;j++){
          inc(x+i,y+j,d);
        }
      }
    }else if(size==2){
      for(i=-1;i<2;i++){
        for(j=-1;j<2;j++){
          inc(x+i,y+j,d);
        }
      }
    }else if(size==1){
      inc(x-1,y,d);
      inc(x+1,y,d);
      for(i=-1;i<2;i++) inc(x,y+i,d);
    }
  }
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(d[i][j]==0) c++;
      if(d[i][j]>m) m = d[i][j];
    }
  }
  printf("%d\n%d\n",c,m);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<int> mi(N, INT_MAX);
    ll ans = LLONG_MAX;
    for (int i = 0; i < N; ++i) {
        ll tmp = (ll)i * x;
        for (int j = 0; j < N; ++j) {
            int l = (j < i ? j - i + N : j - i);
            mi[j] = min(a[l], mi[j]);
            tmp += mi[j];
        }
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 3652
#include <iostream>

int main(int argc, char const *argv[]) {
  int64_t a, b;
  std::cin >> a >> b;
  if (b > 0) {
    if (a <= 0) {
      std::cout << "Zero" << std::endl;
    } else {
      std::cout << "Positive" << std::endl;
    }
  } else if (b == 0) {
    std::cout << "Zero" << std::endl;
  } else {
    int c = b - a;
    if (c % 2 == 0) {
      std::cout << "Negative" << std::endl;
    } else {
      std::cout << "Positive" << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <stack>
using namespace std;

int main(){
	int level,h,w,n,k=1;
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	int c[105][105];
	vector<int> a;
	a.resize(n+1);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=h;i++){
		if(i&1){
			for(int j=1;j<=w;j++){
				if(a[k]){
					c[i][j]=k;
				}
				else{
					k++;
					c[i][j]=k;	
				}
				a[k]--;
			}
		}
		else{
			for(int j=w;j>=1;j--){
				if(a[k]){
					c[i][j]=k;
				}
				else{
					k++;
					c[i][j]=k;	
				}
				a[k]--;
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(j!=1) printf(" ");
			printf("%d",c[i][j]);
		}
		printf("\n");
	}
		
	return 0;
}

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

const int NULLPO = 1 << 30;
const int UNDEFINED = -NULLPO;

int M, p, sum_heap = 0;
string s;
bool error = false;
vector<int> heap, var(26, UNDEFINED);

int p_expr();

int p_number()
{
  int ret = 0;
  while (isdigit(s[p])) {
    ret *= 10;
    ret += s[p] - '0';
    ++p;
  }
  return ret;
}

int p_clone()
{
  p += 6;
  int ret = p_expr();
  if (ret != NULLPO) {
    if (ret == UNDEFINED || heap[ret] == UNDEFINED) {
      error = true;
      ret = UNDEFINED;
    } else if (heap[ret] + sum_heap > M) {
      ret = NULLPO;
    } else {
      sum_heap += heap[ret];
      heap.push_back(heap[ret]);
      ret = heap.size() - 1;
    }
  }
  ++p;
  return ret;
}

int p_malloc()
{
  p += 7;
  int ret = p_number();
  if (ret + sum_heap > M) {
    ret = NULLPO;
  } else {
    sum_heap += ret;
    heap.push_back(ret);
    ret = heap.size() - 1;
  }
  ++p;
  return ret;
}

int p_assign()
{
  char v = s[p];
  p += 2;
  int ret = p_expr();
  var[v-'A'] = ret;
  return ret;
}

int p_expr()
{
  int ret = UNDEFINED;
  if (s[p] == '(') {
    ++p;
    ret = p_expr();
    ++p;
  } else if (p+1 < s.size() && s[p+1] == '=') {
    ret = p_assign();
  } else if (s[p] == 'N') {
    ret = NULLPO;
  } else if (s[p] == 'm') {
    ret = p_malloc();
  } else if (s[p] == 'c') {
    ret = p_clone();
  } else {
    ret = var[s[p]-'A'];
  }
  return ret;
}

void p_free()
{
  p += 5;
  int ret = p_expr();
  if (ret != NULLPO) {
    if (ret == UNDEFINED || heap[ret] == UNDEFINED) {
      error = true;
    } else {
      sum_heap -= heap[ret];
      heap[ret] = UNDEFINED;
    }
  }
  ++p;
}

void p_line()
{
  if (s[p] == 'f')
    p_free();
  else
    p_expr();
}

int main()
{
  cin >> M;
  while (cin >> s) {
    p = 0;
    p_line();
  }

  if (error) {
    cout << "Error" << endl;
  } else {
    int ans = sum_heap;
    for (int i = 0; i < var.size(); ++i) {
      if (var[i] == UNDEFINED || var[i] == NULLPO || heap[var[i]] == UNDEFINED)
	continue;
      ans -= heap[var[i]];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define M 500005
#define ll long long
ll n,a,b,c,d;
int main(){
	cin>>n>>a>>b>>c>>d;
	b-=a;
	for(ll i=1;i<=n;i++){
		ll L=c*(i-1)-d*(n-i);
		ll R=d*(i-1)-c*(n-i);
		if(L<=b&&b<=R){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
	while(1){
		string g; cin >> g;
		if(g == "#") break;
		int y, m, d; cin >> y >> m >> d;
		if(y > 31 || y == 31 && m >= 5){
			g = "?";
			y -= 30;
		}
		cout << g << " " << y << " " << m << " " << d << endl;
	}
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <unordered_set>

using namespace std;

int main(void) {
  int length;
  cin >> length;

  unordered_set<string> set;

  string prev;
  cin >> prev;
  set.insert(prev);

  string now;

  for (int i = 1; i < length; i++) {
    cin >> now;
    if (prev.back() != now.front()) {
      cout << "No" << endl;
      return 0;
    }
    if (set.count(now) != 0) {
      cout << "No" << endl;
      return 0;
    }
    prev = now;
    set.insert(prev);
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
function main(input) {
  var temp = input.split('\n');
  var arr = temp[1].split(' ').map(Number);
  var answer = ""
  for (var i = parseInt(temp[0]); i>0; i--) {
    answer += arr[(i-1)] + ' ';
  }
  console.log(answer.trim());
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 19480
#include <stdio.h>

int a[100000],b[100000];
int cnt=0;
int c,i,j;
int main(void){
	while(1){
		scanf("%d %d",&a[cnt],&b[cnt]);
		if((a[cnt]==0)&&(b[cnt]==0)) break;
		cnt++;
	}//cnt1大きい

	for(c=0;c<cnt;c++){
		for(i=0;i<a[c];i++){
			for(j=0;j<b[c];j++){
				if(i%2==0){
					if(j%2==0) printf("#");
					else printf(".");
				}else{
					if(j%2==1) printf("#");
					else printf(".");
				}
			}
			printf("\n");//次の行
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	n := len(s)

	// 10**224 == 1 (mod 2019)
	pow10 := make([]int, 224, 224)
	pow10[0] = 1
	for i := 1; i < 224; i++ {
		pow10[i] = (pow10[i-1] * 10) % 2019
	}

	m := make([]int, n+1, n+1)
	m[n] = 0
	for i := 0; i < n; i++ {
		k := int(s[n-1-i] - '0')
		m[n-1-i] = (pow10[i%224]*k + m[n-i]) % 2019
	}

	c := make([]int, 2019, 2019)
	for i := 0; i <= n; i++ {
		c[m[i]]++
	}
	answer := int64(0)
	for i := 0; i < 2019; i++ {
		tmp := int64(c[i]) * int64(c[i]-1) / 2
		answer += tmp
	}
	fmt.Println(answer)
}


Measured memory_bytes: 4840
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	int n;
	double t, a;
	cin >> n >> t >> a;

	double m = (double)inf;
	int res = -1;
	for (int i = 0; i < n; i++)
	{
		double h;
		cin >> h;

		double x = t - h * 0.006;
		if (m > abs(a - x))
		{
			m = abs(a - x);
			res = i + 1;
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Atcoder
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int b = a[0] / a[1];
        if (a[0] % a[1] == 0)
        {
            Console.WriteLine(b);
        }
        else
        {
            Console.WriteLine(b + 1);
        }
       
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll k, a, h;
  in(k);
  a = 0;
  rep2(i, 1, k + 1){
    rep2(j, 1, k + 1){
      rep2(l, 1, k + 1){
        h = __gcd(i, j);
        h = __gcd(h, l);
        a += h;
      }
    }
  }
  out(a);
  memi;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
using namespace std;
int N;
int vis[110];
int n;
int main()
{
	cin>>n;
	vis[4]=1;
	vis[8]=1;
	vis[12]=1;
	vis[16]=1;
	vis[7]=1;
	vis[14]=1;
	vis[11]=1;
	vis[15]=1;
	if(n>17)
	{
		cout<<"Yes"<<endl;
	
	}
	else
	{
		if(vis[n])
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int h, w, d[10][10] = {}, z = 0, a;
    cin >> h >> w;
    fr(10) for (int j = 0; j < 10; j++) cin >> d[i][j];
    for (int k = 0; k < 10; k++) fr(10) for (int j = 0; j < 10; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    fr(h * w) {
        cin >> a;
        if (a != -1) z += d[a][1];
    }
    cout << z;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int INF = 1 << 30;
#define rep(i,n) for(int i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll h, w, v[110][110],ct=0;
int main(){
	int n;
	cin >> n;
	cout << n / 3 << endl;
	return 0;
}

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

int	main	(void)
{

	char str[101];
	scanf("%s",str);
	int len = strlen(str);
	int index =0;
	while (index < len/2)
	{
		if(str[index] != str[len-index-1])
		{
			printf("No");
			return (0);
		}
		index++;
	}
	if (len ==3)
	{
		printf("Yes\n");
		return (0);
	}
	index =0;
	while (index< (len-1)/4)
	{
		if(str[index] != str[(len-1)/2 - index -1])
		{
			printf("No");
			return (0);
		}
		index++;
	}
	index =0;
	while (index< (len-1)/4)
	{
		if(str[len -index-1] != str[len -((len-1)/2 - index -1)-1])
		{
			printf("No");
			return (0);
		}
		index++;
	}
	printf("Yes\n");
	return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <regex>
using namespace std;
typedef basic_regex<char>    regex;
int main(int argc,char const* argv[])
{
  int a,b;
  string s;
  cin >> a >> b;
  cin >> s;
  for(int i=0;i<a;i++)
    {
      if(s[i]!='0'&&s[i]!='1'&&s[i]!='2'&&s[i]!='3'&&s[i]!='4'&&s[i]!='5'&&s[i]!='6'&&s[i]!='7'&&s[i]!='8'&&s[i]!='9') 
	{
	  cout << "No" <<endl;
	  return 0;
	}
    }
  if(s[a]!='-')
    {
      cout << "No" <<endl;
      return 0;
    }
  for(int i=a+1;i<a+b;i++)
    {
      if(s[i]!='0'&&s[i]!='1'&&s[i]!='2'&&s[i]!='3'&&s[i]!='4'&&s[i]!='5'&&s[i]!='6'&&s[i]!='7'&&s[i]!='8'&&s[i]!='9')
	{
	  cout << "No" <<endl;
	  return 0;
	}
    }
  cout << "Yes" <<endl;
  return 0;
}


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

color = [0]*8
freer=0

for i in a:
    if i<3200:
        color[i//400]+=1
    else:
        freer+=1
        
ans_base = 8-color.count(0)

if ans_base==0:
    ans_min = 1
else:
    ans_min = ans_base
    
ans_max = ans_base+freer
        
print(ans_min, ans_max)

Measured memory_bytes: 9172
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val N = scanner.nextLong()
    var sum: Long = 0L
    val AN: List<Long> = (0..N - 1).map { val l = scanner.nextLong();sum += l;return@map l }
    val once = (N * (N + 1)) / 2
    if (sum % once != 0L) {
        println("NO")
        return
    }
    val k: Long = sum / once
    var count: Long = 0
    (0..N - 1).forEach { index ->
        var di =-( AN[((index + 1) % N).toInt()] - AN[index.toInt()] - k)
//        di = -di
//        count += di / N
//        di = di % N
//        count += -di / N
//        di = di % N
//        while (di > 0) {
//            di -= N
//            count += 1
//        }
        if(di>0){
            count+=di/N
            di%=N
        }
        if (di != 0L) {
            println("NO")
            return
        }
    }
    if (k == count) println("YES")
    else {
        println("NO")
    }
}


Measured memory_bytes: 46556
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.at(a-1) = i + 1;
  }
  
  for (int i = 0; i < N; i++) {
    cout << A[i] << " ";
  }
}


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

int dp[102][4][2];

int main(){
  string s;
  int kp;
  cin >> s >> kp;
  int n = s.size();
  dp[0][0][0] = 1;
  for(int i=0; i<n; ++i) for(int j=0; j<4; ++j) for(int k=0; k<2; ++k){
    int si = s[i] - '0';
    for(int l=0; l<10; ++l){
      int nk = k;
      if(k == 0){
        if(l > si) continue;
        if(l < si) nk = 1;
      }
      if(l==0) dp[i+1][j][nk] += dp[i][j][k];
      else if(j<kp) dp[i+1][j+1][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][kp][0] + dp[n][kp][1];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<set>

using namespace std;

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

#include<iostream>

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4){
        if (s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long Bx100 = Long.valueOf(sc.next().replace(".", ""));

        System.out.println(A*Bx100/100);
    }
}


Measured memory_bytes: 35608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N;
		long A,B,C,D;
		N=sc.nextInt();
		A=sc.nextLong();
		B=sc.nextLong();
		C=sc.nextLong();
		D=sc.nextLong();
		for (int i=0; i<N; i++) {
			if((C*((long)(N-1-i))-D*((long)i))<=(B-A) && (B-A)<=-C*((long)i)+((long)(N-1-i))*D) {
				pl("YES");
				System.exit(0);
			}
		}
		pl("NO");
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 23380
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
n = int(readline())
a = [int(readline()) for i in range(n)]
k = [ai for i,ai in enumerate(a) if i%2 == 0]
k = set(k)
a.sort()
ans = 0
for i,ai in enumerate(a):
  if ai in k and i%2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 10032
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
vector<int> X;

int main() {
    while (cin >> N) {
        X.resize(N);
        for (int i = 0; i < N; ++i) cin >> X[i];
        vector<int> Y = X;
        sort(Y.begin(), Y.end());
        int mid = Y[(N-1)/2];
        
        for (int i = 0; i < N; ++i) {
            if (X[i] <= mid) cout << Y[(N-1)/2+1] << endl;
            else cout << Y[(N-1)/2] << endl;
        }
    }
}

























Measured memory_bytes: 3712
<?php

// ABC068C
fscanf(STDIN, "%d%d", $n, $m);
$first_way = array();
$second_way = array();
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, '%d%d', $a, $b);
    if ($a == 1) {
        $first_way[$b] = true;
    } elseif ($b == $n) {
        $second_way[$a] = true;
    }
}


foreach ($first_way as $key => $value) {
    if( isset( $second_way[$key] ) ) {
        echo 'POSSIBLE';
        return;
    }
}

echo 'IMPOSSIBLE';

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

int main(){
  int n,a[5000];

  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> a[i];
    
    int ans = -1000000000;
    for(int i=0;i<n;i++){
      int sum = 0;
      for(int j=i;j<n;j++){
	sum += a[j];
	ans = max(sum,ans);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1180
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i += 2) {
    ans += s[i];
  }
  cout<<ans<<endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;

int main()
{
    IOS
    // READ(0test.txt);
    //WRITE(0out.txt) ;
    string s ;
    cin >> s ;
    int ans = 0 ;
    char ok = s[0] ;
    for(int i= 1 ; i< s.size() ; i++){
        if(ok==s[i] ){
            (s[i]=='0')?ok='1':ok='0';
            ans++;
        }
        else (s[i]=='0')?ok='0':ok='1';
        //cout<<ans<<" "<<ok<<endl;

    }
    cout<<ans;


}





Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(i < k){
			if(t[i] == 'r') ans += p;
			if(t[i] == 'p') ans += s;
			if(t[i] == 's') ans += r;
		} else {
			if(t[i] == t[i - k]){
				t[i] = 'x';
			} else {
				if(t[i] == 'r') ans += p;
				if(t[i] == 'p') ans += s;
				if(t[i] == 's') ans += r;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int n,W;cin>>n>>W;
  vector<int> w(n),v(n);
  rep(i,n)cin>>w[i]>>v[i];
  vector<vector<ll>> sumv(n+1,(vector<ll>(W+1,0)));
  
  rep(i,n){
    for(int sumw=0;sumw<=W;sumw++){
      if(sumw-w[i]>=0){
        sumv[i+1][sumw]=max(sumv[i+1][sumw],sumv[i][sumw-w[i]]+v[i]);
      }
      sumv[i+1][sumw]=max(sumv[i+1][sumw],sumv[i][sumw]);
      //cout<<sumv[i+1][sumw]<<" ";
    }//cout<<endl;
  }
  cout<<sumv[n][W];
}

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

int main(){

int S,h,m,s ;
   
	cin >> S ;
	h=S/3600 ; 
	m=S%3600/60 ;
	s=S%3600%60 ;
	 cout << h << ":" << m << ":" << s << endl ;


		return 0 ;
		 
		 
	 }
	

Measured memory_bytes: 1164
import std.stdio, std.string, std.conv;

void main() {
    foreach (i; 0 .. 10) {
        string cards = readln.chomp.to!(string);
        if (cards == "-") break;
        int m = readln.chomp.to!int;
        foreach (j; 0 .. m) {
            int h = readln.chomp.to!int;
            cards = cards[h..$] ~ cards[0..h];
        }
        cards.writeln;
    }
}


Measured memory_bytes: 2452
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, C = in.next().toInt
  val s = new Array[Int](N+1)
  val t = new Array[Int](N+1)
  val c = new Array[Int](N+1)

  for (i <- 1 to N) {
    val x, y, z = in.next().toInt
    s(i) = x
    t(i) = y
    c(i) = z
  }


  //
  val MAX = 1e5.toInt

  val dp = Array.ofDim[Int](31, (2 * MAX)+2)

  for (i <- 1 to N) {
    val l = s(i) * 2
    val r = t(i) * 2
    dp(c(i))(l - 1) += 1
    dp(c(i))(r + 1) -= 1
  }

  for(k <- 1 to 30) {
    for(i <- 1 to 2*MAX) {
      dp(k)(i) += dp(k)(i-1)
    }
  }

  var ans = 0
  for(i <- 1 to 2*MAX) {
    var tmp = 0
    for(k <- 1 to 30) {
      if (dp(k)(i) >= 1){
        tmp += 1
      }
    }
    ans = Math.max(ans, tmp)
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 82528