akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string t;
    cin >> t;
    rep(i, sz(t)) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    ll h, n;
    cin >> h >> n;
    ll ans = 0;
    ll a[n]; rep(i, n){cin >> a[i]; ans += a[i];}
    if(h <= ans){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

Measured memory_bytes: 4316
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))
import string
numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
 
def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
 
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

N,K = nums()
print(len(str(base_cvt(N,K))))

Measured memory_bytes: 4020
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N; cin>>N;
  string S,T; cin>>S>>T;
  rep(i,N)cout<<S.at(i)<<T.at(i);
  cout<<endl;
}

Measured memory_bytes: 3632
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  if (A[i]+A[i+1]) > x:
    cnt = (A[i]+A[i+1]) - x
    ans += cnt
    A[i+1] -= cnt
    if A[i+1] < 0:
      A[i+1] = 0
      
print(ans)      

Measured memory_bytes: 14468
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 int current_min = -1,count = 0;
		 int n;
		 cin >> n;
		 for(int i = 1;i <= n; i++){
			 int in;
			 cin >> in;
			 if(i == 1){
				 count += 1;
				 current_min = in;
				 continue;
			 }
			 if(in < current_min){
				 count += 1;
				 current_min = in;
			 }
		 }
		 cout << count;
	 }
}



Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

char decode(int alph, int n)
{
	if(n == 0){
		return alph;
	}
	if(alph == 'a'){
		return decode('Z', n-1);
	}
	if(alph == 'A'){
		return decode('z', n-1);
	}
	return decode(alph-1, n-1);
}

int main()
{
	int n, l;
	int k[108];
	char s[108];
	
	while(scanf("%d", &n) != EOF){
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> k[i];
		}
		cin >> s;
		l = strlen(s);
		
		for(int i = 0; i < l; i++){
			cout << decode(s[i], k[i % n]);
		}
		cout << endl;
	}
	return 0;
}	

Measured memory_bytes: 1240
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var MA = one[1];
  var MB = one[2];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = nextIntArray();
  }
  var dp = new Array(N + 1);
  var maxValue = 401;
  for(var i = 0; i < N + 1; i++){
    dp[i] = new Array(maxValue);
    for(var j = 0; j < maxValue; j++){
      dp[i][j] = new Array(maxValue);
    }
  }
  dp[0][0][0] = 0;
  //dp[i][j][k] : i個目を買い、MA合計がj、MB合計がkになる時の最小コスト
  for(var i = 1; i <= N; i++){
	for(var j = 0; j < maxValue; j++){
		for(var k = 0; k < maxValue; k++){
			if(dp[i - 1][j][k] != null){
				dp[i][j][k] = dp[i - 1][j][k];
			}
		}
		
	}
    var item = list[i - 1];
    for(var j = 0; j < maxValue; j++){
      for(var k = 0; k < maxValue; k++){
        //myerr({i,j,k});
        if(dp[i - 1][j][k] != null){
          if(dp[i][j + item[0]][k + item[1]] == null){
            dp[i][j + item[0]][k + item[1]] = dp[i - 1][j][k] + item[2];
          }else{
            dp[i][j + item[0]][k + item[1]] = Math.min(dp[i - 1][j][k] + item[2], dp[i][j + item[0]][k + item[1]]);
          }
        }
      }
    }
  }
	var count = 1;
	var output = 10000;
	while(true){
		var getMA = MA * count;
		var getMB = MB * count;
		if(getMA < maxValue && getMB < maxValue){
			if(dp[N][getMA][getMB] != null){
				output = Math.min(output,dp[N][getMA][getMB]);
			}
		}else{
			break;
		}
		count++;
	}
	if(output == 10000){
		myout(-1);
	}else{
		myout(output);
	}
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    int cur;
    vector<int> a_arr;
    vector<int> b_arr;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        a_arr.push_back(cur);
    }
    for (int j = 0; j < N; j++) {
        cin >> cur;
        b_arr.push_back(cur);
    }

    int ans = 0;
    int64_t sum_sub = 0;
    vector<int> m;
    for (int k = 0; k < N; k++) {
        if (a_arr[k] < b_arr[k]) {
            ans++;
            int sub_b = b_arr[k] - a_arr[k];
            sum_sub += sub_b;
        } else if (a_arr[k] == b_arr[k]) {
            // do nothing
        } else {
            int sub_a = a_arr[k] - b_arr[k];
            m.push_back(sub_a);
        }
    }

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

    if (sum_sub > 0) {
        int64_t p = 0;
        for (int l = 0; l < m.size(); l++) {
            p += m[l];
            ans++;
            if (p >= sum_sub) {
                break;
            }
        }
        if (p >= sum_sub) {
        } else {
            ans = -1;
        }
    }

    cout << ans << endl; 
	return 0;
}


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

