akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    vector<long> X(N);
    vector<long> L(N);
    vector<long> fin_x(N);
    // fin_xのindexを格納する配列
    vector<size_t> indices(fin_x.size());
    iota(indices.begin(), indices.end(), 0);

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

    sort(indices.begin(), indices.end(), [&fin_x](size_t i1, size_t i2){
        return fin_x[i1] < fin_x[i2];
    });
    
    int counter = 0;
    long end_x = -10000000;

    for(int i=0; i<N; i++){
        // cout << indices[i] << endl;
        if(end_x <= X[indices[i]] - L[indices[i]]){
            counter++;
            end_x = X[indices[i]] + L[indices[i]];
            // cout << end_x << endl;
        }
    }
    
    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 3328
a,b,m = input().split()
a = int(a)
b = int(b)
m = int(m)

al = input().split()
bl = input().split()
ml = [list(map(int, input().split())) for i in range(m)]

al = list(map(int, al))
bl = list(map(int, bl))

als = sorted(al)
bls = sorted(bl)

tmp = als[0] + bls[0]

comp = 0
fp = tmp
for i in ml:
  comp = al[i[0]-1] + bl[i[1]-1] - i[2]
  if comp < fp:
    fp = comp

print(fp)

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


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

vector<long> a(50,49);

long it=K/50;
long res=K%=50;

for(int i=0;i<50;i++){
  a[i]+=it;
}

for(int i=0;i<res;i++){
  for(int j=0;j<50;j++){
    if(i!=j) a[j]--;
    else a[j]+=50;
  }
}

cout<<50<<endl;
for(int i=0;i<50;i++) cout<<a[i]<<" ";
cout<<endl;
}


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

using namespace std;

