akhauriyash/Code-Regression huggingface dataset:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,M,V,P = LI()
    A = LI()
    A.sort()

    ans = 0
    ac = list(itertools.accumulate(A))
    for i in range(N):
        if i >= N-P:
            ans += 1
            continue
        if M+A[i] < A[N-P]: continue
        if V <= P:
            ans += 1
            continue

        w = ((N-P-i) * (M+A[i])) - (ac[N-P] - ac[i])
        if w >= M * (V-P-i):
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 65256
N = int(input())

for h in range(1, 3501):
    a = 4 * h - N
    if a <= 0:
        continue
    b = N * h
    for n in range(max(h, b // a + 1), 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

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

int main()
{
    string S;
    cin >> S;

    long long int res = 0;
    for (int i = 0; i < (1 << S.size() - 1); ++i) {
        int s = 0;
        for (int j = 0; j < S.size() - 1; ++j) {
            if (i & (1 << j)) {
                res += stoll(S.substr(s, j - s + 1));
                s = j + 1;
            }
        }
        res += stoll(S.substr(s, S.size() - s));
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,m,i,a=0,b=0;
    scanf("%d%d",&n,&m);
    for(i=2;i<=n;i++)
        a+=i-1;
    for(i=2;i<=m;i++)
        b+=i-1;
    printf("%d\n",a+b);
    return 0;
}

Measured memory_bytes: 1692
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
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 };
/*
(char)'1' - (int)48 = (int)1; 


*/


int main()
{
	int a[1100]; a[0] = 0;
	for (int i = 1; i < 1001; i++)
	{
		a[i] = a[i - 1] + i;
	}
	for (int n=-1; n != 0; cin >> n)
	{
		if (n == -1)continue;
		int ans = 0;
		for (int i = n; i >= 0; i--)
		{
			for (int k = i - 1; k >= 0; k--)
			{
				if (a[i] - a[k] == n)ans++;
			}


		}
		cout << ans-1 << endl;


	}
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int i, j, k;
        double a, b, c, S, L, h;
         
        a = sc.nextDouble();
        b = sc.nextDouble();
        c = sc.nextDouble();
         
        S = a * b * Math.sin(Math.toRadians(c)) / 2;
        L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(c)));
        h = 2 * S / a;
         
        System.out.printf("%f\n%f\n%f", S, L, h);
    }
}


Measured memory_bytes: 28140
import sys
from heapq import heappush,heappop

inf = float('inf')

n, m = map(int, sys.stdin.readline().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    u, v = map(int, sys.stdin.readline().split())
    g[u].append(v)

s, t = map(int, sys.stdin.readline().split())

def main():
    dist = [inf] * (n + 1)
    can_reach = [[False] * 3 for _ in range(n + 1)]
    hq = [(0, s)]
    can_reach[s][0] = True
    while hq:
        d, x = heappop(hq)
        if d % 3 == 0:
            dist[x] = min(dist[x], d // 3)
        d += 1
        for y in g[x]:
            if not can_reach[y][d%3]:
                can_reach[y][d%3] = True
                heappush(hq, (d, y))

    return dist[t] if dist[t] != inf else -1

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 32280
import java.util.Scanner;

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

		String s = sc.next();
		int a_index = s.indexOf('A');
		int z_index = s.lastIndexOf('Z');

		System.out.println(z_index - a_index + 1);
	}
}

Measured memory_bytes: 27536
#include <iostream>
#include <cmath>
#include <cassert>

using namespace std;

class mybitset {
  unsigned int *mem;
  int size;
  bool ismemfree;
public:
  mybitset(){
    ismemfree = true;
  }
  void setsize(int size){
    this->size = size;
    mem = new unsigned int[size / sizeof(unsigned int) + 1];
    ismemfree = false;
  }
  ~mybitset(){
    if (!ismemfree){
      delete [] mem;
    }
  }
  bool get(int pos){
    char bit = 1 << (pos % sizeof(unsigned int));
    return (mem[pos / sizeof(unsigned int)] & bit) != 0;
  };
  void set(int pos){
    char bit = 1 << (pos % sizeof(unsigned int));
    mem[pos / sizeof(unsigned int)] |= bit;
  };
  void reset(int pos){
    char bit = ~(1 << (pos % sizeof(unsigned int)));
    mem[pos / sizeof(unsigned int)] &= bit;
  }
};

class primer {
  mybitset isprime;
  int max;
public:
  bool getPrime(int number);
  primer(int max);
};

bool primer::getPrime(int number){
  assert(max * max > number);
  if (max > number){
    return isprime.get(number);
  }
  for(int i = 0; i < max ; i++){
    if (isprime.get(i)){
      if (number % i == 0){
        return false;
      }
    }
  }
  return true;
}
primer::primer(int max){
  this->max = max;
  isprime.setsize(max + 1);
  //??¨??????????????????????????§?´???°?????????????????????
  isprime.reset(0);
  isprime.reset(1);
  for(int i = 2; i < max; i++){
    isprime.set(i);
  }
  for(int i = 2; i < sqrt(max); i++){
    if(isprime.get(i)){
      for(int j = 2; i * j < max; j++){
        isprime.reset(i * j);
      }
    }
  }
}