using namespace std;

int main(){
	char str;
	cin >> str;

	for(int i = 0; i <= ('Z' - 'A'); i++){
		if((int)str == ('A' + i)){
			cout << "A" << "\n";
		}
		else if((int)str == ('a' + i)){
			cout << "a" << "\n";
		}
	}
}


Measured memory_bytes: 3592
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 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 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)

	n := scanInt()

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	d := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = scanInt()
		b[i] = scanInt()
	}

	for i := 0; i < n; i++ {
		c[i] = scanInt()
		d[i] = scanInt()
	}

	pair := make([][]int, n*2)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i] < c[j] && b[i] < d[j] {
				pair[i] = append(pair[i], n+j)
				pair[n+j] = append(pair[n+j], i)
			}
		}
	}

	ans,_ := bipartiteMatching(pair)

	fmt.Fprintln(wr, ans)
}

func bipartiteMatching(g [][]int) (int, []int) {
	used := make([]int, len(g))
	match := make([]int, len(g))
	for i := 0; i < len(g); i++ { match[i] = -1 }
	cnt := 0

	var fn func(v int) bool
	fn = func(v int) bool {
		if used[v] == cnt { return false }
		used[v] = cnt
		for _, to := range g[v] {
			if match[to] == -1 || fn(match[to]) {
				match[v], match[to] = to, v
				return true
			}
		}
		return false
	}

	res := 0

	for i := 0; i < len(g); i++ {
		cnt++
		if match[i] == -1 && fn(i) { res++ }
	}

	return res, match
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int a[100005], n, m;

int main(){
	int i, j;
	cin >> n;
	cout << n + n*n + n*n*n;
}


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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans = "";
  for (int i=0; i<tx-sx; i++) ans += 'R';
  for (int i=0; i<ty-sy; i++) ans += 'U';
  for (int i=0; i<tx-sx; i++) ans += 'L';
  for (int i=0; i<ty-sy+1; i++) ans += 'D';
  for (int i=0; i<tx-sx+1; i++) ans += 'R';
  for (int i=0; i<ty-sy+1; i++) ans += 'U';
  ans += 'L';
  ans += 'U';
  for (int i=0; i<tx-sx+1; i++) ans += 'L';
  for (int i=0; i<ty-sy+1; i++) ans += 'D';
  ans += 'R';
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

ll solve() {
    ll h, w;
    std::cin >> h >> w;
    if (h == 1 || w == 1) return 1;
    ll fst = (h + 1) / 2;
    ll snd = h / 2;
    ll fcnt = (w + 1) / 2;
    ll scnt = w / 2;
    return fst * fcnt + snd * scnt;
}

int main() {
    std::cout << solve() << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int m,f,r;
    while(1) {
        scanf( "%d %d %d", &m, &f, &r );
        if( m==-1 && f==-1 && r==-1 ) break;
        if( m==-1 || f==-1 ) {
            printf( "F\n" );
        }

        else if( 80<=m+f ) {
            printf( "A\n" );
        }

        else if( 65<=m+f && m+f<80 ) {
            printf( "B\n" );
        }

        else if( 50<=m+f && m+f<65 ) {
            printf( "C\n" );
        }

        else if( 30<=m+f && m+f<50 ) {

            if( r>=50 ){
                printf( "C\n" );
            } else {
                printf( "D\n" );
            }
        } 
        
        else {
            printf( "F\n" );
        }
    }
    return 0;
}


Measured memory_bytes: 2560
def resolve():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    ans = 0
    for src in range(N-1):
        for dst in range(src+1, N):
            mintotal = float("inf")
            for trans in range(N):
                if trans == src or trans == dst:
                    continue
                mintotal = min(mintotal, A[src][trans] + A[trans][dst])
            if A[src][dst] > mintotal:
                print(-1)
                return
            if A[src][dst] < mintotal:
                ans += A[src][dst]
    print(ans)




if '__main__' == __name__:
    resolve()

Measured memory_bytes: 75396
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    switch(D) {
        case 22: cout << "Christmas Eve Eve Eve" << endl; break;
        case 23: cout << "Christmas Eve Eve" << endl; break;
        case 24: cout << "Christmas Eve" << endl; break;
        case 25: cout << "Christmas" << endl; break;
    }

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%d", $e);
fscanf(STDIN, "%d", $k);
if($k >= ($e - $a)) {
  echo "Yay!";
} else {
  echo ":(";
}

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j;



int main(){
   ll N;
   cin>>N;
   vector<V> a(N,V(3));
   rep(i,N)rep(j,3)cin>>a[i][j];
   ll dp[N][3];
   for(ll k=0;k<N;k++){
      for(ll m=0;m<3;m++){
         if(k==0)dp[k][m]=a[k][m];
         else dp[k][m]=max(dp[k-1][(m+1)%3],dp[k-1][(m+2)%3])+a[k][m];
      }
   }
   ll ans=max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]));
   cout<<ans<<endl;
   

}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per for(int i=n-1;i>=0;--i)
#define ll long long 
#define pb push_back
#define all(x) (x).begin(),(x).end() 
#define in insert
#define transup(str) transform(str.begin(),str.end(),str.begin(),::toupper)
#define translow(str) transform(str.begin(),str.end(),str.begin(),::tolower)
#define intmax INT_MAX
#define intmin INT_MIN
using namespace std;
int gcd(int a,int b){

	if (b==0){
		return a;
	}
	else{
		return gcd(b,a%b);
	}
}
std::vector<int> primefactors;   
void primefactorisation(int n)  
{  
 	
    while (n % 2 == 0)  
    {  
        primefactors.pb(2);
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        
        while (n % i == 0)  
        {  
            primefactors.pb(i);
            n = n/i;  
        }  
    }
    if (n>2)
    {
        primefactors.pb(n);
    }
    return ;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll check(int*arr,int s,int e,int key){

    ll ans=-1;
    while(s<=e){
       
        ll mid=(s+e)/2;
        if (arr[mid]==key)
        {
            ans=1;
            break;
        }
        else if (arr[mid]>key)
        {
            e=mid-1;
        }
        else if (arr[mid]<key)
        {
            s=mid+1;
        }
    }

    return ans;
}
void sieve(){

	int prime[10000]={0};
	for (int i = 4; i < 10000; i+=2)
	{
		prime[i]=1;
	}
	prime[2]=0;
	for(int i=3;i<10000;i+=2){
		for(int j=i*i;j<10000;j+=i){
			prime[j]=1;
		}
	}
	prime[0]=1;
	prime[1]=1;
	std::vector<int> vprime;
	for(int i=0;i<10000;++i){
		if (prime[i]==0)
		{
			vprime.pb(i);
		}
	}

}
bool compare(int a,int b){
	return a>b;
}
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	 
	string str;
    cin>>str;
    if (str[2]==str[3] and str[4]==str[5])
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 4e5 + 9, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int n, k;   cin >> n >> k;  n++;

    ll v[n], sum = n, diff = 3;
    v[1] = n;
    for(int i = 2;i <= (n / 2);i++){
        sum += (n - diff);
        diff += 2;
        v[i] = sum % modulo;
      	sum %= modulo;
    }

    for(int i = k;i <= n;i++)
        if(i > (n / 2))    v[i] = v[n - i];
    v[n] = 1;


    ll ans = 0;
    for(int i = k;i <= n;i++){
        ans += v[i];
        ans %= modulo;
    }

    cout << ans;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    init();
    int w,h,x,y;
    scanf("%d%d%d%d",&w,&h,&x,&y);
    printf("%.6lf ",((double)w*(double)h)/2.0);
    if(h%2==0&&w%2==0&&x==w/2&&y==h/2)printf("1");
    else printf("0");
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1111];
int l[1];
int j[1];

