akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, M;
	cin >> N >> M;

	if (M - 2 * N >= 0) {
		cout << N + (M - 2 * N) / 4 << "\n";
	}
	else {
		cout << M/2 << "\n";
	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    cout << n * n * n << endl;
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var k = long.Parse(Console.ReadLine());
        var ab = Console.ReadLine().Split(' ');
        var a = long.Parse(ab[0]);
        var b = long.Parse(ab[1]);

        var p = Math.Ceiling(1m * a / k);
        var q =Math.Floor( 1m * b / k);

        Console.WriteLine(p<=q ? "OK":"NG");
    }
}


Measured memory_bytes: 18084
<?php

fscanf(STDIN, "%d %d", $N, $M);

define('NMAX', 1000);
define('MMAX', 2000);

$a = array();
$b = array();
$c = array();

for ($i = 0; $i < $M; ++$i) {
    fscanf(STDIN, "%d %d %d", $a[$i], $b[$i], $c[$i]);
    $c[$i] = -$c[$i];
}

$dist = array();

for ($i = 0; $i < $N; ++$i) {
    $dist[$i] = PHP_INT_MAX;
}

$dist[0] = 0;

for ($loop = 0; $loop < $N - 1; ++$loop) {
    for ($i = 0; $i < $M; ++$i) {

        if ($dist[$a[$i] - 1] == PHP_INT_MAX) continue;

        if ($dist[$b[$i] - 1] > $dist[$a[$i] - 1] + $c[$i]) {
            $dist[$b[$i] - 1] = $dist[$a[$i] - 1] + $c[$i];
        }
    }
}

$ans = $dist[$N - 1];

$negative = array();

for ($i = 0; $i < $N; ++$i) {
    $negative[$i] = false;
}

for ($loop = 0; $loop < $N ; ++$loop) {
    for ($i = 0; $i < $M; ++$i) {
        if ($dist[$a[$i] - 1] == PHP_INT_MAX) continue;

        if ($dist[$b[$i] - 1] > $dist[$a[$i] - 1] + $c[$i]) {
            $dist[$b[$i] - 1] = $dist[$a[$i] - 1] + $c[$i];
            $negative[$b[$i] - 1] = true;
        }

        if ($negative[$a[$i] - 1] == true) {
            $negative[$b[$i] - 1] = true;
        }
    }
}

if ($negative[$N - 1]) {
    echo "inf" . PHP_EOL;
} else {
    echo -$ans . PHP_EOL;
}


