akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];
    int c=0;
    rep(i,1,n-1)
    {
        if((arr[i]>arr[i-1] && arr[i]<arr[i+1])||(arr[i]<arr[i-1]&&arr[i]>arr[i+1])) c++;
    }

cout<<c;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k; cin>>n>>k;
  vector<long long> h(n);
  for(auto& i:h) cin>>i;
  sort(h.begin(),h.end());
  long long res=0;
  for(int i=0; i<(n-k); ++i) res+=h[i];
  cout<<res;
  return 0;
}


Measured memory_bytes: 4800
#include<bits/stdc++.h>
 
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define si set <int>



using namespace std;

int main(){speed;
	double n;
	cin >> n;
	int cnt = 0;
	for(int i = 0; i <= n; ++i){
		if( i % 2 == 1) cnt++;
	}
	double ans = cnt / n;
	printf("%.6f", ans);
	}
	


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int mp[200005];

int main() {
	int n,k,x,ans=0;
	scanf("%d%d",&n,&k);
	for (register int i=0;i<n;++i) {
		scanf("%d",&x);
		++mp[x];
	}
	sort(mp+1,mp+200001);
	for (register int i=200001-k;i<=200000;++i) {
		ans+=mp[i];
	}
	printf("%d\n",n-ans);
	return 0;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 1;
	int i = 1;
	while (i < s.size()){
		if (s[i] != s[i - 1]){
			ans ++;
			i ++;
		}
		else{
			if(i == s.size() - 1)
				i++;
			else if (i + 2 < s.size()){
				ans += 2;
				i += 3;
			}
			else{
				ans ++;
				i += 2;
			}
			
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll n, a, b;
  cin >> n >> a >> b;
  
  cout << min(a, b) << " " << max(a+b-n, 0LL) << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(x) (x&-x)
#define rep(i,n) for(int i = 0; i < n; i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
const int maxn = 1e6+20;
const ll Mod = 1e9+7;
const int INF = 0x3f3f3f3f;
int main()
{
	int a[20];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e5+5;
const double EPS = 1e-6;
using namespace std;
int a[maxn];
int b[maxn];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n) scanf("%d%d",&a[i],&b[i]);
	ll mx = 0;
	rep(i,0,n) if((k|a[i])==k) mx+=b[i];
	rep(i,0,31){
		if(k>>i&1){
			int t=0;
			rep(j,0,i) t|=(1<<j);
			rep(j,i+1,31){
				if(k>>j&1) t|=(1<<j);
			}
			ll sum=0;
			//de(mx);
			rep(j,0,n) if((t|a[j])==t) sum+=b[j];
			//de(sum);
			mx=max(mx,sum);
		}
	}
	printf("%lld\n",mx);
	return 0;
}



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


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');

                int a = int.Parse(s[0]);
                string op = s[1];
                int b = int.Parse(s[2]);

                if (op == "+")
                {
                    Console.WriteLine(a + b);
                }
                else if (op == "-")
                {
                    Console.WriteLine(a - b);
                }
                else if (op == "*")
                {
                    Console.WriteLine(a * b);
                }
                else if (op == "/")
                {
                    Console.WriteLine(a / b);
                }
                else if (op == "?")
                {
                    break;
                }
            }

        }
    }
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main(){
    int n,m;
    while(true){
        cin>>n>>m;
        if(n==0&& m==0)break;
        vector<int>sn(n+1,0),sm(m+1,0);
        int sumn=0,summ=0;
        repd(i,1,n+1){
            cin>>sn[i];
            sumn+=sn[i];
        }
        repd(i,1,m+1){
            cin>>sm[i];
            summ+=sm[i];
        }
        sort(sn.begin(),sn.end());
        sort(sm.begin(),sm.end());
        if(sumn==summ){
            int car=1;
            bool is=false;
            repd(i,1,n+1){
                repd(k,1,m+1){
                    if(sn[i]==sm[k]){
                        cout<<sn[i]<<" "<< sm[k]<<endl;
                        is=true;
                        break;
                    }
                }
                if(is)break;
            }
            if(!is)  cout<<-1<<endl;
        }else{
            int dif=(summ-sumn);
            bool is=false;
            if(dif%2==0){
                dif/=2;
                repd(i,1,n+1){
                    repd(k,1,m+1){
                        if(sm[k]-sn[i]==dif){
                            cout<<sn[i]<<" "<< sm[k]<<endl;
                            is=true;
                            break;
                        }
                    }
                    if(is)break;
                }
            }
            if(!is)cout<<-1<<endl;
        }
    }
    return (0);
}