long long x,y,z,mod=998244353;
string r;
//char r[111];

P u[1];
queue<int> q;

stack<int> s;
map<int,int> p;
vector<int> v;

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t]);
  for(int i=1;i<=a;i++)
    for(int j=i+1;j<=a;j++)
      k+=o[i]*o[j];
    printf("%d",k);
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#pragma GCC optimize("O2")
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
const int mod = 1e9 + 7;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
const int MAXN = 2e5+ 10;
const ll inf = 1e18;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
void read(vi & a) {
    for (int i = 0; i < sz(a); ++i) {
        cin >> a[i];
    }
}
const string x = "ABC";
int cnt(string s){
    int cnt = 0;
    for (int i = 0; i < sz(s) - sz(x) + 1; ++i) {
        if(s.substr(i,sz(x)) == x) cnt++;
    }
    return cnt;
}
int32_t main() {
    fio
    int n;
    cin >> n;
    vector<int>p,q;
    for (int i = 0; i < n; ++i) {
        int l;
        cin >> l;
        p.pb(l);
    }
    for (int i = 0; i < n; ++i) {
        int l;
        cin >> l;
        q.pb(l);
    }
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
        if(p[j] == q[j])continue;
        else if(p[j] > q[j]) {
            swap(p,q);
            break;
        }
        else break;
    }
    do {
        if(p == q)break;
        cnt++;
    }
    while( next_permutation(all(p)));
    cout << cnt << endl;


}






Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  char c;
  cin>>c;

  cout<<char(c+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
# from sys import exit
N, M = [int(n) for n in input().split()]
L = [0]*M
R = [0]*M
imos = [0 for _ in range(N+1)]
for i in range(M):
    L[i], R[i] = [int(n) for n in input().split()]
    imos[L[i]-1] += 1
    imos[min(R[i], N)] -= 1

for i in range(1,N+1):
    imos[i] = imos[i-1] + imos[i]

ans = 0
for i in range(len(imos)):
    if imos[i] == M:
        ans +=1

print(ans)


Measured memory_bytes: 14960
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s, t;
    cin >> s >> t;
    string ans;
    REP(i,t.length()){
        ans += s[i];
        ans += t[i];
    }
    if (s.length() > t.length()) ans += s[s.length()-1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,sum1,sum2,sum3,sum4,sum5,ans;
char a[100006][200];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        if(a[i][0]=='M')sum1++;
        if(a[i][0]=='A')sum2++;
        if(a[i][0]=='R')sum3++;
        if(a[i][0]=='C')sum4++;
        if(a[i][0]=='H')sum5++;
    }
    ans+=sum1*sum2*sum3;
    ans+=sum1*sum2*sum4;
    ans+=sum1*sum2*sum5;
    ans+=sum1*sum3*sum4;
    ans+=sum1*sum3*sum5;
    ans+=sum1*sum4*sum5;
    ans+=sum2*sum3*sum4;
    ans+=sum2*sum3*sum5;
    ans+=sum2*sum4*sum5;
    ans+=sum3*sum4*sum5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19840
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n;
    cin >> n;
    cout << (n % 1000 ? 1000 - n % 1000 : 0) << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  char s[100];
  for(int i=0;i<n;i++) cin >> s[i];
  int r = 0, b = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'B') b++;
  }
  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int a,b;cin >> a >> b;
    int true_b=0;
    for(int i=1;i<=(b-a);i++){
        true_b+=i;
    }
    p(true_b-b)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