int main(int argc, char const *argv[]) {
  int count;
  cin >> count;
  int prime_count = 0;
  primer p = primer(11000);
  for (int i = 0; i < count; i++) {
    int number;
    cin >> number;
    if (p.getPrime(number)){
      prime_count++;
    }
  }
  cout << prime_count << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

class Point{
    public: 
    long double x,y;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    Point operator + (const Point &p) const { return Point(x+p.x, y+p.y); }
    Point operator - (const Point &p) const { return Point(x-p.x, y-p.y); }
    Point operator * (const long double &a) const { return Point(x*a, y*a); }
    Point operator / (const long double &a) const { return Point(x/a, y/a); }
    bool operator < (const Point &p) const { return (x != p.x ? x < p.x : y < p.y); }
    bool operator == (const Point &p) const { return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS; }
    long double abs() const { return sqrt(norm()); }
    long double norm() const { return x*x + y*y; }
    long double dot(Point &p) const { return x*p.x + y*p.y; }
    long double cross(Point &p) const { return x*p.y - y*p.x; }   
};

typedef Point Vector;

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

    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double hm = h * 60.0 + m;
    long double theta_a = 2 * M_PI / 720.0, theta_b = 2 * M_PI / 60.0;
    if(hm < 180.0) {
        theta_a *= 180.0 - hm;
    } else if(hm >= 540.0) {
        theta_a *= 720.0 - hm + 180.0;
    } else {
        theta_a *= 540.0 - hm + 360.0;
    }
    if(m < 15.0) {
        theta_b *= 15.0 - m;
    } else if(m >= 45.0) {
        theta_b *= 60.0 - m + 15.0;
    } else {
        theta_b *= 45.0 - m + 30.0;
    }

    long double xa = a * cos(theta_a), ya = a * sin(theta_a);
    long double xb = b * cos(theta_b), yb = b * sin(theta_b);
    // cerr << xa << ", " << ya << " " << xb << ", " << yb << endl;
    Point p1 = Point(xa, ya);
    Point p2 = Point(xb, yb);
    cout << setprecision(10) << fixed << (p1-p2).abs() << endl;
}


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

int n, m;
vector<vector<int>> g;
vector<int> dp;

int dfs(int u, int p = -1) {
    if (dp[u] != -1) return dp[u];
    int len = 0;
    for (int i = 0; i < (int)g[u].size(); i++) {
        int to = g[u][i];
        if (to != p) {
            len = max(len, 1 + dfs(to, u));
        }
    }

    return dp[u]=len;
}

void solve() {
    cin >> n >> m;
    g.resize(n+1);
    dp.resize(n+1, -1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
    }

    int ans = -1;
    for (int i = 1; i <= n; i++) {
        int x = dfs(i);
        ans = max(ans, x);
    }

    cout << ans << endl;
}

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

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

    return 0;
}