Measured memory_bytes: 3028
import java.util.Scanner;
public class Main {

  public static double mean(double[] ary) {
    double sum = 0;
    for (double num : ary) {
      sum += num;
    }
    return sum / ary.length;
  }

  public static double sse(double[] ary, double mean) {
    double sse = 0;
    for (double num : ary) {
      sse += Math.pow((num - mean), 2);
    }
    return sse;
  }

  public static double sdev(double[] ary) {
    double m = mean(ary);
    double sse = sse(ary, m);
    return Math.pow((sse / ary.length), .5);
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    while (n != 0) {
      double[] ary = new double[n];
      for (int i = 0; i < n; i++) {
        ary[i] = s.nextDouble();
      }
      System.out.println(sdev(ary));
      n = s.nextInt();
    }
    s.close();
  }
}



Measured memory_bytes: 38820
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;

int w, h;
short dp[1<<11][1<<11];
int bit[200];
bool t[200][200];

int solve(int q, int a){
  if(dp[q][a] != -1) return dp[q][a];

  int cnt = 0;

  for(int i = 0; i < h; i++){
    if((bit[i] & q) == a){
      cnt++;
      if(cnt > 1) break;
    }
  }

  if(cnt == 1){
    return 0;
  }

  int res = INT_MAX;

  for(int i = 0; i < w; i++){
    if(!(q & (1 << i))){
      int tmp = max(solve(q | (1 << i), a),
                    solve(q | (1 << i), a | (1 << i)));
      res = min(res, tmp);
    }
  }

  return dp[q][a] = res + 1;
}

int main(){
  while(cin >> w >> h, w || h){
    for(int i = 0; i < h; i++){
      bit[i] = 0;

      for(int j = 0; j < w; j++){
        char ch;
        cin >> ch;
        t[i][j] = ch - '0';
        bit[i] = (bit[i] << 1) + t[i][j];
      }
    }

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
  }
}

Measured memory_bytes: 9084
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#define div 1000000000+7
using namespace std;
typedef long long ll;

int main(){
    int h, w;
    char c[101][101];
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) {
            cin >> c[i][j];
            cout << c[i][j];
        }
        cout << endl;
        for(int k = 0; k < w; k++){
            cout << c[i][k];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    char a;
    cin >> a;
    a++;
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
/**
 * A - Good Integer
 */

#include <iostream>

using namespace std;

int main() {

    string N;
    cin >> N;

    if ((N[1] == N[2]) && (N[0] == N[1] || N[2] == N[3])) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void judge_righttriangle(int a, int b, int c);

int main(void)
{
  int n, a, b, c;

  scanf("%d",&n);
  while(n-- > 0)
  {
    scanf("%d %d %d", &a, &b, &c);
	judge_righttriangle(a,b,c);
  }

  return 0; 		
}

void judge_righttriangle(int a, int b, int c)
{
  int tmp;

  //sort as a<b<c
  if(b > c){tmp=b; b=c; c=tmp;}
  if(a > b){tmp=a; a=b; b=tmp;}
  if(b > c){tmp=b; b=c; c=tmp;}

  if(c*c==a*a+b*b) printf("YES\n");
  else             printf("NO\n");
}

Measured memory_bytes: 580
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    int a[n];for(int i=0;i<n;i++)scanf("%d",&a[i]);
    int ans=0;
    while(1){
        for(int i=0;i<n;i++){
            if(a[i]%2)goto END;
            a[i]/=2;
        }
        ans++;
    }
    END:

    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 2000005
#define MOD  998244353 //1000000007
#define INF 1000000000000000000

using namespace std;

#define int int64_t
#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define all(v) v.begin(), v.end()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout << setprecision(10) << fixed;
}
ll ceil(ll a, ll b){ return (a+ b-1)/b; }
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}