Measured memory_bytes: 4728
#include <stdio.h>
int main(void) {
	
    int i,x;
	i=1;
	
	scanf("%d",&x);
	
	//入力値が0ではない間
	while(x != 0){
		printf("Case %d: %d\n",i,x);
		
		i++;
		
		scanf("%d",&x);
	}
    return 0;
}


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

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

    vector<int> left(n+1, 0);
    for (int i = 0; i < n; i++){
        left.at(i+1) = max(left.at(i), a.at(i));
    }

    reverse(a.begin(), a.end());

    vector<int> rgt(n+1, 0);
    for (int i = 0; i < n; i++){
        rgt.at(i+1) = max(rgt.at(i), a.at(i));
    }

    reverse(rgt.begin(), rgt.end());

    for(int i = 0; i < n; i++){
        cout << max(left.at(i), rgt.at(i+1)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3968
import Data.List

mysort::[(Int,Int)]->[(Int,Int)]
mysort dat = let cmpr (x,_) (y,_) = compare x y in sortBy cmpr dat

indexed::[(Int,Int)]-> Int -> Int
indexed d i = let  (ans,_) = head (eat d (i-1)) in ans

eat::[(Int,Int)]->Int -> [(Int,Int)]
eat d j = let (x,n) = head d in if j < n then (x,n-j):(tail d) else eat (tail d) (j-n)

n_get::Int ->IO [(Int,Int)]
n_get 0 =return []
n_get n =do
  d<-getLine
  let a:b:[]= map read (words d)
  rest <- n_get (n-1)
  return ((a,b):rest)


main::IO()
main=do
  nkc<-getLine
  let n:k:[]= map read (words nkc)
  dat<-n_get n
  print (indexed (mysort dat) k)


Measured memory_bytes: 117628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,k;
int ans[1000009];
int main()
{
	scanf("%d%d",&m,&k);
	if(m==1)
	{
		if(k==0)
			printf("0 0 1 1");
		else
			printf("-1");
		return 0;
	}
	n=1<<m;
	if(k>=n)
	{
		printf("-1");
		return 0;
	}
	ans[n]=k;
	int cur=0;
	for(int i=1;i<=n-1;i++)
	{
		if(cur==k)
			cur++;
		ans[i]=cur;
		cur++;
	}
	for(int i=n+1;i<=2*n-1;i++)
		ans[i]=ans[2*n-i];
	ans[2*n]=k;
	for(int i=1;i<=2*n;i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 2816
yakusu = [0 for _ in range(201)]
for i in range(1, 200+1):
    for j in range(1, 200+1):
        if i*j>200:
            continue
        yakusu[i*j] += 1

N = int(input())
ans = 0
for i in range(1, N+1, 2):
    if yakusu[i] == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int gcd(int n,int m){
    if(m==0) return n;
    return gcd(m,n%m);
}
int main(void){
    int n,i,j;
    int a[100000];
    int b[100000];
    int c[100000];
    int g,max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",(a+i));
    }
    b[1]=a[0];
    c[n-2]=a[n-1];
    for(i=2;i<n;i++){
        b[i]=gcd(a[i-1],b[i-1]);
        c[n-1-i]=gcd(a[n-i],c[n-i]);
    }
    for(i=0;i<n;i++){
        if(i==0){
            if(c[i]>=max) max=c[i];
        }else if(i==n-1){
            if(b[i]>=max) max=b[i];
        }else{
            if(gcd(b[i],c[i])>=max) max=gcd(b[i],c[i]);
        }
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections;

namespace ABC110C
{
  class Program
  {
    static void Main(string[] args)
    {
      string S = Console.ReadLine();
      int n = S.Length;
      int[] valS = new int[n];

      Hashtable tableS = new Hashtable(26);
      for (int i = 0; i < n; i++) {
        if (!tableS.ContainsKey(S[i])) {
          tableS.Add(S[i], tableS.Count);
        }
        valS[i] = (int)tableS[S[i]];
      }

      string T = Console.ReadLine();
      Hashtable tableT = new Hashtable(26);
      for (int i = 0; i < n; i++) {
        if (!tableT.ContainsKey(T[i])) {
          tableT.Add(T[i], tableT.Count);
        }
        if (valS[i] != (int)tableT[T[i]]) {
          Console.WriteLine("No");
          return;
        }
      }

      Console.WriteLine("Yes");
    }
  }
}


Measured memory_bytes: 17368
// #![allow(unused_imports)]

// use text_io::*;
use proconio::*;
// use std::collections::*;
// use std::process::exit;
// use std::cmp::*;
// use itertools::Itertools;


fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    d:usize,
    }
    let mut e=0;
    for i in 0..=a {
        for j in 0..=b {
            for k in 0..=c {
                if 10*i+2*j+k==d/50 {
                    e+=1
                }
            }
        }
    }
    println!("{}",e)
}

Measured memory_bytes: 2152
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int a=gi();
        int b=gi();
        int c=gi();
        int x=gi();
        
        int C=0;
        for (int i=0; i<=a; i++) {
        	for (int j=0; j<=b; j++) {
        		for (int k=0; k<=c; k++) {
                	if(500*i+100*j+50*k==x) {
                		C++;
                	}
                }
            }
        }

	    System.out.println(C);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35248
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')cout<<s<<"es";
	else cout<<s<<"s"; 
	return 0;
}
//cout<<fixed<<setprecision(n)<<endl<<a<<endl<<b;是输出n位小数


Measured memory_bytes: 3596
from collections import OrderedDict
if __name__ == "__main__":
    NM = list(map(int, input().split()))
    n = NM[0]
    m = NM[1]
    mydict = {}
    for i in range(n):
        money_can = list(map(int, input().split()))
        money = money_can[0]
        can = money_can[1]
        if(money not in mydict.keys()):
            mydict[money] = []
        mydict[money].append(can)
    buynow = 0
    moneynow = 0

    mydict = OrderedDict(sorted(mydict.items()))
    for i in mydict.keys():
        if(buynow >= m):
            break
        for canNO in mydict[i]:
            if(buynow >= m):
                break
            if(canNO + buynow < m):
                moneynow += canNO*i
                buynow += canNO
            else:
                need = m - buynow
                moneynow += need*i
                buynow += need
        else:
            continue
    print(moneynow)

    

Measured memory_bytes: 75844
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	int x = max( { A, B, C } );
	int y = x;
	x *= pow( 2, K );

	cout << ( A + B + C + x - y ) << endl;

	return ( 0 );
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

minus=[]
abses=[]
cnt=0
for i in range(n):
    if a[i]<0:
        minus.append(1)
    elif a[i]>0:
        minus.append(0)
    else:
        minus.append(0)
        cnt+=1
    abses.append(abs(a[i]))

if sum(minus)%2==0:
    print(sum(abses))
else:
    if cnt>0:
        print(sum(abses))
    else:
        print(sum(abses)- 2*min(abses))    

Measured memory_bytes: 20020
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<double> v(N);
	rep(i, N) {
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());
	double an = v.at(0)+v.at(1);
	an /= 2;
	rep(i, N-2) {
		an += v.at(i + 2);
		an /= 2;
	}
	cout << fixed << setprecision(10);
	cout << an << endl;
	}

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 ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a+b < 10)
    cout << a+b << endl;
  else
    cout << "error" << endl;
  return 0;
}

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

