akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
using namespace std;
#define llg long long
#define maxn 200010
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);

inline llg getint()
{
    llg w=0,q=0; char c=getchar();
    while((c<'0' || c>'9') && c!='-') c=getchar();
    if (c=='-')  q=1, c=getchar(); while (c>='0' && c<='9') w=w*10+c-'0', c=getchar();
    return q ? -w : w;
}

struct node{llg val,fa;} a[maxn];

bool cmp(const node &a,const node&b){return a.val<b.val;}

llg n,m,fa[maxn],ans,c[maxn],needb,xian[maxn],chuxian[maxn],bj[maxn];

llg find(llg x) {if (fa[x]!=x) fa[x]=find(fa[x]); return fa[x];}

int main()
{
	cin>>n>>m;
	for (llg i=1;i<=n;i++) c[i]=getint(),fa[i]=i;
	for (llg i=1;i<=m;i++)
	{
		llg x=getint(),y=getint();
		x++,y++;
		if (find(x)!=find(y)) fa[find(x)]=find(y);
	}
	for (llg i=1;i<=n;i++) a[i].val=c[i],a[i].fa=find(i);
	sort(a+1,a+n+1,cmp);
	needb=n-1-m;
	llg cs=0;
	for (llg i=1;i<=n && cs<needb*2;i++)
		if (!chuxian[a[i].fa])
		{
			cs++;
			bj[i]=1;
			chuxian[a[i].fa]=1;
			ans+=a[i].val;
		}
	for (llg i=1;i<=n && cs<needb*2;i++)
	{
		if (xian[a[i].fa]<needb && !bj[i])
		{
			xian[a[i].fa]++;
			ans+=a[i].val;
			cs++;
		}
	}
	if (cs<needb*2) puts("Impossible"); else 
	cout<<ans;
	return 0;
} 


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;    
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
#define PI 3.1415926535897932384626433832795
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define trav(x,v) for (auto &x : v)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pv(v) trav(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) trav(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) trav(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table

const int MOD = 1000000007;
ll dp[3005][3005];
ll solve(ll i, ll j, vector<ll> &v, bool flag){
    if(i==j) return flag?v[i]:0;
    if(dp[i][j] != 0)return dp[i][j];
    if(flag){
        dp[i][j]  = max(solve(i+1, j, v, !flag) + v[i], solve(i, j-1, v, !flag) + v[j]);
    }
    else{
        dp[i][j]  = min(solve(i+1, j, v, !flag) , solve(i, j-1, v, !flag));
    }
    return dp[i][j];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp, 0, sizeof(dp));
    ll n;
    cin >> n;
    vector<ll> v(n);
    F0R(i, n) cin >> v[i];
    ll sum = 0, ret = solve(0, n-1, v, true); 
    F0R(i, n) sum += v[i];
    cout << 2*ret - sum;
    return 0;
}

Measured memory_bytes: 74440
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val K = sc.next().toInt()

        val runrun = mutableListOf<Long>(1, 2, 3, 4, 5, 6, 7, 8, 9)
        var p = 0
        var i = runrun.count()
        while (i < K) {
            val n = runrun[p]
            val r = n % 10
            if (r > 0) {
                runrun.add(n * 10 + r - 1)
                i++
            }
            runrun.add(n * 10 + r)
            i++
            if (r < 9) {
                runrun.add(n * 10 + r + 1)
                i++
            }
            p++
        }
        pw.println(runrun[K - 1])
    }
}


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


int main()
{
    string s,s1;
    int c=0, maxx=INT_MAX;
    cin>>s>>s1;
    for(int i=0;i<(s.size()-s1.size()+1);i++)
    {
        c=0;
        for(int j=0;j<s1.size();j++)
        {
           if(s[i+j]!=s1[j])
            {
                c++;
            }
        }
            maxx=min(maxx,c);
        }

    cout<<maxx;

}



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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var numArray = input.Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(numArray[2].ToString() + " " + numArray[0].ToString() + " " + numArray[1].ToString());
        }
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  pb push_back
#define ff first
#define ss second
#define INF_INT 1e9+5
#define INF_LONG 1e18

