akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 26;
const int N = (int)1e5 + 5;
const int M = 123;

ll n, w;
ll a[111][2];
ll dp[N];
ll cp[N];

void solve() {
    cin >> n >> w;

    for(int i = 1; i < N; i++) {
        dp[i] = 0;
        cp[i] = -inf;
    }

    dp[0] = 1;
    cp[0] = 0;

    for(int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1];
        for(int x = w; x >= 0; x--) {
            if (dp[x]) {
                if (x + a[i][0] <= w) {
                    cp[x + a[i][0]] = max(cp[x + a[i][0]], cp[x] + a[i][1]);
                    dp[x + a[i][0]] = 1;
                }
            }
        }
    }

    ll ans = -1;
    for(int i = w; i >= 0; i--)
        ans = max(ans, cp[i]);

    cout << ans << endl;
}

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


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

int main(){
  ll n,k;
  cin >> n >> k;
  
  vector<ll> v(n);
  for(ll i=0; i<n; i++) cin >> v[i];
  
  vector<ll> ans(n);
  ans[0] = 0;
  
  for(ll i=1; i<n; i++){
    ans[i] = ans[i-1] + abs(v[i]-v[i-1]);
    for(ll j = 1; j<=k && i-j >= 0; j++){
      ans[i] = min(ans[i], ans[i-j] + abs(v[i]-v[i-j]));
    }
  }
  
  cout << ans[n-1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    ll cnt = 0;
    if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
        cnt++;  
        if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {cout << cnt + 2 << "\n"; return;}
        if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) cout << cnt + 1 << "\n";
        else cout << cnt << "\n";
    }
    else cout << cnt << "\n";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

typedef struct {
    int x, y;
} POINT;

int x, y;
char map[2][1024][1024];
char visit[1024][1024];
int head, tail;
POINT p[1024], queue[100000];

void enq(POINT t)
{
    queue[(tail++) % 100000] = t;
}

POINT deq(void)
{
    return (queue[(head++) % 100000]);
}

int bfs(void)
{
    POINT add, temp;
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    int i;
    
    memset(visit, 0, sizeof(visit));
    head = tail = 0;
    add.x = add.y = 0;
    visit[0][0] = 1;
    enq(add);
    
    while (head != tail){
        temp = deq();
        
        if (map[1][temp.y][temp.x] == 't'){
            return (1);
        }
        
        for (i = 0; i < 4; i++){
            add.x = temp.x + dx[i];
            add.y = temp.y + dy[i];
            
            if (0 <= add.x && add.x < x && 0 <= add.y && add.y < y && !visit[add.y][add.x] && map[1][add.y][add.x] != '#'){
                visit[add.y][add.x] = 1;
                enq(add);
            }
        }
    }
    
    return (0);
}

int main(void)
{
    int i, j;
    int left, right, center;
    int n;
    
    scanf("%d%d", &x, &y);
    
    for (i = 0; i < y; i++){
        scanf("%s", map[0][i]);
        strcpy(map[1][i], map[0][i]);
    }
    
    p[0].x = p[0].y = 0;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; i++){
        scanf("%d%d", &p[i].x, &p[i].y);
    }
    
    left = 0;
    right = n;
    center = 0;
    
    while (left != right){
        if (center > (left + right) / 2){
            for (i = center; i > (left + right) / 2; i--){
                if (map[0][p[i].y][p[i].x] == '#'){
                    map[1][p[i].y][p[i].x] = '#';
                }
            }
        }
        else {
            for (i = center; i <= (left + right) / 2; i++){
                map[1][p[i].y][p[i].x] = '.';
            }
        }
        center = (left + right) / 2;
        if (bfs()){
            right = center;
        }
        else {
            left = center + 1;
        }
    }
    
    if (center > (left + right) / 2){
        for (i = center; i > (left + right) / 2; i--){
            if (map[0][p[i].y][p[i].x] == '#'){
                map[1][p[i].y][p[i].x] = '#';
            }
        }
    }
    else {
        for (i = center; i <= (left + right) / 2; i++){
            map[1][p[i].y][p[i].x] = '.';
        }
    }
    
    if (bfs()){
        printf("%d\n", left);
    }
    else {
        printf("-1\n");
    }
    
    return (0);
}

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

