akhauriyash/Code-Regression huggingface dataset:
#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 debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<pair<ll,int>> v(n);
    rep(i,n){
        ll t;cin>>t;
        v[i]=make_pair(t,i);
    }
    sort(ALL(v));reverse(ALL(v));

    ll dp[n+1][n+1]={};

    rep(i,n){
        ll num=v[i].first,idx=v[i].second;

        // 左にj個ある, 右にi-j個ある
        for(int j=0;j<=i;j++){
            int l=j,r=n-1-(i-j);
            chmax(dp[l+1][r],dp[l][r]+num*(abs(l-idx)));
            chmax(dp[l][r-1],dp[l][r]+num*(abs(r-idx)));
        }
    }

    ll ans=0;
    rep(i,n+1){
        rep(j,n+1){
            chmax(ans,dp[i][j]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 34968
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Numerics;




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


            //int n = int.Parse(Console.ReadLine());
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();




            int n = int.Parse(Console.ReadLine());
            
            
            
            var pc = new int[n];
            for (int i =0; i< n; i++)
            {
                pc[i] = int.Parse(Console.ReadLine());
            }
            var plug = new int[n];
            for (int i = 0; i < n; i++)
            {
                plug[i] = int.Parse(Console.ReadLine());
            }

            var arr = new int[n * 2];
            pc.CopyTo(arr, 0);
            plug.CopyTo(arr, pc.Length);
            Array.Sort(arr);

            var setPC = new HashSet<int>(pc);
            var setPL = new HashSet<int>(plug);

            long count = 1;

 

            long mod = 1000000007;

            int countPC = 0;
            int countPL = 0;
            for(int i=0; i<2* n; i++)
            {
                int cur = arr[i];

                if(setPC.Contains(cur))
                {
                    if (countPL > 0)
                    {
                        count *= (long)countPL;
                        count %= mod;
                        countPL--;

                    }
                    else countPC++;
                }
                else
                {
                    if (countPC > 0)
                    {
                        count *= (long)countPC;
                        count %= mod;
                        countPC--;
                    }
                    else countPL++;
                }
            }



            

            //count %= mod;

            Console.WriteLine(count);






        }

       
       

    }

   
    
}


Measured memory_bytes: 11856
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    unordered_map<string,int> mp;
    ll ans = 0;
    REP(i,N){
        string tmp; cin >> tmp;
        vector<char> tmpc(10);
        REP(j,10){
            tmpc[j] = tmp[j];
        }
        sort(tmpc.begin(), tmpc.end());
        string tmpstr = "";
        REP(k,10) tmpstr = tmpstr + tmpc[k];
        mp[tmpstr] += 1;
        if(mp[tmpstr] > 1){
            ans += mp[tmpstr] - 1;
        }
       
    }
   
    cout << ans;
    
    return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
vector.erase(vector.begin() + index);
}

ll modpow(ll a,ll n,ll m){
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll m){
  return modpow(a,m-2,m);
}

ll modCON(ll n,ll r,ll m){
  ll res = 1;
  for(ll i = 1;i < n+1;i++){
    res *= i;
    res %= m;
  }
  for(ll i = 1;i < r + 1;i++){
    res *= modinv(i,m);
    res %= m;
  }
  for(ll i = 1;i < n - r + 1;i++){
    res *= modinv(i,m);
    res %= m;
  }
  return res;
}

