akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a == b and b == c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = S()
    if s.count("R") > s.count("B"):
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


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

using namespace std;

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

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  int ret = 0;
  for(int i = 1; i * i <= N; i++) {
    ret = max(ret, i);
  }
  cout << ret * ret << endl;
}


Measured memory_bytes: 256
// Copyright 2015 KanatoNagayama
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;

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

Measured memory_bytes: 1156
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

class combination {
 private:
  vector<mint> fact, finv;

 public:
  combination(int N) {
    fact = finv = vector<mint>(N + 1);
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i <= N; i++) {
      fact[i] = fact[i - 1] * i;
      finv[i] = fact[i].inv();
    }
  }
  mint f(int i) { return fact[i]; }
  mint comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * finv[k] * finv[n - k];
  }
  mint hcomb(int n, int k) {
    if (n == 0 && k == 0) return 1;
    return comb(n + k - 1, k);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  combination comb(n + 5);
  mint ans(0);
  rep(i, n) {
    if (i >= k - 1) {
      ans += comb.comb(i, k - 1) * a[i];
      // cerr << "!" << endl;
    }
    if (n - 1 - i >= k - 1) {
      mint now = comb.comb(n - 1 - i, k - 1);
      now = -now;
      ans += now * a[i];
      // cerr << "#" << comb.comb(n - 1 - i, k - 1).x << "," << a[i] << endl;
    }
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 2560
import collections
N = int(input())
A = list(map(int, input().split()))

lst = collections.Counter(A)

Q = int(input())

# 最初の全てのA_iの和
ans_init = 0
for i in lst:
    ans_init += i*lst[i]

# 初期値からのプラスマイナス分
ans_pm = 0
ans = []
for i in range(Q):
    B, C = map(int, input().split())
    if B in lst:
        # 更新する前に、lst中のkeyがBの個数をBnumに記憶しておく。
        Bnum = lst[B]
        # lstを更新
        if C in lst:
            lst[C] += lst[B]
            lst.pop(B)
        else:
            lst[C] = lst[B]
            lst.pop(B)
    
        # 初期値からの増減分をここで算出。
        ans_pm += Bnum*(C-B)
        ans.append(ans_init + ans_pm)
        
    else:
        ans.append(ans_init + ans_pm)

for i in ans:
    print(i)

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

const int maxn = 200005;

int n, p, q;
int a[maxn];

bool ok(int x) {
	long long cur = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] - (long long)x * q > 0) {
			if (p == q) return false;
			cur += (a[i] - (long long)x * q) / (p - q) + ((a[i] - (long long)x * q) % (p - q) > 0);
		}
	}
	return cur <= x;
}