int main(){
    int N;
    cin >> N;
    int res = 0;
    int temp = 10;
    while(1){
        if(temp <= N){
            res += temp/10*9;
        }
        else{
            int temp_div_ten = temp/10;
            if(N >= temp_div_ten){
                res += N-temp_div_ten+1;
            }
            break;
        }
        temp *= 100;
    }
    cout << res << endl;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	int n, i, j, k;
	vi p;

	cin >> n;
	SIZE(p, n);
	rep(i, n) {
		cin >> p[i];
	}
	j = 0;
	rep(i, n - 2) {
		if (p[i] <= p[i + 1] && p[i + 1] <= p[i + 2] || p[i + 2] <= p[i + 1] && p[i + 1] <= p[i]) {
			j++;
		}
	}

	cout << j;

	return 0;
}


Measured memory_bytes: 256
inputstr = input().strip()
inputarray= inputstr.split(" ")
n = int(inputarray[0])
a = int(inputarray[1])
b = int(inputarray[2])
d1 = min(a,b)
if a+b > n:
  d2 = abs(a+b-n)
else:
  d2 = 0
print (str(max(d1,d2)) + " " + str(min(d1,d2)))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 == m2)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}


Measured memory_bytes: 256
/**
     *    author:  shashank_hire
    **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// typedef tree<
//     int,
//     null_type,
//     less_equal<int>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
//     ordered_set;
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

ll f(ll i, ll j)
{
    cout<<i<<" "<<j<<"\n";
    return 0;
}

int main()
{
    IOS;
    ll n, W, i, j;
    cin>>n>>W;
    vector<ll> v(n), w(n);
    vector<vector<ll>> dp(n, vector<ll>(W+1, 0));

    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
    for(j=1;j<=W;j++)
            dp[0][j] = (j>=w[0])*v[0];
    for(i=1;i<n;i++)
        for(j=1;j<=W;j++)
            if(j>=w[i])
                dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
            else
                dp[i][j] = dp[i-1][j];
    // for(i=0;i<n;i++)
    //     for(j=0;j<=W;j++)
    //         cout<<dp[i][j]<<" \n"[j==W];
    cout<<dp[n-1][W]<<"\n";
}

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


using namespace std;

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

string S;
void solve() {
	cin >> S;
	yes(S[2] == S[3] && S[4] == S[5]);
}



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



Measured memory_bytes: 256
#if 0
#include <stdio.h>
//复杂度为n^2的算法
int main()
{
    int n;
    int A[2000010];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    int max=A[1]-A[0];
    for(int i=0;i<n;i++)
    {
        int j=i+1;
        for(;j<n;j++)
        {
           if(A[j]-A[i]>max)max=A[j]-A[i];
        }
    }
    printf("%d\n",max);
    return 0;
}
#elif 0
#include<stdio.h>
int main()
{
    int i,n,a[200010],ans,min;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    min=a[0];
    ans=a[1]-a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]<min) min=a[i];
        else if(a[i]-min>ans) ans=a[i]-min;
    }
    printf("%d\n",ans);
    return 0;
}

#elif 0
#include<stdio.h>
int main()
{
    int n,min,max,m,m2;
    scanf("%d%d%d",&n,&m,&m2);
    min=m;
    max=m2-min;
    for(int i=2;i<n;i++)
    {
        scanf("%d",&m);
        if(m-min>max)max=m-min;
        if(m<min)min=m;
        printf("min=%d max=%d\n",min,max);
    }
    printf("%d\n",max);
   return 0;
}
#elif 1

#include <stdio.h>
int main()
{
    int A[200010],n,min,max;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    min=A[0];
    max=A[1]-min;
    for(int i=1;i<n;i++)
    {
        if(A[i]-min>max)max=A[i]-min;
        if(A[i]<min)min=A[i];
    }
    printf("%d\n",max);
    return 0;
}

#endif
/*
20
100
99
95
86
85
76
75
71
70
61
52
48
47
43
42
38
37
33
32
28
*/


Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	// cout<<INT_MAX;
	fast
	ll n,x,y;
	cin>>n>>x>>y;
	map<ll,ll> mp;
	ll i,j;
	for(i=1;i<n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			ll d1=j-i;
			ll d2=abs(i-x)+1+abs(y-j);
			ll d3=abs(i-y)+1+abs(x-j);
			d1=min({d1,d2,d3});
			// cout<<d1<<" ";
			mp[d1]++;
		}
	}
	// cout<<"\n";
	for(i=1;i<=n-1;i++)
		cout<<mp[i]<<"\n";
}