void solve(){
    double n;cin >> n; cout << 2*3.14*n;
}

main(){
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3792
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;

#define N 100

int main(void) {
	int v[N][N];
	int n = 0; //入力された行数
	
	string str;
	while(getline(cin, str)) {
		stringstream ss(str);
		string s;
		int i = 0; //行内の要素数
		while(getline(ss, s, ',')) {
			if(s.length() == 1) v[n][i] = s[0] - '0';
			else v[n][i] = (s[0] - '0') * 10 + (s[1] - '0');
			++i;
		}
		++n;
	}
	
	for(int i = 1; i <= n / 2; ++i) {
		for(int j = 0; j <= i; ++j) {
			if(j == 0) {
				v[i][j] += v[i - 1][j];
			} else if(j == i) {
				v[i][j] += v[i - 1][j - 1];
			} else {
				v[i][j] += max(v[i - 1][j], v[i - 1][j - 1]);
			}
		}
	}
	
	for(int i = n / 2 + 1; i < n; ++i) {
		for(int j = 0; j < n - i; ++j) {
			v[i][j] += max(v[i - 1][j], v[i - 1][j + 1]);
		}
	}
	
	cout << v[n - 1][0] << endl;
	
	return 0;
}


Measured memory_bytes: 3272
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N,M,K;
    int A[30] = {};
    int ind = 0;
    int cnt = 0;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> K;
        for(int j=0; j<K; j++){
            cin >> ind;
            A[ind-1]++;
        }
    }
    for(int i=0; i<M; i++){
        if(A[i] == N){
            cnt++;
        } 
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <random>
int D;
int c[26];
int l[26][367];
int s[366][26];
int t[366];
long long m = 10000000;
int  p, q, d, k, pp, dd, f;
int ans, bans;
unsigned long long a;
int main() {
	scanf("%d", &D);
	for (int i = 0; i < 26; i++) {
		scanf("%d", c + i);
	}
	for (int i = 1; i <= D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", s[i] + j);
		}
	}
	std::mt19937_64 rd(468);
	for (int i = 1; i <= D; i++) {
		a = rd();
		t[i] = a % 26;
	}
	for (int i = 1; i <= D; i++) {
		ans += s[i][t[i]];
		for (int j = 0; j < 26; j++) {
			l[j][i] = l[j][i - 1] + 1;
		}
		l[t[i]][i] = 0;
		for (int j = 0; j < 26; j++) {
			ans -= c[j] * l[j][i];
		}
	}
	for (long long i = 0; i < m; i++) {
		a = rd();
		if (f) {
			d = dd;
			q = pp;
		}
		else {
			d = a % D + 1;
			q = a % 26;
		}
		p = t[d];
		if (p != q) {
			bans = ans;
			t[d] = q;
			ans -= s[d][p];
			ans += s[d][q];
			k = d;
			while (l[q][k] && k <= D) {
				ans -= c[q] * (k - d - l[q][k]);
				l[q][k] = k - d;
				k++;
			}
			k = d;
			do {
				ans -= c[p] * (l[p][k - 1] + 1 - l[p][k]);
				l[p][k] = l[p][k - 1] + 1;
				k++;
			} while (l[p][k]);
			a = rd();
			f = 0;
			if (ans < bans && (a % (m * m)) < 2 * m * i - i * i) {
				f = 1;
				pp = p;
				dd = d;
			}
		}
	}
	for (int i = 1; i <= D; i++) {
		printf("%d\n", t[i] + 1);
	}
}

Measured memory_bytes: 1812
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

ll binpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= m;
        }
        a *= (a % m);
        a %= m;
        n >>= 1;
    }
    return res % m;
}

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a,b);
}

void solve() {
    int x;
    cin >> x;
    if (x < 1200) cout << "ABC";
    else cout << "ARC";
}

