akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, m;
int arr[N];

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + m);
  multiset <int> ms;
  long long ans = 0;
  for (int i = 1; i < m; i++) {
    ms.insert(arr[i] - arr[i - 1]);
    ans += arr[i] - arr[i - 1];
  }
  while (n > 1 && !ms.empty()) {
    ans -= *(--ms.end());
    ms.erase(--ms.end());
    n--;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    int cnt[10][10] = {};

    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);

        cnt[s[0] - '0'][s[s.size()-1] - '0']++;
    }

    int ans = 0;

    for (int i = 1; i <= n; ++i) {
        string s = to_string(i);

        ans += cnt[s[s.size()-1] - '0'][s[0] - '0'];
    }

    cout << ans << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c;cin>>a>>b>>c;
    set<int> x;
    x.insert(a);x.insert(b);x.insert(c);
    if (x.size()==2)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) {
    return a.first < b.first;
  }
  if (a.first == 0) {
    if (a.second >= 0) {
      return true;
    }
    return a.first < b.first;
  }
  if (b.first == 0) {
    if (b.second >= 0) {
      return false;
    }
    return a.first < b.first;
  }
  return a.second * b.first < a.first * b.second;
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


void solve() {
  int n; string s; cin >> n >> s;
  for (auto &c : s) {
    c += n;
    if (c > 'Z') c -= 26;
  }
  cout << s << endl;
}


/* -------- <programs end> -------- */


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  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 reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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 MOD = 1000000007;

vector<string> directions = {"NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"};
vector<double> degrees;
vector<double> velocity = {0.0, 0.25, 1.55, 3.35, 5.45, 7.95, 10.75, 13.85, 17.15,
						   20.75, 24.45, 28.45, 32.65, 12001./60.};

void solve()
{	
	int n,a,b; cin >> n >> a >> b;
	string s; cin >> s;
	int tot = 0, b_n = 0;
	vector<string> ans;
	rep(i,sz(s))
	{
		if(s[i] == 'a')
		{
			if(tot < a + b)	{cout << "Yes" << endl;;tot++;}
			else cout << "No" << endl;;
		}
		else if (s[i] == 'b')
		{
			if(tot < a + b && b_n < b) {cout << "Yes" << endl;;tot++;}
			else cout << "No" << endl;;
			b_n++;
		}
		else cout << "No" << endl;;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 848
K,T=map(int,input().split())
A=list(map(int,input().split()))

B=max(A)

if T==1:
    print(max(K-1,1))
    exit()

if K%2:
    X=(K+1)//2
    if X>=B:
        print(0)
    else:
        C=B-X
        print(2*C)
else:
    Y=K//2
    if Y>=B:
        print(0)
    else:
        C=B-Y
        print(2*C-1)


Measured memory_bytes: 61948
class Tree
	attr_accessor :parent, :root, :dep, :key, :left,:right, :sib
	def initialize(key)
		@parent = -1
		@left = -1
		@right = -1
		@dep = -1
		@key = key
		@sib = -1
	end

	def depth(ans,tree)
		if @left!=-1
			@left.depth(ans+1,tree)
		end
		
		if @right != -1
			@right.depth(ans+1,tree)
		end
		@dep = ans
	end

	def height(h)
		n1 = h
		n2 = h

		if @left!=-1
			n1 = left.height(h+1) 
		end

		if @right!=-1
			n2 = right.height(h+1)
		end

		return n1 > n2 ? n1:n2
	end

	def showparent
		if @parent==-1
			return -1
		else
			return @parent.key
		end
	end

	def showsib
		if @sib == -1
			return -1
		else
			return @sib.key
		end
	end

	def degree
		ans = 0
		if @left != -1
			ans+=1
		end
		if @right != -1
			ans+=1
		end
		ans
	end

	def preorder(list)
		list << @key
		if @left != -1
			list = @left.preorder(list)
		end
		if @right != -1
			list = @right.preorder(list)
		end
		
		list
	end	

	def inorder(list)
		if @left != -1
			list = @left.inorder(list)
		end
		list << @key
		if @right != -1
			list = @right.inorder(list)
		end

		list
	end

	def postorder(list)
		if @left != -1
			list = @left.postorder(list)
		end

		if @right != -1
			list = @right.postorder(list)
		end
		list << @key
		list
	end
end




n = gets.to_i

tree = Hash.new
check = Array.new(n){true}
n.times do |i|
	tree[i] = Tree.new(i)
end

n.times do
	data = gets.split.map(&:to_i)
	num = data[0]
	tree[num].left = tree[data[1]]||-1
	tree[num].right = tree[data[2]]||-1
	if tree[data[1]]
		tree[data[1]].parent = tree[num]
		tree[data[1]].sib = tree[data[2]]||-1
		check[data[1]] = false
	end
	if tree[data[2]]
		tree[data[2]].parent = tree[num]
		tree[data[2]].sib = tree[data[1]]||-1
		check[data[2]] = false
	end
	
	
end
r = check.index(true)
obj = tree[r]
list = []
puts "Preorder"
puts " #{obj.preorder(list).join(" ")}"
list = []

puts "Inorder"
puts " #{obj.inorder(list).join(" ")}"
list = []

puts "Postorder"
puts " #{obj.postorder(list).join(" ")}"

Measured memory_bytes: 8760
ac = 0
wa = 0
tle = 0
re = 0

n = int(input())

for _ in range(n):
    result = input()
    if(result == "AC"):
        ac += 1
    if(result == "WA"):
        wa += 1
    if(result == "TLE"):
        tle += 1
    if(result == "RE"):
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))


