akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC116_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var tds = new Model[N];

            for (long i = 0; i < N; i++)
            {
                var td = Console.ReadLine().Split().Select(long.Parse).ToArray();
                tds[i] = new Model() { t = td[0], d = td[1] };
            }

            tds = tds.OrderByDescending(x => x.d).ToArray();

            long sum = 0;
            var type = new Dictionary<long, long>();
            for (long i = 0; i < K; i++)
            {
                long tt = tds[i].t;
                if (type.ContainsKey(tt)) type[tt]++;
                else type.Add(tt, 1);

                sum += tds[i].d;
            }

            long res = (long)Math.Pow(type.Count(), 2) + sum;
            long last = K - 1;
            for (long i = K; i < N; i++)
            {
                var tt = tds[i].t;
                if (type.ContainsKey(tt)) continue;

                while (last > 0 && type[tds[last].t] <= 1)
                {
                    last--;
                }
                if (last == 0) break;

                type[tds[last].t]--;
                type.Add(tt, 1);

                sum = sum - tds[last].d + tds[i].d;
                last--;

                res = Math.Max(res, (long)Math.Pow(type.Count(), 2) + sum);
            }

            Console.WriteLine(res);
        }

        public class Model
        {
            public long d { get; set; }
            public long t { get; set; }
        }
    }
}


Measured memory_bytes: 29876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  ll n;
  
  cin >> n;
  
  vector<ll> a(n);
  vector<ll> b(n-1);
  rep(i, 0, n-1) cin >> b[i];
  
  a[0] = b[0];
  a[n-1] = b[n-2];
  
  rep(i, 1, n-1) {
    a[i] = min(b[i], b[i-1]);
  }
  
  ll sum = 0;
  rep(i, 0, n)
    sum += a[i];  
  cout << sum << "\n";

}


Measured memory_bytes: 256
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

A,B,C = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# T = [list(map(int,input().split())) for _ in range(N)]
# sys.exit()
if A + B + C >= 22 :
    print('bust')
else :
    print('win')

Measured memory_bytes: 2940
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

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

    if((A+B)<C){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }


}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> b >> c >> d;
  Cout(min(a, b) + min(c, d));
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
using  namespace  std ;
typedef  long  long ll;
 
int a [ 100050 ];
 
void  solve ()
{
    int n;
    ll ans = 1 , m = 1 , sum = 0 ;
    cin >> n;
    for ( int i = 0 ; i <= n; i ++)
    {
        cin >> a [i];
        sum+= a [i];
    }
    if ( (n> 0 && a [ 0 ]> 0) || (n == 0 && a [ 0 ]> 1 ) )// Special judgment
    {
        cout << -1<<endl;
        return ;
    }
    for ( int i = 1 ; i <= n; i ++)
    {
        m = min (m << 1 , sum); // Maximum number of nodes in layer i
        ans+= m;
        if (a [i]> m)
        {
            cout << -1 <<endl;
            return ;
        }
        m-= a [i]; // Number of non-leaf nodes in layer i
        sum-= a [i]; // Number of leaf nodes after layer i + 1
    }
    cout << ans << endl ;
}
int  main ()
{
    ios :: sync_with_stdio ( 0 );
    cin .tie ( 0 ); cout .tie ( 0 );
    solve ();
    return  0 ;
}

Measured memory_bytes: 4040
#include<iostream>
#include<set>
using namespace std;
int main() {
    string s;
    int k;
    cin >> s >> k;
    set <string> a;
    for( int i = 1 ; i <= k ; i++ ) {
        for( int j = 0 ; j < s.length() ; j++ ) {
            if( j + i <= s.length() ) a.insert( s.substr( j , i ) );
        }
    }
    auto j = a.begin();
	for ( int i = 0 ; i < k - 1 ; i++ ){ 
      j++;
    }
	  cout << *j << endl;
}