int ar[303];
void solve()
{
 int n;
 cin >> n;
 
 forf(i,1,n+1) cin >> ar[i];

 int A = ar[1] + ar[2];
 int X = 0;

 for(int i=3;i<=n;i++) X = X xor ar[i];
 

 if(X > A || (A-X)%2!=0)
 {
    cout<<"-1\n";
    return ;
 }   

 int vl = (A-X)/2;
 
 if(vl > ar[1])
 {
    cout<<"-1\n";
    return ;
 }

 for(int i=0;i<=60;i++)
 {
    if((vl>>i) & (X>>i))
    {
      cout<<"-1\n";
      return ;
    }
 }
 
 int a = vl ,b = vl;
 //bcout<<A<<" "<<X<<endl;
 for(int i=60;i>=0;i--)
 {
    int Xb = ((X>>i)&1 ? 1:0);
    int Ab = ((vl>>i)&1 ? 1:0);
    int cur = (int)1 << i;
    //cout<<i<<" "<<a<<" "<<b<<endl;
     if(Xb && !Ab)
    {
       if(a+cur < ar[1]) a+=cur;
       else b+=cur;
    }

 }

  if(a==0) 
    {
        cout<<"-1\n";
        return;
    }
  //cout<<a<<" "<<b<<endl;
  cout<<ar[1]-a<<"\n";
 
}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3620
using System;