int main(){
  ll N,K;
  cin >> N >> K;
  for(ll i = 1;i < K+1;i++){
    if(N-K+1 >= i){
      cout << modCON(K-1,i-1,MOD) * modCON(N-K+1,i,MOD) % MOD << endl;
    }else{
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x, y;
    cin >> x >> y;
    if(4*x-y >= 0 && y-2*x >= 0 && y%2 == 0) { 
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;    
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<double>> x(n, vector<double>(d));
	rep(i, n)
	{
		rep(j, d)
		{
			cin >> x[i][j];
		}
	}
	size_t ans = 0;
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = i + 1; j < n; j++)
		{
			double distance = 0;
			for (size_t k = 0; k < d; k++)
			{
				distance += pow(x[i][k] - x[j][k], 2);
			}
			distance = sqrt(distance);
			if (distance == floor(distance))
			{
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  if(a>b){
    cout << 0 << endl;
  }else if(a==b){
    cout << 1 << endl;
  }else{
    if(n==1){
      cout << 0 << endl;
    }else{
      long long ans=1;
      ans=max(1ll,(b-a)*(n-2)+1);
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

// DAME:

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(si, h)rep(sj, w){
        if(s[si][sj]=='#') continue;
        vector<vector<int>> dist(h, vector<int> (w, inf));
        queue<P> q;
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != inf) return;
            dist[i][j] = x;
            q.push(P(i, j));
        };

        update(si, sj, 0);
        while(!q.empty()){
            int i = q.front().first;
            int j = q.front().second;
            q.pop();

            rep(dir, 4){
                int ni = i+dx[dir], nj = j+dy[dir];
                if (ni<0 || ni>=h || nj<0 || nj>=w) continue;
                if(s[ni][nj]=='#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i, h)rep(j, w){
            if(dist[i][j] == inf) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- readLn :: IO Int
  abz <- replicateM n $ (\[x,y] -> (x,y)) . map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [(Int,Int)]


  let abz' = sortBy (\(x,y) (z,u) -> case compare u y of
                                   LT -> LT
                                   GT -> GT
                                   EQ -> compare z x
                ) abz

  -- print abz'

  putStrLn $ solve abz'
  -- print $ solve' abz'

solve :: [(Int,Int)] -> String
solve [] = "Yes"
solve [(x,y)] = if y - x >= 0 then "Yes" else "No"
solve ((x,y):(z,u):xyz) = if y - x >= u
                          then solve ((z,u):xyz)
                          else solve ((z,y-x):xyz)

solve' :: [(Int,Int)] -> [(Int,Int)]
solve' [] = []
solve' [(x,y)] = [(x,y)]
solve' ((x,y):(z,u):xyz) = if y - x >= u
                           then (x,y) : solve' ((z,u):xyz)
                           else (x,y) : solve' ((z,y-x):xyz)


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  vector<ll> csum;
  partial_sum(va.begin(), va.end(), back_inserter(csum));

  ll ans = -1;
  for (int i = 0; i < 2; ++i) {
    ll diff = 0, cnts = 0;
    for (int j = 0; j < n; ++j) {
      ll a = csum[j] + diff;
      if (j % 2 == i && a >= 0) {
        diff -= a + 1;
        cnts += a + 1;
      } else if (j % 2 != i && a <= 0) {
        diff += -a + 1;
        cnts += -a + 1;
      }
    }

    if (ans < 0 || ans > cnts) {
      ans = cnts;
    }
  }

  cout << ans << '\n';

  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int a[3][3];
    rep(i, 3){
        rep(j, 3){
            cin >> a[i][j];
        }
    }
    int n; cin >> n;
    bool card[3][3] = {};
    rep(i, n){
        int b; cin >> b;
        rep(i, 3){
            rep(j, 3){
                if(a[i][j] == b) card[i][j] = true;
            }
        }
    }
    rep(i, 3){
        if(card[i][0] == card[i][1] && card[i][0] == card[i][2] && card[i][0]){
            cout << "Yes" << endl;
            return 0;
        }
        if(card[0][i] == card[1][i] && card[0][i] == card[2][i] && card[0][i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(card[0][0] == card[1][1] && card[0][0] == card[2][2] && card[0][0]){
        cout << "Yes" << endl;
        return 0;
    }else if(card[0][2] == card[1][1] && card[0][2] == card[2][0] && card[0][2]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7') {
        Yes();
        return 0;
    }
    No();
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) << endl
 
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = (1<<20);
const ll inf = 1e9+7;
const ll VAL = 20;
int main() {
	fastio;
	 ll l,r,d,ans;
	 cin>>l>>r>>d;
	 ans =(r/d)-(l/d);
	 if (l % d == 0) ans++; 
	 cout<<ans<<"\n";
	return 0;
}

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

using namespace std;
#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;

#define pb push_back
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int mod = 1e9+7;

ll pwr(ll a, ll b){
    a %= mod;
    ll ans = 1;
        while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    
    return ans;
}

int main(){
    IOS

    char c ; cin>>c;
    cout<<(++c)<<"\n";


    


}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    S = input().split()
    stack = []
    for st in S:
        if st == '+':
            b = stack.pop()
            a = stack.pop()
            stack.append(a + b)
        elif st == '-':
            b = stack.pop()
            a = stack.pop()
            stack.append(a - b)
        elif st == '*':
            b = stack.pop()
            a = stack.pop()
            stack.append(a*b)
        else:
            stack.append(int(st))
    ans = stack[0]
    print(ans)
if __name__ == '__main__':
    main()


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

const double INF = 1e8;

struct Edge {
	int dst, cost, lim;
	Edge(){}
	Edge(int dst, int cost, int lim): dst(dst), cost(cost), lim(lim){}
};

struct State {
	int pos, prev, speed;
	double sum;
	State(){}
	State(int pos, int prev, int speed, double sum): pos(pos), prev(prev), speed(speed), sum(sum){}
	bool operator < (const State &t) const {return sum > t.sum;}
};

int n, m;
int st, gl;
vector<Edge> g[30];
double dist[30][30][31];

void solve()
{
	priority_queue<State> pq;
	fill_n(**dist, 30 * 30 * 31, INF);
	dist[st][st][0] = 0.0;
	pq.push(State(st, st, 0, 0.0));
	double res = INF;
	while (pq.size()){
		auto s = pq.top(); pq.pop();
		if (s.pos == gl && s.speed == 1) res = min(res, s.sum);
		if (dist[s.pos][s.prev][s.speed] < s.sum) continue;
		for (auto &e : g[s.pos]){
			if (e.dst == s.prev) continue;
			for (int ns = s.speed - 1; ns <= s.speed + 1; ns++){
				if (ns <= 0 || ns > e.lim) continue;
				double cost = (double)e.cost / ns;
				if (dist[e.dst][s.pos][ns] > s.sum + cost){
					dist[e.dst][s.pos][ns] = s.sum + cost;
					pq.push(State(e.dst, s.pos, ns, s.sum + cost));
				}
			}
		}
	}
	if (res == INF) puts("unreachable");
	else printf("%.20f\n", res);
}

int main()
{
	while (scanf("%d %d", &n, &m), n){
		scanf("%d %d", &st, &gl); --st; --gl;
		for (int i = 0; i < 30; i++) g[i].clear();
		for (int i = 0; i < m; i++){
			int x, y, d, c;
			scanf("%d %d %d %d", &x, &y, &d, &c); --x; --y;
			g[x].push_back(Edge(y, d, c));
			g[y].push_back(Edge(x, d, c));
		}
		solve();
	}
}

Measured memory_bytes: 1912
N = int(input())
X = input()

a = int(X, 2)
b = X.count("1")

if b > 1:
    a1 = a % (b-1)
else:
    a1 = 0
a0 = a % (b+1)

for i in range(N):
    if X[i] == "1":
        if b == 1:
            print(0)
            continue
        t = (a1 - pow(2, N-1-i, b-1)) % (b-1)
    else:
        t = (a0 + pow(2, N-1-i, b+1)) % (b+1)
    
    ans = 1
    while t > 0:
        t %= bin(t).count("1")
        ans += 1
    print(ans)


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

int main() {
    string s;
    while (true) {
        for (int i = 0; i < 3; i++) {
            cin >> s;
            if (s == "0") return 0;
            int a = 0, b = 0;
            for (int i = 1; i < s.length(); i++) {
                if (s[i] == 'A') a++;
                else b++;
            }
            if (a - b == 1) a = a+1;
            if (b - a == 1) b = b+1;
            if (a < 10) b = 11;
            if (b < 10) a = 11;
            cout << a << ' ' << b << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,ans;
void solve(){
	cin>>n;
	string s;
	cin>>s;
	rep(i,0,n-2){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
int main()
{
	std::string in;
	std::cin >> in;

	int cnt1 = 0,cnt2 = 0;
	for (int i = 0; i < in.size(); i++) {
		if (in[i] == '0') cnt1++;
		if (in[i] == '1') cnt2++;

	}

	int ans = std::min(cnt1, cnt2) * 2;
	std::cout <<ans << std::endl;

	return 0;
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    int x=n*100/108;
    if(x*108/100 == n){
        cout<<x<<endl;
    }
    else if((x+1)*108/100 == n){
        cout<<x+1<<endl;
    }
    else cout<<":("<<endl;
}

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

class Team(object):
    def __init__(self, id, score):
        self.id = id
        self.score = score

    def __lt__(self, other):
        return self.score < other.score

while True:
    N = int(input())
    if N == 0:
        break;

    Teams = []
    for i in range(N):
        id,m1,s1,m2,s2,m3,s3,m4,s4 = [int(i) for i in input().split()]
        score = (m1+m2+m3+m4)*60 + (s1+s2+s3+s4)
        Teams.append(Team(id, score))

    Teams.sort()
    print(Teams[0].id)
    print(Teams[1].id)
    print(Teams[N-2].id)




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

int map[10][5];
int h,w=5;

int chain(int y,int x,int p,int *cnt){
  int ans=0;
  if(x+1<w && map[y][x+1]==p &&p>0  ){
    (*cnt)++;
    ans=max(ans,chain(y,x+1,p,cnt));
  }
  if(*cnt>=3){
    map[y][x]=0;
    ans=*cnt;
    return ans*p;
  }
  return ans;
    
}

void dlt(){
    while(1){
    int f=0;
    for(int i=h-1;i>=0;i--)
      for(int j=w-1;j>=0;j--){
	if(map[i][j]==0 && i-1>=0)swap(map[i][j],map[i-1][j]);
	else if(map[i][j]==0)map[i][j]=-1;
      }
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) if(map[i][j]==0)f=1;
    if(f==0) break;
  }
  
}

int main(){
  while(1){
  int ans=0,ansf=0;
  int cnt;
  cin>>h;
  if(h==0) break;
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>map[i][j];
  while(1){
    for(int i=0;i<h;i++)      
      for(int j=0;j<w;j++){
	cnt=1;
	ans+=chain(i,j,map[i][j],&cnt);
      }
    if(ansf==ans) break;
    ansf=ans;
    dlt();
  }
   cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int arr[N];
  int count=0;
  for(int i=1;i<=N;i++){
    cin>>arr[i];
  }
  for(int i=1;i<=N;i++){
    if(i%2!=0 && arr[i]%2!=0){
      count++;
    }
  }
     cout<<count;
  return 0;
}

Measured memory_bytes: 3532
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	if( tail + 1 == LEN ) tail = 0;
	else tail = tail + 1;
}

P dequeue(){
	P q;
	q = Q[head];
	if( head + 1 == LEN ) head = 0;
	else head = head + 1;
	return q;
}

int main(){
  int elaps = 0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;
  while( head != tail ){
	  if( Q[head].t <= q ){
		  elaps += Q[head].t;
		  u = dequeue();
		  printf("%s %d\n", u.name, elaps);
	  }
	  else if( Q[head].t > q ){
		  elaps += q;
		  Q[head].t -= q;
		  enqueue(Q[head]);
		  dequeue();
	  }
  }
  return 0;
}

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

void takahashi(long long* a, long long* b) {
	if (*a % 2 == 1)
		* a -= 1;
	*a = *a / 2;
	*b = *b + *a;
}

void aoki(long long* a, long long* b) {
	if (*b % 2 == 1)
		* b -= 1;
	*b = *b / 2;
	*a = *a + *b;
}

int main(void) {
	long long a, b;
	int k;
	cin >> a >> b >> k;
	long long* tmp;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			takahashi(&a, &b);
		}
		else {
			aoki(&a, &b);
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    int c[m];
    for(int i = 0;i < m;i++)cin >> c[i];
    
    int dp[n+2];
    for(int i = 0;i <= n;i++)dp[i] = 1e9;
    dp[0] = 0;
    
    for(int i = 0;i <= n;i++){
        for(int j = 0;j < m;j++){
            if(i + c[j] <= n){
                dp[i + c[j]] = min(dp[i + c[j]],dp[i] + 1);
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  vector<ll> H;
  set<ll> good;
  ll n,m;
  cin >> n >> m;
  H=vector<ll>(n);
  rep(i, 0, n-1){
    cin >> H[i];
    good.insert(i);
  }
  rep(i, 1, m){
    ll a,b;
    cin >> a;
    cin >> b;
    if(H[a-1]>H[b-1]){
      good.erase(b-1); 
    }else if(H[a-1]==H[b-1]){
      good.erase(b-1);
      good.erase(a-1);
    }else{
      good.erase(a-1);
    }
  }
  
  cout << good.size() << endl;
  return 0;
}


Measured memory_bytes: 8780
#include <iostream>
#include <vector>
#define INF 2147483647
using namespace std;
struct Edge {
	int to, cost;
	Edge(int to, int cost = -1) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > P;
P graph;
vector<int> dist;

bool bellman_ford(int n, int s) {
	dist = vector<int>(n, 0);
	for (int i = 0; i < n; i++) {
		for (int v = 0; v < n; v++) {
			for (int k = 0; k < graph[v].size(); k++) {
				Edge e = graph[v][k];
				if (dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					if (i == n - 1) return true;
				}
			}
		}
	}
	return false;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int V, E;cin >> V >> E;
	graph = P(V);
	for (int i = 0; i < E; i++) {
		int from, to;cin >> from >> to;
		graph[from].push_back(Edge(to));
	}

	if (bellman_ford(V, 0)) { cout << 1 << endl; }
	else { cout << 0 << endl; }
	return 0;
}

Measured memory_bytes: 3152
import math
N,H=(int(x) for x in input().split())
a=[]
b=[]
for n in range(N):
    aa,bb=(int(x) for x in input().split())
    a.append(aa)
    b.append(bb)
a_sort=sorted(a)
b_sort=sorted(b)
count=0
for n in range(N):
    if b_sort[N-1-n]>a_sort[N-1]:
        H=H-b_sort[N-1-n]
        count+=1
        if H<=0:
            break
if H>0:
    count=count+H//a_sort[N-1]
    if H%a_sort[N-1]>0:
        count+=1
print(count)


Measured memory_bytes: 12792
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int i,n,dp[50];
  scanf("%lld\n",&n);
  dp[0]=1,dp[1]=1;
  for(i=2;i<=n;i++){
    dp[i]=dp[i-1]+dp[i-2];
  }
  printf("%lld\n",dp[n]);
  return 0;
}


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

using namespace std;

vector<int> v;
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		v.push_back(x);
	}
	long long c1 = 0;
	long long sum = 0;
	for(int i = 0; i < n; ++i){
		sum += v[i];
		if(i & 1){
			if(sum == 0){
				sum = -1;
				++c1;
			}
			if(sum > 0){
				c1 += sum + 1;
				sum = -1;
			}
		}else{
			if(sum == 0){
				sum = 1;
				++c1;
			}
			if(sum < 0){
				c1 += abs(sum) + 1;
				sum = 1;
			}
		}
	}
	long long c2 = 0;
	sum = 0;
	for(int i = 0; i < n; ++i){
		sum += v[i];
		if(i & 1){
			if(sum == 0){
				sum = 1;
				++c2;
			}
			if(sum < 0){
				c2 += abs(sum) + 1;
				sum = 1;
			}
		}else{
			if(sum == 0){
				sum = -1;
				++c2;
			}
			if(sum > 0){
				c2 += sum + 1;
				sum = -1;
			}
		}
	}
	// cout << c1 << " " << c2 << endl;
	cout << min(c1, c2) << endl;
	return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

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

const long long int INF = 1e14;
typedef long long int ll;

using namespace std;

char bomb[52][52];
char count[52][52];

// -1,1
// 0,1
// 1,1
// -1,0
// 1,0
// -1,-1
// 0,-1
// 1,-1

int x_diff[] = {-1,0,1,-1,1,-1,0,1};
int y_diff[] = {1,1,1,0,0,-1,-1,-1};

int main(){
    int H,W;
    char c;
    cin >> H >> W;

    rep(i,H){
        rep(j,W){
            cin >> c;
            bomb[i][j] = c;
        }
    }
    rep(i,H){
        rep(j,W){
            if(bomb[i][j]=='#') cout << '#';
            else{
                int cnt=0;
                rep(k,8){
                    int x = i + x_diff[k];
                    int y = j + y_diff[k];
                    if (x<0||y<0||x>=H||y>=W) continue;//範囲
                    if (bomb[x][y]=='#') cnt ++;
                }
                cout << cnt;
            }
        }
        
        cout << "" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
a,b,c,d = I()
mx = max(a*c,a*d,b*c,b*d)
print(mx)

Measured memory_bytes: 83668
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

int main() {
    long long a, b, n, m, t, q, c, ans = 0;
    int x, s;
    cin >> n;
    vector<queue<int>> mq(n);
    map<string, int>mp;
    set<int> ss;
    for (int i = 0; i < n; i++){
        cin >> a;
        ss.insert(a);
    }
    cin >> m;
    for (int i = 0; i < m; i++){
        cin >> b;
        if (ss.count(b)) {
            continue;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const int N = (int) 1e6 + 5;
const int mod = (int) 1e9 + 7;

int n,c,k,t[N],ans;

int main(){
        cin >> n >> c >> k;

        for(int i = 1; i <= n; i ++)
                cin >> t[i];

        sort(t + 1,t + n + 1);

        int i = 1;

        while(i <= n){
                int pos = upper_bound(t + 1,t + n + 1,t[i] + k) - t - 1;
                if(pos - i + 1 > c)
                        ans ++,i += c;
                else{
                        if(i == pos)
                                ans ++,i ++;
                        else
                                ans ++,i = pos + 1;
                }
        }
        cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
a = list(map(int,input().split()))
count = 0
flag = False

while True:
    for i in range(len(a)):
        if a[i]%2 != 0:
            flag = True
            break
        else:
            a[i] = a[i] / 2
            flag = False
    if flag:
        break
    else:
        count += 1

print(count)

Measured memory_bytes: 3060
K, N = map(int, input().split())
A = list(map(int, input().split()))

maxLen = 0
for i in range(N):
  if i == N-1:
    maxLen = max(maxLen, K - A[i] + A[0])
  else:
    maxLen = max(maxLen, A[i+1] - A[i])

print(K - maxLen)


Measured memory_bytes: 78540
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   int n,a,b;cin>>n>>a>>b;
   int res = 0;
   REP(i,1,n){
       int sum = 0;
       string t = to_string(i);
       int sz = t.size();
       rep(j,sz)sum += t[j]-'0';
       if(sum>=a && sum<=b)res += i;
   }
   cout<<res;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 123456789123456789;
int main() {
	int N;
	cin >> N;
	vector<vector<long long> > A(N, vector<long long>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> A[i][j];
		}
	}
	vector<long long> score(1 << N);
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (!((i >> j) & 1)) continue;
			for (int k = 0; k < j; ++k) {
				if (!((i >> k) & 1)) continue;
				score[i] += A[j][k];
			}
		}
	}
	vector<long long> dp(1 << N);
	for (int i = 1; i < 1 << N; ++i) {
		dp[i] = -inf;
		for (int j = i; j > 0; j = (j - 1) & i) {
			dp[i] = max(dp[i], dp[i - j] + score[j]);
		}
	}
	cout << dp[(1 << N) - 1] << '\n';
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

bool compare_by_b(pair<int,int> a, pair<int,int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int,int> a, pair<int,int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

int par[200100];
int ranks[200100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=0;
    ranks[i]=0;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y){
    return ;
  }
  if(ranks[x]<ranks[y]){
    par[x]=y;
  }
  else{
    par[y]=x;
  }
  if(ranks[x]==ranks[y]){
    ranks[x]++;
  }
}

bool same(int x,int y){
  return find(x)==find(y);
}


int main(){
  init(200010);
  int N;
  cin>>N;
  int x,y;
  vector<pair <int,int>> pairs(N);
  for(int i=0;i<N;++i){
    cin>>x>>y;
    //点があるやつのみinitialize
    par[x]=x;
    par[100000+y]=100000+y;
    pairs[i]=make_pair(x,y);
  }
  //まずはxでソート
  sort(pairs.begin(),pairs.end(), compare_by_a);
  //xが同じやつつながりでくくっていく
  long long counter=0;
  bool judge=false;
  pair <int,int> target, target_2;
  while(counter<N){
    target=pairs[counter];
    unite(target.first,target.second+100000);
    judge=true;
    while(judge){
      //一個進める
      target_2=pairs[counter+1];
      if(target.first!=target_2.first){
        //失敗
        break;
      }
      else{
        unite(target.first,target_2.second+100000);
        counter+=1;
      }
    }
    counter+=1;
  }
  //yでソート
  sort(pairs.begin(),pairs.end(), compare_by_b);
  counter=0;
  while(counter<N){
    target=pairs[counter];
    judge=true;
    while(judge){
      //一個進める
      target_2=pairs[counter+1];
      if(target.second!=target_2.second){
        //失敗
        break;
      }
      else{
        unite(target.second+100000,target_2.first);
        counter+=1;
      }
    }
    counter+=1;
  }
  long long num;
  //各ペアについて親を数えていく
  long long X[200010]={};
  long long Y[200010]={};
  for(int i=1;i<=100000;++i){
    if(par[i]!=0){
      num=find(par[i]);
      X[num]+=1;
    }
  }
  for(int i=1;i<=100000;++i){
    if(par[i+100000]!=0){
      num=find(par[i+100000]);
      Y[num]+=1;
    }
  }
  long long ans=0;
  for(int i=1;i<=200010;++i){
    ans+=X[i]*Y[i];
  }
  cout<<ans-N<<"\n";
return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int H, W; cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W, 0));
	int cnt = 0;
	vector<pair<int, int>> ans;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < H - 1; ++i) {
		for (int j = 0; j < W; ++j) {
			if (a[i][j] % 2 == 1) {
				cnt++;
				a[i][j]--;
				a[i + 1][j]++;
				ans.push_back({i + 1, j + 1});
				ans.push_back({i + 2, j + 1});
			}
		}
	}
	for (int i = 0; i < (W - 1); ++i) {
		if (a[H - 1][i] % 2 == 1) {
			cnt++;
			a[H - 1][i]--;
			a[H - 1][i + 1]++;
			ans.push_back({H, i + 1});
			ans.push_back({H, i + 2});
		}
	}
	int loop = 0;
	cout << cnt << endl;
	for (auto& p : ans) {
		if (loop % 2 == 0) {
			cout << p.first << " " << p.second << " ";
		} else {
			cout << p.first << " " << p.second << endl;
		}
		loop++;
	}
	return;
}
int main() {
	solve();
	return 0;
}

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

a = [0]*31

for i in range(N):
    questionary = list(map(int,input().split()))
    for i in range(1,questionary[0]+1):
        a[questionary[i]] += 1

ans = 0

for i in a:
    if i == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    ll h;
    cin >> h;

    ll count=0;
    ll plus=1;
    while(h!=0){
        h/=2;
        count+=plus;
        plus*=2;
    }

    // queue<ll> monster;
    // monster.push(h);
    // ll count = 0;
    // while(!monster.empty()){
    //     if(monster.front()==1){
    //         monster.pop();
    //         count++;
    //         continue;
    //     }
    //     monster.push(monster.front()/2);
    //     monster.push(monster.front()/2);
    //     monster.pop();
    //     count++;
    // }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3612
N=int(input())
AB=[list(map(int,input().split()))+[i] for i in range(N)]
A=sorted(AB,key=lambda x:x[1]+x[0],reverse=True)
value=0
for i in range(N):
    if i%2==0:
        value+=A[i][0]
    else:
        value-=A[i][1]
print(value)


Measured memory_bytes: 67160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<i64,i64>;

i64 gcd(i64 n,i64 m){return m?gcd(m,n%m):n;}
int main(){
    string S;
    cin >> S;

    int p = 0;
    bool in = false;
    string T = "";
    string U = "";
    rep(i,S.size()){
        if(S[i] == '.' || S[i] == ')' || S[i] == '(') continue;
        T += S[i]; 
    }
    rep(i,S.size()){
        if(S[i] == '(') in = true;
        if(S[i] == '.' || S[i] == ')' || S[i] == '(') continue;
        if(in) U += S[i];
    }
    for(int i=S.size() -1; i >= 0; i--){
        if(S[i] == '.') break;
        if(S[i] == ')' || S[i] == '(') continue;
        p++;
    }

    i64 t = stoi(T);
    if(U.size() == 0) U += '0';
    i64 u = stoi(U);
    t -= u;
    t = max(t, (i64)0);

    i64  tbunbo = 1;
    rep(i, p) tbunbo *= 10;

    i64 a = p - U.size();
    i64 ubunbo = 1;
    rep(i, a) ubunbo *= 10;
    ubunbo = tbunbo - ubunbo;

    i64 tgcd = gcd(t, tbunbo);
    i64 ugcd = gcd(u, ubunbo);

    t /= tgcd;
    tbunbo /= tgcd;

    u /= ugcd;
    ubunbo /= ugcd;

    i64 bunbo = tbunbo * ubunbo;
    t *= ubunbo;
    u *= tbunbo;

    i64 bunshi = t + u;

    i64 d = gcd(bunshi, bunbo);
    bunshi /= d;
    bunbo /= d;

    cout << bunshi << '/' << bunbo << endl;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n); rep(i, n) cin >> A[i];
  vector<int> ans(n);
  rrep(i, n) {
    ll sum = 0;
    for(int j=1; (i+1)*j<=n; j++) {
      sum += ans[(i+1)*j-1];
    }
    if(sum%2 != A[i]) ans[i]++;
  }
  cout << accumulate(all(ans), 0LL) << endk;
  rep(i, n) if(ans[i] == 1) cout << i+1 << endk;
  return 0;
}


Measured memory_bytes: 4744
#include<stdio.h>
#include<math.h>
int main(void){
    double r,a=M_PI;
    scanf("%lf\n",&r);
    // x=r*r*a;
    // y=2*r*a;
    printf("%lf %lf\n",r*r*a,2*r*a);
    return 0;
}


Measured memory_bytes: 2092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int n,m;
    cin >> n >> m;
    vvi dp(m+1,vi(1<<n,INF));
    dp[0][0] = 0;

    rep(i,m){
        int a,b;
        cin >> a >> b;
        int ne = 0;
        rep(j,b){
            int c;
            cin >> c;c--;
            ne |= 1<<c;
        }
        rep(bit,1<<n)if(dp[i][bit] < INF){
            //つかう
            dp[i+1][bit|ne] = min(dp[i+1][bit|ne], dp[i][bit] + a);
            //つかわない
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit]);
        }
    }

    int ans = dp[m].back();
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


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

int main() {
	int N, A[101] = {};
	cin >> N;

	int count = 0;

	repeat(i, N) {
		cin >> A[i + 1];
		if (A[i] == A[i + 1]) {
			A[i + 1] = 0;
			count++;
		}
	}

	cout << count << endl;
	return 0;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int a,b;
    cin >> a >> b;
    if (a >= 1 && a <= 9) {
        if (b >= 1 && b <= 9) {
            cout << a*b << endl;
        } else {
            cout << -1 << endl;
        }
    } else cout << -1 << endl;
    return 0;
}




Measured memory_bytes: 256
s = list(input())
num = len(s)
ans = 0
for i in range(2**(num-1)):
    ls = [0 for _ in range(num-1)]
    for j in range(num-1):
        if (i>>j)&1:
            ls[j]=1
    ls.insert(0,0)
    j = 1
    for i in range(num):
        if ls[num-1-i]==0:
            ans += int(s[num-i-1])*j
            j *=10
        else:
            ans += int(s[num-i-1])*j
            j =1
print(ans)

Measured memory_bytes: 41328
#include <iostream>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n >> s;
    
    int def=0;
    for(int i=0;i<n;i++){
        if(s[i]=='.'){
            def++;
        }
    }
    
    int res=def;
    for(int i=0;i<n;i++){
        if(s[i]=='#'){
            def++;
        }else if(s[i]=='.'){
            def--;
        }
        
        if(def<res){
            res=def;
        }
    }
    
    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    int k, foods[m] = {};
    int food;
    for (int i = 0; i < n; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> food;
            foods[food-1]++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < m; i++) {
        if (foods[i] == n) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

ll gcd(ll a1,ll b1){
	ll res=a1%b1;
	if(res==0)return b1;
	return gcd(b1,res);
}
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll g=gcd(c,d);
	ll r1=b/c+b/d-b/((c*d)/g);
	a--;
	ll r2=a/c+a/d-a/((c*d)/g);
	cout<<(b-a)-r1+r2<<endl;
	return 0;
}


Measured memory_bytes: 256
#define MOD 1000000007
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    int m = min(K, X * Y * Z);
    priority_queue<ll> ans;
    for (ll i = 0; i < X; i++) {
        for (ll j = 0; j < Y; j++) {
            for (ll k = 0; k < Z; k++) {
                if (i * j * k > m) break;
                ans.push(A[i] + B[j] + C[k]);
            }
        }
    }
    for (int i = 0; i < K; i++) {
        cout << ans.top() << endl;
        ans.pop();
    }
}


Measured memory_bytes: 35176
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

attrs.flatten!
k = attrs.pop
ng = 0
for i in 0..(attrs.length - 1) do
  for j in 0..(attrs.length - 1) do
    if i == j then
      next
    end
    if (attrs[i] - attrs[j]).abs > k then
      ng = 1
    end
  end
end

if ng == 0 then
  puts "Yay!"
else
  puts ":("
end

Measured memory_bytes: 3836
#include <stdio.h>

constexpr unsigned int MAX_N = 10'000;
unsigned int A[MAX_N + 1];

int main(void){
    unsigned int n, W; scanf("%u%u", &n, &W);
    for(unsigned int i = 0; i < n; ++i){
        unsigned int v, w; scanf("%u%u", &v, &w);
        if(w > W) continue;
        for(unsigned int i = W, j = W - w; j > 0; --i, --j){
            if(A[j] and A[i] < A[j] + v) A[i] = A[j] + v;
        }
        if(A[w] < v) A[w] = v;
    }
    unsigned int res = 0;
    for(unsigned int i = 1; i <= W; ++i) if(res < A[i]) res = A[i];
    printf("%u\n", res);
    return 0;
}


Measured memory_bytes: 2772
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,a=0,b=0,c=0,d=0;
	cin>>n;
	string s;
	while(n--){
		cin>>s;
		if(s=="AC")
		a++;
		if(s=="WA")
		b++;
		if(s=="TLE")
		c++;
		if(s=="RE")
		d++;
	}
	cout<<"AC x "<<a<<"\n";
		cout<<"WA x "<<b<<"\n";
			cout<<"TLE x "<<c<<"\n";
				cout<<"RE x "<<d<<"\n";	

	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<string>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli x,k,n,c,las;
	c=0;
	cin>>n>>k;
	if(k*2<n){
		cout<<n-(k*2);
		return 0;
	}
	
	cout<<0;
	// x='Z';
	// las=int('Z');
	// if('Z'-(s[0]+k)>=0)cout<<(char)(s[0]+2);
	// cout<<'Z'<<" "<<(s[0]+k);
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,a,b,c,d;
  cin >> N;
  a=N/1000;
  b=(N-a*1000)/100;
  c=(N-a*1000-b*100)/10;
  d=N-a*1000-b*100-c*10;
  if(a==b&&b==c || b==c &&c==d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,a[20005],b[20005],x;
int main()
{
	scanf("%d",&n);
	fz1(i,n)a[i]=b[i]=1;
	fz1(i,n){
		scanf("%d",&x);
		a[x]+=i-1;b[x]+=i-1;
	}
	fz1(i,n){
		a[i]+=a[i-1];
	}
	fd1(i,n){
		b[i]+=b[i+1];
	}
	fz1(i,n){
		printf("%d ",a[i]);
	}
	puts("");
	fz1(i,n){
		printf("%d ",b[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <map>
using namespace std;
long long n, sti, a, b;
map<int, int> mp;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> sti;
        if (mp[sti] == 1) {
            if (sti > a) b = a, a = sti;
            else if (sti > b) b = sti;
        } if (mp[sti] == 3) {
            if (sti == a) b = sti;
        } 
        mp[sti]++;
    }
    cout << a * b << endl;
}


Measured memory_bytes: 4992