akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a = I()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return

#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return

#C
def C():
    n = I()
    v = LI()
    q = []
    for i in v:
        heappush(q,i)
    while q:
        x = heappop(q)
        if not q:
            print(x)
            return
        y = heappop(q)
        heappush(q,(x+y)/2)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 39408
#include <bits/stdc++.h>
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)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int D;
    cin >> D;

    vector<int> C(26);
    for (auto &i : C) cin >> i;

    vector<vector<int>> S(D, vector<int>(26));
    for (auto &i : S) for (auto &j : i) cin >> j;

    vector<int> t(D);
    for (auto &i : t) cin >> i, --i;

    vector<int> last(26);

    int ans = 0;
    rep(d, D) {
        // calc
        ans += S[d][t[d]];
        last[t[d]] = d+1;
        rep(i, 26) ans -= C[i] * ((d+1) - last[i]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H.at(i);
    }
    for(int i=N-2;i>=0;i--){
        if(H.at(i) > H.at(i+1)){
            H.at(i)--;
        }
    }
    bool tf = true;
    for(int i=0;i<N-1;i++){
        if(H.at(i) > H.at(i+1)){
            tf = false;
        }
    }
    if (tf){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // StringTokenizer st = new StringTokenizer(br.readLine());
        String s = br.readLine();
        String[] sarr = s.split(",");
        System.out.println(sarr[0]+" "+sarr[1]+" "+sarr[2]);
    }

}


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