int main() {
    speed;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

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

using namespace std;

typedef long long int ll;

int main(){
    int h, n;
    cin>>h>>n;
    int sum = 0;
    for(int i=0;i< n;i++){
        int temp;
        cin>>temp;
        sum += temp;
    }
    if(sum >= h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;
using P = pair<int,int>;

int n,m,k,h,w;
string s,t;
int a[100005],b[100005],c[100005];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a,a+n),sort(c,c+n);

  ll ans=0;
  rep(i,n){
    ll d=lower_bound(a,a+n,b[i])-a;
    ll e=n-(upper_bound(c,c+n,b[i])-c);
    ans+=d*e;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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 long long INF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    vector<int> a(3,0);
    for(auto &i:s){
        switch (i)
        {
        case 'a':
            a[0]++;
            break;
        case 'b':
            a[1]++;
            break;
        case 'c':
            a[2]++;
            break;
        default:
            break;
        }
    }
    sort(a.begin(),a.end());
    /*for(auto &i:a){
        cout << i << " ";
        cout << endl;
    }*/
    cout << (a[2]-a[0]<=1?"YES":"NO") << endl;
    
}

//bacbacbacba

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
V<int>G[200020];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    V<int>a(n);
    for(int i=1;i<n;i++)cin>>a[i];

    for(int i=1;i<n;i++){
        G[a[i]].pb(i+1);
    }

    for(int i=0;i<n;i++){
        cout<<G[i+1].size()<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

















































Measured memory_bytes: 14660
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = IL()
if H == 1 or W == 1:
  print(1)
else:

  numb = W//2
  numa = W - numb

  numd = H//2
  numc = H - numd
  ans = numa * numc + numb * numd

  print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,M;
    cin >> A>>B>>M;
    vector<int>veca(A);
    vector<int>vecb(B);
    for(int i=0;i<A;i++){
        cin>>veca.at(i);
    }
    for(int i=0;i<B;i++){
        cin>>vecb.at(i);
    }
    int countera=999999;
    int counterb=999999;
    for(int i=0;i<A;i++){
   countera=min(countera,veca.at(i));
    }
    for(int i=0;i<B;i++){
   counterb=min(counterb,vecb.at(i));
    }
    int counter=countera+counterb;
    vector<vector<int>>vec(M,vector<int>(3));
   for(int i=0;i<M;i++){
    for(int j=0;j<3;j++){
        cin >> vec.at(i).at(j);
    }
   }
      for(int i=0;i<M;i++){
     counter= min(veca.at(vec.at(i).at(0)-1)+vecb.at(vec.at(i).at(1)-1)-vec.at(i).at(2),counter);
    }
    cout <<counter <<endl;
   }
   

Measured memory_bytes: 9572
#include<bits/stdc++.h>
typedef long long int l1;
using namespace std;
#define pb push_back
#define input l1 t;cin>>t;while(t--)
int main(){
  l1 x;
  cin>>x;
  l1 r=x%500;
  l1 c=0;
  x=x/500;
  c+=(x)*1000;
  x=r;
  x=x/5;
  c+=(x)*5;
  cout<<c;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

int v[200000],a[200000]={0},b[200000]={0};
int main() {
    int N,A=0,B=0;
    cin>> N;
    if(N==1){
        printf("Hello World");
    }else if(N==2){
        cin>>A>>B;
        printf("%d", A+B);
    }

    return 0;


}


Measured memory_bytes: 256
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		public static void main(String args[])
		{
			Scanner scan=new Scanner(System.in);
			
			int[][] a = new int[3][3];
			int count=0;
			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					a[i][j]=scan.nextInt();
				}
			}
			int n = scan.nextInt();
			int[] b = new int[n];
			for(int i=0;i<n;i++)
			{
				b[i]=scan.nextInt();
			}
			
			for(int i=0;i<n;i++)
			{
				for(int j=0;j<3;j++)
				{
					for(int k=0;k<3;k++)
					{
						if(a[j][k]==b[i])
							a[j][k]=0;
					}
				}
			}
			int[] d = {0, 0};
        for(int i = 0; i < 3; i++ )
			{
				int v = 0;
				int h = 0;
				for(int j = 0; j < 3; j++) 
				{
					v += a[j][i];
					h += a[i][j];
				}
				if(v == 0 || h == 0)
				{
					System.out.println("Yes");
					return;
				}
            d[0] += a[i][i];
            d[1] += a[i][2 - i];
        }
        if(d[0] == 0 || d[1] == 0) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
			
		}
	}
	

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.rbegin(), res.rend());
    return res;
}