Measured memory_bytes: 4044
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::BinaryHeap;
fn main() {
    input!{
        n: usize,
        k: usize,
        td: [(usize, i64);n],
    }
    let mut data = vec![vec![];n];
    for &(t,d) in &td {
        data[t-1].push(d);
    }
    for v in &mut data {
        v.sort();
        v.reverse();
        if v.len() == 0 {
            v.push(-(1<<50)/10);
        }
    }
    data.sort_by(|x,y|{
        y[0].cmp(&x[0])
    });
    // println!("{:?}", data);
    let mut cur:i64 = 0;
    let mut que = BinaryHeap::new();
    for i in 0..k {
        cur += data[i][0];
        for j in 1..data[i].len() {
            que.push(data[i][j]);
        }
    }
    for i in k..n {
        for j in 0..data[i].len() {
            que.push(data[i][j]);
        }
    }
    let mut res:i64 = cur + ((k*k) as i64);
    for x in (1..k).rev() {
        let v = data[x][0];
        let w = *que.peek().unwrap();
        if v < w {
            que.pop();
            cur += w;
            que.push(v);
            cur -= v;
        }
        res = std::cmp::max(res, cur+((x*x) as i64));
    }
    println!("{}", res);
}

Measured memory_bytes: 16636
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
int p[262144];
bool mx[262144];
int c1[262144],c2[262144];
int wz1[4194304],wz2[4194304],pre1[4194304],pre2[4194304],tim1[4194304],tim2[4194304],num1=0,num2=0;
void add(int wz,int val1,int val2,int tim)
{
	for(int i=wz;i>0;i-=(i&(-i)))
	{
		if(val1>c1[i])
		{
			wz1[num1]=i;
			pre1[num1]=c1[i];
			tim1[num1]=tim;
			num1++;
			c1[i]=val1;
		}
		if(val2>c2[i])
		{
			wz2[num2]=i;
			pre2[num2]=c2[i];
			tim2[num2]=tim;
			num2++;
			c2[i]=val2;
		}
	}
}
void query(int wz,int& val1,int& val2)
{
	val1=-999999;
	val2=0;
	for(int i=wz;i<=n;i+=(i&(-i)))
	{
		if(c1[i]>val1)
		{
			val1=c1[i];
		}
		if(c2[i]>val2)
		{
			val2=c2[i];
		}
	}
}
void del(int tim)
{
	while(num1)
	{
		if(tim1[num1-1]!=tim)
		{
			break;
		}
		num1--;
		c1[wz1[num1]]=pre1[num1];
	}
	while(num2)
	{
		if(tim2[num2-1]!=tim)
		{
			break;
		}
		num2--;
		c2[wz2[num2]]=pre2[num2];
	}
}
bool chk2(int val,int val1,int val2)
{
	if(val<0)
	{
		return false;
	}
	if(val&1)
	{
		return val<=val1;
	}
	return val<=val2;
}
bool chk(int numx,int numy,int mxx,int mxy,int m)
{
	int val1,val2;
	query(mxx,val1,val2);
	if(chk2(numy-numx+m,val1,val2))
	{
		return true;
	}
	query(mxy,val1,val2);
	return chk2(numx-numy+m,val1,val2);
}
int main()
{
	int last=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		if(p[i]>last)
		{
			mx[i]=true;
			last=p[i];
		}
		c1[i]=-999999;
		c2[i]=0;
	}
	int m=0;
	for(int i=n;i>=1;i--)
	{
		int val1,val2;
		query(p[i],val1,val2);
		if(mx[i])
		{
			m++;
			add(p[i],val1+2,val2+2,i);
		}
		else
		{
			add(p[i],val2+1,val1+1,i);
		}
	}
	int numx=0,numy=0,mxx=1,mxy=1;
	if(!chk(numx,numy,mxx,mxy,m))
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		del(i);
		if(mx[i])
		{
			m--;
		}
		int numx2=numx,numy2=numy,mxx2=mxx,mxy2=mxy;
		if(p[i]>=mxx)
		{
			mxx2=p[i];
			numx2++;
		}
		if(p[i]>=mxy)
		{
			mxy2=p[i];
			numy2++;
		}
		if(chk(numx2,numy,mxx2,mxy,m))
		{
			putchar('0');
			numx=numx2;
			mxx=mxx2;
		}
		else
		{
			putchar('1');
			numy=numy2;
			mxy=mxy2;
		}
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 52480
#pragma warning (disable :4996)
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = cos(-1.0);
const double eps = 1e-12;
#define For(i,n,m) for(int i=n;i<=m;++i)

