akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int alp[300][300];
int min(int a,int b){if(a>b)return b;return a;}
signed main(){
  int n;
  cin>>n;
  vector<str> s(n);
  repi(n) cin>>s[i];
  str ans="";
  rep(i,n){
    rep(j,s[i].length()){
      alp[i][s[i][j]+0]++;
    }
  }
  for(int i='a';i<='z';++i){
    int chk=inf;
    rep(j,n){
      chk=min(chk,alp[j][i]);
    }
    rep(k,chk)ans+=('0'+(i-48));
  }
  SORT(ans);
  cout<<ans<<endl;

  return 0;
}



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

int main(){
    int homu, homuhomu, homuhomuhomu;
    cin >> homu >> homuhomu >> homuhomuhomu;
    int HOMU = 200;
    while(homuhomuhomu){
        --HOMU;
        if(!(homu % HOMU) && !(homuhomu % HOMU) ){
            --homuhomuhomu;
        }
    }
    cout << HOMU << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;

const int MOD = 998244353;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);
const int N = (int)1e5 + 9;

bool isprime(ll n) {
	if (n <= 1)
		return 0;
	for (ll i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
	return 1;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll power(ll x, int y)
{
	ll temp;
	if (y == 0)
		return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp * temp;
	else
		return x * temp*temp;
}
int n;
vector<int> v;
ll dp[100005];

int main()
{
	scanf("%d", &n);
	v.resize(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &v[i]);
	}
	dp[0] = 0;
	dp[1] = fabs(v[1] - v[0]);
	ll sum = 0;
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(fabs(v[i] - v[i - 1])+dp[i-1], fabs(v[i] - v[i - 2])+dp[i-2]);
	}
	printf("%lld\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <cmath>
#include <algorithm>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;


int main(){

	int N,M,maximum,table[1000];

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		maximum = 0;

		for(int i = 0; i < N; i++)scanf("%d",&table[i]);

		for(int i = 0; i < N-1; i++){
			for(int k = i+1; k < N; k++){
				if(table[i]+table[k] <= M){
					maximum = max(maximum,table[i]+table[k]);
				}
			}
		}

		if(maximum == 0){
			printf("NONE\n");
		}else{
			printf("%d\n",maximum);
		}
	}

	return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int a[25],b[25],c[25],ans,n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	    cin>>a[i];
	for(int i=1;i<=n;i++)
	    {
	    	cin>>b[i];
	    	ans+=b[i];
		}
	    
	for(int i=1;i<n;i++)
	    cin>>c[i];
	for(int i=1;i<n;i++)
	    {
	    	if(a[i]==a[i+1]-1)
	    	    ans+=c[a[i]];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 764
s=input()
n=len(s)-1 
sub=[] 
t=(1<<n)
sm=0 
for i in range(t):
    curr=[]
    for j in range(n):
        if i&(1<<j):
            curr.append(j)
    now=''
    part=[]
    for it in range(len(s)): 
        now+=s[it]
        if it in curr:
            part.append(now)
            now=''
    part.append(now)
    for p in part: 
        #print(p)
        sm+=int(p)
print(sm)
            

Measured memory_bytes: 40176
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=a+b+c+d;
	y=0;
	while(!(x<60)) {
	x=x-60;
	y+=1;
	}
	printf("%d\n",y);
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;
 
	public class Main {
		public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      
      	int N  =sc.nextInt();
       	int M  =sc.nextInt();
          
        int t[] = new int[N];
        double tt =0;
        for(int i=0; i<N; i++){
        	t[i] =sc.nextInt();
        	tt +=t[i];
        }
          double a = 0;
          int b = 0;
          for(int i=0; i<N; i++){
          	a = tt/(4*M);
          if(t[i]>=a){
            b++;
            if(b>=M){
          System.out.println("Yes");
              return;
          }
            }
          }
          System.out.println("No");
        }
    }

Measured memory_bytes: 36096
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++) cin >> H.at(i);
    int flag=1;
    for(int i=0;i<N;i++){
        if(i==0) H.at(i)--;
        else{
            if(H.at(i-1)>H.at(i)){
                flag=0;break;
            }
            else if(H.at(i-1)<H.at(i)) H.at(i)--;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  string r="CODEFESTIVAL2016";
  int ans=0;
  for(int i=0;i<s.size();i++)
    if(s[i]!=r[i])ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/


int N;
int A[100005];
ll sum = 0;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N){
        cin >> A[i];
    }
    int tmp = 0;
    rep(i,N){
        if (tmp > 0 and A[i] > 0){
            tmp--;
            A[i]--;
            sum++;
        }
        sum += A[i]/2;
        A[i] = A[i] % 2;
        tmp = A[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll gcd3(ll a, ll b, ll c){
  return gcd(gcd(a, b), c);
}

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

  ll ans = 0;

  rep2(a, 1, K + 1){
    rep2(b, a, K + 1){
      rep2(c, b, K + 1){
        if((a == b) && (b == c)){
          ans += gcd3(a, b, c);
        } else if((a == b) || (b == c)){
          ans += 3 * gcd3(a, b, c);
        } else{
          ans += 6 * gcd3(a, b, c);
        }
      }
    }
  }

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


Measured memory_bytes: 3636
import collections
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
k = collections.Counter(a)
for _ in range(m):
    b, c = map(int, input().split())
    k[c] += b
ans = 0
count = 0
for key in list(reversed(sorted(list(k.keys())))):
    ans += (min(k[key], n - count)) * key
    count += min(k[key], n - count)
    if count == n:
        break
print(ans)

Measured memory_bytes: 32448
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    long long N, K; cin >> N >> K;
    long long p[N];

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

    double MAX = 0;
    for(int i = 0; i < K; i++) {
        MAX += 0.5 * p[i] + 0.5;
    }

    double prev = MAX;
    for(int i = K; i < N; i++) {
        double cur = prev + (0.5 * p[i] + 0.5) - (0.5 * p[i - K] + 0.5);
        if(MAX < cur) {
            MAX = cur;
        }
        prev = cur;
    }

    cout << fixed << setprecision(12) << MAX << endl;

}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    if (n == 0) return 1;
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

lint A, B, N;
lint f(lint x)
{
    return floor((long double)A/B * x);
}

int main()
{
    cin >> A >> B >> N;
    cout << f(min(B-1, N)) << endl;

    return 0;
}


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

int h;

void maxHeapify(vector<int> &heap, int i){
    int left_index = 2 * i;
    int right_index = 2 * i + 1;

    int largest_index = i;

    if(left_index <= h && heap.at(left_index) > heap.at(i)){
        largest_index = left_index;
    }
    if(right_index <= h && heap.at(right_index) > heap.at(largest_index)){
        largest_index = right_index;
    }

    if(largest_index != i){
        // インデックスiの中身とインデックスlargest_indexの中身をswap
        int tmp = heap.at(i);
        heap.at(i) = heap.at(largest_index);
        heap.at(largest_index) = tmp;
        // swapした結果、largest_indexでのヒープが崩れる可能性があるので再びheapify
        maxHeapify(heap, largest_index);
    }

}

void buildMaxHeap(vector<int> &heap){
    for(int i = h/2; i > 0; i--){
        maxHeapify(heap, i);
    }
}
int main(){
    cin >> h;
    // heapは1オリジンとする
    vector<int> heap(h+1); 

    //ヒープの読み込み
    for(int i = 1; i < h+1; i++){
        cin >> heap.at(i);
    }

    buildMaxHeap(heap);
    
    for(int i = 1; i < h + 1; i++){
        cout << " " << heap.at(i);
    }
    cout << endl;

}


Measured memory_bytes: 4604
import sys
sys.setrecursionlimit(10**7)


N = int(input())
AB = [list(map(int,input().split())) for _ in range(N-1)]
adj = [[] for _ in range(N)]
for i in range(N-1):
    adj[AB[i][0]-1].append([AB[i][1]-1,i])
    adj[AB[i][1]-1].append([AB[i][0]-1,i])


col = [0]*(N-1)
visited = [False] * N
visited[0] = True
def dfs(v, color):
    child = adj[v]
    ctmp = 1
    for u,idx in child:
        if not(visited[u]):
            if ctmp == color:
                ctmp += 1
            col[idx] = ctmp
            visited[u] = True
            dfs(u,ctmp)
            ctmp += 1
    return 
            
    
    
    

dfs(0,0)
K = max(col)
print(K)
for k in col:
    print(k)


    

Measured memory_bytes: 89920
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60);

double a, b, x;

int main(){
    scanf("%lf%lf%lf", &a, &b, &x);
    if(a * a * b / 2 > x){
        double y = 2 * x / a / b;
        printf("%.10lf\n", 90.0 - std::atan2(y, b) / (2 * M_PI) * 360);
    }else{
        double y = 2*b - 2*x / (a*a);
        printf("%.10lf\n", std::atan2(y, a) / (2 * M_PI) * 360);
    }
}


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

int main()
{
	int n;
	std::cin >> n;
	std::vector<long long> a(n);
	for(int i = 0; i < n; i++)std::cin >> a[i];
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i]< 0)cnt++;
		a[i] = std::abs(a[i]);
	}
	long long sum = 0;
	for(int i = 0; i < n; i++)sum += a[i];
	if(cnt % 2 == 1){
		sum -= *std::min_element(a.begin(),a.end()) * 2;
	}
	//for(int i = 0; i < n; i++)std::cout << a[i] << std::endl;
	std::cout << sum << std::endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcoder096_A
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力を受け取る
            string[] t_input = Console.ReadLine().Split();
            int a = int.Parse(t_input[0]);
            int b = int.Parse(t_input[1]);

            int result = a - 1 + (a <= b ? 1 : 0);

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  ll n;
  cin >> n;
  ll ans = n - 1ll;
  for (ll i = 2; i * i <= n; i++){
    if (n % i == 0){
      setmin(ans, i + (n / i) - 2);
    }
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
1000000000000000000


*/

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;cin >> h >> w >> k;
    char s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s[i][j];
        }
    }
    int ans=(h-1)*(w-1);
    for(int b=0;b<(1<<(h-1));b++){
        int cnt=0;
        vector<int> p(h);
        for(int i=0;i<h-1;i++){
            if(b&(1<<i)){
                cnt++;
            }
            p[i+1]=cnt;
        }
        int res=cnt;
        bool g=true;
        vector<int> sum(cnt+1);
        for(int j=0;j<w;j++){
            vector<int> tmp(cnt+1);
            for(int i=0;i<h;i++){
                if(s[i][j]=='1'){
                    tmp[p[i]]++;
                }
            }
            bool f=true;
            for(int i=0;i<=cnt;i++){
                if(tmp[i]>k){
                    g=false;
                    break;
                }
                if(sum[i]+tmp[i]>k){
                    f=false;
                }
            }
            if(!g){
                break;
            }
            if(f){
                for(int i=0;i<=cnt;i++){
                    sum[i]+=tmp[i];
                }
            }
            else{
                res++;
                for(int i=0;i<=cnt;i++){
                    sum[i]=tmp[i];
                }
            }
        }
        if(!g){
            continue;
        }
        chmin(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import numpy as np
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

P = np.array(P)
X = P[P <= A]
Y = P[(P >= (A + 1)) & (P <= B)]
Z = P[P >= (B + 1)]

print(min(len(X), len(Y), len(Z)))

Measured memory_bytes: 12396
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
  string s,t;
  cin>>s>>t;

  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
import itertools
def main():
    n=int(input())
    p=list(map(int,input().split()))
    q=list(map(int,input().split()))

    perm = list(itertools.permutations(range(1,n+1)) )
    ansp = perm.index(tuple(p))
    # qq = list(itertools.permutations(q) )
    ansq = perm.index(tuple(q))

    print(abs(ansp-ansq))

if __name__=='__main__':
    main()


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 200005
#define pi 3.14159
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res='1'; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/='2'; } return res;}
ll exp(ll x,ll y){ ll res='1'; while(y) {if(y%2) res=(res*x); x=(x*x); y/='2'; } return res;}