///shortcuts
///ctr+alr+T
ll my_max(ll a, ll b)
{
    return a>b? a: b;
}

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

    string s,t;
    cin>>s>>t;
    vector<vector<int> > dp(s.size()+1,vector<int>(t.size()+1,0));

    for(int i = 0 ;i<s.size(); i++)
    {
        for(int j = 0 ;j<t.size();j++)
        {
            if(s[i] == t[j])
            {
                dp[i+1][j+1]= dp[i][j]+1;
               // cout<<s[i];
            } else
            {
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j] );
            }
          //  cout<<dp[i+1][j+1]<<" ";
        }
        //cout<<endl;
    }

    vector<char>ans;
    for(int i = s.size(),j= t.size(); j>=1 && i>=1; )
    {
      //  cout<<i<<" "<<j<<endl;

            if(s[i-1]==t[j-1])
            {
               // cout<<s[i-1]<<" "<<t[j-1]<<endl;
                ans.pb(s[i-1]);
                i--;
                j--;

            }
            else if(dp[i-1][j]>dp[i][j-1])
                i--;
            else j--;
            //cout<<"after: "<<i<<" "<<j<<endl;

    }
    reverse(ans.begin(),ans.end());
    for(auto ch : ans)
        cout<<ch;
    cout<<endl;
}

Measured memory_bytes: 35584
def isPrime(num):
        if num <= 1:
                return False
        elif num == 2 or num == 3:
                return True
        if num % 2 == 0 or num % 3 == 0:
                return False
        if not(num % 6 == 1) and not(num % 6 == 5):
                return False
        i = 5
        while i * i <= num:
                if num % i == 0 or num % (i + 2) == 0:
                        return False
                i += 6
        return True

num = int(input())
count = 0
for i in range(num):
        if isPrime(int(input())):
                count += 1

print(count)


Measured memory_bytes: 5612
#include <iostream>                                                                                      
using namespace std;                                                                                     
void swap(int& a, int& b){                                                                               
  int tmp = a;                                                                                           
  a = b;                                                                                                 
  b = tmp;                                                                                               
}                                                                                                        
                                                                                                         
int main(){                                                                                              
  int a, b;                                                                                              
  cin >> a >> b;                                                                                         
  while (a or b){                                                                                        
    if (a>b) swap(a, b);                                                                                 
    cout << a << " " << b << endl;                                                                       
    cin >> a >> b;                                                                                       
  }                                                                                                      
} 


Measured memory_bytes: 3084
import java.util.*;
import java.io.*;

public class Main {
	
	public void solve() throws IOException{
		int n = nextInt();
		for(int i = 0; i < n; i++){
			String[] s = nextToken().split(":");
			int[] hand = new int[2];
			hand[0] = Integer.parseInt(s[0]);
			hand[1] = Integer.parseInt(s[1]);
			double key = Math.abs(hand[1]*6 - (hand[0]*30 + (double)hand[1]/2));
			key = Math.min(key, 360-key);
			if( key < 30 ){
				writer.println("alert");
			} else if( key < 90 ){
				writer.println("warning");
			} else {
				writer.println("safe");
			}
			writer.flush();
		}
	}			
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

Measured memory_bytes: 10000
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                int cnt = 0;
                while (x % 2 == 0) {
                    x /= 2;
                    cnt++;
                }
                ans = Math.min(ans, cnt);
            }
            System.out.println(ans);
        }
    }
}


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

int main(int argc, const char * argv[]) {
    int N, K, l;
    vector<int> v;
    int sum;
    
    //初期化
    sum = 0;
    
    //入力
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> l;
        v.push_back(l);
    }
    //最大値計算
    //昇順ソート
    sort(v.begin(), v.end());
    //反転
    reverse(v.begin(), v.end());
    for (int i = 0; i < K; i++) {
        sum += v[i];
    }
    
    //出力
    cout << sum << endl;
    
    return 0;
}


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

class Program
{
    static void Main()
    {
        var N=int.Parse(ReadLine());
        var s=ReadLine();
        var uf = new UnionFind(N);
        for (int i = 1; i < s.Length; i++)
        {
            if(s[i]==s[i-1])uf.Unite(i,i-1);
        }
        WriteLine(uf.Count);
    }
}

