akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{


    class Program
    {

        static void Main(string[] args)
        {
            var NW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = NW[0];
            var W = NW[1];
            var wei = new List<long>[4];
            var val = new List<long>[4];

            for (int i = 0; i < 4; i++)
            {
                wei[i] = new List<long>();
                val[i] = new List<long>();
            }
            //最初の情報を格納
            var WV1 = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var wei1 = WV1[0];
            wei[0].Add(WV1[0]);
            val[0].Add(WV1[1]);
            for (int i = 1; i < N; i++)
            {
                var WV = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                var weight = WV[0];
                var value  = WV[1];
                wei[weight - wei1].Add(weight);
                val[weight - wei1].Add(value);
            }

            for (int i = 0; i < 4; i++)
            {
                val[i] = val[i].OrderByDescending(x => x).ToList();
            }

            var sum = 0L;
            for (int i = 0; i <= N && i <= val[0].Count; i++)
            {
                var Cumval1 = 0L;
                for (int p = 0; p < i; p++)
                {
                    Cumval1 += val[0][p];
                }
                for (int j = 0; j <= N-i && j <= val[1].Count; j++)
                {
                    var Cumval2 = Cumval1;
                    for (int p = 0; p < j; p++)
                    {
                        Cumval2 += val[1][p];
                    }
                    for (int k = 0; k <= N - i-j && k <= val[2].Count; k++)
                    {
                        var Cumval3 = Cumval2;
                        for (int p = 0; p < k; p++)
                        {
                            Cumval3 += val[2][p];
                        }
                        for (int l = 0; l <= N - i - j -k && l <= val[3].Count; l++)
                        {
                            var Cumval4 = Cumval3;
                            for (int p = 0; p < l; p++)
                            {
                                Cumval4 += val[3][p];
                            }
                            var souju = (i + j + k + l) * wei1 + i * 0 + j * 1 + k * 2 + l * 3;
                            if (souju <= W)
                            {
                                sum = Max(sum, Cumval4);
                            }
                        }
                    }
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13524
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int x;
int r[100000];
pii a[100000];
int k, q;
int em[100000], fu[100000];
int diff[100000];
int firstEmpty;
int mm[100000], ma[100000];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	firstEmpty = INF;
	scanf("%lld\n%lld", &x, &k);
	for (int i = 0; i < k; i++) scanf("%d", r + i);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) scanf("%d %d", &a[i].first, &a[i].second);
	em[0] = 0;
	fu[0] = x;
	for (int i = 1; i < k; i++) {
		if (i % 2 == 1) {
			em[i] = min(x, em[i - 1] + r[i] - r[i - 1]);
			fu[i] = min(x, fu[i - 1] + r[i] - r[i - 1]);
		} else {
			em[i] = max(0, em[i - 1] - r[i] + r[i - 1]);
			fu[i] = max(0, fu[i - 1] - r[i] + r[i - 1]);
		}
	}
	diff[0] = -r[0];
	for (int i = 1; i < k; i++) {
		if (i % 2 == 1) {
			diff[i] = min(x, diff[i - 1] + r[i] - r[i - 1]);
		} else {
			diff[i] = max(-x, diff[i - 1] - r[i] + r[i - 1]);
			if (diff[i] == -x) 
				firstEmpty = min(firstEmpty, r[i]);
		}
	}
	mm[0] = -r[0];
	ma[0] = diff[0];
	for (int i = 1; i < k; i++) mm[i] = min(mm[i - 1], diff[i]);
	for (int i = 1; i < k; i++) ma[i] = max(ma[i - 1], diff[i]);
	//for (int i = 0; i < k; i++) cout << r[i] << " " << diff[i] << " " << mm[i] << " " << ma[i] << " " << em[i] << " " << fu[i] << endl;
	for (int i = 0; i < q; i++) {
		if (a[i].first < r[0]) {
			printf("%d\n", max(0, a[i].second - a[i].first));
			continue;
		}
		int ll = 0, rr = k - 1;
		int ans = 0;
		while (ll <= rr) {
			int mid = (ll + rr) / 2;
			if (r[mid] <= a[i].first) {
				ans = mid;
				ll = mid + 1;
			} else rr = mid - 1;
		}
		if (a[i].second + ma[ans] >= x) {
			if (ans % 2 == 0) 
				printf("%d\n", min(x, fu[ans] + min(a[i].first - r[ans], x - fu[ans])));
			else
				printf("%d\n", max(0, fu[ans] - (a[i].first - r[ans])));	
		} else if (a[i].second + mm[ans] >= 0) {
			if (ans % 2 == 0) {
				int cur = min(x, a[i].second + diff[ans]);
				printf("%d\n", min(x, cur + min(a[i].first - r[ans], x - cur)));
			} else {
				int cur = min(x, a[i].second + diff[ans]);
				printf("%d\n", max(0, cur - (a[i].first - r[ans])));
			}
		} else {
			if (ans % 2 == 0) 
				printf("%d\n", min(x, em[ans] + min(a[i].first - r[ans], x - em[ans])));
			else
				printf("%d\n", max(0, em[ans] - (a[i].first - r[ans])));
		}
	}
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
  	cin >> N;
    cin >> K;
  	int height[100005];
    int dp[100005];
	for(int i = 0; i < N; i++){
    	cin >> height[i];
  }
  dp[0] = 0;
  for(int i = 1; i < K; i++){
    dp[i] = dp[i-1] + abs(height[i] - height[i-1]);
    for(int j = 2; j <= i; j++){
      if(dp[i] > dp[i-j] + abs(height[i] - height[i-j])){
        dp[i] = dp[i-j] + abs(height[i] - height[i-j]);
      }
    }
  } 
  for(int i = K; i < N; i++){
    dp[i] = dp[i-1] + abs(height[i] - height[i-1]);
    for(int j = 2; j <= K; j++){
      if(dp[i] > dp[i-j] + abs(height[i] - height[i-j])){
        dp[i] = dp[i-j] + abs(height[i] - height[i-j]);
      }
    }
  }

  /*
  for (int i=1; i<N; i++) {
    for (int j=1; j<K; j++) {
      if (i - j < 0) continue;

    }
  }
  */

  cout << dp[N-1];
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s;
    cin>>s;
    long long int k=s.size();
    
    for(long long int i=0;i<k;i++){
    	cout<<"x";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d);
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
double R;
	cin >> R;
	ce(2*R*3.1415926535)
    return 0;
}



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

int n, h, b[101010];

int main()
{
    cin >> n >> h;
    int ma = 0;
    rep(i, n)
    {
        int a;
        cin >> a >> b[i];
        ma = max(ma, a);
    }
    sort(b, b + n, greater<int>());

    int res = 0;
    rep(i, n)
    {
        if(b[i] < ma || h <= 0) break;
        h -= b[i];
        res++;
    }
    h = max(h, 0);
    res += (h + ma - 1) / ma;
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    double h,w,n; cin >> h >> w >> n;
    cout << ceil(n/max(h,w)) << endl;
}


Measured memory_bytes: 256
program red_scarf
  implicit none
  integer :: n, a(200000) = 0, i, x = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    x = xor(x, a(i))
  end do
  write(*,'(i0)',advance='no') xor(x, a(1))
  do i = 2, n
    write(*,'(x,i0)',advance='no') xor(x, a(i))
  end do
  write(*,*)
end program red_scarf

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    int nb_cas;
    cin>>nb_cas;
    while(nb_cas--)
    {
        double x1,y1,x2,y2,x3,y3;
        cin>>x1>>y1>>x2>>y2>>x3>>y3;
        double a1=(x2-x1)*2;
        double b1=(y2-y1)*2;
        double c1=x1*x1-x2*x2+y1*y1-y2*y2;
        double a2=(x3-x1)*2;
        double b2=(y3-y1)*2;
        double c2=x1*x1-x3*x3+y1*y1-y3*y3;
        double xc=(b1*c2-b2*c1)/(a1*b2-a2*b1);
        double yc=(c1*a2-c2*a1)/(a1*b2-a2*b1);
        double r=sqrt((x1-xc)*(x1-xc)+(y1-yc)*(y1-yc));
        cout<<fixed<<setprecision(3)<<xc<<" "<<yc<<" "<<r<<endl;
    }
}

Measured memory_bytes: 1296
A, B, K = map(int, input().split()) 
if A > B:
    S = B
else:
    S = A
num = 0
correct = []  
for i in range(1,S+1):      
    if A % i == 0 and B % i == 0:
        correct.append(i)
    else:
        pass  
correct.reverse()
print(correct[K-1]) 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k;
const int N=2e5+5;
ll r[N];
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&r[i]);
    ll maxx=0;
    for(int i=1;i<=k;i++)
    {
        maxx+=r[i];
    }
    ll maxn=maxx;
    for(int i=k+1;i<=n;i++)
    {
        maxx=maxx-r[i-k]+r[i];
        maxn=max(maxx,maxn);
    }
    double x=maxn*0.5+k*0.5;
    printf("%.12f",x);
    return 0;
}


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

