akhauriyash/Code-Regression huggingface dataset:
// 参考: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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

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

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

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

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

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

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

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        svec: [String; n],
    };

    let mut set: HashSet<&String> = HashSet::new();

    for i in 0..n {
        if !set.contains(&svec[i]) {
            set.insert(&svec[i]);
        }
    }

    println!("{}", set.len());

}


Measured memory_bytes: 18524
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if dp[p - 2] == None or p == 1:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Measured memory_bytes: 11028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 


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

    if(ans.length() == 2){
        cout << ans << endl;
    }
    else{
        for(int i = 2; i >= 0; i--){
            cout << ans[i];
        }
        cout << endl;
    }
}

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

#define rep(X,Y) for(int (X) = 0; (X) < (Y); ++(X))
typedef long long ll;
typedef pair<int, int> pii;

#define all(X) (X).begin(),(X).end()
#define pb push_back
#define eb emplace_back
#define rrep(X,Y) for(int (X)=(Y)-1; (X) >= 0; --(X))
#define X first
#define Y second
#define reps(X,Y,Z) for(int (X)=(Y); (X) <= (Z); ++(X))
#define sz size()
#define in(i,j,k) ((i) >= (j) && (i) <= (k))

#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())

int H,W;

//int dx[2][6] = {{0,1,-1,1,0,1},{-1,0,-1,1,-1,0}};
int dx[2][6] = {{-1,0,-1,1,-1,0},{0,1,-1,1,0,1}};
int dy[6] = {-1,-1,0,0,1,1};

bool used[128][128];
int cell[128][128];

queue<pii> q;