public class UnionFind
{
    int[] parent;
    int count;
    public int Count => count;

    public UnionFind(int length)
    {
        parent = new int[length];
        for (int i = 0; i < parent.Length; i++)
        {
            parent[i] = -1;
        }
        count = length;
    }

    public int Root(int v) => parent[v] < 0 ? v : parent[v] = Root(parent[v]);

    public bool Same(int l, int r) => Root(l) == Root(r);

    static void Swap<T>(ref T l, ref T r)
    {
        var t = l;
        l = r;
        r = t;
    }

    public bool Unite(int l, int r)
    {
        l = Root(l);
        r = Root(r);
        if (l == r) return false;
        count--;
        if (parent[l] > parent[r]) Swap(ref l, ref r);
        parent[l] += parent[r];
        parent[r] = l;
        return true;
    }

    public int Size(int v) => -parent[Root(v)];
}

Measured memory_bytes: 11616
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int kind;
int num[40];
int main(){
	int n,m,t;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>t;
		for(int j=1;j<=t;j++){
			cin>>kind;num[kind]++;
		}
	}
	int ans=0;
	for(int i=1;i<=m;i++){
		if(num[i]==n) ans++;
	}
	cout<<ans<<endl;
	return 0;
}




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

int main() {
    int n, k;
    while (cin >> n >> k) {
        int cnt = 0;
        while (n) {
            n /= k;
            ++cnt;
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <limits>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;

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

    int total = 0;
    vector<int> t(n), v(n);
    REP(i, n){
        int a;
        cin >> a;
        t[i] = t[max(0, i-1)] + a;
    }
    for(int& i : v){
        cin >> i;
    }
    v.push_back(0);

    double speed = 0.0, ans = 0.0;
    int area = 0;

    for(double i = 0.0; i < t.back(); i += 0.5){
        double speed2 = speed;
        bool down = false;
        if(i == t[area]){
            area++;
        }
        for(int j = area; j < n; j++){
            if(speed - v[j+1] >= t[j] - i){
                down = true;
                break;
            }
        }
        if(down){
            speed2 -= 0.5;
        }else if(speed < v[area]){
            speed2 += 0.5;
        }
        ans += (speed + speed2) * 0.25;
        speed = speed2;
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
long long n,m,k,l,i=0;
int main(){
	scanf("%lld%lld%lld",&n,&m,&k),l=k;
	do l+=m+k,i++;while(l<n);
	if(l>n) i--;
	printf("%lld\n",i);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):

    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]

    for i in range(H):
        for j in range(W):
            if(s[i][j] == '#'):
                f = False
                for k in range(4):
                    iy = i+dy[k]
                    ix = j+dx[k]
                    if(0 <= iy < H and 0 <= ix < W and s[iy][ix] == '#'):
                        f = True
                if(f == False):
                    print(NO)
                    exit()
                
    print(YES)

    return


# Generated by 1.1.5 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()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n, m, h[N];
vector <int> gr[N];

void solve() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	int ans = 0;
	for (int u = 0; u < n; u++) {
		bool fl = true;
		for (int v : gr[u])
			fl &= h[u] > h[v];
		ans += fl;
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 13868
//package NomuraContest2020;

import java.util.*;
import java.io.*;
import java.math.*;


class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        //Start here:
        String input[]=br.readLine().split(" ");
        
        int h1=Integer.parseInt(input[0]);
        int m1=Integer.parseInt(input[1]);
        int h2=Integer.parseInt(input[2]);
        int m2=Integer.parseInt(input[3]);
        
        int time=Integer.parseInt(input[4]);
        
        int t=(h2-h1)*60+(m2-m1);
        
        int ans=t-time;
        if(ans<0)
        {
        	System.out.println(-1);
        }
        else
        {
        	System.out.println(ans);
        }
        
        

    }
}

Measured memory_bytes: 32484
#include <iostream>
#include <cassert>
#include <string>
#include <cctype>
using namespace std;

string S;
size_t cur = 0;
char readchar();
char peek();
int digit();
int number();
int term();
int expression();
int factor();

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cur = 0;
        cin >> S;
        S.resize(S.size()-1);
        cout << expression() << endl;
    }
    return 0;
}