using namespace std;
using Long = long long;

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

	Long n;
	cin >> n;

	cout << (n / 500ll) * 1000ll + ((n % 500ll) / 5ll) * 5ll;

	return 0;
}

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

using namespace std;

int main(void){
  int n,h,w;
  cin>>n;
  cin>>h;
  cin>>w;

  cout << (n-h+1)*(n-w+1) << endl;

  return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    if (N == K)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> num(200001);
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        num[A]++;
    }
    sort(num.begin(), num.end());

    int ans = 0;
    ans = accumulate(num.end() - K, num.end(), 0);
    ans = N - ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int N;
int num[256];
vector<char> mum[11];
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    char n;
    cin >> n;
    if( !(i&1) ) num[n]++;
  }
  for(int i='a';i<='z';i++){
    if( num[i] == 0 ) continue;
    //cout << (char)i << " "<< num[i] << endl;
    mum[num[i]].push_back( i );
  }
  bool f = false;
  int res = 0;
  for(int i=1;i<10;i++){
    //cout << mum[i].empty() << " "<<f << " " << i << " " << res << endl;
    if( mum[i].empty() ) continue;
    if( f ) res++;
    if( mum[i].size() == 1){      
      if( i == 1 ) res++;
      else res+=3;
    } else {
      if( i== 1 ) {
	for(int j=0;j<mum[i].size();j++){
	  if( j ) res++;
	  res++;
	}
      } else {
	res+=3;
	for(int j=0;j<mum[i].size();j++){
	  if( j ) res++;
	  res++;	  
	}
	res++;
      }
    }

    f = true;
  }
  cout <<res << endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    cout<< ceil(n/2.0);
}


