akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main(void){
    int N;cin>>N;
    vector<ll> A(N);
    REP(i,N)cin>>A[i];

    ll res=0;
    for(int d=0;d<60;d++){
        ll n0=0,n1=0;
        for(int i=0;i<N;i++){
            if((A[i]>>d)&1)n1++;
            else n0++;
        }
        ll tmp=(1ll<<d)%MOD;
        ll n=n0*n1%MOD;

        tmp=tmp*n%MOD;
        res=(res+tmp)%MOD;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    int Rx, Lx, Uy, Ly;
    Rx = x + r;
    Lx = x - r;
    Uy = y + r;
    Ly = y - r;
    
    if ((0 <= Lx) && (Rx <= W) && (0 <= Ly) && (Uy <= H))
    cout << "Yes" << endl;
    
    else cout << "No" << endl;
    
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N;

int ma[360];

signed main(){
    cin>>N;
    while(N--){
        int m,d,v,s;
        cin>>m>>d>>v>>s;
        m--;d--;

        int l=m*30+d;
        int r=l+v-1;

        for(int i=-360*10;i<=360*10;i++){
            int tmp;
            if(i<l)tmp=s-(l-i);
            else if(l<=i&&i<=r)tmp=s;
            else tmp=s-(i-r);
            chmax(tmp,0ll);
            chmax(ma[(i+360*114)%360],tmp);
        }
    }

    cout<<*min_element(ma,ma+360)<<endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
    while (1) {
        int a, b;
        cin >> a >> b;

        if (a == 0 && b == 0) {
            break;
        } else {
            if (a < b) {
                cout << a << ' ' << b << endl;
            } else {
                cout << b << ' ' << a << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define MAX 1000010
int n,ans;
char s[MAX],t[MAX];
queue<int> Q;
int main()
{
	scanf("%d",&n);scanf("%s",s+1);scanf("%s",t+1);
	if(!strcmp(s+1,t+1)){puts("0");return 0;}
	for(int i=n,p=n;i;--i)
	{
		if(t[i]==t[i-1])continue;
		p=min(p,i);while(p&&s[p]!=t[i])--p;
		if(!p){puts("-1");return 0;}
		while(!Q.empty())
			if((int)Q.front()-(int)Q.size()>=i)Q.pop();
			else break;
		Q.push(p);if(i^p)ans=max(ans,(int)Q.size());
	}
	printf("%d\n",ans+1);return 0;
}


Measured memory_bytes: 6272
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if i==0:
        is_equal_to_left = False
    else:
        is_equal_to_left = H[i-1] == H[i]
    
    if is_equal_to_left:
        pass
    else:
        H[i] -= 1

        
H_sorted = sorted(H)

if H == H_sorted:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14224
#import<ios>
int64_t r,d,i,b,c,z=500;main(){char s[z*=z];scanf("%s",s);for(;i<z;d=b^c?0:d)b=s[i]==66,c=s[i+1]>66,s[i++]<66?d++:r+=b&c?d:0;printf("%lld",r);}

Measured memory_bytes: 384
s = list(input())

f1 = s == list(reversed(s))
f2 = s[:(len(s)-1)//2] == list(reversed(s[:(len(s)-1)//2]))
f3 = s[(len(s)+2)//2:] == list(reversed(s[(len(s)+2)//2:]))
print("Yes" if all([f1, f2, f3]) else "No")

Measured memory_bytes: 8680
# coding: utf-8

# In[29]:


N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))


# In[30]:


x.append(X)
sorted_x = sorted(x)
y.append(Y)
sorted_y = sorted(y)


# In[31]:


if sorted_x[-1] < sorted_y[0]:
    print("No War")
else:
    print("War")



Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)



int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    vll v{A, B, C};
    sort(v.begin(), v.end());
    cout << v[0]*v[1]/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
 
using namespace std;
 
int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int	n,cant,time;
	cin>>n>>cant>>time;
	int ans=n/cant;
	if(ans*cant<n)ans++;
	ans=ans*time;
	cout<<ans<<endl;

	return 0;
}


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

int main(){
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a.at(k-1) << endl;
}

Measured memory_bytes: 256
#Byakko Delivery Company
from heapq import heappop, heappush
from string import ascii_lowercase as al
dic = dict([(c,i) for i, c in enumerate(al)])
f = lambda (h, v):(dic[h], int(v) - 1)
g = lambda s:f(s.split("-"))

def solve():
    hq = [(0, start[0], start[1])]
    while len(hq) != 0:
        cost, cy, cx = heappop(hq)
        #print "cost = {}, pos = ({}, {})".format(cost, cy, cx)
        if (cy, cx) == goal:
            return cost
        if (cost, cy, cx) in memo:
            continue
        memo[(cost, cy, cx)] = True
        for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ny, nx = cy + dy, cx + dx
            if 0 <= ny < M and 0 <= nx < N:
                #print ny, nx, condition[ny][nx][cy][cx]
                nc = condition[ny][nx][cy][cx] + D + cost
                if field[ny][nx] == 0:
                    heappush(hq, (nc, ny, nx))
                else:
                    if dy == 0:
                        if (nc / field[ny][nx]) % 2 == 1:
                            heappush(hq, (nc, ny, nx))
                    else:
                        if (nc / field[ny][nx]) % 2 == 0:
                            heappush(hq, (nc, ny, nx))
while True:
    M, N = map(int, raw_input().split())
    if M | N == 0:
        break
    memo = {}
    D = input()
    field = [[0] * N for _ in xrange(M)]
    condition = [[[[0] * N for _ in xrange(M)] for _ in xrange(N)] for _ in xrange(M)]
    for _ in xrange(input()):
        p, k = raw_input().split()
        h, v = g(p)
        field[h][v] = int(k)

    for _ in xrange(input()):    
        (h1, v1), (h2, v2) = map(g, raw_input().split())
        condition[h1][v1][h2][v2] = condition[h2][v2][h1][v1] = 1 << 30

    for _ in xrange(input()):
        p1, p2, d = raw_input().split()
        h1, v1 = g(p1)
        h2, v2 = g(p2)
        condition[h1][v1][h2][v2] = condition[h2][v2][h1][v1] = int(d)

    start, goal = map(g, raw_input().split())
    print solve()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=705;

int n, m, k, u, v, x, y, t, a, b, ans;
bool A[N][N];
int col[N], c1, c2;
vector<int> G[N];
bitset<N> B;

bool dfs(int node, int c){
	col[node]=c;
	if (c==1) c1++;
	else c2++;
	for (int v:G[node]) if (col[v]!=3-c){
		if (col[v]==c || !dfs(v, 3-c)) return 0;
	}
	return 1;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	ans=m;
	while (m--){
		cin>>u>>v;
		A[u][v]=A[v][u]=1;
	}
	for (int i=1; i<=n; i++) for (int j=1; j<i; j++) if (!A[i][j]){
		G[i].pb(j);
		G[j].pb(i);
	}
	B.set(0);
	for (int i=1; i<=n; i++) if (!col[i]){
		c1=c2=0;
		if (!dfs(i, 1)) kill(-1)
		B=(B<<c1)|(B<<c2);
	}
	for (int i=0; i<=n; i++) if (B[i]) ans=min(ans, i*(i-1)/2+(n-i)*(n-i-1)/2);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb 	push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)

main()
{
	speed;
	int a,b;
	cin>>a>>b;
	int x=a+b;
	int y=a-b;
	int z=a*b;
	cout<<max(x,max(y,z));
	return 0;
}

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

using namespace std;

string solve(int x, int y, int z) {
   if (y + z == 0) return string(x, 'a');
   if (z + x == 0) return string(y, 'b');
   if (x + y == 0) return string(z, 'c');
   if (x == 0) {
      string nans = solve(y, z, 0);
      for (char &c : nans) c += 1;
      return nans;
   }
   if (z == 0) {
      string nans = solve(x, 0, y);
      for (char &c : nans) if (c == 'c') c = 'b';
      return nans;
   }
   if (x >= z) {
      string nans = solve(x - z, z, y);
      string ans;
      for (char c : nans) {
         if (c == 'a') {
            ans += 'a';
         } else if (c == 'b') {
            ans += "ac";
         } else {
            ans += 'b';
         }
      }
      return ans;
   } else {
      string nans = solve(x, y, z - x);
      string ans;
      for (char c : nans) {
         if (c == 'a') {
            ans += "ac";
         } else {
            ans += c;
         }
      }
      return ans;
   }
}

int main() {
   ios_base::sync_with_stdio(false);
   int x, y, z;
   cin >> x >> y >> z;
   cout << solve(x, y, z) << "\n";
   return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] A=new int[N];
		for(int i=0;i<N;++i) {
			A[i]=-sc.nextInt();
		}
		Arrays.sort(A);
		for(int i=0;i<N;++i)A[i]*=-1;
		int sum=Arrays.stream(A).sum();
		int p=0;
		while(p<N&&(long)(4*M)*A[p]>=sum)++p;
		System.out.println(p>=M?"Yes":"No");
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 28500
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}

bool check(int pos, string& ans, vector<int>& ord) {
    auto n = ans.size();
    auto lpos = (pos -1 + n) % n;
    auto rpos = (pos + 1) % n;
    if (ord[pos] == 1) {
        return (ans[pos] == 'o') == (ord[lpos] == ord[rpos]);
    }
    return (ans[pos] == 'o') == (ord[lpos] != ord[rpos]);
}


void oneCase () {
    int n;
    cin >> n;
    string line;
    cin >> line;
    vector<int> ans;

    vector<int> cur;
    cur.reserve(n);
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            int l = 0;
            int ii = i;
            int jj = j;
            cur.push_back(ii);
            while (l + 1< n) {
                cur.push_back(jj);
                auto curAns = line[l + 1];
                int tmp = jj;
                if (curAns == 'o') {
                    if (jj == 1) {
                        jj = ii;
                    } else {
                        jj = 1 - ii;
                    }
                } else {
                    if (jj == 1) {
                        jj = 1 - ii;
                    } else {
                        jj = ii;
                    }
                }
                ii = tmp;
                ++l;
            }
            if (check(0, line, cur) && check(n - 1, line, cur)) {
                ans = cur;
                break;
            }

            cur.clear();
        }
        if (!ans.empty()) {
            break;
        }
    }
    if (ans.empty()) {
        cout << -1 << "\n";
    } else {
        for (auto i : ans) {
            if (i == 1) {
                cout << "S";
            } else {
                cout << "W";
            }
        }
        cout << "\n";
    }
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 1408
N = int(input())

def f(x):
    ans = 0
    while x>0:
        ans += x%6
        x //= 6
    return ans

def g(x):
    ans = 0
    while x>0:
        ans += x%9
        x //= 9
    return ans

l = []

for x in range(N+1):
    l.append(f(x)+g(N-x))

print(min(l))

Measured memory_bytes: 3864
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=int(1e6);
int R[MAXN];
int A;
int Max=int(1e7);
int main()
{
	scanf("%d",&A);
	for(int i=0;i<=9;i++)
		for(int j=0;j<=9;j++)
			for(int k=0;k<=9;k++)
				for(int l=0;l<=9;l++)
					for(int m=0;m<=9;m++)
						R[10000*i+1000*j+100*k+10*l+1*m]=i+j+k+l+m;
	for(int i=1;i<=(A+1)/2;i++)
		Max=min(Max,R[i]+R[A-i]);
	printf("%d",Max);
}

Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline
N,Q = map(int,input().split())
BIT = [0]*(N+1)

def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

def BIT_update(idx,x):
    while idx <= N:
        BIT[idx] += x
        idx += idx&(-idx)
    return

c = [-1]+list(map(int,input().split()))
lastAppeared = [-1]*(N+1)
ans = [0]*Q
queries = []
for q in range(Q):
    l,r = map(int,input().split())
    queries.append(r*10**12+l*10**6+q)
queries.sort()

curR = 0
for i in range(Q):
    query = queries[i]
    r = query//10**12
    query %= 10**12
    l = query//10**6
    q = query % 10**6
    while curR < r:
        curR += 1
        new = c[curR]
        last = lastAppeared[new]
        if last != -1:
            BIT_update(last,-1)
        lastAppeared[new] = curR
        BIT_update(curR,1)
    ans[q] = BIT_query(r)-BIT_query(l-1)
for i in range(Q):
    print(ans[i])

Measured memory_bytes: 159644
#include<stdio.h>
int main()
{
    int m,n,i,j,k;
    scanf("%d %d %d",&i,&j,&k);
    n=i-j;
    m=k-n;
    if(m<0)
    printf("0");
    else
    printf("%d",m);

    return 0;
}


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

void call(int n){
    int i = 1;
    CHECK_NUM:
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    INCLUDE3:
    if ( x % 10 == 3 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    x /= 10;
    if ( x ) goto INCLUDE3;
    END_CHECK_NUM:
    if ( ++i <= n ) goto CHECK_NUM;

    cout << endl;
}

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int x = i;
        if(x%3 == 0 || x%10 == 3){
            cout << " " << i;
            continue;
        }
        while(x /= 10, x != 0){
            if(x%10 == 3){
                cout << " " << i;
                break;
            }
        }
    }
    cout << endl;
    //call(n);
    return 0;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

struct UnionFind{
    vector<int> par;
    int count;
    UnionFind(int n) : par(n, -1), count(0){}
    int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
    int Size(int x){return par[x] < 0 ? -par[x] : Size(par[x]);}
    bool Unite(int x, int y){
        x = Find(x);
        y = Find(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return ++count;
    }
};



signed main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; ++i){
        if(i + 2 < n && s[i + 0] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
        if(i + 1 < n && s[i + 0] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

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

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<ll> a(N);

    REP(i,N) cin>>a[i];
    int num = N;
    int four = 0;
    int two = 0;

    REP(i,N) {
        if (a[i]%4==0) four++;
        else if (a[i]%2==0) two++;
    }

    bool ans = false;


    if (num - four*2 <= 1) {
        ans = true;
    }
    else if (two >= 2) {
        if (num - (2*four) <= two) {
            ans = true;
        }
    }
    
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    if(s[0]==*(s.end()-1)){
        if((int)s.size()%2==1){
            cout << "Second" << endl;
        }else{
            cout << "First" << endl;
        }
    }else{
        if((int)s.size()%2==1){
            cout << "First" << endl;
        }else{
            cout << "Second" << endl;
        }
    }
}

Measured memory_bytes: 512
use std::cmp::Ordering;

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let mut s = get!(String);
    let a = String::from("a");
    match s.cmp(&a) {
        Ordering::Less => println!("A"),
        _ => println!("a"),
    }
}


Measured memory_bytes: 2140
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int result = INF;
  int N, T;
  cin >> N >> T;
  rep(i, N) {
    int c, t;
    cin >> c >> t;
    if (t <= T && c < result) {
      result = c;
    }
  }
  if (result == INF) {
    cout << "TLE" << endl;
  } else {
    cout << result << endl;
  }
  return 0;
}


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

int main(){
	int n,i;
	int flag = 1;
	int t,x,y,t1,t2,x1,y1;
	x1=y1=t1=0;
	int tmp;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&t,&x,&y); 
		tmp = x-x1+y-y1;
		t2=t-t1;
		if(tmp>t2||(tmp<t2&&(t2-tmp)%2==1))
		{
			flag = 0;
		} 
		t1=t,x1=x;y1=y;	
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
    
	vector<int> vec(3);
  	vec = {A+B,A-B,A*B};
  	sort(vec.begin(), vec.end());
  	cout << vec.at(2) << endl;
}

Measured memory_bytes: 256
s = input()

pattern = ["dream", "dreamer", "erase", "eraser"]

while len(s) != 0:
    is_matched = False
    for p in pattern:
        if s.endswith(p):
            s = s[:-len(p)]
            is_matched = True
            break
    if not is_matched:
        break

if len(s) == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <stdio.h>

long long f(int k, int d) {
	return k == 0 ? 0 : f(k - 1, d) * 10 + d;
}

int main() {
	int a, b;

	scanf("%d%d", &a, &b);
	printf("%lld\n", a < b ? f(b, a) : f(a, b));
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; i < (n); i++)

int main(){
  
  int n, s = 0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    s += i;
    if(s >= n){
      for(int j = 1; j <= i; j++){
        if(j == s - n) continue;
        cout << j << endl;
      }
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
pair<ll,ll> ab[100010];
ll sums[100010];
int main(){ _;
  int n,m;cin>>n>>m;
  REP(i,n) cin>>ab[i].first>>ab[i].second;
  sort(ab,ab+n);
  sums[0]=ab[0].second;
  REP(i,n-1) sums[i+1]=sums[i]+ab[i+1].second;
  int index=distance(sums,lower_bound(sums,sums+n+1,m));
  //cout<<index<<endl;
  ll rest=m-sums[index-1];
  //cout<<rest<<endl;
  ll cost=ab[index].first*rest;
  REP(i,index){
    cost+=ab[i].first*ab[i].second;
  }
  cout<<cost<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

llint n, d;
vector<llint> G[2005];
llint dist[2005];

void dfs(int v, int p, llint d)
{
	dist[v] = min(dist[v], d);
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		dfs(G[v][i], v, d+1);
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> d;
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	llint ans = inf;
	for(int i = 1; i <= n; i++){
		
		if(d % 2 == 0){
			llint cnt = 0;
			for(int j = 1; j <= n; j++) dist[j] = inf;
			dfs(i, -1, 0);
			for(int j = 1; j <= n; j++){
				if(dist[j] > d/2) cnt++;
			}
			ans = min(ans, cnt);
		}
		else{
			for(int j = 0; j < G[i].size(); j++){
				llint cnt = 0;
				for(int k = 1; k <= n; k++) dist[k] = inf;
				dfs(i, G[i][j], 0);
				dfs(G[i][j], i, 0);
				for(int k = 1; k <= n; k++){
					if(dist[k] > d/2) cnt++;
				}
				ans = min(ans, cnt);
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

int main() {
    int y, m, d;
    char c;
    cin >> y >> c >> m >> c >> d;

    if (y < 2019) {
        cout << "Heisei" << endl;
    } else if (y == 2019 && m < 4) {
        cout << "Heisei" << endl;
    } else if (y == 2019 && m == 4 && d <= 30) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}

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

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  MInt mn(n), mk(k);
  MInt ans = 0;
  for (int i = k; i <= n + 1; i++) {
    MInt mi(i);
    MInt min_n = (mi - MInt(1)) * mi / MInt(2);
    MInt max_n = (mn + (mn - mi + MInt(1))) * mi / MInt(2);
    ans += max_n - min_n + MInt(1);
  }

  cout << ans.Get() << '\n';

  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d<=s*t){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in(),A = in(),B = in();
    vector<ll> X(N);
    REP(i,N)X[i] = in();
    ll tired = 0;
    REP(i,N-1){
        tired += min((X[i+1] - X[i]) * A,B);
    }
    cout << tired << "\n";
}

Measured memory_bytes: 1024
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

LLI arr1[100005];


int main(){
    int n;
    scanf("%d",&n);
    FREP(i,1,n){
        scanf("%lld",&arr1[i]);
    }
    LLI prevsum1=0;
    LLI op1=0;
    FREP(i,1,n){
        if(i%2){
            LLI cursum=prevsum1+arr1[i];
            if(cursum>0){
                prevsum1=cursum;
                continue;
            }
            else{
                LLI need=1-prevsum1;
                LLI dif=abs(need-arr1[i]);
                op1+=dif;
                prevsum1=1;
            }
        }
        else{
            LLI cursum=prevsum1+arr1[i];
            if(cursum<0){
                prevsum1=cursum;
                continue;
            }
            else{
                LLI need=-(1+prevsum1);
                LLI dif=abs(need-arr1[i]);
                op1+=dif;
                prevsum1=-1;
            }
        }
    }
    prevsum1=0;
    LLI op2=0;
    FREP(i,1,n){
        if(i%2==0){
            LLI cursum=prevsum1+arr1[i];
            if(cursum>0){
                prevsum1=cursum;
                continue;
            }
            else{
                LLI need=1-prevsum1;
                LLI dif=abs(need-arr1[i]);
                op2+=dif;
                prevsum1=1;
            }
        }
        else{
            LLI cursum=prevsum1+arr1[i];
            if(cursum<0){
                prevsum1=cursum;
                continue;
            }
            else{
                LLI need=-(1+prevsum1);
                LLI dif=abs(need-arr1[i]);
                op2+=dif;
                prevsum1=-1;
            }
        }
    }
    printf("%lld\n",min(op1,op2));
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<climits>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
struct S{int v1,v2,t;}s,t={0,0,-1};
const int N=1000;
int main()
{
	int n,i,j,k,r;
	char x[64],y[64];
	while(scanf("%d",&n),n)
	{
		map<string,int>m;
		vector<S>v;
		bool f[N]={0};
		for(i=0;i<n;++i)
		{
			scanf("%s%d%s%d",x,&s.v1,y,&s.v2);
			if(m.find(y)==m.end())m[y]=v.size(),v.push_back(t);
			s.t=m[y];if(m.find(x)==m.end())m[x]=v.size(),v.push_back(s);
			else v[m[x]]=s;
		}
		for(r=i=0;i<v.size();++i)
		{
			if(f[i])continue;
			if(i==v[i].t)r+=v[i].v1;
			else
			{
				bool c[N]={0};
				vector<int>u;
				for(j=i;!f[i]&&!c[j];j=v[j].t)c[j]=1,u.push_back(j);
				if(i==j)
				{
					int a=INT_MAX,b;
					for(j=0;j<u.size();++j)
					{
						b=v[u[0]].v1;for(k=1;k<u.size();++k)b+=v[u[k]].v2;a=min(a,b);
						f[u[0]]=1;		rotate(u.begin(),u.begin()+1,u.end());}
					r+=a;
				}
				else r+=v[i].v2;
			}
			f[i]=1;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 928
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k,a,b;
    cin >> k >> a >> b;

    if(a+1 > k || b-a < 3){
        cout << 1+k << endl;
        return 0;
    }

    k -= (a+1);
    ll ans = b;

    ans += (b-a)*(k/2);
    if(k%2 == 1){
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
#define JAM(x) cout<< #x <<" = "<<x<<"\n"
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { ll a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
 
 
//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;
const double PI=acos(-1.0);

vector<int> sieve(100001);


long long int power(long long int a,long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}

void SIEVE()
{
    int i,j;
    for(i=0;i<=100000;i++)
    sieve[i]=i;
    for(i=2;i*i<=100000;i++)
    {
        if(sieve[i]!=i)
        continue;
        for(j=i*i;j<=100000;j=j+i)
        {
            if(sieve[j]==j)
            sieve[j]=i;
        }
    }
}


/*_______________________________________________*/
int n,m;
int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};
bool isvalid(int x,int y)
{
    if(x<0 || x>=n || y<0 || y>=m)
    return false;
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    vector<vector<int>> times(n,vector<int>(m,INT_MAX));
    vector<vector<char>> grid(n,vector<char>(m));
    int i,j;
    int sx,sy,ex,ey;
    cin>>sx>>sy;
    cin>>ex>>ey;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        cin>>grid[i][j];
    }
    deque<pair<int,int>> q;
    q.push_back({sx-1,sy-1});
    times[sx-1][sy-1]=0;
    while(!q.empty())
    {
        pair<int,int> cur=q.front();
        q.pop_front();
        if(times[ex-1][ey-1]==0)
        break;
        for(i=0;i<4;i++)
        {
            int x=cur.first+dx[i];
            int y=cur.second+dy[i];
            if(isvalid(x,y) && times[x][y]>times[cur.first][cur.second] && grid[x][y]=='.')
            {
                times[x][y]=times[cur.first][cur.second];
                q.push_front({x,y});
            }
        }
        for(i=-2;i<=2;i++)
        {
            for(j=-2;j<=2;j++)
            {
                int x=cur.first+i;
                int y=cur.second+j;
                if(isvalid(x,y) && times[x][y]>(times[cur.first][cur.second]+1) && grid[x][y]=='.')
                {
                    times[x][y]=times[cur.first][cur.second]+1;
                    q.push_back({x,y});
                }
            }
        }
    }
    if(times[ex-1][ey-1]!=INT_MAX)
    cout<<times[ex-1][ey-1];
    else
    {
        cout<<"-1";
    }
    
}


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

int main(void){
	int n;
  	cin >> n;
  	string s;
  	cin >> s;
  	int ans = 0;
  	rep(i,n){
    	if(s[i] == s[i+1]) continue;
      	ans++;
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
 
int main(void) {
    int n, k, h[100100], count = 0;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++) {
        scanf("%d", &h[i]);
        if(h[i] >= k) count++;
    }
    printf("%d\n", count);
    return 0;
}

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

int main(){
    long long N,sum=0;
    cin>>N;
    vector<long long> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        sum +=A.at(i);
    }
    
    long long minx = sum,S=0;
    for(int i=0;i<N;i++){
        S += A.at(i);
        minx = min(minx,abs(S-(sum-S)));
    }
    cout<<minx<<endl;
    return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
 
k_to_word = [[] for _ in range(K)]
# K回ごとに何を出したか保存
for i,x in enumerate(T):
    k = i % K
    k_to_word[k].append(x)
    
def solve(A):
    # 直前と同じ手は出せない、というルール
    r,s,p = 0,0,0 # 直前に出した手 -> 最大スコア
    for x in A:
        # 例 x == r : 相手がrを出したとき
        if x == 'r':
            # 左から順にr,s,pを出すときの点数変化
            # max(s,p)とかだと前回にs,pのどちらかを出している
            r,s,p = max(s,p),max(r,p),max(r,s)+P
        elif x == 's':
            r,s,p = max(s,p)+R,max(r,p),max(r,s)
        elif x == 'p':
            r,s,p = max(s,p),max(r,p)+S,max(r,s)   
    
    return max(r,s,p)
 
answer = sum(solve(A) for A in k_to_word)
print(answer)

Measured memory_bytes: 13428
def main():
    N = int(input())
    B = [0] + list(map(int, input().split()))
    
    A = [float('inf')] * N
    for i in range(N-1,0,-1):
        A[i] = min(A[i],B[i])
        A[i-1] = min(A[i-1],B[i])

    print(sum(A))

main()

Measured memory_bytes: 38256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int N, a[105];
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int swaps = 0;
    for (int i = 1; i < N; i++) {
        if (a[i] == a[i - 1]) {
            ++swaps;
            a[i] = 1000;
        }
    }
    cout << swaps;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<char> s(n);
  rep(i,n) cin >> s[i];

  if(n%2!=0){
    cout << "No" << "\n";
  }
  else{
    bool f = true;
    rep(i,n/2){
      if(s[i]!=s[i+n/2]){
	f = false;
	break;
      }
    }
    if(f) cout << "Yes" << "\n";
    else cout << "No" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
while True:
    n,x = map(int, input().split())
    ans=0
    a=n
    b=a-1
    c=a-2
    if n==x==0:
        break
    for i in range(n-2):
        for j in range(a-2):
            for k in range(b-1):
                if a+b+c==x:
                    ans+=1
                    c-=1
                else:
                    c-=1

            b-=1
            c=b-1
        a-=1
        b=a-1
        c=b-1

    print(ans)



Measured memory_bytes: 5596
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    
    if(a == b) Console.WriteLine("{0}", c);
    if(a == c) Console.WriteLine("{0}", b);
    if(b == c) Console.WriteLine("{0}", a);
  }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    string s;
    cin>>s;
    cout<<s.substr(0,s.size()-8)<<endl;
}



Measured memory_bytes: 256
# _*_ coding:utf-8 _*_
#  Atcoder_yahooMinnanoProcon_Contest-A
#  TODO https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_a

def solveProblem(LimitInteger,SelectNumber):
	MaxSelectLength = SelectNumber * 2 -1
	if MaxSelectLength <= LimitInteger:
		answer="YES"
	else :
		answer="NO"
	return answer


if __name__ == '__main__':
	N,K = map(int,input().strip().split(' '))
	solution = solveProblem(N,K)
	print("{}".format(solution))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i;
  string s;
  cin>>n;
  cin>>s;
  int count=0;
  for(i=0;i<n-2;i++)
  {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
      count++;
  }
  cout<<count<<endl;
    return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;
    if(A == 1){
        if(B == 2){
            cout << "3" << endl;
        }
        else cout << "2" << endl;
    }
    else if(A == 2){
        if(B == 1){
            cout << "3" << endl;
        }
        else cout << "1" << endl;
    }
    else if(A == 3){
        if(B == 1){
            cout << "2" << endl;
        }
        else cout << "1" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<numeric>
using namespace std;
#define N (1000000000+7)
//#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll iterative_pow(ll x,ll power) {
	ll res = 1;
	ll k = power;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y);
		y = y*y;
		k /= 2;
	}
	return res;
}

ll ext_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x2,y2;
    ll d = ext_gcd(b,a%b,x2,y2);
    x = y2;
    y = x2 - (a/b)*y2;
    return d;
}


ll mod_inv(ll a,ll m){
    ll x,y;
    ll d = ext_gcd(a,m,x,y);
    if(d!=1){
        return -1;
    }
    x %= m;
    if(x<0)x += m;
    return x;
}


ll garner(vector<ll> r,vector<ll>m){
    int n = r.size();
    ll m_prod = 1;
    ll x = (r[0]+m[0])%m[0];
    x = (x+m[0])%m[0];
    for(int i=1;i<n;i++){
        m_prod *= m[i-1];
        ll Inv = mod_inv(m_prod,m[i]);
        ll t = ((r[i]-x)*Inv)%m[i];
        if(t<0)t+=m[i];
        x += t*m_prod;
    }
    return x;
}


int main(void){
    ll n;
    cin>>n;
    vector<ll>primes;
    map<ll,ll>mp;
    ll p = 2*n;
    n = p;
    for(ll i=2;i*i<=n;i++){
        if(p%i==0){
            ll cnt = 0;
            while(p%i==0){
                p/=i;
                cnt++;
            }
            primes.push_back(i);
            mp[i] = iterative_pow(i,cnt);
        }
    }
    if(p>1){
        primes.push_back(p);
        mp[p] = p;
    }
    ll S = primes.size();
    ll ans = 0;
    for(ll i=0;i<(1LL<<S);i++){
        ll k = 1LL;
        for(ll j=0;j<S;j++){
            if((i>>j)&1){
                k*=mp[primes[j]];
            }
        }
        ll rest = n/k;
        vector<ll>m,r1,r2;
        m.push_back(k);
        m.push_back(rest);
        r1.push_back(0);
        r1.push_back(-1);
        ll t1 = garner(r1,m);
        if(ans==0){
            if(t1==0){
                continue;
            }
            else{
                ans = t1;
            }
        }
        else{
            if(t1==0){
                continue;
            }
            else{
               ans = min(ans,t1);
            }
        }
    }
    cout<<ans<<endl;
}

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

#define int long long

//int dp[100001][101];
 
int ans=0;

/*int fn(int i,int n, int a[],int v[],int w )
{
	if(w<0)
	return INT_MIN;
	if(i==-1)
	return 0;
	if(dp[w][i]!=-1)
	return dp[w][i];
	
	ans=max(fn(i-1,n,a,v,w-a[i])+v[i],fn(i-1,n,a,v,w));
	dp[w][i]=ans;
	
	return dp[w][i];
}

*/
int32_t main()
{
	int n,w; 
	cin>>n>>w;
	int a[n+1],v[n+1];
	for(int i=1; i<=n; i++)
	cin>>a[i]>>v[i];
	
	
	int dp[n+1][w+1];
	for(int i=0; i<=w;i++)
	dp[0][i]=0;
	for(int i=0; i<=n;i++)
	dp[i][0]=0;
	
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=w; j++)
		{
			if(a[i]>j)
			dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-a[i]]);
			}
		}
	}
	
	cout<<dp[n][w];




	return 0;
}

Measured memory_bytes: 79104