int main() {
	scanf("%d%d%d", &n, &p, &q);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	int low = 0, high = 1000 * 1000 * 1000, mid;
	while (low < high) {
		mid = low + high >> 1;
		if (ok(mid)) high = mid;
		else low = mid + 1;
	}
	printf("%d\n", low);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    cin >> n;
    vll a(n);
    ll v = 0;
    map <ll, ll> m;
    for(i = 0; i < n; i++)
        cin >> a[i], m[a[i]]++;
    vll b;
    for(auto x : m)
        b.pb(x.F);
    bool p = true;
    if(b.size() == 1)
    {
        if(b[0] == 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
    }
    if(b.size() == 2)
    {
        if(b[0] == 0)
            b.pb(b[1]);
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if(b.size() == 3)
    {
        if(b[0] != (b[1] ^ b[2]))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if(b.size() > 3)
    {
        cout << "No" << endl;
        return 0;
    }
    if(n % 3 != 0)
    {
        cout << "No\n";
        return 0;
    }
    for(i = 0; i < n; i++)
    {
        if(!m[b[i % 3]])
        {
            cout << "No\n";
            return 0;
        }
        m[b[i % 3]]--;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6904
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a_list=list(map(int,input().split()))
import heapq
A=[]
for i in a_list:
    heapq.heappush(A,-i)
for i in range(m):
    now=heapq.heappop(A)
    now=-now
    now=now//2
    now=-now
    heapq.heappush(A,now)
ans=0
for i in range(n):
    now=heapq.heappop(A)
    ans-=now
print(ans)


            



Measured memory_bytes: 63128
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    vi as(n);
    cin>>as;

    rep(i, n) as[i]--;

    int ans = 0;
    rep(i, n) {
        if (as[i] > i && as[as[i]] == i) ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
  int N;
  int ct = -1;
  bool flag = true;
  int A[200];
  
  cin >> N;
  for(int i=0; i<N; ++i) cin >> A[i];
  
  while(flag) {
    ++ct;
  	for(int i=0; i<N; ++i) {
    	if (A[i] % 2 == 1) flag = false;
        else A[i] /= 2;
    }
  }
  
  cout << ct << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int step[2][100010];

int lr (char i, char j) {
    int ii = ((i - '0') - 1) % 3;
    int jj = ((j - '0') - 1) % 3;
    if (ii < jj) {
        return 0;
    } else if (ii == jj) {
        return 1;
    } else {
        return 2;
    }
}

int main() {
    while (1) {
        string s;
        cin >> s;
        if (s == "#") {
            break;
        }
        int len = s.size();
        for (int i = 0; i < 2; i++) {
            step[i][len - 1] = i;
            for (int j = len - 2; j >= 0; j--) {
                if (step[i][j + 1] == 0) {
                    if (lr(s[j], s[j + 1]) >= 1) {
                        step[i][j] = 1;
                    } else {
                        step[i][j] = 0;
                    }
                } else {
                    if (lr(s[j], s[j + 1]) <= 1) {
                        step[i][j] = 0;
                    } else {
                        step[i][j] = 1;
                    }
                }
            }
        }
        ll ans[2];
        for (int i = 0; i < 2; i++) {
            int num = 0;
            for (int j = 1; j < len; j++) {
                if (step[i][j] == step[i][j - 1]) {
                    num++;
                }
            }
            ans[i] = num;
        }
        cout << min(ans[0], ans[1]) << endl;
    }
}



Measured memory_bytes: 4064
#include <cstdio>
#include <algorithm>
using namespace std;
 
int solve(char*s)
{
  int c=(s[0]-'0')*100+(s[1]-'0')*10+(s[2]-'0')-753;
  return c<0?-c:c;
}
int main(void)
{
  int i,res=999;
  char s[12];
  scanf("%s",s);
  for(i=0;s[i+2];i++)
    res=min(res,solve(s+i));
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 128
K = int(input())
t = {}
cnt = 0

for ie in range(10):
    ne = ie
    for id in range(10):
        nd = ne*10+id
        if abs(ie-id)>1 and ne!=0:
            continue
        for ic in range(10):
            nc = nd*10+ic
            if abs(id-ic)>1 and nd!=0:
                continue
            for ib in range(10):
                nb = nc*10+ib
                if abs(ic-ib)>1 and nc!=0:
                    continue
                for ia in range(10):
                    na = nb*10+ia
                    if abs(ib-ia)>1 and nb!=0:
                        continue
                    for i1 in range(10):
                        n1 = na*10+i1
                        if abs(ia-i1)>1 and na!=0:
                            continue
                        for i2 in range(10):
                            n2 = n1*10+i2
                            if abs(i1-i2)>1 and n1!=0:
                                continue
                            for i3 in range(10):
                                n3 = n2*10+i3
                                if abs(i2-i3)>1 and n2!=0:
                                    continue
                                for i4 in range(10):
                                    n4 = n3*10+i4
                                    if abs(i3-i4)>1 and n3!=0:
                                        continue
                                    for i5 in range(10):
                                        n5 = n4*10+i5
                                        if abs(i4-i5)>1 and n4!=0:
                                            # print("conti", n5)
                                            continue
                                        if n5 ==0:
                                            # print("z")
                                            continue
                                        cnt += 1
                                        # print(n5, cnt)
                                        if cnt==K:
                                            print(n5)
                                            exit()
                                        # t[i5*10000 + i4*1000 + i3*100 + i2*10 + i1]
                            # print(n)
            # print(cnt)

            # t.append(10**5)
            # print(t[K])
# print(cnt)

Measured memory_bytes: 62704
n = int(input())
abl = []
for _ in range(n):
    a,b = map(int,input().split())
    abl.append((a,b))

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

abl = sorted(abl)

# Hopcroft-Karp Algorithm
from collections import deque
class HopcroftKarp:
    def __init__(self, N0, N1):
        self.N0 = N0
        self.N1 = N1
        self.N = N = 2+N0+N1
        self.G = [[] for i in range(N)]
        for i in range(N0):
            forward = [2+i, 1, None]
            forward[2] = backward = [0, 0, forward]
            self.G[0].append(forward)
            self.G[2+i].append(backward)
        self.backwards = bs = []
        for i in range(N1):
            forward = [1, 1, None]
            forward[2] = backward = [2+N0+i, 0, forward]
            bs.append(backward)
            self.G[2+N0+i].append(forward)
            self.G[1].append(backward)

    def add_edge(self, fr, to):
        #assert 0 <= fr < self.N0
        #assert 0 <= to < self.N1
        v0 = 2 + fr
        v1 = 2 + self.N0 + to
        forward = [v1, 1, None]
        forward[2] = backward = [v0, 0, forward]
        self.G[v0].append(forward)
        self.G[v1].append(backward)

    def bfs(self):
        G = self.G
        level = [None]*self.N
        deq = deque([0])
        level[0] = 0
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        self.level = level
        return level[1] is not None

    def dfs(self, v, t):
        if v == t:
            return 1
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w] and self.dfs(w, t):
                e[1] = 0
                rev[1] = 1
                return 1
        return 0

    def flow(self):
        flow = 0
        G = self.G
        bfs = self.bfs; dfs = self.dfs
        while bfs():
            *self.it, = map(iter, G)
            while dfs(0, 1):
                flow += 1
        return flow

    def matching(self):
        return [cap for _, cap, _ in self.backwards]

karp = HopcroftKarp(n,n)

for i in range(n):
    for j in range(n):
        if abl[i][0] < cdl[j][0] and abl[i][1] < cdl[j][1]:
            karp.add_edge(i,j)
            
print(karp.flow())    


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;




template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}

main(){
  int n,m;
  cin>>n>>m;
  WG<int> es(3*(n+1));

  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    rep(j,3){ 
      es[a*3+j].PB(edge<int>(b*3+(j+1)%3,1));
    }
  }

  int s,g;
  cin>>s>>g;
  s--;g--;
  vector<int>ans = dijkstra(es,s*3);

  cout<<(ans[g*3]==LLONG_MAX?-1:ans[g*3]/3)<<endl;
}


Measured memory_bytes: 18944
class Main
{
  public static void main(String[] args) {
    System.out.println(new Main(Main.readInt(System.in)).cubic());
  }
  
  private static int readInt(java.io.InputStream in) {
    java.io.BufferedReader reader = null;
    int n = 0;
    try {
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(in));
      n = Integer.parseInt(reader.readLine());
    } catch (java.io.IOException e) {
      e.printStackTrace();
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (java.io.IOException e) {
          e.printStackTrace();
        }
      }
    }
    return n;
  }
  
  private final int x;
  private Main(int x) {
    this.x = x;
  }
  private int cubic() {
    return x * x * x;
  }
}

Measured memory_bytes: 17016
import math

N, K = (int(x) for x in input().split())

mod = 1000000007
def comb(n,k,p):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    a=math.factorial(n) % p
    b=math.factorial(k) % p
    c=math.factorial(n-k) % p
    return (a*mypow(b,p-2,p)*mypow(c,p-2,p)) % p

def mypow(a,b,p):
    if b == 0: return 1
    if b % 2 == 0:
        d=mypow(a,b//2,p)
        return d*d % p
    if b % 2 == 1:
        return (a*mypow(a,b-1,p )) % p

for i in range(1,K+1):
    r_comb = comb(N-K+1, i, mod)
    b_comb = comb(K-1, i-1, mod)
    ans = r_comb*b_comb % mod
    print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, m, ans=0, banyak=0;
	
struct struk{
		ll a, b;
	};	
struk minum[nax];

bool cmp(struk s1, struk s2){
		return s1.a<s2.a;
	}
	
int main(){
	IOS
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> minum[i].a >> minum[i].b;
	}
	sort(minum, minum+n, cmp);
	for(int i=0;i<n;i++){
		while(minum[i].b>0&&banyak<m){
			ans+=minum[i].a;
			banyak++;
			minum[i].b--;
		}
	}
	cout << ans << '\n';
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const ld PI = 3.141592653589793;

ld eps = 1e-7;
ld x = 0, y = 1, ang = 0, steps = 1, mv;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> mv;
    mv *= PI/180;
    while(abs(x) > eps || abs(y) > eps){
        ang += mv;
        steps++;
        x -= sin(ang);
        y += cos(ang);
        if(ang >= 2 * PI) ang -= 2 * PI;
    }
    cout << steps;
    return 0;
}

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

int main(){
    int num[9];
    for (int j = 0; j < 9; ++j) {
        cin>>num[j];
    }
    int bn;
    cin>>bn;
    int atari[3][3];
    for (int k = 0; k < 3; ++k) {
        for (int i = 0; i < 3; ++i) {
            atari[k][i]=0;
        }
    }
    for (int i = 0; i < bn; ++i) {
        int n;
        cin>>n;
        for (int j = 0; j < 9; ++j) {
            if(n==num[j]){
                atari[j/3][j%3]=1;
            }
        }
    }
    for (int l = 0; l < 3; ++l) {
        if(atari[l][0]==1 && atari[l][1]==1 && atari[l][2]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(atari[0][l]==1 && atari[1][l]==1 && atari[2][l]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(atari[0][0]==1 && atari[1][1]==1 && atari[2][2]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(atari[0][2]==1 && atari[1][1]==1 && atari[2][0]==1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLine().toInt()
    val s = sc.nextLine()

    println(problem138_a(a, s))
}

fun problem138_a(a: Int, s: String): String {

    return if (a >= 3200) {
        s
    } else {
        "red"
    }
}

Measured memory_bytes: 31376
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
 
#define vi vector<int>
#define p pair<int, int>
#define REP(i, n) for(int i = 0;i < n; i++)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define BR cout << endl;
#define INF  2000000000
 
int main(){
    int n, a, b, c, d;
    cin >> n;
    d = n % 10; n /= 10;
    c = n % 10; n /= 10;
    b = n % 10; n /= 10;
    a = n % 10;
 
    REP(i, 2) REP(j, 2) REP(k, 2){
        int ans = a;
        ans += b * (i ? 1 : -1);
        ans += c * (j ? 1 : -1);
        ans += d * (k ? 1 : -1);
        if(ans == 7){
            cout << a << (i?'+':'-') << b << (j?'+':'-') << c << (k?'+':'-') << d << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
var
  n,y,i,j,k:longint;
begin
  readln(n,y);
  if (y div n=10000) then
  begin
     writeln(n,' ',0,' ',0);
     halt;
  end;
  if (y div n=5000) then
  begin
    writeln(0,' ',n,' ',0);
    halt;
  end;
  if (y div n=1000) then
  begin
    writeln(0,' ',0,' ',n);
    halt;
  end;
  if (n*10000<y) then
  begin
    writeln('-1 -1 -1');
    halt;
  end;
  if (n*1000>y) then
  begin
    writeln('-1 -1 -1');
    halt;
  end;
  if (y mod 1000<>0) then
  begin
    writeln('-1 -1 -1');
    halt;
  end;
  for i:=0 to y div 10000 do
  for j:=0 to n-i do
  if (i*10000+j*5000+(n-i-j)*1000=y) 
  then begin
     writeln(i,' ',j,' ',n-i-j);
     halt;
  end;
  writeln('-1 -1 -1');
end.

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

int main()
{
	string T, P;
	cin >> T >> P;
	for (int i = 0; i + P.size() <= T.size();i++) {
		bool flag = true;
		for (int j = 0; j < P.size();j++) {
			if (T[i + j] != P[j]) {
				flag = false;
				break;
			}
		}
		if (flag)
			cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var av = IO.RSLong;
            var bw = IO.RSLong;
            var t = IO.RLong;

            if (av[0] <= bw[0])
            {
                if (av[0] + av[1] * t >= bw[0] + bw[1] * t)
                {
                    WriteLine("YES");
                }
                else WriteLine("NO");
                return;
            }
            else
            {
                IO.WriteLineYES_or_NO(av[0] - av[1] * t <= bw[0] - bw[1] * t);
            }

        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 28240
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,l,flag=1;
    char s[20];
    scanf("%d %d",&a,&b);
    getchar();
    gets(s);
    l=strlen(s);
    if((a+b+1)!=l)
        printf("No\n");
    else
    {
        for(i=0;i<l;i++)
        {
            if(i!=a)
            {
                if(s[i]<'0'||s[i]>'9')
                {
                    flag=0;
                    break;
                }
            }
            else
            {
                if(s[i]!='-')
                {
                        flag=0;
                }

            }
        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        char[] cs = sc.nextLine().toCharArray();

        boolean flagA = true;

        //偶数
        for (int i = 0; i < cs.length; i+=2) {
            if (cs[i] == 'L') {
                flagA = false;
                break;
            }
        }

        boolean flagB = true;
        //奇数
        for (int i = 1; i < cs.length; i+=2) {
            if (cs[i] == 'R') {
                flagB = false;
                break;
            }
        }
        if (flagA && flagB) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main() {
  string str;
  cin >> str;
  if ( str.at(1) == 'R'){
    str.at(1) = 'B';
  }
  else if (str.at(1) == 'B'){
    str.at(1) = 'R';
  }
  cout << str << endl;
}




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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int main() {
  int N; cin >> N;
  string S1, S2; cin >> S1 >> S2;
  ll MOD = 1e9 + 7;

  ll ans = 1;
  rep0(i, N) {
    if (i == 0) {
      ans = ((S1[0] == S2[0])? 3: 6);
    } else if (S1[i - 1] == S1[i]) {
      ans *= 1;
    } else if (S1[i - 1] == S2[i - 1] && S1[i] == S2[i]) {
      ans *= 2;
    } else if (S1[i - 1] != S2[i - 1] && S1[i] == S2[i]) {
      ans *= 1;
    } else if (S1[i - 1] == S2[i - 1] && S1[i] != S2[i]) {
      ans *= 2;
    } else if (S1[i - 1] != S2[i - 1] && S1[i] != S2[i]) {
      ans *= 3;
    }
    ans %= MOD;
  }

  cout << ans << BR;
  return 0;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    int l = 1,r = n;
    int i,templ,tempr;
    for(i = 0;i < m;++i){
        cin >> templ >> tempr;
        if(templ > l){
            l = templ;
        }
        if(tempr < r){
            r = tempr;
        }
    }
    if(l > r){
        cout << 0 << endl;
    }else{
        cout << r-l+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ret = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c == X:
        ret += 1
        
print(ret)

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

using namespace std;

int main() {
	string s;
	int n, ans = 0, res = 0;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			res++;
			ans = max(ans, res);
		}
		else {
			res--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int A, C;
  A = a;
  C = c;
  while(A>0 && C >0){
    C = C - b;
    A = A - d;
  }
  
  if(C <= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    int ans = 0;
    for (int i = k; i < n; ++i) {
        if (t[i] == t[i-k]) t[i] = 'a'; 
    }
    rep(i,n) {
        if (t[i] == 'r') ans += p;
        else if (t[i] == 'p') ans += s;
        else if (t[i] == 's') ans += r;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int count;
int g;

int gcd(int x,int y) {

  int temp;

  if(x<y) {

    temp=x;
    x=y;
    y=temp;

  }

  if(y==0) return x;

  else {

    count++;
    return  gcd(y,x%y);

  }

}

int main() {

  int x,y;


  while(cin >> x >> y) {

    if(x==0 && y==0) break;

    count=0;

    g=gcd(x,y);

    cout << g << " " << count << endl;

  }

  return 0;

}

Measured memory_bytes: 0
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    int n, s; cin >> n >> s;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    long long dp[n+1][s+1];
    memset(dp, 0, sizeof dp);
    const int M = 998244353;
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i+1][j] = (2 * dp[i][j] + (j >= a[i] ? dp[i][j-a[i]] : 0)) % M;
        }
    }
    cout << dp[n][s] << endl;
}


Measured memory_bytes: 73912
# -*- coding: utf-8 -*-

def input_converter(key_string):
    key_string = key_string.replace('A', '1')
    key_string = key_string.replace('T', '2')
    key_string = key_string.replace('C', '3')
    key_string = key_string.replace('G', '4')
    return int(key_string)


class HashTable(object):
    def __init__(self, hash_size = 2 ** 26):
        self.hash_size = hash_size
        self.hash_array = [None] * self.hash_size

    def insert_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        while self.hash_array[next_index] is not None:
            collision_number += 1
            next_index = self.hash_function(key, collision_number)
        self.hash_array[next_index] = data

    def search_value(self, data, key):
        collision_number = 0
        next_index = self.hash_function(key, collision_number)
        next_data = self.hash_array[next_index]
        while True:
            if (next_data is None) or (collision_number > self.hash_size):
                return False
            elif next_data == data:
                return True
            else:            
                collision_number +=1
                next_index = self.hash_function(key, collision_number)
                next_data = self.hash_array[next_index]

    def hash_function(self, key, collision_number):
        def h1(key):
            return key % self.hash_size
    
        def h2(key):
            return key % (self.hash_size - 1)

        return (h1(key) + collision_number * h2(key)) % self.hash_size


def main():
    input_size = int(raw_input())
    hash_table = HashTable()
    counter = 0
    while counter < input_size:
        command, key = raw_input().split(' ')
        if command == 'insert':
            hash_table.insert_value(key, input_converter(key))
        else:
            if hash_table.search_value(key, input_converter(key)):
                print 'yes'
            else:
              print 'no'
        counter += 1


if __name__ == '__main__':
    main()

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


int main()
{


        long long n,m,a,b,c,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        //scanf("%lld",&n);

        cin>>n>>m;
        for(i=0;i<m;i++)
        {
            scanf("%lld",&a);  res=res+a;
        }

        if(res>=n)printf("Yes\n");
        else
            printf("No\n");










    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,x;cin>>n>>x;
  vector<ll> A(n);
  rep(i,n){
    cin>>A[i];
  }
  ll dp[2000][2000];
  //i回ヘンゲ, j番目のスライム
  ll ans = LINF;
  rep(i,n){
    ll sum = 0;
    rep(j,n){
      dp[i][j] = A[j];
      if(i>0){
        chmin(dp[i][j], dp[i-1][(j-1+n)%n]);
      }
      sum += dp[i][j];
    }
    chmin(ans, sum + i * x);
  }
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

int x[90009];
int y[90009];
int h,w,d,q;
int l[100005];
int r[100005];
int sum[90009];
int main() {
  cin >> h >> w >> d;
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      int a;
      cin >> a;
      x[a] = i;
      y[a] = j;
    }
  }

  for(int i = 1; i + d <= h * w; i++) {
    sum[i+d] = sum[i] + abs(x[i] - x[i+d]) + abs(y[i] - y[i+d]);
  }

  cin >> q;

  for(int i = 0; i < q; i++) cin >> l[i] >> r[i];

  for(int i = 0; i < q; i++) {
    cout << sum[r[i]] - sum[l[i]] << endl;
  }
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;
#define ll long long int
int main ()
{
    ll num, bin;
    ll br[1000],ar[1000],cr[1000],j;
    ll k,i;
    ll a;
    cin>>a;
    ll m=9999999999999999;
    for(i=1;i<=5;i++)
       {  cin>>ar[i];
           m=min(m,ar[i]);
       }
       if(a%m==0)
        a=a/m;
       else
        a=a/m+1;
       if(a==0)
        cout<<"5";
       else
       {
cout<<5+(a-1)<<endl;
       }

    return 0;
}


Measured memory_bytes: 256
def main():

    def factorization(n):
        l = []
        tmp = n
        i = 2
        while i*i <= n:
            if tmp%i == 0:
                while tmp%i == 0:
                    tmp //= i
                l.append(i)
            i += 1
        if tmp != 1:
            l.append(tmp)
        if l == []:
            if n != 1:
                l.append(n)
        return l

    a, b = map(int, input().split())
    a_f = factorization(a)
    b_f = factorization(b)
    ans = len(set(a_f) & set(b_f)) + 1
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

lack = []
remain = []
for i in range(N):
    if A[i] < B[i]:
        lack.append(B[i]-A[i])
    if A[i] > B[i]:
        remain.append(A[i]-B[i])

sumlack = sum(lack)
remain.sort(reverse=True)

cnt = 0
while sumlack > 0:
    sumlack -= remain[cnt]
    cnt += 1
    if cnt == len(remain) and sumlack > 0:
        print(-1)
        exit()
        break

print(len(lack)+cnt)

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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n),c(n-1);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    ll ans=0;
    rep(i,n){
        ans+=b[a[i]];
        if(i!=0){
            if(a[i-1]+1==a[i])ans+=c[a[i-1]];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int N; cin>>N;
  string S,T; cin>>S>>T;
  string a;
  rep(i,N){
    a+=S.at(i);
    a+=T.at(i);
  }
  cout<<a<<endl;
}

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

int main() {
    long long L, N;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++) {
        cout << S[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // TODO TLE

    // 配る感じですすめる
    // W,Eのペアーを加算しながら勧めていく
    val n = readLine()!!.let(String::toInt)
    val s = readLine()!!

    val leftDp = IntArray(n)
    val rightDp = IntArray(n)
    for (i in 1 until s.length) {
        leftDp[i] = leftDp[i - 1]
        if (s[i - 1] == 'W') {
            leftDp[i]++
        }
    }

    for (i in s.length - 2 downTo 0) {
        rightDp[i] = rightDp[i + 1]
        if (s[i + 1] == 'E') {
            rightDp[i]++
        }
    }

    leftDp.zip(rightDp).map { it.first + it.second }.min().let(::println)

}

Measured memory_bytes: 87928
// AtCoder Beginner Contest 124 - Problem C: Coloring Colorfully (https://atcoder.jp/contests/abc124/tasks/abc124_c)
#include <bits/stdc++.h>

using namespace std;

int solve(string& S)
{
    int N = S.size(), ans = 0;

    for (int i = 1; i < N; ++i)
        if (S[i] == S[i - 1])
        { 
            ++ans;
            S[i] = (1 - (S[i - 1] - '0')) + '0';
        }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    string S;
    cin >> S;

    auto ans = solve(S);

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

int main() {


    string s, t;
    int count(0);

    cin >> s >> t;

    for (size_t i = 0 ; i < s.size() ; i++) {
        if (s[i] != t[i]) {
            count++;
        }
    }


    cout << count << "\n";


    return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[6],b;
	for(int i=1;i<=5;i++)
	cin>>a[i];
	for(int i=1;i<=5;i++)
	if(a[i]==0)
	{
		b=i;
		break;
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 3560
using System;
using System.Web;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var upper = Floor(Sqrt(n));
        int max = 1;
        for (int i = 2; i <= upper; i++)
        {
            int a = i;
            while (true)
            {
                if (a * i > n) break;
                a *= i;
            }
            max = Max(max, a);
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0,a,b;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        sum=sum+(b-a)+1;
    }
    cout<<sum<<endl;
    return 0;

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;


double X[10], Y[10];

double dist(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

void solve() {
	int N; cin >> N;
	REP(i, N)cin >> X[i] >> Y[i];
	double ans = 0;
	int perm[10];
	REP(i, N)perm[i] = i;
	do {
		REP(i, N - 1) {
			ans += dist(X[perm[i]], Y[perm[i]], X[perm[i + 1]], Y[perm[i + 1]]);
		}
	} while (next_permutation(perm, perm + N));
	ll d=1;
	FOR(i, 1, N + 1)d *= i;
	ans /= d;
	cout << setprecision(10) << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
/*
 * ID: ALDS1_1_A
 * Problem: Insert sort
 */

#include <stdio.h>

int main(void)
{
    int a[100];
    int n;

    scanf("%d", &n);
    int i, j;
    for (i = 0; i < n; i++)
        scanf("%d", a + i);
    for (j = 0; j < n; j++)
        printf("%d%s", a[j], j == n - 1 ? "": " ");
    printf("\n");

    for (i = 1; i < n; i++) {
        int v = a[i];
        for (j = i - 1; j >= 0 && a[j] > v; j--)
            a[j + 1] = a[j];
        a[j + 1] = v;

        for (j = 0; j < n; j++)
            printf("%d%s", a[j], j == n - 1 ? "": " ");
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2108