akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e+6;
int weight[N];
int v[N];

int n,w;

int32_t main()
{
	cin>>n>>w;
	for(int i=1;i<=n;i++)
	{
		cin>>weight[i]>>v[i];
	}

	vector<vector<int> > dp(n+1,vector<int> (w+1));
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0||j==0)
			{
				dp[i][j]=0;
			}
			else
			{
				dp[i][j]= dp[i-1][j];
				if(weight[i]<=j)
				{
					dp[i][j] = max(dp[i-1][j-weight[i]] + v[i],dp[i][j]);
				}
			}
		}
	}
	
	cout<<dp[n][w];
	return 0;

}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<18|3,inf=0x3f3f3f3f;
int n,a[N][2],dp[N][55],cnt[N],f[N][19];
int main() {
	read(n);
	rep(i,1,n)read(a[i][0]);
	rep(i,1,n)read(a[i][1]);
	memset(dp,inf,sizeof(dp));
	dp[0][0]=0;
	rep(s,1,(1<<n)-1)cnt[s]=cnt[s>>1]+(s&1);
	rep(s,0,(1<<n)-1)rep(i,1,n)if(!(s>>i-1&1))rep(j,i+1,n)if(s>>j-1&1)f[s][i]++;
	rep(s,0,(1<<n)-1)rep(v,0,50)if(dp[s][v]<inf){
		rep(i,1,n)if(!(s>>i-1&1)&&a[i][i+cnt[s]+1&1]>=v)
			umin(dp[s|(1<<i-1)][a[i][i+cnt[s]+1&1]],dp[s][v]+f[s][i]);
	}
	int res=inf;rep(i,0,50)umin(res,dp[(1<<n)-1][i]);
	cout<<(res<inf?res:-1);
	return 0;
}


Measured memory_bytes: 78080
n,y = map(int,input().split())
count = 0
for a in range(2001):
  for b in range(2001):
    c = n - a - b
    if 10000*a + 5000*b + 1000*c == y and 0 <= c <= 2000:
      print(str(a) + " " + str(b) + " " + str(c))
      count += 1
      break
  if count == 1:
    break
if count == 0:
  print("-1 -1 -1")

Measured memory_bytes: 3188
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_b

paths = [sorted(list(map(int, input().split()))) for _ in range(3)]

# print(paths)

c1 = 0
c2 = 0
c3 = 0
c4 = 0

for p in paths:
    for c in p:
        if c == 1:
            c1 += 1
        elif c == 2:
            c2 += 1
        elif c == 3:
            c3 += 1
        elif c == 4:
            c4 += 1

if [c1,c2,c3,c4].count(2) == 2 and [c1,c2,c3,c4].count(1) == 2:
    print("YES")
else:
    print("NO")
#
# print("{}, {}, {}, {}".format(c1,c2,c3,c4))



Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

nums = []
for idx in range(N):
  nums.append((1, A[idx]))
  nums.append((2, B[idx]))
  nums.append((3, C[idx]))
nums.sort(key=lambda x:(x[1], -x[0]))
sum_a = 0
sum_b = 0
sum_c = 0
for idx in range(3*N):
  if nums[idx][0] == 1:
    sum_a += 1
  elif nums[idx][0] == 2:
    sum_b += sum_a
  elif nums[idx][0] == 3:
    sum_c += sum_b
print(sum_c)

Measured memory_bytes: 63124
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

