akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
#define ll long long
#define RG register
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)

inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!('0'<=ch && ch<='9') && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while('0'<=ch && ch<='9')s=s*10+ch-'0',ch=getchar();
	return s*f;
}

const int maxn=1e5+20;

int a[maxn],b[maxn],f[maxn],g[maxn];

int main()
{
	int n=read();
	REP(i,1,n)a[i]=read(),f[i]=f[i-1]+a[i];
	REP(i,1,n)b[i]=read();DREP(i,n,1)g[i]=g[i+1]+b[i];
	int mx=0;
	REP(i,1,n)
	{
		mx=max(mx,f[i]+g[i]);
	}
	printf("%d\n",mx);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
      int a,b;
    
  
  for(int i=8;i>0;i--){
    //下からi番目の位を抽出
    int c = 1;
    for(int j=i;j>0;j--){
      c *= 10;
    }
    
    a = N /(c/10);
    b = a % 10;
    
    sum += b;
  }
  
  if(N % sum == 0){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n,l = map(int,input().split())

N = [0 for i in range(n)]
NN = [0 for i in range(n)]

for j in range(n):
    N[j] = l + j
    NN[j] = abs(l+j)


if 0 in N:
    print(sum(N))
else:
    if min(N) == min(NN):
        N.remove(min(N))
    else:
        N.remove(max(N))


    print(sum(N))

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

int main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'o') {
			count++;
		}
	}
	cout << 700 + count * 100 << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    _lazy[] = NIL;
    _mini[] = int.max;

    auto nq = readints();
    int n = nq[0], q = nq[1];
    for (int i = 0; i < q; i++) {
        auto xs = readints();

        if (xs[0] == 0) {
            int s = xs[1];
            int t = xs[2];
            int x = xs[3];
            fill(s, t + 1, x);
        }
        else {
            int s = xs[1];
            int t = xs[2];
            int v = minimum(s, t + 1);
            writeln(v);
        }
    }
}

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

const int N = 1 << 18; // ???????????°
const int NIL = int.max;

int[N * 2] _mini; // ?????????k????????????????????????????°????
int[N * 2] _lazy; // lazy[k]????????????k???????????¨??????lazy[k]??§???????????¶?????¨?????????????????¨??????lazy[k]=NIL?????¨???????????????????????¨?´??????????

void setLazy(int k, int v) {
    _lazy[k] = v;

    // ??????????????????????????¨?????? v ??§???????????¶????????????????????????????????¶????????????k????????§??????v??§??????
    _mini[k] = v;
}

void push(int k) {
    // ?????¶?????????????????????????????°???????????????
    if (_lazy[k] == NIL) {
        return;
    }
    setLazy(k * 2 + 0, _lazy[k]);
    setLazy(k * 2 + 1, _lazy[k]);

    // ????????????????????¬??????????????§????????????????????????
    _lazy[k] = NIL;
}

void fix(int k) {
    _mini[k] = min(_mini[k * 2], _mini[k * 2 + 1]);
}

// ??????[queryL,queryR)???val??§???????????¶???
void fill(int queryL, int queryR, int val, int k = 1, int nodeL = 0, int nodeR = N) {
    // ?????¨???????????¨????????????????????????????????????????????????????????\?????????????????????????????????
    if (nodeR <= queryL || queryR <= nodeL) {
        return;
    }
    // ???????????????????????¨?????????????????¨??????????????????????????¶????????????????????????????????£?????¨??°???
    if (queryL <= nodeL && nodeR <= queryR) {
        setLazy(k, val);
        return;
    }
    // ???????????????????????¨??????????????????push??????
    push(k);
    int nodeM = (nodeL + nodeR) / 2;
    fill(queryL, queryR, val, k * 2 + 0, nodeL, nodeM);
    fill(queryL, queryR, val, k * 2 + 1, nodeM, nodeR);

    // ???????????????????????¨??????????????±???fix??????
    fix(k);
}