map<string, int> a;
int n;
string s;
int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	while (n--) {
		cin >> s;
		++a[s];
	}
	cout << a.size() << "\n";
	return 0;
}




Measured memory_bytes: 19244
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int a,b,ans=-1;
    cin>>a>>b;
    b*=10;
    int now=b;
    while(now<b+10){
        if(floor(now*0.08)==a){
            ans=now;
            break;
        }
        ++now;
    }
    cout<<ans;
    return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

i32 N,M,X,C[16],A[16][16];
inline void pre(){
    N=read();
    M=read();
    X=read();
    f(i,1,I,N){
        C[i]=read();
        f(j,1,J,M) A[i][j]=read();
    }
}

inline i32 ans(){
    i32 Ans=1e9,U=(1<<N)-1;
    f(i,1,I,U){
        i32 Cst=0,Us[16]={0};
        f(j,1,J,N)
            if( (i>>(j-1))&1 ){
                f(k,1,K,M) Us[k]+=A[j][k];
                Cst+=C[j];
            }
        bool alw=1;
        f(j,1,J,M) alw&=(Us[j]>=X);
        if(!alw) continue;
        if(Ans>Cst) Ans=Cst;
    }
    if(Ans==1e9) Ans=-1;
    return Ans;
}

int main(){
    pre();
    print( ans() );
    output();
    return 0;
}

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

string str;

void print(int a, int b)
{
    for (int i = a;i <= b;i++)
    {
        cout << str[i];
    }
    cout << endl;
    return;
}

void reverse(int a, int b)
{
    for (int i = a, j = b;i <= (a+b)/2;i++,j--)
    {
    	char temp = str[i];
    	str[i] = str[j];
    	str[j] = temp;
	}
    return;
}

void replace(int a, int b, string s)
{
    for (int i = a, j = 0;i <= b;i++, j++)
    {
    	str[i] = s[j];
	}
    return;
}