Measured memory_bytes: 384
ABC = list(map(int,input().split()))

ABC_sort = sorted(ABC,reverse=True)
AB = ABC_sort[0] - ABC_sort[1]
BC = ABC_sort[1] - ABC_sort[2]
time = 0
if BC % 2 == 0:
    time += BC // 2
    time += AB
else:
    AB += 1
    BC += 1
    time += BC // 2
    time += AB
print(time)

Measured memory_bytes: 9192
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    int cnt = 0;
    for (auto x: A) {
        if (((double)sum / (double)(4 * M)) <= x) {
            cnt++;
        }
    }

    if (cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
const long long inf = 1LL << 60;
int main() {
    long long N, K; cin >> N >> K;
    vector<long long> h(N, 0), dp(N, inf);
    for (int i = 0; i < N; i++) cin >> h[i];
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j == N) break;
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 4852
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let mut cities = vec![];
    for i in 0..n {
        let x: u64 = iter.next().unwrap().parse::<u64>().unwrap();
        let y: u64 = iter.next().unwrap().parse::<u64>().unwrap();
        cities.push((y,x,i));
    }

    let mut edges = vec![];
    // sort by y
    cities.sort_by_key(|c| c.0);
    for i in 0..n-1 {
        let cur = cities[i];
        let next = cities[i+1];
        edges.push((next.0 - cur.0, cur.2, next.2));
    }
    cities.sort_by_key(|c| c.1);
    for i in 0..n-1 {
        let cur = cities[i];
        let next = cities[i+1];
        edges.push((next.1 - cur.1, cur.2, next.2));
    }

    println!("{}", kruskal(&mut edges, n));
}

pub fn kruskal(edges: &mut [(u64, usize, usize)], n: usize) -> u64 {
    edges.sort();
    let mut utree = Utree::new(n);
    let mut ret = 0u64;
    for &(c, p, q) in &*edges {
        if !utree.is_same(p, q) {
            utree.unite(p, q);
            ret += c;
        }
    }
    ret
}

#[allow(dead_code)]
pub struct Utree {
    n: usize,
    par: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}
#[allow(dead_code)]
impl Utree {
    pub fn new(n: usize) -> Utree {
        let par: Vec<usize> = (0..n).collect();
        let rank: Vec<usize> = vec![0; n];
        let size: Vec<usize> = vec![1; n];
        Utree {
            n: n,
            par: par,
            rank: rank,
            size: size,
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let parent = { self.par[x] };
            let ret = self.find(parent);
            self.par[x] = ret;
            ret
        }
    }
    pub fn unite(&mut self, x: usize, y: usize) {
        let x_root = self.find(x);
        let y_root = self.find(y);
        if x_root == y_root {
            return;
        };
        if self.rank[x_root] < self.rank[y_root] {
            self.par[x_root] = y_root;
            self.size[y_root] += self.size[x_root];
        } else {
            self.par[y_root] = x_root;
            self.size[x_root] += self.size[y_root];
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[x_root] += 1;
            }
        }
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        let x_root = self.find(x);
        let y_root = self.find(y);
        x_root == y_root
    }
    pub fn get_size(&mut self, x: usize) -> usize {
        let x_root = self.find(x);
        self.size[x_root]
    }
}

Measured memory_bytes: 20328
using System;
//using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      var list = new List<int[]>();

      while (true)
      {
        var s = Console.ReadLine();
        if (s == "-1 -1 -1") break;
        list.Add(s.Split().Select(int.Parse).ToArray());
      }

      for (int i = 0; i < list.Count; i++)
      {
        string s;
        if (list[i][0] == -1 || list[i][1] == -1) s = "F";
        else if (list[i][0] + list[i][1] >= 80) s = "A";
        else if (list[i][0] + list[i][1] >= 65) s = "B";
        else if (list[i][0] + list[i][1] >= 50) s = "C";
        else if (list[i][0] + list[i][1] >= 30)
        {
          if (list[i][2] >= 50) s = "C";
          else s = "D";
        }
        else s = "F";
        Console.WriteLine(s);
      }
    }
  }
}