namespace abc167A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string M = Console.ReadLine();
            int A = S.Length;
            string O = M.Substring(0, A);
            if (S == O)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25764
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


ll a,b,c,k;

int main(){
	cin>>a>>b>>c>>k;
	if(k%2==1)
		cout<<b-a<<endl;
	else
		cout<<a-b<<endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
long N,M,x,y;
std::priority_queue<int>q;
main(){
for(std::cin>>N>>M;N--;q.push(x))std::cin>>x;
for(;M--;q.pop())q.push(q.top()/2);
for(;q.size();q.pop())y+=q.top();
std::cout<<y;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod = 1e9+7;
const ll maxn = 1e6+9;
ll fat[maxn];



template <typename T>
T extGcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1; y = 0; return a;
    }
    else {
        T g = extGcd(b, a % b, y, x);
        y -= a / b * x; return g;
    }
}
 
template <typename T>
T modInv(T a, T m) {
    T x, y;
    extGcd(a, m, x, y);
    return (x % m + m) % m;
}
 
template <typename T>
T modDiv(T a, T b, T m) {
    return ((a % m) * modInv(b, m)) % m;
}

template<typename T>
T modMul(T a, T b, T m) {
	T x = 0, y = a % m;
	while (b > 0) {
		if (b % 2 == 1) x = (x + y) % m;
		y = (y * 2) % m; b /= 2;
	}
	return x % m;
}

