akhauriyash/Code-Regression huggingface dataset:
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a, b, c, d := scanInt(), scanInt(), scanInt(), scanInt()
	dp := make([][]int, c+1)
	for i := 0; i < c+1; i++ {
		dp[i] = make([]int, d+1)
	}

	dp[a][b] = 1
	for i := a; i < c; i++ {
		dp[i+1][b] = (dp[i][b] * b) % mod

	}
	for i := b; i < d; i++ {
		dp[a][i+1] = (dp[a][i] * a) % mod
	}

	for i := a; i < c; i++ {
		for j := b; j < d; j++ {
			dp[i+1][j+1] = (dp[i][j+1]*(j+1) + dp[i+1][j]*(i+1) - dp[i][j]*i*j) % mod
		}
	}

	fmt.Fprintln(wr, (dp[c][d]+mod)%mod)
}

const mod = 998244353


Measured memory_bytes: 76836
x, y, a, b, c = [int(i) for i in input().split()]
p = [(int(i),0) for i in input().split()]
q = [(int(i),1) for i in input().split()]
r = [(int(i), 2) for i in input().split()]
pqr = p + q + r
pqr.sort(reverse=1)
i = 0
j = 0
ind = 0
ans = 0
for _ in range(x + y):
    if i < x and j < y:
        aa = pqr[ind]
        ans += aa[0]
        if aa[1] == 0:
            i += 1
        elif aa[1] == 1:
            j += 1
        ind += 1
    elif i < x:
        while pqr[ind][1] == 1:
            ind += 1
        aa = pqr[ind]
        ans += aa[0]
        if aa[1] == 0:
            i += 1
        elif aa[1] == 1:
            j += 1
        ind += 1
    else:
        while pqr[ind][1] == 0:
            ind += 1
        aa = pqr[ind]
        ans += aa[0]
        if aa[1] == 0:
            i += 1
        elif aa[1] == 1:
            j += 1
        ind += 1
print(ans)