int main(){
    ll n; cin>>n;
    ll a[n+1];
    fill(a,a+n+1,0);
    for(ll i=0;i<n-1;i++){
        ll x; cin>>x;
        a[x]++;
    }
    for(ll i=1;i<=n;i++)
        cout<<a[i]<<endl;
    
    return 0;
}
 


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define LOG(...) printf(__VA_ARGS__)
using namespace std;

struct Point {
    int t, x, y;
};

int manhattan(Point p1, Point p2) {
    return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}

int main() {
    int N;
    cin >> N;
    
    vector<Point> vp;

    for (int i = 0; i < N; ++i) {
        Point p;
        cin >> p.t >> p.x >> p.y;
        vp.push_back(p);
    }

    Point now = { 0, 0, 0 };
    for (Point p : vp) {
        int td = p.t - now.t;
        int d = manhattan(p, now);

        if (td >= d && (d - td) % 2 == 0) {
            now = p;
            continue;
        }

        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1912
fun main(args: Array<String>) {
    readLine()
    val array = readLine()
        ?.split(" ".toRegex())
        ?.map(Integer::parseInt)
        ?.toIntArray()
        ?: intArrayOf()
    val mid = array.partition()
    println(array.mapIndexed { index, value ->
        if (index == mid) {
            "[$value]"
        } else {
            value.toString()
        }
    }.joinToString(" "))
}

fun IntArray.partition(): Int {
    val x = this.last()
    var i = -1
    for (j in 0 until this.size - 1) {
        if (this[j] <= x) {
            i++
            swap(i, j)
        }
    }
    swap(i + 1, lastIndex)
    return i + 1
}

fun IntArray.swap(i: Int, j: Int) {
    val tmp = this[i]
    this[i] = this[j]
    this[j] = tmp
}


Measured memory_bytes: 52364
import java.util.Scanner;

public class Main {

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

    final String a = T.substring(0, T.length() - 1);

    if (a.equals(S)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-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;
}
const int mod = 998244353;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};

ll dp[3300][3300];
int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    rep(i,3300){
        rep(j,3300){
            dp[i][j]=0;
        }
    }
    dp[a][b]=1;
    for(ll len=a+b;len<c+d;len++){
        for(ll i=a;i<=c;i++){
            ll j=len-i;
            dp[i+1][j]+=j*dp[i][j];
            dp[i+1][j]%=mod;
            dp[i][j+1]+=i*dp[i][j];
            dp[i][j+1]%=mod;
            dp[i+1][j+1]=(dp[i+1][j+1]-dp[i][j]*i*j)%mod;
            if(dp[i+1][j+1]<0){
                dp[i+1][j+1]+=mod;
                dp[i+1][j+1]%=mod;
            }
        }
    }
    
    cout<<dp[c][d]<<endl;
    return 0;
}

Measured memory_bytes: 88688
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back

using namespace std;
using ll=long long;
// using ll=int;

const ll mod = (ll)(1e9+7);

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main(){

    /*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("myoutput.txt", "w", stdout);
    #endif
    */

    fast;
    ll t =1;
    // cin >> t;
    while(t--){
        ll n; cin >> n;
        ll sum = 0;
        for(ll i = 1; i <= n; i++){
            if(i%3==0 || i%5==0) continue;
            else sum += i;
        }

        cout << sum << endl;
    }
    // cerr << (double)clock()/CLOCKS_PER_SEC << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

string s;
int main() {
    cin >> s;
    int n = s.length();
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i - 1])
            ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int h, w;
	int n;
	cin >> h >> w >> n;
	vector< pair<int, int> > p;
	map< pair<int, int>, int > pp;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		p.push_back(make_pair(a, b));
		pp[make_pair(a, b)] = 1;
	}
	vector<int> ans(10, 0);
	map< pair<int, int>, int > mp;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			int a, b;
			a = p[i].first - j / 3;
			b = p[i].second - j % 3;
			if (mp.count(make_pair(a, b)) || a < 1 || b < 1 || a + 2 > h || b + 2 > w) continue;
			mp[make_pair(a, b)] = 1;
			int cnt = 0;
			for (int k = 0; k < 9; k++) {
				if (pp.count(make_pair(a + k / 3, b + k % 3))) cnt++;
			}
			ans[cnt]++;
		}
	}
	long long z = (long long)(w - 2) * (h - 2);
	for (int i = 1; i < 10; i++)
		z -= ans[i];
	cout << z << endl;
	for (int i = 1; i < 10; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 69748
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val S, T = in.next
  val A, B = in.nextInt
  val U = in.next
  println(s"${A - (if (S == U) 1 else 0)} ${B - (if (T == U) 1 else 0)} ")
}

