akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	double l;
	cin >> l;
	cout << setprecision(15) << l * l * l / 27.0 << endl;
	ggr
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  string s;
  int o = 0;
  int e = 0;
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    int d = s[i] - '0';
    o += (d == i%2);
    e += (d != i%2);
  }
  cout << min(o, e) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 512
x = gets.to_i
is_exp_arr = Array.new(x+1, false)
is_exp_arr[1] = true
(2..x).each do |b|
  p = 2
  while (a = b ** p)  <= x do
    is_exp_arr[a] = true
    p += 1
  end
end
puts is_exp_arr.map.with_index { |e, i| e ? i : nil }.compact.max


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

int main(){
  int h, w; cin >> h >> w;
  char a[h][w];
  int row[h]={}, col[w]={};
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> a[i][j];
      if(a[i][j]=='#') {
        row[i] = 1;
        col[j] = 1;
      }    
    }
  }
  for(int i=0; i<h; i++) {
    if(row[i]==1) {
      for(int j=0; j<w; j++) {
        if(col[j]==1) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }  
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

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

int main(){

    int D,N,X[20][20]={},ans=0;
    cin>>N>>D;

    for(int i=1;i<=N;i++){
        for(int j=1;j<=D;j++){
            cin>>X[i][j];
        }
    }

    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            //X[i][]とX[j][]を比較
            int sum=0;
            for(int k=1;k<=D;k++){
                sum+=abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
            }
            double d=sqrt(sum);

            if(d==floor(d)){
                ans++;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T

main :: IO ()
main = do
    n <- readLn
    s <- T.getLine
    putStrLn $ solve n s

solve :: Int -> T.Text -> String
solve n s = if odd n then "No"
            else if T.take (n `div` 2) s == T.drop (n `div` 2) s then "Yes"
            else "No" 

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    cin >> A >> B;
    
    if(A/(B*2) == 0)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << A - (B * 2) << endl;
    }
}


Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
using namespace std;
double a,s;int c;
main()
{
    while(cin>>a)
    {
        s=a;
        for(c=2;c<=10;c++)a=c%2?a/3:a*2,s+=a;
        cout<<fixed<<setprecision(9)<<s<<endl;
    }
}


Measured memory_bytes: 3240
import scala.io.{StdIn => in}

object Main extends App {
  val Array(h, w, d) = in.readLine.split(" ").map(_.toInt)
  case class Point(x:Int, y:Int) {
    def -(that: Point): Point = new Point(x - that.x, y - that.y)
    def mDist(): Int = this.x.abs + this.y.abs
  }
  val table = Array.ofDim[Point](h*w+1)
  val grid = Iterator.continually(in.readLine)
    .take(h)
    .map(_.split(" ").map(_.toInt))
    .toArray
  
  for{
    i <- 0 until h
    j <- 0 until w
  } table(grid(i)(j)) = new Point(y = i, x = j)


  val res = Array.ofDim[Int](h*w+1)
  for(i <- 1 to h*w-d) {
    res(i+d) = res(i) + (table(i+d) - table(i)).mDist 
  }

  val out = new java.io.PrintWriter(System.out)
  val q = in.readInt
  Iterator.continually(in.readLine)
    .take(q)
    .map(_.split(" ")map(_.toInt))
    .foreach (e => {
      val l = e(0)
      var r = e(1)
      out.println(res(r) - res(l))
    })
  out.flush
}

Measured memory_bytes: 53488
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int a,b,c, x;
  int ans = 0;
  cin >> a >> b >> c >> x;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(i*500+j*100+k*50 == x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, t, a;
    cin >> n >> t >> a;
    int h[1010];
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }
    double tem[1010];
    double ans=10000000.0;
    int ansPoint=-1;
    for(int i=1; i<=n; i++){
        tem[i] = (double)t-h[i]*0.006;
        if(ans>=abs(a-tem[i])){
            ans=abs(a-tem[i]);
            ansPoint = i;
        }
    }
    cout << ansPoint << endl;
    return 0;
}

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

using namespace std;

const int N = 1e5 + 5;
int dp[N];
int a[N];

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

	for(int i = 1; i <= n; i++)
		cin >> a[i];

	for(int i = 2; i <= n; i++){
		dp[i] = 2e9;
		for(int j = 1; j <= k; j++){
			if(i - j < 1) continue;
			dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout << dp[n] << endl;
}

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

int main(){
    int n;

    while(true){
        vector<int> point;
        int data;
        int ave=0;

        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0; i<n; i++){
            cin>>data;
            point.push_back(data);
        }
        sort(point.begin(), point.end());
        for(int i=1; i<point.size()-1; i++){
            ave+=point[i];
        }
        cout<<ave/(point.size()-2)<<endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};
string S;
int N, M;

int main() {
    cin >> N >> M >> S;
    reverse(S.begin(), S.end());
    int pos = 0;
    vector<int> res;
    while (pos <= N) {
        int n = pos;
        REP(i, M) {
            if (pos + (M - i) == N) {
                res.emplace_back(N - pos);
                REP(k, res.size()) {
                    cout << res[res.size() - k - 1] << " ";
                }
                cout << endl;
                return 0;
            }
            if (S[pos + (M - i)] == '0') {
                pos += (M - i);
                res.emplace_back(M - i);
                break;
            }
        }
        if(pos == n )break;
    }
    cout << -1 << endl;
    return 0;
}


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

int main(int argc, char** argv)
{
	const int array[] = { 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, 40000, 40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 43681, 44100, 44521, 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, 65536, 66049, 66564, 67081, 67600, 68121, 68644, 69169, 69696, 70225, 70756, 71289, 71824, 72361, 72900, 73441, 73984, 74529, 75076, 75625, 76176, 76729, 77284, 77841, 78400, 78961, 79524, 80089, 80656, 81225, 81796, 82369, 82944, 83521, 84100, 84681, 85264, 85849, 86436, 87025, 87616, 88209, 88804, 89401, 90000, 90601, 91204, 91809, 92416, 93025, 93636, 94249, 94864, 95481, 96100, 96721, 97344, 97969, 98596, 99225, 99856 };
	char a[10], b[10];
	int x;
	int i;
	const char* answer = "No";

	scanf("%s%s", a, b);
	strcat(a, b);
	x = atoi(a);
	for (i = 0; i < sizeof(array) / sizeof(*array); ++i) {
		if (x == array[i]) {
			answer = "Yes";
			break;
		}
	}
	printf("%s\n", answer);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	map<string, int> m;
	forn(i, n) {
		string t;
		cin >> t;
		m[t]++;
	}
	int mx = 0;
	for(auto i : m)
		mx = max(mx, i.se);
	for(auto i : m)
		if(i.se == mx)
			cout << i.fi << endl;
	return 0;
}



Measured memory_bytes: 19256
n = gets.to_i
x, l = n.times.map{gets.split.map(&:to_i)}.transpose
count = 1
arm = n.times.map{|i| [x[i]-l[i], x[i]+l[i]]}.sort

(n-1).times do |i|
  if arm[i][1] <= arm[i+1][0]
    count+= 1
  elsif arm[i][1] < arm[i+1][1]
    arm[i+1][1] = arm[i][1]
  end
end

puts count

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n,m; cin>>n>>m;
    vvint edges(n);
    vint deg(n,0);

    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        if(a>b) swap(a,b);
        edges[a].push_back(b);
        edges[b].push_back(a);
        deg[a]++;
    }

    vint dist(n,-1);
    queue<ll> q;
    q.push(0);
    dist[0] = 0;

    while(!q.empty()){
        ll now = q.front(); q.pop();

        for(auto to:edges[now]){
            if(dist[to] == -1){
                dist[to] = dist[now]^1;
                q.push(to);
            }else{
                if(dist[to]^dist[now] == 1){
                    continue;
                }else{
                    cout<<n*(n-1)/2 - m<<endl;
                    return 0;
                }
            }
        }
    }

    vint cnt(2,0);
    for(auto e:dist) cnt[e]++;
    // printv(dist);
    // printv(cnt);
    ll ans = cnt[0]*cnt[1] - m;
    cout<<ans<<endl;


    return 0;

}

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

