akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

void radix_sort(vector<int>::iterator b,vector<int>::iterator e) {
    vector<int> t(e - b);
    array<int, 256> c, s;
    for (int i = 0; i < 32; i += 8) {
        fill(c.begin(), c.end(), 0);
        for_each(b, e, [&](int j) {c[(j >> i) & 255]++;});
        s[0] = 0;
        partial_sum(c.begin(), c.end() - 1, s.begin() + 1);
        for_each(b, e, [&](int j) {t[s[(j >> i) & 255]++] = j;});
        copy(t.begin(), t.end(), b);
    }
}

int main() {
	for (int N, M; N = in(), M = in();) {
		vector<int> t(N), u;
		for (int &p: t)
			p = in();
		t.push_back(0);
		radix_sort(t.begin(), t.end());
		for (auto i = t.begin(); i != t.end(); i++)
			for (auto j = i; j != t.end(); j++)
				if (*i + *j <= M)
					u.push_back(*i + *j);
		radix_sort(u.begin(), u.end());
		int r = 0;
		for (auto i = u.begin(), e = u.end() - 1; i <= e; i++) {
			for (; *i + *e >= M; e--)
				;
			r = max(r, *i + *e);
		}
		outl(r);
	}
}


Measured memory_bytes: 6144
//バケット法による鏡餅の解法
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N,res;
    res = 0;
    vector<int> vec(110);
    cin >> N;
    for(int i = 0;i < N;i++) cin >> vec.at(i);

    vector<int> bucket(110); //バケツ
    for(int i = 0;i < N;i++){
        bucket.at(vec.at(i))++;//バケツに入れる
    }

    for(int i = 0;i <= 100;i++){
        if(bucket.at(i)) res++;
    }

    cout << res << endl;
}

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

#define MAX 30

int N, M;
int K[MAX];
int A[MAX][MAX];

int cnt[MAX];