Measured memory_bytes: 9208
#!/usr/bin/env python3
import sys

inf = float('inf')

def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    V = list(range(N))
    
    next_v = [[] for v in V]
    for i in range(M):
        next_v[a[i]-1].append((b[i]-1, c[i]))
    
    D = [-inf for v in V]
    D[0] = 0
    
    prev = [None for v in V]

    positive = [False for v in V]

    for i in range(N-1):
        for u in V:
            for v, w in next_v[u]:
                alt = D[u] + w
                if alt > D[v]:
                    D[v] = alt
                    prev[v] = u
    ans = D[N-1]
    
    for i in range(N-1):
        for u in V:
            for v, w in next_v[u]:
                alt = D[u] + w
                if alt > D[v]:
                    D[v] = alt
                    positive[v] = True
                if positive[u]:
                    positive[v] = True

    if positive[N-1]:
        print('inf')
    else:
        print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    c = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

string s;

int main(int argc, char const *argv[]) {
	cin >> s;
	int res = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'g') res++;
		else res--;
	}
	cout << res/2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    long long N, C, K;
    cin >> N >> C >> K;
    
    long long T[N];
    for (long long i = 0; i < N; ++i) cin >> T[i];
    
    sort(T, T + N);
    
    long long i =0;
    long long res = 1;
    long long dep = T[0] + K;
    
    bool b = false;
    
    while (i < N) {
        for (int j = i; j < C + i; ++j) {
            if ( j >= N) {
                i = N;
                b = true;
                break;
            }
            if (T[j] > dep) {
                dep = T[j] +K;
                ++res;
                i = j;
                b = true;
                break;
            } 
        }
        
         if (!b) {
                if (i >= N - C ) {
                    i = N;
                } else {
                    i = C + i;
                    dep = T[i] + K;
                    ++res;
                }
                
            } else {
                b = false;
            }
    }
    
    cout << res << endl;
}

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

int h, w;
int data[111][111];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int solve(int x, int y){

  if(x < 0 || y < 0 || x == w || y == h) return 0;
  if(!data[y][x]) return 0;

  int ret = 0;
  for(int i=0;i<4;i++){
    data[y][x] = 0;
    ret = max(ret, solve(x+dx[i], y+dy[i]) + 1);
    data[y][x] = 1;
  }

  return ret;
}