// ??????[queryL, queryR)???????°????????±???????
int minimum(int queryL, int queryR, int k = 1, int nodeL = 0, int nodeR = N) {
    // ?????¨???????????¨???????????????????????????????????????
    if (nodeR <= queryL || queryR <= nodeL) {
        return int.max;
    }
    // ???????????????????????¨?????????????????¨???????????????
    if (queryL <= nodeL && nodeR <= queryR) {
        return _mini[k];
    }
    // ???????????????????????¨??????????????????push??????
    push(k);
    int nodeM = (nodeL + nodeR) / 2;
    int vl = minimum(queryL, queryR, k * 2 + 0, nodeL, nodeM);
    int vr = minimum(queryL, queryR, k * 2 + 1, nodeM, nodeR);
    return min(vl, vr);
}

Measured memory_bytes: 7280
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define si3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld%lld%lld",&a,&b,&c)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)



int main()
{
   ll t,n,i,j,k,l,mn=0, mx=1000;

   sl(t);

   mn=t/mx;
   if(t%mx) mn++;

   cout<<(mn*mx)-t;

}







Measured memory_bytes: 3688
x = int(input())
y = [int(input()) for i in range(x)]

y.sort(reverse=True)

def fun(y):
  tmp = y[0]
  ans = 1
  for i in y[1:]:
    if tmp > i:
      ans += 1
      tmp = i
    else:
      pass
  return ans
    
print(fun(y))

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

int main() {
    //
    int num, l;
    int sum = 0;
    int small = 999999;

    cin >> num >> l;

    for (int i = 1; i <= num; i++) {
        int tmp;
        tmp = l + i - 1;
        sum += tmp;
        if (abs(tmp) < abs(small)) small = tmp;
    }
    
    cout << sum - small;
    //
}


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

int main(){
  
  int r, D, init;
  cin >> r >> D >> init;
  
  int ans = init;
  
  for(int i=0;i<10;i++){
    ans = r*ans - D;
    cout << ans << endl;
  }
  
}

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

#define endl '\n'
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define SORT(v) sort(ALL(v))
#define SORTD(v) sort(ALL(v), greater<int>())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout<<(x)<<endl
#define printv(v) for(auto i : v){cout<<i<<" ";}cout<<endl
#define printu(v) for(auto i : v){print(i);}
#define readv(v, n) for (int i=0;i<n;i++)cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

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; }

void debug_print() {}

template <class Head, class... Tail>
void debug_print(Head&& head, Tail&&... tail)
{
	cout << (head) << endl;

	debug_print(forward<Tail>(tail)...);
}