Measured memory_bytes: 256
def main():
    mod = 10 **9 +7
    n=int(input())
    s=input()
    alp = [0 for i in range(26)]
    for i in range(n):
        alp[ord(s[i])-97] += 1
    ans = 1
    for i in range(26):
        ans *= (alp[i]+1)


    print((ans-1)%mod)

main()


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include <vector>
#include <set>
#include<queue>
#include<map>
using namespace std;
int main()
{
	long long n,a[1005];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int flag = 0;

	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
			{
				flag = 1;
				break;
			}
		}
	}
	if (flag == 1)
	{
		cout << "DENIED";
	}
	else
		cout << "APPROVED";
}

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    for (int i = 0; i < N; ++i) cout << (i == K - 1 ? std::string(1, tolower(S[i])) : std::string(1, S[i]));
    cout << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int L;
    static int[] A;

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

        N = sc.nextInt();
        L = sc.nextInt();
        A = sc.nextIntArray(N);

        PrintWriter pw = new PrintWriter(System.out);
        Answer answer = solve();
        if( answer != null ) {
            pw.println("Possible");
            for (Integer each : answer.values) {
                pw.println(each);
            }
        } else {
            pw.println("Impossible");
        }
        pw.flush();
    }

    static Answer solve() {
        int safe = -1;
        for (int i = 1; i <= N-1; i++) {
            if( A[i-1] + A[i] >= L ) {
                safe = i;
                break;
            }
        }
        if( safe == -1 ) return null;

        List<Integer> values = new ArrayList<>(N-1);

        for (int i = 1; i < safe; i++) {
            values.add(i);
        }
        for (int i = N-1; i > safe ; i--) {
            values.add(i);
        }
        values.add(safe);

        return new Answer(values);
    }

    static class Answer {
        List<Integer> values;

        public Answer(List<Integer> values) {
            this.values = values;
        }
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 43844
#include<iostream>
using namespace std;
int main() {
	int a, b, c,aa,bb,cc,n,nn;
	int ans[5][5];
	for (int i = 1; i <= 3; i++) {
		cin >> a >> b >> c >> aa >> bb >> cc;
		n = a * 3600;
		n = n + b * 60;
		n = n + c;
		nn = aa * 3600;
		nn = nn + bb * 60;
		nn = nn + cc;
		n = nn - n;
		ans[i][1] = 0;
		while (n >= 3600) {
			ans[i][1] = ans[i][1] + 1;
			n = n - 3600;
		}
		ans[i][2] = 0;
		while (n >= 60) {
			ans[i][2] = ans[i][2] + 1;
			n = n - 60;
		}
		ans[i][3] = n;
	}
	for (int i = 1; i <= 3; i++) {
		cout << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
	}
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int c[3][3];
    rep(i,3) {
        rep(j,3) {
            cin >> c[i][j];
        }
    }

    int x[3], y[3];
    x[0] = 0;
    rep(i,3) y[i] = c[0][i] - x[0];
    rep(i,3) x[i] = c[i][0] - y[0];
    bool good = true;
    rep(i,3) {
        rep(j,3) {
            if (x[i] + y[j] != c[i][j])
                good = false;
        }
    }
    if (good) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main() {
    int e;
    while (cin >> e, e) {
        int mn = e;
        for (int z=0; z*z*z<=e; z++) {
            for (int y=0; y*y<=e-z*z*z; y++) {
                int x = e - z*z*z - y*y;
                mn = min(x+y+z,mn);
            }
        }
        cout << mn << endl;
    }
    return 0;
}


Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr.begin(),arr.end());
	int sum=0;
	for(int i=0;i<min(k,n);i++){
		sum+=arr[i];
	}
	cout<<sum<<"\n";

}