int main(){

  while(cin >> w >> h, w|h){
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> data[i][j];
    
    int ans = 0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	ans = max(ans, solve(j, i));
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 1196
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,q,l,r,a[1<<19]={0};
	string s;
	cin>>n>>q>>s;
	for(int i=1;i<n;i++)a[i]=a[i-1]+(s[i-1]=='A'&&s[i]=='C');
	for(int i=0;i<q;i++)
	{
		cin>>l>>r;
		cout<<a[r-1]-a[l-1]<<endl;
	}
}

Measured memory_bytes: 3072
#include <stdio.h>

int main () {
	int a, b, c;
	scanf ("%d %d %d", &a, &b, &c);
	if ((a == b && b != c) || (a == c && a != b) || (b == c && c != a)) {
		printf ("Yes\n");
	} else printf ("No\n");
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int A = in.nextInt();
            int[] x = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt();
            }

            long[][][] dp = new long[N + 1][51][2501];
            dp[0][0][0]++;
            for (int i = 0; i < N; i++) {
                for (int n = 0; n < 51; n++) {
                    for (int sum = 0; sum < 2501; sum++) {
                        if (dp[i][n][sum] <= 0) {
                            continue;
                        }
                        dp[i + 1][n + 0][sum + 0] += dp[i][n][sum];
                        dp[i + 1][n + 1][sum + x[i]] += dp[i][n][sum];
                    }
                }
            }

            long count = 0;
            for (int n = 0; n < 51; n++) {
                for (int sum = 0; sum < 2501; sum++) {
                    if (dp[N][n][sum] > 0 && sum > 0 && sum == A * n) {
                        count += dp[N][n][sum];
                    }
                }
            }

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


Measured memory_bytes: 93864
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

ll cm = 0;

void merge(vector<int> &A, int left, int mid, int right){
    int n1 = mid - left, n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1] = INF;
    R[n2] = INF;
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        if(L[i] < R[j]){
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
        cm++;
    }
}

void mergeSort(vector<int> &A, int left, int right){
    if(right - left > 1){
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    mergeSort(A, 0, N);
    rep(i, N){
        if(i != N - 1) cout << A[i] << ' ';
        else cout << A[i] << endl;
    }
    cout << cm << endl;
}


Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,M;
  cin>>N>>M;
  ll k[M];
  ll count[M];
  rep(i,M){
    count[i]=0;
  }
  ll s[M][N];
  for(int i=0;i<M;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      cin>>s[i][j];
    }
  }
  ll p[M];
  ll ans=0;
  rep(i,M) cin>>p[i];
  for(int tmp=0;tmp<(1<<N);tmp++){
    bitset<10> c(tmp);
    for(ll i=0;i<N;i++){
      if(c.test(i)){
        for(ll j=0;j<M;j++){
          for(ll l=0;l<k[j];l++){
            if(s[j][l]==i+1){
              count[j]++;
            }
          }
        }
      }
    }
    bool j=true;
    for(int i=0;i<M;i++){
      if(count[i]%2!=p[i]){
        j=false;
      }
    }
    if(j) ans++;
    rep(i,M) count[i]=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%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;
  }
};

vector<mint> fac(2000003, 1);

void calc(int n){
  rep(i, n){
    fac.at(i+1) = fac.at(i) * (i+1);
  }
  return;
}

mint f(int r, int c){ // (r+c)!/(r!c!)
  mint a = fac.at(r+c);
  mint b = fac.at(r);
  mint d = fac.at(c);
  mint ans = a / (b * d);
  return ans;
}

int main(){
  calc(2000002);
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  cout << (f(r2+1, c2+1) - f(r2+1, c1) - f(r1, c2+1) + f(r1, c1)).x << endl;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <cmath>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INFL = 1e18;
const int INF = 1000000007;
const ld PI = acos(-1);
const ld EPS = 1e-13;
const ll MOD = 1000000007;

void add(ll& a, ll b) {
    a += b;
    while (a >= MOD) {
        a -= MOD;
    }
}

void mul(ll& a, ll b) {
    a = (a * b) % MOD;
}

ll todeg(ll x, ll d) {
    if (d < 0LL) {
        d += MOD - 1;
    }
    if (d == 0LL) {
        return 1LL;
    }
    ll ans = todeg(x, d / 2LL);
    mul(ans, ans);
    if (d % 2 == 1) {
        mul(ans, x);
    }
    return ans;
}

vector<ll> fact;
vector<ll> rfact;

void prep(int n) {
    fact.assign(n + 1, 1);
    rfact.resize(n + 1);
    for (int i = 1; i <= n; ++i) {
        fact[i] = fact[i - 1];
        mul(fact[i], i);
    }
    rfact[n] = todeg(fact[n], -1);
    for (int i = n - 1; i >= 0; --i) {
        rfact[i] = rfact[i + 1];
        mul(rfact[i], i + 1);
    }
}

ll C(int n, int k) {
    ll ans = fact[n];
    mul(ans, rfact[k]);
    mul(ans, rfact[n - k]);
    return ans;
}

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

    int n;
    cin >> n;
    vector<ll> d1, d2;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        d1.push_back(x + y);
        d2.push_back(x - y);
    }
    sort(d1.begin(), d1.end());
    sort(d2.begin(), d2.end());

    ll ans = max(d1.back() - d1[0], d2.back() - d2[0]);

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6696
#include<stdio.h>
#include<string.h>