Measured memory_bytes: 117220
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n, 0);
    ll tmp;
    ll i;
    for (i = 0; i < q; i++) {
        cin >> tmp;
        a[tmp-1]++;
    }

    for (i = 0; i < n; i++) {
        if (k - q + a[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int n;
    cin >> n;
    VI h(n);
    
    for(int i = 0; i < n ; ++i)cin >> h[i];
    int ans =1, max = h[0];
    for(int i = 1; i<n ; ++i){
        if(max <= h[i]){
            ans++;
            max = h[i];
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, m;
    int k[11], s[11][11];
    int p[11];
    int ans = 0;

    cin >> n >> m;
    rep(i, 0, m)
    {
        cin >> k[i];
        rep(j, 0, k[i]) cin >> s[i][j];
    }
    rep(i, 0, m) cin >> p[i];

    rep(i, 0, 1 << n)
    {
        //cout << i << endl;
        bool f = true;
        rep(j, 0, m)
        {
            int on = 0;
            rep(l, 0, k[j])
            {
                //cout << "i=" << i << " " << (1 << (s[j][l] - 1)) << " " << (i & (1 << (s[j][l] - 1))) << " " << on << endl;
                if ((i & (1 << (s[j][l] - 1))) != 0)
                {
                    on++;
                }
            }
            //cout << i << " " << j << " " << on << endl;
            if (on % 2 != p[j])
            {
                f = false;
                break;
            }
        }
        if (f)
        {
            //cout << "OK" << endl;
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    if(a<b) swap(a, b);
    if(a<c) swap(a, c);

    cout << (ll)pow(2, k) * a + b + c<< endl;
    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

/*vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	vll a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(all(a));
	ll val = 3*a[2];
	if(val%2 == (a[0]+a[1]+a[2])%2) x=a[2];
	else x=a[2]+1;

	cout<<(ll)(3*x - (a[0]+a[1]+a[2]))/2;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    static ArrayList<Integer> primeList;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count=0;
        while (true) {
            int n = ip(br);
            if (n == 0) {
                break;
            }
            count++;
            int[] cList = new int[2 * n - 1];
            int[] aList = new int[2 * n - 1];
            int[] bList = new int[2 * n - 1];
            for (int i = 0; i < aList.length; i++) {
                cList[i] = i < n ? i + 1 : cList[i - 1] - 1;
                aList[i] = i < n ? i : n - 1;
                bList[i] = i < n ? 0 : i % n + 1;
            }
            int[][] list = new int[2][n * n];
            int k = 0;
            for (int i = 0; i < 2 * n - 1; i++) {
                for (int j = 0; j < cList[i]; j++, k++) {
                    list[i % 2][k] = aList[i]--;
                    list[(i + 1) % 2][k] = bList[i]++;
                }
            }
            int[][] matrix = new int[n][n];
            for (int i = 0; i < n * n; i++) {
                matrix[list[0][i]][list[1][i]] = i+1;
            }
            System.out.println("Case "+count+":");
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    System.out.printf("%3d",matrix[i][j]);
                }
                System.out.println();
            }

        }

    }

    private static int[] ai(BufferedReader br) throws IOException {
        String[] lines;

        lines = br.readLine().split(" ");
        int a = lines.length;
        int[] l = new int[a];
        while (a-- > 0) {
            l[a] = Integer.parseInt(lines[a]);
        }
        return l;
    }

    static int ip(BufferedReader br) throws IOException {
        return Integer.parseInt(br.readLine());
    }
}

Measured memory_bytes: 24860
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    readc(n, x, y);
    int dis[n+1][n+1], cnt[n] = {};

    fori(i, 1, n) fori(j, 1, n) dis[i][j] = j-i;

    fori(i, 1, n-1)
    {
    	fori(j, 2, n)
    	{
    		if(i <= x)
    			dis[i][j] = min(dis[i][j], abs(y-j)+1+x-i);
    		else if(i <= y)
    			dis[i][j] = min(dis[i][j], 1+i-x+ abs(y-j));

    	}
    }

    fori(i, 1, n) fori(j, 1, n) cnt[dis[i][j]]++;

   	fori(i, 1, n-1) cout << cnt[i] << endl;

    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
long long oll = 0;
#define ll long long
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int,int>
#define lcm(a,b) a*b/__gcd(a,b)
#define fl(i,a,b) for(int i = a;i < b;i++)
#define lf(i,a,b) for(int i = b;i >= a;i--)
#define MEM(x,y) memset(x,y,sizeof(x))
#define mp make_pair

bool if_palindrome(string a,int st,int n)
{
    for(int i = st,j = n;i <= n/2;i++,j--)
    {
        if(a[i] != a[j])return false;
    }
    return true;
}

void solve()
{
   string a;
   cin>>a;
   int n = a.size();
   bool x,b,c;
   x = if_palindrome(a,0,((n-1)/2)-1);
   b = if_palindrome(a,((n+3)/2),n-1);
   c = if_palindrome(a,0,n-1);
  if(x&&b&&c)cout << "Yes\n";
   else cout << "No\n";
}

int main()
{
    //FIO;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    solve();
    return 0;
}


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

int main() {
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int co,div;

    if(X>=Y){
        if((A+B)>=2*C){
            co = 2*C*Y;
            div = X - Y;
            if(2*C>=A){
                co += div*A;
            }else{
                co += div*2*C;
            }
        }else{
            co = (A+B)*Y;
            div = X - Y;
            if(2*C>=A){
                co += div*A;
            }else{
                co += div*2*C;
            }

        }
    }else{
        if((A+B)>=2*C){
            co = 2*C*X;
            div = Y - X;
            if(2*C>=B){
                co += div*B;
            }else{
                co += div*2*C;
            }
        }else{
            co = (A+B)*X;
            div = Y - X;
            if(2*C>=B){
                co += div*B;
            }else{
                co += div*2*C;
            }

        }
    }

    cout<<co<<endl;

    return 0;
}



Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);
    const n = numbers[0];

    if (n === 0) break;
    const line2 = lines.shift()
    const array = line2.split(' ').map(Number);

    let distance = 1000000;

    for (let i=0 ; i < n; i++) {
        for (let j=0 ; j < n; j++) {
            if (i === j) continue;
            const tempDistance = Math.abs(array[i] - array[j]);
            if (distance > tempDistance) {
                distance = tempDistance;
            }
        }
    }


    // Edit from here
    const output = distance;
    // to here
    
    console.log(output);
    
}



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

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

  int a[110];
  int b[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
  for (int i=0; i<n; i++){
    cin >> a[i];
    b[a[i]/400]++;
  }

  int max = 0, min = 0;
  for (int i=0; i<13; i++){
    if (b[i]>0 && i<8){
      max++;
      min++;
    }
    if (b[i]>0 && i>=8){
      max += b[i];
    }
  }

  if (min==0){
    min = 1;
  }

  cout << min << " " << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pql priority_queue<ll>
#define fi first
#define se second
#define pb push_back
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mib map<int,bool>
#define mlb map<ll,bool>
#define f(i,k,n) for(ll i=k;i<n;i++)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll mod=1e9+7;
const ld pii=3.141592653589793238;
int main()
{
    IOS
    ll n;
    cin>>n;
    vll a(n);
    for(ll i=0;i<n-1;i++) cin>>a[i];
    mll mp;
    for(ll i=0;i<n-1;i++) mp[a[i]]++;
    for(ll i=1;i<=n;i++) cout<<mp[i]<<endl;
}

Measured memory_bytes: 17248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    string p, q;
    for (int i = 0; i < n; i++)
    {
        char tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    for (int i = 0; i < n; i++)
    {
        char tmp;
        cin >> tmp;
        q.push_back(tmp);
    }
    string num;
    for (char i = '1'; i <= char('0' + n); i++)
    {
        num.push_back(i);
    }
    int pp, qq;
    int idx = 0;
    do
    {
        if (num == p)
        {
            pp = idx;
        }
        if (num == q)
        {
            qq = idx;
        }
        idx++;
    } while (next_permutation(num.begin(), num.end()));
    cout << abs(pp - qq) << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n)    cin >> h[i];
    vector<vector<int>> v(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    int ans = 0;
    rep(i,n) {
        if(v[i].empty()) {
            ans++;
        }
        rep(j,v[i].size()) {
            if(h[i] <= h[v[i][j]])     break;
            if(j+1 >= v[i].size())  ans++; 
        }
    }

    cout << ans << endl;

 return 0;
}


Measured memory_bytes: 8740
// In God We Trust


# include <bits/stdc++.h>

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
#include <algorithm>


using namespace std;




signed main()
{
  int n;
  cin >> n;
  int a[n];
  int wanted = 1;
  for (int i = 0 ; i < n; i ++){
    cin >> a[i];
    if (a[i] == wanted)
      wanted++;
  }
  if (wanted == 1)
    cout << -1 << endl;
  else 
    cout << n - wanted + 1 << endl;
  
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int v[n], c[n], a[n];
    int i;
    int sum = 0;
    rep(i, n) {
      cin >> v[i];
    }
    rep(i, n) {
      cin >> c[i];
    }
    rep(i, n) {
      a[i] = v[i] - c[i];
    }
    rep(i, n) {
      if (a[i] > 0) {
        sum += a[i];
      }
    }

    cout << sum << '\n';

    return 0;
}


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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

template<typename T> T& updMin(T& a, T const& b) { if (b < a) a = b; return a; }
template<typename T> T& updMax(T& a, T const& b) { if (a < b) a = b; return a; }

// ========================================================================= //

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    ll a = 0, b = 0;
    for (int i = 0; i < sz(s); ++i)
        if (s[i] == 'W') {
            ++a;
            b += i;
        }
    cout << b - a*(a-1) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 720
package main

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

func main() {
	if readInt()*500 >= readInt() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
	//scanner.Split(bufio.ScanLines)
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}


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

int main(){
    vector<int> w(10);
    vector<int> k(10);

    for(int i=0; i<10; i++){
        cin >> w[i];
    }

    for(int i=0; i<10; i++){
        cin >> k[i];
    }

    sort(w.begin(), w.end(), greater<int>());
    sort(k.begin(), k.end(), greater<int>());

    int w_sum = 0;
    int k_sum = 0;

    for(int i=0; i<3; i++){
        w_sum += w[i];
        k_sum += k[i];
    }

    printf("%d %d\n", w_sum, k_sum);

    return 0;
}

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

int main(){
    int N,C,K;cin>>N>>C>>K;
    int last=0,count=0,ans=0;
    vector<int> T(N);
    REP(i, N) cin >> T[i];
    sort(T.begin(),T.end());
    REP(i,N){
        if(last<T[i]||count==C){
            ans++;
            count=1;
            last=T[i]+K;
        }else{
            count++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"

ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll d;
		cin >> d;
		if (i % 2 == 0 && d % 2)
			ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<char> c(n);
    int wtow = 0;
    int rtow = 0;
    int rtor = 0;
    int wtor = 0;
    rep(i, n) {
        cin >> c[i];
        if (c[i] == 'R') rtow++;
        else wtow++;
    }

    int ans = 2000000;
    for (int i = 0; i <= n; i++) {
        int cnt = max(rtow, wtor);
        ans = min(ans, cnt);
        if (i == n) break;
        if (c[i] == 'R') {
            rtow--;
            rtor++;
        }
        else {
            wtow--;
            wtor++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
s=input()
l=[chr(i) for i in range(ord("a"),ord("z")+1)]
a=100
for i in l:
    t=0
    c=0
    for j in s:
        if j!=i:
            c+=1
        else:
            if t<c:
                t=c
            c=0
    t=max(t,c)
    if a>t:
        a=t
print(a)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int sx,sy;
int gx,gy;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int co;
vector<vector<char> >in;
bool h;
void func(char d,char q,int x,int y){
	in[x][y]=q;
	co++;
	rep(i,4){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(in[nx][ny]=='.'){
			func(d,q,nx,ny);
		}else if(in[nx][ny]==d)h=false;
	}
}
int main(){
	int n,m;
	while(cin>>m>>n,m+n){
		vector<vector<char> >tmp(n+2,vector<char>(m+2));
		rep(i,n+2)rep(j,m+2){
			if(!i||!j||i==n+1||j==m+1)tmp[i][j]='!';
			else cin>>tmp[i][j];
		}
		//cout<<n<<" "<<m<<endl;
		in=tmp;
		int b=0,w=0;
		rep(i,n+2)rep(j,m+2){
			h=true;
			if(in[i][j]=='.'){
				rep(k,4){
					int nx=i+dx[k];
					int ny=j+dy[k];
					if(in[nx][ny]!='W'&&in[nx][ny]!='B')continue;
					co=0;
					if(in[nx][ny]=='W'){
						func('B','W',i,j);
						if(h)w+=co;
						break;
					}else{
						func('W','B',i,j);
						if(h)b+=co;
						break;
					}
				}
			}
		}
		cout<<b<<" "<<w<<endl;
		//rep(i,n+2){rep(j,m+2)cout<<in[i][j];cout<<endl;}
	}
}

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

int main() {

	int n,m;

	cin >> n >> m;

	int a[1000],b[1000],counter[1000];

	for (int i=0; i<n; i++){

		cin >> a[i];
	}

	for (int j=0; j<m; j++){

		cin >> b[j];
	}

	for (int i=0; i<1000; i++){

		counter[i] = 0;
	}
	for (int j=0; j<m; j++){
		for (int i=0; i<n; i++){

			if (a[i] <= b[j]){
				counter[i]++;
				break;
			}
		}
	}

	/*for (int i=0; i<n; i++){
			cout << counter[i] << endl;
		}*/
	int saikyou = 0;

	for (int i=0; i<n; i++){

		if (counter[i] >= counter[saikyou]){
			saikyou = i;
		}
	}

	cout << saikyou+1 << endl;
	
	return 0;
}



Measured memory_bytes: 3120
//
//  main.cpp
//  ABC173E
//
#include<iostream>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, f;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) f.push_back(a[i]);
    else s.push_back(a[i]);
  }

  int s_num = (int)s.size(); // 正の数
  int f_num = (int)f.size(); // 負の数
  bool ok = false;
    // 積を正にできる場合
    // 正の数があるなら
    //     n==kのとき、負の数の個数ffが偶数ならOK
    //     n>kのとき、OK
    // 正の数がないなら
    //     kが偶数ならOK
  if (s_num > 0) { // 正の数がある
      if (n == k && f_num%2==0) ok = true;
      if(n>k) ok = true;
  } else { // 正の数がない
    if(k%2==0) ok=true;
  }

  mint ans = 1;
  if (!ok) {
    // 絶対値の小さい順にソート
    sort(a.begin(), a.end(), [](int x, int y) { return abs(x) < abs(y);});
    rep(i,k) ans *= a[i];
  } else {
    sort(s.begin(), s.end());
    sort(f.rbegin(), f.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (f.size() >= 2) {
      ll x = f.back(); f.pop_back();
      x *= f.back(); f.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int primes[123456*2];
    for(int i=2;i<123456*2;++i) primes[i] = 1;
    for(int i=2;i<123456*2;++i){
        if(primes[i]){
            for(int j=2;i*j<123456*2;++j) primes[i*j] = 0;
        }
    }
    while(true){
        int n;
        int cnt=0;
        cin >> n;
        if(!n) break;
        for(int i=n+1;i<=2*n;++i){
            if(primes[i]) ++cnt;
        }
        cout << cnt << endl;
    }
}

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

int main() {
    string S;cin>>S;
    int ans=0;
    for (int i = 0; i < S.size()/2; i++){
        if(S[i]!=S[S.size()-1-i])ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  int N, A, B; cin >> N >> A >> B;
  vector<int> ans;
  if (1LL * A * B < N or A + B - 1 > N) {
    ans.push_back(-1);
  } else {
    int cur {};
    for (int i = 1; i <= A; i++) {
      int m = min(N - cur - (A - i), B);
      for (int j = 0; j < m; j++) ans.push_back(cur + m - j);
      cur += m;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << ( (i == ans.size() - 1) ? '\n' : ' ' );
  }
  return 0;
}


Measured memory_bytes: 3440
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


int main() {
	int n;
	cin >> n;
	map<int, int> S;
	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		S[a[i]]++;
	}
	if (a[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	ll ANS = 1;
	bool ans = true;
	for (auto x : S) {
		if (x.first == 0){
          if(x.second == 1) continue;
          else{
            ans = false;
			break;
          }
        }
		if (S[x.first - 1] == 0)ans = false;
		int A = x.second;
		int B = S[x.first - 1];
		ANS = (ANS * modpow(B, A, 998244353))% 998244353;
	}
	ANS %= 998244353;
	if (!ans)cout << 0 << endl;
	else cout << ANS << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    int MIN = INF;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        if (MIN >= p)
        {
            ans++;
            MIN = p;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back


const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int cnt[52];


int main() {
	#ifdef IZI_KATKA      
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
    	cnt[s[i] - 'a'] ++;
    }
    for (int i = 0; i < 26; i++) {
    	if (!cnt[i]) {
    		cout << s << char(i + 'a');
    		return  0;
    	}
    }
    memset(cnt, 0, sizeof(cnt));
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
    	cout << -1;
    	return 0;
    }
    int mae = 0;
    char ch;
    for (int i = 0; i < s.size(); i++) {
		for (int j = s[i] + 1; j <= 'z'; j++) {
			if (!cnt[j - 'a']) {
				mae = i;
				ch = j;
				break;
			}
		}    	
		cnt[s[i] - 'a']++;
    }
    for (int i = 0; i <= mae - 1; i++) {
    	cout << s[i];
    }
    cout << ch;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int n=s.length()-1;
 

    long s1;
    istringstream ss1;
    ss1=istringstream(s);
    ss1>>s1;
	
    long ans=0;
    for (int bit=0;bit< (1<<n) ;bit++){
        vector<int> summation;
        for (int i=0; i<n ; i++){
            if(bit & (1<<i)){
                summation.push_back(i);
                }
            }
        vector<bool> check(n+1,false);
        check[n]=true;
        for (int i=0; i<summation.size(); i++){
            check[summation[i]]=true;
        }
        long sum=0;
        int count=1;
        long t=s1;
        for (int i=0; i<n+1; i++){
            if(check[i]){
                long div=pow(10,count);
               
                sum+=t%div;
             
                t=t/div;
              
                count=1;
            }
            else{
                count++;
            }
        }
   
        ans+=sum;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int[] A=new int[N];
		int[] ans=new int[N];
		for (int i=0;i<N-1;++i) {
			A[i+1]=sc.nextInt()-1;
			ans[A[i+1]]++;
		}
		PrintWriter pw=new PrintWriter(System.out);
		for (int i=0;i<N;++i) {
			pw.println(ans[i]);
		}
		pw.close();
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 50464
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xi(n), yi(m);
  REP(i, n) cin >> xi[i];
  REP(i, m) cin >> yi[i];
  sort(ALL(xi));
  sort(ALL(yi));
  if(xi[n-1] < yi[0] && x < yi[0] && yi[0] <= y){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
inf = float('inf')

s = input()

ans = inf
for start_color in '01':
    cost = 0
    for i, ss in enumerate(s):
        if i % 2 == 0:
            if ss != start_color:
                cost += 1
        else:
            if ss == start_color:
                cost += 1
    ans = min(ans, cost)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    cin >>h >>w;
    for(int i=0;i<w+2;i++){
        cout <<"#";
    }
    cout <<endl;
    for(int i=0;i<h;i++){
        string s;
        cin >>s;
        cout <<"#" <<s <<"#"<<endl;
    }
    for(int i=0;i<w+2;i++){
        cout <<"#";
    }
    cout <<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
  int n;
  double x[100];
  double y[100];
  double p1=0,p2=0,p3=0,pi=0;

  cin>>n;

  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<n;i++) cin>>y[i];

  for(int i=0;i<n;i++){
    p1+=abs(x[i]-y[i]);
  }

  for(int i=0;i<n;i++){
    p2+=(x[i]-y[i])*(x[i]-y[i]);
  }
  p2=sqrt(p2);

  for(int i=0;i<n;i++){
    p3+=(x[i]-y[i])*(x[i]-y[i])*(abs(x[i]-y[i]));
  }
  p3=pow(p3,1.0/3.0);

 for(int i=0;i<n;i++){
   pi=max(abs(x[i]-y[i]),pi);
  }

 printf("%.6f\n%.6f\n%.6f\n%.6f\n",p1,p2,p3,pi);
}

Measured memory_bytes: 1288
A, B, C, K = map(int, input().split())
THRES = 10 ** 18
UNFAIR = 'Unfair'


def bf():
    a, b, c = A, B, C
    for _ in range(K):
        a, b, c = b + c, c + a, a + b
    return a - b


def al():
    return (A - B) * ((-1) ** (K % 2))


# ans1 = bf()
# ans1 = UNFAIR if abs(ans1) > THRES else ans1
# print(ans1)

ans2 = al()
ans2 = UNFAIR if abs(ans2) > THRES else ans2
print(ans2)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int main()
{
    int n;
    cin>>n;
    if(n==1) cout << "Hello World" << endl;
    if(n==2){
        int a,b;
        cin>>a>>b;
        cout <<a+b << endl;
    }
}


Measured memory_bytes: 256
#include <string>
#include <stack>
#include <iostream>
#include <cstdlib>

using namespace std;
int main() {
  string word;
  stack<int> S;
  int current1;
  int current2;

  while (cin >> word) {
    if (word == "+") {
      current1 = S.top();
      S.pop();
      current2 = S.top();
      S.pop();
      S.push(current1 + current2);
    }
    else if (word == "-") {
      current1 = S.top();
      S.pop();
      current2 = S.top();
      S.pop();
      S.push(current2 - current1);
    }
    else if (word == "*") {
      current1 = S.top();
      S.pop();
      current2 = S.top();
      S.pop();
      S.push(current1 * current2);
    } else {
      S.push(atoi(word.c_str()));
    }
  }
  cout << S.top() << endl;
}

Measured memory_bytes: 1200
#include<stdio.h>
#include<iostream>
#include<string>

bool check()
{
	int n;
	std::string str[100];
	char last;
	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> str[i];
		for (int j = 0; j < i; ++j)
			if (str[j] == str[i]) return false;
		if (i && str[i][0] != last) return false;
		last = str[i].back();
	}
	return true;
}

int main()
{
	if (check())
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if ((a+b) < (b+c) and (a+b) < (a+c))
	{
		printf("%d", a+b);
	}
	else if ((b+c) < (a+b) and (b+c) < (a+c))
	{
		printf("%d", b+c);
	}
	else if ((a+c) < (a+b) and (a+c) < (b+c))
	{
		printf("%d", a+c);
	}
	else if ((a+b) == (b+c) and (b+c) == (a+c) and (a+c) == (a+b))
	{
		printf("%d", a+b);
	}
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) (a <= x && x < b)
#define INIT                        \
  std::ios::sync_with_stdio(false); \
  std::cin.tie(0);
template <class T>
inline T CHMAX(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T CHMIN(T& a, const T b) {
  return a = (a > b) ? b : a;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  INIT;

  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  REP(i, n) cin >> a[i];
  REP(i, m) cin >> b[i];

  ll t = 0;
  REP(i, m) t += b[i];

  int j = m;
  int ans = 0;
  REP(i, n + 1) {
    while (j > 0 && t > k) {
      --j;
      t -= b[j];
    }
    if (t > k) break;
    ans = max(ans, i + j);
    if (i == n) break;
    t += a[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4716