akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.precision(10);
   cout << fixed;
   int n;
   cin >> n;
   cout << (n & 1 ? (n / 2 + 1) / (double)n : 0.5) << '\n';
   return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = s.length();
    int n = ans - 1;
    for(int i = 0; i < n; i++) {
        if(s[i] != s[i + 1]) {
            ans = min(ans, max(i + 1, n - i));
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 512
k, n = [int(t) for t in input().split()]
a = [int(i) for i in input().split()]

min_L = a[n - 1] - a[0]
for i in range(n - 1):
    min_L = min(min_L, k - a[i + 1] + a[i])
print(min_L)

Measured memory_bytes: 26420
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    total = 1
    for a in A:
        total *= a
        if total > 10 ** 18:
            print(-1)
            return

    print(total)


main()

Measured memory_bytes: 21644
//akram
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int   a,b;
 cin>>a>>b;
if((a+b)%2!=0)
    cout<<"IMPOSSIBLE\n";
else
{
  long long int c=(a+b)/2;
  cout<<c<<"\n";
}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>

#define MIN(a, b) ((a)>(b)? (b): (a))

int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld %ld", &n, &k);

    std::vector<long> h(n);
    long i, j;
    for(i=0; i<n; i++) {
        scanf("%ld", &(h[i]));
    }

    long c[100001]={0};

    c[0]=0;
    for(i=1; i<n; i++) {
        c[i]=c[i-1]+abs(h[i-1]-h[i]);
        for(j=2; j<=k && i-j>=0; j++) {
            long tmp = c[i-j]+abs(h[i-j]-h[i]);
            c[i] = MIN(c[i], tmp);
        }
    }
    printf("%ld\n", c[n-1]);

    return 0;
}


Measured memory_bytes: 1792
# coding=utf-8


def gcd(n1, n2):
    if n1 < n2:
        n1, n2 = n2, n1

    if n1 == n2 or n2 == 0:
        return n1
    n1, n2 = n2, (n1 % n2)
    return gcd(n1, n2)


def lcm(n1, n2):
    return n1*n2//gcd(n1, n2)


def multi_lcm(numbers_list):
    if len(numbers_list) == 2:
        return lcm(numbers_list[0], numbers_list[1])
    elif len(numbers_list) > 2:
        numbers_list2 = [lcm(numbers_list[0], numbers_list[1])]
        numbers_list2.extend(numbers_list[2:])
        return multi_lcm(numbers_list2)


if __name__ == '__main__':
    n = int(input())
    number_list = list(map(int, input().split()))
    print(multi_lcm(number_list))



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

const ll INF = 1LL << 60;

ll R;
int main() {
    cin >> R;
    double ans = (double)2 * R * M_PI;
    printf("%.10f\n", ans);
}

Measured memory_bytes: 3760
a=int(input())
ans = 0
tmp = 2 
while tmp*tmp <=a:
    ct = 0 
    while not a % tmp:
        ct+=1
        a/=tmp
    for i in range(1,ct+1):
        if (1+i)*i/2<=ct:
            ans+=1
        else:
            break
    tmp+=1
if a != 1:
    ans+=1
print(ans)

Measured memory_bytes: 9260
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: usize, b: usize, c: usize,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
use std::collections::HashMap;
fn main() {
    input!{
        _n: usize, m: usize, 
        tuples: [(u32, u32); m] // (pref, year)
    }
    let mut map = HashMap::new();
    for (city, &(p, y)) in tuples.iter().enumerate() {
        let v = map.entry(p).or_insert(Vec::new());
        v.push((y, city));
    }
    let mut answer = Vec::new();
    for (p, v) in &mut map {
        v.sort_by_key(|&(y, _city)| y);
        for (i, &(_y, city)) in v.iter().enumerate() {
            answer.push((city, format!("{:06}{:06}", p, i+1)));
        }
    }
    answer.sort_by_key(|&(city, ref _ans)| city);
    for (_city, ref ans) in answer { println!("{}", ans); }
}


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

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin>>a>>b;
    reverse(b.begin(),b.end());
    a=a.compare(b)?"NO":"YES";
    cout<<a<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll mod = static_cast<ll>(1e9) + 7;

int main()
{
    ll X, Y;
    cin >> X >> Y;

    const ll x = X == 1 ? 300000 : X == 2 ? 200000 : X == 3 ? 100000 : 0;
    const ll y = Y == 1 ? 300000 : Y == 2 ? 200000 : Y == 3 ? 100000 : 0;
    const ll z = X == 1 && Y == 1 ? 400000 : 0;

    const ll ans = x + y + z;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
let input = ''

process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
  input += chunk
})
process.stdin.on('end', function() {
  input = input.trim().split('\n')
  main()
})