int main(){
  char s[100010];
  int n,cnt=0;
  scanf("%s",s);
  n=strlen(s);
  for(int i=1;i<n;i++)
    if(s[i]!=s[i-1])
      cnt++;
  printf("%d\n",cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <math.h>

using namespace std;

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

int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
    lli x,ans=0;
    cin>>x;
    lli temp=100;
    while(temp<x)
    {
       ans++;
       temp*=1.01;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3596
package main

import (
	"fmt"
	"math"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	W := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &W[i])
	}

	var S1, S2 int
	var min int = 10000
	for T := 1; T < N; T++ {
		S1 = 0
		S2 = 0
		for i := 0; i < T; i++ {
			S1 += W[i]
		}
		for i := N - 1; i >= T; i-- {
			S2 += W[i]
		}

		if min >= int(math.Abs(float64(S1)-float64(S2))) {
			min = int(math.Abs(float64(S1) - float64(S2)))
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 1844
#include <iostream>

using namespace std;

int main (){
	int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ansa = a / d, ansb = c / b;
  if(a % d != 0)ansa++;
  if(c % b != 0)ansb++;

  if(ansa >= ansb)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		cs: Chars,
	}

	if cs[0] == cs[2] {
		println!("Yes");
	}
	else {
		println!("No");
	}
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const long long MOD=1000000007;
const long double Pi=acos(-1);
long long nature(long long a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll mod_pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
vector<long long> fact, fact_inv, inv;
void init_nCk(int n){
    fact.resize(n+54);
    fact_inv.resize(n+54);
    inv.resize(n+54);
    fact[0]=1;
    fact[1]=1;
    fact_inv[0]=1;
    fact_inv[1]=1;
    inv[1]=1;
    for(int i=2;i<n+54;i++){
        fact[i]=(fact[i-1]*i)%MOD;
        inv[i]=MOD-(inv[MOD%i]*(MOD/i))%MOD;
        fact_inv[i]=(fact_inv[i-1]*inv[i])%MOD;
    }
}
int nCk(int n,int k){
    return fact[n]*((fact_inv[k]*fact_inv[n-k])%MOD)%MOD;
}
int main(){
  #define int long long
  int N;
  int ans=0;
  int MOD=1000000007;
  cin>>N;
  if(N<3){cout<<0<<endl;return 0;}
  init_nCk(10000000);
  for(int i=1;i<=N;i++){
    //iグループに分ける
    int x=N-3*i;
    if(x<0){break;}
    if(i==1){ans++;ans%=MOD;}
    else{
      if(x==0){ans++;ans%=MOD;}
      else{
        ans+=nCk(x+i-1,i-1);
        ans%=MOD;
      }
    }
  }
  cout<<ans%MOD<<endl;
}

Measured memory_bytes: 237636
#include<stdio.h>

int main(){
long n = 0, result=0;
scanf("%d\n", &n);
char s[n];

for(long i = 0; i<n; i++){scanf("%c", &s[i]);}

int temp=0;
for(long i = 0; i<n; ){
    while(1){
    if(s[i]==s[i+1]){
        temp=1;
        i++;
    }else{
        i++;
        break;}
    }
    if(temp){result+=temp;}else{result+=1;}
}
printf("%ld", result);
return 0;
}

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

int main()
{

   long long int a,b,c,k;
   cin>>a>>b>>c>>k;
   long long int sum=0;
   long long int z=k-(a+b);
  if(k>=(a+b))
  {
      sum=sum+a-z;
  }
  else sum=k;
  cout<<sum;



}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int, greater<int> > cnt;
    for (int i=0; i<(1<<n); i++) {
        int s; cin >> s;
        cnt[s]++;
    }
    int slots[n+1];
    fill(slots, slots+n+1, 0);
    slots[0] = 1;
    for (auto &c:cnt) {
        int ci = c.second;
        int buf[n+1];
        fill(buf, buf + n+1, 0);
        for (int i=0; i<=n; i++) {
            int dif = min(slots[i], ci);
            slots[i] -= dif;
            ci -= dif;
            for (int j=i+1; j<=n; j++)
                buf[j] += dif;
            if (ci == 0) break;
        }
        if (ci > 0) {
            cout << "No\n";
            return 0;
        }
        for (int i=0; i<=n; i++) slots[i] += buf[i];
    }
    cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 12544
#include <iostream>
using namespace std;
int main(void){
    int n, k; cin>>n>>k;
    if(k>=n) {cout<<1<<endl; return 0;}
   // cout<<n<<k<<endl;
    for(int i=1;i<100005;i++){
       //if(i==1) {if(1+(k-1)*1>=n) cout<<1<<endl; return 0;}
        //cout <<1+(k-1)*i<<':'<<1+(k-1)*(i+1);
        if(n>1+(k-1)*i&&n<=1+(k-1)*(i+1)) {
            cout<<i+1<<endl; return 0;
        }
        //cout<<endl;
    }
    
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=0;i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=0;i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char memarr[96000000];
int N;
long long K;
int A[100000];
int B[100000];
int main(){
  int i, j;
  wmem = memarr;
  rd(N);
  rd(K);K += (-1);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
      rd(B[Lj4PdHRW]);
    }
  }
  sortA_L(N, A, B);
  for(i=0;i<(N);i++){
    if(K < B[i]){
      wt_L(A[i]);
      wt_L('\n');
      break;
    }
    K -= B[i];
  }
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// int N; ll K;
// int A[1d5], B[1d5];
// {
//   int i, j;
//   rd(N,K--,(A,B)(N));
//   sortA(N, A, B);
//   rep(i,N){
//     if(K < B[i]) wt(A[i]), break;
//     K -= B[i];
//   }
// }


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K, X;
    cin >> K >> X;
    int start = X - K + 1;
    int end = X + K - 1;
    for(int i = start; i <= end; i++) {
        if(i == end) {
            cout << i << endl;
        } else {
            cout << i << " ";
        }
        
    }
}


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

class Cube {
public:
  int face[6];
  Cube() {}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}    
  
  void roll(int i, int j, int k, int l) {
    int t = face[i];
    face[i] = face[j];
    face[j] = face[k];
    face[k] = face[l];
    face[l] = t;
  }
  
  
  void move(char ch) {
    if(ch == 'E') {
      for(int i = 0; i < 3; i++) roll_y();
    } else if (ch == 'W') {
      roll_y();
    } else if (ch == 'N') {
      roll_x();
    } else if (ch == 'S') {
      for(int i = 0; i < 3; i++) roll_x();
    }
    
  }

  int getRight(Cube c1, int f1, int f2) {
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 4; j++) {
	if (c1.face[0] == f1 && c1.face[1] == f2) return c1.face[2];
	c1.roll_z();
      }
      if (i % 2 == 0) c1.roll_y();
      else c1.roll_x();
    }
    return -1;
  }
  
};

bool eq(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    if (c1.face[i] != c2.face[i]) return false;
  }
  return true;

}