Measured memory_bytes: 25556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=1e9;
void Main(){
    ll n;cin >> n;
    ll k;cin >> k;k--;
    vector<ll> x(n);
    For(i,0,n) {
        cin >> x[i];
    }
    For(i,0,n-k) ans = min(ans,abs(x[i] - x[i+k]) + min(abs(x[i]),abs(x[i+k])));
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    edge = [[] for _ in range(N)]
    for _ in [0]*(N-1):
        a, b, c = (int(i) for i in input().split())
        edge[a-1].append((c % 2, b-1))
        edge[b-1].append((c % 2, a-1))

    from collections import deque
    dist = [-1]*N
    color = [-1]*N

    def bfs(s, G):
        que = deque()
        dist[s] = 0
        color[s] = 0
        que.append(s)
        while que:
            u = que.popleft()
            for c, v in G[u]:
                if dist[v] != -1:
                    continue
                dist[v] = (dist[u] + c) % 2
                if dist[v] % 2 == 1:
                    color[v] = 1
                else:
                    color[v] = 0
                que.append(v)

    bfs(0, edge)
    print(*color, sep="\n")
    # print("\n", *dist, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 69152
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;
	string s; cin>>s;
	if(n<3200) {
		cout<<"red"<<endl;
	}
	else{
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
A = set()
for _ in range(M):
    A.add(int(input()))
p = 10 ** 9 + 7
DP = [0 for _ in range(N + 1)]
DP[0] = 1
if 1 in A:
    DP[1] = 0
else: DP[1] = 1
for i in range(2, N+1):
    if i in A:
        DP[i] = 0
    else:
        DP[i] = (DP[i-1] + DP[i-2])%p
print(DP[N])


Measured memory_bytes: 11884
#include<stdio.h>
#define N 100
int main(void){
  	int j,F = 1;
	char s[N],s_n[N];
  
  	scanf("%s",&s);
  	//printf("s = %s\n",s); //OK 
  	
 	scanf("%s",&s_n);
  
  	//check(&s);
  	for(j = 0; s[j] != '\0';j++){
      	//printf("s = %c, s_n = %c\n",s[j],s_n[j]);
     	if(s[j] != s_n[j]){
          	printf("No\n");
          	F = 0;
          	break;
        }     
    }
  	if(F)
      printf("Yes\n");
  	
  	return 0;
}

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

using namespace std;
typedef long long ll;

#define LOOP(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) LOOP(i, 0, n)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

bool is_prime(int n) {
  if(n == 1) return false;
  bool flag = true;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0)
      flag = false;
  }
  return flag;
}