int i, j, k;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	map<int, int> a;
	cin >> n;
	rep(i, n) {
		int t;
		cin >> t;
		a[-t] = 1;
	}
	print(a.size());
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n;
	cin >> n;
	vector<string>s(n);
	ll mcount = 0;
	ll acount = 0;
	ll rcount = 0;
	ll ccount = 0;
	ll hcount = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i][0] == 'M') {
			mcount++;
		}
		if (s[i][0] == 'A') {
			acount++;
		}
		if (s[i][0] == 'R') {
			rcount++;
		}
		if (s[i][0] == 'C') {
			ccount++;
		}
		if (s[i][0] == 'H') {
			hcount++;
		}
	}
	int count[5] = { mcount,acount,rcount,ccount,hcount };
	ll ans = 0;
	ll check = 0;
	ll sum = 0;
	for (int bit = 0; bit < (1 << 5); bit++) {
		sum = 1;
		check = 0;
		for (int i = 0; i < 5; i++) {
			if (bit & (1 << i)) {
				check++;
				sum *= count[i];
			}
		}
		if (check == 3) {
			ans += sum;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 6144
#include<stdio.h>

void selectionSort(int *, int);

int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  
  int p[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  
  selectionSort(p, n);
  
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += p[i];
  }
  
  printf("%d\n", sum);
  
  return 0;
}

void selectionSort(int *p, int n)
{
  for (int i = 0; i < n; i++) {
    int minJ, minP = 1000;
    for (int j = i + 1; j < n; j++) {
      if (p[j] < minP) {
        minP = p[j];
        minJ = j;
      }
    }
    if (minP < p[i] ) {
      int tmpP = p[i];
      p[i] = minP;
      p[minJ] = tmpP;
    }
  }
}

Measured memory_bytes: 1728
#include<stdio.h>
int main()
{
    int A1,A2,A3;
    scanf("%d%d%d",&A1,&A2,&A3);
    if(A1+A2+A3>=22)
    {
        printf("bust");
    }
    else
    {
        printf("win");
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.*;

public class Main {
   public static void main (String[] args) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
        int second = Integer.parseInt(reader.readLine());
        int hour = 0,minute = 0;
        while(second >= 3600) {
            second = second - 3600;
            hour++;
        }
        while(second >= 60) {
            second = second - 60;
            minute++;
        }
        System.out.println(hour + ":" + minute + ":" + second);
    } catch(IOException e) {}
   } 
}


Measured memory_bytes: 24252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const double EPS = 1e-10;
struct Vec2 {
  double x;
  double y;

  Vec2() : x(0.0),y(0.0){} 
  Vec2(double _x,double _y) :x(_x),y(_y){}  
  
  Vec2 operator+(const Vec2& other) const { return { x + other.x , y + other.y }; }
  Vec2 operator-(const Vec2& other) const { return { x - other.x , y - other.y }; }

  double dot(const Vec2& other) const { return x * other.x + y * other.y; }
  double cross(const Vec2& other) const { return x * other.y - y * other.x; }
  double length() const { return sqrt(x * x + y * y); }
};

// cosθを返す。A とB のなす角θ
double Cos(const Vec2 A, const Vec2 B) {
  return A.dot(B) / (A.length()*B.length());
}

double Sin(const Vec2 A, const Vec2 B) {
  return A.cross(B) / (A.length()*B.length());
}

int main()
{
  int q; cin >> q;
  while(q-- > 0) {
    vector<double> x(4),y(4);
    rep(i,4) cin >> x[i] >> y[i];
    Vec2 A(x[1] - x[0], y[1] - y[0]);
    Vec2 B(x[3] - x[2], y[3] - y[2]);
    double sine = Sin(A, B);
    double cosi = Cos(A, B);
    if(abs(sine) < EPS) cout << 2 << "\n";
    else if(abs(cosi) < EPS) cout << 1 << "\n";
    else cout << 0 << "\n";
  }
  
  return 0;
}



Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	video = null;

		while ((video = parseVideo()) != null) {
			if (video[0] == -1 && video[1] == -1 && video[2] == -1) {
				break;
			}

			System.out.printf("%02d:%02d:%02d\n", video[0], video[1], video[2]);

			video[0] *= 3;
			video[1] *= 3;
			video[2] *= 3;
			video[1] += video[2] / 60; 
			video[2]  = video[2] % 60; 
			video[0] += video[1] / 60; 
			video[1]  = video[1] % 60; 

			System.out.printf("%02d:%02d:%02d\n", video[0], video[1], video[2]);
		}
	}

	private static int[] parseVideo() {
		int[]		video = null;
		String[]	split = null;
		String		strIn = null;

		if ((strIn = parseStdin()) != null) {
			if (!strIn.equals("-1 -1 -1")) {
				split    = strIn.split(" ");
				video    = new int[3];
				video[0] = 2 - Integer.parseInt(split[0]); 
				video[1] = 0 - Integer.parseInt(split[1]); 
				video[2] = 0 - Integer.parseInt(split[2]); 
	
				if (video[2] < 0) {
					video[1]--;
					video[2] += 60;
				}
	
				if (video[1] < 0) {
					video[0]--;
					video[1] += 60;
				}
			}
		}
		
		return video;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 17028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException, Exception{
		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
		int n = getInt(st);
		double ans = 0;
		if (n == 1) {
			ans = 1;
		} else if(n % 2 == 0) {
			ans = 0.50d;
		} else {
			ans = n/2 + 1;
			ans = ans/n;
		}
		System.out.println(ans);
	}

	private static int getInt(BufferedReader st) throws Exception, IOException {
		int num = Integer.parseInt(st.readLine());
		return num;
	}
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int C0 = 0;
  int C1 = 0;
  int del;
  int ans;
  for(int i = 0; i < N; i++){
    if(S.at(i) == '0'){
      C0++;
    }
    if(S.at(i) == '1'){
      C1++;
    }
  }
  del = min(C0, C1);
  ans = 2 * del;
  cout << ans << endl;
  
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	int N;
	ll sum=0;
	ll sum2=0;
	ll c;
	cin >> N;
	ll min=100000000000;
	for (ll i = 0; i < N; i++)
	{
		cin >> c;
		sum2 += c * c;
		sum += c;
	
	}
	for (ll i = 1; i <= 100; i++) {

		if (sum2 - 2 * sum * i + N*i * i < min) {


		min= sum2 - 2 * sum * i +N* i * i;
		}

	}
	cout << min;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  string s, t;
  cin >> s >> t;

  auto ans = 0;
  rep (i, 3)
  {
    if (s [i] == t [i]) ++ ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,ans=0;
	string s;
	cin>>n;
	vector <int> b(n-1);
	rep(i,n-1)cin>>b[i];
	rep(i,n-2)ans+=min(b[i],b[i+1]);
	ans+=b[0];
	ans+=b[n-2];
	cout<<ans;
	return 0;
}


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

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

  pair<int,int> AB[N]; // AB[i]=(価格, 本数)
  for(int i=0; i<N; i++){
    cin >> AB[i].first >> AB[i].second;
  }
  sort(AB,AB+N);

  int k=0;
  long long int price=0;
  for(int i=0; i<M; i++){
    if(AB[k].second==0){
      k++;
    }
    AB[k].second--;
    price += AB[k].first;
  }

  cout << price << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

int main() {
	//cin.tie(0); ios::sync_with_stdio(false);
	int n, m, a, b, c, ans = 0;
	cin >> n >> m;
	vi av, bv, cv;
	vvi dist(n, vi(n, INT_MAX/2));
	rep(i, m) {
		cin >> a >> b >> c;
		av.push_back(a);
		bv.push_back(b);
		cv.push_back(c);
		dist[a - 1][b - 1] = c;
		dist[b - 1][a - 1] = c;
	}
	rep(i, n) dist[i][i] = 0;
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	rep(i, m) {
		bool sw = false;
		rep(j, n) {
			if (dist[j][av[i] - 1] + cv[i] == dist[j][bv[i] - 1])sw = true;
		}
		if (!sw)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


ll n;
ll a[200005];
ll b[200005];
priority_queue< pll > pq;
priority_queue< pll > ee;
inline ll lft(ll x)
{
        if(x==1) return n;
        return (x-1);
}
inline ll rgt(ll x)
{
        if(x == n) return 1;
        return x+1;
}
int main()
{
        cin >> n;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];

        }
        ll op1 = 0;
        ll op2 = 0;
        for(ll i=1;i<=n;i++) cin >> b[i];
        for(ll i=1;i<=n;i++) {
                if(b[i] > b[lft(i)] + b[rgt(i)] && b[i] > a[i]) {
                        pq.push(make_pair(b[i], i));
                }
        }
        while(pq.empty() == false) {
                pll u = pq.top();
                ll l = lft(u.second);
                ll r = rgt(u.second);
                ll el = u.first;
                if(b[l] + b[r] == 0){
                        pq.pop(); continue;
                }
                ll T = b[l]+b[r];
                if(a[u.second]%T == b[u.second]%T){
                        op2 += (b[u.second] - a[u.second])/T;
                        b[u.second] = a[u.second];
                }else {
                        op2 += (b[u.second])/T;
                        b[u.second] %= T;
                }
                //b[u.second] = el;
                if(b[l] > b[lft(l)] + b[rgt(l)] && b[l] > a[l]) {
                        pq.push(make_pair(b[l], l));
                }
                if(b[r] > b[lft(r)] + b[rgt(r)] && b[r] > a[r]) {
                        pq.push(make_pair(b[r], r));
                }
                pq.pop();
        }
        for(ll i=1;i<=n;i++){
                if(a[i] != b[i]){
                        cout << "-1\n"; return 0;
                }
        }
        cout << op2 - op1 << endl;
        return 0;
}


Measured memory_bytes: 5492
#include<stdio.h>
char a, b;
char am, bm;
int main(void){
	a=(getchar()-'0')*10+(getchar()-'0');
	b=(getchar()-'0')*10+(getchar()-'0');
	if(1<=a && a<=12){am=1;}
	if(1<=b && b<=12){bm=1;}
	if(am){
		if(bm){
			puts("AMBIGUOUS");
		}else{
			puts("MMYY");
		}
	}else{
		if(bm){
			puts("YYMM");
		}else{
			puts("NA");
		}
	}
}


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

int main() {
  int a,b,d,e;
  cin>>a>>b;
  string c;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=b;j++){
      cin>>c;
      if(c=="snuke"){
        d=i;
        e=j;
      }
    }
  }
  char f='A';
  for(int i=1;i<e;i++){
    f++;
  }
  cout<<f<<d<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main(){
    int a[5]={},k;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    for(int i=0; i<4; i++){
      for(int j=i+1; j<5; j++){
        if(a[j]-a[i] > k){
          cout << ":(" << endl;
          return 0;
        }
      }
    }
    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

template<typename Ty>
inline Ty gcd(Ty a, Ty b)
{
	Ty r;
	if (a < b) swap(a, b);
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		string S;

		cin >> S;
		if (cin.fail()) break;

		bool yes = (S[0] == S[1] && S[2] == S[3])
			|| (S[0] == S[2] && S[1] == S[3])
			|| (S[0] == S[3] && S[1] == S[2]);
		if (S[0] == S[1] && S[1] == S[2] && S[2] == S[3]) yes = false;

		cout << (yes ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

  int K;
  string S;
  cin >> K >> S;
  
  if (S.size() <= K){
    cout << S << endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h> 
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;


int n,ans;
int main(){
  cin>>n;
  if(n%2==0)ans=n;
  else ans=n*2;
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
N, K = map(int, input().strip().split())
V = list(map(int, input().strip().split()))
H = []
maxi = 0
for i in range(min(N, K)):
    for o in range(i+2):  # error1
        ts = 0
        hand = []
        for p in range(o):
            hand.append(V[p])
        for p in range(N-(i-o)-1, N):  # error2
            hand.append(V[p])
        for values in hand:
            ts += values
        if ts > maxi:
            maxi = ts
        if len(hand) > 0:
            hand.sort()
            for j in range(K-i-1):  # error3
                if len(hand) > 0:
                    if hand[0] < 0:
                        del hand[0]
                    else:
                        break
        ts = 0
        for k in hand:
            ts += k
        if ts > maxi:
            maxi = ts
print(maxi)

Measured memory_bytes: 3064
from collections import defaultdict
from heapq import*
n,m=map(int,input().split())
e = defaultdict(list)
dist = [2**60]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
q = [(0,0)]
dist[0] = 0
prev = [-1]*n
while q:
    s = heappop(q)
    c,v = s
    for u in e[v]:
        if dist[u] > dist[v]+1:
            dist[u] = dist[v]+1
            heappush(q,(dist[u],u))
            prev[u]=v
if -1 in prev[1:]:
    print('No')
else:
    print('Yes')
    for p in prev[1:]:
        print(p+1)

Measured memory_bytes: 43508
n1 = int(input())
na1 = []

for i1 in range(5):
    na1.append(int(input()))

n2 = min(na1)

r1 = n1 // n2

if n1 % n2 == 0 and n1 // n2 != 0:
    r1 -= 1

r1 += 5
print(r1)

Measured memory_bytes: 3060
#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>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  print((N * (N + 1)) / 2);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200010;

int main() {
	cout << fixed << setprecision(15);
	int n, k;
	cin >> n >> k;
	double p[N];
	rep(i, n) cin >> p[i];
	double sp[N];
	sp[0] = 0.0;
	rep(i, n) sp[i + 1] = sp[i] + p[i];
	double ans = 0.0;
	for(int i = 1; i <= n; i++) {
		if(i - k < 0) continue;
		ans = max((sp[i] - sp[i - k] + k) / 2.0, ans);
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  int mi = INT_MAX;
  int ma = INT_MIN;
  for(auto & i : p){
    cin >> i;
    mi = min(mi, i);
    ma = max(ma, i);
  }
  
  int total = INT_MAX;
  for(int range = mi; range <= ma; range++){
    int tmp = 0;
    for(auto &i : p)
      tmp += (i - range)*(i - range);
    total = min(total, tmp);
  }
  cout << total << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

int main(){
    string s;
    getline(cin, s);

    vector<mint> p3(s.size() + 1);
    p3.at(0) = 1;
    for(int i = 1; i < p3.size(); ++i){
        p3.at(i) = p3.at(i - 1) * 3;
    }

    ll na = 0, nb = 0, nq = 0, naq = 0, nqb = 0, nqq = 0, nab = 0;
    mint ans = 0;
    for(char c : s){
        if(c == 'A'){
            na += 1;
        }else if(c == 'B'){
            nqb += nq;
            nab += na;
            nb += 1;
        }else if(c == '?'){
            ans *= 3;
            ans += p3.at(max((nq - 1), 0LL)) * naq
                + p3.at(max((nq - 1), 0LL)) * nqb
                + p3.at(max((nq - 2), 0LL)) * nqq
                + p3.at(nq) * nab;

            nqq += nq;
            naq += na;
            nq += 1;
        }else{  // c == 'C'
            ans += p3.at(max((nq - 1), 0LL)) * naq
                + p3.at(max((nq - 1), 0LL)) * nqb
                + p3.at(max((nq - 2), 0LL)) * nqq
                + p3.at(nq) * nab;
        }
    }
    cout << ans.v << endl;
    return 0;
}


Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const ll mod= 1e9+7;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){  
  int n,m;cin>>n>>m;
  ll x[n],y[n],z[n];
  rep(i,n)cin>>x[i]>>y[i]>>z[i];
  ll a[8][n];
  rep(i,n){
    a[0][i]=x[i]+y[i]+z[i];
    a[1][i]=x[i]-y[i]+z[i];
    a[2][i]=x[i]+y[i]-z[i];
    a[3][i]=x[i]-y[i]-z[i];
    a[4][i]=-x[i]+y[i]+z[i];
    a[5][i]=-x[i]-y[i]+z[i];
    a[6][i]=-x[i]+y[i]-z[i];
    a[7][i]=-x[i]-y[i]-z[i];
    }
  rep(i,8){
    sort(a[i],a[i]+n);
    reverse(a[i],a[i]+n);
    }
  ll res=0;
  rep(j,8){
    ll ret=0;
    rep(i,m)ret+=a[j][i];
    res=max(res,ret);
    }
  cout<<res<<endl;
  
    
  return 0;
  
  }

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    double n;
    ci >> n;

    if((int)n % 2) co << (((int)(n / 2) + 1) / n) << en;
    else      co << 0.5 << en;
  
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    set<int> a;
    int n;
    rep(i,3){
        cin>>n;
        a.insert(n);
    }
    if(a.size()==2) dunk("Yes");
    else dunk("No");
}



Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let mut x: Vec<usize> = vec![];
    let mut y: Vec<usize> = vec![];
    for _ in 0..n {
        x.push(sc.read::<usize>() - 1);
        y.push(sc.read::<usize>() - 1);
    }

    let x_upper = *x.iter().max().unwrap() + 1;
    let y_upper = *y.iter().max().unwrap() + 1;
    let mut uf = UnionFind::new(x_upper + y_upper);
    for i in 0..n {
        uf.unite(x[i], x_upper + y[i]);
    }

    let mut x_count: Vec<usize> = vec![0; x_upper + y_upper];
    let mut y_count: Vec<usize> = vec![0; x_upper + y_upper];
    let mut included = vec![0; x_upper + y_upper];
    for x in 0..x_upper {
        let x = uf.find(x);
        x_count[x] += 1;
    }
    for y in 0..y_upper {
        let y = uf.find(y + x_upper);
        y_count[y] += 1;
    }
    for i in 0..n {
        let root = uf.find(x[i]);
        included[root] += 1;
    }

    let mut total = 0;
    for root in 0..(x_upper + y_upper) {
        if x_count[root] >= 2 && y_count[root] >= 2 {
            total += x_count[root] * y_count[root] - included[root];
        }
    }

    println!("{}", total);
}

pub struct UnionFind {
    parent: Vec<usize>,
    sizes: Vec<usize>,
    size: usize,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).map(|i| i).collect::<Vec<usize>>(),
            sizes: vec![1; n],
            size: n,
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let px = self.parent[x];
            self.parent[x] = self.find(px);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, x: usize, y: usize) -> bool {
        let parent_x = self.find(x);
        let parent_y = self.find(y);
        if parent_x == parent_y {
            return false;
        }

        let (large, small) = if self.sizes[parent_x] < self.sizes[parent_y] {
            (parent_y, parent_x)
        } else {
            (parent_x, parent_y)
        };

        self.parent[small] = large;
        self.sizes[large] += self.sizes[small];
        self.sizes[small] = 0;
        self.size -= 1;
        return true;
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 18684
A, B, C, D, E, F = gets.split.map(&:to_i)
wt = 0.step(F, 100*A).flat_map{|a| 0.step(F - a, 100*B).map{|b| a + b}}.sort.uniq
sg = 0.step(F, C).flat_map{|c| 0.step(F - c, D).map{|d| c + d}}.sort.uniq
puts wt.product(sg).drop(1).select{|w, s| w + s <= F && 100*s <= w*E}.map{|w, s| [w + s, s]}.max_by{|a, s| 100.0*s / a}.join(' ')

Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
int n;
string s;
int ans=0;
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Cryptography;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			//if (n == 1) {
			//	Console.WriteLine(0);
			//	return;
			//}

			long a = 1, b = 1, c = 1, d = 0;
			for (int i = 0; i < n; i++) {
				// 全ての組み合わせ  a = 10 * 10 * 10 * ...
				a *= 10;
				a %= mod;
				// n 桁中 0,9 を含まない b = 8 * 8 * 8 * ...
				b *= 8;
				b %= mod;
				// n 桁中 n-0 桁 0,9 で全て同じ 2 * 1 * ... * 1 * 1 * nP(n-0)
				// n 桁中 n-1 桁 0,9 で全て同じ 2 * 1 * ... * 1 * 8 * nP(n-1)
				// n 桁中 n-2 桁 0,9 で全て同じ 2 * 1 * ... * 8 * 8 * nP(n-1)
				// n 桁中 1   桁 0,9 で全て同じ 2 * 8 * ... * 8 * 8 * nP1
				c *= i == 0 ? 2 : 8;
				c %= mod;
				d += c * CombinationFactorial(n, n - i, mod);
				d %= mod;
			}
			long ans = Mod(a - b - d, mod);
			Console.WriteLine(ans);
		}

		#region 場合の数(階乗) long CombinationFactorial(int n, int r, long mod)
		static long CombinationFactorial(int n, int r, long mod)
		{
			if (n < r) { return 0; }
			if (n == r) { return 1; }
			// n! / r!(n-r)!
			long result = Factorial(n, mod);
			result *= ModInv(Factorial(r, mod), mod);
			result = Mod(result, mod);
			result *= ModInv(Factorial(n - r, mod), mod);
			result = Mod(result, mod);
			return result;
		}
		#endregion

		#region 階乗(メモ付) long Factorial(int a, long mod)
		static long Factorial(int a, long mod)
		{
			if (a < _Factorial.Count) {
				return _Factorial[a];
			}
			int st = _Factorial.Count;
			long result = st > 0 ? _Factorial[st - 1] : 1;
			for (int i = st; i <= a; i++) {
				result *= i;
				result = Mod(result, mod);
				_Factorial.Add(result);
			}
			return result;
		}
		static List<long> _Factorial = new List<long>(new long[] { 1 });
		#endregion

		#region 逆元(拡張Euclidの互除法) long ModInv(long a, long mod)
		static long ModInv(long a, long m)
		{
			long b = m, x = 1, y = 0;
			while (b > 0) {
				long t = a / b;
				a = Mod(a, b);
				x = x - t * y;
				(a, b, x, y) = (b, a, y, x);
			}
			x = Mod(x, m);
			return x;
		}
		#endregion

	}
}


Measured memory_bytes: 44152
import java.util.InputMismatchException;
import java.util.Scanner;

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

		try {
			int x = sc.nextInt();

			System.out.println(x * x * x);
		} catch(InputMismatchException ex) {
			ex.printStackTrace();
		} finally {
			sc.close();
		}
	}
}