int main(){
int N; string s;
cin >> N;
cin >> s;
int k = 0;
for(int j = 0; j < N; j++){
if(s[j] == 'R'){
k++;
}
}
if(k > N - k){
cout << "Yes" << endl;
}
else{
cout << "No" << endl;
}
return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(map(int,list(input())))
x = [-1]
for i in range(n-1):
    if s[i] != s[i+1]:
        x.append(i)
x.append(n-1)
t = len(x)
ans = 1

for i in range(t-1):
    if i%2 == s[0]:
        ans = max(ans,x[min(t-1,i+2*k)]-x[i])
    else:
        ans = max(ans,x[min(t-1,i+2*k+1)]-x[i])

print(ans)

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

int main() {
    while (true) {
        int z;
        cin >> z;
        if (z == 0) {
            break;
        }
        int x = 1, y = z - 1, z3 = z * z * z, max = 0;
        while (x <= y) {
            int x3 = x * x * x, y3 = y * y * y;
            if (x3 + y3 > z3) {
                y--;
            } else {
                if (max < x3 + y3) {
                    max = x3 + y3;
                }
                x++;
            }
        }
        cout << z3 - max << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

 //   freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    
    int n;cin>>n;
    ll b[n];

    ll ans[n];
    forn(i, n-1) cin>>b[i];

    forn(i, n) ans[i] = INT_MAX;
    forn(i, n-1){
    	ans[i] = min(ans[i], b[i]);
    	ans[i+1]  = min(ans[i+1], b[i]);
    }
    ll rans = 0;
    forn(i,n)rans += ans[i];
    cout<<rans;

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T,class U> void outs(T a,U b){if((ll)(a)>=inf-100||(ll)(a)<=-inf+100)out(b);else out(a);}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    vector<pair<string,string>> a,b;
    rep(bit,1<<n){
        string t,u;
        rep(i,n){
            if(bit>>i&1)t+=s[i];
            else u+=s[i];
        }
        a.eb(t,u);
    }
    rep(bit,1<<n){
        string t,u;
        rep(i,n){
            if(bit>>i&1)t+=s[n*2-1-i];
            else u+=s[n*2-1-i];
        }
        b.eb(t,u);
    }
    sort(all(a));
    sort(all(b));
    //outv(a);outv(b);
    ll ans=0;
    for(auto x:a){
        ans+=ub(b,x)-lb(b,x);
    }
    out(ans);
}

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

using namespace std;
typedef long long ll;

int a, b, c, d, e, f;
int tot=-1, tok=1;
void solve()
{
     cin >> a >> b >> c >> d >> e >> f;
     for(int i = 0; i * a * 100 <= f; i++){
        for(int j = 0; j * b * 100 <= f - i * a * 100; j++){
            int water = i * a * 100 + j * b * 100;
            if(water == 0) continue;
            for(int r = 0; r * c <= f - water; r++){
                for(int k = 0; k * d <= f - water - r * c;k++){
                        int sugarsum = k * d + r * c;
                        int sum = water + sugarsum;
                        int real = i * a * e + j * b * e;
                        if(real < sugarsum || sum >f)  continue;
                    if(sugarsum * 1.0 / sum > tok *1.0 / tot ){
                         tot = sum;
                         tok=sugarsum;
                    }
                }
            }
        }
     }
     cout<< tot <<" "<< tok <<endl;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3600
#include <cstdint>
#include <functional>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

using Int = int64_t;

auto rationalNormalize(const pair<Int, Int>& r)
{
    auto gcd = [](auto a, auto b) {
        while (true) {
            if (a == 0) {
                return b;
            }
            b %= a;
            if (b == 0) {
                return a;
            }
            a %= b;
        }
    };
    auto gcd_ = gcd(r.first, r.second);
    return make_pair(r.first / gcd_, r.second / gcd_);
};

template <typename T>
decltype(auto) operator<<(T& ost, const pair<Int, Int>& r)
{
    auto r_ = rationalNormalize(r);
    if (r_.second == 1) {
        return ost << r_.first;
    }
    else {
        return ost << r_.first << '/' << r_.second;
    }
};

int main()
{
    const string N("north"), W("west");
    while (true) {
        string s;
        cin >> s;

        if (s == "#") {
            return 0;
        }

        auto startsWith = [](const string& s, const string& prefix) {
            return s.compare(0, prefix.size(), prefix) == 0;
        };

        auto rationalSum = [](const pair<Int, Int>& a,
                              const pair<Int, Int>& b) {
            // a / b + c / d = (ad + bc) / b * d
            return rationalNormalize(make_pair(
                a.first * b.second + a.second * b.first, a.second * b.second));
        };

        auto countOccurrences = [startsWith, &W, &N](const string& s) {
            auto t = s;
            int count = 0;
            while (!t.empty()) {
                if (startsWith(t, N)) {
                    t = t.substr(N.size());
                }
                else {
                    t = t.substr(W.size());
                }
                count += 1;
            }
            return count;
        };

        auto pow = [](Int b, Int e) {
            Int r = 1;
            for (Int i = 0; i < e; ++i) {
                r *= b;
            }
            return r;
        };

        function<pair<Int, Int>(const string&)> f =
            [&f, &N, &W, countOccurrences, rationalSum, pow,
             startsWith](const string& s) -> pair<Int, Int> {
            if (s == "north") {
                return make_pair(0, 1);
            }
            else if (s == "west") {
                return make_pair(90, 1);
            }
            auto isNorth = startsWith(s, N);
            auto dir = isNorth ? s.substr(N.size()) : s.substr(W.size());
            auto a = f(dir);
            auto n = countOccurrences(dir);
            return rationalSum(a, make_pair(isNorth ? -90l : 90l, pow(2, n)));
        };

        cout << f(s) << endl;
    }
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


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

	long long n, i, j, k, MOD = 1000000007, ans, jj;
	cin >> n;

	vector<vector<long long>> dp(n + 1, vector<long long>(4, 0));
	dp[0][0] = 1;

	for (i = 0; i < n; i++) {
		for (j = 0; j < 4; j++) {
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 8) % MOD;
			jj = j | 1;
			dp[i + 1][jj] = (dp[i + 1][jj] + dp[i][j]) % MOD;
			jj = j | 2;
			dp[i + 1][jj] = (dp[i + 1][jj] + dp[i][j]) % MOD;
		}
	}
	ans = dp[n][3];
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 73396
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy" << endl;
  if(s == "Cloudy") cout << "Rainy" << endl;
  if(s == "Rainy") cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int main(){
    cin>>n;
    cout<<n*(n-1)/2-n/2<<endl;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i+j+(n%2)-1!=n)cout<<i<<" "<<j<<endl;
        }
    }return 0;
}