int main(void) {
  vector<int> ans;

  while (true) {
    int a, d, n;
    cin >> a >> d >> n;
    if (a == 0 && d == 0 && n == 0)
      break;
    int pcount = 0, count = 0;
    while (pcount < n) {
      if (is_prime(a + count * d))
        pcount++;
      count++;
    }

    ans.push_back(a + (count - 1) * d);
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3040
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;
vvll con(15,vll(15,-1));//con[i][j]=人iが人jを正直/不親切と思っている

int main(){
  int n,m;
  cin>>n>>m;
  ll x[n],y[n],z[n],tmp=0;
  REP(i,n){
    cin>>x[i]>>y[i]>>z[i];
  }
  REP(i,1<<3){
    ll sum=0;vll all(n,0);
    bitset<3> bit(i);
    REP(j,n){
      if(bit.test(0)){all[j]+=x[j];}
      else{all[j]-=x[j];}
      if(bit.test(1)){all[j]+=y[j];}
      else{all[j]-=y[j];}
      if(bit.test(2)){all[j]+=z[j];}
      else{all[j]-=z[j];}
    }
    sort(all.begin(),all.end());reverse(all.begin(),all.end());
    REP(j,m){
      sum+=all[j];
    }
    tmp=max(sum,tmp);
  }
  cout<<tmp<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    char s[1000];
    int i,f;
    scanf("%s", s);
    f = 1;
    for(i = 0;s[i] != '\0';i ++){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                f = 0;
                break;
            }
        }
        else if(i % 2 != 0){
            if(s[i] == 'R'){
                f = 0;
                break;
            }
        }
    }
    if(f == 1){
        printf("Yes");
    }
    else if(f == 0){
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int N,i,j,ans = 0;
  int d[50];
  
  scanf("%d",&N);
  for(i = 0; i < N ; i++){
    scanf("%d", &d[i]);
  }
  
  for(i = 0; i < N; i++){
    for(j = i + 1; j < N; j++){
      ans += d[i] * d[j];
    }
  }
  printf("%d", ans);
  return 0;
  
}


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

int main(){
    //input N, A..Anを受け取る
    int N, A[210];

    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int counter = 0;

    while(true){
        //while check divisible by 2 or not
        bool odd_exists = false;
        for (int i = 0; i < N; ++i){
            if (A[i] % 2 != 0){
                odd_exists = true;
                break;
            }
        }

        if (odd_exists) break;

        for (int i = 0; i < N; ++i) A[i] /= 2;

        counter += 1;
    }

    cout << counter << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 510;
ll dp[N][N], n;
ll mat[N][N], sum[2][N][N];
ll calc(int tp,int l1,int r1,int l2,int r2) {
  return sum[tp][r1][r2] - sum[tp][l1-1][r2] - sum[tp][r1][l2-1] + sum[tp][l1-1][l2-1];
}
int main() {
  read(n);
  rep (i, 1, n) {
    rep (j, 1, n) if (i != j) {
      read(mat[i][j]);
    }
  }
  rep (i, 1, n) rep (j, 1, n)
    sum[i < j][i][j] = mat[i][j];
  rep (k, 0, 1) {
    rep (i, 1, n) rep (j, 1, n)
      sum[k][i][j] += sum[k][i][j-1];
    rep (i, 1, n) rep (j, 1, n)
      sum[k][i][j] += sum[k][i-1][j];
  }
  memset(dp, 0, sizeof dp);
  rep (i, 1, n) rep (j, 1, n) dp[0][0] += mat[i][j];
  // 1 >= qj + .. + q_{i-1} (i > j)
  rep (i, 1, n) {
    rep (a, 0, i-1) rep (b, 0, max(0, a-1)) {
      ckmx(dp[i][a], dp[a][b] - calc(1, a+1, i, a+1, i) - calc(0, i+1, n, b+1, a));
    }
  }
  ll ans = 0;
  rep (a, 0, n) rep (b, 0, max(0, a-1))
    ckmx(ans, dp[a][b] - calc(1, a+1, n, a+1, n));
  ans = dp[0][0] - ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8448
N,M=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N){1}
F = Array.new(N){false}
F[0] = true
0.upto(M-1){|d|
	x,y=gets.chomp.split(' ').map{|n| n.to_i-1}
	F[y] = F[x] || F[y]
	F[x] = false if(A[x] == 1)
	A[x] -= 1
	A[y] += 1
}
puts F.inject(0){|sum,f| sum + (f ? 1 : 0)}


Measured memory_bytes: 3324
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

vector<double> nums;

vector<vector<double>>memo;
double solve (int idx, int cnt) {
    if (idx == nums.size()) {
        return cnt > nums.size() / 2;
    }

    if (memo[idx][cnt] > -1) {
        return memo[idx][cnt];
    }
    return memo[idx][cnt] = solve(idx + 1, cnt + 1) * nums[idx] + solve(idx + 1, cnt) * (1 - nums[idx]);
}

int main() {
    #ifdef LOCAL_JUDGE
        freopen("../input.txt", "rt", stdin);
        freopen("../output.txt", "wt", stdout);
    #endif

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

    for(int n; cin >> n;) {
        nums.assign(n, 0);
        memo.assign(n + 1, vector<double>(n + 1, -1));
        for (auto& val : nums) {
            cin >> val;
        }

        cout << setprecision(10) << fixed << solve(0, 0) << "\n";
    }
return 0;
}

Measured memory_bytes: 70912
N, K = map(int,input().split())
p = list(map(int,input().split()))

exp = [(x+1)*0.5 for x in p]

sums = []
sums.append(0.0)
for i in range(1,N+1):
    sums.append(sums[i-1]+exp[i-1])

#print(sums)
ans = 0.0
for i in range(N-K+1):
    if ans < sums[i+K] - sums[i]: ans = sums[i+K] - sums[i];

print(ans)


Measured memory_bytes: 25060
n = int(input())
h = list(map(int, input().split()))

ans = 'Yes'
for i in range(n-1):
  if h[i+1] - h[i] >= 1:
    h[i+1] -= 1
  elif h[i+1] - h[i] == 0:
    continue
  else:
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  
  if ( r <= x && x <= W - r && r <= y && y <= H - r ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}



Measured memory_bytes: 3100
#include <cstdio>
#include <cstdlib>

int main() {
  int N;
  scanf("%d", &N);

  int T, A;
  scanf("%d %d", &T, &A);

  int ind = -1;
  int opt = 2e9;
  for (int i = 1; i <= N; ++i) {
    int H;
    scanf("%d", &H);

    if (abs((T*500-H*3)-500*A) < opt) {
      ind = i;
      opt = abs((T*500-H*3)-500*A);
    }
  }
  printf("%d\n", ind);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

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

	int n, m;
	cin >> n >> m;

	if (n == 1) {
		cout << m << "\n";
		return 0;
	}
	int kStart = m / n;
	for (int k = kStart; k > 0; k--) {
		if (m % k == 0) {
			if (m / k >= n) {
				cout << k << "\n";
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n, x[101], y[101];
	double ao = 0, at = 0, ath = 0, ai = 0;
	int i;

	scanf("%d", &n);

	for (i = 0; i < n; i++) 
	{
		scanf("%d", &x[i]);
	}
	for (i = 0; i < n; i++)
	{
		scanf("%d", &y[i]);
	}

	for (i = 0; i < n; i++)
	{
		if (x[i] < y[i])
		{
			ao += y[i] - x[i];
			ath += (y[i] - x[i]) * (y[i] - x[i]) * (y[i] - x[i]);
		
		}
		if (x[i] > y[i])
		{
			ao += x[i] - y[i];
			ath += (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);

		}
		at += (x[i] - y[i]) * (x[i] - y[i]);
		
		if(x[i] < y[i])
		{
			if (ai < y[i] - x[i]) ai = y[i] - x[i];
		}
		if(x[i] > y[i])
		{
			if (ai < x[i] - y[i]) ai = x[i] - y[i];
		}
	
	}

	printf("%f\n%f\n%f\n%f\n", ao, sqrt(at), pow(ath, 1.0 / 3.0), ai);
	return 0;
}

Measured memory_bytes: 672
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b, c;

	cin >> a >> b >> c;

	ll x = min(a - b, c);

	cout << c - x << endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

bool check(int n, vector<int> p){
    int tmp=0;
    REP(i,n){
        if(tmp > p[i]){
            return false;
        }
        tmp = p[i];
    }
    return true;

}

void Main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    if(check(n,p)){
        cout << "YES" << endl;
        return;
    }

    vector<int> p_ori = p;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            dump(i)
            dump(j)
            p = p_ori;
            int tmp = p[i];
            p[i] = p[j];
            p[j] = tmp;

            if(check(n,p)){
                cout << "YES" << endl;
                return;
            }
        }
    }
    
    cout << "NO" << endl;

    

    return;
}
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

    return 0;
}

Measured memory_bytes: 256
def solve(H, W, field):
    for hi, row in enumerate(field):
        for wi, cel in enumerate(row):
            if cel != "#":
                continue
            if any([field[hi + dh][dw + wi] == "#"
                    for dh, dw in [(-1, 0), (1, 0), (0, -1), (0, 1)]
                    if 0 <= hi + dh < H and 0 <= dw + wi < W]):
                pass
            else:
                return "No"
    return "Yes"


if __name__ == "__main__":
    H, W = tuple(map(int, input().split(" ")))
    field = [input() for _ in range(H)]
    print(solve(H, W, field))


Measured memory_bytes: 3064
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}
inline void upd(ll &a,ll b){if(b<a)a=b;}