int main() {
  int a,b,c; cin >> a >> b >> c;
  int N = __gcd(a,b);
  const auto &res = enum_divisors(N);
  cout << res[c-1] << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long n, tmp, m;
    long long ans=0;
    long long p=0;
    
    cin >> n;
    
    vector<long long> a(n);
    vector<long long> b(n);
    vector<long long> c(n+1); // kosuu
    
    for(int i=0; i<=n-1; i++){
        
        cin >> a.at(i);
        b.at(i) = a.at(i);
        
    }
    
    sort(b.begin(), b.end());
    
    tmp = 1;
    
    for(int i=1; i<=n-1; i++){
        
        if(b.at(i-1)==b.at(i)){
            
            tmp += 1;
            
        } else {
            
            m = b.at(i-1);
            c.at(m) = tmp;
            ans += tmp * (tmp-1) / 2;
            tmp = 1;
            
        }
        
    }
    
    m = b.at(n-1);
    c.at(m) = tmp;
    ans += tmp * (tmp-1) / 2;
    tmp = 0;
    
    // cout << "debug ans : " << ans << endl;
    
    for(int k=0; k<=n-1; k++){
        
        m = a.at(k);
        tmp = c.at(m);
        p = ans - tmp*(tmp-1)/2 + (tmp-1)*(tmp-2)/2;
        
        cout << p << endl;
        
    }
    
    return 0;
    
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
int main(){
    ll a;
    cin>>a;
    ll arr[a];
    for (int i=0; i<a; i++) cin>>arr[i];
    ll cur=1000, num=0;
    for (int i=0; i<a-1; i++){
        if (arr[i]<arr[i+1]){
            if (num!=0) cur+=num*arr[i];
            num=cur/arr[i], cur-=(cur/arr[i])*arr[i];
        }
        else if (arr[i]>arr[i+1]) cur+=num*arr[i], num=0;
    }
    if (num!=0){
        for (int i=a-1; i>=0; i--){
            if (arr[i]>arr[i-1]){cur+=arr[i]*num;break;}
        }
    }
    cout<<cur<<endl;
}


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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int mod=0;
    rep(i,s.length()){
        mod = (mod+(s[i]-'0')) % 9;
    }
    if(mod==0) print("Yes");
    else print("No");
    return 0;
}

Measured memory_bytes: 3704
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

string s;
int d, k;
vector<int> vec;
int dp[100][100][2];

int go(int pos, int cnt, bool flag) {
    if (cnt > k)
        return 0;

    if (pos == vec.size())
        return cnt == k;

    if (dp[pos][cnt][flag] != -1)
        return dp[pos][cnt][flag];

    int limit = vec[pos];
    if (flag)
        limit = 9;

    int res = 0;
    for (int i = 0; i <= limit; i++) {
        int newCnt = cnt + (i != d);
        bool newFlag = flag;
        if (flag == false && i < limit)
            newFlag = true;

        res += go(pos + 1, newCnt, newFlag);
    }

    return dp[pos][cnt][flag] = res;
}

int solve(string s) {
    vec.clear();
    for (auto c : s)
        vec.push_back(c - '0');
    
    memset(dp, -1, sizeof(dp));
    int res = go(0, 0, false);
    return res;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        cin >> s >> k;
        cout << solve(s) << '\n';        
    }
    
    return 0;
}



Measured memory_bytes: 3736
program sequence_sum;
var
  n, x, m, num: int64;
  i, k, offset, period, rem: integer;
  a: array[0..100000] of int64;
  b: array[0..100000] of integer;
begin
  read(n, x, m);
  if n = 1 then
  begin
    writeln(x);
    halt(0);
  end;
  a[1] := x;
  b[integer(x)] := 1;
  for i := 2 to integer(m) + 1 do
  begin
    x := (x * x) mod m;
    a[i] := a[i - 1] + x;
    if i = n then
    begin
      writeln(a[i]);
      halt(0);
    end;
    k := integer(x);
    if b[k] > 0 then
    begin
      offset := b[k] - 1;
      period := i - offset - 1;
      break;
    end;
    b[k] := i;
  end;
  num := (n - offset) div int64(period);
  rem := integer(n - offset - num * period);
  writeln((a[offset + period] - a[offset]) * num + a[offset + rem]);