Measured memory_bytes: 256
x = int(input())
if x >= 1800:
    x = 1
elif x >= 1600:
    x = 2
elif x >= 1400:
    x = 3
elif x >= 1200:
    x = 4
elif x >= 1000:
    x = 5
elif x >= 800:
    x = 6
elif x >= 600:
    x = 7
elif x >= 400:
    x = 8
print(x)

Measured memory_bytes: 9172
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            //1?????????????????????
           Console.ReadLine();
            

            //????????????????????????
            string[] ss = Console.ReadLine().Split(' ');

            Array.Reverse(ss);

            Console.WriteLine(string.Join(" ", ss));
        }
    }
}

Measured memory_bytes: 17616
N, M=map(int, input().split())
net=[[0 for i in range(N)] for j in range(N)]

for i in range(M):
  a, b=map(int, input().split())
  a-=1
  b-=1
  net[a][b]=1
  net[b][a]=1
  
def f(N):
  nums=[i for i in range(1, N)]
  out=g([0], nums)
  return out

def g(order, nums):
  k=len(nums)
  if k==1:
    return [order+nums]
  else:
    out=[]
    for i in range(k-1):
      temp=g(order+[nums[i]], nums[:i]+nums[i+1:])
      out+=temp
    temp=g(order+[nums[-1]], nums[:-1])
    out+=temp
    return out
  