Measured memory_bytes: 9552
# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double k,a,b;
	if(n%2==0)
	{
		a=1;
		b=2;
		k=a/b;
		cout<<fixed<<setprecision(6)<<k;
	}
	else
	{
		a=n/2+1;
		b=n;
		k=a/b;
		cout<<fixed<<setprecision(6)<<k;
	}
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio> //char
//#include <cstdlib> //atoi

using namespace std;
int main(){
  int i,j,n,q;
  string na;
  queue <string> name;
  int ti;
  queue <int> time;

  cin >> n >> q;

  for(i=0;i<n;i++){
    cin >> na;
    name.push(na);

    cin >> ti;
    time.push(ti);
  }

  int t=0;
  while(name.size()!=0){
    if(time.front()<=q){
      t+=time.front();
      std::cout << name.front() << " " << t << "\n";
      name.pop();
      time.pop();
    }
    else{
      t+=q;
      name.push(name.front());
      name.pop();
      time.push(time.front()-q);
      time.pop();
    }
  }


  return 0;
}


Measured memory_bytes: 6056
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int search(int step, int prev, int total, int n){
	if(step==4){
		int tmp = sqrt(n-total);
		if(tmp >= prev && tmp*tmp == n-total) return 1;
		else return 0;
	}
	
	int count=0;
	for(int i=prev; i*i+total<=n; i++){
		count += search(step+1, i, total+i*i, n);
	}
	return count;
}

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		cout << search(1, 0, 0, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();
  let mut ans = "No";
  if c <= a + b {
    ans = "Yes";
  }

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



Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define X first
#define Y second
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
const int maxn=1e5+10;
int a[maxn];
vector<ll>res;

//解法一：BFS

int main(){
	ll ans;
	int n;
	cin>>n;
	queue<ll>que;//BFS可以保证是升序的。。。
	for(int i=1;i<=9;i++){
		que.push(i);
	}
	while(n--){
		ans=que.front();
		que.pop();
		if(ans%10!=0)que.push(ans*10+ans%10-1);
		que.push(ans*10+ans%10);//这一步是一定要做的，这样也可以保证是从小到大的。。。
		if(ans%10!=9)que.push(ans*10+ans%10+1);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  vector<bool>cnt(8,false);
  int c = 0,ans = 0;
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    int a;
    cin >> a;
    if(a < 400) cnt[0] = true;
    else if(a < 800) cnt[1] = true;
    else if(a < 1200) cnt[2] = true;
    else if(a < 1600) cnt[3] = true;
    else if(a < 2000) cnt[4] = true;
    else if(a < 2400) cnt[5] = true;
    else if(a < 2800) cnt[6] = true;
    else if(a < 3200) cnt[7] = true;
    else c++;
  }
  for(int i = 0;i < 8;i++){
    if(cnt[i]) ans++;
  }
  if(ans == 0) cout << 1 << " ";
  else cout << ans << " ";
  cout << ans+c << endl;
}


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

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

    for(int i=0; i<100000000; i++)
    {
        //cout << (int)(i*0.08) << (int)(i*0.1) << endl;
        if((int)(i*0.08) == A && (int)(i*0.1) == B)
        {
            cout << i;
            return 0;
        }
    }

    cout << -1;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
from statistics import median
N = int(input())
A = list(map(lambda x:int(x),input().split(" ")))
npA = np.array(A)
B = npA-(1+np.arange(len(npA)))
opt_b = median(B)
print(int(np.sum(np.abs(B-opt_b))))

Measured memory_bytes: 35388
<?php
  fscanf(STDIN,"%d",$a);
  $array = explode(" ",fgets(STDIN));

  $max_num = (int)$array[0];
  $min_num = (int)$array[0];
  for($i=1;$i<$a;$i++)
  {
    if((int)$array[$i]<$min_num)
    {
      $min_num = (int)$array[$i];
    }
    if((int)$array[$i]>$max_num)
    {
      $max_num = (int)$array[$i];
    }
  }
  echo abs($max_num-$min_num);

Measured memory_bytes: 3576
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
int main()
{
    ll m,n;
    cin>>m>>n;
    cout<<(n+m)*(n+m-1)/2-n*m;
    return 0;
}
/*
10 6
8 3 7 8 2 9 3 8 2 4


20 20
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define repp(i,n) for(int i=1; i<n; i++)
#define int long long
using namespace std;
/*
int Max(int n, int m){
  vector<int> v1;
  vector<int> v2;
  repp(i,n){
    if(n%i == 0) v1.push_back(i);
    if(m%i == 0) v2.push_back(i);
  }
  int t=0;
  rep(i,v1.size()){
    rep(j,v2.size()){
      if(v1[i] == v2[j] && t < v2[j]) t = v2[j];
    }
  }
  return t;
}*/
int gcd(int a, int b)
{
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
signed main(){
  int n,m;
  while(cin >> n >> m){
    int a = gcd(n,m);
    int b = n/a*m;
    cout << a << " " << b << endl;
  }
  return 0;
}



Measured memory_bytes: 3040
import math
n,k=map(int, input().split())

if n < k:
    res = 0
else:
    res = n - k
for i in range(1, min(n, k) + 1):
    pow2 = math.ceil(math.log(k / i, 2))
    res += 0.5 ** pow2
print(res / n)

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

const ll mod = 1000000007;

string s;

int main(){
  cin>>s;
  ll cnt=0;
  rep(i,s.size())if(s[i]=='p')cnt++;
  cout<<s.size()/2-cnt<<endl;

}


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

const int maxn = 1e6+1000;
typedef long long LL;
struct Node
{
    int v;
    LL w;
    Node(int v = 0,LL w = 0):v(v),w(w) {}
};


vector<Node> G[maxn];


int R,C;
int n;


LL A[maxn];
bool vis[maxn];



const LL INF = 0x3f3f3f3f3f3f3f3f;

int seq[maxn];
int cur;

bool dfs(int u)
{
    seq[cur++] = u;
    for(int i = 0;i < G[u].size();++i)
    {
        int v = G[u][i].v;
        LL w = G[u][i].w;

        if(!vis[v])
        {
            vis[v] = 1;
            A[v] = w-A[u];
            if(!dfs(v)) return false;
        }
        else
        {
            if(A[v] + A[u] != w) return false;

        }
    }
    return true;

}


bool bfs(int s)
{
    int b = 0, e = 1;
    seq[0] = s;
    vis[s] = true;
    A[s] = 0;
    while (b < e) {
      for (int j = 0; j < (int) G[seq[b]].size(); j++) {
        int u = G[seq[b]][j].v;
        int w = G[seq[b]][j].w;
        if (vis[u]) {
          if (A[seq[b]] + A[u] != w) {
            return false;
            }
          continue;
        }
        seq[e] = u;
        A[u] = w - A[seq[b]];
        vis[u] = true;
        e++;
      }
      b++;
    }
    cur = e;

    return true;
}

bool judge()
{

    memset(vis,0,sizeof(vis));
    for(int i = 1;i <= R;++i)
        if(!vis[i])
        {
            vis[i] = 1;
            A[i] = 0;

            cur = 0;
            if(!dfs(i)) return false;

            LL Minr = INF;
            LL Minc = INF;

            for(int j = 0;j < cur;++j)
            {
                int t = seq[j];
                if(t <= R)
                    Minr = min(Minr,A[t]);
                else
                    Minc = min(Minc,A[t]);

            }
            if(Minr + Minc < 0) return false;

        }
    return true;
}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    scanf("%d",&n);
    for(int i = 1;i <= n;++i)
    {
        int a,b;
        LL w;
        scanf("%d %d %lld",&a,&b,&w);
        b += R;
        G[a].push_back(Node(b,w));
        G[b].push_back(Node(a,w));
    }
    if(judge())
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 36608
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int a, b, c; cin >> a >> b >> c;
    if(a + b < c) cout << "NA" << endl;
    else cout << max(0LL, c - a) << endl;   
    return 0;
}



Measured memory_bytes: 3088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(all(A)); reverse(all(A));
    priority_queue<pll> pq;
    ll ans = A[0];
    pq.emplace(A[1],A[0]);
    pq.emplace(A[1],A[0]);
    for (int i = 2; i < N; i++) {
        auto[x,y] = pq.top(); pq.pop();
        ans += x;
        pq.emplace(A[i],x);
        pq.emplace(A[i],y);
    }

    cout << ans << ln;
}


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

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

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

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

