akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (b < 2) {
    cout << 0 << '\n';
    return 0;
  }
  int res = 0;
  bool flag = true;
  while (b > 0) {
    if (flag) {
      b -= a;
      flag = false;
    } else {
      b -= (a - 1);
    }
    ++res;
  }
  cout << res << '\n';
  return 0;
}



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

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
ll dp[12][110][1010];
void mainmain(){
    int n;
    int s;
    rep(i,101){
        dp[1][i][i]=1;
    }
    reep(i,1,11){
        rep(j,101){
            reep(k,j+1,101){
                rep(l,1010){
                    if(l+k>=1010) continue;
                    dp[i+1][k][l+k]+=dp[i][j][l];
                }
            }
        }
    }
    while(cin>>n>>s){
        if(n==0&&s==0) return;
        ll tmp=0;
        rep(i,101){
            tmp+=dp[n][i][s];
        }
        cout<<tmp<<endl;
    }    
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 10196
main(){float a,b;for(;~scanf("%f%f",&a,&b);)puts(a<35.5&&b<71?"AAA":a<37.5&&b<77?"AA":a<40&&b<83?"A":a<43&&b<89?"B":a<50&&b<105?"C":a<55&&b<116?"D":a<70&&b<148?"E":"NA");exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


void clear_m(vector<string> &d,int H,int W){
    rep(k,32){
        for(int i=H-1;i>=1;i--){
            rep(j,W){
                if(d[i][j]=='0'){
                    swap(d[i][j],d[i-1][j]);
                }
            }
        }
    }
}

bool is_update(vector<string> &d,int H,int W,int K){
    bool update=false;
    rep(i,H){
        rep(j,W){
            if(d[i][j]!='0'){
                int c=0;
                char ch=d[i][j];
                while(j<W && d[i][j]==ch) j++,c++;
                if(c>=K) update=true;
                j--;
            }
        }
    }

    return update;
}

ll calc_m(vector<string> &d,int H,int W,int K){
    ll sum=0;
    rep(i,H){
        rep(j,W){
            if(d[i][j]!='0'){
                int c=0;
                char ch=d[i][j];
                int k=j;
                while(k<W && d[i][k]==ch) k++,c++;
                if(c>=K){
                    sum+=(ch-'0')*c;
                    k=j;
                    while(k<W && d[i][k]==ch) d[i][k]='0',k++;
                }
            }
        }
    }

    return sum;
}


int main(){
    int H,W,K;
    cin>>H>>W>>K;
    
    vector<string> c(H);
    rep(i,H) cin>>c[i];

    ll ans=0;
    rep(i,H){
        rep(j,H){
            ll sum=0;
            vector<string> d=c;
            d[i][j]='0';
            clear_m(d,H,W);

            int cnt=0;
            while(true){
                if(!is_update(d,H,W,K)) break;
                ll ret=calc_m(d,H,W,K);
                sum+=pow(2,cnt)*ret;
                clear_m(d,H,W);
                cnt++;
            }
            ans=max(ans,sum);
        }
    }

    cout<<ans<<endl;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  s[5] = ' '; s[13] = ' ';
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
ll n,i,k=0,c=0;
cin>>n;
ll a[n];
rep(i,0,n)
cin>>a[i];
rep(i,0,n)
{
    if(a[i+1]<=a[i])
        k++;
    else
    {
        c=max(c,k);
        k=0;
    }
}
cout<<c;
return 0;
}



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

int main() {
	int N = 0;
	int Alice = 0;
	int Bob = 0;
	int Max = 0;
	cin >> N;
	vector<int> Card(N); 
	for (int Loop = 0; Loop < N; Loop++) {
    	cin >> Card.at(Loop);
    }  
	for (int Loopi = 0; Loopi < N; Loopi++) {
        Max = 0;
		for (int Loopii = 0; Loopii < N; Loopii++) {
            sort(Card.begin(),Card.end());
        	reverse(Card.begin(),Card.end());
        	Max = Card.at(0);
        	if (Loopii % 2 == 0) {
            	Alice += Max;
            }
      		else {
            	Bob += Max;
            }
         	Card.at(0) = 0;
    }
    }
	cout << Alice - Bob << endl;;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define sq(a) (a)*(a)
#define ms(a,v)	memset(a,v,sizeof a)
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<string, string> mss;


int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n,k; cin>>n>>k;
  cout<<min(n%k,abs(n%k-k))<<"\n";
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int x;
    cin >> x;
    for (int i = -400; i <= 400; i++) {
        for (int j = -400; j <= 400; j++) {
            if (i * i * i * i * i - j * j * j * j * j == x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

vi ans, cur;
unordered_set<vi> vis;
bool solve(vi v, int sum){
	if(vis.count(v)) return 0;
	vis.insert(v);
	
	if(v.empty()){
		ans = cur;
		reverse(all(ans));
		return 1;
	}
	rep(i, v.size()) if(i == 0 || v[i] != v[i - 1]) if((sum - v[i]) % v[i] == 0){
		cur.pb(v[i]);
		vi next = v;
		next.erase(next.begin() + i);
		if(solve(next, sum - v[i])) return 1;
		cur.pop_back();
	}
	return 0;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n;
	while(cin >> n, n){
		vi v(n);
		rep(i, n) cin >> v[i];
		sort(all(v), greater<int>());
		ans.clear();
		cur.clear();
		vis.clear();
		if(!solve(v, accumulate(all(v), 0))){
			cout << "No" << endl;
		}
		else{
			rep(i, n) cout << ans[i] << (i==n-1?"\n":" ");
		}
	}
	return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char ch[] = str.toCharArray();
        for(int i=0; i<=str.length()-1; i++){
            if(Character.isUpperCase(ch[i])){
                ch[i] = Character.toLowerCase(ch[i]);
            } else if(Character.isLowerCase(ch[i])){
                ch[i] = Character.toUpperCase(ch[i]);
            }

        }
        System.out.println(ch);
    }
}


Measured memory_bytes: 26256
#include "bits/stdc++.h"
using namespace std;

int main()
{
	char b;
	cin >> b;

	if (b == 'A')
	{
		cout << 'T' << endl;
	}
	else if (b == 'T')
	{
		cout << 'A' << endl;
	}
	else if (b == 'C')
	{
		cout << 'G' << endl;
	}
	else if (b == 'G')
	{
		cout << 'C' << endl;
	}
}

Measured memory_bytes: 256
def main():
    N = int(input())
    H = [int(n) for n in input().split()]

    counter = 0
    for i, h in enumerate(H):
        canView = True
        for j in range(i):
            if H[j] > h:
                canView = False
        if canView:
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll mod = 1e9+7;


int n,i,j,k,t,l,r, c,mid;
int cek[100000];
string s;

int main(){
	memset(cek, -1, sizeof cek);
	cin>>n;
	cout<<0<<"\n"<<flush;
	cin>>s;
	if(s=="Vacant")
		return 0;
	else if(s=="Male")
		cek[0] = 1;
	else
		cek[0] = 2;
	cout<<n-1<<"\n"<<flush;
	cin>>s;
	if(s=="Vacant")
		return 0;
	else if(s=="Male")
		cek[n-1] = 1;
	else
		cek[n-1] = 2;
	l = 0;
	r = n-1;
	t = mid = (l+r)>>1;
	cout<<mid<<"\n"<<flush;
	while(cin>>s, s!="Vacant"){
		if(s == "Male")
			cek[mid] = 1;
		else if(s=="Female")
			cek[mid] = 2;
		else
			break;
		// cout<<l<<" "<<r<<" "<<mid<<endl;
		// cout<<cek[l]<<" "<<cek[mid]<<" "<<cek[r]<<endl;
		// cout<<(mid-l)%2<<" "<<(r-mid)%2<<endl;
		if((mid-l)%2){
			if(cek[mid] == cek[l]){
				r = mid;
				goto DOOM;
			}
		}
		else if(((mid-l)%2)==0){
			if(cek[mid] != cek[l]){
				r = mid;
				goto DOOM;
			}
		}
		if((r-mid)%2){
			if(cek[mid] == cek[r]){
				l = mid;
				goto DOOM;
			}
		}
		else if (((r-mid)%2)==0){
			if(cek[mid] != cek[r]){
				l = mid;
				goto DOOM;
			}
		}
		DOOM :
		mid = (l+r)>>1;
		cout<<mid<<"\n"<<flush;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string t;
    cin >> t;
    ll n = t.size();
    ll ans = 0;
    rep(i, n) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3748
import itertools
N = int(input())

P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p = ""
q = ""
for i in P:
    p += str(i)
p = int(p)
for i in Q:
    q += str(i)
q = int(q)
tmp = itertools.permutations([i+1 for i in range(N)])
target = []
for a in tmp:
    t = ""
    for s in a:
        t += str(s)
    target.append(int(t))
qidx = 0
pidx = 0
for i, t in enumerate(target):
    if p == t:
        pidx = i
    if q == t:
        qidx = i

print(abs(pidx-qidx))



Measured memory_bytes: 43868
#include<stdio.h>
#define SIZE 100

int main(){
  int v,i,j;
  int G[SIZE][SIZE];
  scanf("%d",&v);
  
  for(i=0; i<v; i++){
    for(j=0; j<v; j++){
      G[i][j] = 0;
    }
  }
  
  for(i=0; i<v; i++){
    int u,k;
    scanf("%d %d",&u,&k);
    u--;
    
    for(j=0; j<k; j++){
      int peak;
      scanf("%d",&peak);
      peak--;
      G[u][peak] = 1;
    }
  }
  
  for(i=0; i<v; i++){
    for(j=0; j<v; j++){
      if(j > 0) printf(" ");
      printf("%d",G[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2704
/*
  Identically Colored Panels Connection
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1174&lang=jp
*/

#include <iostream>

using namespace std;

int h,w,c;
int pre[8][8];
int p[8][8];
int ans[4][4][4][4];

// ???????????????
void adj(int x, int y, int c, int tc){
  p[x][y] = c;
  if(tc != c){
    if(x > 0     && p[x - 1][y] != c && p[x - 1][y] == tc){ adj(x - 1, y, c, tc); }
    if(y > 0     && p[x][y - 1] != c && p[x][y - 1] == tc){ adj(x, y - 1, c, tc); }
    if(x < h - 1 && p[x + 1][y] != c && p[x + 1][y] == tc){ adj(x + 1, y, c, tc); }
    if(y < w - 1 && p[x][y + 1] != c && p[x][y + 1] == tc){ adj(x, y + 1, c, tc); }
  }
}

// ??°??????
int num(int x, int y, int c){
  int a = 1;
  p[x][y] = 7;

  if(x > 0     && p[x - 1][y] == c){ a += num(x - 1, y, c); }
  if(y > 0     && p[x][y - 1] == c){ a += num(x, y - 1, c); }
  if(x < h - 1 && p[x + 1][y] == c){ a += num(x + 1, y, c); }
  if(y < w - 1 && p[x][y + 1] == c){ a += num(x, y + 1, c); }

  return a;
}


void printMat(){
  for(int i = 0 ; i < h ; i++){
    for(int j = 0 ; j < w ; j++){
      cout << p[i][j];
    }
    cout << endl;
  }
}


int main(void){
  while(1){
    cin >> h;
    cin >> w;
    cin >> c;

    if(h == 0 && w == 0 && c == 0) break;

    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
        cin >> pre[i][j];
        pre[i][j] -= 1;
      }
    }

    int max = -1;
    for(int c1 = 0 ; c1 < 6 ; c1++){
      for(int c2 = 0 ; c2 < 6 ; c2++){
        for(int c3 = 0 ; c3 < 6 ; c3++){
          for(int c4 = 0 ; c4 < 6 ; c4++){

            for(int i = 0 ; i < h ; i++){
              for(int j = 0 ; j < w ; j++){
                p[i][j] = pre[i][j];
              }
            }

            adj(0,0,c1,p[0][0]);
            adj(0,0,c2,p[0][0]);
            adj(0,0,c3,p[0][0]);
            adj(0,0,c4,p[0][0]);
            adj(0,0,c-1,p[0][0]);
//            printMat(); cout << endl;


            int a = num(0,0,p[0][0]);

            if(max < a){
              max = a;
            }
          }
        }
      }
    }

    cout << max << endl;

  }

  return 0;
}

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

int main() {
  string N;
  cin >> N;
  
  char a = N.at(0);
  char b = N.at(1);
  char c = N.at(2);
  char d = N.at(3);
  
  if ((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
s = input()
s = s.split(" ")
N = s[0]
K = int(s[1])

s = input()
s = s.split(" ")
ds = [int(digit) for digit in s]

minNum = min([digit for digit in range(0, 10) if digit not in ds])
nonZerominNum = min([digit for digit in range(1, 10) if digit not in ds])
maxNum = max([digit for digit in range(0, 10) if digit not in ds])

digits = [int(digit) for digit in N]

result = N
for index in range(0, len(digits)):
  digit = digits[index]
  if digit in ds:
    i = index
    if digit > maxNum:
      i = index - 1
      while i >= 0 and digits[i] == maxNum:
        i -= 1
    
    if i < 0:
      result = str(nonZerominNum) + (str(minNum) * len(N))
    else:
      biggerDigit = min([d for d in range(0, 10) if d not in ds and d > digits[i]])
      digits[i] = biggerDigit
      for j in range(i+1, len(digits)):
        digits[j] = minNum
      result = "".join([str(digit) for digit in digits])
    break

print(result)


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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<int> Pos(w + 1);
	vector<P> Vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &Vec[i].first, &Vec[i].second);
	}
	for(int i = 1; i <= w; ++i)
	{
		int pos = i;
		for(int j = 0; j < n; ++j)
		{
			if(Vec[j].first == pos)
			{
				pos = Vec[j].second;
			}
			else if(Vec[j].second == pos)
			{
				pos = Vec[j].first;
			}
		}
		Pos[pos] = i;
	}
	for(int i = 1; i <= w; ++i)
	{
		cout << Pos[i] << endl;
	}
}

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

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

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

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    ll x;
    cin >> x;

    ll a = 100;
    ll ans = 0;
    while(a < x){
        a = a * 1.01;
        ans ++;
    }
    
    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 3652
n,a,b = map(int,input().split())
s=[]
s_in = input()
for i in range(n):
    s.append(s_in[i])
pass_all = 0
pass_kaigai = 0
judge=[]
for i in range(n):
    if s[i] == "a":
        if pass_all < a + b:
            judge.append("Yes")
            pass_all += 1
        else:
            judge.append("No")
    elif s[i] == "b":
        if pass_all < a+b and pass_kaigai < b:
            judge.append("Yes")
            pass_all += 1
            pass_kaigai += 1
        else:
            judge.append("No")
    else:
        judge.append("No")
for i in range(n):
    print(judge[i])


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;

    cin >> s;
    rep(i, s.length())
    {
        if (s[i] == 'A')
        {
            x = i;
            break;
        }
    }
    repd(i, s.length() - 1)
    {
        if (s[i] == 'Z')
        {
            y = i;
            break;
        }
    }
    pr(y - x + 1);
    return 0;
}


Measured memory_bytes: 3796
def solve(N, W, weightValues):
    dp = [0] * (W + 1)
    s = 0
    for w, v in weightValues:
        s += w # why ?
        for i in range(min(W, s), w - 1, -1): # why min(W, s)
            if dp[i - w] + v > dp[i]:
                dp[i] = dp[i - w] + v

    print(max(dp))

def iln(): return list(map(int, input().split()))

N, W = iln()
w_v = []
for i in range(N):
  w_v.append(iln())
  
solve(N, W, w_v)

Measured memory_bytes: 7752
N, M = map(int, input().split())
xy = [[int(_) for _ in input().split()] for _ in range(M)]
red = [False]*(N+1)
red[1] = True
ballnum = [1]*(N+1)

for i in xy:
    x = i[0]
    y = i[1]
    ballnum[x] -= 1
    ballnum[y] += 1
    if red[x]:
        red[y] = True
        if ballnum[x] == 0:
            red[x] = False

print(red.count(True))

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

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

    int A[31] = {0};
    for (int i=0; i<N; i++) {
        int j_max;
        cin >> j_max;
        for (int j=0; j<j_max; j++) {
            int like_food;
            cin >> like_food;
            ++A[like_food];
        }
    }

    int cnt = 0;
    for (int i=0; i<31; i++) {
        if (A[i] == N) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    deque<ll> a(n);
    ll odd  = 0;
    ll even = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i % 2 == 0 && a[i] > 0)
            even += a[i];
        else if (i % 2 == 1 && a[i] > 0)
            odd += a[i];
    }
    if (even <= 0 && odd <= 0) {
        int idx = -1;
        ll maxi = -INF;
        for (int i = 0; i < n; ++i) {
            if (chmax(maxi, a[i]))
                idx = i;
        }
        cout << maxi << "\n";
        cout << n - 1 << "\n";
        for (int i = n - 1; i > idx; --i) {
            cout << i + 1 << "\n";
        }
        for (int i = 0; i < idx; ++i) {
            cout << 1 << "\n";
        }
    } else {
        vl pos, ret;
        if (odd > even) {
            ret.push_back(1);
            a.pop_front();
            n--;
        }
        for (int i = 0; i < n; i += 2) {
            if (a[i] > 0)
                pos.push_back(i);
        }
        for (int i = n; i >= pos.back() + 2; --i) {
            ret.push_back(i);
        }
        for (int i = 0; i < pos[0]; ++i) {
            ret.push_back(1);
        }
        for (int i = 1; i < (int)pos.size(); ++i) {
            for (int j = 0; j < (pos[i] - pos[i - 1] - 1) / 2; ++j) {
                ret.push_back(3);
            }
            ret.push_back(2);
        }
        cout << max(even, odd) << "\n";
        cout << ret.size() << "\n";
        for (auto &r : ret) {
            cout << r << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
import heapq


def main():
    n, m = map(int, input().split())
    alist = map(int, input().split())
    heap = []
    for a in alist:
        heapq.heappush(heap, a * -1)
    for _ in range(m):
        v = heapq.heappop(heap)
        heapq.heappush(heap, int(v / 2))
    print(int(-1 * sum(heap)))


main()


Measured memory_bytes: 14180
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s;int out=999;
	cin>>s;
	rep(i,s.size()-2){
		int now=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		out=min(out,abs(now-753));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
import numpy as np
import sys

def read_data():
    try:
        LOCAL_FLAG
        import codecs
        import os

        lines = []
        file_path = os.path.join(os.path.dirname(__file__), 'data.dat')
        with codecs.open(file_path, 'r', 'utf-8') as f:
            n_lines = int(f.readline())
            for i in range(n_lines):
                lines.append(f.readline().rstrip("\r\n"))

    except NameError:
        lines = []
        n_lines = int(input())
        for i in range(n_lines):
            lines.append(input())
    return lines

raw_data = read_data()
tarray = []
for each in raw_data:
    tarray.append(each.split())
A = np.array(tarray, dtype='int64')
N = A.shape[0]

def Restoring_Road_Network():

    import scipy.sparse.csgraph as graph

    MAX = [10000000000]*N  # should be > 2*10**9
    d = np.diag(MAX)
    C = A.copy()
    C += d
    total_dis = 0
    n_path = 0
    for i in range(N-1):
        for j in range(i+1, N):
            dis_two_node = np.min(C[i] + C[j])
            if dis_two_node > C[i,j]:
                total_dis += C[i,j]
                # print(i, j)
            elif dis_two_node < C[i,j]:
                print(-1)
                exit()

    print(total_dis)

Restoring_Road_Network()

Measured memory_bytes: 26716
n, m=map(int,input().split())
A=[input() for _ in range(n)]
B=[input() for _ in range(m)]

def dfs(y, x):
    for Y in range(m):
        for X in range(m):
            if A[y+Y][x+X]!=B[Y][X]:
                return False
    return True

ans="No"
for y in range(n-m+1):
    for x in range(n-m+1):
        if A[y][x]==B[0][0]:
            if dfs(y,x):
                ans="Yes"
                break
    else:
        continue
    break

print(ans)

Measured memory_bytes: 9020
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5+10;
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;cin>>n>>m;
    if(n>m)
        swap(n,m);
    if(n==1)
        cout<<abs(m-2);
    else
        cout<<(n-2)*(m-2);

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n=0,p=0,count=0,answer=0;



while(1){
cin >> n >> p;
vector<int> v(n,0);
if(n==0&&p==0)
  return 0;
  while(1){
    for(int i=0;i<n;i++){
      if(p==0){

        if(v[i]!=0){
          p+=v[i];
          v[i]=0;
          count=0;
        }else{
          count++;
        }

      }else{
        v[i]++;
        p--;
        count=0;
      }
      if(count==n-1){
      //  cout << count << endl;
        break;
      }
    }if(count==n-1){
    //  cout << count << endl;
      break;
    }


  }


  for(int i=0;i<n;i++){
    if(v[i]!=0){
      answer = i;
    }
  }

  cout<<answer<<endl;
}
}



Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli n,ans=0,x=10;
    vector<lli> f;
    lli i=0,j,k;
    cin>>n;
    if((n<10)||(n%2==1)){
        ans=0;
    }
    else{
        while(x<=n){
            ans+=n/x;
            x*=5;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8         as BS
import           Data.List
import           Data.Char
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                   as VC
import qualified Data.Vector.Mutable           as VM

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n =
  replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n =
  replicateM n (map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

main :: IO ()
main = do
  [n, k] <- readInts
  s      <- getLine
  putStrLn $ solve s k
  return ()

solve :: String -> Int -> String
solve s k = a ++ [(toLower $ head b)] ++ (tail b)
  where (a, b) = splitAt (k - 1) s


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

using namespace std;

int solve(){
	long long k;
	int n;
	cin>>n;
	cin>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int slow = 1;
	int fast = a[1];
	while(slow!=fast){
		slow = a[slow];
		fast = a[a[fast]];
		k--;
		if(k==0)
			return slow;
	}
	int length = 1;
	fast = a[fast];		
	while(slow!=fast){
		//cout<<fast<<"->";
		fast = a[fast];
		length++;
	}
	k = k % length;
	while(k--){
		slow = a[slow];
	}

	return slow;
}
int main(){
	
	cout<<solve();

	return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    int N, M;
    cin >> N >> M;
    // vector< vector<int> > edges(N,vector<int>());
    vector<P> edges(M);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        // edges[a].push_back(b);
        // edges[b].push_back(a);
        edges[i].first = a;
        edges[i].second = b;
    }

    int ans = 0;
    REP(i, M) {
        UnionFind uf = UnionFind(N);
        REP(j, M)
            if(i != j) uf.unite(edges[j].first, edges[j].second);

        set<int> parents;
        REP(i, N) parents.insert(uf.find(i));
        if(parents.size() > 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
# coding: utf-8
# Your code here!

S=list(input())
S=list(map(int,S))[::-1]


mod=[0]*2019
mod[0]+=1

ans=0
temp=0
p=1
for i in range(len(S)):
    temp+=S[i]*p
    p=p*10%2019
    temp%=2019
    ans+=mod[temp]
    mod[temp]+=1

print(ans)


Measured memory_bytes: 13580
#include <stdio.h>
#define MAX_V 1000000
int prime[MAX_V+1] = {0};
int primeSum[MAX_V+2] = {0};
int main(){
    int i, k, n;

    for(i = 2; i <= MAX_V; i++){
        prime[i] = 1;
    }
    for(i = 2; i * i <= MAX_V; i++){
        if(prime[i]){
            for(k = 2*i;k <= MAX_V; k += i){
                prime[k] = 0;
            }
        }
    }

    for(i = 0; i < MAX_V + 2; i++){
        primeSum[i] = primeSum[i-1] + prime[i];
    }

    while(scanf("%d", &n) != EOF){
        printf("%d\n",primeSum[n]);
    }
    return 0;
}

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

int main() {
    int A, B, C; cin >> A >> B >> C;
    int X, Y; cin >> X >> Y;
    if(Y>X) {
        swap(X, Y);
        swap(A, B);
    }

    if(A > 2*C){
        cout << C * X * 2 << endl;
    } else if((A+B)/2.0 >= C ){
        cout << C * Y * 2 + A * (X-Y) << endl;
    } else {
        cout << A * X + B * Y << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static char[] moji = "atcoder@".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var buy = A[0];

        var money = 1000L;
        var kabu = 0L;

        var asd = false;

        for (int i = 0; i < N - 1; i++)
        {
            if (asd)
            {
                if (A[i] > A[i + 1])
                {
                    money += kabu*(A[i]);
                    asd = false;
                }
            }
            else
            {
                if (A[i] < A[i + 1])
                {
                    buy = A[i];
                    kabu = money / buy;
                    money = money % buy;
                    asd = true;
                }
            }
            
        }

        if (asd)
        {
                money += kabu * (A[N-1]);
                asd = false;
        }

        Console.WriteLine(money);
    }
        

    
}


Measured memory_bytes: 28188
def main():
  N,M=map(int,input().split())

  r=[[]for i in range(N)]
  for i in range(M):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)

  p=[-1]*N
  q=[0]
  while q:
    i=q.pop(0)
    for j in r[i]:
      if p[j]==-1:
        p[j]=i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()


Measured memory_bytes: 33640
# import itertools
import math


def get_data_size(data):
    """桁数を求める

    Args:
        data (int): 数値

    Returns:
        [int]: 桁数
    """
    return int(math.log10(data) + 1)


def solve(N):
    ans = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 == 1:
            ans += 1
    return ans


N = int(input())
# S = input()
# A, B = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}
    int ans = 0;
    int len = 0;
    int bef = a[0];
    rep1(i, n-1){
        if (a[i] == a[i-1]){
            len++;
        } else {
            ans += (len+1)/2;
            len = 0;
        }
        bef = a[i];
    }
    ans += (len+1)/2;
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n, limit = map(int, input().split())
    
    jobs = defaultdict(deque)

    for _ in range(n):
        d, v = map(int, input().split())
        jobs[d].append(v)

    money = 0
    available_jobs = []

    for d in range(1, limit+1):
        if d in jobs:
            for j in jobs[d]:
                heappush(available_jobs, -j)

        if available_jobs:
            money += -heappop(available_jobs)

    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75848
import java.util.*;
public class Main {
	    public static void main(String[] args) throws Exception {
	        
	        @SuppressWarnings("resource")
			Scanner scanner = new Scanner(System.in);
	        int A = scanner.nextInt();
	        int B = scanner.nextInt();
	        System.out.println(B % A == 0?A+B:B-A);
	    }
	}

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

int main()
{
  unsigned N, K;
  std::cin >> N >> K;
  
  unsigned long long int S = K;
	for(unsigned n=0; n<N-1; ++n)
  {
    S *= K - 1;
  }
  std::cout << S << std::endl;
  
  return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

string s;

ll shrnk(char c){
   //すべてをcにするのに最低何回かかるか
   ll ans = 0;
   REP(i, s.size()){
      if(s.find(c, i) == -1) chmax(ans, (ll)(s.size()) - i);
      else{
         chmax(ans, (ll)s.find(c, i) - i);
      }
   }
   return ans;
}
int main(){
   cin >> s;
   ll ans = INF;
   REP(i, 26){
      chmin(ans, shrnk('a' + i));
//      cout << "shrnk(" << (char)('a' + i) << ") = " << shrnk('a' + i) << endl;
   }
   cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  char s[H][W];
  for (int i = 0; i < H; i++)
    cin >> s[i];
  bool check[H][W];
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
      check[i][j] = false;
  }
  int dy[4] = {0, 1, 0, -1};
  int dx[4] = {-1, 0, 1, 0};
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (s[i][j] == '#')
      {
        for (int d = 0; d < 4; d++)
        {
          int y = i + dy[d];
          int x = j + dx[d];
          if (y < 0 || H <= y || x < 0 || W <= x)
            continue;
          if (s[y][x] == '#')
            check[i][j] = true;
        }
      }
    }
  }
  string ans = "Yes";
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (s[i][j] == '#' && !check[i][j])
        ans = "No";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;



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

	vector<vector<ll>> cake(n, vector<ll>(3));
	
	for (int i = 0; i < n; i++) {
		cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
	}

	
	ll ans = 0;
	for (int b = 0; b < (1 << 3); b++) {
		priority_queue<vector<ll>>pq;

		for (int i = 0; i < n; i++) {
			ll val = 0;
			for (int j = 0; j < 3; j++) {
				val += (((b >> j) & 1) == 1 ? 1 : -1)* cake[i][j];
			}

			pq.push(vector<ll>{val, cake[i][0] ,cake[i][1] ,cake[i][2]});
			 
		}


		ll sumX = 0;
		ll sumY = 0;
		ll sumZ = 0;
		for (int i = 0; i < m; i++) {
			sumX += pq.top()[1];
			sumY += pq.top()[2];
			sumZ += pq.top()[3];
			pq.pop();


		}

		ans = max(ans, abs(sumX) + abs(sumY) + abs(sumZ));
	}

	cout << ans << endl;
}  



Measured memory_bytes: 384
gets

inputs = gets.chomp.split.map{ |x| x.to_i }

count = 0

(0 ... (inputs.size - 2)).each { |i|
	if [inputs[i] , inputs[i+1] ,inputs[i+2]].sort[1] == inputs[i+1] then
		count += 1
	end
}

puts count

STDOUT.flush


Measured memory_bytes: 1788