akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,s;
    cin>>n>>s;
    int ans=0;
    for(int i=0; i<=n; ++i){
        for(int j=i; j<=n; ++j){
            for(int k=j; k<=n; ++k){
                if(i+j+k==s){
                    if(i==j&&j==k){
                        ans++;
                    }
                    else{
                        if((i!=j&&j==k)||(i==j&&j!=k)){
                            ans+=3;
                        }
                        else{
                            ans+=6;
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;
const int mod =998244353;

int main()
{
    int n;
    cin>>n;
    vector<ll> d(n);
    rep(i,n)
    {
        cin>>d[i];
    }
    if(d[0]!=0)
    {
        cout<<0;
        return 0;
    }
    map<int,int> dc;
    rep(i,n)
    {
        dc[d[i]]++;
    }
    if(dc[0]!=1)
    {
        cout<<0;
        return 0;
    }
    ll ans=1;
    P prev=P(0,1);
    for(auto v:dc)
    {
        if(v.first-prev.first>1)
        {
            cout<<0;
            return 0;
        }

        if(v.first>1)
        {
            rep(i,v.second)
            {
                ans=ans*prev.second%mod;
            }
        }
        prev=v;
    }
    cout<<ans;

}

Measured memory_bytes: 5760
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections


def solve(N: int, a: "List[int]"):
    c = collections.Counter(a)
    d = dict(c.items())
    counter = 0
    for k in c.keys():
        if k == 1:
            counter += d[k] - 1
            continue
        counter += d[k] - (d[k] // k) * k
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  for(ll j=0;j<4;j++) {
    vec a(n);
    a[0]=j&1;
    a[1]=(j>>1)&1;
    for(ll i=1;i<n-1;i++) {
      ll c=i%n;
      if(a[c]) {
        if(s[c]=='o') {
          a[(c+1)%n]=a[(c-1)%n];
        }
        else {
          a[(c+1)%n]=1-a[(c-1)%n];
        }
      }
      else {
        if(s[c]=='x') {
          a[(c+1)%n]=a[(c-1)%n];
        }
        else {
          a[(c+1)%n]=1-a[(c-1)%n];
        }
      }
    }
    ll f=1;
    for(ll i=0;i<2;i++) {
      if(a[(n+i-1)%n]) {
        if(s[(n+i-1)%n]=='o') {
          if(a[(n+i-2)%n]!=a[i])f=0;
        }
        else {
          if(a[(n+i-2)%n]==a[i])f=0;
        }
      }
      else {
        if(s[(n+i-1)%n]=='x') {
          if(a[(n+i-2)%n]!=a[i])f=0;
        }
        else {
          if(a[(n+i-2)%n]==a[i])f=0;
        }
      }
    }
    if(f) {
      for(ll i=0;i<n;i++) {
        if(a[i]) {
          cout << "S";
        }
        else {
          cout << "W";
        }
      }
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 1408
#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;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
#define int long long
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
//define oset tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}
struct Node{
    int first;int second;
    Node(int x,int y){
        this->first = x;
        this->second = y;
    }
};
struct comparator{
    bool operator()(const Node &a,const Node &b){
        int lena = a.second-a.first+1;
        int lenb = b.second-b.first+1;
        if(lena == lenb)return a.first<b.first;
        else return lena>lenb;
    }
};

signed main(){
    fastio();
    string t;
    cin>>t;
    for(int i = 0; i<t.size(); i++)if(t[i] == '?')t[i] = 'D';
    cout<<t<<"\n";
}

Measured memory_bytes: 3768
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ld sol(ll i,ll c,ll n,vector<ld> &v,vector<vector<ld> > &dp)
{
    if(i==n)
    {
        if(c>(n-c))
        {
            return 1.0;
        }
        return 0.0;
    }
    if(dp[i][c]!=(-1.0))
    {
        return dp[i][c];
    }
    ld ans = v[i]*(sol(i+1,c+1,n,v,dp));
    ld ans2 = (1-v[i])*(sol(i+1,c,n,v,dp));
    ans = ans + ans2;
    dp[i][c]=ans;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ld> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    vector<vector<ld> > dp(n+1,vector<ld>(n+1,-1.0));
    ld ans = sol(0,0,n,v,dp);
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}




Measured memory_bytes: 141440
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    else:
        if m == -1 or f == -1:
            print("F")
        elif m + f >= 80:
            print("A")
        elif m + f < 80 and m + f >= 65:
            print("B")
        elif m + f < 65 and m + f >= 50:
            print("C")
        elif m + f < 50 and m + f >= 30 and r >= 50:
            print("C")
        elif m + f < 30:
            print("F")
        else:
            print("D")

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

using ll = long long;
const int SEG_LEN = 1 << 20;
vector<ll> seg(SEG_LEN * 2);

void add(int pos, ll val) {
    pos += SEG_LEN;
    seg[pos] += val;
    while (true) {
        pos /= 2;
        if (pos == 0) break;
        seg[pos] += val;
    }
}

ll sum(int l, int r) {
    l += SEG_LEN;
    r += SEG_LEN;
    ll res = 0;
    while (l < r) {
        if (l % 2) res += seg[l++];
        if (r % 2) res += seg[--r];
        l /= 2;
        r /= 2;
    }
    return res;
}

int main() {
    int N, Q;  cin >> N >> Q;
    for (int i = 0; i < N; ++i) {
        ll a;  cin >> a;
        add(i, a);
    }

    for (int _ = 0; _ < Q; ++_) {
        int q;  cin >> q;
        if (q == 0) {
            // add query
            int pos;  ll val;  cin >> pos >> val;
            add(pos, val);
        }
        if (q ==  1) {
            // get sum query
            int l, r;  cin >> l >> r;
            cout << sum(l, r) << endl;
        }
    }
}


Measured memory_bytes: 20740
using System;
using System.Collections.Generic;
using System.Linq;

namespace y.miyoshi
{

    public class Queen8
    {
        static int Max = 8;
        static bool[] vertical;
        static bool[] diagonal1;
        static bool[] diagonal2;
        static Dictionary<byte, byte> queenDic;
        static byte[] skip;
        static bool finish;

        public static void Main()
        {
            var n = byte.Parse(Console.ReadLine());
            skip = new byte[n];
            queenDic = Enumerable.Range(0, n).Select(_ =>
            {
                var line = Console.ReadLine().Split();
                skip[_] = byte.Parse(line[0]);
                return new { x = byte.Parse(line[0]), y = byte.Parse(line[1])};
            }).ToDictionary(e => e.x, e=>e.y);

            Initialize();
            queenDic.ToList().ForEach(q => MarkBoad(q.Key, q.Value, true));

            Search8Queens(0);

        }

        public static void Search8Queens(byte x)
        {
            if (finish) return;

            if (x == Max)
            {
                Display();
                finish = true;
                return;
            }

            //?????????????????????????????????
            if (!skip.Contains(x))
            {
                for (byte i = 0; i < Max; i++)
                {
                    //????????????????
                    if (queenDic.ContainsKey(x)
                        || vertical[i] == true
                        || diagonal1[x + i] == true
                        || diagonal2[x - i + Max - 1] == true)
                        continue;

                    //??????
                    MarkBoad(x, i, true);
                    Search8Queens((byte)(x + 1));
                    //????????????
                    MarkBoad(x, i, false);
                }
            }
            else
            {
                Search8Queens((byte)(x + 1));
            }

        }

        public static void Display()
        {
            for (byte i = 0; i < Max; i++)
            {
                for (byte j = 0; j < Max; j++)
                {
                    if (queenDic[i] == j)
                        Console.Write('Q');
                    else
                        Console.Write('.');
                }
                Console.WriteLine();
            }
        }

        public static void MarkBoad(byte x, byte y, bool mark)
        {
            vertical[y] = mark;
            diagonal1[x + y] = mark;
            diagonal2[x - y + Max - 1] = mark;
            if (mark) queenDic[x] = y;
            else queenDic.Remove(x);
        }

        public static void Initialize()
        {
            vertical = new bool[Max];
            diagonal1 = new bool[2 * Max - 1];
            diagonal2 = new bool[2 * Max - 1];
        }
    }
}

Measured memory_bytes: 8692
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        
        int count = 0;
        for (long i = 1; i <= 3234566667L; i++) {
            // System.out.println(i);
            String str = String.valueOf(i);
            char c[] = str.toCharArray();
            
            boolean ok = true;
            for (int j = 0; j < c.length-1; j++) {
                int prev = c[j];
                int next = c[j+1];
                
                // 条件を満たさないものは除外
                if (Math.abs(prev - next) > 1) ok = false;
                
                // 次の桁が前の桁より2以上離れてるならそこまで飛ぶ
                // ex. 299 -> 300 -> 320
                if (prev - next > 1) {
                    ok = false;
                    
                    long tmp = prev - next - 1;
                    for (int l = 0; l < c.length-1-(j+1); l++) {
                        tmp *= 10;
                    }
                    
                    tmp--;
                    i += tmp;
                    
                    break;
                }
            }
            
            if (ok) count++;
            
            if (count == k) {
                System.out.println(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 55188
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
    int n,y,i,j;
    cin>>n>>y;
    for(i=0;i<=n;i++)
        for(j=0;j<=n-i;j++){
            if(i*10000+j*5000+(n-i-j)*1000==y){
                cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
                return 0;
            }
        }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	str := readLine()

	var intSlice []int

	for _, sv := range str {
		iv, _ := strconv.Atoi(string(sv))
		intSlice = append(intSlice, iv)
	}

	sum := 0

	for _, iv := range intSlice {
		sum += iv
	}

	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

int main(){
    int n; cin>>n;
    int sum=0, maxp=0, p;
    rep(i,n){
        cin>>p;
        sum += p;
        maxp = max(maxp, p);
    }
    cout << sum -maxp/2 << endl;
    return 0;
}

Measured memory_bytes: 3620
A, B, C, X, Y = map(int, input().split())
r = 0

if A+B >= 2*C:
    t = min(X, Y)
    r += 2 * t * C
    X -= t
    Y -= t
if 2*C <= A:
    r += X * 2 * C
    Y = max(Y-X, 0)
    X = 0
if 2*C <= B:
    r += Y * 2 * C
    X = max(X-Y, 0)
    Y = 0
r += A * X
r += B * Y
print(r)


Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
long long n;
typedef pair<long long,long long> pll;
bool cmp(pll x,pll y){
	return x.first+x.second>y.first+y.second;
}
pll dd[100010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>dd[i].first>>dd[i].second;
	}
	sort(dd+1,dd+n+1,cmp);
	long long ttt=0,aaa=0;
	for(int i=1;i<=n;i++){
		ttt+=dd[i].first;
		i++;
		if(i>n)
		   break;
		aaa+=dd[i].second;
	}
	cout<<ttt-aaa<<endl;
	return 0;
}


Measured memory_bytes: 1792
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {                                                                                                                             
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  for (ll i = K; i < N; ++i) {
    if (A[i-K] < A[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

int main(void) {
  int A, B, ans = 0;
  cin >> A >> B;
  for (int i = 0; i < 2; i++) {
    if (A > B)
      ans += A--;
    else
      ans += B--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if ((a + b + c) == 17) {
			if ((a == 7) && (b == 5) && (c == 5)) {
				System.out.println("YES");
			}	else if ((a == 5) && (b == 7) && (c == 5)) {
				System.out.println("YES");
			}	else if ((a == 5) && (b == 5) && (c == 7)) {
				System.out.println("YES");
			}	else {
				System.out.println("NO");
			}
		}	else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    vector<pair<int, int> > vec;//end, start
    int N,M;
    int s,e;
    int last = -1;
    int ans = 0;
    cin >> N >> M;
    for(int i = 0; i < M; i++)
    {
        cin >> s >> e;
        vec.push_back(make_pair(e,s));
    }
    sort(vec.begin(), vec.end());
    for(int i = 0; i < M; i++)
    {
        if(vec[i].second >= last)
        {
            ans++;
            last = vec[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cmath>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;


double PI = 3.14159265358979323846264338327950288;

void solve() {
  double a, b, C;
  cin >> a >> b >> C;
  C = C * PI / 180;
  double S = a * b * sin(C) / 2;
  double h = b * sin(C);
  double foo = b * cos(C);
  double c = h * h + (a-foo) * (a-foo);
  c = pow(c, 0.5);
  double L = a + b + c;
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,e,f,max_suger=0,water,max_water,suger;
  double max_con=0,con;
  cin >> a >> b>>c>>d>>e>>f;
  for(int i=0;i*100*a<=f;i++){
    for(int j=0;100*(i*a+j*b)<=f;j++){
      for(int k=0;100*(i*a+j*b)+c*k<=f;k++){
        for(int l=0;100*(i*a+j*b)+c*k+d*l<=f;l++){
          water=i*a*100+j*b*100;
          suger=c*k+d*l;
          if(((e*water)/100<suger)||(i==0&&j==0&&k==0&&l==0)){
            continue;
          }
          con=(100.0*suger)/(water+suger);
        //  printf("%d %d %d %d %f\n",i,j,k,l,con);
          if(con>=max_con){
            max_con=con;
            max_suger=suger;
            max_water=water;
          }
        }
      }
    }
  }
  cout << max_suger+max_water<<" "<<max_suger<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class K
{
	static void Main()
	{
		var N = int.Parse(Console.ReadLine());
		var ps = new List<P>();
		for (int i = 0; i < N; i++)
		{
			var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
			ps.Add(new P(I[0], I[1]));
		}
		ps.Sort();
		var dp = new List<long>[N + 1];
		dp[0] = new List<long>{ 0 };
		for (var i = 0; i < N; i++)
		{
			dp[i + 1] = dp[i].ToList();
			for (var j = 1; j < dp[i].Count; j++) if (dp[i][j - 1] <= ps[i].H) dp[i + 1][j] = Math.Min(dp[i][j], dp[i][j - 1] + ps[i].Power); else break;
			var z = dp[i][dp[i].Count - 1];
			if (z <= ps[i].H) dp[i + 1].Add(z + ps[i].Power);
			dp[i] = null;
		}
		Console.WriteLine(dp[N].Count - 1);
	}
}
struct P : IComparable<P>
{
	public readonly int H, Power;
	public P(int h, int p) {H = h; Power = p; }
	public int CompareTo(P p) => End.CompareTo(p.End);
	public int End => H + Power;
}


Measured memory_bytes: 38416
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    char h = 'h';
    char ci = 'i';
    bool can = true;
    if (S.size() % 2 != 0) {
        cout << "No" << '\n';
        return 0;
    }
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] != h) can = false;
        }
        else {
            if (S[i] != ci) can = false;
        }
    }
    if (can) cout << "Yes" << '\n';
    else cout << "No" << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MEM 400001
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
const long long MOD = 1e9+9;
long long a,b,t;
long long p[MEM];
int main() {
    cin >> a >> b;
    for(int i=1; i<=a; i++)
        cin >> p[i];
    sort(p+1,p+a+1,greater<int>());
    for(int i=b+1; i<=a; i++)
        t += p[i];
    cout << t;
}


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

int main() {
  long long a, b, c, d, e;
  cin >> d;
  b = 1;
  c = 1;
  a = 1;
  e = 0;
  for (int i = 0; i < d; i++){
    a *= 10;
    a %= 1000000007;
    b *= 9;
    b %= 1000000007;
    c *= 8;
    c %= 1000000007;
  }
  e = a + c - 2 * b;
  if (e < 0){
    e += 1000000007;
  }
  if (e < 0){
    e += 1000000007;
  }
  cout << e << endl;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n-1];
	for(int i=0;i<n-1;i++){
		cin>>arr[i];
	}
	int array[n+1];
	memset(array,0,sizeof(array));
	for(int i=0;i<n-1;i++){
		array[arr[i]]++;
	}
	for(int i=1;i<n+1;i++){
		cout<<array[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5204
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		x = new long[V + 1];
		y = new long[V + 1];
		var dp0 = DFS0(0, V);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp0 = new long[V];
		var st = new Stack<A0>();
		st.Push(new A0(u, p));
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f.p >= 0)
			{
				es[f.u].Remove(f.p);
				st.Push(new A0(f.u, -1));
				foreach (var v in es[f.u]) st.Push(new A0(v, f.u));
			}
			else
			{
				dp0[f.u] = 1L;
				foreach (var v in es[f.u]) dp0[f.u] = dp0[f.u] * (dp0[v] + 1) % Mod;
			}
		}
		return dp0;
	}
	long[] x, y;
	long[] DFS1(int u, long[] dp0)
	{
		var dp1 = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			//var x = new long[W + 1];
			//var y = new long[W + 1];
			x[0] = y[W] = 1;
			for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
			//x = y = null;
			foreach (var v in es[u]) st.Push(v);
		}
		return dp1;
	}
}
struct A0 { public int u, p; public A0(int u, int p) { this.u = u; this.p = p; } }


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

int main(){
  int n; 
  string a,b,c;
  cin>>n>>a>>b>>c;

  int ans=0;
  for(int i=0; i<n; i++){
    if(a[i]==b[i] && b[i]==c[i]);
    else if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i])ans++;
    else ans+=2;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    long long i,n,d,x[200002]={},y[200002]={},count=0;
    scanf("%lld%lld",&n,&d);
    for(i=0;i<n;i++){
        scanf("%lld%lld",&x[i],&y[i]);
        if(d>=sqrt(x[i]*x[i]+y[i]*y[i])) count++;
    }
    printf("%lld",count);

    return 0;
}


Measured memory_bytes: 5304
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    long long a,b,x;
    cin >> a >> b >> x;
    int ans = 0;
    if (a == 0 & x != 1) ans += 1;
    cout << ans + -(a-1)/x + b/x << endl;
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
masu = [list(input()) for _ in range(H)]

from collections import deque

def bfs():
    seen = [[float('inf')]*W for _ in range(H)]
    que = deque([(0,0)])
    seen[0][0] = 0
    while que:
        a,b = que.popleft()
        if a==W-1 and b==H-1:
            break
        for x,y in [[0,1],[1,0],[0,-1],[-1,0]]:
            nx = x + a
            ny = y + b
            if 0<=nx<W and 0<=ny<H and masu[ny][nx]!='#' and seen[ny][nx] == float('inf'):
                que.append((nx,ny))
                seen[ny][nx] = seen[b][a]+1
    return seen[H-1][W-1]
saitan = bfs()
count = 0
for h in range(H):
    for w in range(W):
        if masu[h][w] == '#':
            count += 1
if saitan == float('inf'):
    print(-1)
else:print(H*W-saitan-count-1)

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

using namespace std;

int a[15][4];
int n, m, q;
vector<int> p;
long long ans = -1e18;

void go(int pos, int color) {
  if (pos == n) {
    long long cur = 0;
    for (int i = 0; i < q; i++) {
      if (p[a[i][1] - 1] - p[a[i][0] - 1] == a[i][2]) {
        cur += a[i][3];
      }
    }
    ans = max(ans, cur);
    return;
  }
  for (int i = color; i < m; i++) {
    p[pos] = i;
    go(pos + 1, i);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  p.resize(n);
  for (int i = 0; i < n; i++) {
    p[i] = i; 
  }
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> a[i][j];
    }
  }
  go(0, 0);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll h,n;
  cin>>h>>n;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    h-=a;
  }
  cout<<(h>0?"No":"Yes")<<endl;
}


Measured memory_bytes: 256
s = list(input())

l01 = ["0" if i % 2 == 0 else "1" for i in range(len(s))]
l10 = ["1" if i % 2 == 0 else "0" for i in range(len(s))]

count01 = 0
count10 = 0
for i in range(len(s)):
    if s[i] != l01[i]:
        count01 += 1

for i in range(len(s)):
    if s[i] != l10[i]:
        count10 += 1

print(min(count01, count10))

Measured memory_bytes: 50956
// i/o example

#include <bits/stdc++.h>
using namespace std;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	float a = 0;
	int m,n;
	float index = 0;
	float sum = 0;
	cin >> n >> m;
	int arr[int(n)];
	for(int i = 0; i < n; i++){
		cin >> a;
		arr[i] = a;
		sum+=a;
	}
	float threshold = sum/(4*m);
	for(int i = 0; i < n; i++){
		if (arr[i] >= threshold) index++;
	}
	if(index >= m) cout << "Yes";
	else cout << "No";
	
}


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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 1; i <= (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr int MAX = 2 * 1e5 + 5;

std::vector<int> to[MAX];

bool used[MAX];

int dfs(int v)
{

    int res = 1;

    for (int x : to[v])
    {
        if (!used[x])
        {
            used[x] = 1;
            res += dfs(x);
        }
    }

    return res;
}

int main()
{
    int n, m;

    std::cin >> n >> m;

    rep(i, m)
    {
        int a, b;
        std::cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    int ans = 0;

    rep(i, n)
    {
        if (!used[i])
        {
            used[i] = 1;
            ans = std::max(ans, dfs(i));
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 24088
import java.util.*;
public class Main {
    public static void main(String[] args) {
		String[] list={"SUN","MON","TUE","WED","THU","FRI","SAT"};
      	Scanner sc=new Scanner(System.in);
      	String s=sc.next();
      	int o=0;
      	for(int i=0;i<7;i++){
        	if(list[i].equals(s)){
            	o=7-i;
            }
        }
      	System.out.println(o);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int a[10000001];
inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
int main(){
    int n=read(),s=0;
    for(int i=1;i<=n;i++){
        a[i]=i;
        s+=i;
        if(s>n)
        break;
    }
    int t=s-n;
    for(int i=1;i<=n;i++){
        if(a[i]){
            if(a[i]!=t)
            {
                write(a[i]);
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	int maxX, maxY, minX, minY;
	maxX = x + r;
	maxY = y + r;
	minX = x - r;
	minY = y - r;

	if (maxX > W || maxY > H || minX <0.0 || minY < 0.0)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}




Measured memory_bytes: 3104
import java.util.*;
public class Main{
    public static void main(String[] args) throws Exception {
      
        Scanner sc = new Scanner(System.in);
        int n,m;
        n=sc.nextInt();
        m=sc.nextInt();
        int[] s=new int[m];
        int[] c=new int[m];
        for(int i=0;i<m;i++){
            s[i]=sc.nextInt();
            c[i]=sc.nextInt();
        }
      
        System.out.println(solve(n,m,s,c));
    }

    public static String solve(int n,int m,int[] s,int[] c){
        for(int i=0;i<1000;i++){
            String str=String.valueOf(i);
            if(ok(str,n,m,s,c)){
                return str;
            }
        }
        return "-1";
    }

    public static Boolean ok(String str,int n,int m,int[] s,int[] c){
        if(n!=str.length()) return false;
        for(int i=0;i<m;i++){
            if(str.charAt(s[i]-1)!=c[i]+'0') return false;
        }
        return true;
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#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 INF 2e+9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    string s,rev_s;
    cin >> s;
    rev_s = s;
    string sub = s.substr(0, s.size()/2), rev_sub = sub; 
    string sub2 = s.substr(s.size()/2+1 , s.size()/2), rev_sub2 = sub2;

    reverse(rev_s.begin(),rev_s.end());
    reverse(rev_sub.begin(),rev_sub.end());
    reverse(rev_sub2.begin(),rev_sub2.end());

    bool can = true;
    
    //全体の回文を確認
    REP(i,s.size()){
        if(s[i] != rev_s[i]) can = false;
    }

    //subの回文を確認
    REP(i,sub.size()){
        if(sub[i] != rev_sub[i]) can = false;
    }

    //sub2の回文を確認
    REP(i,sub2.size()){
        if(sub2[i] != rev_sub2[i]) can = false;
    }

    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	var p = new int[n];

	for (int i = 0; i < n; i++)
	{
	    p[i] = int.Parse(ReadLine());
	}

	Array.Sort(p);

	p[n-1] /= 2;

	WriteLine(p.Sum());
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

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

// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	vl v(n+1,0); fore(i,0,n)cin>>v[i];
	vvl dp(n,vl(n,-1));
	vl sum(n+1);
	sum[0]=v[0];
	fore(i,1,n+1)sum[i]=sum[i-1]+v[i];
	auto f=[&](auto f, int l, int r)->lli{
		if(l==r)return 0;
		if(dp[l][r]!=-1)return dp[l][r];
		dp[l][r]=INF;
		fore(i,l,r)dp[l][r]=min(dp[l][r],f(f,l,i)+f(f,i+1,r)+sum[r]-(l?sum[l-1]:0));
		return dp[l][r];
	};
	cout<<f(f,0,n-1)<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 4500
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	cout << A + (B / 2) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()
	l := float64(nextInt())
	fmt.Printf("%f\n", l*l*l/27.0)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if (s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//Insertion_Sort.cpp
#include<iostream>
#include<cstdio>

int bubbleSort(int A[], int N){
  int sw = 0;
  for (size_t i = 0; i <= N; i++) {
    for (size_t j = N-1; j > i; j--) {
      if (A[j-1] > A[j]) {
        int v = A[j];
        A[j] = A[j-1];
        A[j-1] = v;
        sw++;
      }
    }
  }
  return sw;
}

int main() {
  int n; // a number of scores
  scanf("%d", &n);

  int arr[100];
  
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }

  int ans = bubbleSort(arr, n);
  for (size_t k = 0; k < n; k++) {
      printf("%d%c",arr[k],(k==n-1)? '\n':' ');
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3216
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int res = 0;
        for (int i = 1; i < n - 1; i++)
        {
            int cnt = 0;
            if (p[i] < p[i + 1]) cnt++;
            if (p[i] < p[i - 1]) cnt++;
            if (cnt == 1) res++;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
int n, m;
char W[100][100];

void dfs(int y, int x){
    W[y][x] = '0';
    for(int dx = -1; dx <= 1; dx++){
        for(int dy = -1; dy <= 1; dy++){
            int nx = dx + x;
            int ny = dy + y;
            if(W[ny][nx] == '1' and 0 <= nx and nx < n and 0 <= ny and ny < m) dfs(ny, nx);
        }
    }
    return ;
}

int main(void){
    while(true){
        cin >> n >> m;
        if(n == 0 and m == 0) return 0;
        REP(i, m){
            REP(j, n){
                cin >> W[i][j];
            }
        }

        int ans = 0;
        REP(i, m){
            REP(j, n){
                if(W[i][j] == '1'){
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


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

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

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

    string a,b,c; cin >> a >> b >> c;

    cout << char(a[0]+('A'-'a')) << char(b[0]+('A'-'a')) << char(c[0]+('A'-'a')) << endl;

    return 0;

}

Measured memory_bytes: 256
#
# abc067 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
1 2 3 4 5 6"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
10 -10"""
        output = """20"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = float("inf")
    S = sum(A)
    T = []
    T.append(A[0])
    for i in range(1, N):
        T.append(T[i-1]+A[i])

    if N == 2:
        ans = abs(A[0]-A[1])
    else:
        for i in range(1, N-1):
            ans = min(ans, abs(S-2*T[i]))
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 39276
//Name: Books
//Level: 3
//Category: DP,動的計画法
//Note:

/*
 * 同じジャンルの中では，高いものから順に売っていくのが最適なことは自明．
 * あとはジャンルごとに何冊ずつ売るかを決めればよいのだが，これは
 * ・ジャンルgまでを使ってn冊の本を売る
 * ときの売値の最大値を考えると
 * ・ジャンルg-1までを使ってn-k冊の本を売るときの最大値に加え，ジャンルgでk冊の本を売る
 * の(kについての)最大値であることが分かる(ジャンルgでの選択はジャンルg-1まででの選択に影響しないため)．
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

inline bool update(int &a, int v) {
    if(a > v) return false;
    a = v;
    return true;
}

// dp[using_upto_g][sale_books]
int dp[10][2001];
int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int> > books_of(10);
    for(int i = 0; i < N; ++i) {
        int c, g;
        cin >> c >> g;
        --g;
        books_of[g].push_back(c);
    }
    vector<vector<int> > values_of(10);
    for(int i = 0; i < 10; ++i) {
        vector<int> &books = books_of[i];
        vector<int> &values = values_of[i];
        values.push_back(0);
        sort(books.begin(), books.end());
        reverse(books.begin(), books.end());
        const int BN = books.size();
        int acc = 0;
        for(int j = 0; j < BN; ++j) {
            acc += books[j];
            int v = acc;
            if(j > 0) v += j*(j+1);
            values.push_back(v);
        }
    }
    for(int sale = 0; sale < (int)values_of[0].size(); ++sale) {
        dp[0][sale] = values_of[0][sale];
    }
    for(int g = 1; g < 10; ++g) {
        const vector<int> &values = values_of[g];
        const int VN = (int)values.size();
        for(int sale = 0; sale <= K; ++sale) {
            update(dp[g][sale], dp[g-1][sale]);
            for(int prev = 0; prev < sale; ++prev) {
                if(sale-prev < VN) update(dp[g][sale], dp[g-1][prev] + values[sale-prev]);
            }
        }
    }
    cout << dp[9][K] << endl;
    return 0;
}

Measured memory_bytes: 0
N=int(input())
A=sorted([int(i) for i in input().split()],reverse=True)
#6,6,4,4,2,2,0
#7,7,5,5,3,3,1,1
B=[]
for i in range(N//2):
    for p in [0,1]:
        B.append(N-1-2*i)
if N%2==1:
    B.append(0)
for i in range(N):
    if A[i]!=B[i]:
        print(0)
        exit()
M=1
P=10**9+7
for i in range(N//2):
	M=(2*M)%P
print(M)

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

int n,C;
int t[100];

int main(){
  cin>>n;
  while(n)t[C++]=n%3,n/=3;
  string ans="";
  for(int i=0;i<=C;i++){
    if(t[i]==0){
      if(i==C)break;
      ans.push_back('0');
    }else if(t[i]==1){
      ans.push_back('+');
    }else if(t[i]==2){
      ans.push_back('-');
      t[i+1]++;
    }else if(t[i]==3){
      ans.push_back('0');
      t[i+1]++;
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>

#define MAX 100000

using namespace std;

int n, A[MAX + 1], L[MAX];

int lis()
{
  L[0] = A[0];
  int length = 1;

  for (int i = 1; i < n; i++)
  {
    if (L[length - 1] < A[i])
    {
      L[length++] = A[i];
    }
    else
    {
      *lower_bound(L, L + length, A[i]) = A[i];
    }
  }

  return length;
}

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

  cout << lis() << endl;

  return 0;
}


Measured memory_bytes: 3772
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> list = new ArrayList<>();
    int count = 0;

    for(int i = 1; i < n + 1 ; i++){
        list.add(sc.nextInt());
    }

    for(int i = 1; i < n + 1 ; i++){
        if(i % 2 == 1 && list.get(i - 1) % 2 == 1){
            count++;
        }
    }

    System.out.println(count);







    





}
}

Measured memory_bytes: 35700
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC109_B();
        }

        static void ABC109_B()
        {
            var N = int.Parse(Console.ReadLine());
            var W = new HashSet<string>();
            for (var n = 0; n < N; n++)
                W.Add(Console.ReadLine());

            if (W.Count != N)
            {
                Console.WriteLine("No");
                return;
            }

            var list = W.ToList();
            var isShiritori = true;
            for (var n = 0; n < N-1; n++)
            {
                if (list[n].Last() != list[n + 1].First())
                {
                    isShiritori = false;
                    break;
                }
            }
            Console.WriteLine(isShiritori ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13408
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
const int MAX=1e3;
int main(int argc, char *argv[])
{
	int s;
	cin>>s;
	int a[MAX],l=0;
	memset(a,0,sizeof(a));
	a[0]=s;
	bool t=true;
	while(t)
	{
		l++;
		if(a[l-1]%2==0)a[l]=a[l-1]/2;
		else a[l]=a[l-1]*3+1;
		for(int i=0;i<l;i++)
		{
			if(a[l]==a[i])
			{
				t=false;
				break;
			}
		}
	}
	cout<<l+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    double a,b,t;
    cin>>a>>b;
    t = a*pow(10, int(log10(b)+1))+b;
    t = pow(t, 0.5);
    if(t == int(t)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

judge :: Array (Int,Int) Int -> (Int,Int) -> Bool
judge a p@(i,j) = row && col && blk
  where
    v = a ! p
    row = (==1) . length . filter (==v) $ [a ! (i,k) | k <- [0..8]]
    col = (==1) . length . filter (==v) $ [a ! (k,j) | k <- [0..8]]
    blk = (==1) . length . filter (==v) $ [a ! (k,l) | k <- [ii..ii+2], l <- [jj..jj+2]]
    ii = 3 * div i 3
    jj = 3 * div j 3

main = do
    n <- getInt
    forM_ [1..n] $ \t -> do
        f <- listArray ((0,0),(8,8)) . concat <$> replicateM 9 getInts
        forM_ [0..8] $ \i -> putStrLn $ concat [((++) $ cond " " "*" $ judge f(i,j)) . show $ f ! (i,j) | j <- [0..8]]
        when (t/=n) $ putStrLn ""

Measured memory_bytes: 4168