orderlists=f(N)
counter=0
for orderlist in orderlists:
  k=0
  for i in range(N-1):
    k+=net[orderlist[i]][orderlist[i+1]]
  if k==N-1:
    counter+=1
    
print(counter)

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

int main() {
  int A,B,C,D,E,K;
  cin >> A >> B >> C >> D >> E >> K;
  if (E-A>K) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int w,h,n;
  cin >> w>> h >> n;
  // vector<vector<bool>> vec(h+1,vector<bool>(w+1,false));
  int sqx_=w,sqy_=h,sqx=0,sqy=0;
  REP(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1)sqx=max(sqx,x);
    if(a==3)sqy=max(sqy,y);
    if(a==2)sqx_=min(sqx_,x);
    if(a==4)sqy_=min(sqy_,y);
    // if(a==1)FOR(j,1,h+1)FOR(k,1,w+1)if(k<x)vec.at(j).at(k)=true;
    // if(a==2)FOR(j,1,h+1)FOR(k,1,w+1)if(k>x)vec.at(j).at(k)=true;
    // if(a==3)FOR(j,1,h+1)FOR(k,1,w+1)if(j<y)vec.at(j).at(k)=true;
    // if(a==4)FOR(j,1,h+1)FOR(k,1,w+1)if(j>y)vec.at(j).at(k)=true;
  }
  int ans = 0;
  // FOR(j,1,h+1)FOR(k,1,w+1)if(vec.at(j).at(k))ans++;
  // cout << sqx << endl;
  // cout << sqx_ << endl;
  // cout << sqy << endl;
  // cout << sqy_ << endl;
  cout << max(0,sqx_-sqx)*max(0,sqy_-sqy) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

struct edge {
    ll cost, from, to;

    edge(ll &c, ll &f, ll &t) : cost(c), from(f), to(t) {  }

    bool operator<(edge &x) { return cost < x.cost; }
    bool operator>(edge &x) { return cost > x.cost; }
    bool operator==(edge &x) { return cost == x.cost; }
};

struct union_find {
    vll data;

    union_find(ll &size) : data(size, -1) {  }

    ll root(ll &x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

    bool merge(ll x, ll y) {
        if ((x = root(x)) == (y = root(y))) return false;

        if (data[x] > data[y]) std::swap(x, y);

        data[x] += data[y], data[y] = x;

        return true;
    }
};

void solve();

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

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    std::vector<pll> x(n), y(n);
    for (ll i = 0; i < n; i++) {
        std::cin >> x[i].first >> y[i].first;
        x[i].second = y[i].second = i;
    }

    auto compare = [](pll &a, pll &b) {
        return a.first != b.first ? a.first < b.first
                                  : a.second < b.second;
    };
    std::sort(x.begin(), x.end(), compare);
    std::sort(y.begin(), y.end(), compare);

    std::deque<edge> es;
    for (ll i = 0; i < n - 1; i++) {
        ll cost_x = x[i + 1].first - x[i].first;
        ll cost_y = y[i + 1].first - y[i].first;
        es.push_back(edge(cost_x, x[i].second, x[i + 1].second));
        es.push_back(edge(cost_y, y[i].second, y[i + 1].second));
    }

