akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var q = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(S);

            var count = 0;
            foreach (var t in T)
            {
                var left = 0;
                var right = n - 1;
                while (right > left)
                {
                    var mid = (right + left) / 2;
                    if (S[mid] == t)
                    {
                        left = mid;
                        break;
                    }
                    else if (S[mid] > t) right = mid;
                    else left = mid + 1;
                }

                if (S[left] == t) count++;
            }

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 29352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc058.contest.atcoder.jp/tasks/arc058_b>
問題文============================================================
 縦 H マス、横 W マスのマス目があります。
 いろはちゃんは、今一番左上のマス目にいます。
 そして、右か下に1マス移動することを繰り返し、一番右下のマス目へと移動します。
 ただし、下から A 個以内、かつ左から B 個以内のマス目へは移動することは出来ません。
 
 移動する方法は何通りあるか求めてください。
 なお、答えは非常に大きくなることがあるので、答えは 10^9+7 で割ったあまりを出力してください。
=================================================================

解説=============================================================
移動経路の組み合わせ問題。
 
 先に通過しなければならない部分は絞られるので、
 通過しなければならないあるマスに関して
 
 始点からそのマスへの移動経路　＊　そのマスから終点までの移動経路
 を加算していけば良い
================================================================
*/

const ll MAX_N = 2e5 + 10;
const ll MOD = 1e9+7;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}

// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}
ll nCr(int n,int r) {
    if(n < r) return 0;
    return (fact[n] * (factInv[r] * factInv[n-r] % MOD)) % MOD;
}

void init(){
    Inv_init();
    fact_init();
}

ll calc(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1, dy = y2 - y1;
    return nCr(dx + dy, dx);
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    int H,W,A,B; cin >> H >> W >> A >> B;
    ll ans = 0;
    for(int i = 1; i <= H - A;i++){
        ans += (calc(1,1,i,B)*calc(i,B+1,H,W))%MOD; ans%=MOD;
    }
    cout << ans << endl;
	return 0;
}


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

