akhauriyash/Code-Regression huggingface dataset:
def main():
    N = int(raw_input())
    A = list(map(int, raw_input().split()))


    class RangeMinimumQuery:
        def __init__(self, n, inf=2 ** 31 - 1):
            self.n = 1 << (n - 1).bit_length()
            self.INF = inf
            self.segtree = [self.INF] * (2 * self.n)

        # i番目の値(0-indexed)をxに変更
        def update(self, i, x):
            i += self.n
            self.segtree[i] = x
            while i > 0:
                i //= 2
                self.segtree[i] = min(self.segtree[2 * i], self.segtree[2 * i + 1])

        # [l, r)のmin
        def query(self, l, r):
            L, R = l + self.n, r + self.n
            R = min(R, len(self.segtree))
            s = self.INF
            while L < R:
                if L & 1:
                    s = min(s, self.segtree[L])
                    L += 1

                if R & 1:
                    s = min(s, self.segtree[R - 1])
                    R -= 1

                L >>= 1
                R >>= 1

            return s


    # 番兵を設置
    A = [0] + A + [0]
    N = N + 2


    # セグ木を初期化
    RMQ = RangeMinimumQuery(N)
    for i, a in enumerate(A):
        RMQ.update(i, a)


    # r_indexes := 自分より右側であって、最も近い、自分より小さなもののindex
    # l_indexes := 自分より左側であって、最も近い、自分より小さなもののindex
    r_indexes = [None] * N
    l_indexes = [None] * N


    # 右側についてにぶたん := iからm内の区間最小値がai以上か？
    for i, a in enumerate(A[1: -1], start=1):
        ok, ng = i, N - 1
        while abs(ok - ng) > 1:
            m = (ok + ng) // 2

            if a <= RMQ.query(i, m + 1):
                ok = m
            else:
                ng = m

        r_indexes[i] = ok + 1

    # 左側についてにぶたん := iからm内の区間最小値がai以上か？
    for i, a in enumerate(A[1: -1], start=1):
        ok, ng = i, 0
        while abs(ok - ng) > 1:
            m = (ok + ng) // 2

            if a <= RMQ.query(m, i + 1):
                ok = m
            else:
                ng = m

        l_indexes[i] = ok - 1


    # 答えを計算
    ans = 0
    for i, (a, l, r) in enumerate(zip(A[1: -1], l_indexes[1: -1], r_indexes[1: -1]), start=1):
        ans += a * (i - l) * (r - i)

    print(ans)


if __name__ == '__main__':
    main()


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

int main(void) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D)
    cout << "Left" << endl;
  else if (A + B < C + D)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  string s;
  cin >> s;
  rep(i, sz(s)) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3616
n, k = map(int, input().split())
s = input()

last = ''
count = 0
face_count = 0
for i in range(len(s)):
    if i == 0: pass
    else:
        if s[i] == last:
            count += 1
        else:
            face_count += 0.5
    last = s[i]

if face_count > k:
    print(count + 2*k)
elif face_count <= k:
    print(n - 1)


Measured memory_bytes: 3316
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//edge cases when n=1 , m=1. wrong variable in loop. if<->while
signed main()
{
	speed
	int n;cin>>n;
	vector<int> inp(n);
	map<int,int>mp;
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];
		++mp[inp[i]];
	}
	int ans=0;
	for(auto it:mp)
	{
		ans+=((it.y*(it.y-1))/2);
	}
	for(auto it:inp)
	{
		int tans=ans;
		tans-=(mp[it]*(mp[it]-1))/2;
		tans+=((mp[it]-1)*(mp[it]-2))/2;
		cout<<tans<<"\n";
	}

}

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