Measured memory_bytes: 11760
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A;
    int step = 1;
    cin >> A;
    set<int> S;
    S.insert(A);
    while (1) {
        A = (A % 2 == 0) ? A / 2 : A * 3 + 1;
        step++;
        if (S.count(A) > 0) {
            cout << step << endl;
            return 0;
        } else S.insert(A);
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
	int A, B;
	int p, d, m;

	scanf("%d%d", &A, &B);

	p = A + B;
	d = A - B;
	m = A * B;

	if (p >= d&& p >= m)
		printf("%d", p);
	else if (d >= p&& d >= m)
		printf("%d", d);
	else
		printf("%d", m);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");

int a,b,n;

int ff(int x){
    return (a*x)/b - a*(x/b);
}

int f(int l,int r){
    if(l>r)return 0;
    if(l/b==r/b){
        return ff(r);
    }
    int mid=(l+r)/2;
    return max(f(l,mid),f(mid+1,r));
}

signed main(){
    FASTER;
    cin>>a>>b>>n;
    n=min(b-1,n);
    cout<<f(0,n);
}


Measured memory_bytes: 3648
import std.stdio, std.range, std.algorithm, std.conv, std.string, std.math, std.typecons;

void main() {
  auto N = readln.chomp.to!int;
  foreach (i; 0..N) {
    auto a = readln.split.to!(int[]).map!(a => a * a).array;
    writeln((a[0] + a[1] == a[2]
        || a[1] + a[2] == a[0]
        || a[2] + a[0] == a[1]) ? "YES" : "NO");
  }
}

Measured memory_bytes: 2464
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::min_element;
using std::max_element;
using std::sort;
using std::abs;

int main(void) {
    int n;
    cin >> n;

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

    int l = *min_element(a.begin(), a.end());
    int r = *max_element(a.begin(), a.end());

    cout << r - l << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

struct node {
	ll distance[3];
	bool seen[3];
	vector<pil> conected;
};

void dikstra(node* nodes, int startAt) {
	priority_queue<pli, vector<pli>, greater<pli>> que;
	que.push(pli(0, startAt));

	while (!que.empty()) {
		pli t = que.top();
		que.pop();
		if (t.first > nodes[t.second].distance[t.first % 3]) continue;

		rep(i, nodes[t.second].conected.size()) {
			ll minDis = INF;

			rep(j, 3) {
				if (!nodes[t.second].seen[j]) {
					if (nodes[nodes[t.second].conected[i].first].distance[(j + 1) % 3] > nodes[t.second].distance[j] + 1) {
						nodes[nodes[t.second].conected[i].first].distance[(j + 1) % 3] = nodes[t.second].distance[j] + 1;

						minDis = min(minDis, nodes[nodes[t.second].conected[i].first].distance[(j + 1) % 3]);
					}
				}
			}

			if (minDis != INF) {
				que.push(pli(minDis, nodes[t.second].conected[i].first));
			}
		}

		nodes[t.second].seen[t.first % 3] = true;
	}
}

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

	int n, m;
	cin >> n >> m;
	pii* uv = new pii[m];
	rep(i, m) cin >> uv[i].first >> uv[i].second;

	node* nodes = new node[n];
	rep(i, n) {
		rep(j, 3) {
			nodes[i].distance[j] = INF;
			nodes[i].seen[j] = false;
		}
	}

	rep(i, m) {
		nodes[uv[i].first - 1].conected.push_back(pil(uv[i].second - 1, 1));
	}

	int s, t;
	cin >> s >> t;
	nodes[s - 1].distance[0] = 0;
	dikstra(nodes, s - 1);

	if (nodes[t - 1].distance[0] != INF) {
		cout << nodes[t - 1].distance[0] / 3 << "\n";
	}
	else {
		cout << "-1" << "\n";
	}

	return 0;
}


Measured memory_bytes: 12972
n,m = map(int,input().split())
sc = [list(map(int,input().split()))for _ in range(m)]
for i in range(1000):
    ok = True
    x = str(i)
    if len(x) !=n:continue
    for s,c in sc:
        if int(x[s-1]) !=c:
            ok = False
    if ok:
        print(i)
        exit(0)
print(-1)
    
        

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

int main() {
  int64_t n;
  cin >> n;
  string s;
  while (n > 0) {
    s += char('a' + ((n - 1) % 26));
    n = (n - 1) / 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

int l, r, d;
void test() {
    cin >> l >> r >> d;
    if (l%d) l+=d-l%d;
    if (r%d) r-=r%d;
    cout << (r-l)/d+1 << endl;
}

int main() {
    IOS;

    // int t; cin>>t;
    // while (t--) {
    //     test();
    // }

    // int t; cin>>t;
    // for (int i=1; i<=t; ++i) {
    //     cout<<"Case #"<<i<<": ";
    //     test();
    // }

    test();
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <queue>
#include <utility>
#include <string>

#define MAX 1000
#define P pair<int,int>
#define PI pair<int,P>
#define mp make_pair
using namespace std;
vector<PI> G[MAX][MAX];
int dist[MAX][MAX];
bool used[MAX][MAX];
priority_queue<PI,vector<PI>,greater<PI>> que;

void dijkstra(P s){
	que.push({0,s});
	while(!que.empty()){
		PI p = que.top(); que.pop();
		int d = p.first,posx = p.second.first,posy = p.second.second;
		if(used[posx][posy]) continue;
		used[posx][posy] = true; dist[posx][posy] = d;
		for(auto&& i:G[posx][posy]){
			int x = i.second.first, y = i.second.second;
			if(dist[x][y]>d+1){
				que.push({d+1,mp(x,y)});
			}
		}
	}
}

int main(){
	int i,j,h,w,k;
	string s[MAX];
	P p;
	cin >> h >> w >> k;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			used[i][j] = false;
		}
	}
	for(i=0;i<h;i++){
		cin >> s[i];
		for(j=0;j<w;j++){
			dist[i][j] = 10000000;
			if(s[i][j]=='S'){
				p = {i,j};
			}
			if(s[i][j]=='#') continue;
			if(i!=0 && s[i-1][j]!='#'){
				G[i][j].push_back({1,mp(i-1,j)});
				G[i-1][j].push_back({1,mp(i,j)});
			}
			if(j!=0 && s[i][j-1]!='#'){
				G[i][j].push_back({1,mp(i,j-1)});
				G[i][j-1].push_back({1,mp(i,j)});
			}
		}
	}
	dijkstra(p);
	int ans = 1000;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			int x = min(min(i,h-1-i),min(j,w-1-j));
			if(dist[i][j]<=k){
				int y = x/k + 1;
				if(x%k!=0) y++;
				ans = min(ans,y);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 68480
#include <bits/stdc++.h>
using namespace std;
void DFS(int&i,int&N,vector<deque<int>>&E,vector<bool>&seen,deque<int>&order){
  seen.at(i)=true;
  for(auto P:E.at(i)){
    if(seen.at(P))continue;
    else DFS(P,N,E,seen,order);
  }
  order.push_front(i);
}
int main(){
  int N,M,x,y,MAX=0;cin>>N>>M;
  vector<deque<int>>E(N);
  deque<int>order;vector<int>dp(N,0),O(N,0);
  deque<int>v;vector<bool>seen(N,false);
  for(int i=0;i<M;i++){cin>>x>>y;E.at(x-1).push_back(y-1);}
  for(int i=0;i<N;i++){
    if(seen.at(i))continue;
    else DFS(i,N,E,seen,order);
  }
  for(int i=0;i<N;i++)O.at(order.at(i))=i;
  for(int i=0;i<N;i++)for(auto P:E.at(order.at(i)))dp.at(O.at(P))=max(dp.at(O.at(P)),dp.at(i)+1);
  for(int i=0;i<N;i++)MAX=max(MAX,dp.at(i));
  cout<<MAX<<endl;
}

Measured memory_bytes: 73472
#include<bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define ll long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll f=0;
    ll dp[n+1];
    ll a[n+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        dp[a[i]]=i;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            f++;
        }

    }
   // cout<<f<<endl;
    if(f>2){cout<<"NO";}
    else{cout<<"YES";}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int n, m;
vector<vector<int>> G;
int s, t;
ll dist[100010][3];

ll bfs(){
    memset(dist, -1LL, sizeof(dist));
    dist[s][0] = 0;
    queue<P> stt;
    stt.push(P(s, 0));
    while(!stt.empty()){
        int v = stt.front().first;
        int m = stt.front().second;
        stt.pop();
        for(auto nv : G[v]){
            if(dist[nv][(m + 1) % 3] != -1){
                continue;
            }
            else{
                dist[nv][(m + 1) % 3] = dist[v][m] + 1;
                stt.push(P(nv, (m + 1) % 3));
            }
        }
    }
    if(dist[t][0] == -1) return -1;
    else return dist[t][0] / 3;
}

int main(void){
    cin >> n >> m;
    G.assign(n, vector<int>());
    for(int i = 0; i < m; i++){
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        // 有向グラフなのでuからvだけ辺を張りましょう。
        // G[v].push_back(u);
    }
    cin >> s >> t;
    s--; t--;

    cout << bfs() << endl;

    return 0;
}

Measured memory_bytes: 11184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int v[1000][1000],ans[10000][4];
int main(){
  int h,w;
  cin >> h >> w;
  rep(i,h)rep(j,w)cin >> v[i][j];
  int N = 0;
  rep(i,h - 1)rep(j,w){
    if(v[i][j] % 2 != 0){
      v[i + 1][j]++,v[i][j]--;
      ans[N][0] = i + 2,ans[N][1] = j + 1,ans[N][2] = i + 1,ans[N][3] = j + 1;
      swap(ans[N][0],ans[N][2]);
      swap(ans[N][1],ans[N][3]);
      N++;
    }
  }
  rep(i,w - 1)if(v[h - 1][i] % 2 != 0){
    v[h - 1][i + 1]++,v[h - 1][i]--;
    ans[N][0] = h,ans[N][1] = i + 1,ans[N][2] = h,ans[N][3] = i + 2;
    N++;
  }
  cout << N << endl;
  rep(i,N)cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
  return 0;
}


Measured memory_bytes: 5696
w,h,N=map(int,input().split())
n=h
e=0
w=w
s=0
for _ in range(N):
    x,y,a=map(int,input().split())
    if a==1: e=max(e,x)
    elif a==2: w=min(w,x)
    elif a==3: s=max(s,y)
    else: n=min(n,y)
print(0 if (e>=w or s>=n) else (n-s)*(w-e))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    ll l,r;
    cin>>l>>r;
    ll a=l%2019,b=r%2019;
    if(r>=l+2018||b<=a) cout<<0<<endl;
    else {
      int mm=1e9;
      for(int i=a;i<b;i++){
          for(int j=i+1;j<=b;j++){
              mm=min(mm,(i*j)%2019);
          }
      }
      cout<<mm<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
	"runtime/pprof"
)

const MAX int = 100005

type Node struct {
	Parent int
	Left int
	Right int
}

var T []Node = make([]Node, MAX)
var N int
var D []int = make([]int, MAX)

func print() {
	for i:=0; i<N; i++ {
		typeStr := ""
		if T[i].Parent == -1 {
			typeStr = "root"
		} else if T[i].Left == -1 {
			typeStr = "leaf"
		} else {
			typeStr = "internal node"
		}

		childern := make([]string, 0)
		j := 0
		for c:=T[i].Left; c!=-1; c=T[c].Right {
			childern = append(childern, strconv.Itoa(c))
			j ++
		}
		childernStr := "[" + strings.Join(childern, ", ") + "]"
		fmt.Printf("node %d: parent = %d, depth = %d, %s, %s\n", i, T[i].Parent, D[i], typeStr, childernStr)
	}
}

func rec(u, p int) {
	D[u] = p
	if T[u].Right != -1 {
		rec(T[u].Right, p)
	}
	if T[u].Left != -1 {
		rec(T[u].Left, p+1)
	}
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	cpuFile, _ :=  os.Create("/tmp/CPUProfile")
	pprof.StartCPUProfile(cpuFile)
	defer pprof.StopCPUProfile()


	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N = nextInt(scanner)
	for i:=0; i<N; i++ {
		T[i].Parent = -1
		T[i].Left = -1
		T[i].Right = -1
	}
	for i:=0; i<N; i++ {
		index := nextInt(scanner)
		cnt := nextInt(scanner)
		var left int
		for j:=0; j<cnt; j++ {
			child := nextInt(scanner)
			if j==0 {
				T[index].Left = child 
			} else {
				T[left].Right = child
			}
			left = child
			T[child].Parent = index
		}
	}
	start := 0
	for i:=0; i<N; i++ {
		if T[i].Parent == -1 {
			start = i
		}
	}

	rec(start, 0)

	print()
}


Measured memory_bytes: 17552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int amount = A * B;
  
  if (amount % 2 == 0) {
 	 cout << "Even" << endl; // 真
  } else {
 	 cout << "Odd" << endl; // 偽
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}


int main(){
 ll n ; cin>>n ;
 ll k=1ll ;
 while(n>0){
   n-=pow(26ll,k) ;
   k++ ;
 }
 n+=pow(26ll,k-1) ;
 n-- ;  //k-1keta
 
 vector<ll> A(20) ;
 ll u=0 ;
 while(n>0){
   A[u]=n%26ll ;
   n= n/26ll ;
   u++ ;
 }
  u-- ; //u+1keta
  if(u+1<k-1){
    for(int j=u+1;j<k-1;j++) A[j]=0 ;
  }
  string s="" ;
  rep3(i,k-2,0){
   if(A[i]==0) s+='a' ;
   if(A[i]==1) s+='b' ;
   if(A[i]==2) s+='c' ;
   if(A[i]==3) s+='d' ;
   if(A[i]==4) s+='e' ;
   if(A[i]==5) s+='f' ;
   if(A[i]==6) s+='g' ;
   if(A[i]==7) s+='h' ;
   if(A[i]==8) s+='i' ;
   if(A[i]==9) s+='j' ;
   if(A[i]==10) s+='k' ;
   if(A[i]==11) s+='l' ;
   if(A[i]==12) s+='m' ;
   if(A[i]==13) s+='n' ;
   if(A[i]==14) s+='o' ;
   if(A[i]==15) s+='p' ;
   if(A[i]==16) s+='q' ;
   if(A[i]==17) s+='r' ;
   if(A[i]==18) s+='s' ;
   if(A[i]==19) s+='t' ;
   if(A[i]==20) s+='u' ;
   if(A[i]==21) s+='v' ;
   if(A[i]==22) s+='w' ;
   if(A[i]==23) s+='x' ;
   if(A[i]==24) s+='y' ;
   if(A[i]==25) s+='z' ;
  }
    cout<<s<<endl ;
 
  }

Measured memory_bytes: 4104
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    double N;
    cin >> N;
    double pr = int(((N + 1)/ 2)) / N;
    cout << pr << endl;
}


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

void get_network(int N,vector<vector<int>>& array){
    int u,k,x;

    for(int i=0;i<N;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>x;
            array[u-1][x-1]=1;
        }
    }

}

int dfs_rec(vector<int>& flag,int n,vector<vector<int>>& A,int v,vector<int>& f,vector<int>& d,int t){
        flag[v]=1;
        d[v]=t;
        for(int i=0;i<n;i++){
                if(A[v][i]==1 && flag[i]!=1){
                        t=dfs_rec(flag,n,A,i,f,d,t+1);

                }
        }
        f[v]=t+1;
        t++;
        return t;
}


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

        int n;
        cin>>n;
        vector<vector<int>> array(n,vector<int>(n,0));
        get_network(n,array);

        //
        vector<int> flag(n,-1);
        vector<int> d(n,0);
        vector<int> f(n,0);
        //
        int t=0;
        t=dfs_rec(flag,n,array,0,f,d,t);
        for(int i=0;i<n;i++){
                if(flag[i]==-1){
                        t=dfs_rec(flag,n,array,i,f,d,t+1);
                }
        }
        //

        for(int i=0;i<n;i++){
                cout<<i+1<<" "<<d[i]+1<<" "<<f[i]+1<<"\n";
        }

        return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
//using namespace std;
int main()
{
    long n, i, j, temp, m = 0, k = 0;

    scanf("%ld", &n);

    long a[n];

    for(i = 0; i < n; i++)
    {
        scanf("%ld", &a[i]);
    }


    std::sort(a,a+n);
    std::reverse(a,a+n);
    
    for(i = 0; i < n-1; i++)
    {
        if(a[i] == a[i+1])
        {
            m = a[i];
            break;
        }
    }
    for(i = i+2; i < n-1; i++)
    {
        if(a[i] == a[i+1])
        {
            k = a[i];
            break;
        }
    }


    printf("%ld", m*k);


    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<random>
#include<algorithm>
#define ll long long
using namespace std;
char c;
char a[200];
char s[20]={'k','e','y','e','n','c','e','0'};
int len=7;
int n=0;

bool check(int left,int right)
{
    int j=0;
    char st[200];
    int top=0;
    for (int i=0; i<n; ++i)
    {
        if (i>=left && i<=right) continue;
        st[top++]=a[i];
    }
    if (top!=7) return 0;
    for (int i=0; i<top; ++i)
        if (s[i]!=st[i]) return 0;
    return 1;
}


int main()
{
    while (scanf("%c",&c)!=EOF)
    {
        if (c<'a' || c>'z') break;
        a[n++]=c;
    }
    bool flag=0;
    for (int left=0; left<=n; ++left)
        for (int right=left; right<=n; ++right)
        {
            if (check(left,right))
            {
                flag=1;
            }
        }
    if (flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = inf;
	rep(i, n) {
		int tmp = 0;
		while (a[i] % 2 == 0) a[i] /= 2, tmp++;
		mins(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
#define ll long long
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,d;
	cin >> n >> d;
	int ans = 0;
	for(int i = 0;i<n;++i) {
		int x,y;
		cin >> x >> y;
		if(sqrt(pow(x,2)+pow(y,2)) <= d) {
			ans++;
		}
	}
	cout << ans << '\n';
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (auto &v : a) {cin >> v; --v;}
    for (auto &v : b) cin >> v;

    for (auto &v : c) cin >> v;
    int sum = accumulate(b.begin(), b.end(), 0);
    for (int i = 1; i < n; ++i) if (a[i] == a[i - 1] + 1) sum += c[a[i - 1]];
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())
QUERY = []
for i in range(Q):
    # q = list(map(int, input().split()))
    q = input().split()
    if q[0] == '1':
        QUERY.append([int(q[0])])
    else:
        QUERY.append([int(q[0]), int(q[1]), q[2]])

st = []
en = []
rev = False
rev_c = 0
for q in QUERY:
    if q[0] == 1:
        if rev:
            rev = False
        else:
            rev = True
        rev_c += 1
    else:
        if q[1] == 1:
            if not rev:
                st.append(q[2])
            else:
                en.append(q[2])
        else:
            if not rev:
                en.append(q[2])
            else:
                st.append(q[2])

# print(st)
# print(en)

st_s = "".join(st)
st_s = st_s[::-1]
en_s = "".join(en)

ans = st_s + S + en_s
if rev_c % 2 == 0:
    pass
else:
    ans = ans[::-1]

print(ans)

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

int main() {
    ll A, B;
    cin >> A >> B;

    ll ans = 0;
    vector<ll> N(4, -1);
    vector<bool> repeat(4, false);
    if (B - A < 12) {
        for (ll i = A; i <= B; ++i) {
            ans ^= i;
        }
    } else {
        rep(i, 12) {
            ans ^= A + i;
            if (N[i % 4] == ans) repeat[i % 4] = true;
            N[i % 4] = ans;
        }

        int a = (B - A) % 4;
        if (repeat[a] == true)
            ans = N[a];
        else
            ans = N[(a + 4 - 1) % 4] ^ B;
    }
    cout << ans << endl;
}

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

int main(){
  int H,W;cin>>H>>W;
  vector<string>S(H);
  for(int i=0; i<H; i++)cin>>S[i];

  int L[H][W], R[H][W], U[H][W], D[H][W];

  for(int i=0, I=H-1; i<H; i++, I--){
    for(int j=0, J=W-1; j<W; j++, J--){
      {//L
        if(S[i][j]=='.'){
          if(j==0)L[i][j] = 1;
          else L[i][j] = L[i][j-1] +1;
        }else{
          L[i][j] = 0;
        }
      }
      {//R
        if(S[i][J]=='.'){
          if(J==W-1)R[i][J] = 1;
          else R[i][J] = R[i][J+1] +1;
        }else{
          R[i][J] = 0;
        }
      }
      {//U
        if(S[i][j]=='.'){
          if(i==0)U[i][j] = 1;
          else U[i][j] = U[i-1][j] +1;
        }else{
          U[i][j] = 0;
        }
      }
      {//D
        if(S[I][j]=='.'){
          if(I==H-1)D[I][j] = 1;
          else D[I][j] = D[I+1][j] +1;
        }else{
          D[I][j] = 0;
        }
      }
    }
  }

  int ans = 0;
  for(int i=0; i<H; i++)for(int j=0; j<W; j++){
    ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 66816
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int ans=0;
	stack<char> st;
	string s;
	cin>>s;
	for(auto &it:s)
	{
		if(it=='0')
		{
			if(st.size() && st.top()=='1')
			{
				ans+=2;
				st.pop();
			}
			else
				st.push(it);
		}
		else
		{
			if(st.size() && st.top()=='0')
			{
				ans+=2;
				st.pop();
			}
			else
				st.push(it);
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
using namespace std; 
void fastio()
{
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
signed main()
{
    fastio();
   int n,c=0,z=0,zz=0;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<n;i++)
   {
       if(s[i]=='W')
       c++;
       else
       z++;
     //  break;
   }
   for(int i=0;i<z;i++)
   {
       if(s[i]=='W')
       zz++;
      
   }
   if(c==0)
   cout<<0;
   else
   cout<<zz;
  // cout<<c<<" "<<z;
}


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

int main()
{
  int i,n;
  cin >> n;
  
  vector<int> p(n),p_sort(n);
  
  for(i=0;i<n;i++)
  {
   cin >> p[i]; 
  }
  
  copy(p.begin(),p.end(),p_sort.begin());
  sort(p_sort.begin(),p_sort.end());
  
  int cnt=0;
  for(i=0;i<n;i++)
  {
    if(p_sort[i] != p[i]) cnt++;
  }
  
  if(cnt ==2 || cnt ==0) cout << "YES";
  else cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int H,W;
string s[30][30];
string tmp = "snuke";
bool flag;
int main()
{
	scanf("%d%d",&H,&W);
	flag = false;
	for(int i=1;i<=H;i++)
	for(int j=1;j<=W;j++)
	{
		cin>>s[i][j];
		if(flag)continue;
		if(s[i][j] == tmp)
		{
			char y = j+'A'-1;
			int x = i;
			printf("%c%d",y,x);
			flag = true;
			break;
		}
	}
	return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;


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

	map<int, lli>mp, ms;
	unordered_set<int> se;
	for (int i = 0; i < N; i++) {
		mp[A[i] + i + 1]++;
		se.insert(A[i] + i + 1);
		ms[-A[i] + i + 1]++;
	}
	lli ans = 0;
	for (int i : se) {
		if (ms.count(i) > 0)ans += mp[i] * ms[i];
	}

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



Measured memory_bytes: 34904
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

int w, h;
ll p[111111], q[111111];

int main(void) {
  scanf("%d%d", &w, &h);
  for (int i = 0; i < w; i++) scanf("%lld", p+i);
  for (int i = 0; i < h; i++) scanf("%lld", q+i);
  sort(p, p+w);
  sort(q, q+h);

  int a, b;
  int ww = w+1;
  int hh = h+1;
  ll res = 0;
  a = 0;
  b = 0;
  for (int i = 0; i < w+h; i++) {
    // printf("%d %d %d %d %lld\n", ww, hh, a, b, res);
    if (a == w || (b < h && p[a] > q[b])) {
      res += q[b]*ww;
      --hh;
      ++b;
    } else {
      res += p[a]*hh;
      --ww;
      ++a;
    }
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

int max(int a, int b) {
  if(a > b)
    return a;
  return b;
}

int main() {
  int n, a, b, c, dp[100001][3];
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = b + max(dp[i - 1][2], dp[i - 1][0]);
    dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
  }
  printf("%d\n", max(max(dp[n][0], dp[n][1]), dp[n][2]));
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string a;
    cin >> a;
    int tmp = 0;
    for (int i = 0; i<4; i++){
        if (a[i] == '+') tmp++;
        else if (a[i] == '-') tmp--;
    }
    cout << tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int ,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int cont5=0,cont7=0;
  for(int i=1;i<=3;i++){
    int a; cin >> a;
    if(a==5)cont5++;
    if(a==7)cont7++;
  }
  if(cont5==2&&cont7==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input().strip("\n")

L = [-1] * N
R = [10 ** 10] * N

l = 1
r = K
li = 0
ri = N-1
while li < N:
    if S[li] == "o":
        L[li] = l
        l += 1
        li += C + 1
    else: li += 1

while ri >= 0:
    if S[ri] == "o":
        R[ri] = r
        r -= 1
        ri -= C + 1
    else: ri -= 1


for i in range(N):
    if L[i] == R[i]: print(i + 1)



Measured memory_bytes: 25248
import numpy as np
from numpy.fft import rfft,irfft
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
class Polynomial:
    def __init__(self,dim=0,const=1):
        self.values = [(dim,const)]
    def __add__(self,other):
        return self.values + other.values


class PolySolver:
    def __init__(self,size,init_val=1):
        self.size = size
        self.f = np.zeros(size, np.int64)
        self.f[0] = init_val


    def multiple(self,polynomial,MOD): # const1 * x^dim1 + const2 * x^dim2 + ... をfにかけ合わせる
        new_F = np.zeros(self.size, np.int64)
        for dim,const in polynomial:
            if dim != 0:
                g = np.zeros(self.size, np.int64)
                g[dim:] += self.f[:-dim] # dim分係数情報をずらす
            else:
                g = const * self.f.copy()

            new_F += g

        self.f = new_F
        
    
    def add(self,polynomial): # const1 * x^dim1 + const2 * x^dim2 + ... をfに足す
        for dim,const in polynomial:
            self.f[dim] += const
            

    def get_coefficient(self,dim):
        return self.f[dim]

    def fft(self,A,B,fft_len=1<<18):
        x = irfft(rfft(A,fft_len) * rfft(B,fft_len))
        return np.rint(x).astype(np.int64)

    def convolve(self,g):
        h = self.fft(self.f,g)[:len(self.f) + len(g) - 1]
        self.f = h
    


def main():
    N,M=mi()
    A=list(mi())
    
    mx = 2*10**5+10
    F = PolySolver(mx,init_val=0)
    for a in A:
        F.add(Polynomial(dim=a).values)
    
    g = F.f
    F.convolve(g)

    ans = 0
    handshake = M
    for x in range(mx-1,1,-1):
        count = F.get_coefficient(x)
        if count <= 0: continue

        if count > handshake:
            ans += handshake * x
        else:
            ans += count * x
 
        handshake = max(handshake-count,0)
        if handshake == 0:
            break

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 45000
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
b = intl()

a = b[0] + b[-1]
for i in range(n-2):
	a += min( b[i], b[i+1] )
print(a)

Measured memory_bytes: 8976
#include<bits/stdc++.h>
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__)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	if(s=="H")cout<<(t=="H"?"H":"D")<<endl;
	else cout<<(t=="D"?"H":"D")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b)/2+(a+b)%2<<endl;
}

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

const int Maxn = 500010;
int N, K, A[ Maxn ], P[ Maxn ], Rec[ Maxn ];

int Tree[ Maxn << 2 ];
struct edge {
	int To, Next;
};
edge Edge[ Maxn << 1 ];
int Start[ Maxn ], Used;
int Degree[ Maxn ];
inline void AddEdge( int x, int y ) {	
	Edge[ ++Used ] = ( edge ) { y, Start[ x ] };
	Start[ x ] = Used;
	++Degree[ y ];
	return;
}

void Add( int Index, int L, int R, int Pos, int Key ) {
	Tree[ Index ] = max( Tree[ Index ], Key );
	if( L == R ) return;
	int Mid = L + R >> 1;
	if( Pos <= Mid ) Add( Index << 1, L, Mid, Pos, Key );
	if( Pos > Mid ) Add( Index << 1 | 1, Mid + 1, R, Pos, Key );
	return;
}

int Query( int Index, int L, int R, int l, int r ) {
	if( l <= L && R <= r ) return Tree[ Index ];
	int Mid = L + R >> 1;
	if( r <= Mid ) return Query( Index << 1, L, Mid, l, r );
	if( l > Mid ) return Query( Index << 1 | 1, Mid + 1, R, l, r );
	return max( Query( Index << 1, L, Mid, l, r ), Query( Index << 1 | 1, Mid + 1, R, l, r ) );
}

struct Cmp {
	bool operator () ( int x, int y ) {
		return x > y;
	}
};
priority_queue< int, vector< int >, Cmp > PQ;

int main() {
	scanf( "%d%d", &N, &K );
	for( int i = 1; i <= N; ++i ) scanf( "%d", &A[ i ] );
	for( int i = 1; i <= N; ++i ) P[ A[ i ] ] = i;
	for( int i = 1; i <= N; ++i ) {
		int x;
		x = Query( 1, 1, N, max( 1, P[ i ] - K + 1 ), P[ i ] );
		if( x ) AddEdge( P[ x ], P[ i ] );
		x = Query( 1, 1, N, P[ i ], min( N, P[ i ] + K - 1 ) );
		if( x ) AddEdge( P[ x ], P[ i ] );
		Add( 1, 1, N, P[ i ], i );
	}
	for( int i = 1; i <= N; ++i ) 
		if( !Degree[ i ] )
			PQ.push( i );
	for( int i = 1; i <= N; ++i ) {
		Rec[ i ] = PQ.top();
		PQ.pop();
		for( int t = Start[ Rec[ i ] ]; t; t = Edge[ t ].Next ) {
			int v = Edge[ t ].To;
			--Degree[ v ];
			if( !Degree[ v ] ) PQ.push( v );
		}
	}
	for( int i = 1; i <= N; ++i ) A[ Rec[ i ] ] = i;
	for( int i = 1; i <= N; ++i ) printf( "%d\n", A[ i ] );
	return 0;
}


Measured memory_bytes: 27384
import java.util.Scanner;


public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		while(true){
			int w = s.nextInt();
			int h = s.nextInt();
			if(w == 0 && h == w)break;
			int x = 0;
			int y = 0;
			String tile[][] = new String[h][w];
			for(int i = 0;i < h;i++){
				tile[i] = s.next().split("");
				for(int j = 0;j < w;j++){
					if(tile[i][j].charAt(0) == '@'){
						x = i;
						y = j;
					}
				}
			}
			int chkP[][] = new int[h][w];
			int cnt = cntTile(tile,chkP,'.',x,y);
			System.out.println(cnt);
		}
	}
	
	int cntTile(String[][] panel,int[][] chkP,char tile,int x,int y){
		chkP[x][y] = -1; 
		int cnt = 0;
		if(x + 1 < panel.length    && chkP[x + 1][y] != -1 && panel[x + 1][y].charAt(0) == tile)cnt += cntTile(panel,chkP,tile,x + 1,y);
		if(x     > 0               && chkP[x - 1][y] != -1 && panel[x - 1][y].charAt(0) == tile)cnt += cntTile(panel,chkP,tile,x - 1,y);
		if(y + 1 < panel[x].length && chkP[x][y + 1] != -1 && panel[x][y + 1].charAt(0) == tile)cnt += cntTile(panel,chkP,tile,x,y + 1);
		if(y     > 0               && chkP[x][y - 1] != -1 && panel[x][y - 1].charAt(0) == tile)cnt += cntTile(panel,chkP,tile,x,y - 1);
		cnt++;
		return cnt;
	}
	
	public static void main(String args[]){
		new Main().run();
	}
}

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

int main(){
  string s;
  int sum=0;
  while(cin>>s){
    int tmp=0;
    for(int i=0; i<s.length(); i++){
      if('0'<=s[i] && s[i]<='9'){
        tmp=tmp*10+(s[i]-'0');
      }
      else{
        sum+=tmp;
        tmp=0;
      }
    }
    sum+=tmp;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int N;
  scanf("%d", &N);
  int V[N*2];
  for(int i = 0; i < N; i++){
      scanf("%d %d", &V[2*i], &V[2*i+1]);
  }
  long long int R2 = 0;
  for(int i = 0; i < 100; i++){
      double theta = 2*M_PI*i/100;
      double a = cos(theta);
      double b = sin(theta);
      long long int X = 0;
      long long int Y = 0;
      for(int j = 0; j < N; j++){
          long long int x = V[j*2];
          long long int y = V[j*2+1];
          if(a*x+b*y > 0){
              X += x;
              Y += y;
          }
      }
      long long int r2 = X*X+Y*Y;
      if(r2 > R2){
          R2 = r2;
      }
  }
  printf("%.16lf", sqrt(R2));
  return 0;
}


Measured memory_bytes: 384