int main() {
    int n, tmp;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        if (x == y) {
            ++tmp;
            if (tmp == 3) {
                break;
            }
        } else {
            tmp = 0;
        }

    }
    if (tmp >= 3) {
        cout << "Yes" << endl;

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

Measured memory_bytes: 3632
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T>
vector<pair<T, int>> runlength(vector<T> arr) {
	int i = 0;
	int n = arr.size();
	vector<pair<T, int>> run;
	while (i < arr.size()) {
		T t = arr[i];
		int k = 0;
		while (i + k < n && arr[i + k] == t) k++;
		run.push_back(pair<T, int>(t, k));
		i += k;
	}
	return run;
}
int main(void) {
	string t; cin >> t;
	int n = t.length();
	int ans = n;
	for (int k = 0; k < n - 1; k++) {
		if (t[k] != t[k + 1]) {
			mins(ans, max(k+1, n - k-1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

int dp[105][55][55];

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d(n);
    const int INF = numeric_limits<int>::min();
    for(auto&& x:d)cin >> x;
    for(int i=0;i<=k+2;i++)for(int l=0;l<=n;l++)for(int r=0;r<=n;r++)dp[i][l][r] = INF;
    dp[0][0][n] = 0;
    for(int i=0;i<k;i++){
        for(int l=0;l<=n;l++){
            for(int r=l;r<=n;r++){
                if(dp[i][l][r] == INF)continue;
                //nop
                for(int t=i+1;t<=k;t++)
                    dp[t][l][r] = max(dp[t][l][r], dp[i][l][r]);
                cerr << i << " " << l << " " << r << " " << dp[i][l][r] << endl;
                if(l+1 <= r){
                    // pop l and enq l
                    dp[i+2][l+1][r] = max(dp[i+2][l+1][r], dp[i][l][r]);
                    // pop l
                    dp[i+1][l+1][r] = max(dp[i+1][l+1][r], dp[i][l][r] + d[l]);
                }
                if(l <= r-1){
                    // pop r and enq r
                    dp[i+2][l][r-1] = max(dp[i+2][l][r-1], dp[i][l][r]);
                    // pop r
                    dp[i+1][l][r-1] = max(dp[i+1][l][r-1], dp[i][l][r] + d[r-1]);
                }
            }
        }
    }
    int ret = 0;
    for(int l=0;l<=n;l++){
        for(int r=0;r<=n;r++){
            cerr << dp[k][l][r] << " ";
        }cerr << endl;
    }
    for(int l=0;l<n;l++)for(int r=l;r<=n;r++)ret = max(ret, dp[k][l][r]);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
  int S;
  int h, m, s;
  scanf("%d", &S);
  h = S / 3600;
  m = (S % 3600) / 60;
  s = S % 60;
  //m = (S - h * 3600) / 60;
  //s = S - h * 3600 - m * 60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 1020
// #define DEBUG_MODE
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp("[%s = %s]\n", #x, to_string(x).data())

const int N = 200010;
int f[N], vis[N], n, q;
vector<vi> adj;

void dfs (int u) {
	vis[u] = true;
	for (int i = 0; i < (int)adj[u].size(); i++) {
		int v = adj[u][i];
		if (!vis[v]) {
			f[v] += f[u];
			dfs(v);
		}
	}
}

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	int x, y;
	memset(f, 0, sizeof f);
	memset(vis, 0, sizeof vis);

	scanf("%d%d", &n, &q);
	adj.assign(n + 1, vi(0));
	for (int i = 0; i < n - 1; i++) {
		scanf("%d%d", &x, &y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	while (q--) {
		scanf("%d%d", &x, &y);
		f[x] += y;
	}

	dfs(1);
	for (int i = 1; i <= n; i++) printf("%d%c", f[i], " \n"[i == n]);
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
  int ec = 0,ec2 = 0,wc = 0,wc2 = 0,N,cmin = 9999999999;
  cin >> N;
  vector<int> count(N);
  string s;
  cin >> s;
  froop1(0,N){
	if(s[i] == 'E'){
      ec++;
    }else{
      wc++;
    }
  }
  froop1(0,N){
    if(s[i] == 'E'){
      ec--;
    }else{
      wc--;
    }
    count.at(i) = ec + wc2;
    if(s[i] == 'E'){
      ec2++;
    }else{
      wc2++;
    }
    if(cmin > count.at(i)){
      cmin = count.at(i);
    }
  }
  cout << cmin << endl;
return 0;
}

Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <boost/math/constants/constants.hpp>

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

int main(){
  ll N;
  cin >> N;
  ll H[100010];
  rep(i, N) cin >> H[i];
  
  if(N==1){
    cout << "Yes" << endl;
    return 0;
  }
  rep(i, N-1){
    //cout << H[N-i-1] << endl;
    if(H[N-i-1] < H[N-i-2]){
      H[N-i-2]--;
      if(H[N-i-1] != H[N-i-2]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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


int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    for (int i = 1; i <= B;i++)
    {
        if(A * i % B == C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double arg=max(6.0*m-(30.0*h+0.50*m),(30.0*h+0.50*m)-6.0*m);
  arg=min(360.0-arg,arg);
  double rad=arg*acos(-1)/180.0;
  double x=a*a+b*b-2.0*a*b*cos(rad);
  double ans=sqrt(x);
  
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 4204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
    long N;
    long d[50]={};
    long sum=0;
    std::cin >> N;
    for(long i=0; i<N; i++){
        std::cin >> d[i];
    }
    for(long i=0; i<N-1; i++){
        for(long j=i+1; j<N; j++){
            sum+=d[i]*d[j];
        }
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a;

    cin >> a;

    if(a < 1200){
        cout << "ABC" << endl;
    }
    else {
        cout << "ARC" << endl;
    }
    
    return 0;
}




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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            var list = new List<int>();
            var boo = 0;
            for (int i = 0; i < input[0]; i++)
            {
                var x = ReadInts();
                if (x[1] <= input[1])
                {
                    list.Add(x[0]);
                    boo = 1;
                }
            }
            if (boo==0)
            {
                WriteLine("TLE");
            }
            else
            {
                WriteLine(list.Min());
            }
            
            
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

typedef pair<int, int> P;

bool cmp(pair<int,int> a, pair<int,int> b) { 
  return a.second < b.second; 
}

int main() {
  int n;
  cin >> n;
  vector<P> red(n);
  vector<P> blue(n);

  for (int i = 0; i < n; i++) {
    cin >> red[i].first >> red[i].second;
  }

  for (int i = 0; i < n; i++) {
    cin >> blue[i].first >> blue[i].second;
  }

  sort(red.begin(), red.end(), cmp);
  reverse(red.begin(), red.end());

  sort(blue.begin(), blue.end());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < red.size(); j++) {
      if (blue.at(i).first > red.at(j).first && blue.at(i).second > red.at(j).second) {
        red.erase(red.begin()+j);
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

vector<int> Zalgorithm(auto S){
    vector<int> res(S.size());
    res[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k; j -= k;
    }
    return res;
}

int solve(const string& s , const string& t){
    string u = t + s;
    while(u.size() < s.size() + 2 * t.size()) u += s;
    vector<int> zlen = Zalgorithm(u);
    vector<int> check(s.size(), -1);
    for(int i=0;i<s.size();i++){
        if(zlen[t.size() + i] < t.size()) check[i] = 0;
    }
    for(int i=0;i<s.size();i++){
        if(check[i] != -1) continue;
        vector<int> visit;
        int pos = i;
        while(zlen[t.size() + pos] >= t.size()){
            visit.push_back(pos);
            pos = (pos + t.size()) % s.size();
            if(pos == i) return -1;
            if(check[pos] != -1) break;
        }
        for(int j=visit.size()-1;j>=0;j--){
            check[visit[j]] = check[(visit[j] + t.size())%s.size()] + 1;
        }
    }
    return *max_element(check.begin(), check.end());
}

int main(){
    string s, t;
    while(cin >> s >> t){
        cout << solve(s, t) << endl;
    }
}

Measured memory_bytes: 16912
n,m = map(int,input().split())
inf = float('inf')
dp = [inf]*(2**n)
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  c = sum([ 1<< (p-1) for p in list(map(int,input().split()))])
  for j in range(2**n):
    dp[j|c] =min(dp[j|c] ,dp[j]+a)
    
print(dp[2**n-1] if dp[2**n-1] != inf else -1)

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

int main(){
    map <char, int> m = {{'A',10},{'B',11},{'C',12},{'D',13},{'E',14},{'F',15}};
    char a, b;
    cin >> a >> b;
    if(m[a] > m[b]) cout << ">" << endl;
    else if(m[a] < m[b]) cout << "<" << endl;
    else cout << "=" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int x, y;
	while(1)
	{
		scanf("%d %d", &x, &y);
		if(x ==0 && y == 0)
		break;
		if(x < y)
		{
			printf("%d %d\n",x, y);
		}else {
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int a,b;
  cin >> a >> b;
  bool ch=false;
  if(a<b){
    swap(a,b);ch=true;
  }
  b-=1;
  int col[100][100];
  int ta=a;
  int tb=b;  
  int x,y;
  x=y=0;
  while(tb>0){
    col[x][y]=(x%2);col[x][y+1]=((x+1)%2);
    y+=2;
    if(y==100){
      x++;y=0;
    }
    ta--;tb--;    
  }


  int taa=0;
  while(y!=0){
    col[x][y]=0;col[x][y+1]=0;
    ta--;
    taa++;
    y+=2;
    if(y==100){
      x+=1;y=0;
    }
  }
  x++;
  //  rep(i,100) col[x][i]=0;
  //  x++;
  //  ta
  if(x>=3) ta=ta+taa+49;
  else ta=a-1;
  //  cout << ta << endl;
  while(x<100){
    rep(i,100) col[x][i]=1;
    x++;
    if(x>=100) break;
    rep(i,50){
      if(ta==0){
	col[x][i*2]=1;
	col[x][i*2+1]=1;
	continue;
      }
      col[x][i*2]=0;
      col[x][i*2+1]=1;
      ta--;      
    }
    x++;
  }
  cout << 100 << " " << 100 << endl;
  rep(i,100){
    rep(j,100){
      if(ch) col[j][i]=(col[j][i]+1)%2;
      if(col[j][i]==1){
	cout << "#";
      }
      else cout << ".";
    }
    cout << "" << endl;    
  }
  return 0;
}


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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans=1e9,num=0,n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=-100;i<=100;i++){
        for(int j=0;j<n;j++){
            num+=pow(abs(a[j]-i),2);
        }
        ans=min(ans,num);
        num=0;
    }
    cout << ans<<endl;
    return 0;
}



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

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

    vec s(n + 1), t(m + 1);
    For(i, 1, n) cin >> s[i];
    For(i, 1, m) cin >> t[i];

    vector<vec> dp(n + 1, vec(m + 1));

    rep (i, n + 1)
        dp[i][0] = 1;
    rep (i, m + 1)
        dp[0][i] = 1;

    For(i, 1, n) {
        For(j, 1, m) {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            if (s[i] != t[j]) dp[i][j] += MOD - dp[i - 1][j - 1];
            dp[i][j] %= MOD;
        }
    }
    print(dp[n][m]);

    return 0;
}


Measured memory_bytes: 31616
nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])

if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print( "Yes")
    else:
        print( "No")
else:
    print( "No")

Measured memory_bytes: 7720
//In the name of Allah
#include <bits/stdc++.h>
using namespace std; 

const int maxN = 100 * 1000 + 10;
vector<int> c[maxN];
vector<int> v[maxN]; 


int dfs( int s ) { 
    for( auto x : c[s] ) 
        v[s].push_back( dfs( x ) );

    sort( v[s].begin() , v[s].end() ); 
    int mn = 0; 
    for( auto x : v[s] ) 
        mn = max( mn , x ) + 1;
    return mn;
}


int main() { 
    int n; cin >> n; 
    for( int i = 1 ; i < n ; i++ ) { 
        int x; cin >> x; 
        x--; 
        c[x].push_back(i); 
    }
    cout << dfs(0) << endl;
}


Measured memory_bytes: 17408
while 1:
  n,r=list(map(int,input().split()))
  if not n and not r:break
  l=list(range(1,n+1))[::-1]
  for _ in range(r):
    p,c=list(map(int,input().split()))
    l=l[p-1:p-1+c]+l[0:p-1]+l[p-1+c:]
  print(l[0])


Measured memory_bytes: 5612
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

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

int main(){
int N;
bool flag = false;
cin>>N;
if(N%10 == 7)flag =true;
else if((N/10)%10==7)flag = true;
else if(N/100==7)flag = true;
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
s = list(str(input()))
s = list(map(int, s))
k = int(input())

flag = True
for i in range(min(len(s),k)):
    if s[i] != 1:
        flag = False
    else:
        pass

if flag:
    print(1)
else:
    for i in range(len(s)):
        if s[i] != 1:
            print(s[i])
            break


Measured memory_bytes: 3060
n=int(input())
a_list = list(map(int,input().split()))

import collections
c = collections.Counter(a_list)

dict_items = list(c.items())

ans_max = 0
for j in range(len(dict_items)):
    ans_max += ((dict_items[j][1] - 0) * (dict_items[j][1] - 1)) / 2
    
for i in range(n): # kごと
    tmp = c[a_list[i]]
    ans_tmp = ans_max - tmp*(tmp-1)/2 + (tmp-1)*(tmp-2)/2
    print(int(ans_tmp))

Measured memory_bytes: 29780
import java.util.Scanner

fun main(args: Array<String>){
	val s = Scanner(System.`in`).nextLine()
	val S = s.split(" ")

	val D = Integer.parseInt(S[0])
	val N = Integer.parseInt(S[1])

	val factor: Int = when{
		D == 0 -> 1
		D == 1 -> 100
		D == 2 -> 10000
		else -> 1
	}

	val order: Int = when{
		N == 100 -> 101
		else -> N
	}

	println(factor*order)
}

Measured memory_bytes: 35824
public class Main {
 
  private static void solve() {
    int x1 = ni();
    int y1 = ni();
    int x2 = ni();
    int y2 = ni();

    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x3 - dx;
    int y4 = y3 - dy;
    out.println(x3 + " " + y3 + " "  + x4 + " " + y4);
  }
 
  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }
 
  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;
 
  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
 
  private static double nd() {
    return Double.parseDouble(next());
  }
 
  private static long nl() {
    return Long.parseLong(next());
  }
 
  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }
 
  private static char[] ns() {
    return next().toCharArray();
  }
 
  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }
 
  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }
 
  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }
 
  private static int ni() {
    return Integer.parseInt(next());
  }
 
  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
 }

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

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

    vector<int> L(N + 1), R(N + 1);
    L[0] = 0, R[N] = 0;
    for (int i = 0; i < N; i++)
        L[i + 1] = max(L[i], A[i]);
    for (int i = N - 1; i >= 0; i--)
        R[i] = max(R[i + 1], A[i]);

    for (int i = 0; i < N; i++) {
        int l = L[i];
        int r = R[i + 1];
        cout << max(l, r) << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
char imap[8][9];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};


void bfs(int x, int y) {
    queue <pair<int, pair<int, int> > > q;
    pair <int, pair <int, int> > p;
    int nx, ny;
    imap[x][y] = '0';
    q.push({1, {x, y}});
    while ( ! q.empty() ) {
        p = q.front(); q.pop();
        for (int i = 0; i < 4; i++) {
            nx = p.second.first + (dx[i] * p.first), ny = p.second.second + (dy[i] * p.first);
            if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && imap[nx][ny] == '1') {
                q.push({1, {nx, ny}});
                imap[nx][ny] = '0';
            }
        }
        if (p.first < 3) q.push({p.first+1, {p.second.first, p.second.second}});
    }
}

int main(){

    int N, x, y;
    scanf("%d", &N);
    for (int t = 1; t <= N; t++) {
        for (int i = 0; i < 8; i++) {
            scanf("%s", imap[i]);
        }
        scanf("%d %d", &y, &x);
        bfs(x-1, y-1);
        printf("Data %d:\n", t);
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) printf("%c", imap[i][j]);
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2588
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n + 1],
    }
    let mut acc = vec![0; n + 2];
    for i in (0..n + 1).rev() {
        acc[i] = acc[i + 1] + a[i];
    }
    let mut cur: i64 = 0;
    let mut tot: i64 = 0;
    for i in 0..n + 1 {
        cur = if i == 0 { 1 } else { cur * 2 };
        cur = min(cur, acc[i]);
        tot += cur;
        cur -= a[i];
        if cur < 0 {
            puts!("-1\n");
            return;
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(){
    int k;
    cin >> k;
    queue<long long> que;
    if(k<=9){
        cout << k << endl;
        return 0;
    }
    for(int i=1;i<=9;i++){
        que.push(i);
    }
    long long tmp;
    for(int i=0;i<k;i++){
        tmp=que.front();
        if(tmp%10!=0) que.push(tmp*10+(tmp%10-1));
        que.push(tmp*10+(tmp%10));
        if(tmp%10!=9) que.push(tmp*10+(tmp%10+1));
        que.pop();
        //cout << tmp << endl;
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 5132
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 102;

int dp[N];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[0] = 1000;
	for (int i = 1; i <= n; i++) {
		//cur price = a[i - 1]
		dp[i] = dp[0];
		for (int j = 1; j < i; j++) {
			//prev price = a[j - 1]
			int v = (dp[j] % a[j - 1]) + (dp[j] / a[j - 1]) * a[i - 1];
			dp[i] = max(dp[i], v);
			dp[i] = max(dp[i], dp[j]);
		}
	}
	cout << dp[n] << '\n';
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,ans=1e18;
    cin>>n;
    ll b[n];
    for(int i=0;i<n;i++){
        cin>>a;
        if(i){
            b[i]=b[i-1]+a;
        }
        else{
            b[0]=a;
        }
    }
    for(int i=0;i<n-1;i++){
        ans=min(abs(b[n-1]-2*b[i]),ans);
    }
    cout << ans<<endl;
    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll pows(ll ten, ll n) {
	return ten * pow(ten, n - 1);
}

ll ans;

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

	ll tens = 10;
	ll i = 1;
	if (N % 2 != 0) {
		ans = 0;
	}
	else if (N % 2 == 0) {
		while (tens <= N) {
			//cout << "tens:" << tens << endl;
			ans += N / tens;
			if (tens == N) break;
			else tens *= 5;
		}
		

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

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for (int i = 0; i < L.size(); i++) {
        for (int j = i + 1; j < L.size(); j++) {
            for (int k = j + 1; k < L.size(); k++) {
                if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
using namespace std;

int main(){
	int x, r;
	char split;
	double cx = 0.0;
	double cy = 0.0;
	int cr = 0;
	while (cin >> x >> split >> r) {
		if (x == 0 && r == 0) break;
		cx += x * sin(cr * M_PI / 180.0);
		cy += x * cos(cr * M_PI / 180.0);
		cr += r;
	}
	cout << static_cast<int>(cx) << endl;
	cout << static_cast<int>(cy) << endl;

	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 1e2+34;
const int M = 1e3+34;
const int inf = 2e9;

int a[M], b[M], c[M];
int d[N][N];

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%d", a+i, b+i, c+i);
		--a[i]; --b[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) d[i][j] = 0;
			else d[i][j] = inf;
		}
	}
	for (int i = 0; i < m; ++i) {
		d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
		d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
	}
	for (int k = 0; k < n; ++k) {
		for (int j = 0; j < n; ++j) {
			for (int i = 0; i < n; ++i) {
				if (d[i][k] < inf && d[k][j] < inf) {
					d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
				}
			}
		}
	}
	int ans = m;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < n; ++j) {
			if (d[j][b[i]] == d[a[i]][j]+c[i]) {
				--ans; break;
			}
		}
	}
	printf("%d", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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


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

    int n;
    cin >> n;

    int count = 0;
    int c=0, multi, i;

    while (++c != n) {
        multi = n - c;
        for (i = 1; i * i < multi; i++)
            if (multi % i == 0)
                count += 2;
        if (i * i == multi)
            count += 1;
    }

    cout << count;
    return 0;
}

Measured memory_bytes: 3580
h,w,k = map(int,input().split())

s = [input() for i in range(h)]

#print(s)

ans = [[0 for i in range(w)]for j in range(h)]

now_h = 0
now_w = 0
num = 1

li = []

for i in range(h):
    now_w = 0
    for j in range(w):
        #print(i,j,now_w)
        if s[i][j] == '#':
            #print(now_h+1>=i,i,j)
            #if now_h+1 >= i:
                #print(now_h==i)
            for k in range(j-now_w+1):
                ans[i][now_w+k] = num
            """
            else:
                for k in range(now_w-j+1):
                    if s[i][k] == 1:
                        a = 1
            """
            now_h = i
            now_w = j+1
            num += 1


for i in range(h):
    for j in range(w):
        if ans[i][j] == 0:
            ans[i][j] = ans[i][j-1]


for i in range(h):
    for j in range(w):
        if ans[i][j] == 0:
            flag = False
            for k in range(h):
                if i+1+k >= h:
                    break
                if ans[i+1+k][j] != 0:
                    ans[i][j] = ans[i+1+k][j]
                    flag = True
                    break
            if flag == False:
                for k in range(h):
                    if i-1-k < 0:
                        break
                    if ans[i-1-k][j] != 0:
                        ans[i][j] = ans[i-1-k][j]
                        break

for i in range(h):
    print(*ans[i])

Measured memory_bytes: 7568
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N, Q;
    while(cin>>N>>Q&&N){
        vector<int> line(103, 0);
        REP(i, N){
            int a;
            cin >> a;
            REP(j, a){
                int b;
                cin>>b;
                ++line[b];
            }
        }
        int ans = 0;
        REP(i, line.size()){
            if(line[i] > line[ans] && line[i] >= Q)ans=i;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 2988
# ABC055D - Menagerie (ARC069D)
def check(a: str, b: str) -> str:
    ret, cur, prev = "", a, b
    for i in S:
        ret += cur
        if (cur == "S" and i == "o") or (cur == "W" and i == "x"):
            prev, cur = cur, prev  # both neighbors are the same
        elif (cur == "S" and i == "x") or (cur == "W" and i == "o"):
            x = "W" if prev == "S" else "S"  # both are different
            prev, cur = cur, x
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else ""


def main():
    global S
    N = int(input())
    S = input().rstrip()
    for a in ("S", "W"):
        for b in ("S", "W"):
            ans = check(a, b)
            if ans:
                print(ans)
                return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int pop(const VL &bs, int bit) {
  int ret = 0;
  FOR(b,bs) {
    if(b >> bit & 1) {
      ret++;
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  int k;
  cin >> n >> k;
  VL as(n);
  FOR(a,as) {
    cin >> a;
  }
  VL sum(n+1, 0);
  REP(i,0,n) {
    sum[i+1] = sum[i] + as[i];
  }
  VL bs;
  REP(i,0,n) {
    REP(j,i+1,n+1) {
      bs.push_back(sum[j] - sum[i]);
    }
  }
  int bit = 40;
  while(pop(bs, bit) < k) {
    bit--;
  }
  ll ans = 0;
  for(int i=bit; i >= 0; i--) {
    VL can;
    FOR(b,bs) {
      if(b >> i & 1) {
        can.push_back(b);
      }
    }
    if((int)can.size() >= k) {
      ans |= 1ll << i;
      bs = move(can);
    } else {
      continue;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6128
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (t<=x)
            System.out.println(x-t);
        else
            System.out.println("0");
    }
}


Measured memory_bytes: 35548
S = input()
T = input()
flag = False

for i in range(len(S)):
    if flag:
        break
    if S[i] == T[0]:
        tem = i+1
        f = 1
        if tem == len(S):
            tem = 0
        for t in range(1,len(T)):
            if T[t] == S[tem]:
                tem += 1
                if tem == len(S):
                    tem = 0
            else:
                break
            if t == len(T)-1:
                flag = True
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8888
#include<bits/stdc++.h>
using ll = long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/


/*....................................DEFINE GLOBAL VARIABLES .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	VI v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(ALL(v));

	int ans = 0;

	ans += v[2] - v[1];
	v[0] += (v[2] - v[1]);

	if ((v[2] - v[0]) % 2 == 0)ans += (v[2] - v[0]) / 2;
	else ans += 1 + (v[2] - v[0] + 1) / 2;
	cout << ans << endl;













	return 0;
}













Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

void swap1(vi &v) {
    int t=v[0];
    v[0]=v[4];
    v[4]=v[5];
    v[5]=v[1];
    v[1]=t;
}

void swap2(vi &v) {
    int t=v[0];
    v[0]=v[3];
    v[3]=v[5];
    v[5]=v[2];
    v[2]=t;
}

void swap3(vi &v) {
    int t=v[1];
    v[1]=v[3];
    v[3]=v[4];
    v[4]=v[2];
    v[2]=t;
}

int main() {
    
    vi v(6),w(6);
    rep(i,6)cin>>v[i];
    rep(i,6)cin>>w[i];
    bool ch=(v==w);
    int M=200;
    rep(i,M){
        swap1(v);
        rep(j,M){
            swap2(v);
            rep(k,M){
                swap3(v);
                // dump(v);
                ch |= (v==w);
            }
        }
    }
    Yn(ch);
}


Measured memory_bytes: 3116
//created by pyoxiao on 2020/04/26
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int a, b, c, d;
void solve() {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int flag = 0;
    while(1) {
        if(a <= 0) {
            puts("No");
            break;
        }
        if(c <= 0) {
            puts("Yes");
            break;
        }
        if(flag == 0) {
            c -= b;
        } else {
            a -= d;
        }
        flag ^= 1;
    }
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());

        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        int c = Integer.parseInt(tokenizer.nextToken());

        int target = c % b;

        for (int i = 1; i <= b; i++) {
            if (i*a % b == target) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, m, a, b, x[100], y[100];

int main(int argc, char **argv) {
	cin >> n >> m >> a >> b;
	REP(i, n) cin >> x[i];
	REP(i, m) cin >> y[i];
	ll ma = a, mi = b;
	REP(i, n) ma = max(ma, x[i]);
	REP(i, m) mi = min(mi, y[i]);
	cout << (ma < mi ? "No War": "War") << endl;
	return 0;
}


Measured memory_bytes: 3640