Measured memory_bytes: 3672
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 300001
#define MOD 1000000007ll
using namespace std;
int A[100][100],B[100][100];
int n,m;
struct STACK{
    int cnt;
    int stk[6401*2+2];
}s[81][81];
bool vis[81][81][6401*2];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>A[i][j];
            s[i][j].cnt=0;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>B[i][j];
        }
    }
    
    s[1][1].cnt=2;
    s[1][1].stk[1]=A[1][1]-B[1][1];
    s[1][1].stk[2]=B[1][1]-A[1][1];
    for(register int i=1;i<=n;i++)
    {
        for(register int j=1;j<=m;j++)
        {   // cout<<i<<" "<<j<<":";
            
        
            for(register int k=1;k<=s[i][j].cnt;k++)
            {
                //cout<<s[i][j].stk[k]<<" ";
                if(j<m)
                {
                    int u=s[i][j].stk[k]+A[i][j+1]-B[i][j+1],v=s[i][j].stk[k]+B[i][j+1]-A[i][j+1];
                    if(!vis[i][j+1][u+6400])s[i][j+1].stk[++s[i][j+1].cnt]=u,vis[i][j+1][u+6400]=1;
                    if(!vis[i][j+1][v+6400])s[i][j+1].stk[++s[i][j+1].cnt]=v,vis[i][j+1][v+6400]=1;
                }
                if(i<n)
                {
                    int u=s[i][j].stk[k]+A[i+1][j]-B[i+1][j],v=s[i][j].stk[k]+B[i+1][j]-A[i+1][j];
                    if(!vis[i+1][j][u+6400])s[i+1][j].stk[++s[i+1][j].cnt]=u,vis[i+1][j][u+6400]=1;
                    if(!vis[i+1][j][v+6400])s[i+1][j].stk[++s[i+1][j].cnt]=v,vis[i+1][j][v+6400]=1;
                }
            }//cout<<endl;
        }
    }
    int ans=6400*2;
    for(int i=1;i<=s[n][m].cnt;i++)
    {
        //cout<<s[n][m].stk[i]<<endl;
        ans=min(ans,abs(s[n][m].stk[i]));
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 407168
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.math.BigDecimal;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String S = in.next();
            if(S.charAt(0)==S.charAt(2)){
                out.println("Yes");
            }
            else out.println("No");
            
        }
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 23380
#include<stdio.h>
#include<string.h>
int main(){
  int n,m,h,i,t,j,k;
  char s[150],a[150];
  while(scanf("%d %d",&n,&m),n||m){
    int c=n,f[1010]={0};
    t=-1;
    for(i=1;i<=m;i++){
      t++;
      while(f[t%=n])t++;
      scanf("%s",s);//printf("%s %d ",s,t);
      if     (i%15==0)h=strcmp(s,"FizzBuzz\0");
      else if(i%3 ==0)h=strcmp(s,"Fizz\0");
      else if(i%5 ==0)h=strcmp(s,"Buzz\0");
      else{
	k=0;
	for(j=i;j;j/=10)k++;
	a[k]=0;
	for(j=i;k;j/=10)a[--k]=j%10+'0';//printf("%s\n",a);
	h=strcmp(s,a);
      }//printf("%d\n",h);
      if(h)f[t]=1;
      c-=f[t];
      if(c==1)break;
    }//printf("i%d\n",i);
    while(i++<m)scanf("%*s");
    for(i=h=0;i<n;i++){
      if(f[i])continue;
      if(h)printf(" ");
      h=1;
      printf("%d",i+1);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vp ab(N);
  rep(i,N) {
    int a,b;
    cin >> a >> b;
    ab[i] = P(b,a);
  }
  sort(rng(ab));
  int lim = 0;
  rep(i,N) {
    int a = ab[i].second;
    int b = ab[i].first;
    if(b-a < lim) {
      cout << "No" << endl;
      return 0;
    }
    lim += a;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int dd; cin >> dd;
    vector<int> ar(26);
    rep(i,26) cin >> ar[i];
    vector<vector<int>> sc(dd,vector<int>(26));
    rep(i,dd) rep(j,26) cin >> sc[i][j];
    vector<int> la(26,0);
    rep(i,(dd-2)/3){
        int ma = -10000000;
        vector<int> ko(3);
        rep(a,26)rep(b,26)rep(c,26){
            vector<int> nla = la;
            vector<int> im = {a,b,c};
            int ima = 0;
            rep(j,3){
                ima += sc[3*i+j][im[j]];
                nla[im[j]] = 3*i+j+1;
                rep(k,26){
                    ima -= ar[k] * (3*i+j+1-nla[k]);
                }
            }
            if (ma < ima){
                ma = ima;
                ko = im;
            }
        }
        rep(j,3){
            la[ko[j]] = 3*i+j+1;
            cout << ko[j] + 1 << endl;
        }
    }
    rep(i,2){
        int ma = -10000000;
        int as = 0;
        int ima = 0;
        rep(j,26){
            ima += ar[j] * (dd-1+i - la[j]);
        }
        rep(j,26){
            int sp = sc[dd-2+i][j];
            sp -= ima;
            sp += ar[j] * (dd-1+i - la[j]);
            if (ma < sp){
                ma = sp;
                as = j+1;
            }
        }
        la[as-1] = dd-1+i;
        cout << as << endl;
    }
}

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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 1e6 + 5, MOD = 1e9 + 7  , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
int main(){

    fastio;
    int n;
    cin>>n;
    int a = n/500;
    n -= (a*500);
    int b = n/5;

    cout<<(a*1000 + b*5)<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int H,N;
  cin >> H >> N;
  for(int i=0,A;i<N;i++){
    cin >> A;
    H-=A;
  }
  if(H<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

# Aizu 507

class Array
    def sum
        inject(0){|sum,i| sum+i}
    end

    def last
        if size > 0
            self[size-1]
        else
            nil
        end
    end
end

# 紙の枚数の制約
def check(result,value)
    if result.sum+value > $n
        return false
    else
        return true
    end
end

def backtrack(n,result)
    if result.sum == $n
        puts result.join(" ")
        return
    end
    n.times.map{|i| i+1}.reverse.each do |i|
        if result.size>0 && result.last<i
            next
        end
        if check(result,i)
            result << (i)
            backtrack(n-1,result)
            result.pop
        end
    end
end

while(true)
    $n = gets().to_i
    break if $n==0

    result = []
    backtrack($n,[])
end

Measured memory_bytes: 2912
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

typedef long long lint;

const double EPS = 1e-10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, -1, 0};
const int INF = 1001001001;
const lint INFLL = 1001001001001001001ll;

#define zclear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))

#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int n, m;
int a[16], b[16];
int memo[1 << 12][12];

int getMax(int state, int u)
{
	if (u == m || __builtin_popcount(state) == n) return (0);
	if (memo[state][u] >= 0) return (memo[state][u]);
	
	int ans = getMax(state, u + 1);
	for (int i = 0; i < n; i++){
		if (state >> i & 1) continue;
		int p = abs(a[i] - b[u]);
		ans = max(ans, getMax(state | (1 << i), u + 1) + p * (p - 30) * (p - 30));
	}
	return (memo[state][u] = ans);
}

int main()
{
	while (scanf("%d %d", &n, &m) && n){
		for (int i = 0; i < n; i++) scanf("%d", a + i);
		for (int i = 0; i < m; i++) scanf("%d", b + i);
		
		memset(memo, -1, sizeof(memo));
		printf("%d\n", getMax(0, 0));
	}
	return (0);
}

Measured memory_bytes: 1392
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (1<<30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x,y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
    if ( !v.empty() ) {
        out << '[';
        copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


/* template end */


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

    int k;
    cin >> k;
#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif
    cout << (k / 2) * ((k + 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
const int maxN=1e5+7;
int N;
int p[maxN];
int pos[maxN];
int leftFirstMaxPos[maxN];
int rightFirstMaxPos[maxN];
ll ans=0;
int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>p[i];
		pos[p[i]]=i;
		leftFirstMaxPos[i]=i-1;
		rightFirstMaxPos[i]=i+1;
	}
	for(int i=1;i<=N;i++){
		int Lpos1=leftFirstMaxPos[pos[i]];
		int Lpos2=leftFirstMaxPos[Lpos1];
		int Rpos1=rightFirstMaxPos[pos[i]];
		int Rpos2=rightFirstMaxPos[Rpos1];
		if(Lpos1!=0)ans+=(long long)1*i*(Lpos1-Lpos2)*(Rpos1-pos[i]);
		if(Rpos1!=N+1)ans+=(long long)1*i*(pos[i]-Lpos1)*(Rpos2-Rpos1);
		leftFirstMaxPos[Rpos1]=Lpos1;
		rightFirstMaxPos[Lpos1]=Rpos1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>


int main(){
    int list[3];

    int l = sizeof(list)/sizeof(int);
    for(int i=0; i < l ;i++){
        scanf("%d", &list[i]);
    }

    for(int s = 0; s < l-1; s++){
        for (int j = l - 1; j >= s + 1; j--){
            if ( list[j] < list[j-1]){
                int tmp;
                tmp = list[j];
                list[j] = list[j-1];
                list[j-1] = tmp;
            }
        }
    }

    for(int j = 0; j < l-1; j++){
        printf("%d ", list[j]);
    }
    printf("%d\n", list[l-1]);
}



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

int main() {
  int x, y;
  cin >> x >> y;
  int n[] = {1,3,1,2,1,2,1,1,2,1,2};
  if (n[x - 1] == n[y - 1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int leftWhite = 0, rightRed = 0;
    for (auto c:s) {
        if (c == 'R')rightRed++;
    }

    int ret = rightRed;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W')leftWhite++;
        else rightRed--;
        int mi = min(leftWhite, rightRed);
        ret = min(ret, (leftWhite - mi) + (rightRed - mi) + mi);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3748
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    if P[i] > P[i-1] and P[i] > P[i+1]:
        continue
    elif P[i-1] < P[i] or P[i+1] < P[i]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
#define inf 1e18
const int mod=1e9+7;
const int N=2e5+9;
int a[N],b[N];

void raushan_kumar(){

    //variables
    int d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m,n,o=0,p=0,q=0,r=0,u=0,v=0,w=0,x=0,y=0,z=0,t=0;
    double f1=0.0,f2=0.0,f3=0.0,f4=0.0,f5=0.0,f6=0.0;
    int flag=0,ans=0,res=0,cnt=0;

    string s;cin>>s;
    fo0(i,s.length()){
        if(s[i]=='7'){
            flag=1;
        }
    }
    if(flag)
        cout<<"Yes";
    else{
        cout<<"No";
    }
    
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif
    fast;int t=1;
    //cin>>t;
    while(t--){
        raushan_kumar();
    }

}


Measured memory_bytes: 3636
from collections import deque


def solve(n, u, v, edge_list):
    # graph
    g = [[] for i in range(n)]
    for a, b in edge_list:
        g[a].append(b)
        g[b].append(a)

    # root at v
    parent = [0] * n
    depth = [0] * n
    parent[v] = -1
    queue = deque([v])
    while len(queue) > 0:
        p = queue.popleft()
        for q in g[p]:
            if parent[p] != q:
                parent[q] = p
                depth[q] = depth[p] + 1
                queue.append(q)

    # collect max_depth from leaf
    temp_list = [[i, -depth[i]] for i in range(n)]
    temp_list = list(sorted(temp_list, key=lambda x: x[1]))
    run_list = [temp_list[i][0] for i in range(n)]
    max_children_depth = depth.copy()
    for i in run_list[:-1]:
        max_children_depth[parent[i]] = max(max_children_depth[parent[i]], max_children_depth[i])
    # print(depth)
    # print(max_children_depth)
    du = depth[u]
    up = u
    res = 0
    if du > 2:
        for _ in range((du - 1) // 2):
            up = parent[up]
            res += 1
    res += max_children_depth[up] - depth[up]
    if du % 2 == 0:
        res += 1
    return res


def main():
    n, u, v = map(int, input().split())
    edge_list = [[0, 0] for _ in range(n - 1)]
    for i in range(n - 1):
        a, b = map(int, input().split())
        edge_list[i][0] = a - 1
        edge_list[i][1] = b - 1
    u -= 1
    v -= 1
    res = solve(n, u, v, edge_list)
    print(res)


def test():
    assert solve(5, 3, 0, [[0, 1], [1, 2], [2, 3], [2, 4]]) == 2
    assert solve(5, 3, 4, [[0, 1], [0, 2], [0, 3], [0, 4]]) == 1
    assert solve(2, 0, 1, [[0, 1]]) == 0


if __name__ == "__main__":
    test()
    main()


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

using namespace std;

int main(void)
{
	int a, b, c, d, l;
	
	scanf("%d\n%d\n%d\n%d\n%d", &l, &a, &b, &c, &d);
	
	printf("%d\n", l - max((a + c - 1) / c, (b + d - 1) / d));
	
	return (0);
}

Measured memory_bytes: 1024
def gene(n,leng):
    r = []
    for i in range(leng):
        r.append(n)
        n = 1 - n
    return r

def nuri(lis):
    zerone = gene(0,len(lis))
    zo = 0
    onezero = gene(1,len(lis))
    oz = 0

    for i in range(len(lis)):
        if zerone[i] != lis[i]:
            zo += 1
        if onezero[i] != lis[i]:
            oz += 1
    if zo < oz:
        ans = zo
    else:
        ans = oz
    return ans

        

tyle = list(input())
tyle = [int (i) for i in tyle]
print(nuri(tyle))

Measured memory_bytes: 5404
# a <= b <= cとする
a, b, c = gets.chomp.split(' ').map(&:to_i).sort
count = 0

# aを+2でbに追いつかせる
# +1せざるをえないときはcとセットで増やす
if (b - a) % 2 == 1 then
  count += 1
  a += 1
  c += 1
end
count += (b - a) / 2

# aとbを+1でcに追いつかせる
count += (c - b)

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;
const ll MO = 1000000007;


int main(){
    int n;cin >> n;
    set<string> s;
    rep(i,n){
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
    return 0;
}

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

int main()
{
	vector<int> a(4), b = { 1, 9, 7, 4 };
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	puts(a == b ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = (input())
c = (input())
d = (input())
count = 0
for i in range(a):
    if b[i] == c[i] == d[i]:
        count += 0
    elif b[i] == c[i] or b[i] == d[i]  or  c[i] == d[i]:
        count += 1
    else:
        count += 2
print(count)


Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum=0;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
    sum+=v[i];
  }
  int ave1=sum/N,ave2=sum/N+1;
  int cost1=0,cost2=0;
  for (int x : v){
    cost1+=(x-ave1)*(x-ave1);
  }
  for (int x : v){
    cost2+=(x-ave2)*(x-ave2);
  }
  if (cost1<cost2){
    cout << cost1 << endl;
  }
  else {
    cout << cost2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int V, E, root;
    cin >> V >> E >> root;
    vector<vector<P> > g(V);
    for(int i=0;i<E;i++){
        int s, t, d;
        cin >> s >> t >> d;
        g[s].push_back({t, d});
    }
    vector<ll> dist(V, IINF);
    dist[root] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push({0,root});
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(auto e : g[v]){
            ll u = e.first, d = e.second;
            if(dist[u] > dist[v] + d){
                dist[u] = dist[v] + d;
                que.push({dist[u], u});
            }
        }
    }
    for(int i=0;i<V;i++){
        if(dist[i] < IINF){
            cout << dist[i] << endl;
        }
        else{
            cout << "INF" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 19328
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> p;
  REP(i, n) {
    ll a;
    cin >> a;
    p.push_back(make_pair(a, i));
  }
  sort(ALL(p));
  REP(i, n) { cout << p[i].second + 1 << " "; }
  return 0;
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
const ll MOD=1e9+7;
const ll A=0,C=1,G=2,T=3;
bool OK(ll i,ll j,ll k,ll l){
	if(i==A&&j==G&&k==C)return false;
	if(i==A&&j==C&&k==G)return false;
	if(i==G&&j==A&&k==C)return false;
	if(j==A&&k==G&&l==C)return false;
	if(j==A&&k==C&&l==G)return false;
	if(j==G&&k==A&&l==C)return false;
	if(i==A&&k==G&&l==C)return false;
	if(i==A&&j==G&&l==C)return false;
	return true;
}

int main(){
	ll N;
	cin >> N;
	if(N==3){cout<<61<<endl;return 0;}
	ll dp[N+1][4][4][4][4]={};
	FOR(i,0,4)FOR(j,0,4)FOR(k,0,4)FOR(l,0,4){
		if(OK(i,j,k,l))dp[4][i][j][k][l]=1;
	}
	ll ans=0;
	FOR(t,5,N+1){
		FOR(h,0,4)FOR(i,0,4)FOR(j,0,4)FOR(k,0,4)FOR(l,0,4){
			if(OK(i,j,k,l))
			(dp[t][i][j][k][l]+=dp[t-1][h][i][j][k])%=MOD;
		}
	}
	FOR(i,0,4)FOR(j,0,4)FOR(k,0,4)FOR(l,0,4){
		if(OK(i,j,k,l))
		(ans+=dp[N][i][j][k][l])%=MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <valarray>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

int main() {
	string s, t;
	char a;
	cin >> s >> t;
	a = t[t.size() - 1];
	if (s + a == t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
int n,play[2],m,card[100001];
int h[501],w[501],na[2];
int p[2][501][501];
bool b[1000001];
int check(int x){
  map<int,pair<int,int> >ma;
  memset(h,0,sizeof(h));
  memset(w,0,sizeof(w));
  memset(b,0,sizeof(b));
  memset(na,0,sizeof(na));
  r(i,n)r(j,n)ma[p[x][i][j]]=mk(i,j),b[p[x][i][j]]=1;
  r(i,m)if(b[card[i]]){
    int f=ma[card[i]].fi,ans=0;
    int s=ma[card[i]].se;
    h[f]++;w[s]++;
    if(f==s)na[0]++;
    if(f+s==n-1)na[1]++;
    r(i,n)if(h[i]>=n)ans++;
    r(i,n)if(w[i]>=n)ans++;
    r(i,2)if(na[i]>=n)ans++;
    if(n==1&&ans/4>=play[x])return i;
    if(n!=1&&ans>=play[x])return i;
  }
  return 1e9;
}
main(){
  cin>>n>>play[0]>>play[1]>>m;
  r(k,2)r(i,n)r(j,n)cin>>p[k][i][j];
  r(i,m)cin>>card[i];
  int usagi=check(0);
  int neko=check(1);
  if(usagi==neko)cout<<"DRAW"<<endl;
  else if(usagi<neko)cout<<"USAGI"<<endl;
  else cout<<"NEKO"<<endl;
}

Measured memory_bytes: 14700