int main ()
{
    int q, a, b;
    string cmd, s;
    cin >> str;
    cin >> q;
    while(q--)
    {
        cin >> cmd;
        if (cmd == "print")
        {
            cin >> a >> b;
            print(a, b);
        }
        else if (cmd == "reverse")
        {
            cin >> a >> b;
            reverse(a, b);
        }
        else if (cmd == "replace")
        {
            cin >> a >> b >> s;
            replace(a, b, s);
        }
        cmd.clear();
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <map>
#include <vector>
typedef long long ll;
using namespace std;
int main (int argc, char const* argv[]) {
  int N, id, price, num;
  const ll LIMIT = 1000000LL;
  while (true) {
    cin >> N;
    if (N == 0) break;
    map<int,pair<bool,ll> > dict;
    vector<int> id_list;
    for (int i = 0; i < N; i += 1) {
      cin >> id >> price >> num;
      ll tmp = (ll)price * (ll)num;
      // New
      if (dict.count(id) == 0) {
        if (LIMIT <= tmp) {
          dict.insert(make_pair(id,make_pair(true,0)));
        } else {
          dict.insert(make_pair(id,make_pair(false,tmp)));
        }
        id_list.push_back(id);
      // Add
      } else {
        if (dict[id].first) continue;
        if (LIMIT <= tmp + dict[id].second) {
          dict[id].first = true;
        } else {
          dict[id].second += tmp;
        }
      }
    }
    // Print
    bool printed = false;
    for (int i = 0; i < id_list.size(); i += 1) {
      if (dict[id_list[i]].first) {
        cout << id_list[i] << endl;
        printed = true;
      }
    }
    if (!printed) cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():
	median = n // 2

	for i in range(m):
		if n % 2 == 0 and i >= n // 4:
			print(median-i, median+i+2)
		else:
			print(median-i, median+i+1)


if __name__ == '__main__':
	format_input()

	get_answer()


Measured memory_bytes: 9272
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
const int N = 2020;
int n, rt, cnt[N], sum[N], son[N], f[N];
vector<int> G[N];
char s[N];
void dfs(int u, int d = 0, int fa = 0) {
	son[u] = 0; cnt[u] = s[u] == '1'; sum[u] = 0; f[u] = 0;
	for(int i = 0; i < (int) G[u].size(); i ++) {
		int v = G[u][i];
		if(v != fa) {
			dfs(v, d + 1, u);
			sum[u] += (sum[v] += cnt[v]);
			cnt[u] += cnt[v];
			if(sum[v] > sum[son[u]]) son[u] = v;
		}
	}
	if(sum[son[u]] <= sum[u] - sum[son[u]]) {
		f[u] = sum[u] / 2;
	} else {
		f[u] = sum[u] - sum[son[u]] + min(f[son[u]], (2 * sum[son[u]] - sum[u]) / 2);
	}
}
int main() {
	scanf("%d%s", &n, s + 1);
	for(int x, y, i = 1; i < n; i ++) {
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = -1;
	for(rt = 1; rt <= n; rt ++) {
		dfs(rt);
		if(f[rt] * 2 == sum[rt]) ans = ans == -1 ? f[rt] : min(ans, f[rt]);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    if(k <= a)cout << k << endl;
    else if(k <= a + b) cout << a << endl;
    else cout << a - (k - a - b) << endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
 
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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 T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
N = int(input())
S = input()
L = [chr(i) for i in range(65, 65+26)]
H = ""
for i in range(len(S)):
  x = S[i]
  for j in range(26):
    if x == L[j]:
      H = H + L[(j+N)%26]
      break
print(H)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  ll H; cin >> H;

  ll h = 0;
  while (H > 1) {
    H /= 2;
    h++;
  }

  ll ans = 1;
  REP(i, 0, h + 1) ans *= 2;
  ans -= 1;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;

int n, num, x, y;
struct node {
    int p[10];
    inline bool operator == (const node &a) const {
        for (R int i = 1; i <= n; ++i)
            if (p[i] != a.p[i]) return 0;
        return 1;
    }
} a, b, c;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    read(n);
    for (R int i = 1; i <= n; ++i) read(a.p[i]);
    for (R int i = 1; i <= n; ++i) read(b.p[i]);
    for (R int i = 1; i <= n; ++i) c.p[i] = i;
    do {
        ++num;
        if (c == a) x = num;
        if (c == b) y = num;
    } while (next_permutation(c.p + 1, c.p + 1 + n));
    cout << abs(x - y) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	N := nextInt()
	x := 0
	if N >= 10 {
		x += 9
	} else {
		x += N
	}
	if N >= 1000 {
		x += 900
	} else if N >= 100 {
		x += N - 99
	}
	if N >= 100000 {
		x += 90000
	} else if N >= 10000 {
		x += N - 9999
	}
	fmt.Fprint(out, x, "\n")
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k <= a) {
    cout << k;
  } else if (k <= a + b) {
    cout << a;
  } else {
    cout << a - (k - a - b);
  }

  return 0;
}


Measured memory_bytes: 3636
s = STDIN.gets.chomp

d1 = 0
d2 = 0
s.each_char.with_index do |c, i|
  if i.even?
    d2 += 1 if c == '1'
    d1 += 1 if c == '0'
  else
    d1 += 1 if c == '1'
    d2 += 1 if c == '0'
  end
end

STDOUT.puts d1 > d2 ? d2 : d1

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

int main() {
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int dp[n];
    dp[0]=0; dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++){
        //dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
        int temp=1;
        int mindp=dp[i-1]+abs(a[i-1]-a[i]);
        while(temp<=k&&i-temp>=0){
            mindp=min(mindp,dp[i-temp]+abs(a[i]-a[i-temp]));
            temp++;
        }
        dp[i]=mindp;
    }
    cout << dp[n-1] << endl;
    
}

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

const long MOD = 1e9+7;
int n;
struct Triple {
  char c[3];
};
map<vector<char>, long> memo[1000];

bool ok(char last[3], char c) {
  string s = string(last, 3) + c;
  if (s.find("AGC")!=string::npos) {
    return false;
  }
  for(int i=0;i<3;i++){
    string t = "";
    int j=0;
    while(j<4){
      if (i == j) {
        t += s[j+1];
        t += s[j];
        j += 2;
      } else {
        t += s[j];
        j += 1;
      }
    }
    if (t.find("AGC")!=string::npos) {
      return false;
    }
  }
  return true;
}
long dfs(char last[3], int cur) {
  if (cur == n) {
    return 1;
  }
  vector<char> key(last, last + 3);
  if (memo[cur].find(key) != memo[cur].end()) {
    return memo[cur][key];
  }
  int ret = 0;
  for(char c: {'A','G','C','T'}) {
    if(ok(last, c)) {
      char next_last[3] = {last[1], last[2], c};
      ret = (ret + dfs(next_last, cur+1)) % MOD;
    }
  }
  memo[cur][key] = ret;
  return ret;
}
int main() {
  cin>>n;
  char init[3]={'T','T','T'};
  cout <<dfs(init, 0)<<endl;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
int a[3];
namespace NB {
	
	int main(){
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		cout<<a[0]+a[1]<<"\n";
		return 0;
	}
	
}
int main(){
	return NB::main();
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;

#define MP make_pair
#define F first
#define S second

int main(){
	ll n,m;
    cin >> n >> m;
    ll s[n][m];
    ll light[m];
    ll p[m];
    fill((ll*)light,(ll*)light+m,0);
    fill((ll*)s,(ll*)s+n*m,0);
    
    for(int i=0;i <m;i++){
    	int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int tmp;
            cin >>tmp;
        	s[tmp-1][i]=1;
        }
    }
    for(int i=0;i<m;i++){
    	cin >> p[i];
    }

    ll ans=0;
    for (int bit = 0; bit < (1 << n); ++bit) { //全部でN個
        fill((ll*)light,(ll*)light+m,0);
		for (int i = 0; i < n; ++i) {
        	if (bit & (1 << i)){
            	for(int j=0;j<m;j++){
                	light[j]+=s[i][j];
                }
	    	}
        }
        bool f=true;
        for(int i=0;i<m;i++){
        	if(light[i]%2!=p[i]) f=false;
        }
        if(f){ ans++;}
	}
    cout << ans << endl;
}

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

using namespace std ;

int main (){

    long long a , b ;

    cin >> a >> b ;

    if (a>12)
        b=b;
    else if (a>5)
        b/=2 ;
    else
        b=0 ;

    cout << b ;

    return 0 ;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n = lread();
    auto a = aryread();
    auto b = aryread();
    long kill;
    foreach (i; iota(0, n))
    {
        long left = min(a[i], b[i]);
        b[i] -= left;
        a[i] -= left;
        long right = min(a[i + 1], b[i]);
        b[i] -= right;
        a[i + 1] -= right;
        
        kill += left + right;
    }
    kill.writeln();
}

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

int main(){
  int ans=0;
  string s,t="CODEFESTIVAL2016";
  cin>>s;
  for(int i=0;i<s.size();i++){
    ans+=(s[i]!=t[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        int a[] =new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int num =0;
        
        for(int i=0;i<N-2;i++){
            if(a[i]<a[i+1] && a[i+1]<a[i+2] || a[i]>a[i+1]&&a[i+1]>a[i+2]){
                num +=1;
            }
        }
        System.out.println(num);
        
    }
}


Measured memory_bytes: 35660
N, M = map(int, input().split())
P = [0] * 10**5
score, penalty = 0, 0
for i in range(M):
    p, s = map(str, input().split())
    p = int(p)
    if s == 'AC' and P[p-1] != -1:
        penalty += P[p-1]
        score += 1
        P[p-1] = -1
    elif P[p-1] != -1:
        P[p-1] += 1
print(score, penalty)


Measured memory_bytes: 3828
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

const int MAX_V = 101010;

struct edge { int to; LL cap; int rev; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, LL cap) {
	G[from].emplace_back(edge{ to,cap,(int)G[to].size() });
	G[to].emplace_back(edge{ from,0,(int)G[from].size() - 1 });
}

void bfs(int s) {
	for (int i = 0; i < MAX_V; i++)level[i] = -1;
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()) {
		int v = que.front();
		que.pop();
		for (int i = 0; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

LL dfs(int v, int t, LL f) {
	if (v == t)return f;
	for (int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0LL;
}

LL max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0)return flow;
		for (int i = 0; i < MAX_V; i++)iter[i] = 0;
		int f;
		while ((f = dfs(s, t, INF<LL>())) > 0) {
			flow += f;
		}
	}
}


int x, y, e;
int s = 99999, t = 100000;
int main() {
	cin >> x >> y >> e;
	REP(i, x)add_edge(s, i, 1);
	REP(j, y)add_edge(200 + j, t, 1);
	REP(i, e) {
		int a, b;
		cin >> a >> b;
		add_edge(a, 200 + b, 1);
	}
	cout << max_flow(s,t) << endl;
}


Measured memory_bytes: 6752
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

ll a, b;

ll calc(ll x){
	ll ret = (a*x) / b;
	ret -= a * (x / b);
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> a >> b >> n;
	ll l = 0, r = n+1;
	int cnt = 0;
	while(r - l > 1 && cnt < 1000000){
		ll x1 = (l*2 + r) / 3;
		ll x2 = (l + r*2) / 3;
		if(calc(x1) > calc(x2)) r = x2;
		else l = x1;
		cnt++;
	}
	ll ans = calc(l);
	chmax(ans, calc(l+1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
N = int(input())

v = list(map(int, input().split()))  # Ni個目の具材の価値

if len(v) <= 2:
    print(sum(v) / 2)
else:
    v = list(sorted(v))

    result = 0

    while (True):

        v = sorted(v)
        l = v[0:2]

        v.append(sum(l) / 2)
        v = v[2:]

        if len(v) <= 2:
            break

    print(sum(v) / 2)


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

using namespace std;

int main(){
  int n; cin>>n;
  double ans = 0;
  for(int i=0;i<n;i++){
    double x; string u;
    cin>>x; cin>>u;
    if(u[0]=='B'){ ans+=x*3.8e5; }
    else { ans+=x; }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int H, W;
    while (1){
        cin >> H >> W;
        for(int i=0;i<H;i++){
            if (i+1==1 | i+1==H) for(int i=0;i<W;i++) cout << '#';
            else{
                for(int j=0;j<W;j++){
                    if (j+1==1 | j+1==W) cout << '#';
                    else cout << '.';
                    }
            }
            cout << endl;
        }
    if (H==0 && W==0) break;
    cout << endl;
    }
}


Measured memory_bytes: 3072
use std::collections::HashMap;

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let s = getline();
    let vec: Vec<_> = s.trim().split(' ').collect();
    let x: i32 = vec[0].parse().unwrap();
    let y: i32 = vec[1].parse().unwrap();

    let mut group_hash: HashMap<i32, i32> = HashMap::new();

    for n in vec![1, 3, 5, 7, 8, 10, 12].iter() {
        group_hash.insert(*n, 1);
    }

    for n in vec![4, 6, 9, 11].iter() {
        group_hash.insert(*n, 2);
    }

    group_hash.insert(2, 3);

    let ans = if group_hash.get(&x) == group_hash.get(&y) {
        "Yes"
    } else {
        "No"
    };

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


Measured memory_bytes: 4352
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    s,t=split(chomp(readline()))
    a,b=parseMap(split(readline()))
    u=chomp(readline())
    a=ifelse(u==s,a-1,a)
    b=ifelse(u==t,b-1,b)
    println("$a $b")
end
main()

Measured memory_bytes: 110520
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
n = int(input())
x_list = []
y_list = []
N = 1
m = 2
d_sum = 0
for i in range(2, n + 1):
    N *= i
    m *= (i - 1)
for i in range(0, n):
    x, y = map(int, input().split())
    x_list.append(x)
    y_list.append(y)

for i in range(0, n - 1):
    for j in range(i + 1, n):
        d_sum += m * math.sqrt((x_list[i] - x_list[j])**2 + (y_list[i] - y_list[j])**2)
print(d_sum / N)

Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int n, y, i, j, k, t;
	scanf("%d %d", &n, &y);

	for(k = 0;k <= n;++k){
		t = n - k;
		for(j = 0;j <= t;++j){
			if(k*1000 + j*5000 + (t-j)*10000 == y){
				printf("%d %d %d\n", t-j, j, k);
				return 0;
			}
		}
	}

	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
n,m,x,y = map(int, input().split())
*xl, = map(int, input().split())
*yl, = map(int, input().split())
for i in range(x,y+1):
    if x<i<=y and max(xl)<i<=min(yl):
        print("No War")
        exit()
print("War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

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


Measured memory_bytes: 1792
from statistics import mean
from typing import List
import sys


def read_data(file_name: str, std_in=True):
    satisfactions_list = list()
    file = sys.stdin if std_in else open(file_name, 'r')
    days = int(file.readline().rstrip())
    satisfaction_decreases = [int(c) for c in file.readline().rstrip().split(" ")]
    for i in range(days):
        satisfactions_list.append([int(c) for c in file.readline().rstrip().split(" ")])
    if not std_in:
        file.close()
    return days, satisfaction_decreases, satisfactions_list


class Contest:
    def __init__(self, _type: int, satisfactions: List[int], satisfaction_decrease: int, weight=2):
        self.times_on_bench = list()
        self.last_time_on_bench = 0
        self.weight = weight

        self.dissatisfaction = 0
        self.type = _type
        self.satisfactions = satisfactions
        self.satisfaction_decrease = satisfaction_decrease

    def __getitem__(self, key: int):
        return self.satisfactions[key - 1]

    def __str__(self):
        return str(self.type)

    def __repr__(self):
        return f"Contest(_type={self.type}, satisfactions={self.satisfactions}, satisfaction_decrease={self.satisfaction_decrease})"

    def heuristic(self, day):
        # return self[day] - self.weight*(self.dissatisfaction - self.satisfaction_decrease)
        return self[day] - self.weight*self.dissatisfaction

    def winner(self):
        self.dissatisfaction = 0

        self.times_on_bench.append(self.last_time_on_bench)
        self.last_time_on_bench = 0

    def loser(self):
        self.dissatisfaction -= self.satisfaction_decrease

        self.last_time_on_bench += 1

    def make_weight(self):
        return mean(self.times_on_bench) if len(self.times_on_bench) else 2


def get_best(contests: List[Contest], day: int):
    # improve this by optimistically making everyone a loser and then going back to undo that for the winner
    best = contests[0]
    for contest in contests:
        if contest.heuristic(day) > best.heuristic(day):
            best = contest
    return best


def main(file_name="input.txt"):
    contests = list()
    days, satisfaction_decreases, satisfactions_list = read_data(file_name)
    picks = list()

    for (_type, (satisfactions, satisfaction_decrease)) in enumerate(zip(zip(*satisfactions_list), satisfaction_decreases), start=1):
        contests.append(Contest(_type, satisfactions, satisfaction_decrease))

    for day in range(days):
        best = get_best(contests, day + 1)
        for contest in contests:
            if contest.type == best.type:
                contest.winner()
                picks.append(contest)
            else:
                contest.loser()

    weights = [contest.make_weight() for contest in contests]
    contests = list()

    for (_type, (satisfactions, satisfaction_decrease, weight)) in enumerate(zip(zip(*satisfactions_list), satisfaction_decreases, weights), start=1):
        contests.append(Contest(_type, satisfactions, satisfaction_decrease, weight))

    return "\n".join([str(pick) for pick in picks])


if __name__ == "__main__":
    print(main("input.txt"))


Measured memory_bytes: 11804
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

const int N=2e5+1;
char t[N];
int main() {
	assert(scanf("%s", t)==1);
	int n=strlen(t), n1=std::count(t, t+n, '1');
	long long ans=0;
	for(int i=1; i<=n1; ++i) ans+=(i+1)/2;
	int len=0, pair=0;
	for(int i=0; i<n; ++i) {
		if(t[i]=='0')
			t[len++]='0';
		else if(i+1==n || t[i+1]=='0')
			t[len++]='1';
		else {
			++pair;
			++i;
		}
	}
	int no=0, ne=0;
	for(int i=0; i<len; i+=2) no+=t[i]-'0';
	for(int i=1; i<len; i+=2) ne+=t[i]-'0';
	n1=n=0;
	for(int i=0; i<len; ++i) {
		if(t[i]=='1') {
			if(n&1) {
				ans+=pair+n1+no;
				std::swap(no, ne);
				--n;
			}
			++n1;
			--no;
		}
		t[n++]=t[i];
	}
	no=ne=0;
	for(int i=n; i--; ) {
		if(t[i]=='1')
			++no;
		else {
			ans+=pair+n1-ne;
			std::swap(no, ne);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >>A>>B;
  if(A >= 13)
    cout << B << endl;
  if(A <= 12 && A >= 6)
    cout << B / 2 << endl;
  if(A <= 5)
    cout << 0 << endl;
}
    

Measured memory_bytes: 256
#include "stdio.h"

int people;
int get;
int now[1000] = {};
long long int place[100001] = {};
long long int time;
int dir[100001] = {};
long long int stop;

int main() {
	scanf("%d %lld %d", &people, &time, &get);
	for (int i = 1; i <= people; i++) {
		scanf("%lld %d", &place[i],&dir[i]);
	//	printf("%lld\n", place[i + 1]);
	}
	for (int i = 0; i < get; i++) {
		scanf("%d", &now[i]);
	//	printf("%lld\n", place[now[i]]);
		if (dir[now[i]] == 1) {
			stop = place[now[i]] + time;
			for (int j = now[i]+1; j <= people; j++) {
				if (dir[j] == 2) {
					if (place[j] - place[j - 1] > time * 2)stop = place[j] - time;
					else stop = place[j] / 2 + place[j - 1] / 2;
					break;
				}
				stop = place[now[i]] + time;
			}
			if (stop > place[now[i]] + time)stop = place[now[i]] + time;
			printf("%lld\n", stop);
		}
		else{
			stop = place[now[i]] - time;
			for (int j = now[i] - 1; j >= 1; j--) {
				if (dir[j] == 1) {
					if (place[j + 1] - place[j] > time * 2)stop = place[j] + time;
					else stop = place[j] / 2 + place[j + 1] / 2;
					break;
				}
				stop = place[now[i]] - time;
			}
			if (stop < place[now[i]] - time)stop = place[now[i]] - time;
			printf("%lld\n", stop);
		}
	}

	return 0;
}

Measured memory_bytes: 2200
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Mon Dec 24 16:17:15 2018
//
package main

import "fmt"

func pow100(n int) int {
	if n == 0 {
		return 1
	}
	return 100 * pow100(n-1)
}

func main() {
	var D, N int
	fmt.Scan(&D, &N)

	if N == 100 {
		N++
	}

	fmt.Println(N * pow100(D))
}


Measured memory_bytes: 512
r = l = p = lp = 0
for c in input():
    if c != p:
        if c == '<':
            r -= min(l, lp)
        p = c
        lp = l
        l = 0
    l += 1
    r += l
if p == '>':
    r -= min(l, lp)   
print(r)


Measured memory_bytes: 4104
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,a=0,b=0;
	vector<int>p(9);
	rep(i,9)cin>>p[i];
	if(p[0]-p[1]==p[3]-p[4]&&p[0]-p[1]==p[6]-p[7]&&p[1]-p[2]==p[4]-p[5]&&p[1]-p[2]==p[7]-p[8])cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int H,W,N;
int sr, sc;
string s,t;
int l[200100],r[200100],u[200100],d[200100];

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

  cin>>H>>W>>N>>sr>>sc>>s>>t;

  l[N]=d[N]=1;
  r[N]=W;
  u[N]=H;

  bool good = 1;
  for(int i=N-1;i>=0;i--) {
    l[i]=l[i+1],r[i]=r[i+1],d[i]=d[i+1],u[i]=u[i+1];
    switch (t[i]) {
    case 'U':
      u[i] = min(u[i]+1, H);
      break;
    case 'D':
      d[i] = max(d[i]-1, 1);
      break;
    case 'L':
      r[i] = min(r[i]+1, W);
      break;
    case 'R':
      l[i] = max(l[i]-1, 1);
      break;
    }
    // cout << i << ' ' << l[i] << ' ' << r[i] << ' ' << d[i] << ' ' << u[i] << endl;
    switch (s[i]) {
    case 'U':
      d[i]++;
      break;
    case 'D':
      u[i]--;
      break;
    case 'L':
      l[i]++;
      break;
    case 'R':
      r[i]--;
      break;
    }
    // cout << i << ' ' << l[i] << ' ' << r[i] << ' ' << d[i] << ' ' << u[i] << endl;
    if (d[i] > u[i] || l[i] > r[i]){
      good=0;
      break;
    }
  }

  if (!(l[0]<=sc && sc<=r[0] && d[0]<=sr && sr<=u[0])) good=0;

  cout << (good ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 3992