function main() {
    for(i=0; i<input.length; i++) {
        input_line = input[i].split(' ')
        input_line.sort(compareNumbers)
        let a = input_line[0]
        let b = input_line[1]
        let r = input_line[0] % input_line[1]
        let x = a * b
        while(r!=0){
          a = b
          b = r
          r = a % b
        }
        console.log(b, x/b)
    }
}

function compareNumbers(a, b) {
  return b - a;
}


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

int num = 0;

bool checking_the_format(int a, int i)
{
	num++;
	if (num == a + 1)
	{
		if (!(i == '-'))
		{
			return false;
		}
	}
	else if (!(isdigit(i)))
	{
		return false;
	}
	return true;
}

int main()
{
	int a, b;
	string s;
	cin >> a >> b >> s;
	for (int i : s)
	{
		if (checking_the_format(a, i) == false)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int aCb(int a,int b,int m){
  long long s=1,i;
  if(b>a-b)b=a-b;
  for(i=0;i<b;i++)s=(((s*(a-i))%m)*inv(i+1,m))%m;  
  return (int)s;
}
int main(){
  long long n,a,b,M=1e9+7;
  scanf("%lld %lld %lld",&n,&a,&b);
  printf("%lld\n",(mbk(2,n,M)-aCb(n,a,M)+M-aCb(n,b,M)+M-1+M)%M);
  return 0;
}


Measured memory_bytes: 128
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = []
for i in range(m):
    p,x = map(int,input().split())
    px.append([p,x])
nodrinkt = sum(t)
for i in range(m):
    diff = t[px[i][0]-1] - px[i][1]
    ans = nodrinkt - diff
    print(ans)

Measured memory_bytes: 12500
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
int ke (int n){
    n--;
    if(n == 1 )return 0;
    int ans = 1;
    while (0 < n){
        ans *= n;
        n--;
    }
    return ans ;

}
int main(){
    int n,x,y;
   cin >> n >> x >> y;

   x--;y--;

   vector<int> vec(n);

   for(int i = 0 ; i < n-1;i++){
       for(int j = i+1 ; j < n;j++){
           int g = min(abs(i-j),min( abs(x-i) + abs(y-j) + 1, abs(x-j) + abs(y-i) + 1));
           vec[g] ++;
       }
   }

    for(int i = 1 ; i < n ; i++){
         cout << vec[i] << endl;
    }
}





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



int main(void){
    int k, n;
    cin >> n >> k;
    vector<int> a(200001);

    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    sort(a.begin(), a.end(), greater<int>());
    if(a[2] == 0) {
        cout << 0 << endl;
        return 0;
    }
    int sum = 0;
    for(int i=0; i<k; i++) sum += a[i];
    cout << n - sum << endl;
    return 0;
}


Measured memory_bytes: 1024
a = "abcdefghijklmnopqrstuvwxyz"
A = [0 for i in range(26)]

while True :
    try :
        s = input()
        
        for i in range(len(s)) :
            if s[i] in a or s[i].lower() in a :
                A[a.index(s[i].lower())] += 1
    except :
        break
    
for j in range(26) :
    print(a[j], ":", A[j])


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>T(N),A(N);
  for(int i=0;i<N;i++)cin>>T[i];
  for(int i=0;i<N;i++)cin>>A[i];

  if(N==1){
    if(T[0]==A[0])cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
  }

  vector<bool>tb(N,false),ab(N,false);
  tb[0]=true;
  ab[N-1]=true;
  for(int i=1;i<N;i++){
    if(T[i]!=T[i-1])tb[i]=true;
  }
  for(int i=N-2;i>=0;i--){
    if(A[i]!=A[i+1])ab[i]=true;
  }
  
  ll ans=1;
  bool ng=false;
  for(int i=0;i<N;i++){
    if(tb[i]&&ab[i]){
      if(T[i]!=A[i])ng=true;
    }
    else if(tb[i]){
      if(T[i]>A[i])ng=true;
    }
    else if(ab[i]){
      if(T[i]<A[i])ng=true;
    }
    else{
      ans*=min(T[i],A[i])%MOD;
      ans%=MOD;
    }
  }
  if(ng)cout<<0<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
def submit():
    n = int(input())
    alist = list(map(int, input().split()))
    order = [-1 for _ in range(n)]

    for i, a in enumerate(alist, start=1):
        order[a - 1] = i

    print(*order, sep=" ")
    


if __name__ == "__main__":
    submit()

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

void solve(int H,int W,int h,int w){
  int bcnt = (H/h) * (W/w);
  int a = bcnt*2;
  int low = a * (h*w-1) + 1;
  int high = (H*W - bcnt) * 2;
  // a*(hw-1) < b < a*(rrate-1)
  if(high-low<=0){
    puts("No");
  }else{
    int b = low;
    puts("Yes");
    REP(i,H){
      REP(j,W){
        if((i+1)%h==0 && (j+1)%w==0){
          printf("-%d%c",b,j==W-1?'\n':' ');
        }else{
          printf("%d%c",a,j==W-1?'\n':' ');
        }
      }
    }
  }
}

int main(){
  int H,W,h,w;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  solve(H,W,h,w);
  return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long a, b, x = long.Parse(Console.ReadLine());
            for (a = -120; a < 120; ++a)
            {
                for (b = -120; b < 120; ++b)
                {
                    if (a * a * a * a * a - b * b * b * b * b == x)
                    {
                        Console.Write(a);
                        Console.Write(" ");
                        Console.WriteLine(b);
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 27476
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
int main(){
	ll sum=0;
	char c;
	while((c=getchar())!='\n'){
		sum+=(c-'0');
	}
	if(sum%9==0) cout<<"Yes";
	else cout<<"No";
}
	

Measured memory_bytes: 3000
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  if(abs(c-a)<=d)cout<<"Yes";
  else if(abs(b-a)<=d&&abs(c-b)<=d)cout<<"Yes";
  else cout<<"No";
}



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

bool safe(string st) {
    string th = st.substr(1);
    if (th == "AGC" or th == "GAC" or th == "ACG") return false;
    if (st[0] == 'A' and st.substr(2) == "GC") return false;
    if (st.substr(0, 2) == "AG" and st[3] == 'C') return false;
    return true;
}

vector<map<string, int>> v;
string candi[4] = {"A", "T", "G", "C"};
int N;

int dfs(string st, string c, int n) {
    if (not safe(st + c)) return 0;
    if (n == N) return 1;

    int memo = v[n][st.substr(1) + c];
    if (memo) return memo;

    int ans = 0;
    repall (nx, candi) {
        ans += dfs(st.substr(1) + c, nx, n + 1);
        ans %= MOD;
    }

    v[n][st.substr(1) + c] = ans;

    return ans;
}

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

    v = vector<map<string, int>>(N + 1);

    int ans = 0;
    print(dfs("ZZZ", "Z", 0));

    return 0;
}


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

using namespace std;
#define int long long
#define pb push_back
#define f(i,s,n) for(int i=s;i<n;i++)



class node{
public:
	int index;
	vector<int> links;
	bool visited;

	node(){
		index = -2;
		visited=false;
	}

	void visit(){
		visited=true;
	}

	void unvisit(){
		visited=false;
	}

	void addEdge(int d){
		links.push_back(d);
	}
};

signed main(){
	int n,x,y;
	cin>>n>>x>>y;
	
	// did n+1 because indexing starts from 1
	node ndlist[n+1];
	f(i,1,n+1)
		ndlist[i].index=i;
	f(i,1,n+1){
		if(i>1)
			ndlist[i].addEdge(i-1);
		if(i<n)
			ndlist[i].addEdge(i+1);
		if(i==x)
			ndlist[i].addEdge(y);
		if(i==y)
			ndlist[i].addEdge(x);
	}

	int distanceFreq[n];
	// 1 2 3 4 ... n-1
	f(i,0,n) distanceFreq[i]=0;

	f(i,1,n+1){
		// cacl dist b/w (i,j)
		queue<int> line;
		for(int x:ndlist[i].links){
			if(!ndlist[x].visited){
				line.push(x);
				ndlist[x].visit();
				if(i>x)
					distanceFreq[1]++;
			}
		}
		int len =2;
		while(line.size()!=0){

			int duml =  line.size();
			for(int ll=0;ll<duml;ll++){
				node first=ndlist[line.front()];
				line.pop();

				for(int x:first.links){
					if(!ndlist[x].visited){
						line.push(x);
						ndlist[x].visit();
						if(i>x)
							distanceFreq[len]++;
					}
				}
			}
			len++;
		}

		f(j,1,n+1) ndlist[j].unvisit();
	}

	f(i,1,n) cout<<distanceFreq[i]<<endl;
}

Measured memory_bytes: 384
#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 calc_digit(ll n) {
    int res = 0;
    while(0 < n) {
        n /= 10;
        res++;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    int res = (1<<29);

    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            int digit = max(calc_digit(i),calc_digit(n/i));
            res = min(res, digit);
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3592
N = input()
s = []
for i in range(N):
    s.append(raw_input())
alpha='abcdefghijklmnopqrstuvwxyz'
num = []
for i in range(26):
 num.append(0)

for j in range(26):
 num[j]=s[0].count(alpha[j])

for k in range(N-1):
 for l in range(26):
  if num[l]>0:
   aaa=s[k+1].count(alpha[l])
   if aaa<num[l]:
    num[l]=aaa
out=""
for n in range(26):
 out=out+alpha[n]*num[n]
print out

Measured memory_bytes: 2692
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int a;
	getval(a);
	printf("%d\n", a + a * a + a * a * a);
}


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

void solve(long long N, long long A, long long B, std::vector<long long> X) {
  long long tmp = 0;
	for(int i = 1;i<N;i++){
      tmp+=min((X[i]-X[i-1])*A,B);
}
  cout<<tmp;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  std::vector<long long> X(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &X[i]);
  }
  solve(N, A, B, std::move(X));
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n*2-1);
  for(Int i=0;i<n*2-1;i++) cin>>a[i];

  auto check=[&](Int x)->Int{
    vector<Int> b(a);
    for(Int &e:b) e=e>=x;
    //for(Int i=0;i<n*2-1;i++) cout<<b[i]<<" ";
    //cout<<endl;
    for(Int i=0;i+1<n;i++){
      if(b[n-1-i]==b[n-1-(i+1)]) return b[n-1-i];
      if(b[n-1+i]==b[n-1+(i+1)]) return b[n-1+i];
    }
    return b[n-1]^(~n&1);
  };

  Int l=0,r=2*n;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(check(m)) l=m;
    else r=m;    
  }
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 3428
import java.util.*;
class Main {
  public static void main(String[]args){
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    String t = scanner.next();
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    
    String u = scanner.next();
    
    if(u.equals(s)){
      a --;
    }else{
      b --;
    }
      
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 23124
nums = [int(x) for x in input().split()]
N,M,K = nums[0],nums[1],nums[2]
 
for k in range(N+1):
	for l in range(M+1):
		if k * (M - l) + l * (N-k) == K:
			print("Yes")
			exit(0)
print("No")


Measured memory_bytes: 3060
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++11 -D_GLIBCXX_DEBUG c.cpp -oc && ./c " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fr(i,n) for(int i=(n);i--;)
#define fv(i,v) f(i,sz(v))

main(){
	ios::sync_with_stdio(0),cin.tie(0);
	string l="MARCH";
	int n;
	cin>>n;
	int k[5]={0};
	f(i,n){
		string s;
		cin>>s;
		fv(j,l){
			if(s[0]==l[j]){
				k[j]+=1;
			}
		}
	}
	vc<int> v(5);
	v[2]=v[3]=v[4]=1;
	int r=0;
	do{
		int cur=1;
		fv(i,v){
			if(v[i]) cur*=k[i];
		}
		r+=cur;
	}while(next_permutation(all(v)));
	cout<<r<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){

    int a, b;
    cin >> a >> b;
    int k = (a + b) / 2;
    if((a+b)%2==1 || (a>=k && b>=k) || (a<=k && b<=k)){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << k << endl;
    }

    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> ok(m + 1, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      ok[a]++;
    }
  }
  int res = 0;
  for (int i = 0; i <= m; i++) {
    if (ok[i] == n) res++;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    s1 = s[:i+1]
    s2 = s[i+1:]
    S1 = set(s1)
    S2 = set(s2)
    num = S1 & S2
    ans = max(ans,len(num))
print(ans)

Measured memory_bytes: 3060
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    time = 0
    ls = PX[i]
    for j in range(N):
        if ls[0] == j+1:
            time += ls[1]
        else:
            time += T[j]
    print(time)

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Drink {
    int p;
    int x;
};

int main () {
    int n;
    cin >> n;
    vector<int> time(n);
    for(int i = 0; i < time.size(); i++) {
        cin >> time[i];
    }

    int m;
    cin >> m;
    vector<Drink> drink(m);
    for(int i = 0; i < drink.size(); i++) {
        cin >> drink[i].p >> drink[i].x;
    }

    for(int j = 0; j < drink.size(); j++) {
        int sum = 0;
        for(int i = 0; i < time.size(); i++) {
            if(drink[j].p == i + 1) {
                sum += drink[j].x;
            }else {
                sum += time[i];
            }
        }
        cout << sum << endl;
    }
}


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

namespace Problem_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var nums = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var dict = new Dictionary<int, int>();
            foreach (var num in nums)
            {
                if (dict.ContainsKey(num)) dict[num] += 1;
                else dict.Add(num, 1);
            }

            var count = 0;
            foreach (var e in dict)
            {
                if (e.Value < e.Key)
                {
                    count += e.Value;
                }
                else if (e.Value > e.Key)
                {
                    count += e.Value - e.Key;
                }
            }
            Console.WriteLine($"{count}");
        }
    }
}


Measured memory_bytes: 25308
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[300010];
    ll sum[300010]={},sumr[300010]={};
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
    }
    repr(i,n){
        sumr[i]=sumr[i+1]+a[i];
    }
    ll ans=LLINF;
    rep2(i,1,n){
        ans=min(ans,abs(sum[i]-sumr[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
//区間DP
#include <iostream>
#include <climits>
using namespace std;

int n;//スライムの数
long long p[405];//スライムの価値
long long All[405][405];//m番目からn番目のスライムの価値の和All[m][n]

long long infl = 10000000000000;//inflは十分大きい

long long fmin[405][405];//m番目からn番目の区間の最小値fmin[m][n]

long long dp(int m,int n)
{
    //メモ済み
    if(fmin[m][n] != infl) return fmin[m][n];
    //メモしていない
    else {
        //if(n - m == 1) return fmin[m][n] = p[m] + p[n];
        if(m == n) return fmin[m][n] = 0;
        else{
            long long t = infl;
            fmin[m][n] = 0;
            for(int v = m; v < n; v++){
                fmin[m][n] = min(dp(m,v) + dp(v + 1,n) + All[m][n],t);
                t = fmin[m][n];
            }
            
            return fmin[m][n];
        }
    }
}

int main()
{
 
 cin >> n;
 for(int i = 1; i <= n; i++){
  cin >> p[i];
  for(int j = 1; j <= n; j++){
      fmin[i][j] = infl;
  }
 }
 long long b[405];//価値の累積和
 b[0] = 0;
 b[1] = p[1];
 All[0][0] = 0;
 for(int i = 2; i <= n; i++) b[i] = b[i - 1] + p[i];
 for(int i = 1; i < n; i++){
     for(int j = 2; j <= n; j++){
         All[i][j] = b[j] - b[i - 1];
     }
 }
 //区切る場所
 cout <<  dp(1,n);
 return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;

    if (m < 2) {
        if (n < 2) {
            cout << 0 << endl;
        }
        else {
            cout << n*(n-1)/2 <<endl;
        }

    }
    else {
        cout << (m*(m-1)/2)+(n * (n - 1) / 2) << endl;

    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int K;
    cin >> K;
    map<int , int> mp;
    int retsu[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int cnt=1;
    for(auto r:retsu) {
        mp[cnt] = r;
        cnt++;
    }

    cout << mp[K] << endl; 

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[100005];
    cin>>a;
    int n0=0,m1=0;
    int len=strlen(a);
    for(int i=0;i<len;i++)
    {
        if(i%2==0&&a[i]!='0')
            n0++;
        if(i%2==1&&a[i]!='1')
            n0++;
    }
     for(int i=0;i<len;i++)
    {

        if(i%2==0&&a[i]!='1')
            m1++;
        if(i%2==1&&a[i]!='0')
            m1++;
    }
    int s=min(n0,m1);
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)

n,u,v=map(int, input().split())
u-=1
v-=1
ab=[list(map(int, input().split())) for _ in range(n-1)]
graph = [[] for _ in range(n+1)]
for a,b in ab:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

dist=[[-1, -1] for _ in range(n)]
dist[v][0]=0
dist[u][1]=0

def dfs1(graph,v):
    vv=graph[v]
    for vvv in vv:
        if dist[vvv][0]==-1:
            dist[vvv][0]=dist[v][0]+1
            dfs1(graph,vvv)

def dfs2(graph,v):
    vv=graph[v]
    for vvv in vv:
        if dist[vvv][1]==-1:
            dist[vvv][1]=dist[v][1]+1
            dfs2(graph,vvv)

dfs1(graph,v)
dfs2(graph,u)
dist.sort(reverse=True)

for i in range(10**6):
    if dist[i][0]-dist[i][1]>=1:
        print(dist[i][0]-1)
        break



Measured memory_bytes: 124724
N = int(input())
A = list(map(int,input().split()))
B = sorted(A[i] - i - 1 for i in range(N))
def sad(b):
    return sum(abs(A[i] - i - 1 - b)for i in range(N))
print(min(sad(B[N//2]),sad(B[min(N//2+1,N-1)])))


Measured memory_bytes: 26180
from fractions import Fraction
n,k=map(int,input().split())
times=[0]*n
for i in range(1,n+1):
    count=0
    j=1
    while True:
        if j*i<k:
            count+=1
            j=2*j
        else:
            break
    times[i-1]+=count
ans=0
for k in times:
    ans+=(Fraction(1,2))**k
print(ans.numerator/(ans.denominator*n))

Measured memory_bytes: 79532
//線分状の格子点の数

#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <random>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <complex>

using namespace std;

int main(){
    int k, x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
 

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ave = 0;
  REP(i, N) ave += A[i];

  int MIN = INF;
  REP(i, N) chmin(MIN, abs(ave-A[i]*N));

  REP(i, N){
    if(abs(ave-A[i]*N) == MIN){
      cout << i << endl;
      break;
    }
  }


  return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int& v: a) cin >> v;





    int l = 0, r = n;
    while (l + 1 < r) {
        int m = (l + r) / 2;
        vector<pair<int, int>> lst;

        bool check = true;
        for (int i = 1; i < n; i++) {
            if (a[i] <= a[i - 1]) {

                while (lst.size() && lst.back().first >= a[i]) lst.pop_back();

                bool ok = false;
                for (int j = a[i] - 1; j >= 0; j--) {
                    if (!lst.size() || lst.back().first < j) {
                        if (m == 1) break;
                        lst.push_back({j, 1});
                        ok = true;
                        break;
                    } else if (lst.back().first == j && lst.back().second + 1 < m) {
                        lst.back().second++;
                        ok = true;
                        break;
                    } else {
                        lst.pop_back();
                    }
                }

                if (!ok) {
                    check = false;
                    break;
                }
            }
        }
        if (check)
            r = m;
        else
            l = m;
    }

    cout << r << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

class Range{
public:
    int l,r,count;
    char kind;
    Range(int a_l, int a_r, int a_count, char a_kind)
        :l(a_l), r(a_r), count(a_count), kind(a_kind){}
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<Range> x;
    int l = 0, r = 0;
    char now = s[0];
    REP(i,n){
        if(s[i] != now){
            r = i - 1;
            x.PB(Range(l,r,r-l+1,now));
            l = i;
            now = s[i];
        }
    }
    x.PB(Range(l,r,n-1-l+1,now));

    VL sum(SZ(x));
    sum[0] = x[0].count;
    FOR(i,1,SZ(x)){
        sum[i] = sum[i-1] + x[i].count;
    }

    int ans = 0;
    REP(i,SZ(x)){
        if(x[i].kind == '1'){
            int last_index = min(i + k * 2, SZ(x) - 1);
            int renzoku = sum[last_index] - sum[i] + x[i].count;
            ans = max(ans, renzoku);
        }
        else{
            int last_index = min(i + (k-1) * 2 + 1, SZ(x) - 1);
            int renzoku = sum[last_index] - sum[i] + x[i].count;
            ans = max(ans, renzoku);
        }
    }

    PUTS(ans);
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long
#define ld long double
#define loopi(i,intial,n)  for(ll i=ll(intial);i<n;i++)
#define loopj(j,intial,n) for(ll j=ll(intial);j<n;j++)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 1e13;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
   afify();
   int n;
   cin>>n;
   vi v(2*n);
   loopi(i,0,2*n) cin>> v[i];
   sort (all(v));
   int res=0 ;
   loopi(i,0,2*n){
	   res+=v[i];
	   i++;
   }

   cout<<res<<endl;

   return 0;
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B, C) = read!(usize, usize, usize);

    let K = if A + B < C {
        A + B + 1 + B
    } else {
        C + B
    };

    println!("{}", K)
}


Measured memory_bytes: 4352
S = input()
N = len(S)

def check(S1):
    if S1 != S1[::-1]:
        return False
    else:
        return True

POS = int((N-1)/2)
S1 = S[0:POS]
POS = int((N+3)/2)
S2 = S[POS-1:N]

if check(S) == False or check(S1) == False or check(S2) == False:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 9028
#include <iostream>
#include <string>

#define ll long long
#define repeat(i, x) for (register ll i = 0; i < x; i++)

using namespace std;

int main()
{
  ll a, b, c, d;
  ll tmp;

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

  if (((a < 0 && b < 0) && (c >= 0 && d >= 0)) || ((a >= 0 && b >= 0) && (c < 0 && d < 0)))
  {
    tmp = a * d < b * c ? b * c : a * d;
  }
  else
  {
    tmp = a * c < b * d ? b * d : a * c;
  }
  cout << tmp << endl;
}

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

int main() {
  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 << "Balanced" << endl;
  }
  else {
      cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  int a, b;
  while(cin >> a >> b){
    int c = a + b, i;
    for(i = 0; c != 0; i++){
      c /= 10;
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 1160