void calc(){
    fat[0] = 1;
    rep(i, 1, maxn){
        fat[i] = modMul((ll)i, fat[i-1], mod);
        //cout << fat[i] << ' ';
    }
    //cout << '\n';
    }


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3){
        cout << 0 << '\n';
        return 0;
    }
    
    calc();
    ll n = (x+y)/3, k = (2*y - x)/3;
    if (x < n || x > 2*n || y < n || y > 2*n){
        cout << 0 << '\n';
        return 0;
    }
    ll num = fat[n], den = modMul(fat[k], fat[n-k], mod);
    cout << modDiv(num, den, mod) << '\n';
    return 0;
}

Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		String t = fs.next();
		
		int ans = 0;
		for(int i = 0; i< s.length(); i++) {
			if(s.charAt(i) != t.charAt(i)) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 37112
H, W, K = map(int, input().split())
s = [input() for i in range(H)]

c = 1
div = [[0] * W for i in range(H)]
for i in range(H):
  for j in range(W):
    if s[i][j] == '#':
      div[i][j] = c
      c += 1

for i in range(H):
  for j in range(1, W):
    if div[i][j] == 0 and div[i][j-1] != 0:
      div[i][j] = div[i][j-1]
  for j in range(W-2, -1, -1):
    if div[i][j] == 0 and div[i][j+1] != 0:
      div[i][j] = div[i][j+1]

for i in range(1, H):
  for j in range(W):
    if div[i][j] == 0 and div[i-1][j] != 0:
      div[i][j] = div[i-1][j]

for i in range(H-2, -1, -1):
  for j in range(W):
    if div[i][j] == 0 and div[i+1][j] != 0:
      div[i][j] = div[i+1][j]

for d in div:
  print(*d)

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

int main(void){
  int n, k;
  int result = 0;

  cin >> n >> k;

  for(int i = 0; i < n; i ++){
    if(i == 0) result = k;
    else result *= k-1;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define PP(m) REP(i, m.size()) cout << m[i] << endl;

vector<bool> isPrime;
ll primed = 0;

void eratosu(ll max){
  if (max < primed) return;
  else primed = max;

  if (max+1 > isPrime.size()) {
    isPrime.resize(max+1,true);
  }
  isPrime[0] = false;
  isPrime[1] = false;

  for(ll i = 2; i * i <= max; ++i) {
    if (isPrime[i]) {
      for(ll j = 2; i * j <= max; ++j) {
        isPrime[i*j] = false;
      }
    }
  }
}

int main() {
  int a, b, c;
  eratosu(100000);
  while (cin >> a && a) {
    b=a-1; c=a+1;
    while (!isPrime[b]) b--;
    while (!isPrime[c]) c++;
    cout << b << " " << c << endl;
  }
  return 0;
}

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

int main()
{
    long long int n,m,i,j;
    cin>>n>>m;

    long long int dp[n+1]={0};
    long long int degree[n+1]={0};

    vector<long long int> v[n+1];

    for(i=0;i<m;i++)
    {
        long long int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        degree[y]++;
    }

    set<pair<long long int,long long int> > s;

    for(i=1;i<=n;i++)
    s.insert({degree[i],i});

    while(!s.empty())
    {
        pair<long long int,long long int> top=*s.begin();
        s.erase(s.begin());

        long long int si=v[top.second].size();
        vector<long long int> temp;

        for(i=0;i<si;i++)
        {
            dp[v[top.second][i]]=max(dp[v[top.second][i]],dp[top.second]+1);
            temp.push_back(v[top.second][i]);
        }

        for(i=0;i<si;i++)
        {
            s.erase({degree[temp[i]],temp[i]});
            degree[temp[i]]--;
            s.insert({degree[temp[i]],temp[i]});
        }
    }

    long long int ma=0;

    for(i=1;i<=n;i++)
        ma=max(ma,dp[i]);
    cout<<ma;
}


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

int main()
{
ll i,j,k,l,m,n;
cin>>n;
ll a[n+10];
for(i=0;i<n;i++)cin>>a[i];
bool ok=true;
for(i=n-2;i>=0;i--)
{
    if(a[i]>a[i+1])
    {
        a[i]--;
        if(a[i]>a[i+1])
        {
            ok=false;
            break;
        }
    }
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; string S; cin >> N >> S;
    vector<ll> cnt(3,0);
    for (int i=0;i<N;++i){
        if (S[i]=='R') ++cnt[0];
        if (S[i]=='G') ++cnt[1];
        if (S[i]=='B') ++cnt[2];
    }
    ll ans=cnt[0]*cnt[1]*cnt[2];
    for (int i=0;i<N;++i){
        for (int j=1;i+2*j<N;++j){
            if (S[i]!=S[i+j]&&S[i+j]!=S[i+2*j]&&S[i+2*j]!=S[i]) --ans;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3652
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", function (chunk) {
    var input = chunk.trim().split("\n");
    for (var i = 0; i < input.length; i++) {
        var pairs = input[i].trim().split(" ");
        var a = parseInt(pairs[0]);
        var b = parseInt(pairs[1]);
        console.log(a + b);
    }
});

Measured memory_bytes: 16276
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
typedef long long ll;
#define Rep(i,n) for(int i = 0;i < (n);i++)	

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

int main() {
	/*
	double a;
	std::cin >> a;
	printf("%20.10f", 2 * a * M_PI);
	
	int n, m;
	std::vector<int> A;
	std::cin >> n >> m;
	int sum = 0;
	Rep(i, m) {
		int k;
		std::cin >> k;
		sum += k;
	}
	if (sum <= n) {
		std::cout << n - sum << std::endl;
	}
	else {
		std::cout << -1 << std::endl;
	}
	*/
	int n;
	std::cin >> n;
	std::vector<int>A;
	Rep(i, n - 1) {
		int k;
		std::cin >> k;
		A.emplace_back(k);
	}
	std::vector<int> ans;
	Rep(i, n) {
		ans.emplace_back(0);
	}
	Rep(i, n-1) {
		ans[A[i]-1]++;
	}
	Rep(i, n) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 5632
import java.util.*;

public class Main{
//public class abc167_b{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b = scan.nextLong();
		long c = scan.nextLong();
		long k = scan.nextLong();
		
		long sum = 0;

		if(k >= a){
			sum += a;
			if( (k-a) >= b ){
				if( (k-a-b) > 0 )sum -= (k-a-b);
			}
		}else{
			sum += k;
		}

		System.out.println(sum);
	}

}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    string s;
    cin >> s;
    if(s[0] != 'A'){
        print("WA");
        return 0;
    }
    s.erase(s.begin());
    bool c = false;
    for(int i = 1; i < s.size() - 1; i++){
        if(s[i] == 'C') {
            if(c){
                print("WA");
                return 0;
            }
            s.erase(s.begin() + i);
            c = true;
        }
    }
    if(!c){
        print("WA");
        return 0;
    }
    rep(i, s.size()){
        if(s[i] < 'a' || 'z' < s[i]){
            print("WA");
            return 0;
        }
    }
    print("AC");
}

Measured memory_bytes: 256
fn gcd(a: usize, b: usize) -> usize {
    if a < b {
        gcd(b, a)
    } else if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let n: usize = read();
    println!("{}", 360 / gcd(360, n));
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main(){
	int n,i,count;
	cin >> n;
	int d[n][2];
	for(i = 0; i < n; i++){
		cin >> d[i][0];
		cin >> d[i][1];
	}

	count = 0;
	for(i = 0; i < n; i++){
		if(d[i][0] == d[i][1]){
			count++;
			if(count >= 3){
				break;
			}
		}
		else{
			count = 0;
		}
	}

	if(count >= 3){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

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 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() {
  ll ans=9999999999999;
  ll A,B,C,X,Y;

  cin>>A>>B>>C>>X>>Y;


  FOR(i,0,800000000){
    ll tmp=999999999999;
//cout<<i<<" "<<ans<<endl;
    tmp=i*C;

    tmp=tmp+max((X-i/2),0)*A;

    tmp=tmp+max((Y-i/2),0)*B;
//cout<<i<<" "<<ans<<endl;
    ans=min(ans,tmp);
  }


cout<<ans<<endl;
return 0;

}
 


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

const ll inf = 1e10;

int main() {
	int n, W;
	cin >> n >> W;
	vector<ll> w(n), v(n);
	for (ll i = 0; i < n; ++i)cin >> w[i] >> v[i];
	ll sumv = accumulate(v.begin(), v.end(), 0ll);
	vector<vector<ll>> dp(n, vector<ll>(sumv + 1, inf));
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	for (ll i = 1; i < n; ++i) {
		dp[i] = dp[i - 1];
		for (ll j = 0; j <= sumv - v[i]; ++j) {
			dp[i][j + v[i]] = min(dp[i][j + v[i]], dp[i - 1][j] + w[i]);
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= sumv; ++i) {
		if (dp.back()[i] <= W)ans = i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 79488
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    for h in range(H):
        for w in range(W):
            if h == 0 or w == 0 or h == H - 1 or w == W - 1: print("#",end="")
            else: print(".",end = "")
        print()
    print()


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

int check_intersection(const double ra, const double rb, const double distance){
	if(distance > (ra + rb)){
		return 0;
	}else if(ra > rb){
		return ((distance + rb) < ra) ? 2 : 1;
	}else{
		return ((distance + ra) < rb) ? -2 : 1;
	}
}

int main(){
	int data_set;
	std::cin >> data_set;
	std::vector<double> xa(data_set), ya(data_set), ra(data_set), xb(data_set), yb(data_set), rb(data_set);
	for(int i = 0; i < data_set; ++i){
		std::cin >> xa[i] >> ya[i] >> ra[i] >> xb[i] >> yb[i] >> rb[i];
	}
	double distance;
	for(int i = 0; i < data_set; ++i){
		distance = sqrt(pow(xa.at(i) - xb.at(i), 2) + pow(ya.at(i) - yb.at(i), 2));
		std::cout << check_intersection(ra.at(i), rb.at(i), distance) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1236
/*


*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#define gc() getchar()
#define mod 998244353
#define Add(x,v) (x+=v)>=mod&&(x-=mod)
typedef long long LL;
const int N=4005;

int f[N][N],sum1[N],sum2[N];
char s[N];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1; i<=n; ++i)
	{
		if(s[i]=='0') sum1[i]=2;
		else if(s[i]=='1') sum1[i]=sum2[i]=1;
		else sum2[i]=2;
		sum1[i]+=sum1[i-1], sum2[i]+=sum2[i-1];
	}
	f[0][0]=1;
	for(int i=1,lim=n<<1; i<=lim; ++i)
	{
		int n1=sum1[std::min(i,n)],n2=sum2[std::min(i,n)];
		for(int j=0; j<=i; ++j)
			if(n1>=j && n2>=i-j)
			{
				f[i][j]=f[i-1][j];//Add
				if(j) Add(f[i][j],f[i-1][j-1]);
			}
	}
	printf("%d\n",f[n<<1][sum1[n]]);

	return 0;
}

Measured memory_bytes: 60416