struct UnionFind
{
    vector<int> par, rank, sz;
    UnionFind(int N) : par(N), rank(N), sz(N)
    {
        REP(i, N)
        {
            par[i] = i;  //the parent of the node
            rank[i] = 0; //the rank of the tree
            sz[i] = 1;
        }
    }
    int find(int x)
    { //Find the root of x
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }
    int size(int x)
    {
        return sz[find(x)];
    }
    void unite(int x, int y)
    { //Unite (the set of x) and (the set of y)
        x = find(x), y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y])
        { //larger rank is above
            sz[y] += sz[x];
            par[x] = y;
        }
        else
        {
            sz[x] += sz[y];
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vint> G(n);
    set<pint> se;
    UnionFind uf(n);
    REP(i,m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }
    int ans = 1;
    REP(i, n) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 10388
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{
double t,x;
cin >>t>>x;
cout<<t/x<<endl; 

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

int main() {
	fio;
	int n, m;
	cin >> n >> m;
	int sx, sy, ex, ey;
	cin >> sx >> sy >> ex >> ey;
	sx--, sy--, ex--, ey--;
	string s[n];
	for (int i = 0;i < n;i++)
		cin >> s[i];
	deque<pii> Q;
	bool vis[n][m] = {};
	int d[n][m];
	for (int i = 0;i < n;i++)
		for (int j = 0;j < m;j++)
			d[i][j] = INT32_MAX;
	d[sx][sy] = 0;
	Q.push_back({sx, sy});
	while (!Q.empty()) {
		int x = Q.front().fi;
		int y = Q.front().se;
		Q.pop_front();
		if (vis[x][y])
			continue;
		vis[x][y] = 1;
		for (int i = max(x - 2, 0);i < min(x + 3, n);i++)
			for (int j = max(y - 2, 0);j < min(y + 3, m);j++) {
				if (abs(i - x) + abs(j - y) == 0)
					continue;
				if (abs(i - x) + abs(j - y) == 1 && s[i][j] == '.' && !vis[i][j]) {
					Q.push_front({i, j});
					d[i][j] = min(d[i][j], d[x][y]);
				}
				if (abs(i - x) + abs(j - y) > 1 && s[i][j] == '.' && !vis[i][j]) {
					Q.push_back({i, j});
					d[i][j] = min(d[i][j], d[x][y] + 1);
				}
			}
	}
	if (d[ex][ey] == INT32_MAX)
		cout << -1 << '\n';
	else
		cout << d[ex][ey] << '\n';
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;

const int M = 100100;

int n, a[M];
int d[M][2];
int ans = 1;

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

void kill() {
    d[0][1] = 1, d[0][0] = 1;
    for (int i = 1; i < n; ++i) {
    
        if (a[i - 1] <= a[i])
            d[i][0] = min(d[i - 1][0], 1 + d[i - 1][1]);
        else
            d[i][0] = 1 + min(d[i - 1][0], d[i - 1][1]);

        if (a[i - 1] >= a[i])
            d[i][1] = min(d[i - 1][1], 1 + d[i - 1][0]);
        else
            d[i][1] = 1 + min(d[i - 1][0], d[i - 1][1]);
    }
    
    cout << min(d[n - 1][0], d[n - 1][1]) << endl;
}


int main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  vector<string>s(h);
  rep(i,0,h)cin>>s[i];
  rep(i,0,w-1){
    auto dp=vec(h+1,h+1,INF);
    auto cum=vec(2*h+1,h+1,0LL);
    rep(j,0,h)rep(o,0,h){
      if(s[j][i]==s[o][i+1]){
        if(j<o)cum[o-j+h][h-j-1]++;
        else cum[o-j+h][h-j-1]++;
      }
    }
    rep(j,0,2*h+1)rrep(o,0,h)cum[j][o]+=cum[j][o+1];
    dp[0][0]=0;
    rep(j,0,h+1)rep(o,0,h+1){
      if(j<h)chmin(dp[j+1][o],dp[j][o]+cum[j-o+h][j]);
      if(o<h)chmin(dp[j][o+1],dp[j][o]+cum[j-o+h][j]);
    }
    //debug(cum,2*h+1,h+1);cout<<endl;debug(dp,h+1,h+1);
    res+=dp[h][h];
  }

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

Measured memory_bytes: 2576
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

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

int main()
{
	fastIO;

	int n; cin >> n;
	int ans = 0;

	for(int i = 1; i <= n; i++)
		for(int j = 1; i*j < n; j++)
			ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

public class Pg
{
    static void Main()
    {
        var rd = new Reader();
        rd.Read().ToList().ForEach(delegate (string x)
        {
            var ct = new Counter();
            Console.WriteLine(ct.GetTimes(x));
        });

    }
}
class Reader
{
    internal IEnumerable<string> Read()
    {
        int n = int.Parse(Console.ReadLine());
        while (n-- > 0)
        {
            yield return Console.ReadLine();
        }
    }
}
class Counter
{
    int cnt = 0;
    internal int GetTimes(string str)
    {
        var lst = new List<int>();
        for (int i = 1; i < str.Length; ++i)
        {
            var s1 = str.Substring(0, i);
            var s2 = str.Substring(i);
            lst.Add(int.Parse(s1) * int.Parse(s2));
        }
        cnt++;
        int max;
        try
        {
            max = lst.Max();
        }
        catch
        {
            return 0;
        }
        if (max < 10)
            return cnt;
        else if (str == max.ToString())
            return -1;
        else
            return GetTimes(max.ToString());
    }
}



Measured memory_bytes: 18344
import bisect
def check(x,s,t):
    s_index = bisect.bisect_left(s,x)
    
    sr = s[s_index]
    sl = s[s_index-1]
    t_index = bisect.bisect_left(t,x)
    tr = t[t_index]
    tl = t[t_index-1]
    shrine = [sr,sl]
    temp = [tr,tl]
    ans = 10**20
    for i in range(2):
        for j in range(2):
            for l in range(2):
                if i == 0:
                    can = abs(shrine[j]-x)
                    can += abs(temp[l]-shrine[j])
                else:
                    can = abs(temp[l]-x)
                    can += abs(shrine[j]-temp[l])
                ans = min(ans,can)
    print(ans)
    


def main():
    a,b,q = map(int,input().split())
    s = [int(input()) for _ in range(a)]
    s.append(10**20)
    s.insert(0,-10**20)
    t = [int(input()) for _ in range(b)]
    t.append(10**20)
    t.insert(0,-10**20)
    x = [int(input()) for _ in range(q)]

    for i in range(q):
        check(x[i],s,t)

if __name__ == "__main__":
    main()

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

int main(){
    int A1,A2,A3;
    cin>>A1>>A2>>A3;
    int a = abs(A1-A2);
    int b = abs(A2-A3);
    int c = abs(A3-A1);
    cout<<a+b+c-max({a,b,c})<<endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())

q, r = divmod(X, 100)

if r == 0:
    print(1)
    quit()

cnt = 0
for i in reversed(range(1, 6)):
    a, r = divmod(r, i)
    cnt += a
    if r == 0:
        break

if cnt <= q:
    print(1)
else:
    print(0)


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n,m;

	cin>>n>>m;

	vector<lli> a(n);
	priority_queue<lli> q;
	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		q.push(tmp);
	}

	REP(i,0,m){
		lli top = q.top();
		top /= 2;
		q.pop();
		q.push(top);
	}

	lli sum=0;
	while(q.size())
	{
		lli top = q.top();
		sum += top;
		q.pop();
	}
	cout<<sum<<endl;
	


	return 0;
}

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

int main() {
  string s;
  cin >> s;
  reverse(all(s));
  ll ans = 0;
  for(int tmp = 0; tmp < (1 << s.size() - 1); tmp++) {
    bitset<10> ss(tmp);
    ans += s[0] - '0';
    ll now = 1;
    for(int i = 0; i < s.size() - 1; i++) {
      if(ss.test(i)) {
        now = 1;
      } else {
        now *= 10;
      }
      ans += (s[i + 1] - '0') * now;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
x = [int(input()) for _ in range(q)]
s.sort()
t.sort()
#print(s)
#print(t)
#print(x)
from bisect import bisect_left

def search_st(xi, s, t):
    ret = 10 ** 15
    ls = len(s)
    lt = len(t)
    ss = bisect_left(s, xi)
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    ss -= 1
    si = s[ss % ls]
    st = bisect_left(t, si)
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    st -= 1
    ti = t[st % lt]
    ret = min(ret, abs(xi - si) + abs(si - ti))
    #print(si, ti, ret)
    return ret

for i in range(q):
    xi = x[i]
    ans = 10 ** 15
    # sから先
    ans = min(ans, search_st(xi, s, t))
    ans = min(ans, search_st(xi, t, s))
    print(ans)


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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  int64_t N,sum = 0,min = INT_MAX;
  bool f = false;
  cin >> N;
  for(int i; i < N; i++){
  	int64_t a;
  	cin >> a;
    int64_t ab = abs(a);
    if(ab < min) min = ab;
    if(a < ab) f = !f;
    sum += ab;
  }
  if(f) sum -= min * 2;
  cout << sum << endl;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	string a,b,c;
	cin>>a>>b>>c;	
	int A,B;
	A=a.size();
	B=b.size();
	if(a.at(A-1)==b.at(0)&&b.at(B-1)==c.at(0)){
	  cout<<"YES"<<endl;}	
	  else{
		  cout<<"NO"<<endl;
		}
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int m = in.nextInt();
		int t = in.nextInt()-1;
		int d = in.nextInt();

		int[] a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = i+1;
		}

		String[] s = new String[d];
		for (int i=0; i<d; i++) {
			s[i] = in.next();
			for (int j=0; j<n-1; j++) {
				if (s[i].charAt(j) == '1') {
					int tmp = a[j]; a[j] = a[j+1]; a[j+1] = tmp;
				}
			}
		}

		if (a[t] == m) {
			out.println("0");
			return true;
		}

		int x = a[t];

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

		for (int i=0; i<d; i++) {
			for (int j=0; j<n-1; j++) {
				if (s[i].charAt(j) == '1') {
					int tmp = a[j]; a[j] = a[j+1]; a[j+1] = tmp;
				}
			}

			for (int j=0; j<n-1; j++) {
				if (j != 0 && s[i].charAt(j-1) == '1') continue;
				if (s[i].charAt(j) == '1') continue;
				if (j != n-2 && s[i].charAt(j+1) == '1') continue;

				if ((a[j] == x && a[j+1] == m) || (a[j] == m && a[j+1] == x)) {
					out.println((i+1)+" "+(j+1));
					return true;
				}
			}
		}

		out.println("1");
		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

int N;

void factor(map<int,int> &m, int num){
    for(int i=2; i*i <= num; i++){
        int p = 0;
        while(num%i==0){
            num /= i;
            p++;
        }
        if(p > 0){
            if(!m.count(i)) m[i] = 0;
            m.at(i) += p;
        }
    }
    if(num != 1){
        if(!m.count(num)) m[num] = 0;
        m.at(num)++;
    }
}

signed main(){
    cin >> N;
    map<int, int> div;
    reps(i,1,N) factor(div, i);
    
    vector<int> pows(76,0);
    for(auto p: div){
        if(p.second >= 74) pows[75]++;
        if(p.second >= 24) pows[25]++;
        if(p.second >= 14) pows[15]++;
        if(p.second >= 4)  pows[5]++;
        if(p.second >= 2)  pows[3]++;
    }
    
    int ans = 0;
    
    //a^75
    ans += pows[75];
    
    //a^3 * b^25
    ans += pows[3]*pows[25] - pows[25];
    
    //a^5 * b^15
    ans += pows[5]*pows[15] - pows[15];
    
    //a^3 * b^5 * c^5
    ans += (pows[3]-pows[5]) * max(0ll, pows[5]*(pows[5]-1)/2);
    ans += max(0ll, pows[5]*(pows[5]-1)*(pows[5]-2)/2);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    long mod = (long)Math.pow(10,9) + 7;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextLong();
    }
    long ans = 0;
    for (int i = 0; i < 60; i++) {
        long cnt = 0;
        for (int j = 0; j < N; j++){
            if (((A[j] >>> i) & 1) == 1){
                cnt++; // 1の物をカウント
            }
        }
        long a = (cnt * (N - cnt)) % mod; //0の数*1の数=合計カウント数
        for (int j = 0; j < i; j++){
            a = (a << 1) % mod; //桁を繰り上げて元に戻す
        }
        ans += a;
        ans %= mod;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 98348
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long c = sc.nextLong();
		long[][] xv = new long[n][2];
		for(int i = 0; i < n; i++){
		    xv[i][0] = sc.nextLong();
		    xv[i][1] = sc.nextLong();
		}
		
		// 計算
		long result = 0;
		long[] cal = new long[n+1];
		for(int i = 0; i < n; i++){
		    if(i > 0){
		        cal[i+1] = cal[i] + xv[i][1] - (xv[i][0] - xv[i-1][0]); 
		    }else{
		        cal[i+1] = cal[i] + xv[i][1] - xv[i][0];
		    }
		}
		long[] rev = new long[n+1];
		for(int i = 0; i < n; i++){
		    if(i > 0){
		        rev[i+1] = rev[i] + xv[n-1-i][1] - (xv[n-i][0] - xv[n-1-i][0]); 
		    }else{
		        rev[i+1] = rev[i] + xv[n-1-i][1] - (c - xv[n-1-i][0]);
		    }
		}
		long[] cal_return = new long[n+1];
		for(int i = 0; i < n; i++){
		    if(i > 0){
		        cal_return[i+1] = cal_return[i] + xv[i][1] - 2*(xv[i][0] - xv[i-1][0]); 
		    }else{
		        cal_return[i+1] = cal_return[i] + xv[i][1] - 2*xv[i][0];
		    }
		}
		long[] rev_return = new long[n+1];
		for(int i = 0; i < n; i++){
		    if(i > 0){
		        rev_return[i+1] = rev_return[i] + xv[n-1-i][1] - 2*(xv[n-i][0] - xv[n-1-i][0]); 
		    }else{
		        rev_return[i+1] = rev_return[i] + xv[n-1-i][1] - 2*(c - xv[n-1-i][0]);
		    }
		}
		long[] cal_max = new long[n+1];
		for(int i = 0; i < n+1; i++){
		    if(i == 0){
		        cal_max[i] = cal[i];
		    }else{
		        cal_max[i] = max(cal[i], cal_max[i-1]);
		    }
		}
		long[] rev_max = new long[n+1];
		for(int i = 0; i < n+1; i++){
		    if(i == 0){
		        rev_max[i] = rev[i];
		    }else{
		        rev_max[i] = max(rev[i], rev_max[i-1]);
		    }
		}
		for(int i = 0; i < n; i++){
		    result = max(result, cal_return[i] + max(0, rev_max[n-i]));
		    result = max(result, rev_return[i] + max(0, cal_max[n-i]));
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 95168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[130],k;
    for(int i=0;i<5;i++)
    {
        scanf("%d",&arr[i]);
    }
    scanf("%d",&k);
    sort(arr,arr+5);
    /*for(int i=0;i<5;i++)
    {

    }*/
    int res;
    res=arr[4]-arr[0];
    if(res>k)
    {
        printf(":(");
    }
    else
    {
        printf("Yay!");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 256
# E - Colorful Blocks
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())

# --+----+----+----+----+----+----+----+----+
# 予め逆元の階乗をO(n)で計算することにより
# nCr(mod.p)をO(1)で計算する
MOD = 998244353

fac = [1, 1]
inv = [0, 1]
finv = [1, 1]

for i in range(2, N+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD)

def comb_mod(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m
# --+----+----+----+----+----+----+----+----+

ans = 0
for i in range(K+1):
    ans = (ans + (M*pow(M-1, N-1-i, MOD)) * comb_mod(N-1, i, MOD))%MOD

print(ans)


Measured memory_bytes: 32800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)2e2+7;

int N;
char pic[MAXN][MAXN];

queue<pi> qu;
int loc[MAXN];

int solve(int s) {
    while (!qu.empty()) qu.pop();
    memset(loc,0,sizeof(loc));

    qu.push(make_pair(s,1));
    loc[s] = 1;
    while (!qu.empty()) {
        pi to = qu.front();qu.pop();
        int now = to.first;
        int ci = to.second;
        rep(i,1,N) {
            if (pic[now][i] == '1' && loc[i] == 0) {
                qu.push(make_pair(i,ci+1));
                loc[i] = ci+1;
            }
        }
    }
    rep(i,1,N) {
        rep(j,1,N) {
            if (loc[i] == loc[j] && pic[i][j] == '1') {
                return -1;
            }
        }
    }

    return *max_element(loc+1,loc+1+N);
}

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

    cin >> N;
    rep(i,1,N) {
        cin >> pic[i]+1;
    }
    int mx = -1;
    rep(i,1,N) {
        int res = solve(i);
        mx = max(mx,res);
    }
    cout << mx << endl;
}


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

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

  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >>  vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  

  long long mini = 10000000000;
  for(int j = vec.at(0);j <= vec.at(N-1);j++) {
    long long sum = 0;
    for(int i = 0;i < N;i++) {
      sum += (vec.at(i) - j) * (vec.at(i) - j);
    }
  mini = min(mini,sum);
  }

  cout << mini << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, b) for(int i = (a); i < (b); i++)
typedef long long ll;

int main() {
   int H, W, h, w;
   cin >> H >> W >> h >> w;

   cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int w = scan.nextInt();
			int h = scan.nextInt();
			if(w == 0 && h == 0){
				break;
			}
			char[][] tile = new char[w][];
			for(int i = 0;i < w;i++){
				tile[i] = scan.next().toCharArray();
			}
			int i = 0;
			int j = 0;
			int count = 0;
			boolean[][] fl = new boolean[w][h];
			while(true){
				count = (fl[i][j])?count+1:0;
				if(count > 1){
					System.out.println("LOOP");
					break;
				}
				fl[i][j] = true;
				if(tile[i][j] == '.'){
					System.out.println(j + " " + i);
					break;
				}else if(tile[i][j] == '>'){
					j++;
				}else if(tile[i][j] == '<'){
					j--;
				}else if(tile[i][j] == '^'){
					i--;
				}else if(tile[i][j] == 'v'){
					i++;
				}
			}
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  int count = 0;
  for(int j = 0;j < 100;j++) {
    bool finished = false;
    for(int k = 0;k < N;k++) {
      if(vec.at(k) % 2 == 1) {
        finished = true;
        break;
      }
      else {
      vec.at(k) = vec.at(k) / 2;
      }
    }
    if (finished) {
      break;
    }
      count++;
  }
   cout << count << endl;
}

Measured memory_bytes: 256
// B - Trained?
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi A(N); rp(i, 0, N){cin>>A[i]; --A[i];}
	vi visited(N, false);
	for(int t=0, a=0; !visited[a]; a=A[a], ++t){
		visited[a] = true;
		if(a == 1){
			cout<< t <<endl;
			return 0;
		}
	}
	cout<< -1 <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define ldb double
template<typename T>void ckmn(T&a,T b){a=min(a,b);}
template<typename T>void ckmx(T&a,T b){a=max(a,b);}
void rd(int&x){scanf("%i",&x);}
void rd(ll&x){scanf("%lld",&x);}
void rd(char*x){scanf("%s",x);}
void rd(ldb&x){scanf("%lf",&x);}
void rd(string&x){scanf("%s",&x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&i:x)rd(i);}
template<typename T,typename...A>void rd(T&x,A&...args){rd(x);rd(args...);}
template<typename T>void rd(){T x;rd(x);return x;}
int ri(){int x;rd(x);return x;}
template<typename T>vector<T> rv(int n){vector<T> x(n);rd(x);return x;}
const int base=1e9;
int main(){
	int n=ri();
	vector<ldb> v=rv<ldb>(n);
	vector<ll> a;
	for(auto i:v)a.pb(round(i*base));
	map<pii,int> cnt;
	for(ll i:a){
		//printf("%lld ",i);
		int t=0,f=0;
		while(i%2==0)i/=2,t++;
		while(i%5==0)i/=5,f++;
		cnt[{t,f}]++;
		//printf("%i %i\n",t,f);
	}
	ll ans=0;
	for(auto it:cnt){
		for(auto jt:cnt){
			if(it.first<jt.first){
				if(it.first.first+jt.first.first>=18&&it.first.second+jt.first.second>=18){
					ans+=(ll)it.second*jt.second;
				}
			}else if(it.first==jt.first){
				if(it.first.first+jt.first.first>=18&&it.first.second+jt.first.second>=18){
					ans+=(ll)it.second*(jt.second-1)/2;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6948
/*
    A - 753
    https://atcoder.jp/contests/abc114/tasks/abc114_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int x;
    cin >> x;
    if (x == 7 || x == 5 || x == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    cout << n*(n+1)/2;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,m; cin>>n>>m;
    vector<ll> a(n), t(n+1);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end());
    rep(i,n) t[i+1] = t[i]+a[i];

    auto check = [&](ll X) {
        ll cnt = 0;
        rep(i,n) {
            ll s = X-a[i];
            cnt += a.end()-lower_bound(a.begin(), a.end(), s);
        }
        if (cnt >= m) return true;
        else return false;
    };

    auto get_cnt = [&]() {
        ll ok = 0; ll ng = LINF;
        while (abs(ok-ng)>1) {
            ll mid = (ok+ng)/2;
            if (check(mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    };

    ll sm = get_cnt();
    ll rest = 0;

    auto get_sum = [&]() {
        ll ret = 0;
        rep(i,n) {
            ll A = a[i];
            ll s = sm-a[i];
            int ind = lower_bound(a.begin(), a.end(), s)-a.begin();
            rest += n-ind;
            ret += t[n]-t[ind];
            ret += (n-ind)*A;
        }
        return ret;
    };

    ll ans = get_sum();
    ans -= (sm*(rest-m));
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string s; cin >> s;
    int ans;
    if (s == "SSS") {
        ans = 0;
    } else if (s == "SSR" or s == "SRS" or s == "RSS" or s == "RSR") {
        ans = 1;
    } else if (s == "RRS" or s == "SRR") {
        ans = 2;
    } else {
        ans = 3;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,k;
    string s;
    vector<int> A;
    cin>>n>>k>>s;
    int a,b;
    rep(i,n){
        if(i==0){
            if(s[i]=='L') a=0;
            else a=1;
            b=1;
        }
        else{
            if(a==0&&s[i]=='R') A.push_back(b),a=1,b=1;
            else if(a==1&&s[i]=='L') A.push_back(b),a=0,b=1;
            else b++;
        }
    }
    A.push_back(b);
    int ans=0;
    for(auto i:A) ans+=i-1;
    cout<<ans+min(2*k,int(A.size())-1);
}

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

typedef long long ll;

ll gcd(ll n,ll m){
  if(m==0) return n;
  else return gcd(m,n%m);
}

ll lcm(ll n,ll m){
  return n/gcd(n,m)*m;
}

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll n=lcm(c,d);
  ll x=b/c-(a-1)/c;
  ll y=b/d-(a-1)/d;
  ll z=b/n-(a-1)/n;
  cout << (b-a+1)-(x+y-z) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
M = 0
for i in range(N):
  M += B[A[i] - 1]
  if i < N - 1 and A[i] + 1 == A[i + 1]:
    M += C[A[i] - 1]
print(M)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int m, g, s;
	while(cin >> m, m) {
		int a, b, dp[1010][7] = {};
		rep(i,m) {
			cin >> a >> b;
			rep2(j,1,b+1) {
				dp[a*j][i] = 1;
			}
			if(i!=0) {
				rep2(k,1,1001) {
					if(dp[k][i-1] != 0) {
						rep(l,b+1) {
							if(k+a*l <= 1000) dp[k+a*l][i] += dp[k][i-1];
						}
					}
				}
			}
		}
		cin >> g;
		rep(i,g) {
			cin >> s;
			cout << dp[s][m-1] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int x[3];
    rep(i, 3) cin >> x[i];
    sort(x, x + 3);
    if(x[0] == 5 && x[1] == 5 && x[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#スライス操作とbit全探索 
S = input()
N = len(S)
insert = []

#部分集合列挙 を応用し + の挿入位置を求める
for i in range(1<<(N-1)):
    #insert = []
    tmp = []
    for j in range(N-1):
        if ((i>>j) & 1) == 1:
            #何故か位置でなく値を格納した
            #tmp.append(int(S[j]))
            tmp.append(j+1)
    insert.append(tmp)
#print(insert)

#挿入位置をもとに文字列スライス。ここで苦労
split = []

for i in insert:
    s = []
    copy = S[:]
    prev = 0
    for j in i:
        #前の挿入位置を記録し次で利用すれば良い
        if not (S[prev:j] == ""):
            s.append(int(S[prev:j]))
            copy = S[j:]
            prev = j
    s.append(int(copy))
    split.append(s)    
#print(split)

res = 0
for a in split:
    res += sum(a)
print(res)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int X = sc.nextInt();
    	List<int[]> list = new ArrayList<>();
    	for (int i = 0; i < N; i++) {
    		int[] ar = new int[M + 1];
    		for (int j = 0; j < ar.length; j++) {
    			ar[j] = sc.nextInt();
    		}
    		list.add(ar);
    	}
    	List<List<int[]>> ptn = new ArrayList<>();
    	for (int i = 1; i < Math.pow(2, N); i++) {
    		List<int[]> p = new ArrayList<>();
    		for (int j = 0; j < N; j++) {
    			if ((1&(i>>j)) == 1) {
    				int[] array = list.get(j);
    				p.add(array);
    			}
    		}
    		ptn.add(p);
    	}
    	long cost = Long.MAX_VALUE;
    	boolean isEx = false;
    	for (List<int[]> p : ptn) {
    		int[] cont = new int[M + 1];
    		for (int[] a : p) {
    			for (int i = 0; i < a.length; i++) {
    				cont[i] += a[i];
    			}
    		}
    		boolean key = true;
    		for (int i = 1; i < cont.length; i++) {
    			if (cont[i] < X) {
    				key = false;
    			}
    		}
    		if (key && (cont[0] < cost)) {
    			cost = cont[0];
    			isEx = true;
    		}
    	}
    	System.out.println(isEx ? cost : -1);
    	
    }
}

Measured memory_bytes: 38176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int N, M, K;

int main() {
	fact_inv(1123456, MOD);
	
	cin >> N >> M >> K;
	
	ll ans = mod_pow(3, M + K, MOD), sum = 1;
	FOR(i, 1, M + K + 1) {
		sum *= 2;
		if (i > M) sum -= ncr(i - 1, M, MOD);
		if (i > K) sum -= ncr(i - 1, K, MOD);
		sum = (sum % MOD + MOD) % MOD;
		
		ll now = ncr(N - 1 + i, i, MOD) * mod_pow(3, M + K - i, MOD) % MOD * sum % MOD;
		ans = (ans + now) % MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
char b;
cin >> b;
if (b == 'A') {
    cout << 'T' << endl;
} else if (b == 'T') {
    cout << 'A' << endl;
} else if (b == 'C') {
    cout << 'G' << endl;
} else if (b == 'G') {
    cout << 'C' << endl;
}
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int n , ans ;
map <int , int> mark ;

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

	cin >> n ;

	while (n --) {
		int x ;
		cin >> x ;

		if (!mark.count(x)) {
			mark[x] = 1 ;
			ans ++ ;
		}
	}

	cout << ans << '\n' ;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N; cin >> N;
	VL x(N);
	FOR(i, 0, N) {
		cin >> x[i];
	}
	LL L, Q; cin >> L >> Q;

	// ダブリング
	// d[x][i]:=xから2^i回移動して移動可能な最長の頂点
	VVL d(N, VL(31, -1));
	FOR(i, 0, N) {
		int id = lower_bound(ALL(x), x[i] + L) - x.begin();
		if (id==N||x[id] - x[i] > L)id--;
		d[i][0] = id;
	}
	FOR(i, 0, 30) {
		FOR(j, 0, N) {
			d[j][i + 1] = d[d[j][i]][i];
		}
	}

	FOR(_, 0, Q) {
		int a, b; cin >> a >> b;
		a--, b--;
		if (a > b)swap(a, b);
		ans = 0;
		DD(de(a, "to", b));
		// 上から二分探索
		FORR(i, 30, 0 - 1) {
			if (b > d[a][i]) {
				ans += 1 << i;
				a = d[a][i];
				DD(de("step to", a));
			}
		}
		cout << ans +1<< "\n";

	}


	return 0;
}

Measured memory_bytes: 28928
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
d,x=get_i
a=array(n,1)
n.times do|i|
  a[i]=gets.to_i
end
ans=x
n.times do|i|
  j=1
  while j<=d
    ans+=1
    j+=(a[i]) 
  end
end
puts ans

Measured memory_bytes: 3836
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    money = 1000

    # 反省点:
    # 難しく考えすぎて、実装しきれなかった。
    # ある時点で最も安い値のときに買って、最も高いときに売る、という考え方をしていた。
    # 「何もしない」「買う」「売る」の3パターンを愚直に遷移させようとしていた。

    # KeyInsight:
    # 「i日目には、その時点で所持する金と株の範囲内で、M君は次の取引を何回でも行えます。」を、
    # = i日目の最初に全て売る + 必要に応じて買い戻す と言い換える。
    # See:
    # https://www.youtube.com/watch?v=z6SeLXdwVhA&feature=youtu.be

    for i in range(n - 1):
        today = a[i]
        tomorrow = a[i + 1]

        if tomorrow > today:
            count = money // today
            money %= today
            money += tomorrow * count

    print(money)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160