int main()
{
    long int takahashi, aoki, repeat;
    long int rest_repeat;

    cin >> takahashi >> aoki >> repeat;

    /* After reading answer */
    if (repeat <= takahashi)
        cout << takahashi - repeat << " " << aoki << endl;
    else if (repeat <= takahashi + aoki)
        cout << 0 << " " << aoki - (repeat - takahashi) << endl;
    else
        cout << 0 << " " << 0 << endl;

    /* Second idea */
    // if (takahashi >= 1 && takahashi <= repeat)
    // {
    //     rest_repeat = repeat - takahashi;
    //     takahashi = 0;
    // }

    // if (aoki >= 1)
    // {
    //     if (aoki <= rest_repeat)
    //     {
    //         aoki = 0;
    //     }
    //     else
    //     {
    //         aoki -= rest_repeat;
    //     }
    // }

    /* First idea */
    // long int i;
    // for (i = 0; i < repeat; i++)
    // {
    //     if (takahashi >= 1)
    //         takahashi -= 1;
    //     else if (takahashi == 0)
    //         break;
    //     // else if (aoki >= 1)
    //     //     aoki -= 1;
    //     // else
    //     //     continue;
    // }

    // for (; i < repeat; i++)
    // {
    //     if (aoki >= 1)
    //         aoki -= 1;
    //     else if (aoki == 0)
    //         break;
    // }

    // cout << takahashi << " " << aoki << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll z=a+b;
	if(z%2==0)
		cout<<z/2<<"\n";
	else
	cout<<"IMPOSSIBLE\n";	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,x;
int main(){
	cin>>n>>x;int m=2*n-1;
	if(x==1 || x==2*n-1){cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	for(int i=0;i<m;i++){
		cout<<(i+x-n+m)%m+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>

// 入力受付用の変数
#define BUF 200002
char str[BUF];

// 入力された値
#define LIM_A 100001
int N;
int d[LIM_A];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);

	for (size_t i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
}

void solve() {
	int ans = 0;

	for (size_t i = 0; i < N; i++) {
		for (size_t j = i+1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}

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

int main(void) {
	receive_input();

	solve();

	return 0;
}


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

int main(){
	int H,W,i,j;
	cin >> H >> W ;
	while(H!=0||W!=0){
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(j==0||i==0||i==(H-1)||j==(W-1)){
			cout << '#';
			}else{
			cout << '.';
			}
		}
		cout << endl;
	}
		cout << endl;
		cin >> H >> W ;
	}
	return 0;
}

Measured memory_bytes: 3056
import java.util.*;

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

        int N = sc.nextInt();
        String S = sc.next();
        int l = S.length();
        char[] T = new char[l];
        String ans = "";
        String A = "A";

        for(int i=0; i<l; i++){
            T[i] = (char)((S.charAt(i) - A.charAt(0) + N) % 26 + A.charAt(0));
            ans = ans + T[i];
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 147028
#include <stdio.h>

int main(void)
{
    int n, x;
    int L[101];

    scanf("%d%d", &n, &x);

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

    int d=0, c=0;

    while (d<=x) {
        d += L[c++];
    }

    printf("%d\n", c);

    return 0;
}


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


long long N, W;
vector<vector<long long> > dp(101, vector<long long>(100001));
vector<long long> w(101);
vector<long long> v(101);

void knap(){
    
    dp.assign(101, vector<long long>(100001, 1e12));
    dp[0][0] = 0;

    for(long long i = 1; i <= N; i++){
        for(long long j = 0; j <= 100000; j++){
            if(v[i] <= j) dp[i][j] = min(dp[i-1][j], dp[i-1][j - v[i]] + w[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }
}

int main(){
    cin >> N >> W;
    for(long long i = 1; i <= N; i++) cin >> w[i] >> v[i];

    knap();

    for(long long value = 100000; value >= 0; value--){
        if(W >= dp[N][value]){
            printf("%lld\n", value);
            return 0;
        }
    }
}

Measured memory_bytes: 83364
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c,d=input()
    from itertools import product
    for i,j,k in product(['+','-'],repeat=3):
        s=a+i+b+j+c+k+d
        if(eval(s)==7):
            print(s+'=7')
            return
resolve()

Measured memory_bytes: 38384
// package whatever; // don't place package name!


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

class Main {
    
    public static void main(String[] args) throws Exception {
        int N = 0;
        int A = 0;
        int divNum = 500;

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        A = sc.nextInt();

        if ( N % divNum <= A){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }            
    }

}


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

int main(){
	int N;
	cin >> N;
	int a[N];
	bool done[N];
	for(int i=0;i<N;i++){
		cin >> a[i];
		done[i]=false;
	}
	
	int L=1;
	for(int i=0;i<N;i++){
		if(done[L-1]){
			cout << -1 << endl;
			return 0;
		}
		else{
			done[L-1]=true;
			L=a[L-1];
			if(L==2){
				cout << i+1 << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}

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

int N,l[100001],r[100001],a;

main(){
     cin>>N;
     for(int i=0;i<N;++i){
     cin>>l[i]>>r[i];
     a=a+r[i]-l[i]+1;
     }
     cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi (atan2(1.0, 1.0) * 4.0)
#define EPS 1e-9
using namespace std;

  double kakuritu(int x1, int y1, int x2, int y2, int H, int W, double h1, double h2){
    double X1, X2, Y1, Y2, h, w;
    X1=(double)x1;X2=(double)x2;Y1=(double)y1;Y2=(double)y2;h=(double)H;w=(double)W;
    if(x1 == 0 && x2 == 0){
      if(Y1 < h1 && h2 < Y2){
        return (h2-h1)/w;
      }
      else{
        return 0.0;
      }
    }
    else if(x1 == 0 || x2 == 0)return 0.0;
    else{
      double tmp = (h1+h2)/2;
      double tmp1 = tmp + (Y1-tmp) * w / X1;
      double tmp2 = tmp + (Y2-tmp) * w / X2;
      if(tmp1 > -EPS && tmp1 < h+EPS && tmp2 > -EPS && tmp2 < h+EPS ){
        double tmpo1 = (Y2/X2 - Y1/X1) * w;
        tmpo1 *= h2-h1;
        double tmpo2 = (1.0 / X2 - 1.0 / X1) * w * (h2*h2-h1*h1) / 2.0;
        //printf("timpo%f %f %f %f",tmpo1, tmpo2, x1, y1, h1, h2);
        return (tmpo1 - tmpo2) / (h*h);
      }
      else return 0.0;
    }
  }

int main(){
  while(1){
    int W,H,N;
    scanf("%d%d%d", &W, &H, &N);
    if(N==0)break;
    double w,h;
    w=(double)W;h=(double)H;
    int x[2*N + 2], y[2*N + 2];
    double X[2*N + 2], Y[2*N + 2];
    for(int i=0;i<2*N;i++)scanf("%d%d", &x[i], &y[i]);
    x[2*N] = W; y[2*N] = 0;
    x[2*N+1] = W; y[2*N+1] = H;
    for(int i=0;i<2*N+2;i++){X[i]=(double)x[i];Y[i]=(double)y[i];}
    vector<double> hasi;
    hasi.push_back(0.0);
    hasi.push_back(h);
    for(int i=0;i<2*N+2;i++)if(x[i]==0)hasi.push_back(Y[i]);
    for(int i=0;i<2*N+2;i++)for(int j=i+1;j<2*N+2;j++){
      if(x[i]!=x[j] && x[i] != 0 && x[j]!=0){
        double tmp = Y[i] - (Y[j]-Y[i]) * X[i] / (X[j]-X[i]);
        if(tmp > 0 && tmp < h)hasi.push_back(tmp);
      }
    }

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

    vector<pair<int,int> > soeji;

    for(int i=1;i<hasi.size();i++){
      double tmp = (hasi[i] + hasi[i-1])/ 2.0;
      vector<pair<pair<double, double>, int> > rad;
      for(int i=0;i<2*N+2;i++){
        if(x[i]!=0)rad.push_back(make_pair(make_pair(atan2(Y[i] - tmp, X[i]),Y[i] ), i));
        else if(Y[i] < tmp)rad.push_back(make_pair(make_pair(-pi / 2, Y[i]), i));
        else rad.push_back(make_pair(make_pair(pi/2, Y[i]), i));
      }
      sort(rad.begin(), rad.end());
      //for(int i=0;i<rad.size();i++)printf("%d %.10f ", rad[i].second, rad[i].first.first);
      soeji.push_back(make_pair(rad[N].second, rad[N+1].second));
      //printf("\n");
    }
    double ans = 0.0;
    for(int i=0;i<soeji.size();i++){
      double h1 = hasi[i];
      double h2 = hasi[i+1];
      ans += kakuritu(x[soeji[i].first], y[soeji[i].first], x[soeji[i].second], y[soeji[i].second], H, W, h1, h2);
    }
    printf("%.10f\n", ans);

  }
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)


P tree[1000000];
int value[1000000];
int ind = 1;

void Preorder(int i=0){
	if(i)cout << ' ' << value[i];
	if(~tree[i].first)Preorder(tree[i].first);
	if(~tree[i].second)Preorder(tree[i].second);
}
void Inorder(int i=0){
	if(~tree[i].first)Inorder(tree[i].first);
	if(i)cout << ' ' << value[i];
	if(~tree[i].second)Inorder(tree[i].second);
}
void Postorder(int i=0){
	if(~tree[i].first)Postorder(tree[i].first);
	if(~tree[i].second)Postorder(tree[i].second);
	if(i)cout << ' ' << value[i];
}
void in(int x){
	int v = 0;
	while(1){
		if(x<value[v]){
			if(~tree[v].first){
				v = tree[v].first;
			}else{// -1の時
				value[ind] = x;
				tree[v].first = ind;
				ind++;
				return;
			}
		}else{
			if(~tree[v].second){
				v = tree[v].second;
			}else{// -1の時
				value[ind] = x;
				tree[v].second = ind;
				ind++;
				return;
			}
		}
	}
}
bool find(int x){
	int v = 0;
	while(1){
		if(x<value[v]){
			if(~tree[v].first){
				v = tree[v].first;
			}else{// -1の時
				return false;
			}
		}else if(x>value[v]){
			if(~tree[v].second){
				v = tree[v].second;
			}else{// -1の時
				return false;
			}
		}else{
			return true;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	FOR(i,0,1000000)tree[i]={-1,-1};
	FOR(i,0,1000000)value[i]=-1;
	value[0] = 2000000002;

	int n;
	cin >> n;
	FOR(i,0,n){
		string s;
		cin >> s;
		if(s=="insert"){
			int key;
			cin>>key;
			in(key);
		}else if(s=="print"){
			Inorder();
			cout << '\n';
			Preorder();
			cout << '\n';
		}else if(s=="find"){
			int x;
			cin >> x;
			if(find(x)){
				cout << "yes" << "\n";
			}else{
				cout << "no" << "\n";
			}
		}
	}
}


Measured memory_bytes: 14936
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll N; cin>>N;
  vi A(N);
  string ans="second";
  rep(i,0,N){
    cin>>A[i];
    if(A[i]%2==1) ans="first";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n;
	string s;
	cin >> n >> s;

	int res = 1;
	rep(i, n-1) {
		if (s[i]!=s[i+1]) res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;
  int ans=0;
  for(int i=0; i<n; i++){
    if(a.at(i)==b.at(i) && b.at(i)==c.at(i))
      ans+=0;
    else if(a.at(i)==b.at(i) && b.at(i)!=c.at(i) ||
            b.at(i)==c.at(i) && c.at(i)!=a.at(i) ||
            c.at(i)==a.at(i) && a.at(i)!=b.at(i))
      ans+=1;
    else
      ans+=2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n =  int(sys.stdin.readline())
h =  list(map(int, sys.stdin.readline().split()))

tmp=0
c=0
if n==1:
    print(0)
else:
    for i in range(n-1):
        if h[i] >= h[i+1]:
            c+=1
        else:
            if tmp < c:
                tmp = c
            else:
                ans = tmp
            c=0
        ans = max(c,tmp)
    print(ans)

Measured memory_bytes: 16240
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: u64 = read();
    let n: usize = read();
    let ai: Vec<u64> = (0..n).map(|_| read()).collect();

    let atk: u64 = ai.iter().sum();

    if atk >= h {
        println!("Yes");
    } else {
        println!("No");
    }    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a, b;
	cin >> a >> b;
	int Cmp[999] = {};
	Cmp[0] = 1;
	for (int i = 0; i < 999; i++) {
		Cmp[i + 1] = Cmp[i] + i + 2;
	}
	int Ans;
	for (int i = 0; i < 999; i++) {
		if (Cmp[i + 1] - Cmp[i] == b - a) {
			Ans = Cmp[i] - a;
			break;
		}
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	vector<vector<int>> a(n,vector<int>(3));
	vector<vector<int>> dp(n+1,vector<int>(3));
	for(int i=0;i<n;++i){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	} 
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;++i){
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

Measured memory_bytes: 11264
let rec lower_bound l r p =
  if r <= 1 + l
  then r
  else let m = (l + r) / 2 in
       if p m
       then lower_bound l m p
       else lower_bound m r p

let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let as_ = Array.init (n + 1) @@ function
    | 0 -> 100000000
    | _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort (fun x y -> compare y x) as_;
  let acc = Array.make (n + 1) 0 in
  for i = 0 to n - 1 do
    acc.(i + 1) <- acc.(i) + as_.(i + 1)
  done;
  let border = lower_bound 0 1000000 @@ fun b ->
    ( > ) (m + n) @@ Array.fold_right (fun a -> ( + ) @@
    upper_bound 0 (n + 1) @@ fun i -> b < a + as_.(i)) as_ 0 in
  let x, sum =
    Array.fold_left (fun (x, sum) (x', sum') -> x + x', sum + sum') (0, 0) @@
    Array.init n @@ fun i ->
      let x = upper_bound 0 (n + 1) @@ fun j -> border < as_.(i + 1) + as_.(j) in
      x, acc.(x) + x * as_.(i + 1) in
  Printf.printf "%d\n" @@ sum + (m - x) * border


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n, d;
int x, y;
int ans;

int main(){
	scanf("%d%d", &n, &d);
	while(n--){
		scanf("%d%d", &x, &y);
		if(1ll * x * x + 1ll * y * y <= 1ll * d * d) ans++;
	}
	printf("%d", ans);
}

Measured memory_bytes: 3808
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int main() {
  int N;
  ll T;
  cin >> N >> T;
  vector<ll> t(N);
  rep(i,N) cin >> t[i];
  ll ans = 0;
  ll cur = 0;
  rep(i,N) {
    cur = max(cur,t[i]);
    ll nex = t[i] + T;
    if( nex > cur ) {
      ans += ( nex - cur );
    }
    cur = nex;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
indata1 = input().split()
indata1 = list(map(int,indata1))
indata2 = input().split()
indata2 = list(map(int,indata2))

arrD = [0]
arrL = indata2.copy()

for i in range(1,indata1[0]+1):
    arrD.append(arrD[i-1]+arrL[i-1])

cnt = 0
for d in arrD:
    if d <= indata1[1]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
# coding: utf-8

def main():
    a, b, c = map(int, input().split())
    ans = 0

    if a == b and b == c and a % 2 == 0:
        ans = -1
    else:
        while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            d = b / 2 + c / 2
            e = c / 2 + a / 2
            f = a / 2 + b / 2
            a, b, c = d, e, f
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int maxm=100007;
int n,m;
int tot;//连通块个数 
int w[maxm],f[maxm];
int cnt[maxm];
vector<int> t,q[maxm];
ll ans=0;
int find(int x)
{
 if(x!=f[x])
 f[x]=find(f[x]);
 return f[x];	
}
int main()
{
 scanf("%d%d",&n,&m);
 for(int i=1;i<=n;i++)
 scanf("%d",&w[i]),f[i]=i;
 for(int i=1;i<=m;i++)
 {
  int x,y;
  scanf("%d%d",&x,&y);
  x++;//编号初始为0，++变1 
  y++;
  int fx=find(x);
  int fy=find(y);
  if(fx!=fy) f[fx]=fy;
 }
 for(int i=1;i<=n;i++)
 {
   int fx=find(i);
   if(!cnt[fx]) cnt[fx]=++tot;
   q[cnt[fx]].push_back(w[i]);
 }
 if(tot==1)
 {
  printf("0\n");
  return 0; 
 } 
 for(int i=1;i<=tot;i++)
 {
  sort(q[i].begin(),q[i].end());
  ans+=q[i][0];
  for(int j=1;j<q[i].size();j++)
  {
  	t.push_back(q[i][j]);
  }
 }
 if(t.size()<tot-2)
 {
  printf("Impossible\n");
  return 0;	
 }
 sort(t.begin(),t.end());
 for(int i=0;i<tot-2;i++)
 ans+=t[i];
 printf("%lld\n",ans);
 return 0;	
}


Measured memory_bytes: 6912
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
const LL lim = 1e10;

int n, m, p, q, ans;
bool flag, is_prime[N];
LL a[N], prime[N], prime2[N], prime3[N];
set<LL> ST;
map<LL, LL> MP, G;

void init(){
	LL s;
    for(LL i=1; ;i++){
		s = i * i * i;
		if(s > lim)	break;
		ST.insert(s);
    }
    for(LL i=1; ;i++){
		s = i * i;
		if(s > lim)	break;
		MP[s] = i;
    }

    memset(is_prime, 1, sizeof(is_prime));
    p = q = 0;

    for(int i=2; i<N; i++){
		if(is_prime[i]){
			prime[p] = i;
			prime2[p] = prime[p] * prime[p];
			s = prime2[p] * prime[p];
			p++;
			if(s <= lim){
				prime3[q++] = s;
			}
			for(int j=i<<1; j<N; j+=i){
				is_prime[j] = 0;
			}
		}
    }
}

void trans(LL x){
	if(ST.count(x)){
		flag = 1;
		return;
	}

    for(int i=0; i<q && prime3[i]<=x; i++){
        while(x % prime3[i] == 0){
			x /= prime3[i];
        }
    }

    LL y = 1, z = x;

    for(int i=0; prime[i]<4000 && prime2[i]<=x; i++){
		if(x % prime[i] == 0){
			if(x % prime2[i] == 0){
				y *= prime[i];
				x /= prime2[i];
			} else {
				x /= prime[i];
				y *= prime2[i];
			}
		}
    }

    if(x > 1){
		if(MP.count(x)){
			y *= MP[x];
			a[m++] = z;
			G[z] = y;
		} else if(x <= 100000){
			y = y * x * x;
			a[m++] = z;
			G[z] = y;
		} else {
			ans++;
		}
    } else {
    	a[m++] = z;
    	G[z] = y;
    }
}

int Cnt(LL x){
	int j = lower_bound(a, a+m, x) - a;
	int k = upper_bound(a, a+m, x) - a;
	return k - j;
}

int main(){
	init();
	LL x, y;
	int c, d;
    while(~scanf("%d", &n)){
		ans = m = 0;
		flag = 0;
		G.clear();
		for(int i=0; i<n; i++){
			scanf("%lld", &x);
			trans(x);
		}

		ans += flag;

		if(m){
			sort(a, a+m);

			y = G[a[0]];
			c = Cnt(a[0]);
			d = Cnt(y);
			ans += max(c, d);
			for(int i=1; i<m; i++){
				if(a[i]==a[i-1])	continue;
				y = G[a[i]];
				d = Cnt(y);
				if(y<a[i] && d)	continue;
                c = Cnt(a[i]);
                ans += max(c, d);
			}
		}

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


Measured memory_bytes: 12800
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N; cin.ignore();

  vector<int> a_vec;

  for (int i=0; i<N; i++){
    int j, k;
    cin >> j >> k;
    int count = k-j+1;
    a_vec.push_back(count);
  }

  int ans = accumulate(a_vec.begin(), a_vec.end(), 0);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!{
        element_count: u32,
        axis: [f64; element_count],
    }
    println!("{}", solve(element_count as f64, axis));
}

fn solve(element_count: f64, axis: Vec<f64>) -> f64{
    let p = (axis.iter().sum::<f64>() / element_count).round();
    let mut result = 0.0;
    for &element in axis.iter() {
        result += (p - element as f64).powi(2) as f64
    }
    result
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000009LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

vector < pair<i64,i64> > vp ;

i64 fromLeft[maxn] , fromRight[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld %lld",&n,&m) ;

    vp.pb(mp(0LL,0LL)) ;

    for(i=1 ; i<=n ; i++)
    {
        scanf("%lld %lld",&k,&l) ;
        vp.pb(mp(k,l)) ;
    }

    i64 ret = vp[n].yy - ( m-vp[n].xx ) ;
    fromRight[n] = ret ;
    i64 ans = ret ;
    for(i=n-1 ; i>=1 ; i--)
    {
        ret += (  vp[i].yy - (vp[i+1].xx - vp[i].xx) ) ;
        fromRight[i] = max( fromRight[i+1],ret ) ;
        ans = max( ans,ret ) ;
    }

    ret = 0LL ;
    fromLeft[0] = -INF ;
    for(i=1 ; i<=n ; i++)
    {
        ret += vp[i].yy - ( vp[i].xx-vp[i-1].xx ) ;
        fromLeft[i] = max(fromLeft[i-1],ret) ;
        ans = max(ans,ret) ;
        if( i<n ){
            ans = max( ret - vp[i].xx + fromRight[i+1] , ans ) ;
        }
    }

    for(i=n ; i>1  ; i--)
    {
        ans = max( ans , fromRight[i]+fromLeft[i-1]-(m-vp[i].xx) ) ;
    }

    printf("%lld\n",max(ans,0LL) ) ;

    return 0 ;
}


Measured memory_bytes: 3440
from heapq import heapify,heappush,heappop
n = int(input())
a = [int(i) for i in input().split()]

p = 0
ans = 0
cc = 0
cs = 0
chk = []
heapify(chk)
for i,ai in enumerate(a):
  heappush(chk,(i,ai))
  cc = cc^ai
  cs += ai
  ans += 1
  if cc != cs :
    p += (ans-1)*(ans)//2
    while chk:
      j,aj = heappop(chk)
      ans -= 1
      cc = cc^aj
      cs -= aj
      if cc == cs:
        p -= (ans-1)*(ans)//2
        cnt = 0
        break
p += ans*(ans+1)//2
print(p)

Measured memory_bytes: 26556
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

struct Edge {
  ll to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(ll to, ll cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge
AdjList revgraph;
const ll INF = 1e18;

vector<ll> dist; // 最短距離
vector<int> cycle;

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(ll n, ll s) { // nは頂点数、sは開始頂点
  bool f = false;
  dist = vector<ll>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  REP(i,n) REP(v,n) REP(k,graph[v].size()){
    Edge e = graph[v][k];
    if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
      dist[e.to] = dist[v] + e.cost;
      if (i == n - 1){
        f =  true; // n回目にも更新があるなら負の閉路が存在
        cycle[v] = 1;
      }
    }
  }
  return f;
}

void dfs(ll node, AdjList& g, vector<int>& reach){
  if(reach[node]) return;
  reach[node] = 1;
  FOREACH(e,g[node]){
    dfs(e.to, g, reach);
  }
}

int main(){
  ll n,m,p; cin >> n >> m >> p;
  graph = AdjList(n);
  revgraph = AdjList(n);
  cycle = vector<int>(n);
  vector<int> reach_s(n,0),reach_t(n,0);
  REP(i,m){
    ll a,b,c; cin >> a >> b >> c;
    a--; b--;
    revgraph[b].push_back(Edge(a,1));
    c -= p;
    c *= -1;
    graph[a].push_back(Edge(b,c));
  }
  bool f = bellman_ford(n, 0);
  //負閉路あり
  if(f) {
    dfs(0, graph,reach_s);
    dfs(n-1, revgraph, reach_t);
    //負閉路を経由して頂点n-1へ行けるとき
    REP(i,n) if(reach_s[i] & cycle[i] & reach_t[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << max(-dist[n-1],0LL) << endl;
}



Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
int GCD(int a, int b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
 
    int main(){
      ll n,k;
      cin >> n >> k;
      ll ans=0;
      for(int b=k+1;b<=n;b++){
        int c=n%b;
        if(c>=k){
         ans+=(b-k)*(n-c)/b+c-k+1;
          if(k==0)ans--;
        }else{
         ans+=(b-k)*(n-c)/b;
        }
      }
      cout << ans << endl;
      return 0;}

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

using namespace std;

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

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

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int v, e;
	cin >> v >> e;

	vector<int> inDegree(v);
	vector<vector<int>> g(v);

	for (int i = 0; i < e; i++) {
		int s, t;
		cin >> s >> t;

		g[s].emplace_back(t);
		inDegree[t]++;
	}

	queue<int> que;
	for (int i = 0; i < inDegree.size(); i++) {
		if (inDegree[i] == 0) {
			que.emplace(i);
		}
	}

	vector<int> ans;
	while (!que.empty()) {
		int now = que.front(); que.pop();
		ans.emplace_back(now);

		for (auto i : g[now]) {
			inDegree[i]--;
			if (inDegree[i] == 0) {
				que.emplace(i);
			}
		}
	}

	for (auto v : ans) {
		cout << v << endl;
	}
	return 0;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int c = 0;
  vector<int> p(n);
  for ( int i = 0; i < n; i++)
    cin >> p.at(i);
  for ( int i = 0; i < n-2; i++) {
    int n1 = p.at(i);
    int n2 = p.at(i+1);
    int n3 = p.at(i+2);
    vector<int> s{n1, n2, n3};
    sort(s.begin(), s.end());
    if ( s.at(1) == n2 )
      c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))

ans = []
while b:
    
    next = -1
    for i, n in enumerate(b):
        if i + 1 == n:
            next = i
    if next == -1:
        ans = []
        break
    else:
        ans.append(b.pop(next))

if ans:
    ans = ans[::-1]
    for s in ans:
        print(s)
else:
    print(-1)

Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Crane and Turtle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  // a+b=x, 2a+4b=y
  // -> a+b=x,a+2b=y/2 -> b=y/2-x, a=2x-y/2

  if (! (y & 1)) {
    int a = 2 * x - y / 2, b = y / 2 - x;
    if (a >= 0 && b >= 0) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;
int gcd(int a, int b) {
	int c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	cout << (A * B) / gcd(A, B) << endl;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll k,s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k>>s;
    ll ans=0;
    for (int i = 0; i <= k; i++)
    {
        for(int j=0;j<=k;j++){
            if(i+j+k>=s&&i+j<=s){
                ans++;
            }
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 764
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);
const ll INF = 1e18;



void solve() {
	int A, B; cin >> A >> B;
	B *= 2;
	int ans = max((ll)0, A - B);
	print(ans);
}


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

	solve();
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct S
{
	int x;
	S() {}
	S(int x) : x(x) {}
	static S I() {
		return S(0);
	}
	void merge(S& a, S& b) {
		x = a.x + b.x;
	}
};

struct SegmentTree
{
	const int n;
	std::vector<S> data;
	SegmentTree(int n) : n(n), data(2*n) {
		for(int i=0;i<n;i++) {
			data[n+i] = S::I();
		}
		for(int i=n-1;i>0;i--) {
			data[i].merge(data[i<<1], data[i<<1|1]);
		}
	}
	void set(int i, S v) {
		data[n+i] = v;
		i+=n;
		while(i>0) {
			i>>=1;
			data[i].merge(data[i<<1], data[i<<1|1]);
		}
	}
	S get(int l, int r) {
		// 0-Indexed, [l, r)
		l+=n; r+=n;
		S sum = S::I();
		while(l<r) {
			if(l&1) sum.merge(sum,data[l++]);
			if(r&1) sum.merge(sum,data[--r]);
			l>>=1; r>>=1;
		}
		return sum;
	}
};


signed main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	int q;
	std::cin >> q;
	std::vector<SegmentTree> seg(26,SegmentTree(n));
	rep(i,n) {
		seg[s[i]-'a'].set(i,S(1));
	}
	rep(qq,q) {
		int qt;
		std::cin >> qt;
		if(qt==1) {
			int i; char c;
			std::cin >> i >> c;
			i--;
			if(s[i]==c) continue;
			seg[s[i]-'a'].set(i,S(0));
			s[i]=c;
			seg[s[i]-'a'].set(i,S(1));
		} else {
			int l,r;
			std::cin >> l >> r;
			l--;r--;
			int count = 0;
			rep(i,26) if(seg[i].get(l,r+1).x) count++;
			print(count);
		}
	}
	return 0;
}


Measured memory_bytes: 211844
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;

void main()
{
	int[] t = map!(to!int)(split(readln())).array;
	int[] checker = [0,0];
	
	for(int i=0;i < 3;i ++)
	{
		if(t[i] == 5)
		{
			checker[0] ++;
		}
		else
		{
			checker[1] ++;
		}
	}
	if(checker[0] == 2 && checker[1] == 1)
	{
		writeln("YES");
	}
	else
	{
		writeln("NO");
	}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

int main()
{
	ull a,b,k;
	cin >> a>>b>>k;

	BREP(i,101)
	{
		if( i == 0 ) continue;
		if( a % i == 0 && b % i == 0 )
			if( --k == 0 )
			{
				cout << i << endl;
				break;
			}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n,k,ans=INF;
	cin >> n >> k;
	vector<ll> a(n);
	FOR(i,0,n)cin >> a[i];
	FOR(i,0, (1<<(n-1)) ){
		ll b = a[0];
		ll p = 0;
		ll cnt = 0;
		FOR(j,0,n-1){
			if(i&(1<<j)){
				cnt++;
				if(b<a[j+1]){
					b = a[j+1];
				}else{
					p += b+1-a[j+1];
					b++;
				}
			}else{
				if(b<a[j+1])b=a[j+1];
			}
		}
		if(cnt>=(k-1))ans=min(ans,p);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

// combination mod prime（mintが必要）
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// nCkを求めて結果をansに格納したい場合、
// combination c(n);
// mint ans = c(n, k);
// cout << ans.x << endl;
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
	int n, k;
	cin >> n >> k;
	combination c(2*n);
	mint ans = 0;
	rep(i, min(k+1, n)){ // i : 0の個数
		mint tmp = c(n, i);
		tmp *= c(n-1, i);
		ans += tmp;
	}
	
	cout << ans.x << endl;
	return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n,m;
    cin>>n>>m;
    int s[m],c[m];
    for(int i=0;i<m;i++)cin>>s[i]>>c[i];
    int x,y;
    if(n==1){
        x=0;
        y=9;
    }
    else if(n==2)
    {
        x=10;
        y=99;
    }
    else
    {
        x=100;
        y=999;
    }
    for(int i=0;i<=1000;i++)
    {
        int p=i;
        vector<int>v;
        v.clear();
        while(p)
        {
            v.pb(p%10);
            p=p/10;
        }
        reverse(all(v));
        if(v.size()==0)v.pb(0);
        if(v.size()!=n)continue;
        int f=0;
        for(int j=0;j<m;j++)
        {
            if(v[s[j]-1]!=c[j])f=1;
        }
        if(f==0)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;

}


Measured memory_bytes: 3600
#include <stdio.h>
#include <stdbool.h>
#define LENGTH 256
#define NUM 5

int main(void) {
    char input[LENGTH];
    int n;
    fgets(input, LENGTH-1, stdin);
    sscanf(input, "%d", &n);
    
    bool j = false;
    int result[3];
    result[0] = n / 100;
    n = n % 100;
    result[1] = n / 10;
    n = n % 10;
    result[2] = n;

    for(int i = 0;i<3;i++){
        if(result[i] == 7) {
            j = true;
        }
    }

    if (j) {
        printf("Yes");
    }else{
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 1688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm> // sort

using namespace std;

void Main()
{
    int N;
    cin >> N;
    vector<int> L(N, 0);
    for (int i = 0; i < N; i++) {
        int Li;
        cin >> Li;
        L[i] = Li;
    }

    int result = 0;

    sort(L.begin(), L.end(), greater<int>());

    for (int i = 0; i < N - 2; i++) {
        for (int k = i + 1; k < N - 1; k++) {
            for (int l = k + 1; l < N; l++) {
                if (
                        (L[i] < L[k] + L[l]) &&
                        (L[k] < L[l] + L[i]) &&
                        (L[l] < L[i] + L[k])
                   ) {
                    result++;
                } else {
                    break;
                }
            }
        }
    }

    cout << result;

}

int main()
{
    Main();
    return 0;
}


/*
	std::sort(data.begin(),data.end(),std::greater<int>());//降順ソート

 */


Measured memory_bytes: 256
# 問題文
# 高橋君は 500円玉を K 枚持っています。 
# これらの総額が X 円以上である場合は Yes を、そうでない場合は No を出力してください。

def main():
	K, X = map(int, input().split())
	
	if 500 * K >= X:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__' :
	main()

Measured memory_bytes: 2940
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			PriorityQueue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());
			for (int i = 0; i < N; i++) q.add(sc.nextInt());
			for (int i = 0; i < M; i++) q.add(q.poll() / 2);
			long sum = 0;
			for (int i = 0; i < N && !q.isEmpty(); i++) sum += q.poll();
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 55068
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const int intinf = 1 << 30;
const long long mod = 1e9 + 7;

vector<int> A;
vector<int> M;
vector<vector<int>> memo(30, vector<int>(2010, -1));
int n, q;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
};

bool dfs(int num, int sum) {
    if(sum < 0)
        return false;
    if(sum == 0)
        return true;
    if(num >= n)
        return false;
    if(memo.at(num).at(sum) != -1) {
        return memo[num][sum];
    }
    memo[num][sum] = dfs(num + 1, sum) || dfs(num + 1, sum - A[num]);
    return memo[num][sum];
}

int main() {
    cin >> n;
    A.resize(n);
    rep(i, n) cin >> A[i];
    cin >> q;
    M.resize(q);
    rep(i, q) cin >> M[i];
    rep(i, q) cout << (dfs(0, M[i]) ? "yes" : "no") << endl;
}



Measured memory_bytes: 3252