char readchar(){
    assert(cur < S.size());
    char ret = S[cur];
    cur += 1;
    return ret;
}

char peek(){
    assert(cur < S.size());
    return S[cur];
}

int digit(){
    assert(isdigit(peek()));
    int n = readchar() - '0';
    return n;
}

int number(){
    int n = digit();
    while(cur < S.size() && isdigit(peek()))
        n = n*10 +digit();
    return n;
}

int term()
{
    int a = factor();
    while(cur < S.size() && (peek() == '*' || peek() == '/')){
        char op = readchar();
        int b = factor();
        if (op == '*') a *= b; else a /= b;
    }
    return a;
}

int expression(){
    int a = term();
    while(cur < S.size() && (peek() == '+' || peek() =='-'))
    {
        char op =readchar();
        int b = term();
        if(op == '+')
        {
            a += b;
        }
        else a -= b;
    }
    return a;
}
int factor() {
    if (peek() != '(') return number();
    cur += 1;
    int n = expression();
    assert(peek() == ')');
    cur += 1;
    return n;
}
int parse() {return expression();}

Measured memory_bytes: 3108
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <cmath>
#define SIZE 200005

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

int pos[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int p;
		scanf("%d",&p);p--;
		pos[p]=i;
	}
	int ret=0;
	for(int i=0;i<n;i++)
	{
		int f=i;
		for(;i+1<n&&pos[i]<pos[i+1];i++);
		ret=max(ret,i-f+1);
	}
	printf("%d\n",n-ret);
	return 0;
}


Measured memory_bytes: 896
import sys
input = sys.stdin.readline
INF = 10**20
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)

def main():
    n = int(input())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    
    depth = [-1] * n
    depth[0] = 0
    snuke = [0] * n
    snuke[-1] = 1
    children = [1] * n

    def dfs(i):
        if len(G[i]) == 0:
            return
        else:
            for e in G[i]:
                if depth[e] == -1:
                    depth[e] = depth[i] + 1
                    dfs(e)
                    snuke[i] |= snuke[e]
                    children[i] += children[e] 
  
    dfs(0)
    white = depth[-1]//2 + 1
    for i in range(n):
        if depth[i] == white and snuke[i]:
            sp = children[i]
            fp = n - sp
            break
    
    if  fp > sp:
        print('Fennec')
    else:
        print('Snuke')  
if __name__=='__main__':
    main()

Measured memory_bytes: 140848
inputstr1 = [input() for inputstr1 in range(6)]

a = int(inputstr1[0])
b = int(inputstr1[1])
c = int(inputstr1[2])
d = int(inputstr1[3])
e = int(inputstr1[4])
k = int(inputstr1[5])

inputmax = max(a, b, c, d, e)
inputmin = min(a, b, c, d, e)


if inputmax - inputmin <= k :
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> T INF = 1000000007;

template <typename T>
struct edge {
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};