void solve(){
   int a,b,h,m;
   cin >> a >> b >> h >> m;
   ld ang = acos(-1)*abs(60*h - 11*m)/360.0;
   ld ans = sqrt(a*a + b*b - 2*a*b*cos(ang)) ;
   cout << fixed << setprecision(10) << ans;
}

int32_t main(){
   fast;
   int t = 1;
   // cin >> t;
   while(t--)  solve();   
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define rf freopen("in.txt", "r", stdin);
#define ld long double
#define all(v) v.begin(),v.end()
#define push_back push_back
#define ff first
#define ss second
#define ln length()
#define rep(i,a, n) for(int i=a;i<=n;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define s(n) scanf("%d",&n);
#define sl(n) scanf("%lld",&n);
#define sld(n) scanf("%lf", &n);

using namespace std;

vector <int> v;

int main() { //rf
    ll n, sum = 0, m;
    sl(n); sl(m);
    for (int i = 0; i < n; i++) {
        int x;
        s(x);
        v.push_back(x);
    }

    sort(all(v));
    reverse(all(v));
    for (int i = 0; i < m; i++) {
        sum += v[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
t=input()
if(t=='SUN'):
    print(7)
elif(t=='MON'):
    print(7-1)
elif(t=='TUE'):
    print(7-2)
elif(t=='WED'):
    print(7-3)
elif(t=='THU'):
    print(7-4)
elif(t=='FRI'):
    print(7-5)
elif(t=='SAT'):
    print(7-6)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

#define int long long

signed main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  vector<int> data;
  int cnt = 0; char n = S[0];
  for(int i = 0; i < S.size(); i++){
    if(S[i] == n) cnt++;
    else {
      if(n == '0') data.push_back(-cnt);
      else data.push_back(cnt);
      cnt = 1; n = S[i];
    }
  }
  if(n == '0') data.push_back(-cnt);
  else data.push_back(cnt);

  ll ans = 0, count = 0;
  int right = 0;
  for(int left = 0; left < data.size(); left++){
    while(right < data.size()){
      if(data[right] < 0) {
	if(K == 0) { break; }
	count += -(data[right]);
	K--;
      }else{
	count += data[right];
      }
      right++;
    }
    ans = max(ans, count);
    ////cerr << left << " " << right << " = " << count << endl;
    count -= abs(data[left]);
    if(data[left] < 0) K++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1528
#include<iostream>
using namespace std;
int main (void)
{
  long long int h,a;
  int n,i;
  cin>>h>>n;
  for(i=0;i<n;i++)
  {
    cin>>a;
 
    h=h-a;
   
    if(h<=0)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(K, S):
    if len(S) <= K:
        return S
    return S[:K] + '...'


def main():
    K = read_int()
    S = read_str()
    print(slv(K, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76792
N = int(input())
ABC = [list(map(int, input().split())) for i in range(N)]

DP = [[0] * 3 for i in range(N)]
DP[0][0], DP[0][1], DP[0][2] = ABC[0][0], ABC[0][1], ABC[0][2]

for i in range(1, N):
  for j in range(3):
    for k in range(3):
      if j != k:
        DP[i][j] = max(DP[i - 1][k] + ABC[i][j], DP[i][j])
        
ans = max(DP[-1])
print(ans)

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

int main()
{
	char s[10];
	scanf("%s",s);
	if(strcmp(s,"Sunny")==0)	printf("Cloudy");
	else if(strcmp(s,"Cloudy")==0)	printf("Rainy");
	else if(strcmp(s,"Rainy")==0)	printf("Sunny");
	return 0;
}


Measured memory_bytes: 128
from collections import Counter
n,k,q = map(int, input().split())
A = []
for i in range(q):
    A.append(int(input()))
l = [1 if k>q else 0 for _ in range(n)]
for num,count in Counter(A).items():
    if k-q+count > 0:
        l[num-1] = 1
    else:
        l[num-1] = 0
for x in l:
    if x:
        print('Yes')
    else:
        print('No')

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


using namespace std;


int main(){
  int a, b;
  cin >> a;
  cin.ignore();
  cin >> b;
  cin.ignore();
  vector<int> data = {1, 2, 3};

  for (int x : data){
    if((x != a) && (x != b)){
      cout << x << endl;
      return 0;
    }
  }
  return 0;
}
    
  
  


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}

typedef pair<int,int>   ii;

int P[N];

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

    int n;      cin >> n;
    string s;   cin >> s;

    P[0] = 1;   for(int i = 1 ; i <= n ; ++i)   P[i] = mul(P[i - 1],2);

    auto cal = [&](int L)   {
        int ans = 0;    string t(n,'0');

        for(int i = 0 ; i < L ; ++i)    {
            char nxt = '0';

            if (s[i] == '1')
                add(ans,P[L - i - 1]),
                nxt = '1';

            for(int j = i ; j < n ; j += L)
                t[j] = nxt,
                nxt ^= 1;
        }
        if (t <= s)
            add(ans,1);

        return  ans;
    };

    vector<int> dvs;
    vector<int> vec;

    for(int i = 1 ; i <= n ; i += 2)    if (n % i == 0)
        dvs.pb(n / i),
        vec.pb(cal(n / i));

    reverse(all(dvs));
    reverse(all(vec));

    for(int i = 1 ; i < sz(vec) ; ++i)
    for(int j = 0 ; j < i       ; ++j)
        if (dvs[i] % dvs[j] == 0)
            sub(vec[i],vec[j]);

    int ans = 0;

    for(int i = 0 ; i < sz(dvs) ; ++i)  {
        add(ans,mul(vec[i],dvs[i]));
        add(ans,mul(vec[i],dvs[i]));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1556
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n, k;
	scanf("%d%d", &n, &k);
	printf("%d\n", n % k >= 1);
	
	Please AC;
}


Measured memory_bytes: 256
#include<stdio.h>
int length(char s[])
{
  int i,len=0,count=0,max=0;
  
  while(s[len])
    len++;
  for(i=0;i<len-1;i++){
   if(s[i]=='0'&&s[i+1]=='0'){
        s[i+1]='1';
        count++;
       
   }
    if(s[i]=='1'&&s[i+1]=='1'){
         s[i+1]='0';
           count++;
     }
  }    
   return count;
   
} 
int main(void){
  char str[1000001];
  
  scanf("%s",str);
  printf("%d\n",length(str));
  
  return 0;
}

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

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		int[][] a = new int[n][m];
		int[][] edgeV = new int[n][m];
		int[][] edgeH = new int[n][m];

		for (int i = 0; i < n; ++i) {
			String s = sc.next();
			for (int j = 0; j < m; ++j) {
				a[i][j] = (int) (s.charAt(j) - '0');
				if (i > 0 && a[i][j] == 1 && a[i - 1][j] == 1) {
					edgeV[i][j] = 1;
				}
				if (j > 0 && a[i][j] == 1 && a[i][j - 1] == 1) {
					edgeH[i][j] = 1;
				}
			}
		}

		System.gc();
		// １：青
		// ０：白

		RectangleSum s1 = new RectangleSum(a, n, m);
		a = null;
		RectangleSum s2 = new RectangleSum(edgeH, n, m);
		edgeH = null;
		RectangleSum s3 = new RectangleSum(edgeV, n, m);
		edgeV = null;
		for (int i = 0; i < q; ++i) {
			int y1 = sc.nextInt() - 1;
			int x1 = sc.nextInt() - 1;
			int y2 = sc.nextInt();
			int x2 = sc.nextInt();
			int ans = 0;
			ans += s1.get(y1, y2, x1, x2);
			ans -= s2.get(y1, y2, x1 + 1, x2);
			ans -= s3.get(y1 + 1, y2, x1, x2);
			System.out.println(ans);
		}

	}

	class RectangleSum {
		int[][] sum;

		public RectangleSum(int[][] a, int h, int w) {
			sum = new int[h + 1][w + 1];
			for (int i = 1; i <= h; ++i) {
				for (int j = 1; j <= w; ++j) {
					sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i - 1][j - 1];
				}
			}
		}

		// [l,r)
		// [t,b)
		int get(int t, int b, int l, int r) {
			return sum[b][r] - sum[b][l] - sum[t][r] + sum[t][l];
		}

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 243172
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;

map<ll,ll>memo;
ll N;
int ct[4];
int dv[3]={2,3,5};
ll rec(ll n){
    if(n==0)return 0;
    if(n==1)return ct[3];
    if(memo.count(n))return memo[n];
    ll res=1e18;
    if(n<res/ct[3])res=n*ct[3];//if res=n*ct[3],overflow will happen.
    rep(i,3){
        if(n%dv[i]==0){
            res=min(res,rec(n/dv[i])+ct[i]);
        }
        else{
            ll a=(n/dv[i])*dv[i];
            ll b=a+dv[i];
            res=min(res,rec(a/dv[i])+ct[i]+(n-a)*ct[3]);
            res=min(res,rec(b/dv[i])+ct[i]+(b-n)*ct[3]);
        }
    }
    memo[n]=res;
    return res;
}



struct edge{int to,cost;};
int main(){
    int t;
    cin>>t;
    vector<ll>ans;
    rep(i,t){
        
        cin>>N>>ct[0]>>ct[1]>>ct[2]>>ct[3];
       
        ans.push_back(rec(N));
        memo.clear();
    }
    rep(i,t)cout<<ans[i]<<endl;
    return 0;
}

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

using namespace std;

int main(){
    string s; cin >> s;
    
    string ans;
    
    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] == '0')
            ans.push_back('0');
        
        else if(s[i] == '1')
            ans.push_back('1');
        
        else if(s[i] == 'B' && !ans.empty())
            ans.pop_back();
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
D = list(map(int,input().split()))
number_set = {0,1,2,3,4,5,6,7,8,9}
for i in D:
    number_set.remove(i)    

while True:
    N_str = str(N)
    list_N = list(N_str)
    list_N = [int(n) for n in list_N]
    N_set = set(list_N)

    if N_set <= number_set:
        print(N)
        break
    else:
        N+=1
    
         


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define in(a) cin >> a;
#define out(a) cout << a << endl;
#define inV(A) REP(i,A.size()) in(A[i]);
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-----------------------------------
int main(){
    init();
    ll n;
    
    vector<vector<ll>>A(3,vector<ll>(3,0));
    vector<vector<ll>>B(3,vector<ll>(3,0));
    REP(i,3){
        REP(j,3){
            cin >> A[i][j];
        }
    }
    in(n);
    vl V(n);
    REP(i,n){
        cin >> V[i];
    }
    REP(i,3){
        REP(j,3){
            REP(k,n){
                if(V[k]==A[i][j]) B[i][j]=1;
            }
        }
    }
    if(B[0][0]*B[0][1]*B[0][2]==1) cout << "Yes" << endl;
    else if(B[1][0]*B[1][1]*B[1][2]==1) cout << "Yes" << endl;
    else if(B[2][0]*B[2][1]*B[2][2]==1) cout << "Yes" << endl;
    else if(B[0][0]*B[1][0]*B[2][0]==1) cout << "Yes" << endl;
    else if(B[0][1]*B[1][1]*B[2][1]==1) cout << "Yes" << endl;
    else if(B[0][2]*B[1][2]*B[2][2]==1) cout << "Yes" << endl;
    else if(B[0][0]*B[1][1]*B[2][2]==1) cout << "Yes" << endl;
    else if(B[0][2]*B[1][1]*B[2][0]==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import math

a,b,h,m=map(int,input().split())

arg=abs(((h*30)+(m*0.5))-m*6)


if arg>180:
    arg=360-arg

rad=math.radians(arg)

dim=(a**2+b**2)-2*a*b*(math.cos(rad))

dim=dim**(1/2)

print(dim)

Measured memory_bytes: 9536
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        String s = scanner.next();
        String t = scanner.next();
        Matcher matcher = Pattern.compile("(.*)" + t.replaceAll(".", "[$0?]") + "(.*?)").matcher(s);
        System.out.println(matcher.matches() ? matcher.replaceFirst("$1" + t + "$2").replace('?', 'a') : "UNRESTORABLE");
    }
}

Measured memory_bytes: 23892