int main(){
    int ans =0;
    cin >> W >> H;
    rep(i,H)rep(j,W) cin >> cell[i+1][j+1];
    q.push(pii(0,0));

    while(!q.empty()){
        pii t = q.front();q.pop();
        int y = t.X,x = t.Y;
        //cout << "(" << y << "," << x << ")" << endl;
        if(used[y][x])continue;
        used[y][x]=1;
        rep(i,6){
            int nx = x+dx[y%2][i];
            int ny = y+dy[i];
            //cout << dy[i] << "," << dx[x%2][i] << endl;
            //cout << "~(" << ny << "," << nx << ")" ;
            if( !in(ny, 0, 120) || !in(nx, 0, 120))continue;
            if(cell[ny][nx] != 0){
		//cout << "(" << x << "," << y << ")->(" << nx << "," << ny << ")" << endl;
		ans++;}

            else q.push(pii(ny,nx));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;

ll GCD(ll a,ll b){
  ll r = a % b;
  if(r==0){
    return b;
  }
  else{
    return GCD(b,r);
  }

}




vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll A,B,G;
    cin >> A>>B;
    G = GCD(A,B);

    //pairの書き換えが煩雑であるので、素数リストと指数連想配列に分ける
   map<ll,ll> prime_countG;
   vector<ll> prime_listG;
   
    //resに素数のペア(素数、その素数の指数）の配列が入る
    const auto  &resG = prime_factorize(G);
    
   rep(i,resG.size()){
       if(prime_countG[resG[i].first]==0){
           prime_listG.push_back(resG[i].first);
       }
       prime_countG[resG[i].first]+=resG[i].second;
   }
   cout<<prime_listG.size()+1<<endl;
    return 0;
}

Measured memory_bytes: 256
dic = {}
mark = ['S', 'H', 'C', 'D']
rank = [k for k in range(1, 14)]

for i in mark:
	for j in rank:
		dic[(i,j)] = 0

n = int(raw_input())
for k in range(n):
	p,r = raw_input().split()
	r = int(r)
	dic [(p,r)] += 1

for i in mark:
	for j in rank:
		if dic[(i,j)] == 0:
			print '%s %d' % (i,j)

Measured memory_bytes: 6472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			string s = cin.Next();
			if (s.Contains("00")
				|| s.Contains("11")
				|| s.Contains("22")
				|| s.Contains("33")
				|| s.Contains("44")
				|| s.Contains("55")
				|| s.Contains("66")
				|| s.Contains("77")
				|| s.Contains("88")
				|| s.Contains("99")){
				Console.WriteLine("Bad");
			} else {
				Console.WriteLine("Good");
			}
		}

	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp.to!(wchar[]);
    int r, b;
    foreach (c; S) {
        switch (c) {
            case '0':
                ++r;
                break;
            case '1':
                ++b;
                break;
            default:
        }
    }
    writeln(min(r, b) * 2);
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;
	vi arr (N); 
	F0R(i, N) cin >> arr[i];

	ll AS, BS, CS, DS;
    AS = 0;
    BS = 0;
    CS = 0;
    DS = 0;

	int D1 = 0;
	int D2 = 1;
	int D3 = 2;

	FOR(i, 0, D1 + 1)      AS += arr[i];
	FOR(i, D1 + 1, D2 + 1) BS += arr[i];
	FOR(i, D2 + 1, D3 + 1) CS += arr[i];
	FOR(i, D3 + 1, N)      DS += arr[i];


	ll best = max(max(AS, BS), max(CS, DS)) - min(min(AS, BS), min(CS, DS));

	while (true) {
		while (abs((AS + arr[D1 + 1]) - (BS - arr[D1+1])) < abs(AS - BS)) {
			++D1;
			AS += arr[D1];
			BS -= arr[D1];
		}

		while (D3 + 1 < N && (D3 <= D2 || abs((CS + arr[D3 + 1]) - (DS - arr[D3 + 1])) < abs(CS - DS))) {
			++D3;
			CS += arr[D3];
            DS -= arr[D3];
		}

        if (D3 == N - 1) break;
        
        best = min(best, max(max(AS, BS), max(CS, DS)) - min(min(AS, BS), min(CS, DS)));

        ++D2;
        BS += arr[D2];
        CS -= arr[D2];

	}
    print(best);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    ll K;
    cin >> K;
    int ans;

    for(int i = 0; i < K; i++) {
        if(S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }

    cout << 1;

    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll h;
    cin >> h;
    ll sum = 0, cur = 1;
    while (h > 0) {
        sum += cur;
        cur *= 2;
        h /= 2;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;


int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s[i]=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();

		char[] c = new char[n];
		long r = 0;
		long g = 0;
		long b = 0;

		for ( int i=0; i<n; i++ ) {
			if ( s.charAt(i)=='R' ) {
				r++;
			} else if ( s.charAt(i)=='G' ) {
				g++;
			} else {
				b++;
			}
		}

		if ( r*g*b==0 ) {
			System.out.println(0);
			System.exit(0);
		}

		long f = 0;
		for ( int i=0; i<n-2; i++ ) {
			for ( int j=i+1; j<n; j++ ) {
				int k = 2*j-i;
				if ( k < n ) {
					if ( s.charAt(i)!=s.charAt(j) && s.charAt(j)!=s.charAt(k) && s.charAt(k)!=s.charAt(i) ) {
						f++;
					}
				}
			}
		}

		System.out.println(r*g*b-f);
	}

}


Measured memory_bytes: 27640
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int x[50],y[50],z[50];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>x[i];
    }
    for(int i=1; i<=n; i++)
    {
        cin>>y[i];
    }
    for(int i=1; i<n; i++)
    {
        cin>>z[i];
    }

    int last=x[1],sum=y[x[1]];
    for(int i=2; i<=n; i++)
    {
        int cur=x[i];
        sum+=y[cur];
        if(last<cur && (cur-last)==1)
        {
            sum+=z[last];
        }
        last=cur;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N,0);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }

    vector<int> min_(N,pow(10,9));
    long long ans=pow(10,18);
    for(int k=0; k<N; k++){
        long long tmp=x*k;
        for(int i=0; i<N; i++){
            int n = (i-k+N)%N;
            if (a[n]<min_[i]){
                min_[i]=a[n];
            }
            tmp+=min_[i];
        }
        if (tmp<ans){
            ans=tmp;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k=2,m,n,p,s,a[200040],b[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i<=n;i++)cin>>a[i];
	if(*a)
	{
		if(n||*a>1)cout<<-1;
		else cout<<1;
		return 0;
	}
	for(i=0;i++<n;)
	{
		k-=a[i];
		if(k<0)
		{
			cout<<-1;
			return 0;
		}
		b[i]=k;
		k*=2;
		if(b[i]>100000000000000)
		{
			i++;
			break;
		}
	}
	p=i;
	for(i=n;i;i--)
	{
		if(i<p)m=min(m,b[i]);
		m+=a[i];
		s+=m;
	}
	cout<<s+1;
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int h, n; cin >> h >> n;
  const int H = 2e4 + 10, INF = 1e9;
  vector<int> best(H, INF);
  best[0] = 0;
  for (int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    for (int x = a; x < H; x++) {
      best[x] = min(best[x], best[x - a] + b);
    }
  }
  int ans = INF;
  for (int x = h; x < H; x++) {
    ans = min(ans, best[x]);
  }
  cout << ans << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define ll long long


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     ll n;
     cin>>n;
     vector<int>v(100009,0);
     for(ll i=0;i<n;i++)
     {  int x;
		 cin>>x;
		 if(x==0)
		 v[1]++;
		 else
		 {v[x]++;
		 v[x-1]++;
		 v[x+1]++;}
		 
	 }
	 int maxi=0;
	 for(int i=0;i<(int)v.size();i++)
	 {
		 if(maxi<v[i])
		 maxi=v[i];
	 }
	 cout<<maxi<<"\n";
		 
	 
				
	}
		
		

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;


int main(){
    int a;
    cin>>a;
    out(3*a*a);
    return 0;
}


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

using namespace std;

int main (void) {
      int r = 0;

      cin >> r;

      if (r < 1200){
            cout << "ABC" << "\n";
      }
      if (r < 2800 && r >= 1200){
            cout << "ARC" << "\n";
      }
      if (r >= 2800){
            cout << "AGC" << "\n";
      }
      return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int n;
vector<vector<int>> to;
int dfs(int i,int k){
	if(i==1) return 0;
	if(k==n) return -100000;
	int ret;
	ret=dfs(to[i][0],k+1)+1;
	if(ret>0) return ret;
	else return -1;
}
signed main(){
	
	cin>>n;
	to.resize(n);
	rep(i,n){ 
		int a;cin>>a;
		a--;
		to[i].push_back(a);
	}
	cout<<dfs(0,0)<<endl;
}


Measured memory_bytes: 7296
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: Chars
    }
    let b = (b[0].to_digit(10).unwrap() * 100 + b[2].to_digit(10).unwrap() * 10 + b[3].to_digit(10).unwrap()) as usize;
    let ans: usize = a * b / 100;
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(string, S);
	vector<ll> b, w;
	ll wc = 0, ans = 0, bc = 0;
	loop(i, S.size())
		if(S[i]=='W') ++wc;
	loop(i, S.size())
		if(S[i]=='B')
			ans += wc + bc++ - i;
	out(ans);
}