int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<edge<int>>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b, l;
        scanf("%d %d %d", &a, &b, &l);
        G[a-1].emplace_back(b-1, l);
        G[b-1].emplace_back(a-1, l);
    }
    vector<int> d(n, INF<int>);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> Q;
    for (int i = 0; i < k; ++i) {
        int t; cin >> t; t--;
        d[t] = 0;
        Q.emplace(0, t);
    }
    while(!Q.empty()){
        int cost; int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    int ans = *max_element(d.begin(),d.end());
    for (int i = 0; i < n; ++i) {
        for (auto &&e : G[i]){
            if(d[e.to] < d[i] || d[e.to] == d[i]+e.cost) continue;
            ans = max(ans, (d[e.to]+d[i]+e.cost+1)/2);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7420
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=5e5+50,K=11;

int n,m,col[N];
bool f[N][K];
vector<int> g[N]; 

void gao(int v,int k,int c){
	//Pr("Gao %d,%d,%d\n",v,k,c); 
	if(f[v][k])return;else f[v][k]=true;
	if(k==0)col[v]=c;
	else{
		gao(v,k-1,c); 
		for(int d:g[v])gao(d,k-1,c); 
	}
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n),read(m); 
	rep(i,1,m){
		int u,v; 
		read(u),read(v);
		g[u].pb(v); 
		g[v].pb(u); 
	}
	static int Q,V[N],D[N],C[N];
	read(Q); 
	rep(i,1,Q){
		read(V[i]),read(D[i]),read(C[i]); 
	}
	dec(i,Q,1){
		gao(V[i],D[i],C[i]); 
	}
	rep(i,1,n)printf("%d\n",col[i]);
	return 0;
}

Measured memory_bytes: 26616
import java.util.Scanner;

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

        while (true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if ((m == -1) && (f == -1) && (r == -1)) {
                break;
            }

            if (m == -1 || f == -1 || (m + f) < 30) {
                System.out.println("F");
            } else if ((m + f) >= 80) {
                System.out.println("A");
            } else if ((m + f) >= 65) {
                System.out.println("B");
            } else if ((m + f) >= 50 || (((m + f) < 50) && ((m + f) >= 30) && (r >= 50))) {
                System.out.println("C");
            } else {
                System.out.println("D");
            }
        }
    }
}


Measured memory_bytes: 26300
#include <stdio.h>
#include <string.h>
#define MAXL 10

int main(void){
    char a[MAXL + 1], b[MAXL + 1], c[MAXL + 1];
    scanf("%s %s %s", a, b, c);
    
    printf("%s\n", (a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0])? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 128
def main():
  n = int(input())
  a = list(map(int, input().split()))
  d = [0]*n
  for i, x in enumerate(a):
    if i+x < n: d[i+x] += 1
  ans = 0
  for i, x in enumerate(a):
    if i-x >= 0: ans += d[i-x]
  print(ans)
main()

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

typedef long long ll;

const int N = 303;
int n, m;
ll dp[N][N];
ll A[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }
    if (m >= n) {
        cout << 0 << endl;
        exit(0);
    }

    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int k = 1; k <= n - m; ++k) {
            for (int j = 0; j < i; ++j) {
                dp[i][k] = min(dp[i][k], dp[j][k - 1] + max(0LL, A[i] - A[j]));
            }
        }
    }

    ll res = LLONG_MAX;
    for (int i = 1; i <= n; ++i) {
        res = min(res, dp[i][n - m]);
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;

#define int long long 
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)
 
const ll INF = 2e9;
const ll large_P = 1e9 + 7;


signed main() {
	int A, B;
	cin >> A >> B;

	if (A != 1 && B != 1) cout << 1 << endl;
	else if(A != 2 && B != 2) cout << 2 << endl;
	else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
 
using namespace std;
 
int main ()
{
    int n;
 
    scanf("%d", &n);
 
    long long fact = 1;
 
    for ( int i = 1; i <= n; i++ )
        fact *= i;
 
    cout << fact << endl;
 
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

    lli n;
    cin>>n;

    vector<lli> h(n);
    REP(i,0,n)cin>>h[i];

    lli num = h[n-1];

    for(lli i=n-2;i>=0;i--){
        if(h[i]>num){
            h[i]--;
        }
        if(h[i]>num){
            cout<<"No"<<endl;
            return 0;
        }
        num = min(num,h[i]);
    }
    cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ECountMedian {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N), B(N);
        REP(i, N) cin >> A[i] >> B[i];
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());

        if (N & 1) {
            int mid = N / 2;
            cout << B[mid] - A[mid] + 1 << endl;
        } else {
            int mid1 = N / 2;
            int mid2 = mid1 - 1;
            cout << (B[mid1] + B[mid2]) - (A[mid1] + A[mid2]) + 1 << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ECountMedian solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 6332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * Twin Prime
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean[] primes = new boolean[10001];

		Arrays.fill(primes, true);
		for (int i = 2; i < 10001; i++) {
			if (primes[i]) {
				for (int j = 2; j * i < 10001; j++) {
					if (primes[i * j]) {
						primes[i * j] = false;
					}
				}
			}
		}

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			for (int i = n; i > 1; i--) {
				if (primes[i] && primes[i - 2]) {
					System.out.println(i - 2 + " " + i);
					break;
				}
			}
		}

	}

}