    auto kruskal = [&]() {
        std::sort(es.begin(), es.end());

        ll res = 0; union_find uf(n);
        for (edge e : es) if (uf.merge(e.from, e.to))
            res += e.cost;

        return res;
    };

    std::cout << kruskal() << '\n';
}


Measured memory_bytes: 11900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lolololololol ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
vector<int>pat;
int a[200005];
bitset<200005>vis;
int main(){ lolololololol
	int n; long long k; cin>>n>>k;
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	vis=0;
	int nw=1; pat.push_back(nw);
	while(!vis[nw]){
		vis[nw]=1;
		nw=a[nw];
		pat.push_back(nw);
	} pat.pop_back();
	int idx=0;
	for(; idx<pat.size(); idx++){
		if(pat[idx]==nw) break;
	}
//	for(int i:pat) cout<<i<<" "; cout<<endl;
	if(k<idx) cout<<pat[k]<<endl;
	else{
		vector<int>newpath;
		for(int i=idx; i<pat.size(); i++)
			newpath.push_back(pat[i]);
		k-=idx;
//		for(int i:newpath) cout<<i<<" "; cout<<endl;
		cout<<newpath[k%(newpath.size())]<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k, a, b;
  cin >> k >> a >> b;
  ll ans = k + 1;
  ll ret = 0;
  if (b > a) {
    k -= a;
    if (k > 0) {
      k--;
      ret += b;
      ret += (b - a) * (k / 2);
      if (k % 2)
        ret++;
      ans = max(ans, ret);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d %d",$N, $M);
$CK = [];
for($i=1; $i<=$M; $i++){
    $CK[$i] = 0;
}
for($i=0; $i<$N; $i++) {
    $K = preg_split("/[\s]/ ", fgets(STDIN));
    for($j=1; $j<=$K[0]; $j++) {
        $CK[ $K[$j] ]++;
    }
}
$countCK = array_count_values($CK);
echo (isset($countCK[$N]))?$countCK[$N]:0;


Measured memory_bytes: 4604
A, B = map(int, input().split(' '))
S = input()
N=0
if S[A] != '-':
    N=1
else:
    i=0
    while i < A:
        if S[i] in ['0','1','2','3','4','5','6','7','8','9']:
            i+=1
        else:
            N = 1
            break
    i+= 1
    while i < (A+B+1):
        if S[i] in ['0','1','2','3','4','5','6','7','8','9']:
            i+=1
        else:
            N = 1
            break
if N == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{	
	int a,b,c,n1,n2,n3,answer;
	scanf("%d %d %d",&a,&b,&c);

	if(a>=b){
		if(b>=c){
			n1=a;
			n2=b;
			n3=c;
		}
		else if(a>=c){
			n1=a;
			n2=c;
			n3=b;
		}
		else{
			n1=c;
			n2=a;
			n3=b;
		}
	}

	else{
		if(a>=c){
			n1=b;
			n2=a;
			n3=c;
		}
		else if(b>=c){
			n1=b;
			n2=c;
			n3=a;
		}
		else{
			n1=c;
			n2=b;
			n3=a;
		}
	}

	answer=n1*10+n2+n3;

	printf("%d\n",answer);
	return 0;
}

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

int n, k;

int main() {
	cin >> n >> k;
	int d, a;
	bool f[n + 1] = {};
	for(int i = 1; i <= k; i++) {
		cin >> d;
		for(int j = 1; j <= d; j++) {
			cin >> a;
			f[a] = true;
		}
	}

	int t = 0;
	for(int i = 1; i <= n; i++)
		if(!f[i]) t++;

	cout << t;

//	system("pause");
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	ll a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
dic = {}
for i in s:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
r = 0
for d in dic.values():
    r += d*(d-1)//2
print(r)

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

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

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s = "01235789";
  ll k;
  while(cin >> k && k){
    string s2;
    while(k){
      int n = k % 8;
      s2 += s[n];
      k /= 8;
    }
    reverse(all(s2));
    cout << s2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3152
from bisect import bisect_right
N = int(input())
L = {1}
m = 6
n = 9
while m <= N:
    L.add(m)
    m *= 6
while n <= N:
    L.add(n)
    n *= 9
L = list(L)
L.sort()
# print(L)

dp = [N]*(N+1)
dp[0] = 0

for i in range(1, N+1):
    x = bisect_right(L, i)
    for j in range(x):
        dp[i] = min(dp[i], dp[i-L[j]]+1)

# print(dp)
print(dp[N])


Measured memory_bytes: 74372
#include <stdio.h>

int main(){
	int i, j, k, l;
	int comb_num;
	int n;


	while( scanf("%d", &n) != EOF ){

		comb_num = 0;

		for( i=0; i<10; i++ ){
			for( j=0; j<10; j++ ){
				for( k=0; k<10; k++ ){
					for( l=0; l<10; l++ ){
						if( i+j+k+l == n )
							comb_num++;
					}
				}
			}
		}

		printf("%d\n", comb_num);
		
	}

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false); 
    int n,x;
    cin>>n>>x;
    if(x%2 != 0){
        cout<<"No"<<endl;
    }
    else
    {
        if(x>=(2*n) && x<=(4*n))
            cout<<"Yes";
        else
        {
            cout<<"No";
        }
    }
    
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n, m, c, in, count, sum;
	int *b;
	scanf("%d %d %d", &n, &m, &c);
	b = malloc(sizeof(int) * m);
	for(int i = 0; i < m; i++)
		scanf("%d", b + i);
	count = 0;
	for(int i = 0; i < n; i++){
		sum = c;
		for(int i = 0; i < m; i++){
			scanf("%d", &in);
			sum += b[i] * in;
		}
		if(sum > 0)count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<int> a(4, 0);
int main() {
    for(int i = 0; i < 4; ++i) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());

    int ar = a.at(3)+a.at(0);
    int al = a.at(1)+a.at(2);

    cout << abs(ar-al) << endl;
}


Measured memory_bytes: 3164
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  string s, ans;
  cin >> s;
  for (const auto &c : s) {
    if (c == 'B') {
      if (!ans.empty()) ans.pop_back();
    } else {
      ans.push_back(c);
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
N = int(input())
S_1 = input()
S_2 = input()

is_vertical = []

i = 0
while i < N:
    if i < N - 1 and S_1[i] == S_1[i + 1]:
        is_vertical.append(False)
        i += 2
    else:
        is_vertical.append(True)
        i += 1

res = 3 if is_vertical[0] else 6

for i in range(1, len(is_vertical)):
    if is_vertical[i] and is_vertical[i - 1]:
        res *= 2
    elif is_vertical[i] and not is_vertical[i - 1]:
        res *= 1
    elif not is_vertical[i] and is_vertical[i - 1]:
        res *= 2
    else:
        res *= 3

print(res % (10 ** 9 + 7))


Measured memory_bytes: 3064
n,y = gets.split(' ').map(&:to_i)
y = y/1000
ans = '-1 -1 -1'

for c in 0..y
key = 10 * n - y - 9 * c
	if key % 5 == 0
		b = key / 5
		a = n - b - c
		if b >= 0 && a >= 0
			ans = a.to_s + ' ' + b.to_s + ' ' + c.to_s
			break
		end
	end
end
puts ans


Measured memory_bytes: 3836
import math

def main():
    a,b,x = list(map(int,input().split()))

    v = a**2*b
    ans = 0
    if x <= v/2:
        ans = math.degrees(math.atan(a*b**2/(2*x)))
    else:
        ans = math.degrees(math.atan(2*(a**2*b-x)/(a**3)))
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  while (1) {
    string x;
    cin >> x;
    if (x[0] == '0') {
      break;
    }

    int ans = 0;
    for (int i = 0; i < (int)x.size(); i++) {
      ans += x[i] - 48;
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3132
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N >> K;
	long long int ans = 0;
	for (long long int i = K; i <= N + 1; i++) {
		L = i * (i - 1) / 2;
		R = N * i - L;
		ans += R - L+1;
	}
	cout << ans % MOD << endl;
}

Measured memory_bytes: 3652
import sys
import math
import itertools

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))

num_list=list(itertools.permutations(i for i in range(1,n+1)))

ans=abs(num_list.index(p)-num_list.index(q))
print(ans)

Measured memory_bytes: 8052
require 'matrix'

class Matrix
  # v2.3 では代入不可
  def []=(i, j, x)
    @rows[i][j]=x
  end
end

n, m = gets.split.map(&:to_i)
a = Matrix.zero(n)
b = Matrix.zero(m)
n.times do |i|
  s = gets.chomp.chars
  n.times do |j|
    if s[j] == '#'
      a[i, j] = 1
    end
  end
end
m.times do |i|
  s = gets.chomp.chars
  m.times do |j|
    if s[j] == '#'
      b[i, j] = 1
    end
  end
end
if n == 1 && a[0, 0] == b[0, 0]
  puts "Yes"
  exit
end
(n - m).times do |i|
  (n - m).times do |j|
    if a.minor(i, m, j, m) == b
      puts "Yes"
      exit
    end
  end
end
puts "No"

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

const int T = 26;

int main()
{
    int D;
    cin >> D;
    vector<long> c(T);
    rep(i, T) cin >> c[i];
    vector<vector<long>> s(D);
    rep(i, D) {
        s[i] = vector<long>(T);
        rep(j, T) cin >> s[i][j];
    }




    long ansFin = 0;
    vector<long> cc(T);
    vector<long> pair;

    rep(i, T) cc[i] = -1;
    rep(i, D) {
        pair = vector<long>(T);
        rep(j, T) {
            vector<long> ccc = cc;
            long ans = ansFin;
            ans += s[i][j];
            ccc[j] = i;
            rep(k, T) {
                ans -= c[j] * (i - ccc[j]);
            }
            pair[j] = ans;
        }
        auto iter = max_element(pair.begin(), pair.end());
        auto index = distance(pair.begin(), iter);
        ansFin += pair[index];
        cc[index] = i;
        cout << index + 1 << endl;
    }




    return 0;
}

Measured memory_bytes: 3676
import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        int count=0;
        boolean sw=false;
        int max=Integer.MIN_VALUE;
        int min=Integer.MAX_VALUE;
        double dMax=Double.MIN_VALUE;
        double dMin=Double.MAX_VALUE;
        //int answer=0;
        String answer="Yes";
        //StringBuilder answer=new StringBuilder();

        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        ArrayList<Cost> costs=new ArrayList<>();

        for (int i=0;i<N;++i)
        {
            Cost p=new Cost(sc.nextInt(),sc.nextInt());
            costs.add(p);
        }

        costs.sort((p,q)->p.b-q.b);

        int time=0;
        for (Cost i:costs)
        {
            time+=i.a;
            if (time>i.b)
            {
                answer="No";
                break;
            }
        }

        //output
        //BigDecimal bd=new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

class Cost
{
    int a;
    int b;

    public Cost(int x,int y)
    {
        a=x;
        b=y;
    }
}

Measured memory_bytes: 111692
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 201000
#define SZ 262144
using namespace std;
vector<int>G[N_];
int n, Q, w[N_], S[N_], D[N_];
int IT[SZ+SZ];
void Ins(int b, int e, int x) {
	b += SZ, e += SZ;
	while (b <= e) {
		IT[b] = min(IT[b], x);
		IT[e] = min(IT[e], x);
		b = (b + 1) >> 1, e = (e - 1) >> 1;
	}
}
int Get(int x) {
	int r = 1e9;
	x += SZ;
	while (x) {
		r = min(r, IT[x]);
		x >>= 1;
	}
	return r;
}
int main() {
	int i, b, e, j;
	for (i = 1; i < SZ + SZ; i++)IT[i] = 1e9;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		S[i] = S[i - 1] + (1 - w[i]);
	}
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d%d", &b, &e);
		G[e].push_back(b);
	}
	for (i = 1; i <= n; i++) {
		Ins(i - 1, i - 1, D[i - 1] - S[i - 1]);
		D[i] = D[i - 1] + w[i];
		for (j = 0; j < G[i].size(); j++) {
			b = G[i][j], e = i;
			Ins(b, e, Get(b - 1));
		}
		D[i] = min(D[i], Get(i) + S[i]);
	}
	printf("%d\n", D[n]);
}

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

const int mod = 2019;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    ll d = 1, r = 0;
    vector<ll> cnts(mod);
    cnts[r]++;
    rep(i,n){
        r += (s[i]-'0')*d;
        r %= mod;
        cnts[r]++;
        d = d*10%mod;
    }

    ll ans = 0;
    rep(i,mod){
        ans += (cnts[i]*(cnts[i]-1)) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3764