akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; string S; cin >> N >> S;

    ll ans = INF;
    vel t(N+1,0);
    rep(i,N) {
        if(S[i] == '#') t[i+1] = t[i] + 1;
        else t[i + 1] = t[i];
    }

    rep(i,N+1) {
        ll b = t[i];
        ll w = (N  - i) - (t[N] - t[i]);
        ans = min(ans, b + w);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int r,g,b,n;cin>>r>>g>>b>>n;
    int count=0;
    for(int i=0;i*r<=n;i++){
        for(int j=0;j*g+i*r<=n;j++){
            if((n-j*g-i*r)%b==0)count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
class dice:
    def __init__(self,label):
        self.label = {i+1: l for i,l in enumerate(label)}
    def roll(self,op):
        l = self.label
        if   op=='N': self.label = {1:l[2], 2:l[6], 3:l[3], 4:l[4], 5:l[1], 6:l[5]}
        elif op=='E': self.label = {1:l[4], 2:l[2], 3:l[1], 4:l[6], 5:l[5], 6:l[3]}
        elif op=='W': self.label = {1:l[3], 2:l[2], 3:l[6], 4:l[1], 5:l[5], 6:l[4]}
        elif op=='S': self.label = {1:l[5], 2:l[1], 3:l[3], 4:l[4], 5:l[6], 6:l[2]}
    def yaw(self,op):
        l = self.label
        if   op=='CW' : self.label = {1:l[1], 2:l[3], 3:l[5], 4:l[2], 5:l[4], 6:l[6]}
        elif op=='CCW': self.label = {1:l[1], 2:l[4], 3:l[2], 4:l[5], 5:l[3], 6:l[6]}
    def get_label(self,i=0):
        if 1 <= i <= 6:
            return self.label[i]
        else:
            return [self.label[x] for x in range(1,7)] 

def cmp_dice(d0,d1):
    dc = dice(d0.get_label())
    d1_l = d1.get_label()
    result=False
    if set(dc.get_label())==set(d1_l):
        for i in range(6):
            for _ in range(4):
                if dc.get_label()==d1_l:
                    result=True
                    break
                dc.yaw('CW')
            if dc.get_label()==d1_l:
                break
            if i < 4:
                dc.roll('E')
            if i >= 3:
                dc.roll('N')
            if i >= 4:
                dc.roll('N')
    return result

if __name__ == '__main__':
    import itertools
    n=int(input())
    d_list = [dice(list(map(int, input().split()))) for _ in range(n)]
    result='Yes'
    for dx, dy in itertools.combinations(d_list,2):
        if cmp_dice(dx,dy):
            result='No'
            break
    print(result)

Measured memory_bytes: 7944
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int a, b, c, d;
	cin >> a >> b;
	if(a == b){
		cout << "Draw" << endl;
	}else if(a == 1){
		cout << "Alice" << endl;
	}else if(b == 1){
		cout << "Bob" << endl;
	}else if(a > b){
		cout << "Alice" << endl;
	}else{
		cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
struct node
{
    ll x,y;
};

node p[200];
int n;

bool cmp(node p1, node p2)
{
    if (atan2(p1.y, p1.x)!=atan2(p2.y, p2.x))
        return atan2(p1.y, p1.x) < atan2(p2.y, p2.x);
    else return p1.x < p2.x;
}


int main()
{
    cin >> n;
    for (int i=0; i<n; ++i)
        cin >> p[i].x >> p[i].y;
    sort(p, p+n, cmp);
    //for (int i=0; i<n; ++i)
    //    cout << p[i].x <<' '<< p[i].y <<endl;
    ll max_ans = 0;
    for (int i=0; i<n; ++i)
    {
        ll nowx=0,nowy=0;
        for (int j=0; j<n; ++j)
        {
            int now_idx = (i+j)%n;
            nowx += p[now_idx].x;
            nowy += p[now_idx].y;
            if (nowx*nowx + nowy*nowy > max_ans)
                max_ans = nowx*nowx + nowy*nowy;
        }
    }
    printf("%0.50lf",sqrt(max_ans));
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;int main() {
  int N, n, Sum;
  cin >> N;
  n = N;
  for(int i = 0; i = n; n /= 10){
    Sum += n % 10;
  }
  if(N % Sum == 0)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m), timea(n+1, 0), timeb(m+1, 0);
    for(ll i =0; i < n; i++){
        cin >> a[i];
        timea[i+1] = timea[i] + a[i];
    }
    for(ll i =0; i < m; i++){
        cin >> b[i];
        timeb[i+1] = timeb[i] + b[i];
    }
    ll ans = 0;
    for(ll i = 0; i< n+1; i++){
        ll tmp = 0;
        if(k < timea[i]) break;
        auto itr = upper_bound(timeb.begin(), timeb.end(), k-timea[i]);
        if(itr - timeb.begin() == timeb.end() - timeb.begin()) tmp = itr-timeb.begin()-1;
        else tmp = itr-timeb.begin()-1;
        tmp += i;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    string S; cin >> S;
    int N = S.size() + 1;

    ll num[N + 5];
    rep(i, N) num[i] = 0;

    rep(i, N - 1)
    {
        if (S[i] != '<') continue;

        num[i + 1] = num[i] + 1;
    }

    for (int i = N - 2; i >= 0; i--)
    {
        if (S[i] != '>') continue;

        num[i] = max(num[i], num[i + 1] + 1);
    }

    ll ans = 0;
    rep(i, N)
    {
        ans += num[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4740
//DPCoded
	//

#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef set<int> si;
typedef set<string> ss;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> ii;

//#define FILEINOUT
#ifdef FILEINOUT
ifstream In("Input.txt");
ofstream Out("Output.txt");
#else
#define In cin
#define Out cout
#endif

int main() {
	
	int n;
	In >> n;
	Out << (n >= 30 ? "Yes" : "No");
	
	return 0;
}


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

int main() {
	int l, r, d;
	cin >> l >> r >> d;

	int sum = 0;
	for (l;l <= r;l++)
	{
		if (l % d == 0)
		{
			sum++;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 W, H, x, y;
  std::cin >> W >> H >> x >> y;
  std::cout << std::fixed << std::setprecision(6) << W * H / 2.0 << ' ' << (W % 2 == 0 && H % 2 == 0 && W / 2 == x && H / 2 == y ? 1 : 0) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int MAX = 1000000000;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b < 0) {
    cout << "No" << endl;
    return 0;
  }
  ll left = 4 * a * b;
  ll right = c - a - b;
  right *= right;
  if (left < right) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

int64_t calc_Lucas(vector<int64_t> &lucas, int N, int i) {
    // 停止
    if (i == N) {
        return lucas.at(i);
    }

    // 処理
    int64_t r;
    r = lucas.at(i) + lucas.at(i-1);
    lucas.push_back(r);

    // 再帰
    return calc_Lucas(lucas, N, i + 1);
}

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

    // 初期値の設定
    vector<int64_t> lucas(2);
    lucas.at(0) = 2;
    lucas.at(1) = 1;

    cout << calc_Lucas(lucas, N, 1) << endl;
}


Measured memory_bytes: 3612
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;

void main()
{
  string input;
  int num;
  int[] train;

  while ((input = readln().chomp()).length != 0) {
    num = input.to!int();
    if (num == 0) {
      writeln(train[$ - 1]);
      train.length--;
    } else {
      train ~= num;
    }
  }
}

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

int main(void)
{
    string x;
    cin >> x;
    if(x[0]=='A'&&x[1]=='A'&&x[2]=='B') cout << "Yes" << endl;
    else if(x[0]=='A'&&x[1]=='B'&&x[2]=='A') cout << "Yes" << endl;
    else if(x[0]=='B'&&x[1]=='B'&&x[2]=='A') cout << "Yes" << endl;
    else if(x[0]=='B'&&x[1]=='A'&&x[2]=='B') cout << "Yes" << endl;
    else if(x[0]=='A'&&x[1]=='B'&&x[2]=='B') cout << "Yes" << endl;
    else if(x[0]=='B'&&x[1]=='A'&&x[2]=='A') cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int area { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var n = s.Length;
        var a = new int[n];
        for (int i = 0; i < n; i++)
            if (s[i] == '\\') a[i] = -1;
            else if (s[i] == '/') a[i] = 1;
        var st1 = new Stack<int>();
        var st2 = new Stack<P>();
        getAns(s, st1, st2);
        print(st2);
    }
    public static void print(Stack<P> st)
    {
        var n = st.Count();
        if (n == 0) { Console.WriteLine(0); Console.WriteLine(0); return; }
        var a = new int[n];
        var asum = 0;
        for (int i = 0; i < n; i++)
        {
            var w = st.Pop();
            a[n - 1 - i] = w.area;
            asum += w.area;
        }
        Console.WriteLine(asum);
        Console.Write("{0} ", n);
        for (int i = 0; i < n; i++)
            if (i == n - 1) Console.WriteLine(a[i]);
            else Console.Write("{0} ", a[i]);

    }
    public static void getAns(string s, Stack<int> st1, Stack<P> st2)
    {
        for (int i = 0; i < s.Length; i++)
            if (s[i] == '\\') st1.Push(i);
            else if (s[i] == '/' && st1.Count() > 0)
            {
                var id = st1.Pop();
                var area = i - id;
                getSum(id, area, st2);
            }
    }
    public static void getSum(int id, int area, Stack<P> st2)
    {
        while (st2.Count() > 0 && id <= st2.Peek().id)
        {
            area += st2.Peek().area;
            st2.Pop();
        }
        st2.Push(new P { id = id, area = area });
    }
}



Measured memory_bytes: 10876
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    int x, y;

    cin >> a >> b >> c >> d;

    x = (a+b+c+d) / 60;
    y = (a+b+c+d) % 60;

    cout << x << endl << y << endl;
}



Measured memory_bytes: 3068
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

struct UnionFind {
    V<int> p, r, on;
    int gn;
    UnionFind(int n = 0) : p(n, -1), r(n, 1), on(n, 0), gn(n) {}
    void merge(int a, int b) {
        int x = group(a), y = group(b);
        if (x == y) {
            dbg("mrg", a, b);
            assert(!on[y]);
            on[x] = true;
            return;  // same
        }
        gn--;
        if (r[x] < r[y]) {
            p[x] = y;
            on[y] |= on[x];
        } else {
            p[y] = x;
            on[x] |= on[y];
            if (r[x] == r[y]) r[x]++;
        }
    }
    int group(int a) {
        if (p[a] == -1) return a;
        return p[a] = group(p[a]);
    }
    bool same(int a, int b) { return group(a) == group(b); }
    bool can(int a, int b) {
        int x = group(a), y = group(b);
        return !on[x] || !on[y];
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n, h, w;
    cin >> n >> h >> w;
    struct E {
        int r, c; ll a;
    };
    V<E> ed;
    for (int i = 0; i < n; i++) {
        int r, c; ll a;
        cin >> r >> c >> a; r--; c--;
        ed.push_back({r, c, a});
    }
    sort(ed.begin(), ed.end(), [&](E x, E y) {
        return x.a > y.a;
    });

    ll ans = 0;
    UnionFind uf(h + w);
    for (auto e: ed) {
        if (!uf.can(e.r, e.c + h)) continue;
        dbg(e.r, e.c + h, e.a);
        uf.merge(e.r, e.c + h);
        ans += e.a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    map<string, int> mp;
    for (string m : S)
    {
        mp[m]++;
    }
    cout << mp.size() << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

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

const double PI=acos(-1.0);

string S;
void input()
{
    cin >> S;
}

void solve()
{
    if(S[0] == 'R'){
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout << 3 << endl;
                return;
            } else {
                cout << 2 << endl;
                return;
            }
        } else {
            cout << 1 << endl;
            return;
        }
    } else {
        if(S[1] == 'R'){
            if(S[2] == 'R'){
                cout << 2 << endl;
                return;
            } else {
                cout << 1 << endl;
                return;
            }
        } else {
            if(S[2] == 'R'){
                cout << 1 << endl;
                return;
            } else {
                cout << 0 << endl;
                return;
                
            }
        }
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int N;
    cin >> N;
    string s[N];
    for(int i=0;i<N;i++) cin >> s[i];
    vector<vector<int>> count(N,vector<int>(26,0));
    for(int i=0;i<N;i++){
        for(int j=0;j<s[i].size();j++){
            count[i][s[i][j]-'a']++;
        }
    }
    int cnt = INF;
    string ans;
    for(int i=0;i<26;i++){
        for(int j=0;j<N;j++){
            cnt = min(cnt,count[j][i]);
        }
        for(int j=0;j<cnt;j++){
            ans.push_back('a'+i);
        }
        cnt = INF;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
from itertools import groupby
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
p = list(map(int, readline().split()))
xy = map(int, read().split())


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


tree = UnionFind(N)
for x, y in zip(xy, xy):
    tree.Unite(x, y)

group = tree.root[1:]
number = list(range(1, N + 1))
answer = 0

for i in range(N):
    if tree.isSameGroup(number[i], p[i]):
        answer += 1

print(answer)

Measured memory_bytes: 23520
#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>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;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 pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(int a, int n) {//aのn乗を計算します。
	int x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;




ll x[100010];
int v[100010];
ll Max[100010];
ll Rsum[100010];
ll Sum[100010];
int main() {
	int N; ll C;
	cin >> N >> C;
	x[0] = 0; v[0] = 0;
	FOR(i,1, N+1) {
		cin >> x[i] >> v[i];
	}
	v[N + 1] = 0; x[N + 1] = C;

	Sum[0] = 0;
	FOR(i, 1, N + 1) {
		Sum[i] = Sum[i - 1] + v[i];
	}

	//時計回り
	Max[0] = 0;
	FOR(i,1, N+1) {
		Max[i] = max(Max[i - 1], Sum[i]-2*x[i]);
	}
	ll ans = 0;
	Rsum[N+1] = v[N+1];
	for (int j = N; j >= 0; j--) {
		Rsum[j] = Rsum[j + 1] + v[j];
	}
	for (int j = N+1; j >= 0; j--) {
		ll sum = Rsum[j] + Max[j - 1];
		sum -= (C - x[j]);
		ans = max(ans, sum);
	}


	//反時計回り
	Max[0] = 0;
	FOR(i, 1, N+1) {
		Max[i] = max(Max[i - 1], Sum[i] - x[i]);
	}
	for (int j = N+1; j >= 0; j--) {
		ll sum = Rsum[j] + Max[j - 1];
		sum -= 2*(C - x[j]);
		ans = max(ans, sum);
	}

	cout << ans << endl;
}




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


int main()
{
    map<string, int> moji;
    int N;
    cin >> N;
    for(int i=0; i<N; i++)
    {
        string S;
        cin >> S;
        moji[S] += 1;
    }

    int maxv = 0;
    for(const auto& x  : moji)
    {
        int v = x.second;
        if(v > maxv)
            maxv = v;
    }

    for(auto it = moji.begin(); it != moji.end(); it++)
    {
        if(it->second == maxv)
        {
            cout << it->first << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 25216
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 64

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int pebble[MAXN];

int main(void) {
    int n, p;
    while (cin >> n >> p) {
        if (n == 0 && p == 0) break;
        int center = p, cur = 0;
        for (int i = 0; i < n; i++) pebble[i] = 0;
        while (1) {
            if (center == 0) {
                center += pebble[cur];
                pebble[cur] = 0;
            } else {
                pebble[cur]++;
                center--;
                if (pebble[cur] == p) {
                    cout << cur << endl;
                    break;
                }
            }
            cur = (cur+1) % n;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main(){
 	ll n;
  	cin >> n;
  	ll ans = 1000*(n/500);
  	n %= 500;
  	ans += 5*(n/5);
  	cout << ans << endl;
 	return 0; 
}

Measured memory_bytes: 256
using System;
class Multiplication2
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            String[] a = Console.ReadLine().Split();
            ulong sum = 1;
            int frag = 0;
            for (int i = 0; i < n; i++)
            {
                if (ulong.Parse(a[i]) == 0)
                {
                    frag = 1;
                    break;
                }
            }

            if (frag == 1) Console.WriteLine(0);

            else
            {
                try
                {
                    for (int i = 0; i < n; i++)
                    {
                        checked
                        {
                            sum *= ulong.Parse(a[i]);
                        }
                    }
                }
                catch(OverflowException)
                {
                    Console.WriteLine(-1);
                    return;
                }
                if (sum > 1000000000000000000) Console.WriteLine(-1);
                else Console.WriteLine(sum);
            }
        }
    }

Measured memory_bytes: 41168
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  string S;
  cin >> N >> S;

  int ans=0;
  for(int i=1;i<N;i++){
    int ma=0;
    int now=0;
    for(int j=0;j<N;j++){
      if(j+i>=N)  break;
      if(S.at(j)!=S.at(j+i))  now=0;
      else  now++;
      chmax(ma,now);
    }
    chmin(ma,i);
    chmax(ans,ma);
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> H(N);
  for(int i=0; i<N; i++)
    cin >> H[i];
  vector<vector<int>> paths(N);
  for(int i=0; i<M; i++){
    int A,B;
    cin >> A >> B;
    paths[A-1].push_back(B-1);
    paths[B-1].push_back(A-1);
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    bool highest = true;
    for(auto p: paths[i]){
      if(H[i] <= H[p])
        highest = false;
    }
    if(highest)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8788
#include<stdio.h>
int main(void){
    int n,m,i=0,j=0,k=0;
    int a[100][100],b[100],answer;
    scanf("%d %d",&n,&m);
    while(scanf("%d",&a[i][j])==1){
        j++;
        if(j==m){ 
            i++;
            j=0;
        }
        if(i==n) break;  
    }
    while(scanf("%d",&b[k])==1){
        if(k==m-1) break;
        k++;
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
          answer+=a[i][j]*b[j];
        }
         printf("%d\n",answer);
        answer=0;
    }
    return 0;
}


Measured memory_bytes: 2112
//#include <bits\stdc++.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int n, i, x, y, t;

vector<pair<pair<int, int>, int> > vpp;

pair<int, int> pre;

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

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t >> x >> y;
		vpp.push_back(make_pair(make_pair(x, y), t));
	}

	for (int i = 0; i < n; i++)
	{
		int dist = abs(pre.first - vpp[i].first.first) + abs(pre.second - vpp[i].first.second);
		if (dist > vpp[i].second) return cout << "No", 0;
		if (dist <= vpp[i].second && ((dist % 2) != (vpp[i].second) % 2))return cout << "No", 0;
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;

struct point {
    int x;
    int y;
    int h;
};

int judge(int cx, int cy, vector<point> &ps) {
    int h = abs(cx - ps[0].x) + abs(cy - ps[0].y) + ps[0].h;
    for(auto p : ps) {
        if(max(h - abs(cx-p.x) - abs(cy-p.y), 0) != p.h) return 0;
    }
    return h;
}

int main(){
    int n;
    cin >> n;
    vector<point> ps(n);
    for(int i=0; i<n; i++) {
        cin >> ps[i].x >> ps[i].y >> ps[i].h;
    }
    sort(ps.begin(), ps.end(), [](point &a, point &b){ return a.h>b.h; });
    for(int cx=0; cx<=100; cx++) {
        for(int cy=0; cy<=100; cy++) {
            int h = judge(cx, cy, ps);
            if(h) {
                cout << cx << " " << cy << " " << h << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<algorithm>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;i++)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;i--)
#define ll long long
#define max(a,b)(a>b?a:b)
#define min(a,b)(a<b?a:b)
#define tl t[v].l
#define tr t[v].r
using namespace std;
const int N=2e5+5,mo=1e9+7;
int n,a[N],ans,ts,rt,mi;
int d[N],b[N],ds;
bool pd(){
	ds=0;b[0]=0;
	fo(i,1,n){
		if(a[i]<=a[i-1]){
			if(mi==1)return 0;
			for(;d[ds]>a[i];)ds--;
			if(d[ds]==a[i]){
				for(;++b[ds]==mi;){
					if(d[ds-1]==d[ds]-1)ds--;else{
						d[ds]--;b[ds]=1;
						break;
					}
				}
				if(!ds)return 0;
			}else{
				d[++ds]=a[i];b[ds]=1;
			}
		}else{
			d[++ds]=a[i];b[ds]=0;
		}
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	for(int l=1,r=n;mi=l+r>>1,l<=r;){
		if(pd())ans=mi,r=mi-1;else l=mi+1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int e1,e2,e3,e4;
	scanf("%d %d %d %d",&e1,&e2,&e3,&e4);
	if((1<=e1 && e1<=100) && (1<=e2 && e2<=100) && (1<=e3 && e3<=100) && (1<=e4 && e4<=100)){
		if((e1==e2 && e3==e4) || (e1==e3 && e2==e4) || (e1==e4 && e2==e3)){
			printf("yes\n");
		}
		else{
			printf("no\n");
		}
	}
	else{
		printf("error\n");
	}
	return 0;
}


Measured memory_bytes: 2060
input = gets.chomp.split(" ").map(&:to_i)
idx = [0,1,2]
cost = []

3.times do |i|
  focus = idx - [i]
  cost << (input[focus[0]] - input[i]).abs + (input[focus[1]] - input[focus[0]]).abs
  cost << (input[focus[1]] - input[i]).abs + (input[focus[0]] - input[focus[1]]).abs
end

puts cost.min

Measured memory_bytes: 1788
while True:
 n,k = map(int,input().split())
 if n==0 and k==0: break
 
 a = [int(input()) for i in range(n)]

 s = sum(a[0:k])
 max = s

 for i in range(k,n):
  s = s+a[i]-a[i-k]
  if s > max: max = s
 
 print(max)


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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define hash sodnf9843bsd
#define ll long long
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl
#define prec(x) cout << fixed << setprecision(x)
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

const int maxn = 1e5;
vector<int>adj[maxn+7];
int dp[maxn+7] = {};

int dfs(int a){
    if (dp[a] == 0){
        dp[a] = 1;
        for(int b:adj[a]){
            dp[a] = max(dp[a], dfs(b)+1);
        }
    }
    return dp[a];
}

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

    int n, m;cin>>n>>m;
    _fi(m){
        int a, b;cin>>a>>b;
        adj[a].pb(b);
    }

    int ans = 0;
    for(int i = 1;i <= n;i++){
        ans = max(ans, dfs(i));
    }
    cout << ans-1 << endl;


    return 0;
}


Measured memory_bytes: 7552
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

inline int Gcd(int a, int b)
{
    while(b){
        int tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main(int argc, char **argv)
{
    int N; // 2 1e5
    scanf("%d", &N);
    vector<int> A(N); // Ai 1 1e9 inside [1, 1e9]
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    vector<int> pre(N), suf(N);
    pre[0] = A[0];
    for(int i = 1; i < N; i++){
        pre[i] = Gcd(pre[i - 1], A[i]);
    }
    suf[N - 1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--){
        suf[i] = Gcd(A[i], suf[i + 1]);
    }

    int res = max(suf[1], pre[N - 2]); // N >= 2
    for(int i = 1; i + 1 < N; i++){
        res = max(res, Gcd(pre[i - 1], suf[i + 1]));
    }
    printf("%d\n", res);
    
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s_a, s_b, s_c;
  cin >> s_a >> s_b >> s_c;
  map<char, string> m = {{'a', s_a}, {'b', s_b}, {'c', s_c}};
  int i_a = 0, i_b = 0, i_c = 0;
  map<int, int> i = {{'a', i_a}, {'b', i_b}, {'c', i_c}};
  queue<char> q;
  q.push('a');
  while (!q.empty()) {
    char c = q.front();
    q.pop();
    if (i[c] == m[c].length()) {
      cout << (char)toupper(c) << endl;
      return 0;
    }
    char next_c = m[c][i[c]];
    i[c]++;
    q.push(next_c);
  }
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=2e5+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int val[N],fa[N];
int head[N],nxt[N*2],to[N*2],w[N*2];
inline int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
#define fi first
#define se second
struct DT{ pair<LL,int>fi,se; }f[N];
inline DT operator + (const DT &a,const int &b) { return (DT){mp(a.fi.fi+b,a.fi.se),mp(a.se.fi+b,a.se.se)}; }
inline DT operator + (const DT &a,const DT &b) {
	DT ans;
	if (a.fi.se==b.fi.se) ans.fi=min(a.fi,b.fi),ans.se=min(a.se,b.se);
	else if (a.fi.fi<b.fi.fi) ans=a,upmin(ans.se,b.fi);
	else ans=b,upmin(ans.se,a.fi);
	return ans;
}
inline void dfs1(int k,int fa) {
	f[k]=(DT){mp(val[k],find(k)),mp(OO,0)};
	for (int i=head[k];i;i=nxt[i])
		if (to[i]!=fa)
			dfs1(to[i],k),f[k]=f[k]+(f[to[i]]+w[i]);
}
inline void dfs2(int k,int fa) {
	for (int i=head[k];i;i=nxt[i])
		if (to[i]!=fa) {
			f[to[i]]=f[to[i]]+(f[k]+w[i]);
			dfs2(to[i],k);
		}
}
int main()
{
	int n=gi(),i,a,b,C=n,tot=0;pair<LL,int>p;LL ans=0;
	for (i=1;i<=n;i++) val[i]=gi(),fa[i]=i;
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
		w[tot]=w[tot-1]=gi();
	}
	while (C>1) {
		dfs1(1,0);
		dfs2(1,0);
		for (i=1;i<=n;i++) f[i].fi.fi+=val[i],f[i].se.fi+=val[i];
		for (i=1;i<=n;i++) if (fa[i]!=i) f[find(i)]=f[find(i)]+f[i];
		for (i=1;i<=n;i++) if (fa[i]==i) {
				p=f[i].fi.se==i?f[i].se:f[i].fi;
				if (find(i)!=find(p.se)) {
					ans+=p.fi;
					fa[i]=p.se;
					C--;
				}
			}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 35456
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

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

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	ll x, y;
	cin >> x >> y;
	int cnt = 0;
	while (x <= y) {
		x *= 2, ++cnt;
	}
	cout << cnt << "\n";
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m[10001];
bool p(int x){
  if(m[x]>=0) return m[x];
  for(int i=2;i*i<=n;i++) {
    if(x%i==0) return m[x]=0;
  }
  return m[x]=1;
}
main() {
  memset(m,-1,sizeof(m));
  while(cin>>n&&n) {
    int mx=5;
    for(int i=2;i<=n-2;i++)if((p(i)&p(i+2)))mx=i;
    printf("%d %d\n",mx,mx+2);
  }
  return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(){
    int n,i,c=0;
      scanf("%d",&n);
      for(i=1;i<10;i++){
          for(int j=1;j<10;j++){
              if(n==i*j){
                 c++;
              }
          }
      }
        if(c>0)printf("Yes");
        else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

string w;
cin>>w;
int n=w.length();
char a[n];
for(int i=0;i<n;i++){
    a[i]=w[i];
}
if(n==1){
    cout<<"No"<<endl;
    return 0;
}

sort(a,a+n);

int cnt=1;
bool beautiful=true;

for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
        cnt+=1;
        continue;
    }
    if(a[i]!=a[i+1]){
        if(cnt%2==1){
            beautiful=false;
            break;
        }else{
                cnt=1;
        }
    }    
}

if(beautiful){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}

return 0;
}

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

int main(){
  string str;
  cin >> str;

  int point = 0;
  int g_cnt = 0, p_cnt = 0;
  for(int i=0;i<str.size();i++){
    if(str[i] == 'g'){
      if(p_cnt < g_cnt){ p_cnt++; point++; }
      else g_cnt++;

    }else{
      if(p_cnt < g_cnt) p_cnt++;
      else { g_cnt++; point--; }
    }
  }
  cout << point << endl;
  return 0;
}


Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String S = sc.next();
		char[] c = S.toCharArray();

		if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3])
			System.out.println("Bad");
		else
			System.out.println("Good");

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21204
#include <stdio.h>
#include <string.h>
int main(void){
	char str[100000+1];
	int n,um=0,zero=0;
	scanf("%s", &str);
	n = strlen(str);
	for(int i=0;i<n;i++){
		if(str[i]=='1')++um;
		else ++zero;
	}
	if(um<=zero)printf("%d\n",um*2);
	else if(zero<um)printf("%d\n",zero*2);
	
	return 0;
}

Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807;
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000;
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
 
int l[3001][3001];
string s,t;

int fun(int siz1,int siz2)
{
	int ans;

	if(siz1 <0 || siz2<0 )
		return 0;
	else if(l[siz1][siz2]!=-1)
		return l[siz1][siz2];
	else
	{
		if(s[siz1]==t[siz2])
		{
			ans = l[siz1][siz2] = fun(siz1-1,siz2-1)+1;
		}
		else
		{
			ans = l[siz1][siz2] =  max(fun(siz1,siz2-1),fun(siz1-1,siz2));
		}
	}

	return ans;
}


int main()
{
 
	//FAST

	int i,j,ans,siz1,siz2;

	rep(i,0,3000)
	{
		rep(j,0,3000)
			l[i][j]=-1;
	}

	cin>>s>>t;

	//we need to solve this problem using recursion
	//we need to consider positions everytime

	siz1 = s.size();
	siz2 = t.size();

	if(s[siz1-1]==t[siz2-1])
		ans =l[siz1-1][siz2-1]= fun(siz1-2,siz2-2)+1;
	else
	{
		ans =l[siz1-1][siz2-1]= max(fun(siz1-1,siz2-2),fun(siz1-2,siz2-1));
	}


//	cout<<ans<<"\n";

	char arr[ans+1];

	arr[ans]='\0';

	siz1 = siz1-1;
	siz2 = siz2-1;

	i = ans-1;

	while(1)
	{

		//cout<<"Here "<<siz1<<" "<<siz2<<" "<<i<<"\n";


		if(i<0 || siz1<1 || siz2<1)
		{
			if(!i)
			{
				if(siz1==0)
					arr[i]=s[siz1];
				else
					arr[i]=t[siz2];

			}
			break;
		}

		if(s[siz1]==t[siz2])
		{
			arr[i]=s[siz1];
			--siz1;
			--siz2;
			--i;
		}
		else
		{
			if(l[siz1-1][siz2] > l[siz1][siz2-1])
			{
					--siz1;
			}
			else
			{
					--siz2;
			}
		}
	}


	cout<<arr<<"\n";



	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n) {
    if (i%2 == 0 && a[i]%2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

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

#define ll long long

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

    if (n%2 ==0) cout << (float(n)/2)/n << endl;
    else cout << ((n)/2 + float(1))/n << endl;

    return 0;
}



Measured memory_bytes: 256
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define INF 9223372036854777ll
#define pb push_back
using namespace std;
vector<ll> v[100001];
pair<ll,ll> dfs(int s,int pa){
    ll whi=1,so;
    ll sbla=0;
    for(auto i:v[s]){
        if(i!=pa){
            pair<ll,ll> p=dfs(i,s);
            so=whi;
            whi=(whi*p.second);
            whi%=mod;
            sbla=(so * p.first)+(sbla * (p.first+p.second));
            sbla%=mod;
            
        }
    }
    return {whi,(whi+sbla)%mod};//black,white
}
void solve(){
    int n,a,b;
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    pair<ll,ll> pa=dfs(1,-1);
    cout<<(pa.first+pa.second)%mod;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 15980
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d/0%d/%d",&a,&b,&c);
	printf("2018/0%d/",b);
	if(c<10)
	{
		printf("0");
	}
	printf("%d",c);
} 

Measured memory_bytes: 256
N, M = map(int, input().split())

V = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    V[p-1].append((y, i))

ans = [0] * M
for i, v in enumerate(V, start=1):
    v.sort()
    for j, (y, k) in enumerate(v, start=1):
        ans[k] = format(str(i), "0>6") + format(str(j), "0>6")

for a in ans:
    print(a)


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

typedef long long ll;
#define ten5 100000+10
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define iif(c,t,f) ((c)?(t):(f))
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair

int intcmp(const void *v1,const void *v2){return *(int *)v1-*(int *)v2;}

int k,n;

int a[100010];

int main(){
  cin>>n>>k;

  rep(i,0,n){
    scanf("%d",a+i);
  }
  n--;
  if(n%(k-1) == 0){
    cout<<(n/(k-1))<<endl;
  }else{
    cout<<(1+n/(k-1))<<endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N)sum+=P[i];
  K=sum/N;
  L=K+1;
  sum=0;
  rep(i,0,N)sum+=(P[i]-K)*(P[i]-K);
  rep(i,0,N)num+=(P[i]-L)*(P[i]-L);
  Out(min(num,sum));
}

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

int main(){
	int n,sum=0;
	std::string str;
	
	std::cin>>n>>str;

	for (int i = 0; i < str.size()-1; i++) {
		if (str[i] != str[i + 1]) {
			sum++;
		}
	}

	


	std::cout<<sum+1<<std::endl;
	return 0;
}

Measured memory_bytes: 512
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		BigDecimal A=new BigDecimal(sc.nextLong());
		BigDecimal B=new BigDecimal(sc.next());
		
		BigDecimal result=A.multiply(B);
		BigDecimal BigResult=result.setScale(0,RoundingMode.DOWN);
		System.out.println(BigResult);
	
	}

}

Measured memory_bytes: 36060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  char c;
  cin >> c;
  cout << char('a'<=c&&c<='z'?'a':'A') << endl;
}


Measured memory_bytes: 3628