Measured memory_bytes: 24840
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int a;
    cin >> a;
    string s1, s2;
    cin >> s1 >> s2;

    string s;
    for (int i = 0; i < a; i++) {
        s.push_back(s1[i]);
        s.push_back(s2[i]);
    }
    cout << s << '\n';

}


Measured memory_bytes: 256
#include "iostream"
#include "map"
using namespace std;

int main()
{
	int n;
	map<int,int> m;
	int count=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int num;
		cin>>num;
		if(m[num]==0)
		{
			m[num]=1;
			count++;
		}
			
		else
		{
			m[num]=0;
			count--;
		}
	}
	cout<<count<<endl;
	system("pause");
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n,q;
	string s;
	cin >> n >> q >> s;
	vector<int> sum(n);
	rep(i,n-1)
	{
		if(s[i]=='A'&&s[i+1]=='C')
		{
			sum[i+1] += sum[i] + 1;
		}
		else
		{
			sum[i+1] += sum[i];
		}
		
	}
	//rep(i,n)cout<<sum[i]<<endl;
	rep(i,q)
	{
		int l,r;
		cin >> l >> r;
		cout<<sum[r-1]-sum[l-1]<<endl;
	}
	return 0;
}

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

typedef long long ll;


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

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

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

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll ab[25000][2500];
int main() {
	double x,y;
	cin >> w >> h >> x >> y;
	double xx = w / 2;
	double yy = h / 2;
	double res = w * h / 2;
	int k = 2;
	if (x == xx && y == yy) {
		k = 1;
	}
	else {
		k = 0;
	}
	cout << res<<" "<< k << endl;
}

Measured memory_bytes: 256
a,b,c = gets.split.map(&:to_i)
d,e,f = gets.split.map(&:to_i)
g,h,i = gets.split.map(&:to_i)

ok = true

if !(a-d == b-e && b-e == c - f)
  ok = false
elsif !(d-g == e-h && e-h == f - i)
  ok = false
elsif !(a-b == d-e && d-e == g-h)
  ok = false
elsif !(b-c == e-f && e-f == h-i)
  ok = false
end

puts ok ? "Yes" : "No"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll K;
  cin >> K;
  vll A(K);
  REP(i, K) cin >> A[i];

  if(A[K-1]!=2){
    cout << "-1\n";
    return 0;
  }
  
  //after final 
  ll N_min = 2;
  ll N_max = 2;
  RREP(i, K-1){
    ll tmp1 = (N_min/A[i])*A[i], tmp2 = (N_max/A[i])*A[i];
    while((tmp1/A[i])*A[i] < N_min) tmp1+=A[i];
    while((tmp2/A[i])*A[i] <= N_max) tmp2+=A[i];
    tmp2--;
    if(tmp1>tmp2){
      cout << "-1\n";
      return 0;
    }
    N_min = tmp1;
    N_max = tmp2;
  }

  cout << N_min << " " << N_max << "\n";

  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll X, N; cin >> X >> N;

  vector<ll> a(110, 0);
  rep(i, N) {
    ll a1;
    cin >> a1;
    a[a1] = 1;
  }
  
  ll ans = 0;
  rep(i, 110) {
    ll a1 = X - i;
    if(a1 >= 0) {
      if(a[a1] == 0) { ans = a1; break; }
    }
    a1 = X + i;
    if(a1 < 105) {
      if(a[a1] == 0) { ans = a1; break;}
    }
  } 
  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3728
module Main where

import Control.Monad
import Control.Applicative
import Data.List

showingList :: [Int] -> String
showingList (x:[]) = show x
showingList (x:xs) = (show x) ++ " " ++ (showingList xs)


main :: IO ()
main = do
    x <- readLn
    print $ (-x `mod` 1000 + 1000) `mod` 1000