Measured memory_bytes: 26360
import Data.List.Split
import Data.Char

main = fmap (map read . words) getLine >>=
  \[_,w] -> getLine >>=
  \_ -> fmap (map read . words ) getLine >>=
  \as -> let xs = (chunksOf w . concatMap (\(x,y) -> replicate y (show x)) . zip [1..]) as
         in mapM_ putStrLn $ map concat $ map g (f 1 xs)

-- [[1,2,2],[3,3,3],[4,4,4],[4,5,5],[5,5,5]]

f :: Int -> [[a]] -> [[a]]
f _ [] = []
f n (xs:xss)
  | odd n = xs : f (n+1) xss
  | otherwise = reverse xs : f (n+1) xss

g :: [String] -> [String]
g [] = []
g (x:xs) = x : " " : g xs

Measured memory_bytes: 2428
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, k, i, ans;
int a[maxN];
vector<int> list[maxN];
int dp[maxN];
bool good[maxN];

void dfs(int node) {
    dp[node] = 0;

    for (auto to : list[node]) {
        dfs(to);
        dp[node] = max(dp[node], dp[to] + 1);
    }

    if (dp[node] == k - 1 && node != 1 && !good[node]) {
        ans++;
        dp[node] = -1;
    }
}

int main()
{
//    freopen("test.in","r",stdin);

    scanf("%d%d", &n, &k);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);

    if (a[1] != 1) ans++;
    a[1] = 1;

    for (i = 2; i <= n; i++) {
        list[a[i]].pb(i);
        if (a[i] == 1) good[i] = true;
    }

    dfs(1);
    printf("%d", ans);


    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	rep(i,3){
		int a,b,c,d,e,f;
		cin>>a>>b>>c>>d>>e>>f;
		int ans=d*3600+e*60+f-(a*3600+b*60+c);
		cout<<ans/3600<<" "<<(ans/60)%60<<" "<<ans%60<<endl;
	}
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, a;
  cin >> x >> a;

  if(x < a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
  return 0;
}



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

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

    int x = b-a, y = c-b;

    if(x == y){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }
   
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int r, g, b, n; cin >> r >> g >> b >> n;
	int ans = 0;
	rep(i, 3001)rep(j, 3001) {
		if (i * r + j * g <= n && (n - i * r - j * g) % b == 0)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
import bisect

n, c = [int(item) for item in input().split()]

xs, vs, xrs = [], [], []
for i in range(n):
  x, v = [int(item) for item in input().split()]
  xs.append(x)
  xrs.append(c-x)
  vs.append(v)
xrs = xrs[::-1]

lft_v = list(accumulate(vs))
rgt_v = list(accumulate(vs[::-1]))

lft_c = []
rgt_c = []
for i in range(n):
  lft_c.append(lft_v[i]-xs[i])
  rgt_c.append(rgt_v[i]-xrs[i])
  
lft_max = [0] * n
rgt_max = [0] * n
lm, rm = 0,0
for i in range(n):
  if lm < lft_c[i]:
    lm = lft_c[i]
  lft_max[i] = lm
  if rm < rgt_c[i]:
    rm = rgt_c[i]
  rgt_max[i] = rm

ans = 0
# No return
for i in range(n):
  ans = max(ans, lft_c[i], rgt_c[i])
  
# Includes return
for i in range(n-1):
  ans = max(ans, lft_c[i] - xs[i] + rgt_max[n-2-i])
  ans = max(ans, rgt_c[i] - xrs[i] + lft_max[n-2-i])
    
print(ans)

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

int Plus(int x){
    int sum=0;
    while(x>0){
        sum+=x%10;
        x/=10;
    }
    return sum;
}

int main(void){
    int n,a,b,sum;
    cin>>n>>a>>b;
    sum=0;
    for(int i=1;i<=n;i++){
        int d=Plus(i);
        if(d>=a && d<=b){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    cin >> a[i + 1];
  }

  int ac = 0, bc = 0;
  FOR(i, 1, n + 1) {
    if(a[i] == i) ac++;
  }

  if(ac >= n - 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N, K;
int l[52];

int main(){
  cin.tie(0);

  cin>>N>>K;
  REP(i, N)cin>>l[i];
  sort(l, l+N);
  int s=0;
  REP(i, K)s+=l[N-i-1];
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int S;
	int h, m, s;

	scanf("%d", &S);

	if (S >= 0) {
		if (S < 86400) {
				h = S / 3600;
				m = (S - h * 3600) / 60;
				s = S - h * 3600 - m * 60;
				printf("%d:%d:%d\n", h, m, s);
		}
	}

	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int a[20]={0,100,1,2,3,4,5,6,7,8,9,10,11,12};
int main(){
	int A,b;
	cin>>A>>b;
	if(a[A]==a[b])
		cout<<"Draw"<<endl;
	else if(a[A]>a[b])
		cout<<"Alice"<<endl;
	else
		cout<<"Bob"<<endl;
	return 0;
}

Measured memory_bytes: 256