int main() {
	long long N, X[1000], Y[1000];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
	for (int i = 0; i < N - 1; i++) {
		if (abs(X[i] + Y[i]) % 2 != abs(X[i + 1] + Y[i + 1]) % 2) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (abs(X[0] + Y[0]) % 2 == 0) {
		cout << 32 << endl << 1;
		for (int i = 0; i < 31; i++) {
			cout << " " << (1 << i);
		}
		cout << endl;
	}
	else {
		cout << 31 << endl;
		for (int i = 0; i < 31; i++) {
			cout << (1 << i);
			if (i == 30) cout << endl;
			else cout << " ";
		}
	}
	for (int i = 0; i < N; i++) {
		long long U = X[i] + Y[i], V = X[i] - Y[i];
		if (U % 2 == 0) {
			cout << 'R';
			U--, V--;
		}
		U = ((1LL << 32 - 1) - U) / 2, V = ((1LL << 32 - 1) - V) / 2;
		for (int i = 0; i < 31; i++) {
			long long UB = U % 2, VB = V % 2;
			U /= 2, V /= 2;
			if (UB == 0 && VB == 0) cout << 'R';
			if (UB == 0 && VB == 1) cout << 'U';
			if (UB == 1 && VB == 0) cout << 'D';
			if (UB == 1 && VB == 1) cout << 'L';
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
import bisect
n,*l = map(int,open(0).read().split())
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans += bisect.bisect_left(l,l[i]+l[j],j+1)-bisect.bisect_right(l,abs(l[i]-l[j]),j+1)
print(ans)

Measured memory_bytes: 9360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   int n,a,b[100],e=0;
   cin>>n;
   for(int i=1;i<=n;i++)
   {
       cin>>b[i];
       if(b[i]!=i)
        e++;
   }
   if(e==2||e==0)
    cout<<"YES"<<endl;
   else
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;


import java.io.*;

public class Main {
    
    public static String solve(String s1 , String s2){
        if(Math.abs(s1.length() - s2.length()) > 1 || Math.abs(s1.length() - s2.length())== 0)
            return "No";
        return (s2.indexOf(s1) == 0) ? "Yes" : "No";
    }
    

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println(solve(br.readLine().trim(),br.readLine().trim()));
    }
}

Measured memory_bytes: 32820
#include<stdio.h>

int main(){
  int N;
  int a[201]={0};
  int i;
  int cnt=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  while(1){
    for(i=0;i<N;i++){
      if(a[i]%2==1){
        printf("%d",cnt);
        return 0;
      }
      a[i]=a[i]/2;
    }
    cnt++;
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
  char a,b;
  scanf("%c %c",&a,&b);
  if(a == 'H')
    printf("%c\n",b);
  else if(b == 'H')
    printf("D\n");
  else
    printf("H\n");
    
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int N,M;
    cin>>N>>M;
    ve<int> A(N);
    in(N,A);
    
    ve<int> B(N);
    rep(i,N) B[i] = A[i]%M;
    reps(i,1,N) B[i] = (B[i]+B[i-1])%M;
    map<int,int> C;
    rep(i,N) C[B[i]]++;
    ll ans = 0;
    for(auto p : C){
        //cout << p.fi << " " << p.se << endl;
        ans += (ll)p.se*((ll)p.se+1)/2;
        if(p.fi != 0){
            ans -= ll(p.se);
        }
    }
    out(ans);


    return 0;
}


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

int main(){
    long long N;
    cin >> N;

    long long A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    long long minMove = min({A, B, C, D, E});
    
    long long ans = ((N + minMove - 1) / minMove) + 4;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int h,n;
  cin >> h >> n;
  vint dp(11010);
  erep1(i,h){
    dp[i] = INF; 
  }
  rep(j,n){
    int a,b;
    cin >> a >> b;
    rep(i,h){
      int nxt = min(i+a,h);
      dp[nxt] = min(dp[i]+b,dp[nxt]);
    }
  }
  cout << dp[h] << endl;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  if(s=="AAA")cout<<"No"<<endl;
  else if(s=="BBB")cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

  

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

int main()
{
    string s;

    cin >> s;

    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if (s == "Rainy")
    {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import kotlin.math.min

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var leftBlackCount = 0
    var rightWhiteCount = s.count { it == '.' }
    var ans = rightWhiteCount
    s.forEach {
        if (it == '#') {
            leftBlackCount++
        } else {
            rightWhiteCount--
        }
        ans = min(ans, rightWhiteCount + leftBlackCount)
    }
    println(ans)
}

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

using namespace std;

int b[105][105];

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> a(255);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (auto c : s) {
      a[c]++;
    }
  }
  int x = 0, y = 0;
  if ((n & 1) && (m & 1)) {
    y = 1;
    x = n - 1 + m - 1;
  } else if (n & 1) {
    x = m;
  } else if (m & 1) {
    x = n;
  }
  int z = n * m - x - y;
  for (int i = 'a'; i <= 'z'; ) {
    if (a[i] >= 4 && z >= 4) {
      a[i] -= 4, z -= 4;
    } else if (a[i] >= 2 && x >= 2) {
      a[i] -= 2, x -= 2;
    } else if (a[i] >= 1 && y >= 1) {
      a[i] -= 1, y -= 1;
    } else if (a[i] == 0) {
      i++;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    int maxv = -1, minv = 10010010;
    for(int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
        maxv = max(maxv, l[i]);
        minv = min(minv, r[i]);
    }
    
    int ans = minv - maxv + 1;
    if(ans < 0) cout << 0 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
def dist(X, Y, p):
    d = sum([abs(x - y)**p for x, y in zip(X, Y)])
    return d**(1/p)


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

print(dist(X, Y, 1))
print(dist(X, Y, 2))
print(dist(X, Y, 3))
print(max([abs(x - y) for x, y in zip(X, Y)]))



Measured memory_bytes: 5648
#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;   
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll p[200005],a[200005];
map<ll,ll>M;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,j,k,x,y,t,m;

    cin >> n >> k;
    for(i=1;i<=n;i++)
        cin >> a[i];

    for(i=1;i<=n;i++)
        p[i]=p[i-1]+a[i];

    ll ans=0;
    ordered_set os;
    for(i=1;i<=n;i++)
    {
        if(p[i]>=k*i)
            ans++;

        x=p[i]-k*i;
        ll c=0;
        if(M.find(x)!=M.end())
            c=M[x];

        ans+=(ll)os.order_of_key({x,-i})+c;
        M[x]++;
        os.insert({x,-i});
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 31760
N = int(input())
score = [0] * N
for i in range(N):
    score[i] = int(input())
score.sort()
disp = sum(score)
if disp % 10 != 0:
    print(disp)
    exit()
else:
    for i in score:
        tmp = disp - i
        if tmp % 10 != 0:
            print(tmp)
            exit()
print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
template<class T,enable_if_t<is_integral<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}
template<class T,enable_if_t<is_floating_point<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-fmod(-a,b);}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(a!=c)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    long double x, k, d; cin >> x >> k >> d;
    if(abs(x) / d >= k){
        cout << (ll)(abs(x) - d * k) << endl;
    }else{
        ll y = abs(x) / d;
        if(y % 2 == ll(k) % 2){
            cout << (ll)min(abs(abs(x) - y * d), abs(abs(x) - (y + 2) * d)) << endl;
        }else{
            cout << (ll)min(abs(abs(x) - (y + 1) * d), abs(abs(x) - (y + 3) * d)) << endl;
        }
    }
}

Measured memory_bytes: 3752
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static long res;
    public static long[] ary;
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n == 0) break;
            res = 0;
            ary = new long[n];
            for (int i = 0; i < n; i++) {
                ary[i] = sc.nextLong();
            }
            
            Arrays.sort(ary);
            
            for (int i = 1; i < n-1; i++) {
                res += ary[i];
            }
            
            System.out.println(res/(n-2));
        }
    }
}

Measured memory_bytes: 29508
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long ngcd(vector<long long> a){
    long long res = a[0];
    for(int i = 1; i < a.size() && res != 1; ++i) {
        res = gcd(res, a[i]);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, X;
    cin >> n >> X;
    vll x(n);
    rep(i, n) {
        cin >> x[i];
        x[i] = abs(X - x[i]);
    }
    cout << ngcd(x) << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    string s;
    cin>>s;
    cout<<s.substr(0,s.size()-8)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  string s;
  cin >> s;
  int count = 0;
  int ans = 0;
  if (s == "RSS") {
    cout << "1" << endl;
    return 0;
  }
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R')
      count++;
    else {
      ans = count;
      count = 0;
    }
  }
  cout << max(ans, count) << endl;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {

	/**
	 * ?????°???index
	 */
	final static int A = 0;
	final static int B = 1;
	final static int C = 2;
	final static int D = 3;
	final static int E = 4;
	final static int F = 5;

	/**
	 * AOJ 0004 Simultaneous Equation
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));

		String input = bufferedReader.readLine();
		String[] coefficients;
		while (input != null) {
			coefficients = input.split("\\s");

			BigDecimal[] bdCoefficients = getBigDecimalArray(coefficients);

			BigDecimal ae_bd = bdCoefficients[A].multiply(bdCoefficients[E])
					.subtract(bdCoefficients[B].multiply(bdCoefficients[D]));
			BigDecimal x = bdCoefficients[C].multiply(bdCoefficients[E])
					.subtract(bdCoefficients[B].multiply(bdCoefficients[F]))
					.divide(ae_bd, 3, RoundingMode.HALF_UP);
			BigDecimal y = bdCoefficients[A].multiply(bdCoefficients[F])
					.subtract(bdCoefficients[C].multiply(bdCoefficients[D]))
					.divide(ae_bd, 3, RoundingMode.HALF_UP);
			System.out.println(x + " " + y);

			input = bufferedReader.readLine();
		}
	}

	/**
	 * String????????????BigDecimal?????????????????????????????´??????
	 *
	 * @param strArray
	 *            String?????????
	 * @return BigDecimal?????????
	 */
	private static BigDecimal[] getBigDecimalArray(String[] strArray) {
		BigDecimal[] bigDecimalArray = new BigDecimal[strArray.length];
		for (int i = 0; i < bigDecimalArray.length; i++) {
			bigDecimalArray[i] = new BigDecimal(strArray[i]);
		}
		return bigDecimalArray;
	}

}

Measured memory_bytes: 16976
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int ans=x;
    for(int i=0;i<n;i++)
    {
        ans+=(d+a[i]-1)/a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
int main(){
	int L;cin>>L;
	int n=20;
	for(;(1<<n)>L;--n);
	cout<<n+1<<' '<<2*n+__builtin_popcount(L)-1<<'\n';
	int len=1<<n;
	for(int i=0;i<n;++i){
		cout<<i+1<<' '<<i+2<<' '<<0<<'\n';
		cout<<i+1<<' '<<i+2<<' '<<(1<<i)<<'\n';
		if(L>>i&1){
			cout<<i+1<<' '<<n+1<<' '<<len<<'\n';
			len|=1<<i;
		}
	}
	return 0;
}

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

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=arr[i]*arr[j];
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
//C - Fennec vs Monster

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    vector<long long> h(n);
    for (int i=0; i<n; i++){
        cin >> h[i];
    }
    
    sort(h.begin(), h.end(), greater<long long>());

    long long cnt = 0;

    for (int i=k; i<n; i++){
        cnt += h[i];
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=-2;
	string s,t;
	cin>>n>>s>>t;
	for(int i=0;i<=n-1;i++) 
	{
		if(t[i]==s[n-1])
		{
			bool jud=true;
			for(int j=i;j>=0;j--)
			{
				if(t[j]!=s[n-1-i+j])
					jud=false;
			}
			if(jud)
				ans=2*n-i-1; 
		}
	}
	if(ans==-2)
		ans=2*n;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int

	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	sort.Sort(sort.IntSlice(a))

	fmt.Println(a[n-1] - a[0])
}


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

void solve(vector<int> &h,vector<int> &v)
{ int n=h.size();
    for(int curr=0;curr+1<n;curr++)
    {
  	    int d1=abs(h[curr]-h[curr+1]);
        v[curr+1]=min(v[curr+1],v[curr]+d1);
        if(curr+2<n)
        {
            int d2=abs(h[curr]-h[curr+2]);
            v[curr+2]=min(v[curr+2],v[curr]+d2);
        }
    }
}
int main()
{
    int n;
    cin>>n;
    vector<int>h(n),v(n);

  for(int i=0;i<n;i++)
	cin>>h[i];
    v[0]=0;
	for(int i=1;i<n;i++)
	v[i]=INT_MAX;
  solve(h,v);
  cout<<v[n-1]<<endl;
  
}

Measured memory_bytes: 1024
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll k;
ll dp[99][100010];
//dp[s][m]=mod kでmになるものが桁和sでつくれるか(bool)
int main(){
	scanf("%lld",&k);
	
	rep(i,1,9)dp[i][i]=1;
	rep(s,1,50){
		//末尾に0を1個以上増やす
		rep(m,0,k)if(dp[s][m]){
			ll mm=m*10%k;
			while(!dp[s][mm]){
				dp[s][mm]=1;
				mm=mm*10%k;
			}
		}
		//末尾に1～9を1個増やす
		rep(m,0,k)if(dp[s][m])rep(d,1,10)dp[s+d][(m*10+d)%k]=1;
		
		if(dp[s][0]){
			printf("%lld\n",s);
			return 0;
		}
	}
}

Measured memory_bytes: 41216
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			int d=sc.nextInt();
			int s=0;
			for(int i=1; i*d<600; i++)
				s+=i*d*i*d*d;
			println(""+s);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

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

int main(){
    int w, h, n; cin >> w >> h >> n;
    vector<int> box = {0, 0, h, w}; //[x, y, h, w]
    
//    cout << "x y h w" << endl;
    
    for(int i = 0; i < n; i++){
        int x, y, a; cin >> x >> y >> a;
        
        if(a == 1){
            if(box.at(0) < x){
                box.at(3) = box.at(3) + box.at(0) - x;
                box.at(0) = x;
                if(box.at(3) < 0){
                    box.at(2) = 0;
                    box.at(3) = 0;
                    break;
                }
            }
            
        }else if(a == 2){
            if(box.at(0) > x){
                box.at(3) = 0;
                box.at(2) = 0;
                break;
            }else if(box.at(0) + box.at(3) > x){
                box.at(3) = x - box.at(0);
            }
           
        }else if(a == 3){
            if(box.at(1) < y){
                box.at(2) = box.at(2) + box.at(1) - y;
                box.at(1) = y;
                if(box.at(2) < 0){
                    box.at(2) = 0;
                }
            }
        }else if(a == 4){
            if(box.at(1) + box.at(2) > y){
                box.at(2) = y - box.at(1);
            }
        }
//        for(int i: box){
//            cout << i << " ";
//        }
//        cout << endl;

    }
    
    cout << box.at(2) * box.at(3) << endl;
    
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
seq = []

for i in range(0, n + 1):
    b = [None] * n
    for j in range(0, n): b[j] = a[j]
    seq = []
    for j in range(i - 2, -1, -1):
        seq.append((j + 1, j))
        seq.append((j + 1, j))
        b[j] += b[j + 1] * 2
    for j in range(i, n - 1):
        seq.append((j, j + 1))
        seq.append((j, j + 1))
        b[j + 1] += b[j] * 2
    valid = True
    for j in range(n - 1):
        if b[j] > b[j + 1]:
            valid = False
            break
    if valid: break

print(len(seq))
print('\n'.join(map(lambda x: '%d %d' % (x[0] + 1, x[1] + 1), seq)))


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;cin>>n;
    string s; cin>>s;
    ll ans=0,i=0,j=s.size()-1;
    while(i<j)
    {
      if(s[i]=='R') i++;
      else if(s[j]=='W') j--;
      else
      {
        ans++; i++; j--;
      }
      //cout<<i<<" "<<j<<" "<<ans<<endl;
    }
    cout<<ans;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){
 
 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    ll n,a,b;cin>>n>>a>>b;
    if((b-a)%2==0) cout<<(b-a)/2<<endl;
    else{
        ll s1=a-1;
        ll tb=b-s1;
        if((tb-1)%2==0) s1+=tb/2;
        else s1+=(tb-1)/2+1;

        a=n-a+1, b=n-b+1;
        swap(a,b);

        ll s2=a-1;
        tb=b-s2;
        if((tb-1)%2==0) s2+=tb/2;
        else s2+=(tb-1)/2+1;
        cout<<min(s1,s2)<<endl;
    }

	return 0;
}
 



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e6;

int slen;
char s[MAX];
int sa[MAX],sb[MAX];

int tlen;
char t[MAX];
int ta[MAX],tb[MAX];

void solve(int sl,int sr,int tl,int tr){
  int SA=sa[sr]-sa[sl];
  int SB=sb[sr]-sb[sl];

  int TA=ta[tr]-ta[tl];
  int TB=tb[tr]-tb[tl];
  int snum=(SA-SB+MAX)%3;
  int tnum=(TA-TB+MAX)%3;

  if(snum==tnum){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
}
int main(){
  scanf("%s",s);
  slen=strlen(s);
  for(int i=0;i<slen;i++){
    sa[i+1]=sa[i]+(s[i]=='A');
    sb[i+1]=sb[i]+(s[i]=='B');
  }
  
  scanf("%s",t);
  tlen=strlen(t);
  for(int i=0;i<tlen;i++){
    ta[i+1]=ta[i]+(t[i]=='A');
    tb[i+1]=tb[i]+(t[i]=='B');
  }

  int Q;
  scanf("%d",&Q);
  while(Q--){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    a--,c--;
    solve(a,b,c,d);
  }
  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 998244353;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
vi G[N];
int H[N];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int n, m;
    cin >> n >> m;
    fore(i, 0, n)
        cin >> H[i];
    w(m){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    /*fore(i, 0, n){
        cout << i + 1 << " : {";
        fore(j, 0, sz(G[i]))
        cout << G[i][j] + 1 << ", ";
        cout << "}\n";
    }*/
    int ans = 0;
    fore(i, 0, n){
        if(sz(G[i]) == 0)
            ans++;
        else{
            bool flag = 1;
            fore(j, 0, sz(G[i])){
                if(H[i] <= H[G[i][j]]){
                    flag = 0;
                    break;
                }
            }
            if(flag)
                ans++;
        }
    }
    cout << ans << "\n";
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 9264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline
ll getint(){
	re ll num=0;
	re char c;
	while(!isdigit(c=gc()));
	while(isdigit(c))num=(num<<1)+(num<<3)+(c^48),c=gc();
	return num;
}

inline
void outint(ll a){
	static char ch[23];
	if(a==0)pc('0');
	while(a)ch[++ch[0]]=(a-a/10*10)^48,a/=10;
	while(ch[0])pc(ch[ch[0]--]);
}

int a,b;
int main(){
	a=getint();
	b=getint();
	if(a==2||b==2)puts("No");
	else puts("Yes");
	return 0;
}

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


int main(){
  int k,n;
  cin >>k>>n;
  vector <int> a(n);
  rep(i,n)cin>>a.at(i);

  int tan = a.at(0) +k - a.at(n-1);
  int amax=tan;
  ll sum=tan;
  for(int i=1;i<=n-1;++i){
    int dist =a.at(i)-a.at(i-1);
    sum += dist;
    amax = max(amax,dist);
  }
  sum -= amax;
  cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int main(){
	ll n;
	cin >> n;
	string ans;
	while (n){
		n--;
		ans += 'a' + n % 26;
		n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}



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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int x,n;
   cin >> x >> n;

   set<int> s;
   f(i,0,n){
      int a;
      cin >> a;
      s.insert(a);
   }

   int ans  , gap = inf;

   rf(i,1000,-1000){
      if(s.find(i) == s.end() && abs(i-x) <= gap){
         ans = i;
         gap = abs(i-x);
      }
   }
   cout << ans << "\n";
}

Measured memory_bytes: 3664
L = [input() for i in range(4)]
X, Y, A, B, C = map(int, L[0].split())
p = list(map(int, L[1].split()))
q = list(map(int, L[2].split()))
r = list(map(int, L[3].split()))

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)

p = p[:X]
q = q[:Y]

s = p + q + r
# print(p)

s = sorted(s, reverse=True)

s = s[:X+Y]

print(sum(s))

Measured memory_bytes: 26016
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, r int
	var s string
	fmt.Scan(&N)
	m := map[string]int{}
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		m[StrSort(s)]++
	}
	for _, v := range m {
		if v < 2 {
			continue
		}
		r += Combination(v, 2)
	}
	fmt.Println(r)
}

func StrSort(s string) string {
	a := make([]string, len(s))
	for i, v := range s {
		a[i] = string(v)
	}
	sort.Sort(sort.StringSlice(a))
	r := ""
	for i := 0; i < len(s); i++ {
		r += a[i]
	}
	return r
}

func Factorial(n int) int {
	return Permutation(n, n-1)
}

func Permutation(n, k int) int {
	if k > n {
		return 0
	}
	r := 1
	for i := n; i > n-k; i-- {
		r *= i
	}
	return r
}

func Combination(n, k int) int {
	return Permutation(n, k) / Factorial(k)
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 1e5;
vector<int> es[MAX_V];

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, M){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    queue<int> que;
    que.push(0);
    int ans[N];
    fill(ans, ans+N, -1);
    ans[0] = 0;
    while(!que.empty()){
        int i = que.front();
        que.pop();
        for(auto &e: es[i]){
            if(ans[e] != -1) continue;
            ans[e] = i;
            que.push(e);
        }
    }
    cout << "Yes" << endl;
    rep2(i, 1, N-1) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 10516
n = int(input())
a = list(map(int, input().split()))

d = {}
for ai in a:
    if d.get(ai) == None:
        d[ai] = 1
    else:
        d[ai] += 1

ans = 0
for k, v in d.items():
    if k > v:
        ans += v
    else:
        ans += v - k

print(ans)

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

 /*int lenght(char* str){
    int i=0;
    while(str[i]){
     i++;
    }
    return i;
    }*/
    
    
int main() {
    string s;
    cin >> s;
    int count_gu_0= 0;
    int count_gu_1= 0;
    int count_ki_0= 0;
    int count_ki_1= 0;
    
    int N=s.size();
    
    for (int i = 0; i < N;i=i+2){
    	if(s[i]%2==0){
    	    count_gu_0 ++;	
    	}
    	else if(s[i]%2 != 0){
    		count_gu_1 ++;
    	}
     }
    
    for (int i = 1; i < N;i=i+2){
    	if(s[i]%2==0){
    	    count_ki_0 ++;	
    	}
    	else if(s[i]%2 != 0){
    		count_ki_1 ++;
    	}
     }
     
     if(N%2==0){
     int kouho_1_0=N/2;
     int kouho_1_1=N/2;
     int kouho_2_0=N/2;
     int kouho_2_1=N/2;
     int a=0;
     int b=0;
     
     a=(kouho_1_1  - count_gu_1)+(kouho_1_0  - count_ki_0);
     b=(kouho_2_0  - count_gu_0)+(kouho_2_1  - count_ki_1);
     int c=0;
     if(a>b){c=b;}
     else{c=a;}
     
     cout<<c<<endl;
     
    }
    
    else if(N%2 != 0){
     int kouho_1_0=N/2;
     int kouho_1_1=N/2+1;
     int kouho_2_0=N/2+1;
     int kouho_2_1=N/2;
     int a=0;
     int b=0;
     
     a=(kouho_1_1  - count_gu_1)+(kouho_1_0  - count_ki_0);
     b=(kouho_2_0  - count_gu_0)+(kouho_2_1  - count_ki_1);
     int c=0;
     if(a>b){
     	c=b;
     }
     else{
     	c=a;
     }
     
     cout<<c<<endl;

    }
    
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
#define int ll
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

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

typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};

signed main(){

	string S;
	cin >> S;
	int c = 0;
	char prev = S[0];
	for (int i = 0; i < S.length(); i++){
		if (S[i] != prev){
			c++;
			prev = S[i];
		}
	}
	cout << c << endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = Inputer.IntArray1Line();
            if(N[0] <10 && N[1] < 10)
            {
                Console.WriteLine(N[0] * N[1]);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }

    /// <summary>
    /// 入力受付
    /// </summary>
    static class Inputer
    {
        /// <summary>
        /// A B C の複数整数からなる1行を受け取る
        /// </summary>
        /// <returns></returns>
        public static int[] IntArray1Line()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
    }

    /// <summary>
    /// 順列を出すやつ
    /// </summary>
    /// <typeparam name="T"></typeparam>
    static class Permutation<T>
    {
        private static void Search(List<T[]> perms, Stack<T> stack, T[] a)
        {
            int N = a.Length;
            if (N == 0)
            {
                perms.Add(stack.Reverse().ToArray());
            }
            else
            {
                var b = new T[N - 1];
                Array.Copy(a, 1, b, 0, N - 1);
                for (int i = 0; i < a.Length; ++i)
                {
                    stack.Push(a[i]);
                    Search(perms, stack, b);
                    if (i < b.Length) { b[i] = a[i]; }
                    stack.Pop();
                }
            }
        }
        public static IEnumerable<T[]> All(IEnumerable<T> src)
        {
            var perms = new List<T[]>();
            Search(perms, new Stack<T>(), src.ToArray());
            return perms;
        }
    }
}

Measured memory_bytes: 13396
n = int(input())
d = list(map(int, input().split()))

import collections
c = collections.Counter(d)
if d[0] == 0:
    if c[0] != 1:
        print(0)
    else:
        result = 1
        for i in range(1, len(c)):
            result *= c[i-1]**c[i]
            result = result%998244353
        print(result)
else:
    print(0)

Measured memory_bytes: 18932
<?php
$s = trim(fgets(STDIN));
$max = 0;
$m = 0;
for($i = 0; $i < strlen($s); $i++){
  if(strpos("AGCT",$s[$i])!==false){
    $m++;
    $max = max($max, $m);
  }else{
    $m = 0;
  }
}
echo $max;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

size_t b2()
{
    size_t n, m;
    cin >> n >> m;

    vector<bool> tag(n, false);
    vector<size_t> cnt(n, 1);
    tag[0] = true;

    for(size_t i = 0, u, v; i < m; ++ i)
    {
        cin >> u >> v;
        -- u; -- v;

        tag[v] = tag[v] || tag[u];

        ++ cnt[v];
        if(!--cnt[u])
            tag[u] = false;
    }

    return accumulate(begin(tag), end(tag), (size_t) 0);
}

int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << b2();

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

#define M 12

int main(){

  int cost,m,n;
  int sum;
  int st;
  while(1){
    sum=0;
    st=0;
    cin >>cost;
    if(cost==0) break;

    for(int i=1;i<=M;i++){
      cin >>m>>n;
      if(sum<cost){
      sum+=(m-n);
      if(sum>=cost)st=i;
      }
    }
    
    if(st!=0)cout <<st<<endl;
    else cout <<"NA"<<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 510000;
const int MOD = 1e9;

const double PI=3.14159265358979323846;

/*
long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}*/

int length(vector<int> v, int u, int HW){
    if(v.size() == 0) return HW;
    if(v[0] > u) return v[0];
    if(v[v.size() - 1] < u) return HW - v[v.size()- 1] -1;
    else{
        int i = lower_bound(ALL(v), u)- v.begin();
        return v[i] - v[i-1] -1;
    }
}

int main(){
    cin >> N >> M;
    vector<pair<int, int>> v;
    REP(i,M){
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    int init = pow(10, N-1);
    if (N == 1) init = 0;
    int fin  = pow(10,N) -1;
    //cout << init << " "<< fin ;
    vector<int> digit(N);
    for(int n = init; n <= fin; ++n){
        int m = n;
        bool flag = true;
        //cout << "kk" << "\n";
        REP(i,N){digit[i] =m%10; m /= 10;}
        for(auto u: v){
            if(digit[N- u.first] != u.second ) flag = false;
        }
        if(flag) {cout << n ; return 0;}
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main(void)
{
	int i,n,m,x,z,a[100001],b[100001];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		b[i]=0;
		scanf("%d",&a[i]);
	}
	x=0;
	z=1;
	m=0;
	while(1){
		if(m==1 || z==2){
			printf("%d\n",x);
			break;
		}
		if(b[a[z]]==0){
			b[z]=1;
			z=a[z];
			x++;
		}
		else{
			m=1;
			x=-1;
		}
	}
	return 0;
}

Measured memory_bytes: 896