const int maxn=100005;
int n,col[maxn],cnt[maxn],tot;
vector<int>edge[maxn];
ll dp[maxn][2][2][2],ans;
ll pre[maxn],suf[maxn];
char c[maxn];

void prep(int x,int p){
	if(!col[x])cnt[x]++;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		prep(y,x);
		cnt[x]+=cnt[y];
	}
}

void dfs(int x,int p){
	int sz=0;
	ll sum=0;
	vector<int>son;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		dfs(y,x);
		if(cnt[y]){
			sum+=dp[y][0][0][1]+2;
			son.pb(y);
			sz++;
		}
	}
	if(!sz){
		rep(i,2)rep(j,2)rep(k,2){
			dp[x][i][j][k]=(col[x]+i)%2;
		} 
		goto end;
	}
	pre[0]=sum-dp[son[0]][0][0][1]-2+dp[son[0]][1][1][1]+1;
	REP(i,sz-1)pre[i]=min(pre[i-1],sum-dp[son[i]][0][0][1]-2+dp[son[i]][1][1][1]+1);
	suf[sz-1]=sum-dp[son[sz-1]][0][0][1]-2+dp[son[sz-1]][1][1][1]+1;
	for(int i=sz-2;i>=0;i--)suf[i]=min(suf[i+1],sum-dp[son[i]][0][0][1]-2+dp[son[i]][1][1][1]+1);
	rep(i,2){
		dp[x][i][0][0]=Inf;
		rep(j,sz)upd(dp[x][i][0][0],sum-dp[son[j]][0][0][1]-2+dp[son[j]][0][0][0]+1);
		dp[x][i][0][0]+=(sz+col[x]+1+i)%2;
		dp[x][i][0][1]=sum+(sz+col[x]+i)%2;
		dp[x][i][1][0]=Inf;
		rep(j,sz){
			ll cur=min((!j?Inf:pre[j-1]),(j==sz-1?Inf:suf[j+1]))-dp[son[j]][0][0][1]-2;
			upd(dp[x][i][1][0],cur+dp[son[j]][0][0][0]+1+(sz+col[x]+1+i)%2);
			upd(dp[x][i][1][0],sum-dp[son[j]][0][0][1]-2+dp[son[j]][0][1][0]+2+(sz+col[x]+i)%2);
		}
		dp[x][i][1][1]=Inf;
		rep(j,sz)upd(dp[x][i][1][1],sum-dp[son[j]][0][0][1]-2+dp[son[j]][1][1][1]+1);
		dp[x][i][1][1]+=(sz+col[x]+i)%2;
		rep(j,2)upd(dp[x][i][j][0],dp[x][i][j][1]);
	}
	end:
	rep(i,2)rep(j,2)rep(k,2){
		upd(dp[x][i][j][k],dp[x][i^1][j][k]+1);
	}
	if(tot==cnt[x]){
		rep(i,2)rep(j,2)upd(ans,dp[x][1][i][j]);
	}