int main() {
	cin >> N >> M;
	for( int i = 0; i < N; i++ ) {
		cin >> K[i];
		for( int j = 0; j < K[i]; j++ ) {
			cin >> A[i][j];
		}
	}
	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < K[i]; j++ ) {
			cnt[A[i][j] - 1]++;
			if( cnt[A[i][j] - 1] >= N ) {
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    char s[1200];
    int data[26] = {};

    while (cin.getline(s, 1200)) {
        for (int i = 0; i < strlen(s); i++) {
            char c = s[i];
            if ('A' <= c && c <= 'Z') {
                c += 'a' - 'A';
            }
            if (c < 'a' || c > 'z') { continue; }
            data[c-'a'] += 1;
        }
    }

    for (int i = 'a'; i <= 'z'; i++) {
        char c = i;
        cout << c << " : " << data[i-'a'] << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    deque<char> que(s.begin(), s.end());
    int q; cin >> q;
    bool rev = false;
    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 1) {
            rev = (rev ? false : true);
        } else {
            int f; char c; cin >> f >> c;
            if (f == 1) {
                if (rev) {
                    que.push_back(c);
                } else {
                    que.push_front(c);
                }
            } else {
                if (rev) {
                    que.push_front(c);
                } else {
                    que.push_back(c);
                }
            }
        }
    }
    if (rev) reverse(que.begin(), que.end());
    for (char c : que) cout << c;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<ll> vec;

void dfs(ll x, int a, int b, int c, int d){
    if(a > 0 && b > 0 && c > 0) vec.emplace_back(x);
    if(d > 9) return;
    dfs(x * 10 + 7, a + 1, b, c, d + 1);
    dfs(x * 10 + 5, a, b + 1, c, d + 1);
    dfs(x * 10 + 3, a, b, c + 1, d + 1);
}

int main(){
    dfs(0, 0, 0, 0, 0);
    sort(vec.begin(), vec.end());
    ll n;
    cin >> n;
    auto it = upper_bound(vec.begin(), vec.end(), n);
    cout << (it - vec.begin()) << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int n, k;
int a[maxn], b[maxn];
int main()
{
	scanf("%d%d", &k, &n);
	int ans = k;
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 2; i <= n; ++i) ans = min(ans, k - (a[i] - a[i - 1]));
	ans = min(ans, a[n] - a[1]);
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n),p2(n);
    for(int i=0;i<n;i++){
            cin >> p[i];
            p2[i] = p[i];
    }
    sort(p.begin(),p.end());
    int cnt=0;
    for(int i=0;i<n;i++){
        if(p[i]!=p2[i]) cnt++;
    }
    if(cnt==0||cnt==2)  cout << "YES";
    else    cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  
  int sum=0;
  cin>>n;
  int b[n];
  for(int i=0;i<n-1;i++)
  {
    cin>>b[i];
  }
  sum=b[0]+b[n-2];
  for(int i=1;i<=n-2;i++)
  {
    sum+=min(b[i-1],b[i]);
  }
  cout<<sum;
  return 0;
  
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sc(v) v.size()
#define eb push_back
#define pb pop_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define TC() int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define mk make_pair
#define fi first
#define se second
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

const int N = 1e5 + 5;
int ar[N], ans[N];
int main()
{
	int n;
	cin>>n;
	f(i,0,n) {
		cin>>ar[i];
	}
	ans[0] = 0;
	f(i,1,n) {
		ans[i] = ans[i - 1] + abs(ar[i] - ar[i - 1]);
		if (i > 1) {
			ans[i] = min(ans[i], ans[i - 2] + abs(ar[i] - ar[i - 2]));
		}
	} 
	cout<<ans[n - 1];
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(n):
    try:
        a = sorted(a, reverse = True)
        Alice += a[0]
        del(a[0])
        Bob += a[0]
        del(a[0])
    except:
        break
print(Alice - Bob)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        double s = (double)h*w/2.0;
        if(w==2*x && h==2*y){
            System.out.print(s+" "+1);
        }else{
            System.out.print(s+" "+0);
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i <= n / 7; i++){
        for(int j = 0; j <= n / 4; j++){
            if(7 * i + 4 * j == n){
                printf("Yes\n");

                return 0;
            }
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<vector<Pll>> B(N);
    ll x,y;
    rep(i,N){
        cin >> A[i];
        rep(j,A[i]){
            cin >> x >> y;
            x--;
            B[i].push_back(Pll(x,y));
        }
    }
    ll ans = 0;
    for(ll i=0;i<(1LL<<N);i++){
        bool flag = true;
        ll cnt = 0;
        rep(j,N){
            if((i>>j)&1LL){
                cnt++;
                rep(k,A[j]){
                    if(B[j][k].second == ll((i >> B[j][k].first)&1LL)){
                        continue;
                    }else{
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag){
            cmax(ans, cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
li = [0]*n
for i in range(n):
    li2 = list(map(int,input().split()))
    li2.pop(0)
    li[i] = set(li2)
for i in range(n-1):
    li[0] = li[0] & li[1]
    li.pop(1)
print(len(li[0]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
int A,B,K,i;std::set<int> S;
main(){std::cin>>A>>B>>K;for(i=0;i<K;i++)if(B-A>=i){S.insert(A+i),S.insert(B-i);}for(auto x:S)std::cout<<x<<'\n';}


Measured memory_bytes: 256
use proconio::marker::*;
use proconio::*;

fn main() {
    input! {
        l: usize,
        r: usize,
        d: usize,
    };

    let mut ans = 0;

    for i in l..=r {
        if i % d == 0 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


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

int n,k;
int a[100105];
int mem[100005];

int bac(int i)
{
	if (i==n-1)return 0;
	
	if (mem[i]!=-1)
	return mem[i];
	
	int ans=2e9;
	for (int h=1;h<=k;h++)
	{
		if (i+h<=n-1)ans=min(ans,abs(a[i]-a[i+h])+bac(i+h));
	}
	return mem[i]=ans;
}



int main()
{
	memset(mem,-1,sizeof mem);
    scanf("%d%d",&n,&k);
    for (int i=0;i<n;i++)
    scanf("%d",&a[i]);
    printf("%d\n",bac(0));
}

Measured memory_bytes: 5760
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const double EPS = 1e-8;
const double INF = 1e12;

// ½ÊãÌ_ExNg
typedef complex<double> P;
namespace std{
	bool operator< (const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

// OÏ
double cross(const P& a, const P& b){
	return imag(conj(a)*b);
}

// àÏ
double dot(const P& a, const P& b){
	return real(conj(a)*b);
}

// ¼ü
struct L : public vector<P> {
	L(const P &a, const P &b){
		push_back(a);
		push_back(b);
	}
};

// ½p`
typedef vector<P> G;

// ~
struct C{
	P p;
	double r;
	C(){}
	C(const P& p, double r) : p(p), r(r) {}
};

P projection(const L& l, const P& p){
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
bool intersectSP(const L& s, const P& p){
	return abs(s[0]-p) + abs(s[1]-p) - abs(s[1]-s[0]) < EPS;
}
double distanceSP(const L& s, const P& p){
	const P r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0]-p), abs(s[1]-p));
}

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vector<C> cs(n);
		rep(i, n){
			scanf("%lf%lf%lf", &cs[i].p.real(), &cs[i].p.imag(), &cs[i].r);
		}
		
		int m;
		scanf("%d", &m);
		rep(i, m){
			P a, b;
			scanf("%lf%lf%lf%lf", &a.real(), &a.imag(), &b.real(), &b.imag());
			L l(a, b);

			bool visible = true;
			rep(i, n){
				bool inner = abs(l[0]-cs[i].p)<cs[i].r && abs(l[1]-cs[i].p)<cs[i].r;
				if(!inner && distanceSP(l, cs[i].p) - cs[i].r < EPS){
					visible = false;
					break;
				}
			}
			puts(visible ? "Danger" : "Safe");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
#?????\???
#??????????????¨????§?????????¨?????¨?????????????????????????????????????????????????????????
def rrs(quantum, process):
    finished_process = []
    queue = Queue()
    current_time = 0
    i = 0
    while len(finished_process) < len(process):
        if i < len(process):
            p_info = process[i]
            i += 1
        else:
            p_info = queue.dequeue()
        time = int(p_info[1])
        name = p_info[0]
        
        if time <= quantum:
            current_time += time
            finished_process.append((name, current_time))
        else:
            current_time += quantum
            queue.enqueue((name, time - quantum))
            
    return finished_process


class Queue:
    def __init__(self):
        self.data = []

    def enqueue(self, d):
        self.data.append(d)

    def dequeue(self):
        r = self.data[0]
        self.data = self.data[1:]
        return r
    
def main():
    info = input().split()
    n_list = int(info[0])
    quantum = int(info[1])
    target_list = [tuple(input().split()) for i in range(n_list)]
    print("\n".join([p + " " + str(t) for p,t in rrs(quantum, target_list)]))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 22932
N, A, B, C = map(int, input().strip().split())

L = []
for i in range(N):
  L.append(int(input()))

INF = 10**9
  
def dfs(depth, a, b, c): # current length for A, B, C
  if depth == N:
    if min(a, b, c) > 0:
      return abs(A-a) + abs(B-b) + abs(C-c) - 30
      # -30 is for the first merger (it's unnecessary cost)
    else:
      return INF # a,b,c must be > 0
  else:
    # use L[depth] for A (with merger)
    case_a = dfs(depth+1, a+L[depth], b, c) + 10
    # use L[depth] for B (with merger)
    case_b = dfs(depth+1, a, b+L[depth], c) + 10
    # use L[depth] for C (with merger)
    case_c = dfs(depth+1, a, b, c+L[depth]) + 10
    # not using L[depth] 
    case_x = dfs(depth+1, a, b, c) 

    return min(case_a, case_b, case_c, case_x)
  
print(dfs(0,0,0,0)) 

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

int main() {
  int S,W;
  cin >> S >> W;
  
  if (S < W){
    cout << "unsafe" << endl;
  }
  else if (S == W) {
        cout << "unsafe" << endl;
  }
  else {
    cout << "safe" << endl;
  }
  
}

Measured memory_bytes: 3600
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let a = nexts(n);
    for (let i = 0; i < 30; i++) {
        for (let j = 0; j < n; j++) {
            if (a[j] % 2 == 0) {
                a[j] = a[j] / 2;
            } else {
                return i;
            }
        }
    }
}

Measured memory_bytes: 7372
using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var N = arr[0];
        var x = arr[1];
        Array.Sort(a);
        var answer = 0;
        for (int i = 0; i < N; i++){
            if (a[i] > x){
                x = 0;
                break;}
            answer++;
            x -= a[i];}
        if (x > 0 && answer > 0) answer--;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

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

int main() {
    char ch;
    int num;
    int counter[26];

    for (int i = 0; i < 26; i++) {
        counter[i] = 0;
    }

    while (cin >> ch){
        if (islower(ch)) {
            num = ch - 'a';
            counter[num]++;
        } else if (isupper(ch)) {
            num = ch - 'A';
            counter[num]++;
        }
    }

    for (int i = 0; i < 26; i++) {
        cout << char ('a' + i) << " : " << counter[i] << endl;
    }

    return 0;
}



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

int main() {
  int n;
  cin>>n;
  vector<tuple<string, int, int>> a;
  for(int i=1;i<=n;i++){
    string s;
    int t;
    cin>>s>>t;
    t*=-1;
    tuple<string, int, int> date;
    date=make_tuple(s,t,i);
    a.push_back(date);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<get<2>(a.at(i))<<endl;
  }
}

Measured memory_bytes: 256
//
// Created by tattsun on 2017/02/14.
//

#include <iostream>
#include <vector>
#include <stack>

using namespace std;

#define VERTEX_MAX 100001

typedef vector<int> Vertex;

int color = 0;
int n, m;
Vertex vs[VERTEX_MAX];
int cs[VERTEX_MAX];

void _dfs(int color, int i) {
    cs[i] = color;

    auto& v = vs[i];
    for(auto it = v.begin(); it != v.end(); it++) {
        if(cs[*it] != -1)
            continue;

        _dfs(color, *it);
    }
}

void dfs() {
    for(int i=0; i<n; i++) {
        if(cs[i] != -1)
            continue;

        _dfs(color, i);
        color++;
    }
}

int main() {
    for(int i=0; i<VERTEX_MAX; i++)
        cs[i] = -1;

    cin >> n >> m;

    int a, b;
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        vs[a].push_back(b);
        vs[b].push_back(a);
    }

    dfs();

    int q;
    cin >> q;
    for(int i=0; i<q; i++) {
        cin >> a >> b;
        if(cs[a] == cs[b] && cs[a] != -1)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}

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

using namespace std;
using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;

    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }

    int output = 1;
    int socket = A;
    while (1) {
        if (socket >= B) break;
        socket--;
        socket += A;
        output++;
    }

    cout << output << endl;

    return 0;
}


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

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


Measured memory_bytes: 3084
import numpy as np

H,W = input().split()
H,W=int(H),int(W)
P=[0]*H
for i in range(H):
    P[i] = input()

dp=np.zeros((H,W),dtype='u8')
if P[0][0]=='#':
    dp[0][0]=1
else:
    dp[0][0]=0

def DP(y,x):
    global dp
    if 0<=x<=W-1 and 0<=y<=H-1:
        return dp[y][x]
    else:
        return 9999999

for l in range(1,H+W):
    for i in range(l+1):
        if i<H and l-i<W:
            if P[i][l-i]=='#':
                a=DP(i-1,l-i)
                b=DP(i,l-i-1)
                if a < 9999999:
                    if P[i-1][l-i]=='.':
                        a+=1
                if b <  9999999:
                    if P[i][l-i-1]=='.':
                        b+=1
                dp[i][l-i]=min(a,b)
            else:
                #print(i,l-i,DP(i-1,l-i),DP(i,l-i-1))
                dp[i][l-i]=min(DP(i-1,l-i),DP(i,l-i-1))
print(dp[H-1][W-1])

Measured memory_bytes: 13444
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{	
	TLong n,m;
	scanf("%lld%lld",&n,&m);
	if(n == 1){
		if(m == 1)	puts("1");
		else printf("%lld\n", m - 2);
	}
  	else if(m == 1)  printf("%lld\n", n - 2);
	else	printf("%lld\n", (n - 2) * (m - 2));
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 17 16:53:19 2016

@author: Yasuhiro_2
"""

def checkSorted(A):
    check = True
    a = A[0]
    for e in A:
        if a > e:
            check = False
            break
        else:
            a = e
    return check
        

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return [cnt, A]

"""
def shellSort(A, n):
    cnt = 0
    m = 0
    G = []          
    while checkSorted(A) == False:
        g = 1
        for i in range(n):
            j = i
            tmp = g
            while j < n:
                if A[i] > A[j]:
                    g = j - i
                j += tmp
        G.append(g)
        m += 1
        A = insertionSort(A, n, g, cnt)
        cnt = A[0]
        A = A[1]
    if m == 0:
        m = 1
        G = [1]
    return [m, G, cnt, A]
"""
def shellSort(A, n):
    cnt = 0
    m = 1
    G = [1]
    while G[-1] < n:
        G.append(3*G[-1] + 1)
        m += 1
    if m > 1:
        G = G[:-1]
        G.reverse()
        m -= 1
    
    for g in G:
        A = insertionSort(A, n, g, cnt)
        cnt = A[0]
        A = A[1]

    return [m, G, cnt, A]

            

if __name__ == '__main__':   
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))
    results = shellSort(A, n)
    m = results[0]
    G = results[1]
    cnt = results[2]
    Ar = results[3]
    print(m)
    gs = ''
    for g in G:
        gs = gs + str(g) + ' '
    print(gs[:-1])
    print(cnt)
    for a in Ar:
        print(a)


Measured memory_bytes: 45524
#include<bits/stdc++.h>
using namespace std;
#define forN(n, N) for(int n=0; n<N; n++)
#define res_out(ans) cout << ans << "\n";
#define ll long long

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ts[5];
    forN(n,5)cin >> ts[n];
    int l_i = 0;
    for(int n=1;n<5; n++){
        if(ts[n] % 10 != 0 && ts[n] % 10 < ts[l_i] % 10){
            l_i = n;
        }
    }
    int ans = 0;
    forN(n,5){
        if(n == l_i)ans += ts[n];
        else if(ts[n] % 10 == 0)ans += ts[n];
        else{
            ans += (ts[n] / 10 + 1) * 10;
        }
    }
    res_out(ans)
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n,k; cin >> n >> k;
  
  cout << n - k +1 << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

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...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, m; cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      		Scanner scan = new Scanner(System.in);
            
            int a = scan.nextInt();
            int b = scan.nextInt();
        	int c = scan.nextInt();
            
            if( a+b+c == 17)System.out.println("YES");
        	else System.out.println("NO");
	  }
}

Measured memory_bytes: 21204
#include<iostream>
using namespace std;
#define rep(i,re,ra) for((i)=(re);(i)<(ra);(i)++)
#define INF 10e16
long long N,a,mini=INF;
int i;
int main(void){
	scanf("%lld",&N);
	rep(i,0,5){
		scanf("%lld",&a);
		mini=min(mini,a);
	}
	printf("%lld",5+(N+mini-1)/mini-1);
}

Measured memory_bytes: 256
MOD=10**9+7

MF=[1,1]
for i in range(2,10**5+10):
  MF.append((MF[-1]*i)%MOD)

N,M=map(int,input().split())
ans=0
if N==M:
  ans=MF[N]*MF[M]*2
elif abs(N-M)==1:
  ans=MF[N]*MF[M]
print(ans%MOD)

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

int main(){
	lint n,sumax=0;
	cin>>n;
	vector<vector<lint>> h(3,vector<lint>(n)),dp(3,vector<lint>(n));
	//3行2列の配列を宣言
	vector<vector<int>>d={{1,2},{-1,1},{-2,-1},};
	//A,B,Cそれぞれを0,1,2としたときの自身以外の要素へのアクセスを単純化するための配列
	rep(i,n)rep(j,3)cin>>h.at(j).at(i);
	//幸福度を配列に入力
	rep(i,n)rep(j,3)dp.at(j).at(i)=0;
	//最大値問題なのでdp配列を0で初期化
	rep(i,n){
		rep(j,3){
			if(i){
			//iが0でなければ,前日に今日と異なる活動をしたときの幸福度の最大値を調べる
				lint ret1 = dp.at(j+d.at(j).at(0)).at(i-1);
				lint ret2 = dp.at(j+d.at(j).at(1)).at(i-1);
				dp.at(j).at(i)=h.at(j).at(i)+max(ret1,ret2);
				//今日の活動の幸福度と先の最大値を足したものが今日この活動を行ったときの幸福度の最大値(=dp.at(j).at(i))
			}else{
			//iが0のとき,今の活動をしたときの幸福度はh.at(j).at(i)の1通りしかないので,それを代入
				dp.at(j).at(i)=h.at(j).at(i);
			}
		}
	}
	rep(i,3) if(sumax<dp.at(i).at(n-1)) sumax=dp.at(i).at(n-1);
	//出てきた三通りの答えdp.at(0~3)(n-1)のうち最大のものを求めて出力
	cout<<sumax<<endl;
}


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

int main() {
    int c;
    cin >> c;
    int *a = new int[c];
    for (int cc = 0; cc < c; cc++) {
        cin >> a[cc];
    }

    string str;
    for (int cc = c - 1; cc >= 0; cc--) {
        str += to_string(a[cc]) + " ";
    }
    str.erase(str.length() - 1);
    cout << str << endl;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll a,b,m;
ll c[100010],d[100010];
int main() {
    cin >> a >> b >> m;
    for (int i = 0; i < a; i++) cin >> c[i];
    for (int i = 0; i < b; i++) cin >> d[i];
    ll ans = 1e18;
    for (int i = 0; i < m; i++) {
        ll x,y,k;
        cin >> x >> y >> k;
        x--;
        y--;
        ans = min(ans, c[x] + d[y] - k);
    }
    sort(c,c+a);
    sort(d,d+b);
    ans = min(ans, c[0] + d[0]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int C(int a, int b) {
	if (a < 2)return 0;
	int t = min(b, a - b), ans = 1, tmp = t;
	while (t--) {
		ans *= a--;
		if (ans % tmp == 0)ans /= tmp--;
	}
	while (tmp)ans /= tmp--;
	return ans;
}
int main() {
	IOS;
	int n, k; cin >> n >> k;
	int m = C(n - 1, 2);
	if (k > m)cout << "-1\n";
	else {
		int c = m - k, ans = n - 1 + c;
		cout << ans << endl;
		repi(2, n + 1)cout << "1 " << i << "\n";
		for (int i = 2; i < n && c; i++) {
			for (int j = i + 1; j < n + 1 && c; j++) {
				cout << i << " " << j << "\n";
				c--;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
def examA():
    N, A, B = LI()
    if (A-B)%2==0:
        ans = "Alice"
    else:
        ans = "Borys"
    print(ans)
    return

def examB():
    K = I()
    A = LI()
    cur = 2
    for i in range(K-1,-1,-1):
        a = A[i]
        if A[i]>cur:
            print(-1)
            exit()
        cur = (cur//a+1)*a-1
#        print(cur)
    maxA = cur; cur = 2
    for i in range(K-1,-1,-1):
        a = A[i]
        if cur<=a:
            cur = a
        else:
            cur = a*((cur-1)//a+1)
    minA = cur
    if minA>maxA:
        print(-1)
        exit()
    print(minA,maxA)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


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

typedef long long int ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;

int main(){
 int N;
 string S;
 cin >> N >> S;
 if(N%2 == 1){
    cout << "No" << endl;
    return 0;
 }
 if(S.substr(0,N/2) == S.substr(N/2,N/2)){
    cout << "Yes" << endl;
 }else{
    cout << "No" << endl;
 }

}

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

int main() {
  ll a[3];
  for (int i=0; i<3; i++) {
    cin>>a[i];
    if (a[i]%2==0) {
      cout<<0<<endl;
      return 0;
    }
  }
  sort(a,a+3);
  cout<<a[0]*a[1]<<endl;   
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
/*----------------------------------------------------------------------*/

const int N = 105, K = 1e5+5;
ll dp[N][K],arr[N],cum[N][K];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    memset(dp, 0, sizeof(dp));
    memset(cum, 0, sizeof(cum));
    int n,k;
    cin>>n>>k;

    F(i, 0, n) {
    	cin>>arr[i];
    }

    F(j, 0, k+1) {
        if(j <= arr[0]) {
            dp[1][j]=1;
            cum[1][j]=1;
        }

        if(j) cum[1][j] += cum[1][j-1];
        cum[1][j] %= MOD;
    }

    F(i, 2, n+1) {
    	F(j, 0, k+1) {
    		dp[i][j] = cum[i-1][j];
            if(j - arr[i-1] > 0) {
                dp[i][j] -= cum[i-1][j-arr[i-1]-1];
                dp[i][j] += MOD;
                dp[i][j] %= MOD;
            }
            cum[i][j] = dp[i][j];
            if(j) cum[i][j] += cum[i][j-1];
            cum[i][j] %= MOD;
    	}
    }
    cout<<dp[n][k];

    return 0;
}/*

*/


Measured memory_bytes: 164352
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+5;
 
int main() {
	int n, m, k;
	int a, b, c, d, e, f;
	string s, t, r;
	char c1, c2, c3;
	cin >> a >> b >> c;
	if (a == b and b != c) cout <<"Yes"<<endl;
  	else if (a != b and b == c) cout <<"Yes"<<endl;
  	else if (a == c and b != c) cout <<"Yes"<<endl;
  	else cout <<"No"<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

string S;
int main(){
  cin >> S;
  if (S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1]){
    cout << "Yes" << endl;
    return 0;
  }
  if (S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
    cout << "Yes" << endl;
    return 0;
  }
  if (S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


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

int main(){
  long long n,i,j,t,cura=0,curc=0,ans;
  cin >> n;
  multiset<long long> a,c;
  vector<long long> b(n),ansa(n+1),ansc(n+1);
  for(i=0; i<n; i++){
    cin >> t;
    a.insert(t);
    cura+=t;
  }
  for(i=0; i<n; i++){
    cin >> b[i];
  }
  for(i=0; i<n; i++){
    cin >> t;
    c.insert(-1*t);
    curc-=t;
  }
  
  ansa[0]=cura;
  auto itr =a.begin();
  for(i=1; i<=n; i++){
    a.insert(b[i-1]);
    itr =a.begin();
    cura=cura-*itr+b[i-1];
    ansa[i]=cura;
    a.erase(itr);
  }
  
  ansc[n]=curc;
  for(i=n-1; i>=0; i--){
    c.insert(-1*b[i]);
    itr=c.begin();
    curc=curc-*itr-b[i];
    ansc[i]=curc;
    c.erase(itr);
  }
  ans=-100000000000000;
  for(i=0; i<n+1; i++){
    ans=max(ans,ansa[i]+ansc[i]);
  }
  cout << ans; 
  
}

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

int main() {
  int N;
  bool includeY = false;
  cin >> N;

  // ここにプログラムを追記
  for( int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if( S == "Y" ){
      includeY = true;
      break;
    }
  }

  if(includeY){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }

}


Measured memory_bytes: 256
# include<bits/stdc++.h>
 
using namespace std;
 
# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 
# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define UB upper_bound 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	char c = '0';
	int ans = 0;
	for (int i = 0; i < n; i ++)
	{
		char x;
		cin >> x;
		if (x != c)
		{
			c = x;
			ans ++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

ll dx[5]={-2,-1,0,1,2},dy[5]={-2,-1,0,1,2};

ll h,w,sx,sy,ex,ey;
vvll d;
vs g;

bool check(ll x,ll y)
{
	return (x>=0 && x<h && y>=0 && y<w);
}

void dfs()
{
	d[sx][sy]=0;
	deque<pll> q;
	q.pb({sx,sy});
	while(!q.empty())
	{
		ll x=q.front().F,y=q.front().S;
		q.pop_front();
		//if(d[x][y]!=INF){continue;}
		FOR(i,0,5)
		{
			FOR(j,0,5)
			{
				if(j==2&&i==2){continue;}
				if(check(x+dx[i],y+dy[j]) && g[x+dx[i]][y+dy[j]]=='.')
				{
					//cout<<"hello";newl;
					ll w;
					if((abs(dx[i])==0 && abs(dy[j])==1) || (abs(dx[i])==1 && abs(dy[j])==0))
					{
						w=0;
					}
					else{w=1;}
					
					if(d[x+dx[i]][y+dy[j]]>d[x][y]+w)
					{
						//cout<<"hello";newl;
						d[x+dx[i]][y+dy[j]]=d[x][y]+w;
						if(w==1)
						{
							q.pb({x+dx[i],y+dy[j]});
						}
						else
						{
							q.push_front({x+dx[i],y+dy[j]});
						}
					}
				}
			}
		}
	}
}

int main()
{
    io;
    cin>>h>>w>>sx>>sy>>ex>>ey;
    sx--;
    sy--;
    ex--;ey--;
    g.resize(h);
    d.resize(h,vll(w,INF));
    FOR(i,0,h)
    {
    	cin>>g[i];
    }
    
    dfs();
    
    if(d[ex][ey]>=INF){cout<<-1;}
    else{cout<<d[ex][ey];}
    newl;
    //cout2d(d)
    
    return 0;
}



Measured memory_bytes: 12692
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		char[] s = str.toCharArray(); 
		int cnt = 0;

		for(int i=0;i<str.length() / 2;i++){
			if(s[i] != s[str.length() - 1 - i] ){
				cnt++;
			}	
		}
		System.out.println(cnt);
		}
	}

Measured memory_bytes: 35688
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

#define REP(i,a,b) for(int i=(a); i<(b); ++(i))
#define rep(i,n) REP(i,0,n)

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  ll ans = 0;
  REP(b, 1, N + 1) {
    ll p = N / b, r = N % b;
    ans += p * max<ll>(0ll, b - K);
    ans += max<ll>(0ll, r - K + 1);
  }

  if (K == 0) ans -= N;

  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

struct Node {
    vector<int> to;
    vector<ll> to_cost;

    bool done;
    ll dist;
};

void calc_dist(int pos, vector<Node>& node) {
    node[pos].done = true;
    for (int i = 0; i < node[pos].to.size(); i++) {
        int next = node[pos].to[i];
        if (node[next].done == false) {
            node[next].dist = node[pos].dist + node[pos].to_cost[i];
            calc_dist(next, node);
        }
    }
}

int main() {
    int N;
    cin >> N;
    vector<Node> node(N);

    for (int i = 0; i < N - 1; i++) {
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        node[a].to.push_back(b);
        node[a].to_cost.push_back(c);
        node[b].to.push_back(a);
        node[b].to_cost.push_back(c);
    }

    int Q, K;
    cin >> Q >> K; K--;

    // 頂点 K からの最短距離
    node[K].dist = 0;
    calc_dist(K, node);

    vector<int> x(Q), y(Q);
    for (int i = 0; i < Q; i++) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    for (int i = 0; i < Q; i++) {
        cout << node[x[i]].dist + node[y[i]].dist << endl;
    }

    return 0;
}

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

def main():

    N, M = map(int, input().split())

    numN = N * (N - 1) / 2
    numM = M * (M - 1) / 2

    ans = 0

    if numN >= 0:
        ans += numN

    if numM >= 0:
        ans += numM

    print(int(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9084
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			System.out.println(A * B);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32612