bool equal(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      if(eq(c1,c2)) return true;
      c1.roll_z();
    }
    if(i % 2 == 0) c1.roll_y();
    else c1.roll_x();
  }
  return false;

}

int main() {
  Cube c1,c2;
  for (int i = 0; i < 6; i++) cin >> c1.face[i];
  for (int i = 0; i < 6; i++) cin >> c2.face[i];

  if (equal(c1, c2)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
    int n;
    int h, m;
    int i;
    double angle;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d:%d", &h, &m);
        
        angle = h * 360 / 12 + 0.5 * m;
        angle -= (360 / 60 * m);
        
        if (angle > 180){
            angle -= 360;
        }
        else if (angle < -180){
            angle += 360;
        }
        
        if (-30 < angle && angle < 30){
            printf("alert\n");
        }
        else if (-90 < angle && angle < 90){
            printf("warning\n");
        }
        else {
            printf("safe\n");
        }
    }
    return (0);
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl ;
#define Yes cout << "Yes" << endl ;
#define NO cout << "NO" << endl ;
#define No cout << "No" << endl ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    lli num1 , num2 , num3 , maxm = 0 ;
    cin >> num1 >> num2 >> num3 ;

    maxm = max ({num1 , num2 , num3}) ;

    cout <<( num1 + num2 + num3 ) - maxm + (maxm * 10) ;


    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}