//	cout<<x<<" "<<dp[x][0][0][0]<<" "<<dp[x][0][0][1]<<" "<<dp[x][0][1][0]<<" "<<dp[x][0][1][1]<<endl;
//	cout<<x<<" "<<dp[x][1][0][0]<<" "<<dp[x][1][0][1]<<" "<<dp[x][1][1][0]<<" "<<dp[x][1][1][1]<<endl;
}

int main(){
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);
	scanf("%d",&n);
	rep(i,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	scanf("%s",c);
	rep(i,n)col[i]=c[i]=='W'?0:1;
	rep(i,n)if(!col[i])tot++;
	prep(0,-1);
	ans=Inf;
	dfs(0,-1);
	printf("%lld\n",ans);
	return 0;
}

/*
Input:
10
1 2
1 3
2 8
3 4
3 5
3 6
3 7
6 9
9 10
WBWWWBWWWW
-----------------
Output:
*/


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

int main() {
    int N;
    cin >> N;
    int num[1001] = {0};
    for(int i=2; i<=N; ++i) {
        int n = i;
        for(int d=2; d * d <= n; ++d) {
            while(n % d == 0) {
                n /= d;
                num[d] += 1;
            }
        }
        if(n != 1) num[n] += 1;
    }

    long long ans = 1;
    for(int n=2; n<=N; ++n) {
        ans *= num[n] + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int nxt = 1, cnt = 0;
  for (int i = 0; i < N; i++) {
    if (nxt==A.at(i))  nxt++;
    else cnt++;
  }
  if(cnt==N) cnt = -1;
  cout << cnt << endl;
}

Measured memory_bytes: 1024
/*
*author : alfarelzaki
*created : 27.04.2019
*/
#include <bits/stdc++.h>
using namespace std;

int main (){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, ct=0;
	long long sum=0;
	bool nol=0;
	cin >> n;
	vector<int>v;
	for (int i=0; i<n; i++){
		int x;
		cin >> x;
		if (x<=0) ct++;
		if (x!=0) v.push_back(abs(x));
		else nol=1;
		sum+=abs(x);
	}

	sort(v.begin(),v.end());
	if (ct%2==0 || nol==1) cout << sum << "\n";
	else cout << sum-2*v[0] << "\n";
}

Measured memory_bytes: 892
#include <stdio.h>

int main(void)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a <= b && b <= c){
printf("%d %d %d\n", a, b ,c);
} else if(a <= c && c <= b){
printf("%d %d %d\n", a, c, b);
} else if(b <= a && a <= c){
printf("%d %d %d\n", b, a, c);
} else if(b <= c && c <= a){
printf("%d %d %d\n", b, c, a);
} else if(c <= a && a <= b){
printf("%d %d %d\n", c, a, b);
} else if(c <= b && b <= a){
printf("%d %d %d\n", c, b, a);
}
return 0;

}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  bool flag = false,small_flag = false;
  ll ans(0),x(0),tmp(1);
  for(int i(0);i<40;i++){
    tmp *= 2; 
  }
  for(int i(40);i>=0;i--){
    if(!flag && ((K >> i) & 1)) flag = true; 
    if(flag){
      int cnt0(0),cnt1(0);
      for(int j(0);j<N;j++){
        if((A[j] >> i) & 1) cnt1++; 
        else cnt0++;
      }
      //cout << cnt0 << " " << cnt1 << " " << small_flag <<" " <<x <<  endl;
      if(cnt0 > cnt1){
        if(!((K >> i) & 1) && small_flag == false){
        }else{
          x += tmp;
        }
      }else if(((K >> i) & 1)){
        small_flag = 1;
      }
    }
    tmp /= 2;
  }
  //cout << x << endl;
  for(int i(0);i<N;i++){
    ans += A[i] ^ x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024