Measured memory_bytes: 720
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x,y;
	cin>>x>>y;
	set<int> s1;
	s1.insert(1);
	s1.insert(3);
	s1.insert(5);
	s1.insert(7);
	s1.insert(8);
	s1.insert(10);
	s1.insert(12);
	if(s1.count(x)==1 && s1.count(y)==1)
		cout<<"Yes"<<endl;
	else
	{
		if(x==2 && y==2)
			cout<<"Yes"<<endl;
		else if(s1.count(x)==0 && s1.count(y)==0 && x!=2 && y!=2)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

static const int INF = 1001001001;

using namespace std;

typedef long long ll;

int main()
{
	int n;
	int ans=0;
	cin >> n;
	vector<int> l(2*n);
	for (int i = 0; i < 2*n; ++i) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	for (int i = 0; i < n; ++i) {
		ans += min(l[2*i], l[2*i+1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import *
x,y,z,K = map(int, input().split())
m = [sorted(map(int, input().split()))[::-1] for _ in range(3)]
q = [(-sum(i[0] for i in m),(0,0,0))]
r = 0
s = set()
for _ in range(K):
    v,a = heappop(q)
    v = -v
    print(v)
    for p in ((0,0,1),(0,1,0),(1,0,0)):
        p = tuple(i+j for i,j in zip(p,a))
        if not p in s and all(i<j for i,j in zip(p,(x,y,z))):
            s.add(p)
            heappush(q, (-sum(i[j] for i,j in zip(m,p)), p))



Measured memory_bytes: 5076
#include <iostream>
#include <iomanip>
#include <math.h>

int main() {
    double r;
    std::cin >> r;

    double area = M_PI * r * r;
    double circ = 2 * M_PI * r;
    std::cout << std::fixed << std::setprecision(5) << area << " " << circ;
    return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[2*i+1] + node[2*i+2];
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }

    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    int q;
    cin >> q;

    vector<int> sv(s.size());
    vector<int> tv(t.size());

    rep(i, s.size()) {
        if (s[i] == 'A') sv[i] = 1;
        else sv[i] = 2;
    }

    rep(i, t.size()) {
        if (t[i] == 'A') tv[i] = 1;
        else tv[i] = 2;
    }

    SegmentTree seg_s(sv);
    SegmentTree seg_t(tv);

    rep(i, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        if (seg_s.getsum(a, b+1) % 3 == seg_t.getsum(c, d+1) % 3) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>;
#define vi vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false);
#define FIX(a) cout << fixed << setprecision(a)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always

int main() {
    ios
    
    string s; cin >> s;
    int a[26] = {0};
    rep(i, SZ(s)) {
        a[s[i] - 'a']++;
    }
   
    int odd = 0, even = 0;
    rep(i, 26) {
        if (a[i] % 2 == 0) even++;
        else odd++;
    }
    
    if (SZ(s) % 2 == 0) {
        cout << odd / 2 + (odd % 2) << endl;
    } else {
        cout << odd / 2 + !(odd % 2) << endl;
    }
    
    
    
    
    
}

/*
 
 回文にできるようなセットにしたい
 回文を作るわけではない
 
 1. 中心以外は偶数個にしたらええ
 
 ritscamp
 ritsstir
 
 奇数個のを入れ替えるのが最善
 
 
 
 
 
 
 */



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

int main()
{
    int A,B;
    int H,M;
    cin>> A >> B >> H >> M;
    double H_deg=(H%12)*30;
    H_deg+=(0.5*M);
    double M_deg=6*M;
    double deg=fabs(H_deg-M_deg);
    double rad=M_PI*deg/180.;
    double x_double=A*A+B*B-2*A*B*cosf128(rad);
    cout << setprecision(10)<<sqrt(x_double) << endl;
}

Measured memory_bytes: 4300
const MOD: i64 = 1000_000_000 + 7;
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let a: Vec<i64> = scn.vec(n);
        let mut sum: i64 = a.iter().sum();
        
        let mut result = 0;
        for &x in a.iter() {
            sum -= x;
            result += (sum % MOD * x % MOD) % MOD;
            result %= MOD;
        }
        println!("{}", result % MOD);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2708
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int G[9];
int J[9];

const int sum = 19 * 9;

int solve(int now, int rest, int gp){
  if(now == 9){
    if(gp + gp > sum) return 1;
    else return 0;
  }

  int ret = 0;
  REP(i,9) if(rest & (1 << i)){
    int g = G[i];
    int j = J[now];

    if(g > j) ret += solve(now+1, rest^(1<<i), gp + g + j);
    else      ret += solve(now+1, rest^(1<<i), gp);
  }

  return ret;
}

int main(){
  int n = getInt();
  const int fact = 2*3*4*5*6*7*8*9;
  while(n --> 0){
    REP(i,9) G[i] = getInt();
    REP(i,9) J[i] = getInt();
    double ans = (double)solve(0,(1<<9)-1,0) / fact;
    printf("%.5f %.5f\n",ans,1.0-ans+1e-10);
  }
  return 0;
}

Measured memory_bytes: 872
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;
typedef long long ll;

int cnt[200200];
int main()
{
 	ios_base::sync_with_stdio(0);
 	int n, k;
 	cin >> n >> k;
 	for(int i=0; i<n; i++) {
 		int x;
 		cin >> x;
 		cnt[x]++;
 	}
 	sort(cnt+1, cnt+n+1);
 	int sum=0;
 	for(int i=0; i<k; i++) {
 		sum += cnt[n-i];
 	}
 	cout << n-sum;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

char S[100002];
char T[100002];
int Ssum[100001];
int Tsum[100001];
int V[256];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int q;
    V['A'] = 1;
    V['B'] = 2;
    cin >> S + 1 >> T + 1 >> q;
    int n = strlen(S + 1), m = strlen(T + 1);
    for (int i = 1; i <= n; ++i)
        Ssum[i] = Ssum[i - 1] + V[S[i]];
    for (int i = 1; i <= m; ++i)
        Tsum[i] = Tsum[i - 1] + V[T[i]];
    while (q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int s = Ssum[b] - Ssum[a - 1];
        int t = Tsum[d] - Tsum[c - 1];
        printf(s % 3 == t % 3 ? "YES\n" : "NO\n");
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007

int main() {
	ios;
	int n;
	cin>>n;
	set <string> s;
	string x;
	for (int i = 0; i < n; i++) {
		cin>>x;
		s.insert(x);
	}
	cout<<sz(s);
	
	return 0;
}


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

int main()
{
	int n, m, k,s;//n個,m面ダイス
	int max;
	int p, r, i, j, t;
	double ans=0;
	scanf("%d %d %d", &n, &m, &k);
	while(n != 0)
	{
		s= m * n;
		double dic[2][s+1];//0-10000:合計がその値になる確率
		for(i=0;i<s+1;i++)
		{
			dic[1][i]=0;
			dic[0][i]=0;
		}
		dic[0][0]=1.0;
		max=0;
		for(j=0;j<n;j++)
		{
			for(p=0;p<=max+m;p++)
			{
				if(dic[0][p]>0)
				{
					for(r=1;r<=m;r++)
					{
						dic[1][p+r] += dic[0][p] * 1.0 / m;
					}
				}
				dic[0][p]=dic[1][p];
				dic[1][p]=0;
			}
			max += m;
		}
		for(t=0;t<=s;t++)
		{
			if(t<=k) ans += dic[0][t];
			else ans += (t-k) * dic[0][t];
		}
		printf("%.8f\n", ans);
		ans=0;
		scanf("%d %d %d", &n, &m, &k);
	}
	return 0;
}

Measured memory_bytes: 792
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int INF=2147483647;
int n,k,a[100];
ll ans;
ll doo(int x,int y){
	vector <int> v;
	for(int i=1;i<=x;i++)
		v.push_back(a[i]);
	for(int i=n;i>y;i--)
		v.push_back(a[i]);
	int lim=x+n-y;
	if(lim>k)
		return 0;
	else{
		lim=k-lim;
		ll sum=0;
		sort(v.begin(),v.end());
		for(int i=0;i<v.size();i++)
			if(v[i]<0&&lim>0)
				lim--;
			else
				sum+=v[i];
//		cout<<x<<' '<<y<<" "<<sum<<endl;
		return sum;
	}
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<=n;i++)
		for(int j=n;j>=i;j--)
			if(i+n-j<=k)
				ans=max(ans,doo(i,j));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
const int N = 2e5;
using namespace std;
int n,edge[N * 2 + 5],nxt[N * 2 + 5],head[N + 5],edge_cnt,sg[N + 5];
void add_edge(int u,int v)
{
    edge[++edge_cnt] = v;
    nxt[edge_cnt] = head[u];
    head[u] = edge_cnt;
}
void dfs(int u,int fa)
{
    for (int i = head[u];i;i = nxt[i])
    {
        int v = edge[i];
        if (v == fa)
            continue;
        dfs(v,u);
        sg[u] ^= sg[v] + 1;
    }
}
int main()
{
    scanf("%d",&n);
    int u,v;
    for (int i = 1;i < n;i++)
    {
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(1,0);
    if (sg[1])
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 13812
#include <stdio.h>
int binarySearch(int);
int n1,S[100000];
int main()
{
  int i,cnt=0,n2,key;
  scanf("%d",&n1);
  for(i=0;i<n1;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&n2);
  for(i=0;i<n2;i++)
    {
      scanf("%d",&key);
      if(binarySearch(key))
	cnt++;
    }
  printf("%d\n",cnt);
}
binarySearch(int key)
{
  int left=0,right=n1,mid;
  while(left < right)
    {
      mid = (left + right) / 2;
      if(S[mid] == key)
	return 1;
      if(key > S[mid])
	left = mid + 1;
      else if(key < S[mid])
	right = mid;
    }
  return 0;
}



Measured memory_bytes: 2152
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long i, N, K, Q, a;
  cin >> N >> K >> Q;
  //vector<long long> A(Q);
  map<long long, long long> Cnt;
  
  for(i = 0; i < Q; i++){
    
    cin >> a;
    Cnt[a - 1]++;
  }
  
  for(i = 0; i < N; i++){
    
    if (K <= Q - Cnt[i]){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 6912
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long
#define ull unsigned long long
#define debug(x) cerr<<#x<<"="<<x<<'\n'
//#define DEBUG

const int MOD=1e9+7;

int n;
int a[300100];
ll ans=0;

int main()
{
	#ifdef DEBUG
	clock_t tStart = clock();
	#endif
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	int num=0;
	int j=0;
	for(int i=0;i<n;i++)
 	{
        while((j<n)&&((num&a[j])==0)) 
		{
            num+=a[j];
            j++;
        }
        ans+=j-i;
        num^=a[i];
    }
    cout<<ans<<'\n';
	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> ii;

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

int A[200001];

int main(){
    ios_base::sync_with_stdio(false);
    int N, M, res = 0, acc = 0;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int p;
        string ans;
        cin >> p >> ans;
        if(A[p] == -1)continue;
        if(ans=="WA")A[p]++;
        else{
            if(A[p]!=-1){
                res+=A[p];
                A[p] = -1;
                acc+=1;
            }
        }
    }
    cout << acc << " " <<  res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N;
  int H[110000]={};
  cin >> N;

  for(int i=0;i<N;++i) cin >> H[i];
  
  bool bigger_diff= false;
  for(int i=N-1;i>0;--i){
    if(H[i]-H[i-1]< -1) bigger_diff =true;
    else if(H[i]-H[i-1]==-1) H[i-1]=H[i-1]-1;
  }
 
  if(bigger_diff) cout << "No" << endl;
  else cout << "Yes" << endl;
  

  
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
  ll n,k;
  cin>>n>>k;
  vector<ll>vec(n);
  for(ll i=0;i<n;i++) cin>>vec.at(i);
  sort(vec);
  vector<ll>sai(n-k+1);
  for(ll i=0;i<n-k+1;i++) {
    sai.at(i)=vec.at(i+k-1)-vec.at(i);
  }
  sort(sai);
  cout<<sai.at(0)<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  vector<int> B(N - 1);
  FOR(i, N - 1) cin >> B[i];
  ll ans = B[0] + B[N - 2];
  FOR(i, N - 2) { ans += min(B[i], B[i + 1]); }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);

            int count = 0;
            long i;
            long s = 0;
            for (i = 1; count < N; )
            {
                string str = i.ToString();
                s = 0;
                for (int j = 0; j < str.Length - 1; j++)
                {
                    if (Math.Abs(int.Parse(str[j].ToString()) - int.Parse(str[j + 1].ToString())) > 1)
                    {
                        // ダメ
                        s = (long)Math.Pow(10, (str.Length - j - 2));
                        i /= s;
                        i += 1;
                        i *= s;
                        break;
                    }
                }
                if (s > 0) continue;
                // OK
                count++;
                i++;
            }

            Console.WriteLine(i-1);
        }

        public static bool isLunlun(int num)
        {
            string str = num.ToString();
            for(int i = 0; i < str.Length - 1; i++)
            {
                if (Math.Abs(int.Parse(str[i].ToString()) - int.Parse(str[i + 1].ToString())) > 1) return false;
            }
            return true;
        }
    }
}


Measured memory_bytes: 15288
#include<stdio.h>
#include<stdlib.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,a=0,s=0,m,i,d[10010];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    s+=d[i];
  }
  m=s;
  for(i=0;i<n;i++){
    a+=d[i];
    m=MIN(m,abs(s-a-a));
  }
  printf("%d\n",m);
  return 0;
}


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

using namespace std;

#define ll long long int

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

    vector<vector<ll> > dp(n, vector<ll>(3));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> dp[i][j];
        }
    }
    for (int i = n-2; i >= 0; i--) {
        for (int j = 0; j < 3; j++){
            ll a = 0;
            for(int k = 0;k <3; k++){
                if(k!=j)
                    a = max(a, dp[i+1][k]);
            }
            dp[i][j] += a;
        }
    }

    cout << *max_element(dp[0].begin(),dp[0].begin()+3);
}

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

int main(void){
  int K;
  cin >> K;
  int odd=K/2,even=K/2;
  if(K%2)odd++;
  cout << odd*even << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

while m > 0:
    a_max = heapq.heappop(a)
    if a_max == 0:
        break
    heapq.heappush(a, (-1)*(-a_max // 2))
    m -= 1
print(sum(a)*(-1))

Measured memory_bytes: 20536
S = input()
T = input()
n = len(S)
m = len(T)

flag = 0
ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
        ans = S2.replace('?', 'a')
        
print(ans)

Measured memory_bytes: 3064
import math
mod = 10**9+7
N,M = map(int,input().split())
if abs(N-M) > 1:
    print(0)
elif N == M:
    print((math.factorial(N)*math.factorial(M)*2)%mod)
else:
    print((math.factorial(N)*math.factorial(M))%mod)

Measured memory_bytes: 5188
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    int m1,m2,m3,m4;
    cin>>m1>>m2>>m3>>m4;
    if(m4==1 and m1!=m3) cout<<"1";
    else cout<<"0";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        double A = scanner.nextDouble();
        double B = scanner.nextDouble();
        double C = scanner.nextDouble();
        double K = scanner.nextDouble();

        Double sum1,sum2,sum3;
        sum1 = A * Math.pow(2,K) + B + C;
        sum2 = A + B * Math.pow(2,K) + C;
        sum3 = A + B + C * Math.pow(2,K);
        int answer = 0;
        if ((sum1 >= sum2)&&(sum1 >= sum3)) {
        	answer = sum1.intValue();
        }else if ((sum2 >= sum1)&&(sum2 >= sum3)) {
        	answer = sum2.intValue();
        }else if ((sum3 >= sum2)&&(sum3 >= sum1)) {
        	answer = sum3.intValue();
        }
        System.out.println(String.valueOf(answer));

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21332