int N,K;
int table[1005][1005];

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> K;
  rep(i,N){
    int x,y;char c;cin >> x >> y >> c;
    x%=2*K;
    y%=2*K;
    int black = 1;
    //if(c=='W')black^=1;
    //if(x>=K)black^=1;
    //if(y>=K)black^=1;
    black^=(c=='W');
    black^=(x>=K);
    black^=(y>=K);
    x%=K;
    y%=K;
    table[1][1]+=black;
    if(!black)black=-1;
    table[1][y+2]-=black;
    table[x+2][1]-=black;
    table[x+2][y+2]+=2*black;
  }
  int ans = 0;
  rep(x,K)rep(y,K){
    table[x+1][y+1] += table[x+1][y] + table[x][y+1] - table[x][y];
    ans = max(ans, max(table[x+1][y+1], N-table[x+1][y+1]));
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

long long int maxim(long long int a,long long int b)
{

if(a>b)
{

    return a;
}
return b;
}

long long int minim(long long int a,long long int b)
{

if(a<b)
{

    return a;
}
return b;
}

long long int gcd(long long int a,long long int b)
{

if(b==0)
{

    return a;
}
return gcd(b,a%b);
}

long long int power(long long int a, long long int b)
{
    if(b==0)
    {
        return 1;
    }
    if(b==1)
    {
        return a;
    }
    long long int c = 1;
    while (b)
    {
        if (b & 1){
        c = (c * a)%1000000007;
        }
        a = ((a%1000000007) * (a%1000000007)%1000000007);
        b >>= 1;
    }
    return c;
}

void solve()
{
long long int n;
cin>>n;
int a[100000];
int dp[100000];
long long int i;
for(i=0;i<n;i++)
{
    cin>>a[i];
}
dp[0]=0;
dp[1]=abs(a[0]-a[1]);

for(i=2;i<n;i++)
{
    dp[i]=minim(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
}
cout<<dp[n-1]<<endl;

}

int main()
{

long long int t;

    solve();

return 0;
}


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

int main(){
    int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << x[k-1] << endl;
    return 0;
}

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

int main(){
  int x,y,r;

  cin>>x>>y;
  if(x<y){
    int tmp=x;
    x=y;
    y=tmp;
  }
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int MAX=1e5+5;
const ll MOD=1e9+7;
ll adm(ll a,ll b){
	return (a+b)%MOD;
}
ll tim(ll a,ll b){
	return (a*b)%MOD;
}

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_inv(ll a){
	ll x,y;
	extgcd(a,MOD,x,y);
	return (MOD+x%MOD)%MOD;
}

int main(){
	ll N,A,B,C;
	cin>>N>>A>>B>>C;
	ll ans=100;
	ans=tim(ans,N);
	ll iab=mod_inv(A+B);
	rep(i,2*N-1)ans=tim(ans,iab);
	
	ll b[MAX], c[MAX];
	ll ab[MAX];
	
	b[0]=1;
	c[0]=1;
	
	
	rep1(i,N-1){
		b[i]=tim(b[i-1],2*i);
		b[i]=tim(b[i],2*i-1);
		ll p=mod_inv(i);
		b[i]=tim(b[i],p);
		b[i]=tim(b[i],p);
		ll q=mod_inv(i+1);
		c[i]=tim(b[i], q);
	}
	ab[0]=1;
	rep(i,2*N-2){
		ab[0]=tim(ab[0], A+B);
	}
	ll xy=mod_inv(A+B);
	rep1(i,N-1){
		ab[i]=tim(ab[i-1], A);
		ab[i]=tim(ab[i], B);
		ab[i]=tim(ab[i], xy);
		ab[i]=tim(ab[i], xy);
	}
	ll up=0;
	rep(i,N){
		ll prod=tim(c[i], ab[i]);
		up=adm(up, prod);
	}
//  	rep(i,N)cout<<ab[i]<<" ";
	ans=tim(ans, up);
	
	cout<<ans<<endl;
}

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

int main() {
  int value = 700;
  string s;

  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'o') {
      value += 100;
    }
  }

  cout << value << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 330000
#define sqr(x) ((x)*(x))
using namespace std;
ll n,s,m;
bool check(int b){
	ll x=n,sum=0; for (; x; x/=b) sum+=x%b;
	return sum==s;
}
void Min(ll &x,ll y){ if (x==-1 || y<x) x=y; }
int main(){
	cin>>n>>s; m=min(n,(ll)N);
	rep (b,2,m) if (check(b)){ printf("%d\n",b); exit(0); }
	if (n<s){ puts("-1"); exit(0); }
	if (n==s){ cout<<s+1<<endl; exit(0); }
	m=n-s; ll ans=-1;// printf("%lld\n",m);
	for (ll a1=1; sqr(a1)<=m; a1++) if (m%a1==0){
		if (a1<=s && n-a1*(m/a1+1)>=0 && n-a1*(m/a1+1)<(m/a1+1) && (m/a1+1)>=2 && (m/a1+1)>n/(m/a1+1)) Min(ans,m/a1+1);
		if (m/a1<=s && n-(m/a1)*(a1+1)>=0 && n-(m/a1)*(a1+1)<=a1+1 && (a1+1)>=2 && (a1+1)>n/(a1+1)) Min(ans,a1+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,x;
    int a[110];
    cin>>N>>x;
    for(int i=0;i<N;i++)cin>>a[i];
    sort(a,a+N);
    int res=0;
    while(x>=a[res]&&res<N-1){
        x-=a[res];
        res++;
    }
    if(x==a[N-1])cout<<res+1<<endl;
    else cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		String s=in.next();
		int n=s.length();
		int flag=0;
		for(int i=1;i<=n;i++)
		{
			if(i%2==0&&s.charAt(i-1)=='R')
				flag=1;
			if(i%2==1&&s.charAt(i-1)=='L')
				flag=1;
		}
		if(flag==0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}
	

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/dp/tasks/dp_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<vector<ll>> abc(N,vector<ll>(3));
    for(int i = 0; i < N;i++) for(int j = 0; j < 3;j++) cin >> abc[i][j];
    
    vector<vector<ll>> dp(2,vector<ll>(3,0));
    int cur = 0,next = 1;
    for(int i = 0; i < 3;i++) dp[cur][i] = abc[0][i];
    for(int i = 1; i < N;i++){
        for(int j = 0; j < 3;j++){
            for(int k = 0; k < 3;k++){
                if(j==k) continue;
                dp[next][k] = max(dp[next][k],dp[cur][j]+abc[i][k]);
            }
            dp[cur][j] = 0;
        }
        swap(cur,next);
    }
    res = *max_element(dp[cur].begin(), dp[cur].end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  
  /*for (int64_t i = 0; i < K; i++) {
    if (A >= 1) {
      A--;
      continue;
    }
    if (B >= 1) {
      B--;
      continue;
    }
  }*/
  
  if (K >= (A + B)) {
    cout << 0 << ' ' << 0 << endl;
    return 0;
  }
  
  if (K > A) {
    B -= (K - A);
    A = 0;
  } else {
    A = (A - K);
  }
  
  cout << A << ' ' << B << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define loop(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;


int main(void){
 int a, p;
 cin>>a>>p;

 p += a * 3;
 cout<< p / 2 << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;
long long n,x,m;
long long a[200005];
map<long long,int>ma;
int l,r;
long long sum,asum;
int main(){
	scanf("%lld%lld%lld",&n,&x,&m);
	a[1]=x;
	for(int i=2;;++i){
		a[i]=a[i-1]*a[i-1]%m;
		if(ma.count(a[i])){
			l=ma[a[i]];
			r=i;
			break;
		}
		ma[a[i]]=i;
	}
	if(n<l){
		for(int i=1;i<=n;++i)sum+=a[i];
		printf("%lld\n",sum);
		return 0;
	}
	for(int i=1;i<l;++i){
		sum+=a[i];
	}
	n-=l;
	++n;
	for(int i=l;i<r;++i)asum+=a[i];
	sum+=asum*(n/(r-l));
	n%=r-l;
	for(int i=l;i<l+n;++i)sum+=a[i];
	printf("%lld\n",sum);
	return 0;
}


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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#define debug(x) cerr << #x << ": <" << (x) << ">\n"
#else
#define debug(x)
#endif
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp(x, y)  make_pair(x, y);
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second
#define mod       1000000007
#define pi        acos(-1.0)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
  ioThings();

  cout << setprecision(12) << fixed;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double radH = (h * 60 + m) / 720.0 * 2 * pi;
  double radM = m / 60.0 * 2 * pi;

  cout << sqrt(a * a + b * b - 2.0 * a * b * cos(radH - radM));
  

  return 0;
}


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

int main() {
    int n;cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }
    int count=0;
    for(int i=0;i<n-1;i++) {
        if (p.at(i) == i + 1 && p.at(i + 1) == i + 2) {
            swap(p.at(i), p.at(i + 1));
            count++;
        }
    }
    for(int i=0;i<n-1;i++) {
        if (p.at(i) == i + 1 || p.at(i + 1) == i + 2) {
            swap(p.at(i), p.at(i + 1));
            count++;
        }
    }
    cout<<count<<endl;

}

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

const string GRADE_A = "A";
const string GRADE_B = "B";
const string GRADE_C = "C";
const string GRADE_D = "D";
const string GRADE_F = "F";
void Main() {
	string grades[50];
	int m, f, r, cnt = 0;
	for (int i = 0; i < 50; i++) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) {
			cnt = i + 1;
			break;
		}
		if (m == -1 || f == -1) {
			grades[i] = GRADE_F;
			continue;
		}
		int mfValue = m + f;
		if (mfValue >= 80) {
			grades[i] = GRADE_A;
		}
		else if (mfValue >= 65) {
			grades[i] = GRADE_B;
		}
		else if (mfValue >= 50) {
			grades[i] = GRADE_C;
		}
		else if (mfValue >= 30) {
			if (r >= 50) {
				grades[i] = GRADE_C;
			}
			else {
				grades[i] = GRADE_D;
			}
		}
		else {
			grades[i] = GRADE_F;
		}
	}
	for (int i = 0; i < cnt; i++) {
		cout << grades[i];
		if (i != cnt - 1) {
		cout << endl;
		}
	}
}
int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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 (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0; 
    if (k%2!=0){
        ll x = n / k;
        ans = pow((double)x, 3.0);
    }
    else {
        ll x = n / k;
        ll y = n / (k/2) - x;
        ans = pow((double)x, 3.0) + pow((double)y, 3.0);
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  long long sum = 0;
  int mi = INT_MAX;
  for (int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    sum += b;
    if (b < a) mi = min(mi, b);
  }
  if (mi != INT_MAX) cout << sum - mi << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 384
# ABC155 B - Papers, Please

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

B=[]
for i in range(len(A)):
    if A[i]%2 ==0:
        B.append(A[i])

if all([B[j]%3==0 or B[j]%5==0  for j in range(len(B))]):
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 61932
#include <cstdio>
const int N=105;
char a[N],b[N];
int main (){
    int n;scanf ("%d",&n);
    scanf ("%s",a+1);
    scanf ("%s",b+1);
    for (int i=n;i>=1;i--){
        bool flag=true;
        for (int j=1;j<=i;j++)
            if (a[n-i+j]!=b[j]) flag=false;
        if (flag) {printf ("%d",n*2-i);return 0;}
    }
    printf ("%d",n*2);
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
    int i,j;
    while(1){
        int n;
        cin>>n;
        if(n==0) return 0;
        int A=0,B=0;
        for(i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            if(a==b){
                A+=a;
                B+=b;
            }
            else if(a>b){
                A+=a+b;
            }
            else B+=a+b;
        }
        cout<<A<<" "<<B<<endl;
    }

}


Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <inttypes.h>

int main(void){
	char s[100]={'\0'};
	int i;
	int len;
	int ans=0;

	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<(len+1)/2;i++){
		if(s[i]!=s[len-1-i]){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128