ll gcd(double x, double y)
{
	ll m = (int)floor(x);
	ll n = (int)floor(y);
	ll r;

	do {
		r = m % n;
		m = n;
		n = r;
	} while (r != 0);

	return m;
}

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

cout<<(a*b)/gcd(a,b)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){


    int c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    int b2_b1 = c[0][1] - c[0][0];
    int b3_b2 = c[0][2] - c[0][1];
    for(int i = 0; i < 3; i++){
        if(c[i][1] - c[i][0] != b2_b1){
            cout << "No" << endl;
            return 0;
        }
        if(c[i][2] - c[i][1] != b3_b2){
            cout << "No" << endl;
            return 0;
        }
    }

    b2_b1 = c[1][0] - c[0][0];
    b3_b2 = c[2][0] - c[1][0];
    for(int i = 0; i < 3; i++){
        if(c[1][i] - c[0][i] != b2_b1){
            cout << "No" << endl;
            return 0;
        }
        if(c[2][i] - c[1][i] != b3_b2){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;


}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,a,b,c,i,j,cnt;
    int t_a,t_b,t_c;
    long long ans=100000000,tmp;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    int t[n];
    for(i=0;i<n;i++) scanf("%d",&t[i]);
    for(i=0;i<(1<<(n*2));i++){
        tmp=i,cnt=0,t_a=0,t_b=0,t_c=0;
        for(j=0;j<n;j++){
            switch(tmp&3){
                case(1):
                    t_a+=t[j];
                    if(t_a!=t[j]) cnt+=10;
                    break;
                case(2):
                    t_b+=t[j];
                    if(t_b!=t[j]) cnt+=10;
                    break;
                case(3):
                    t_c+=t[j];
                    if(t_c!=t[j]) cnt+=10;
                    break;
            }
            tmp /= 4;
        }
        if(t_a==0 || t_b==0 || t_c==0) continue;
        tmp = abs(a-t_a)+abs(b-t_b)+abs(c-t_c)+cnt;
        if(ans>tmp) ans=tmp;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int A,B,C,a,b,c;
int ans;
int binom[105][105],f[105][105],g[105][105];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
int Calc(int a,int A,int b,int B) {
    int res = 0;
    update(res,mul(b,fpow(a,B / b)));
    update(res,mul(a,fpow(b,A / a)));
    update(res,MOD - mul(a,b));
    return res;
}
void Trivial() {
    update(ans,mul(c,fpow(Calc(a,A,b,B),C / c)));
    update(ans,mul(b,fpow(Calc(a,A,c,C),B / b)));
    update(ans,mul(a,fpow(Calc(b,B,c,C),A / a)));
    update(ans,MOD - mul(mul(b,c),fpow(a,B / b * C / c)));
    update(ans,MOD - mul(mul(a,c),fpow(b,A / a * C / c)));
    update(ans,MOD - mul(mul(a,b),fpow(c,A / a * B / b)));
    update(ans,mul(mul(a,b),c));
    
}
void Solve() {
    Trivial();
    binom[0][0] = 1;
    for(int i = 1 ; i <= 100 ; ++i) {
	binom[i][0] = 1;
	for(int j = 1 ; j <= i ; ++j) {
	    binom[i][j] = inc(binom[i - 1][j - 1],binom[i - 1][j]);
	}
    }
    for(int i = 0 ; i <= A / a ; ++i) {
	for(int j = 0 ; j <= B / b ; ++j) {
	    int t = 1;
	    for(int k = 0 ; k <= i ; ++k) {
		int tmp = inc(fpow(c,i - k),MOD - 1);
		tmp = fpow(tmp,j);
		update(g[i][j],mul(mul(tmp,binom[i][k]),t));
		t = mul(t,MOD - 1);
	    }
	}
    }
    int all = 0;
    for(int i = 1 ; i <= A / a ; ++i) {
	for(int j = 1 ; j <= B / b ; ++j) {
	    if(i == A / a && j == B / b) continue;
	    int k = fpow(a,j),t = fpow(b,i);
	    update(f[i][j],fpow(inc(inc(k,t),MOD - 1),C / c));
	    update(f[i][j],MOD - fpow(k,C / c));
	    update(f[i][j],MOD - fpow(t,C / c));
	    update(f[i][j],1);
	    int tmp = mul(f[i][j],mul(binom[A / a][i],binom[B / b][j]));
	    tmp = mul(tmp,c);
	    tmp = mul(tmp,g[A / a - i][B / b - j]);
	    update(all,tmp);
	}
    }
    all = mul(all,mul(a,b));
    update(ans,all);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(a);read(b);read(c);read(A);read(B);read(C);
    if(A % a == 0 && B % b == 0 && C % c == 0) Solve();
    else puts("0");
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int C,E;
} box_t;

int qsc(const void *x,const void *y) {
	int a=*((int*)x);
	int b=*((int*)y);
	if(a>b)return -1;
	if(a<b)return 1;
	return 0;
}

int qsc2(const void *x,const void *y) {
	int a=((box_t*)x)->C;
	int b=((box_t*)y)->C;
	if(a>b)return -1;
	if(a<b)return 1;
	return 0;
}

int M,N;
int P[10001];
box_t b[500];

int memo[10010][510];

int search(int man,int box) {
	int ret=0,retc;
	int d;
	if(box>=N || man>M)return 0;
	if(memo[man][box]>0)return memo[man][box]-1;
	/* hachuu sinai */
	ret=search(man,box+1);
	/* hachuu suru */
	d=b[box].C;
	if(man+d>M+1)d=M+1-man;
	retc=search(man+d,box+1)+(P[man+d-1]-P[man-1])-b[box].E;
	if(retc>ret)ret=retc;
	memo[man][box]=ret+1;
	return ret;
}

int main(void) {
	int i;
	if(scanf("%d%d",&M,&N)!=2)return 1;
	for(i=1;i<=M;i++) {
		if(scanf("%d",&P[i])!=1)return 1;
	}
	for(i=0;i<N;i++) {
		if(scanf("%d%d",&b[i].C,&b[i].E)!=2)return 1;
	}
	qsort(P+1,M,sizeof(P[0]),qsc);
	qsort(b,N,sizeof(b[0]),qsc2);
	for(i=1;i<=M;i++)P[i]+=P[i-1];
	printf("%d\n",search(1,0));
	return 0;
}

Measured memory_bytes: 20660
#include<iostream>
#include<vector>
#define INF 1e9+11

int main()
{
	int n, k;
	std::cin >> n;

	std::vector<int>first(n+1, 0);
	std::vector<int>second(n+1, 0);
	std::vector<int>third(n+1, 0);

	for(int i = 1; i <= n; i++)
	{
		int a, b, c;
		std:: cin >> a >> b >> c;

		int newA = a + std::max(second[i-1], third[i-1]);
		first[i] = newA;

		int newB = b + std::max(first[i-1], third[i-1]);
		second[i] = newB;

		int newC = c + std::max(second[i-1], first[i-1]);
		third[i] = newC;
	}

	std:: cout << std::max(std::max(second[n], third[n]), first[n]);
	return 0;
}

Measured memory_bytes: 1408
def solve(f, i = 0, j = 0)
  return false if f[i][j] == '.'
  return 1 if i == f.size - 1 && j == f[0].size - 1

  r1 = false
  r2 = false
  if i + 1 < f.size && f[i+1][j] == '#'
    res = solve(f, i + 1, j)
    r1 = 1 + res if res
  end

  if j + 1 < f[0].size && f[i][j + 1] == '#'
    res = solve(f, i, j + 1)
    r2 = 1 + res if res
  end

  if r1 && r2
    return [r1, r2].max
  end

  return r1 if r1
  return r2 if r2

  false
end

r, c = gets.strip.split(' ').map(&:to_i)
a = []
1.upto(r) do
  a << gets.strip
end
r = solve(a)
printf("%s\n", r && a.flatten.join('').count('#') == r ? "Possible" : "Impossible")


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){

int N, L;
cin >> N >> L;

vector<string> S(N);
REP(i, N) cin >> S.at(i);

sort(all(S));

REP(i, N) cout << S.at(i);

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,x,y;
	for(int t=1;;t++)
	{
		scanf("%d %d",&i,&j);
		if(i==0&&j==0) break;
		for(x=1;x<=i;x++)
		{
			for(y=1;y<=j;y++)
			{
				if((x>=2&&x<=i-1)&&(y>=2&&y<=j-1)) printf(".");
				else printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100005
#define rep(i,j,k) for(i=j;i<=k;++i)
int n,i,j,k,top,up,right;
int a[N],x[N<<1],y[N<<1];
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0'; x=getchar();}
}
bool cmp(int a,int b){ return a>b; }
int main(){
	read(n);
	rep(i,1,n) read(a[i]);
	sort(a+1,a+1+n,cmp);
	top++; x[1]=0; y[1]=a[1];
	rep(i,1,n)
	if(a[i]!=a[i+1]){
		top++; x[top]=i; y[top]=a[i];
		top++; x[top]=i; y[top]=a[i+1];
	}
	rep(i,1,top)
	if(y[i]-x[i]==0){
		if(y[i]==a[x[i]]){
			puts("Second");
		}else{
			up=((y[i-1]-y[i])&1)?1:0;
			right=((x[i+1]-x[i])&1)?1:0;
			if(up || right) puts("First");
			else puts("Second");
		}
		break ;
	}else
	if(y[i]-x[i]<0){
		if(a[x[i-1]]==y[i-1]){
			if((y[i-1]-x[i-1])&1) puts("First");
			else puts("Second");
		}else{
			if((x[i]-y[i-1])&1) puts("First");
			else puts("Second");
		}
		break ;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    ll n,k;cin>>n>>k;
    ll c=0;
    rep(i,0,n)
    {
        ll h;cin>>h;
        if(h>=k)
            c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;
vector<P> vec[200010], peo[200010];
ll bit[100010], num;
ll par[100010], sz[100010];
ll n, k, a[100010];
ll dp[110][100010];

struct edge { ll to, cost; };
ll V;
vector<edge> G[300010];
ll d[300010];

ll root(int x) { // �f�[�^x��������؂̍����ċA�œ���Froot(x) = {x�̖؂̍�}
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) { // x��y�̖؂𕹍�
	int rx = root(x); //x�̍���rx
	int ry = root(y); //y�̍���ry
	if (rx == ry) return; //x��y�̍�������(=�����؂ɂ���)���͂��̂܂�
	par[rx] = ry; //x��y�̍��������łȂ�(=�����؂ɂȂ�)���Fx�̍�rx��y�̍�ry�ɂ���
}

bool same(int x, int y) { // 2�̃f�[�^x, y��������؂������Ȃ�true��Ԃ�
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}

void dijkstra(ll s)
{
	priority_queue<P, vector<P>, greater<P>> que;
	for (int i = 0; i <= 300010; i++)
	{
		d[i] = INF;
	}
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		ll v = p.second;
		if (d[v] < p.first) continue;
		for (ll i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			(dp[i + 1][j] += dp[i][j]) %= mod;
			if (j + a[i] + 1 <= k)
			{
				dp[i + 1][j + a[i] + 1] += mod;
				(dp[i + 1][j + a[i] + 1] -= dp[i][j]) %= mod;
			}
		}
		for (int j = 1; j <= k; j++)
		{
			(dp[i + 1][j] += dp[i + 1][j - 1]) %= mod;
		}
	}
	cout << dp[n][k] << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 99840
a, b, c, d = map(int, input().split())
a_b = [i for i in range(a, b+1)]
c_d = [i for i in range(c, d+1)]
counter = -1
flg = "False"

for i in range(len(a_b)):
  for j in range(len(c_d)):
    if a_b[i] == c_d[j]:
      counter += 1
      flg = "True"

if flg == "True":
  print(counter)
else:
  print(0)

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#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)

int main()
{
    lint h,a;cin >> h>>a;
    lint ans=0;
    ans = h / a;
    ans += (h % a != 0);

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>

#define ASDF (1000000007)
#define MODADD(A, B) (A = (A + B) % ASDF)

long modpow(long src, long pow, long mod)
{
    long res = 1;
    while (0 < pow) {
        if (pow % 2 == 1) {
            res = (res * src) % mod;
            pow--;
        }
        src = (src * src) % mod;
        pow /= 2;
    }
    return res;
}

long modinv(long src, long mod)
{
    return modpow(src, mod - 2, mod);
}

long getgcd(long a, long b) {
    while (0 < a && 0 < b) {
        if (a < b)
            b = b % a;
        else
            a = a % b;
    }
    return std::max(a, b);
}

std::vector<int> getFlags(long long value)
{
    std::vector<int> ret;
    if (value <= 0) {
        ret.resize(1, 0);
        return ret;
    }
    int digit = 0;
    long long tmpval = value;
    while (0 < tmpval) {
        digit++;
        tmpval /= 2;
    }
    ret.resize(digit, 0);
    for (int i = digit - 1; 0 <= i; i--) {

        long long a = 1;
        for (int j = 0; j < i; j++) {
            a *= 2;
        }
        a--;
        if (a < value) {
            long long rem = value - a;
            if (rem % 2 == 1) {
                ret[i] = 1;
            }
            if (i > 1)
                value = rem - 1;
            else
                value = rem;
        }
        //if (1 == i) {
        //    ret[0] = value % 2;
        //}
    }
    if (value % 2 != 0) ret[0] = 1;
    return ret;
}

int main(void)
{
    /*
    n, a,b,c,d,e=io.read("*n","*n","*n","*n","*n","*n")

st1,st2,st3,st4,st5,st6 = {n},{0},{0},{0},{0},{0}
t = 1

while(st6[t] ~= n) do
    t = t + 1
    mv6 = math.min(st5[t-1], e)
    mv5 = math.min(st4[t-1], d)
    mv4 = math.min(st3[t-1], c)
    mv3 = math.min(st2[t-1], b)
    mv2 = math.min(st1[t-1], a)
    st6[t] = st6[t-1] + mv6
    st5[t] = st5[t-1] + mv5 - mv6
    st4[t] = st4[t-1] + mv4 - mv5
    st3[t] = st3[t-1] + mv3 - mv4
    st2[t] = st2[t-1] + mv2 - mv3
    st1[t] = st1[t-1] - mv2
end
print(t - 1)
    */
    long long n, a, b, c, d, e;
    std::cin >> n;// >> a >> b >> c >> d >> e;
    std::vector<long long> costs;
    for (int i = 0; i < 5; i++) {
        long long l;
        std::cin >> l;
        costs.push_back(l);
    }
    std::sort(costs.begin(), costs.end());
    long long worst = costs.front();
    if (n % worst == 0) {
        std::cout << n / worst + 4 << std::endl;
    }
    else {
        std::cout << n / worst + 5 << std::endl;
    }
    //		std::cout << std::fixed << std::setprecision(8) << d * (1.0 + a / (1.0 * b)) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 #define rep(i, n) for (int i = A; i <=B; i++)
 
int main() {
  int sum,A,B,a,b,c,d,e,T;
  sum=0;
  cin >> A >> B;
  rep(i,B-A+1){
    e=i%10;
    T=i/10;
    d=T%10;
    T=T/10;
    c=T%10;
    T=T/10;
    b=T%10;
    T=T/10;
    a=T%10;
    if ((a==e) && (b==d))
      sum++;
  }
  cout << sum << endl;  
}

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

char ttt(string& s)
{
  for (int i = 0; i < 9; i+=3) {
    if (s[i] != 's' && s[i] == s[i+1] && s[i] == s[i+2])
      return s[i];
  }
  for (int i = 0; i < 3; i++) {
    if (s[i] != 's' && s[i] == s[i+3] && s[i] == s[i+6])
      return s[i];
  }
  if (s[4] != 's'
        && ((s[4] == s[0] && s[4] == s[8])
            || (s[4] == s[2] && s[4] == s[6])))
    return s[4];
  return 'd';
}

int main(int argc, char **argv)
{
  string s;
  while (cin >> s) {
    cout << ttt(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
int main(void){
	int W,H,x,y,r,f = 1;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((W<(x+r)) || (0>(x-r))){
	f = 0;
	}
	if((H<(y+r)) || (0>(y-r))){
	f = 0;
	}
	if(f==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}
		

Measured memory_bytes: 584
#include<iostream>
#include<string>
using namespace std;
int summ(string,string);
int NtoM(string);
void MtoN(int);
int main(){
  int n,ans;
  string a,b;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    ans=summ(a,b);
    MtoN(ans);
  }
  return 0;
}
int summ(string a,string b){
  return  NtoM(a)+NtoM(b);
}
int NtoM(string a){
  int st=1;
  int x=0;
  for(int i=0;i<a.size();i++){
    if(a[i]>='0'&&a[i]<='9'){
      st=a[i]-'0';
    }
    else{
      if(a[i]=='m'){
	x+=st*1000;
      }
      else if(a[i]=='c'){
	x+=st*100;
      }
      else if(a[i]=='x'){
	x+=st*10;
      }
      else if(a[i]=='i'){
	x+=st;
      }
      st=1;
    }
  }
  return x;
}
void MtoN(int a){
  string x;
  x.clear();
  if(a/1000!=0){
    if(a/1000!=1)
      x+='0'+a/1000;
    x+='m';
    a%=1000;
  }
  if(a/100!=0){
    if(a/100!=1)
      x+='0'+a/100;
    x+='c';
    a%=100;
  }  
  if(a/10!=0){
    if(a/10!=1)
      x+='0'+a/10;
    x+='x';
    a%=10;
  }
  if(a!=0){
    if(a!=1)
      x+='0'+a;
    x+='i';
  }
  cout << x << endl;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int n[4];
int main(){ _;
  REP(i,4)cin>>n[i];
  sort(n,n+4);
  if(n[0]==1&&n[1]==4&&n[2]==7&&n[3]==9){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 20001;
ll n,a[N],w=0;
ll used[30003];
ll gojo(ll x,ll y){
	if(y>x){
		ll w=x;
		x=y;
		y=w;
	}
	ll w=1;
	while(w!=0){
		w=x%y;
		x=y;
		y=w;
	}
	return x;
}


int main(){
	cin>>n;
	FOR(i,0,30003)used[i]=false;
	a[0]=2;
	w=2;
	used[2]=true;
	ll i=1,k=3;
	while(n-i!=1){
		if(k%3==0||k%2==0){
			used[k]=true;
			a[i]=k;
			i++;
			w+=k;
		}
		k++;
	}
	FOR(j,4,30001){
		if(used[j]==true)continue;
		bool ok=true;
		FOR(l,0,i){
			if(gojo(w+j-a[l],a[l])==1){
				ok=false;
				break;
			}
		}
		if(ok&&gojo(w,j)!=1){
			cout<<a[0];
			FOR(bb,1,i){
				cout<<" "<<a[bb];
			}
			cout<<" "<<j<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int DP[1<<20];
int main() {
  // ios_base::sync_with_stdio(0);

  int N;
  scanf("%d", &N);
  REP(i,N+1) DP[i] = i;
  for (int i = 6; i <= N; i *= 6) {
    FOR(j,i,N+1) DP[j] = min(DP[j], DP[j-i] + 1);
  }
  for (int i = 9; i <= N; i *= 9) {
    FOR(j,i,N+1) DP[j] = min(DP[j], DP[j-i] + 1);
  }
  printf("%d\n", DP[N]);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    string s, ans = "No";
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] and s[1] != s[2] and s[2] == s[3]) {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((a>0)||(abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D&lang=jp
#  Areas on the Cross-Section Diagram : python3
#  2018.11.27 yonezawa


from collections import deque
import heapq
import sys
input = sys.stdin.readline


def main():
    q = deque()
    m = str(input()).strip()
    dq = []
    count = 0
    for i in range(len(m)):
        if (m[i] == "\\" ):
            q.append(i)
            continue
        if (m[i] == "/" and len(q) > 0):
            j = q.pop()
            count += i - j
            #dq.append((j,i))
            dq.append((j,i))
    print (count)
    if (len(dq) == 0):
        print (0)
        return

    l = []
    dq.sort()
    dq.reverse()
    (a,b) = dq.pop()
    
    score = b - a
    while len(dq) > 0:
        (i,n) = dq.pop()
        if ( b > i ):
            score += n - i
        else:
            l.append(score)
            score = n - i
            a = i
            b = n
    else:
        l.append(score)

    print (len(l),*l)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7092
import java.time.chrono.MinguoChronology;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for(int count =0; count < 4; count++) {
			list.add(a);
			list.add(b);
			list.add(c);
			list.add(d);
		}
		int mitasu = 0;
		int countAns = 0;
		boolean one = false;
		boolean seven = false;
		boolean nine = false;
		boolean forth = false;
		
		for(int youso: list) {
			if(youso == 1 && !one) {
				one = true;
				countAns++;
			}
			if(youso == 7 && !seven) {
				seven = true;
				countAns++;
			}
			if(youso == 9 && !nine) {
				nine = true;
				countAns++;
			}
			if(youso == 7 && !forth) {
				forth = true;
				countAns++;
			}
		}
		
		if(countAns == 4) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


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

int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	int pre[5];
	pre[0] = abs(a - b);
	pre[1] = abs(a - c);
	pre[2] = abs(b - c);
	sort(pre,pre + 3);
	cout<<pre[0]+pre[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 1
a = [0 for i in range(n+1)]
for k in range(1,n+1):
    i = k
    while i % 2 == 0:
        a[2] += 1
        i //= 2
    j = 3
    while j ** 2 <= i:
        if i % j == 0:
            a[j] += 1
            i //= j
        else:
            j+=2
    if i != 1:
        a[i]+=1
for i in a:
    if i != 0:
        ans *= (i+1)
        ans %= (10**9+7)
print(ans)

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

const string Yes = "Yes";
const string No = "No";

void solve(ll N, ll M, vector<ll> A)
{
    sort(A.begin(),A.end(),greater<int>());
    int sum = accumulate(A.begin(),A.end(),0);
    if(A[M-1] * 4 * M < sum)cout<<No<<endl;else cout<<Yes<<endl;
}


int main()
{
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(N);
    for(int i = 0 ; i < N ; i++)
    {
        cin >> A[i];
    }
    solve(N, M, move(A));
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int N, K;
    string S;
    cin >> N;
    cin >> S;
    cin >> K;

    char targetChar = S[K - 1];

    for (size_t i = 0; i < N; i++) {
        if (S[i] != targetChar) {
            S[i] = '*';
        }
    }
    cout << S << endl;

    return 0;
}

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

import static java.lang.Integer.parseInt;

/**
 * Spellcasters
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, S;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			S = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | S) == 0) break;

			int[] r = new int[101];

			for (int i = 0; i < n; i++) {
				r[parseInt(br.readLine())]++;
			}

			long count = 0;

			for (int i = S / 2; i <= 100; i++) {
				if (i * 2 > S) count += r[i] * (r[i] - 1) / 2;
			}

			for (int i = 1; i < 100; i++) {
				for (int j = i + 1; j <= 100; j++) {
					if (i + j > S) count += r[i] * r[j];
				}
			}

			System.out.println(count);
		}
	}
}

Measured memory_bytes: 56460
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	char s[110], c;
	int l = 0;
	while((c=getchar()) != '\n') s[l++] = c;
	

	ll ans = 1e11;
	rep(x, 0, l){
		c = s[x];
		int cnt = 0;
		V a;
		rep(i, 0, l){
			if(s[i]!=c) cnt++;
			else{
				if(cnt) a.push_back(cnt);
				cnt = 0;
			}
		}
		if(cnt) a.push_back(cnt);
		
		ll tmp = 0;
		for(ll x: a) tmp = std::max(tmp, x);
		ans = std::min(ans, tmp);
	}
	printf("%ld\n", ans);
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << ((n + 999) / 1000) * 1000 - n;
    return 0;
}


Measured memory_bytes: 3628
import itertools
n = input()
dp = [[[[[0] * 2 for i in range(2)] for j in range(2)] for k in range(2)]for l in range(len(n))]
#dp[i桁目][nより小さいかどうか][3がある][5がある][7がある]

for i in range(len(n)):
    dp[i][0][0][0][0] = 1

for j in range(10):
    if int(n[0]) >= j:
        dp[0][int(n[0]) == j][j == 3][j == 5][j == 7] = 1
dp[0][1][0][0][0] = 0

for i, j, k, l, m in itertools.product(range(len(n)-1), range(2), range(2), range(2), range(10)):
    if m in [3, 5, 7]:
        dp[i + 1][0][j or m == 3][k or m == 5][l or m == 7] += dp[i][0][j][k][l]
        if m <= int(n[i+1]):
            dp[i + 1][m == int(n[i+1])][j or m == 3][k or m == 5][l or m == 7] += dp[i][1][j][k][l]

print(dp[-1][0][1][1][1] + dp[-1][1][1][1][1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 4294967296
#define MAX 100001
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end()
int main()
{ 
  #ifdef sublime
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
     boost; 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a+b)>(c+d))
    {
          cout<<"Left"<<endl;
    }
    else if((a+b)==(c+d))
    {
          cout<<"Balanced"<<endl;
    }
    else if((a+b)<(c+d))
    {
          cout<<"Right"<<endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
    using namespace std;
    int main(){
      int n,i;
      cin>>n;
      char s[n];
      for(i=0;i<n;i++){
        cin>>s[i];
      }
      int sum=1;
      for(i=1;i<n;i++){
        if(s[i]!=s[i-1])
          sum++;
      }
      cout<<sum<<"\n";
      return 0;
    }

Measured memory_bytes: 384
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__


h,w,k = map(int, input().split())
sx,sy,gx,gy = map(lambda x: int(x)-1, input().split())
board = [list(map(lambda x: int(x=="."), input())) for i in range(h)]
inf = 1<<30
DP = [[inf for j in range(w)] for i in range(h)]
DP[sx][sy] = 0

que = [(sx,sy)]
dxdy = [(0,1),(1,0),(0,-1),(-1,0)]
for x,y in que:
    for dx,dy in dxdy:
        nx,ny = x,y
        for i in range(k):
            nx += dx
            ny += dy
            if not(0<=nx<h and 0<=ny<w and board[nx][ny] and DP[nx][ny] >= DP[x][y]+1):
                break
            if DP[nx][ny] == DP[x][y]+1:
                continue
            DP[nx][ny] = DP[x][y]+1
            que.append((nx,ny))
ans = DP[gx][gy]
if ans == inf:
    ans = -1
print(ans)


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

class UnionFind {
public:
    vector<int> parents, rank;

    UnionFind(int n) : parents(n), rank(n) {
        for (int i = 0; i < n; i++) {
            parents[i] = i;
            rank[i] = 0;
        }        
    }

    int root(int x) {
        if (parents[x] == x) { // root
            return x;
        } else {
            return parents[x] = root(parents[x]);
        }
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            parents[x] = y;
        } else {
            parents[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
};

int main() {

    int N, M; cin >> N >> M;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i]; p[i]--;
    }

    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        uf.unite(x-1, y-1);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == p[i] || uf.isSame(i, p[i])) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int m,f,r;
  for( ; ; ){
    cin >> m >> f >> r;
    if(m==-1 && f==-1 && r==-1) break;
    
    if(m==-1 || f==-1){
      cout << 'F';
    }else if(m+f<30){
      cout << 'F';
    }else if(m+f<50 && m+f>=30 && r>=50){
	cout << 'C';
      }else if(m+f<50 && m+f>=30){
	  cout << 'D';
	}else if(m+f<65 && m+f>=50){
	    cout << 'C';
	  }else if(m+f<80 && m+f>=65){
	    cout << 'B';
	  }else if(m+f>=80){
	    cout << 'A';
	  }
	  cout << endl;
	  }
	return 0;
	}

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

void Main() {
  int n;
  std::cin >> n;
  int l[n];
  for (int i = 0; i < n; i++) {
    std::cin >> l[i];
  }

  std::sort(l, l + n);
  int r = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
          r++;
        }
      }
    }
  }

  std::cout << r << std::endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256