Measured memory_bytes: 3752
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin>>n;
	Array s(n);
	REP(i,n) cin>>s[i];

	//a,a-b,a+a-b,..,n-1
	//c=a-b -> a,c,a+c,2*c,...,n-1
	//a+k*c=n-1 -> c,2*c,...,k*c,n-1-k*c,...,n-1
	ll ans=0;
	rep(c,1,n-1){
		ll sum=0;
		if((n-1)%c == 0){
			for(ll k=1;2*k*c<n-1;k++){
				sum+=s[k*c]+s[n-1-k*c];
				chmax(ans,sum);
			}
		}else{
			for(ll k=1;c<n-1-k*c;k++){
				sum+=s[k*c]+s[n-1-k*c];
				chmax(ans,sum);
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
N = int(input())
c = input()
var = 0
i = 0
j = 0
while True:
  if i+j >= N:
    break
  else:
    if c[i] == "W":
      if c[-1-j] == "R":
        var += 1
        i += 1
        j += 1
      else:
        j += 1
    elif c[i] == "R":
      i += 1
print(var)

Measured memory_bytes: 9368
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 2e5+5;
int n,k,cnt[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<n;++i) read(k),++cnt[k];
	for(ri i=1;i<=n;++i) printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 4472
a, b=map(int, input().split())
try:
    c = a // (b // 2)
    c = c //2 + c%2
except Exception as  e:
    c = 0
if b % 2 == 1:
    c = 0
try:
    d = a // b
except Exception as e:
    d = 0
print(c**3 + d**3)

Measured memory_bytes: 2940
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, K, C;
string S;
int earl [200000];
int late [200000];

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K >> C >> S;
    int ind = 0;
    F0R(i,K) {
        while (S[ind] == 'x' && ind != N-1) ind++;
        earl[i] = ind;
        ind += C+1;
    }
    ind = N-1;
    RF0(i,K) {
        while (S[ind] == 'x' && ind != 0) ind--;
        late[i] = ind;
        ind -= C+1;
    }
    F0R(i,K) {
        if (earl[i] == late[i]) cout << earl[i]+1 << '\n';
    }
}

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

using namespace std;

typedef long long ll;

int dp[1000050];

bool eh(ll num){
	if(dp[num]) return false;
	if(num < 0) return false;
	if(num == 0) return true;

	bool tem = false;
	
	for(int i = 0; i < 6; i++){
		tem = tem || eh(num - (100+i));	
	}

	if(tem)
		return true;
	else{
		dp[num] = 1;
		return false;
	}

}

int main(){
	ll num;
	cin >> num;

	if(eh(num))
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long long a,sum,max,min,i,n;
  sum=0; max=-2000001; min=2000001;
  scanf("%lld",&n);
  for(i=1;i<=n;i++)
    { scanf("%lld",&a);
      if(a>=max)max=a;
      if(a<min)min=a;
      sum+=a;
    }
  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
}

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

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[1000000],s[1000000];
int main(){
	scanf("%s%s",c,s);
	printf("%s%s\n",s,c);
	return 0;
}


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

    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n;
  ll t[100010] = {}, a[100010] = {};
  cin >> n;
  rep(i, n) cin >> t[i + 1];
  rep(i, n) cin >> a[i + 1];

  ll ans = 1;
  rep(i, n) {
    if (t[i] < t[i + 1]) {
      if (a[i + 2] < a[i + 1]) {
	if (a[i + 1] != t[i + 1]) {
	  cout << 0 << endl;
	  return 0;
	}
      } else {
	if (t[i + 1] > a[i + 1]) {
	  cout << 0 << endl;
	  return 0;
	}
      }
    } else {
      if (a[i + 2] < a[i + 1]) {
	if (a[i + 1] > t[i + 1]) {
	  cout << 0 << endl;
	  return 0;
	}
      } else {
	ans *= min(t[i + 1], a[i + 1]);
	ans %= MOD;
      }
    }
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1792
module A
  sub Main(ByVal args() as String)
    dim a,b as integer
    dim ans as integer
    dim arr(2) as string
    arr = Split(Console.ReadLine())
    a = arr(0): b = arr(1)
    ans = a-2*b
    Console.WriteLine(If(ans > 0, ans, 0))
    
  end sub
end module

Measured memory_bytes: 13532