end.

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

using namespace std;

int solve(std::vector<int>& hs) {
  int const n = hs.size();
  int l;
  for (l = 0; l < n; ++l) {
    if (hs[l]) {
      break;
    }
  }
  int ret = 0;
  while (true) {
    int minimum = hs[l];
    int r;
    for (r = l;; ++r) {
      minimum = std::min(hs[r], minimum);
      if (r + 1 >= n || hs[r + 1] == 0) {
        break;
      }
    }
    for (int i = l; i <= r; ++i) {
      hs[i] -= minimum;
    }
    ret += minimum;
    for (; l < n; ++l) {
      if (hs[l]) {
        break;
      }
    }
    if (l >= n) {
      break;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> hs(n);
  bool allZeros = true;
  for (auto& h : hs) {
    std::cin >> h;
    if (h) {
      allZeros = false;
    }
  }
  if (allZeros) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << solve(hs) << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;

	int A[100000];

	int min_pos = 0;

	for(int i = 0; i < N; ++i){
		cin >> A[i];
		if(A[i] == 1){
			min_pos = i;
		}
	}

	if(N == K){
		cout << 1 << endl;
	} else {
		int g = 2;
		while(true){
			if(N > K + (K - 1) * (g - 1)){
				++g;
			} else {
				cout << g << endl;
				break;
			}
		}
	}
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

constexpr auto M = 1000000007L;

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector fact(m + 1, 1L), ifact(m + 1, 1L), inv(m + 1, 1L);
    for (auto i : irange(2L, m + 1)) {
        inv[i] = (M - inv[M % i] * (M / i) % M) % M;
        fact[i] = fact[i - 1] * i % M;
        ifact[i] = ifact[i - 1] * inv[i] % M;
    }

    int64_t ans = 0;
    int64_t s = 1;
    for (auto i : irange(0L, n + 1)) {
        ans += M + s * fact[n] * ifact[i] % M * ifact[n - i] % M * fact[m] % M *
                           ifact[m - n] % M * fact[m - i] % M * ifact[m - n] %
                           M;
        ans %= M;
        s *= -1;
    }

    cout << ans << endl;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

int main(){
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  
  rep(i, 0, n){
    double a;
    cin >> a;
    a += 1.0;
    a /= 2.0;
    p[i] = a;
  }
  
  double sum = 0.0;
  
  rep(i, 0, k){
    sum += p[i];
  }
  
  double mx = sum;
  
  rep(i, 0, n-k){
    sum -= p[i];
    sum += p[i+k];
    if(mx < sum)
      mx = sum;
  }
  
  cout << fixed << setprecision(10);
  cout << mx << endl;
  
  return 0;
  
}

Measured memory_bytes: 4812
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

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

        long A = sc.nextLong() - 1;
        long B = sc.nextLong();
        long C = sc.nextLong();
        long D = sc.nextLong();

//        int cnt = 0;
//        for (long i = A; i <= B; i++) {
//            if (i % C == 0) continue;
//            if (i % D == 0) continue;
//
//            cnt++;
//        }

        long lcm = lcm(C, D);

        long Ccnt = (B / C) - (A / C);
        long Dcnt = (B / D) - (A / D);

        long LCMcnt = (B / lcm) - (A / lcm);

        System.out.println(B - A - (Ccnt + Dcnt - LCMcnt));
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
# define pb(a) push_back(a)
#define ll long long int
const ll LLINF = 1e18 + 10;
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
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; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const * argv[]){
    int n,tmp;
    cin>>n;
    tmp = 1;
    rep(i, 8)
    {
        if (tmp > n)
            break;
        tmp *= 2;
    }
    cout<<tmp/2<<endl;
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', solve);

function solve() {
  let a = lines[0].split(' ');
  const L = parseInt(a[0]);
  const R = parseInt(a[1]);
  const d = parseInt(a[2]);
  let count = 0;

  for(let i = L; i <= R; i++) {
    if(i % d === 0) {
      count++;
    }
  }

  console.log(count);
}

Measured memory_bytes: 29944
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;

signed main(){
    //A
    /*
    string s;cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    */
   //B
   int n,k;cin>>n>>k;
   vector<int> d(k);
   set<int> a;
   rep(i,0,k){
       cin>>d[i];
       rep(j,0,d[i]){
           int p;cin>>p;
           a.insert(p);
       }
   }
   cout<<n-a.size()<<endl;

}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>

int main(void){
	char a[15], b[15], c[15];
	int lena, lenb;
	scanf("%s%s%s",a, b,c);
	
	lena = strlen(a);
	lenb = strlen(b);
	
	if(a[lena-1] == b[0] && b[lenb-1] == c[0]){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}
	

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  string po = S.substr(0, 1);
  ll N = S.size();
  ll now = 1;
  ll ans = 1;
  FOR(i, 1, N) {
    // cout << S.substr(now, i - now + 1) << endl;
    if (po != S.substr(now, i - now + 1)) {
      po = S.substr(now, i - now + 1);
      ans++;
      now = i + 1;
    }
    // cout << po << endl;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n, d, x;
	cin >> n >> d >> x;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(begin(a), end(a));

	int choco = 0;
	for (int i = 0; i < n; i++) {
		int v = 1;
		while (v <= d) {
			v += a[i];
			choco++;
		}
	}

	choco += x;
	cout << choco << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC, task B, 2020/04/26
//ms, ac
/*
*/

int main(void){
  int t_at, t_hp, a_at, a_hp;

  cin >>t_hp >>t_at >>a_hp >>a_at;
  bool t_wins = (a_hp-1)/t_at <= (t_hp-1)/a_at;

  if(t_wins) cout <<"Yes";
  else       cout <<"No";

  return 0;
}
/*
0
|
9

10
|
18
*/


Measured memory_bytes: 3624
# Wrote in Feb 29, 2020 13:43 by reetok
require 'time'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=:to_i)
  t = []
  n.times do
    t.push(eval("gets.chomp.#{datatype.to_s}"))
  end
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
#---------------
w,h,x,y,r = inp

ynju(( !(x-r<0)&&!(x+r>w)&&!(y-r<0)&&!(y+r>h) ))


Measured memory_bytes: 7028
from collections import deque
import time


def f1(x,y,xa,ya):
    if reach[xa][ya] == -1 or reach[xa][ya] > reach[x][y]:
         if c[xa][ya] == ".":
            reach[xa][ya] = reach[x][y]
            r.append([xa,ya])
            q.append([xa,ya])

            
            
def f2(x,y,xa,ya):
    if 0 <= xa <= h and 0 <= ya <= w:
    
        if reach[xa][ya] == -1 or reach[xa][ya] > reach[x][y] + 1:
            if c[xa][ya] == ".":
                reach[xa][ya] = reach[x][y] + 1
                q.append([xa,ya])

h,w = map(int,input().split())
cx, cy = map(int,input().split())
dx, dy = map(int,input().split())

t0 = time.time()

c = ["#"]*(h+2)
for i in range(1,h+1):
    c[i] = ["#"] + list(input()) + ["#"]
c[0]  = [0]*(w+2)
c[-1] = [0]*(w+2)

reach = [[-1 for j in range(w+2)] for i in range(h+2)]
q = deque([])

reach[cx][cy] = 0
q.append([cx,cy])

ans = 0

while q:
    
    if time.time() - t0 >= 1.5:
        break
    
    
    x,y = q.popleft()
    
    r = deque()
    r.append([x,y])
    while r:
        xx,yy = r.popleft()
        
        f1(xx,yy,xx-1,yy)
        f1(xx,yy,xx+1,yy)
        f1(xx,yy,xx,yy-1)
        f1(xx,yy,xx,yy+1)
    
    for i in range(-2,3):
        for j in range(-2,3):
            f2(x,y,x+i,y+j)


print(reach[dx][dy])


Measured memory_bytes: 167916
#include <stdio.h>
#define NUM 10

int main(void)
{
  int n[NUM];
  int t=0;
  int i;
  for(i=0;i<NUM;i++){
    scanf("%d",&n[i]);
    t += n[i];
      }
  printf("%d\n",t);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  string s, p;
  cin >> s;
  cin >> p;
  string ring = s + s;
  if (ring.find(p) != string::npos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;
template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

main(){
    char c=in<char>();
    out((char)(c+1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXN = 21;
const int MOD = 1000000000 + 7;
int N;
int memo[MAXN][1<<MAXN];
int can[MAXN];
vector<int> bit_on[1<<MAXN];

int dp(int u, int bm) {
    if(u == N) return 1;
    int& ans = memo[u][bm];
    if(ans == -1) {
        ans = 0;
        int cpbm = bm & can[u];
        for(const int& x : bit_on[cpbm]) {
            ans = (ans + dp(1 + u, bm & ~(1 << x))) % MOD;
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N;
    foi(i,0,N) {
        int& bm = can[i] = 0;
        foi(j,0,N) {
            int x; cin >> x;
            if(x == 1) bm |= (1 << j);
        }
    }
    foi(i,1,1<<MAXN) {
        vector<int>& pos = bit_on[i];
        for(int x = i, b = 0; x; ++b, x >>= 1) {
            if(x & 1) {
                pos.emplace_back(b);
            }
        }
    }
    memset(memo, -1, sizeof memo);
    cout << dp(0, (1 << N) - 1) << '\n';
    return 0;
}


Measured memory_bytes: 373120
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long long64;

long64 inline distance(long64 s, long64 t, long64 p)
{
	long64 d = abs(s - t);
	long64 d1 = abs(p - s);
	long64 d2 = abs(p - t);

	if (d1 < d2)
		return d1 + d;
	else
		return d2 + d;
}

int main()
{
	size_t s_num, t_num, p_num;
	std::cin >> s_num >> t_num >> p_num;

	std::vector<long64> s(s_num);
	std::vector<long64> t(t_num);
	std::vector<long64> p(p_num);

	for (size_t i = 0; i < s_num; i++)
	{
		std::cin >> s[i];
	}

	for (size_t i = 0; i < t_num; i++)
	{
		std::cin >> t[i];
	}

	for (size_t i = 0; i < p_num; i++)
	{
		std::cin >> p[i];
	}

	std::sort(s.begin(), s.end());
	std::sort(t.begin(), t.end());

	for (size_t i = 0; i < p.size(); i++)
	{
		typedef std::vector<long64>::iterator it;
		it it_s_l;
		it it_s_r;
		it it_t_l;
		it it_t_r;

		auto find = [](it& l, it& r, long64 p, std::vector<long64>& array)
		{
			r = l = std::lower_bound(array.begin(), array.end(), p);
			if (r == array.end())
			{
				r--;
				l = r;
			}
			else {
				if (l != array.begin()) {
					l--;
				}
				else {
					r = l = array.begin();
				}
			}
		};

		find(it_s_l, it_s_r, p[i], s);
		find(it_t_l, it_t_r, p[i], t);

		long64 mins[4] = {};
		mins[0] = distance(*it_s_l, *it_t_l, p[i]);
		mins[1] = distance(*it_s_l, *it_t_r, p[i]);
		mins[2] = distance(*it_s_r, *it_t_l, p[i]);
		mins[3] = distance(*it_s_r, *it_t_r, p[i]);

		long64 min = mins[0];
		for (size_t i = 0; i < 4; i++) {
			if (min > mins[i]) {
				min = mins[i];
			}
		}

		std::cout << min << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

ll A, B, C, D;

unsigned euclidean_gcd(unsigned a, unsigned b) {
	if (a < b) return euclidean_gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {

	scanf("%lld%lld%lld%lld", &A, &B, &C, &D);

	ll G = euclidean_gcd(C, D);
	G = (ll)C * D / G;
	A--;

	ll t = B / D - A / D + B / C - A / C - B / G + A / G;
	printf("%lld\n", B - A - t);

	return 0;
}


Measured memory_bytes: 256
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

ans = 0

0.upto(A) do |a|
  0.upto(B) do |b|
    0.upto(C) do |c|
      next if 500 * a + 100 * b + 50 * c != X

      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)

using ll = long long;
using ull = unsigned long long;
using llv = vector<long long>;

int main(void){
    ll s,w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
}

Measured memory_bytes: 3104