int main(){
	ll N;
	cin >> N;
	vector<ll> X(N);
	for(auto &x : X) cin >> x;
	ll ans = LLONG_MAX;
	for(ll i=0;i<=100;i++) {
		ll tmp = 0;
		for(ll j=0;j<N;j++) {
			tmp += (i-X[j])*(i-X[j]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 1000000000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n;
    cin>>n;
    vector<pair<pair<int,int>,int>> sides(n-1);
    REP(i,n-1)cin>>sides[i].first.first>>sides[i].first.second>>sides[i].second;
    int q,k;
    cin>>q>>k;
    vector<int>x(q);
    vector<int>y(q);
    REP(i,q)cin>>x[i]>>y[i];

    vector<ll>bf(n+1,INF);
    bf[k]=0;
    /*
    bool flag=true;
    while(flag){
        flag=false;
        for(auto s:sides){
            if(bf[s.first.first]!=INF){
                if(bf[s.first.second]>bf[s.first.first]+s.second)flag=true;
                bf[s.first.second]=min(bf[s.first.second],bf[s.first.first]+s.second);
            }
            if(bf[s.first.second]!=INF){
                if(bf[s.first.first]>bf[s.first.second]+s.second)flag=true;
                bf[s.first.first]=min(bf[s.first.first],bf[s.first.second]+s.second);
            }
        }
    }
    */

    map<int,vector<pair<int,int>>> map_;
    for(auto s:sides){
        map_[s.first.first].push_back(mp(s.first.second,s.second));
        map_[s.first.second].push_back(mp(s.first.first,s.second));
    }
    vector<int> search;
    search.pb(k);
    while(search.size()!=0){
        vector<int> ve=search;
        search.clear();
        for(auto v:ve){
            for(auto m:map_[v]){
                if(bf[m.first]==INF){bf[m.first]=bf[v]+m.second;search.pb(m.first);}
            }
        }

    }

    REP(i,q){
        cout<<bf[x[i]]+bf[y[i]]<<endl;
    }
    return 0;
}


Measured memory_bytes: 16628
// traP is kyopuro circle
// -> true

#include <stdio.h>

int main(){
  int a,b,c,d,e,f;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
  int sum = a + 5*b + 10*c + 50*d + 100*e + 500*f;
  if(sum>=1000){
    puts("1");
  }else{
    puts("0");
  }
  return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int d[5]={5,7,5,7,7};
int num[40];
int n;
bool rec(int s){
    int sum=0;
    int t[5];
    REP(i,5)t[i]=d[i];
    int ss=0;
    for(int i=s;i<n;i++){
        if(t[ss]>0)t[ss]-=num[i];
        else{
            ss++;
            t[ss]-=num[i];
        }
    }
    REP(i,5)if(t[i]!=0)return false;
    return true;
}
int main(){
    while(1){
        cin>>n;
        if(n==0)break;
        REP(i,n){
            string s;cin>>s;
            num[i]=s.size();
        }
        REP(i,n){
            if(rec(i)){
                cout<<i+1<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3224
#include <stdio.h>

int main(){
  double xA,yA,xB,yB,xC,yC,xD,yD;
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xA,&yA,&xB,&yB,&xC,&yC,&xD,&yD)!=EO\
F){
    if ((xB-xA)*(xD-xC)+(yB-yA)*(yD-yC)==0)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}

Measured memory_bytes: 608
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string a = strArray[0];
            string b = strArray[1];
            string S = "";
            string X = "";
            int A = int.Parse(a);
            int B = int.Parse(b);
            for(int i =0; i < B; i++)
            {
                S += a;
            }
            for(int j = 0; j < A; j++)
            {
                X += b;
            }
            if (A > B)
            {
                Console.WriteLine(X);
            }
            else
            {
                Console.WriteLine(S);
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28008
def solve(aaa):
    l = 1
    r = 200000
    while l < r:
        m = (l + r) // 2
        if check(m, aaa):
            r = m
        else:
            l = m + 1
    return r


def check(d, aaa):
    if d == 1:
        return all(a1 < a2 for a1, a2 in zip(aaa, aaa[1:]))
    l = 0
    word = [[0, 0]]
    for a in aaa:
        if l >= a:
            if not carry(d, word, a):
                return False
        l = a
    return True


def carry(d, word, i):
    while word[-1][0] > i:
        word.pop()
    while word[-1] == [i, d]:
        word.pop()
        i -= 1
    if i == 0:
        return False
    if word[-1][0] == i:
        word[-1][1] += 1
    else:
        word.append([i, 2])
    return True


n = int(input())
aaa = list(map(int, input().split()))
print(solve(aaa))


Measured memory_bytes: 89172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <stack>
#include <unordered_map>
#include <map>
#include <array>
#include <set>
#include <unordered_set>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define EPS 1e-14
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INFLL 1e18
#define INF 1e9

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

typedef unordered_map<int, int> umi;
typedef unordered_set<int> usi;
typedef unordered_map<int, umi> graph;

#define RANGE(i,a,b,d) for (int i=min((int)a,(int)b); i<max((int)a,(int)b); i+=d)
#define RRANGE(i,a,b,d) for (int i=max((int)a,(int)b); i>min((int)a,(int)b); i+=d)
#define FOR(i,a,b) RANGE(i,a,b,1)
#define RFOR(i,a,b) RRANGE(i,a,b,-1)
#define REP(i,s) FOR(i,0,s)
#define RREP(i,s) RFOR(i,s-1,-1)
#define FORIT(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define EACH(x,v) for (auto &x : v)

#define sz(x) (int)(x).size()
#define len(x) (int)sizeof(x)/sizeof(*x)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define contains(m,x) m.find(x) != m.end()

#define pv(v) for(auto &x:v) cout << x << " "; cout << endl;
#define pm(m) for(auto &x:m) cout << x.F << ":" << x.S << " "; cout << endl;
#define pa(a) REP(i, len(a)) cout << a[i] << " "; cout << endl;
#define paa(aa) REP(i, len(aa)) {REP(j, len(aa[0])) cout << aa[i][j] << " "; cout << endl;}

template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
void print(T t){
    cout << t << endl;
}

template<typename T, typename... Args>
void print(T t, Args... args){
    cout << t << " ";
    print(args...);
}

int main(){
    int a, b;
    cin >> a >> b;
    if( a % 2 == 0 || b % 2 == 0 ) printf("Even\n" );
    else printf("Odd\n" );

    return 0;

}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n;
    cin1(n);
    lli x[n];
    lli y[n];
    lli h[n];
    ncin3(n, x, y, h);

    REP(cx,0,101) {
        REP(cy,0,101) {
            bool is_ans = true;
            // h[i]がゼロではないケースから、Hを出す
            lli H = -1;
            REP(i,0,n) {
                if (h[i] != 0) {
                    H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
                    break;
                }
            }
            REP(i,0,n) {
                // 全部の計算結果が H と一致するのであればそれがこたえ
                if (h[i] == 0) {
                    if (H -  abs(x[i]-cx) - abs(y[i]-cy) > 0) {
                        is_ans = false;
                        break;
                    }
                }
                else {
                    if (H !=h[i] + abs(x[i]-cx) + abs(y[i]-cy)) {
                        is_ans = false;
                        break;
                    }
                }
            }
            if (is_ans) {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
n,p = map(int,input().split())
s = input()
ans = 0
if p == 2 or p == 5:
    for i,c in enumerate(s,1):
        if int(c)%p == 0: ans += i
else:
    cnt = [0]*p
    cnt[0] = 1
    x = 0
    d = 1
    for c in s[::-1]:
        x += d*int(c)
        x %= p
        cnt[x%p] += 1
        d *= 10
        d %= p
    # print(cnt)
    for v in cnt: ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 9408
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }

    a.sort();
    a.reverse();
    let mut ans = 0;
    let mut idx = 0;
    let mut is_first_time = false;
    for i in 1..n {
        // println!("i: {} point: {}", i, a[idx]);
        ans += a[idx];
        if is_first_time {
            is_first_time = false;
        } else {
            idx += 1;
            is_first_time = true;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6168
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n, m, q;
int f[N];
ll ans;

struct quad
{
    int a, b, c, d;
} e[N];

void dfs(int step)
{
    if (step == n + 1)
    {
        int ret = 0;
        for (int i = 1; i <= q; ++i)
        {
            if (f[e[i].a] + e[i].c != f[e[i].b])
                continue;
            ret += e[i].d;
        }
        ans = max(ans, 1ll*ret);
        return;
    }
    int start = f[step - 1];
    for (int i = start; i <= m; ++i)
    {
        f[step] = i;
        dfs(step + 1);
    }
}

void solve()
{
    cin >> n >> m >> q;
    f[0] = 1;
    for (int i = 1; i <= q; ++i)
        scanf("%d%d%d%d", &e[i].a, &e[i].b, &e[i].c, &e[i].d);
    dfs(1);
    cout << ans << '\n';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;

int main()
{
   ll t,n,i,j,k,l,r,mn=0, mx=0;
   cin>>s;
   int p=s.sz;
   if(s[p-1]=='2' || s[p-1]=='4' || s[p-1]=='5' || s[p-1]=='7' || s[p-1]=='9' ) cout<<"hon";
   else if(s[p-1]=='0' || s[p-1]=='1' || s[p-1]=='6' || s[p-1]=='8' ) cout<<"pon";
   else if(s[p-1]=='3' ) cout<<"bon";
}



Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0149

"""
import sys
from sys import stdin
from collections import defaultdict
input = stdin.readline


def process_data(result, rank):
    if result >= 1.1:
        rank['A'] += 1
    elif result >= 0.6:
        rank['B'] += 1
    elif result >= 0.2:
        rank['C'] += 1
    else:
        rank['D'] += 1


def main(args):
    left_rank = defaultdict(int)
    right_rank = defaultdict(int)
    for line in sys.stdin:
        l, r = map(float, line.split())
        process_data(l, left_rank)
        process_data(r, right_rank)

    print('{} {}'.format(left_rank['A'], right_rank['A']))
    print('{} {}'.format(left_rank['B'], right_rank['B']))
    print('{} {}'.format(left_rank['C'], right_rank['C']))
    print('{} {}'.format(left_rank['D'], right_rank['D']))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7772
numList = [int(c) for c in input()]

sum_a = 0
sum_b = 0

for index, num in enumerate(numList):
  a = index % 2
  b = (index + 1) % 2
  if(num - a != 0): 
  	sum_a += 1
  else:
    sum_b += 1

if(sum_a >= sum_b):
  print(sum_b)
else:
  print(sum_a)

Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s < t){
        cout << "Yes\n";
    } else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

/**
 * Created by shoya on 2017/04/11.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println(GCJ(sc.nextInt(), sc.nextInt()));
    }

    static int GCJ(int a, int b){
        if (a < b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        if (b == 0)
            return a;
        else
            return GCJ(b, a % b);
    }

}

Measured memory_bytes: 26264
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int main() {
    int a,b,c;
    cin >> a>> b >>c;
    cout << min(b/a, c) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
    
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output1.txt", "w", stdout);
    int n;
    cin >> n;
    vector< vector<int> > a(n, vector<int>(3, 0));
    for(int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    vector< vector<int> > cnt(n, vector<int>(3, 0));
    cnt[0] = a[0];
    for(int i = 1; i < n; i++) {
        cnt[i][0] = max(cnt[i - 1][1], cnt[i - 1][2]) + a[i][0];
        cnt[i][1] = max(cnt[i - 1][0], cnt[i - 1][2]) + a[i][1];
        cnt[i][2] = max(cnt[i - 1][1], cnt[i - 1][0]) + a[i][2];
    }

    cout << max(max(cnt[n - 1][0], cnt[n - 1][1]), cnt[n - 1][2]);
    return 0;
}

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

int main() {
    int n,i,j,k,p,x;
    cin>>n>>k;
    int a[n];
    int s[n]={0};
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=1;i<n;i++)
    {
            x=1000000000;
            for(j=i-1;j>=max(0,i-k);j--)
            {
                x=min(x,abs(a[i]-a[j])+s[j]);
            }
            s[i]=x;
    }
    cout<<s[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int value = 0;
  cin >> value;
  
  int pos = 0;
  cin >> pos;
  
  int min = pos - value + 1;
  
  for (int i = 0; i < (value*2)-1; i++){
    cout << min << " ";
    min++;
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int sr = sc.nextInt();
        int st = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        int tmpst=st;
        for(int i=0;i<n;i++){
            if(s.charAt(i)=='L'){
                tmpst--;
            }
            if(tmpst==0){
                System.out.println("NO");
                return;
            }
            if(t.charAt(i)=='R'){
                if(tmpst!=w)tmpst++;
            }
        }
        tmpst=st;
        for(int i=0;i<n;i++){
            if(s.charAt(i)=='R'){
                tmpst++;
            }
            if(tmpst==w+1){
                System.out.println("NO");
                return;
            }
            if(t.charAt(i)=='L'){
                if(tmpst!=1)tmpst--;
            }
        }
        int tmpsr=sr;
        for(int i=0;i<n;i++){
            if(s.charAt(i)=='U'){
                tmpsr--;
            }
            if(tmpsr==0){
                System.out.println("NO");
                return;
            }
            if(t.charAt(i)=='D'){
                if(tmpsr!=h)tmpsr++;
            }
        }
        tmpsr=sr;
        for(int i=0;i<n;i++){
            if(s.charAt(i)=='D'){
                tmpsr++;
            }
            if(tmpsr==h+1){
                System.out.println("NO");
                return;
            }
            if(t.charAt(i)=='U'){
                if(tmpsr!=1)tmpsr--;
            }
        }
        System.out.println("YES");
    }

}


Measured memory_bytes: 27668
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
int N;
vector<string> ans;
void dfs(string s, int n) {
	if (s.size() == N) {
		ans.push_back(s);
	}
	else {
		rep(i, 0, n + 1) {
			string next = s;
			next += ('a' + i);
			dfs(next, max(i + 1, n));
		}
	}
}
int main() {
	cin >> N;
	dfs("", 0);
	for (auto st : ans) {
		puts(st.c_str());
	}
	return 0;
}


Measured memory_bytes: 7796
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
MOD = 10**9+7
AB = []
x = 0
y = 0
d = defaultdict(int)
ch = defaultdict(int)
flag = 0
for _ in range(N):
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        flag += 1
        continue
    elif a == 0:
        x += 1
        continue
    elif b == 0:
        y += 1
        continue
    else:
        dd = math.gcd(abs(a),abs(b))
        if dd < 0:
          dd *= -1
        a //= dd
        b //= dd
        if a < 0:
            a *= -1
            b *= -1
        d[(a,b)] += 1
        AB.append([a,b])
n = len(AB)
ans = 1
if n > 0:
  for i in range(n):
      a,b = AB[i]
      if ch[(a,b)] == 1:
          continue
      m = d[(a,b)]
      if b > 0:
          l = d[(b,(-1)*a)]
          ch[(a,b)] = 1
          ch[(b,(-1)*a)] = 1
      else:
          l = d[((-1)*b,a)]
          ch[(a,b)] = 1
          ch[((-1)*b,a)] = 1
      ans *= (pow(2,m,MOD)+pow(2,l,MOD)-1+MOD)
      ans = ans % MOD
ans *= (pow(2,x,MOD)+pow(2,y,MOD)-1+MOD)
ans = ans % MOD
ans = ans -1 + flag
ans = ans % MOD
print(ans)


Measured memory_bytes: 184336
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    int ans = 0;
    int acc = 0, val =0;
    int pre = INT_MIN;
    for(int i = 0; i < n; i++) {
        cin >> val;
        if (val <= pre) {
            acc += 1;
            ans = max(ans, acc);
        } else {
            acc = 0;
        }
        pre = val;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
long M;
long long LM;


long somme(long n) {
  long long s;

  s = n*(n+1);
  s >>= 1;
  s = s % LM;
  return((long) s);
}



int main() {


  M = 10;
  M *= M; // 10^2
  M *= M; // 10^4
  M *= M; // 10^8
  M *= 10; // 10^9
  M += 7;

  LM = (long long) M;

  long N,K;
  cin >> N >> K;

  long i,resultat,grande,petite;

  resultat = 0;
  for (i=K;i<=N+1;i++) {
    // plus grande somme - plus petite somme + 1 avec i nombres
    grande = (somme(N)-somme(N-i)+M) % M;
    petite = somme(i-1);
  //  cerr << i << " MAX = " << grande << " MIN = " << petite << endl;
    resultat = (resultat + grande-petite +1 + M ) % M;
  }

  cout << resultat;

  return 0;


}

Measured memory_bytes: 3636
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
priority_queue<int> W,K;
int main()
{
  int x;
  for(int i = 0;i < 20;i++){
    scanf("%d",&x);
    if(i <10){
      W.push(x);
    }else
      K.push(x);
  }
  int a=0,b=0;
  for(int i = 0;i < 3;i++){
    a += W.top();
    W.pop();
    b +=K.top();
    K.pop();
  }
  cout <<a<<" ";
  cout <<b<<endl;

  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b;
    map<string,long int>mp;
    map<string,int>::iterator it;
    string str;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&a);
        cin>>str;
        if(a==0)
        {
            scanf("%d",&b);
            mp[str]=b;
        }
        else cout<<mp[str]<<endl;
    }
    return 0;
}




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

class Program
{
	static void Main(string[] args)
	{
		//文字列を読み込む
		int N = int.Parse(Console.ReadLine());

		int answer = N/2;
		
        if(N%2 == 1)
		{
			answer++;
		}

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092
/*
  AOJ 2139
  Title:Memory Mach
  @kankichi573
*/
#include <stdio.h>
#include <float.h>

double memo[501][1001];

double div_(int x,int y)
{
  return ((double)x)/((double)y);
}
double match_12(int n,int m) 
{
  return div_(n-2*m,(n-m)*(n-m-1));
}
double match_1st(int n,int m)
{
  return div_(m,n-m);
}
double match_2nd(int n,int m)
{
  return div_(n-2*m,n-m)*div_(m,n-m-1);
}
double nomatch(int n,int m)
{
  return div_((n-2*m)*(n-2*m-1)-(n-2*m),(n-m)*(n-m-1));
}


double kitaiti(	int n, // # of all cards
	        int m  // # of cards already opened
) 
{
  double ret;
  if(n==2 || n/2 <= m)
    return(0.0);

  if((ret=memo[n/2][m])!=0.0)
    return(ret);

  ret  = match_12(n,m)    * kitaiti(n-2,m);
  if(m>0)
    ret += match_1st(n,m) * kitaiti(n-2,m-1);
  if(m>0)
    ret += match_2nd(n,m) * (1.0+kitaiti(n-2,m));
  ret += nomatch(n,m)     * (1.0+kitaiti(n,m+2));
  memo[n/2][m]=ret;
  return(ret);
}

main()
{
  int n,i,j;
  while(scanf("%d",&n) && n)
    {
      for(i=0;i<500;i++)
	for(j=0;j<1000;j++)
	  memo[i][j]=0.0;

      printf("%2.7lf\n",kitaiti(n,0));
    }
  return(0);
}

Measured memory_bytes: 4620
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int gcd(int a,int b){
	while(b>0){
		int t=a%b;
		a=b;
		b=t;
	}
	return a;
}

void solve(){  
	int a,b;
	cin>>a>>b;
	set<int> pfs;
	int g=gcd(a,b);
	int j=g;
	for(int i=2;i*i<=j;++i){
		while(g%i==0){
			g/=i;
			pfs.insert(i);
		}
	}
	if(g!=1) pfs.insert(b);
	cout<<sz(pfs)+1<<endl;
}

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

Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1:
    if b == 2:
        print(3)
    elif b == 3:
        print(2)
elif a == 2:
    if b == 1:
        print(3)
    elif b == 3:
        print(1)
else:
    if b == 1:
        print(2)
    elif b == 2:
        print(1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>N>>H;
    
        if (N>H){
            for (i=0;i<N;i++){
                cout <<H;
            }
            cout <<endl;
        }
        else{
            for (i=0;i<H;i++){
                cout <<N;
            }
            cout <<endl;
        }
    

    
    

    return 0;
    
}


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

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i = 0; i < N; ++i){
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  int M = 0;
  int d;
  for(int i = 0; i < 100000; ++i){
    d = upper_bound(num.begin(),num.end(),i+2)-lower_bound(num.begin(),num.end(),i);
    M = max(M,d);
  }
  cout << M << endl;
}

Measured memory_bytes: 640
def M?(n)
  01 <= n && n <= 12
end

S = gets
x, y = M?(S[0..1].to_i), M?(S[2..3].to_i)

if x && y
  puts :AMBIGUOUS
elsif x
  puts :MMYY
elsif y
  puts :YYMM 
else
  puts :NA
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int a,b;
	cin>>a>>b;
	if(a<=8 and b<=8){
		cout << "Yay!";
		return 0;
	}
	cout << ":(";
	return 0;

}


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

int main() {
  ll a,b,c,ans;
  bool af = false,bf = false;
  cin >> a >> b;
  if(a%2 != 0){
    a++;
    af = true;
  }
  if(b%2 == 0){
    b--;
    bf = true;
  }
  c = ((b-a+1)/2)%2;
  if(af) ans = (a-1)^c;
  else ans = c;
  if(bf) ans = ans^(b+1);
  cout << ans << endl;
}

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

using namespace std;

void bottom_up(int node, int parent, vector<vector<long long>>& dp_left, vector<vector<long long>>& dp_right, vector<long long>& dp, int M, vector<vector<int>>& graph){
  dp[node] = 1;
  
  for(int next : graph[node]){
    if(next != parent){
      bottom_up(next, node, dp_left, dp_right, dp, M, graph);
      
      dp_left[node].push_back(dp[next] + 1);
      dp_right[node].push_back(dp[next] + 1);
      
      dp[node] *= dp[next] + 1;
      dp[node] %= M;
    }else{
      dp_left[node].push_back(1);
      dp_right[node].push_back(1);
    }
  }
  
  for(int j = 1; j < (int)dp_left[node].size(); j++){
    dp_left[node][j] *= dp_left[node][j - 1];
    dp_left[node][j] %= M;
  }
  
  for(int j = (int)dp_right[node].size() - 2; j >= 0; j--){
    dp_right[node][j] *= dp_right[node][j + 1];
    dp_right[node][j] %= M;
  }
}

void top_down(int node, int parent, long long pro, vector<vector<long long>>& dp_left, vector<vector<long long>>& dp_right, vector<long long>& dp, int M, vector<vector<int>>& graph){
  dp[node] *= pro;
  dp[node] %= M;
  
  for(int j = 0; j < (int)graph[node].size(); j++){
    int next = graph[node][j];
    if(next == parent) continue;
    
    long long c = 1;
    if(j - 1 >= 0) c *= dp_left[node][j - 1];
    if(j + 1 < (int)graph[node].size()) c *= dp_right[node][j + 1];
    
    top_down(next, node, (c % M * pro % M + 1) % M, dp_left, dp_right, dp, M, graph);
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> graph(N);
  for(int i = 0; i < N - 1; i++){
    int u, v;
    cin >> u >> v;
    --u; --v;
    
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  
  vector<vector<long long>> dp_left(N), dp_right(N);
  vector<long long> dp(N);
  
  bottom_up(0, -1, dp_left, dp_right, dp, M, graph);
  top_down(0, -1, 1, dp_left, dp_right, dp, M, graph);
  
  for(int i = 0; i < N; i++){
    cout << (dp[i] + M) % M << endl;
  }
  
  return 0;
}

Measured memory_bytes: 31520
N = int(input())
a = list(map(int, input().split()))

left = [0] * (N + 1)
right = [0] * (N + 1)

# 左から
buf = list()
for i in range(N):
    while len(buf) > 0 and a[buf[-1]] > a[i]:
        buf.pop()
    if len(buf) > 0:
        left[i] = buf[-1]
    else:
        left[i] = -1
    buf.append(i)

# 右から
buf = list()
for i in reversed(range(N)):
    while len(buf) > 0 and a[buf[-1]] > a[i]:
        buf.pop()
    if len(buf) > 0:
        right[i] = buf[-1]
    else:
        right[i] = N
    buf.append(i)

ans = 0
for i in range(N):
    ans += a[i] * (i - left[i]) * (right[i] - i)

print(ans)

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

int main(void){
	int n;
	cin >> n;
	vector<int> a;
	a.resize(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	int ans = -1;
	for(int i = -100; i <= 100; ++i){
		int sum = 0;

		for(int j = 0; j < n; ++j){
			sum += (a[j] - i) * (a[j] - i);
		}

		if(ans == -1) ans = sum;
		ans = min(ans, sum);
		//cout << ans << " ";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = int.Parse(Console.ReadLine());
            var list = new List<List<string>>();
            var ans = 0;

            for (var i = 0; i < n; i++)
            {
                var playList = new List<string>();
                var s = test.ReadInput();

                playList.Add(s[0]);
                playList.Add(s[1]);
                list.Add(playList);
            }

            var x = Console.ReadLine();
            var index = test.SearchIndex(list, x, n);

            for (var i = index + 1; i < n; i++)
            {
                ans += int.Parse(list[i][1]);
            }

            Console.WriteLine(ans);
        }

        public int SearchIndex(List<List<string>> list, string word, int n)
        {
            var memory = 0;
            for (var i = 0; i < n; i++)
            {
                if (list[i][0].ToString() == word)
                {
                    memory = i;
                    break;
                }
            }
            return memory;
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, k;
    cin >> n >> k;
    vt<int> neg, pos;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < 0) neg.push_back(x);
        else pos.push_back(x);
    }

    int ni = 0, pi = k - sz(neg) - 1;
    int mn = 1 << 30;
    while (pi != sz(pos)) {
        int negD = ni >= sz(neg) ? 0 : -neg[ni];
        int posD = pi < 0 ? 0 : pos[pi];
        mn = min(mn, min(negD, posD) + negD + posD);
        ni++, pi++;
    }

    cout << mn;
}


Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){   cout << endl ;}

template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false); 
    //cin.tie(NULL);  

    int t=1,te=0;
    while(t--){
        ll n;

        cin>>n;

        ll res=(n*(n-1))/2;

        cout<<res<<endl;

        //printf("Case %d: ",++te);
    }
    return 0;
}


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

int main() {
  int N , A , B , C , D;
  cin >> N ;
  A = N / 1000 ;
  B = (N % 1000) / 100 ;
  C = ((N % 1000) % 100) / 10;
  D = ((N % 1000) % 100) % 10;
  if (A == B){
    if (B == C){
  		cout << "Yes" << endl;
    }else{
  	    cout << "No" << endl;
  	}
  }else if(B == C){
    if (C == D){
    	cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int A = rei();
	int P = rei();
	int ans = (A*3+P) / 2;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
//atcoder clange
#include <stdio.h>

int main(void){
  int a[3];
  int i=0;
  for(i=0;i<3;i++){
      scanf("%d", &a[i]);//数値の取得
}
 int max = a[0];
  int sum = 0;
        for(i=0;i<3;i++){
            if(a[i] > max){
                max = a[i];
            }
          sum = sum + a[i];
        }
  int ans = 0;
  ans  = sum - max;
    printf("%d",ans);

    //int max = max(a, N);
    return 0;     
}

Measured memory_bytes: 128
(_, _, X, Y), x, y = [int(i) for i in input().split()], [int(i) for i in input().split()], [int(i) for i in input().split()]

for Z in range(X + 1, Y + 1):
    if max(x) < Z <= min(y):
        print("No War")
        exit()
print("War")


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int a = in.nextInt();
      String s = in.next();

      if (a >= 3200) {
        System.out.println(s);
      } else {
        System.out.println("red");
      }
    }
  }
}

Measured memory_bytes: 21844
S = input()

st = ['A', 'C', 'G', 'T']

res = 0

for i in range(len(S)+1):
    for j in range(1,len(S)+1):
        flag = True
        if -j+1 == 0:
            #print(S[i:])
            for k in S[i:]:
                if k not in st:
                    flag = False
                    break
        
            if flag:
                res = max(res,len(S[i:]))
        
        else:
            for k in S[i:-j+1]:
                if k not in st:
                    flag = False
                    break
            
            if flag:
                res = max(res,len(S[i:-j+1]))

print(res)



Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
void p(int n){
  if(n==0)return;
  int c;
  c=n%10;
  p(n/10);
  c=10-c;
  cout<<c;
}
int main(){
  int n;
  cin>>n;
  p(n);
  return 0;
}


Measured memory_bytes: 256