akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;

fn main() {
    input! {
        // s: String
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    println!("{}", max(a * b, c * d));
}


Measured memory_bytes: 2116
/*||>>>> Praveen Ojha <<<<>>>> 10 June 2019 <<<<>>>> 01:44:56 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int maxn=2222;
char gg[maxn][maxn];
int lef[maxn][maxn],rig[maxn][maxn],dow[maxn][maxn],up[maxn][maxn];
int32_t main(){__
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>gg[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(gg[i][j]=='.'){
				up[i][j]=up[i-1][j]+1;
				lef[i][j]=lef[i][j-1]+1;
			}
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=m;j>=1;j--){
			if(gg[i][j]=='.'){
				dow[i][j]=dow[i+1][j]+1;
				rig[i][j]=rig[i][j+1]+1;
			}
		}
	}
	int maxi=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(gg[i][j]=='.'){
				maxi=max(maxi,up[i][j]+dow[i][j]+lef[i][j]+rig[i][j]-3);
			}
		}
	}
	cout<<maxi<<"\n";
return 0;
}

Measured memory_bytes: 150656
package main

import (
	"fmt"
)

func main() {
	var W, a, b int
	fmt.Scan(&W, &a, &b)
	if a > b {
		a, b = swap(a, b)
	}
	if b > a+W {
		fmt.Println(b - a - W)
	} else {
		fmt.Println(0)
	}
}
func swap(a, b int) (int, int) {
	if a > b {
		t := a
		a = b
		b = t
	}
	return a, b
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App02
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] W = Console.ReadLine().Split(' ');
            int[] inW = new int[N];
            int result = 100;

            for(int i = 0; i < N; i++)
            {
                inW[i] = int.Parse(W[i]);
            }

            for(int t = 1; t < N; t++)
            {
                int S1 = 0;
                int S2 = 0;
                for(int i = 0; i < t; i++)
                {
                    S1 += inW[i];
                }
                for(int i = t; i < N; i++)
                {
                    S2 += inW[i];
                }
                int sub = Math.Abs(S1-S2);
                result = Math.Min(result, sub);
            }
            Console.WriteLine($"{result}");
        }
    }
}


Measured memory_bytes: 11220
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    R, C, N = ILI()
    num_point = []
    for __ in range(N):
        x_1, y_1, x_2, y_2 = ILI()
        num_point.append([(x_1, y_1), (x_2, y_2)])
    return R, C, N, num_point


# 周上を (0, 0) を原点として反時計回りに 1 本の数直線とした時の point の座標を返す．
# 周上にあるかの判定も行う．
def change_edge_point(R, C, point):
    x, y = point
    if x == 0:
        return R * 2 + C + (C - y)
    if x == R:
        return R + y
    if y == 0:
        return x
    if y == C:
        return R + C + (R - x)


def solve(R, C, N, num_point):
    point_double = []
    for ind, point in enumerate(num_point):
        p_1, p_2 = point
        if ((p_1[0] == 0 or p_1[0] == R) or (p_1[1] == 0 or p_1[1] == C)) and ((p_2[0] == 0 or p_2[0] == R) or (p_2[1] == 0 or p_2[1] == C)):
            point_double.append((ind + 1, change_edge_point(R, C, p_1)))
            point_double.append((ind + 1, change_edge_point(R, C, p_2)))
    point_double.sort(key=lambda  x: x[1])
    stack = []
    for point in point_double:
        if len(stack) == 0:
            stack.append(point[0])
            continue
        if point[0] == stack[-1]:
            stack.pop()
        else:
            stack.append(point[0])
    
    if len(stack) == 0:
        return "YES"
    else:
        return "NO"
    

def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 66028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n, m, l;
ll a[101][101], b[101][101];

int main(){
	std::cin >> n >> m >> l;
	rep(i, n)rep(j, m)std::cin >> a[i][j];
	rep(i, m)rep(j, l)std::cin >> b[i][j];
	rep(i, n){
		rep(j, l){
			ll sum = 0;
			rep(k, m)sum += a[i][k] * b[k][j];
			if (j != l - 1)std::cout << sum << " ";
			else std::cout << sum;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n, q,num=0;
	int a[10000], b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		scanf("%d", &b);
		for (int j = 0; j < n; j++) {
			if (b == a[j]) {
				num++;
				break;
			}
		}
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 3232
san=tyo=ei=don=0
while true
    a,b,c=gets.split.map(&:to_i).sort
    if c<a+b
        san+=1
        cos_sgn=a**2+b**2-c**2
        if cos_sgn==0
            tyo+=1
        elsif cos_sgn>0
            ei+=1
        else
            don+=1
        end
    else
        printf("%d %d %d %d\n",san,tyo,ei,don)
        break
    end
end



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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl

const long long MOD = 1000000007;


int main(){
    ll n, m;
    cin >> n >> m;
    ll x[m];
    rep(i, m){
        cin >> x[i];
    }
    sort(x, x+m);

    if(n >= m){
        cout << 0 << endl;
        return 0;
    }

    ll d = x[m-1] - x[0];
    vector<ll> v;
    for(ll i = 1; i < m; i++){
        v.push_back(x[i]-x[i-1]);
    }
    sort(v.begin(), v.end());
    rep(i, n-1){
        d -= v.back();
        v.pop_back();
    }

    cout << d << endl;
    
    return 0;
}


Measured memory_bytes: 2168
a = input()

b =  ['R','U','D']
c =  ['L','U','D']
f= 0
for n,x in enumerate(a):
    if n%2==0 and x not in b : f = 1
    elif n%2==1 and x not in c : f = 1
def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
y(f)

Measured memory_bytes: 3064
import sys
import itertools
import math

N = int(sys.stdin.readline())

towns = []
for _ in range(N):
    x, y = map(int, sys.stdin.readline().split(" "))
    towns.append((x, y))

dist = 0
count = 0
patterns = itertools.permutations(towns)
for pattern in patterns:
    count += 1
    pre_x, pre_y = 0, 0
    for i, (x, y) in enumerate(pattern):
        if i > 0:
            dist += math.sqrt((x - pre_x)**2 + (y - pre_y)**2)
        pre_x, pre_y = x, y

print(dist / count)

Measured memory_bytes: 40940
import sys
k = 1

while k == 1:
    r = raw_input()
    H, W = r.split()
    H = int(H)
    W = int(W)
    
    if H == 0 and W == 0:
        k = 0
    else:
        for i in range(H):
            for j in range(W):
                sys.stdout.write("#")
            print ("")
        print("")

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

int cost[90003] = {0};

int distance(pair<int, int> a, pair<int, int> b){
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    map<int, pair<int,int>> mp;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            int a;
            cin >> a;
            mp[a] = make_pair(i, j);
        }
    }

    for(int i=1;i<=d;++i){
        cost[i] = 0;
        for(int j=i+d;j<=h*w;j+=d){
            cost[j] = cost[j-d] + distance(mp[j-d], mp[j]);
        }
    }

    int q;
    cin >> q;
    for(int i=0;i<q;++i){
        int l, r;
        cin >> l >> r;
        cout << cost[r] - cost[l] << endl;
    }

    return 0;
}


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


ll d[5002];
ll dm[5002];

int main(int argc, char const *argv[])
{
    int k, q;
    cin >> k >> q;
    rep(i, k) {
        cin >> d[i];
    }
    rep(i, q) {
        ll n, x, m;
        cin >> n >> x>>m;
        ll nn = n-1;
        rep(j, k) {
            dm[j] = d[j] % m;
        }
        x %= m;
        int n_0 = 0;
        rep(j, k) {
            if(dm[j] == 0) n_0++;
        }
        n_0 *= nn / k;
        rep(j, nn%k) {
            if(dm[j] == 0) n_0++;
        }
        ll a_nm1 = x;
        for (int j = 0; j < nn%k; j++)
        {
            a_nm1 += dm[j] * (nn/k+1);
        }
        for(int j= nn%k; j<k; j++) {
            a_nm1 += dm[j] * (nn/k);
        }
        int ans = a_nm1 / m - x/ m;
        ans = (n-1) - n_0 - ans;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] cnt = new long[5];
		for (int i = 0; i < n; i++) {
			char ch = sc.next().charAt(0);
			if (ch == 'M') cnt[0]++;
			if (ch == 'A') cnt[1]++;
			if (ch == 'R') cnt[2]++;
			if (ch == 'C') cnt[3]++;
			if (ch == 'H') cnt[4]++;
		}
		sc.close();

		int c = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] > 0) c++;
		}
		if (c < 3) {
			System.out.println(0);
			return;
		}

		long ans = 0L;
		for (int i = 0; i < cnt.length; i++) {
			for (int j = i + 1; j < cnt.length; j++) {
				for (int k = j + 1; k < cnt.length; k++) {
					ans += cnt[i] * cnt[j] * cnt[k];
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 43808
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long a,b,c,d;
long long gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	scanf("%lld%lld%lld%lld",&b,&a,&c,&d);
	ll m=gcd(c,d);
	long long num=a/c-(b-1)/c+a/d-(b-1)/d-a/(c*d/m)+(b-1)/(c*d/m);
	printf("%lld\n",a-b+1-num);
	return 0;
}

Measured memory_bytes: 384
import java.io.*;

public class Main{
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] array = input.split(" ");
        int x = Integer.parseInt(array[0]);
        int a = Integer.parseInt(array[1]);

        if(x < a){
            System.out.println(0);
        }else{
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define L(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long 
#define endl '\n'   
using namespace std;
const int N = 1e5+7;
int  n, a,b,x;
ull sum = 0;
int main()
{
	IO
		cin >> n;
	int  arr[N];
	L(i, n+1)
		cin >> arr[i];
	L(i, n)
	{
		cin >> x;
		sum += min(x, arr[i]);
		x -= min(x, arr[i]);
		arr[i] -= min(x, arr[i]);
		if (x > 0 )
		{
			sum += min(arr[i+1],x);
			arr[i + 1] -= min(arr[i + 1], x);
		}
		
	}
	cout << sum << "\n";
}

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

vector<int> GetBigInteger(string str) 
{ 
    int x = str.size(), f = 0; 
  
    // Create an array to store the big 
    // integer into it. 
  
    // Make the array size same as the 
    // size of string str 
    vector<int> arr(str.size()); 
  
    // Loop to extract string elements 
    // into the array one by one 
    while (f != x) { 
  
        // Subtracting '0' to convert 
        // each character into digit 
  
        // str[a] - '0' 
        // = ASCII(str[a]) - ASCII('0') 
        // = ASCII(str[a] - 48 
        arr[f] = str[f] - '0'; 
        f++; 
    } 
    return arr;
}


int main() {
        string str;
        cin>>str;
        vector<int> a = GetBigInteger(str);
        long long int s=0;
        for(int i=0;i<str.size();i++)
        s = s + a[i];
        if(s%9==0)
        cout<<"Yes";
        else
        cout<<"No";
	    return 0;
}

Measured memory_bytes: 4436
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rept(i,s,n) for (int i = (s); i < (n); ++i)

#include <iostream>
#include <cmath>
#include <bitset>
#include <algorithm>
using namespace std;

int main() {

  int a, b, k;
  cin >> a >> b >> k;
    int cnt = 0;
    int i = 101;
    
    while(cnt<k && i>=1){
        --i;
        if(a%i==0 && b%i==0){
            cnt++;
        }
    }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int n;
	double x[10];
	string u[10];
	double ans = 0;
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY")ans += x[i];
		else ans += x[i] * 380000.0;
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import sys

def main():
    a = sys.stdin.readline().strip()
    # [int(i) for i in sys.stdin.readline().strip().split()]
    # [[int(i) for i in sys.stdin.readline().strip().split()] for _ in range(2)]
    f = 'Good'
    for i in range(3):
        if a[i] == a[i+1]:
            f = 'Bad'

    print(f)

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define I inline void

using namespace std ; 

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

// How Interesting!

const int N = 1e5 + 7 ; 

int n; 

int las[22] , slas[22] ; 

int main(){

	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in" ,"r" , stdin) ;

	memset(las , -1 , sizeof las) ; 
	memset(slas , -1 , sizeof slas) ; 

	cin >> n; 

	ll ans = 0 ; 
	for(int i = 0 ; i < n;i++){
		ll x;  
		cin >> x ; 
		ll mn = -1 ; 
		for(int j = 0 ; j < 20 ;j ++){
			if(x&(1<<j))
				mn = max(mn , (ll) las[j]) ; 
			else 
				mn = max(mn , (ll) slas[j]) ; 
		}
		ans+= i - mn ; 
		for(int j = 0 ;j < 20 ; j++){
			if(x &(1<<j)){
				slas[j] = las[j] ; 
				las[j] = i ; 
			}
		}
	}
	cout<< ans ; 

	return 0; 
}

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

int main() {
    int n;
    cin>>n;
    vector<long> S(n);
    for(int i=0;i<n;++i){
        cin>>S[i];
    }
    int q;
    cin>>q;
    vector<long> T(q);
    for(int i=0;i<q;++i){
        cin>>T[i];
    }
    sort(S.begin(), S.end());
    long ans = 0;
    int l, r, m;
    for(int i=0;i<q;++i){
        l = 0;
        r = n-1;
        while(l<r){
            m = (l+r)/2;
            if(S[m] < T[i]){
                l = m+1;
            }
            else{
                r = m;
            }
        }
        if(S[l] == T[i])ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3792
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    var aaa = chunk.toString();
    var line = aaa.split("\n")
    line.pop();
    for(var i in line){
        var l = line[i].split(" ")
        var num1 = new Number (l[0]);
        var num2 = new Number(l[1]);
        var num = num1+num2
        //num.toString();
        console.log(String(num).length);
    }
});

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

#define sz(s) (int)(s).size()
#define sqr(x) (x) * (x)
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define pi acis(-1)
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 1000000007
#define nol(a) memset(a, 0, sizeof(a))
#define minus(a) memset(a, 0xff, sizeof(a))
#define eb emplace_back
#define file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)


using namespace std;
template <typename _T>inline void read(_T &f){f = 0; _T fu = 1; char c = getchar();while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar();}    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar();}f *= fu;}
template <typename T>void print(T x){if (x < 0) putchar('-'), x = -x;if (x < 10) putchar(x + 48);else print(x / 10), putchar(x % 10 + 48);}
template <typename T> void print(T x, char t){print(x); putchar(t);}
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
template<class T>void eras(vector<T>& a,T b){a.erase(find(a.begin(),a.end(),b));}

typedef long long ll;
vector <ll> vll;
ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
string to_upper(string a)
{
	for (int i = 0; i < (int)a.size(); ++ i) if (a[i] >= 'a' && a[i] <= 'z') a[i] -= 'a' - 'A';
	return a;
}
string to_lower(string a)
{
	for (int i = 0; i < (int)a.size(); ++ i) if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 'a' - 'A';
	return a;
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int h1, m1, h2, m2, k, ans1 = 0;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	if (h1 < h2)
	{
		ans1 = (h2 - h1) * 60;
	}
	else
	if (h1 == h2)
	{
		ans1 = 0;
	}
	else
	{
		h2 += 24;
		ans1 = (h2 - h1) * 60;
	}
	ans1 += m2;
	ans1 -= m1;
	ans1 -= k;
	if (ans1 > 0)
		cout << ans1;
	else
		cout << 0;





}



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

int main(){
  int A[4]; cin >> A[0] >> A[1] >> A[2] >> A[3];
  sort(A,A+4);
  if(A[0]==1&&A[1]==4&&A[2]==7&&A[3]==9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

#define ll long long

int main(void){
	int n;
	cin >> n;
	vector<int> slime(n);
	for(int i= 0;i < n;i++)
		cin >> slime[i];
	vector<vector<ll> > dp(n, vector<ll>(n)); // x -> y substring - value
	vector<ll> pref_sum(n);
	pref_sum[0] = slime[0];
	for(int i = 1;i < n;i++)
		pref_sum[i] = pref_sum[i-1]+slime[i];
	for(int slen = 2;slen <= n;slen++){
		for(int start = 0;start <= n-slen;start++){
			int end = start+slen-1;
			ll minn = LLONG_MAX;
			for(int first_len = 1;first_len <= slen-1;first_len++){ // first substring, second substring
				ll first_ans = dp[start][start+first_len-1];
				ll second_ans = dp[start+first_len][end];
				minn = min(minn, first_ans + second_ans + (pref_sum[end] - pref_sum[start] + slime[start]));
			}
			dp[start][end] = minn;
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> a >> b;


    cout << a * b << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;

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

int main(){
    int n;
    cin >> n;
    vector<int> v = {}, c = {};
    REP(i, n){ int x; cin >> x; v.push_back(x); }
    REP(i, n){ int y; cin >> y; c.push_back(y); }

    int ans = 0;
    REP(i, n){
        if(v[i]-c[i]>0)ans += v[i] - c[i];
    }
    cout << ans << "\n";
    return 0;
}

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

int main(int argc, char** argv){
	int n;
	cin >> n;
	map<string,long long> m;
	long long ans=0;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		m[s] += 1;
	}
	for(auto it = m.begin(); it != m.end(); it++){
		ans += it->second * (it->second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  
  int ans , num;
  int keep[3];
  for(int i = N ; i < 1000 ; i++){         //Nから999までを走査
    
    num = i;                               //iを答え用に避難させる
      
    for(int j = 0 ; j < 3 ; j++){          //各桁の数字を確認
	   keep[j] = num % 10;
	   num /= 10;
    }

      //全桁が同一なら処理
    if(keep[0] == keep[1] && keep[1] == keep[2]){
		ans = i;
		break;
    }
      
  }

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

      
  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll x, m, i, ans = 0;
  cin >> x;
  
  if(x == 2)
    ans = 2;
  
  m = x;
  while(ans == 0){
    for(i = 2; i < m; i++){
      if(__gcd(m, i) != 1){
        break;
      }
      else if(i == m-1){
        ans = m;
      }
    }
    m++;
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

bool solve(){
  long a,b,c,d;
  cin>>a>>b>>c>>d;

  if(a < b) return false;
  if(d < b) return false;

  if(a <= c) return true;

  long g = __gcd(b, d);

  long na = a - ((a-c - 1) / g) * g;

  return na >= b;
}

int main(){
  int t;
  cin>>t;
  rep(i,t) cout << (solve() ? "Yes" : "No") << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, errados = 0, cont = 0;
    scanf("%d", &a);
    while(a>cont){
        scanf("%d", &b);
        if (b%2==0){
            if(b%3!=0 && b%5!=0){
                ++errados;
            }
        }
        ++cont;
    }

    if (errados != 0){
        printf("DENIED\n");
    } else {
        printf("APPROVED\n");
    }
    return 0;
}

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

int N;
int S[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", S + i);
	
	ll ans = 0;
	
	FOR(d, 1, N - 1) {
		// d = B - A
		
		ll cur = 0;
		int l = 0, r = N - 1;
		
		while (true) {
			l += d;
			r -= d;
			
			if (l >= N - 1 || r <= 0) break;
			if (l >= r && ((N - 1 - l) % d == 0 || r % d == 0)) break;
			int A = N - 1 - l;
			if (A <= d) break;
			
			cur += S[r];
			cur += S[l];
			chmax(ans, cur);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(void) {
    int ans = 0;
    string s, t = "CODEFESTIVAL2016";
    cin >> s;
    for (int i = 0; i < 16; i++) {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// E - Roaming

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const int MOD = 1e9 + 7;

class Comb {
private:
	int MOD;
	long long* fac;
	long long* finv;
	long long* inv;
public:
	// 事前にテーブルを作成
	Comb(int MAX, int MOD) {
		this->MOD = MOD;

		fac = new long long[MAX + 1];
		finv = new long long[MAX + 1];
		inv = new long long[MAX + 1];

		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;
		}
	}

	~Comb() {
		delete[] fac, finv, inv;
	}

	// 二項係数計算
	long long calc(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;
	}
};

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

	Comb comb = Comb(n * 2, MOD);

	ll ans;

	if (k >= n) {
		ans = comb.calc(n+n-1, n);
	} else {
		ans = 0;
		for (int i=0; i<=k; i++) { // i: 空き部屋の数
			ans = (ans + (comb.calc(n, i) * comb.calc((n-i) + i - 1, i)) % MOD) % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

void solve() {
	int x[2];
	rep(i, 0, 2) {
		cin >> x[i];
	}
	if (x[0] == x[1]) cout << "Draw" << endl;
	else if (x[0] == 1 || (x[0] > x[1] && x[1] != 1)) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <utility>
#include <iomanip>
using namespace std;

string s[2000];
int l[2000][2000], r[2000][2000], u[2000][2000], d[2000][2000];

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
        cin >> s[i];
    for (int i = 0; i < h; ++i)
    {
        int prev = -1;
        for (int j = w - 1; j >= 0; --j)
        {
            if (s[i][j] == '#')
                prev = j;
            r[i][j] = prev;
        }
    }
    for (int i = 0; i < h; ++i)
    {
        int prev = -1;
        for (int j = 0; j < w; ++j)
        {
            if (s[i][j] == '#')
                prev = j;
            l[i][j] = prev;
        }
    }
    for (int i = 0; i < w; ++i)
    {
        int prev = -1;
        for (int j = 0; j < h; ++j)
        {
            if (s[j][i] == '#')
                prev = j;
            u[j][i] = prev;
        }
    }
    for (int i = 0; i < w; ++i)
    {
        int prev = -1;
        for (int j = h - 1; j >= 0; --j)
        {
            if (s[j][i] == '#')
                prev = j;
            d[j][i] = prev;
        }
    }

    /*
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
            cout << setw(2) << d[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    */
    int mx = -1;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
            if (s[i][j] != '#')
            {
                int cnt = 1;
                if (l[i][j] == -1)
                    cnt += j;
                else
                    cnt += j - l[i][j] - 1;

                if (r[i][j] == -1)
                    cnt += w - j - 1;
                else
                    cnt += r[i][j] - j - 1;

                if (u[i][j] == -1)
                    cnt += i;
                else
                    cnt += i - u[i][j] - 1;

                if (d[i][j] == -1)
                    cnt += h - i - 1;
                else
                    cnt += d[i][j] - i - 1;
                mx = max(mx, cnt);
            }
    }
    cout << mx << endl;
    return 0;
}
// aa ac ca c a b aa ba bc

Measured memory_bytes: 66944
def main():
    n, t = map(int, input().split())
    f = [list(map(int, input().split())) for _ in range(n)]
    dp1 = [[0 for i in range(t)]for j in range(n+1)]
    dp2 = [[0 for i in range(t)]for j in range(n+1)]
    for i in range(n):
        for j in range(t - 1, -1, -1):
            if j - f[i][0] >= 0:
                dp1[i+1][j] = max(dp1[i][j - f[i][0]] + f[i][1],dp1[i][j])
            else:
                dp1[i+1][j] = dp1[i][j]
    for i in range(n):
        for j in range(t - 1, -1, -1):
            if j - f[n-1-i][0] >= 0:
                dp2[i+1][j] = max(dp2[i][j - f[n-1-i][0]] + f[n-1-i][1],dp2[i][j])
            else:
                dp2[i+1][j] = dp2[i][j]

    res = 0
    for i in range(n):
        for j in range(t):
            res = max(res,dp1[i][j]+f[i][1]+dp2[n-1-i][t-1-j])

    return res




print(main())


Measured memory_bytes: 195076
#include<stdio.h>
int main()
{
    int s,a,b,c;
    scanf("%d", &s);
    if(s>=0&&s<=86400)
    {
    a=s/3600;
    b=(s%3600)/60;
    c=((s%3600)%60);
    printf("%d:%d:%d\n",a,b,c);
    }
    return 0;
}


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

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

  while (b <= a) {
    b *= 2;
    k--;
  }

  while (c <= b) {
    c *= 2;
    k--;
  }

  if (k >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

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

  long long L0 = 2, L1 = 1;
  long long ans = L0 + L1;

  if (N == 1) {
    cout << L1 << endl;
  } else if (N == 2) {
    cout << ans << endl;
  } else {
    for (int i = 0; i < N - 2; i++) {
      L0 = L1;
      L1 = ans;
      ans = L0 + L1;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""code-fes-2017-qual-c-a"""


import sys
import re


def main():
    """Main function."""
    S = input()

    print("Yes") if re.search("AC", S) else print("No")


if __name__ == '__main__':
    sys.exit(main())

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int A = 1e9;
    int X = 0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A')
            A = min(A,i);
        else if(s[i]=='Z')
            X = max(X,i);
    }
    cout<<X-A+1;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long int solve()
{
    long long int a,b,res,x;
    scanf("%lld %lld %lld",&a,&b,&x);
    res=b/x;
    if(a==0)
    {
        return res+1;
    }
    return res-((a-1)/x);
}
int main()
{
    long long int r=solve();
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N;
	cin >> N;
	ll A[110]={};
	REP(i,N) cin >> A[i];
	ll mac=0;
	REP(i,N-1){
		FOR(j,i+1,N){
			mac=max(mac,abs(A[i]-A[j]));
		}
	}
	cout << mac << endl;
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, t;

vi x, y, z;

int ind;

void read() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    x.pb(X);
    y.pb(Y);
    z.pb(Z);
    if (z[i] > 0)
      ind = i;
  }
}

void solve() {
  for(int cx = 0; cx <= 100; ++cx)
    for(int cy = 0; cy <= 100; ++cy) {
      bool p = 1;
      int H = z[ind] + abs(x[ind] - cx) + abs(y[ind] - cy);
      for(int i = 0; i < n; ++i) {
        int h = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0);
        if (h != z[i]) {
          p = 0;
          break;
        }
      }
      if (p) {
        cout << cx << " " << cy << " " << H;
      }
    }
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

const int maxn=2000005;
int p[maxn];
int sz[maxn];
int cnt=0;
void clear(int n=maxn){
    rep(i,0,n+1)p[i]=i,sz[i]=1;
    cnt=n;
}
int root(int x){
   while(x!=p[x]){
       p[x]=p[p[x]];
       x=p[x];
   }
   return x;  
}
void merge(int x,int y){
    int p1=root(x);
    int p2=root(y);
    if(p1==p2)return;
    cnt--;
    if(sz[p1]>=sz[p2]){
        p[p2]=p1;
        sz[p1]+=sz[p2];
        sz[p2]=0;
    }
    else{
        p[p1]=p2;
        sz[p2]+=sz[p1];
        sz[p1]=0;
    }
}

int solve(){
 	int n;cin>>n;
 	clear(n);
 	int m;cin>>m;
 	rep3(m){
 		int a,b;cin>>a>>b;
 		merge(a,b);
 	}
 	int mx=1;
 	for(int i=1;i<=n;i++){
 		maxs(mx,sz[root(i)]);
 	}
 	cout<<mx<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 6736
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var T = new long[N].Select(x => x = long.Parse(Console.ReadLine())).ToArray();
            var answer = 1L;
            for (var i = 0; i < N; i++)
            {
                answer = LCM(answer, T[i]);
                // Console.WriteLine(answer);
            }
            Console.WriteLine(answer);
        }

        static long LCM(long a, long b)
        {
            var (min, max) = a >= b ? (a, b) : (b, a);
            return min * (max / GCD(min, max));
        }
        static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    }
}

Measured memory_bytes: 28248
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int gcd(int a, int b) {
    if (a < b)swap(a, b);
    int r = a % b;
    while (r) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

signed main() {
    int N, M;
    cin >> N >> M;
    int lcm = N * M / gcd(N, M);
    string S, T;
    cin >> S >> T;
    if (S[0] != T[0]) {
        cout << -1 << endl;
        return 0;
    }
    map<int, char> map1;
    rep(i, N) {
        map1[i * lcm / N] = S[i];
    }
    rep(i, M) {
        if (map1[i * lcm / M] != 0 && map1[i * lcm / M] != T[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << lcm << endl;
    return 0;
}


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

using namespace std;
typedef pair<int, int> ipair;
typedef priority_queue<ipair> pq;

int main()
{
    int n, m;
    while(cin >> n >> m, n|m)
    {
        pq q;
        int res = 0;
        for(int i=0; i<n; i++)
        {
            int d, p;
            cin >> d >> p;
            res += d * p;
            q.push(ipair(p, d));
        }
        while(!q.empty() && m>0)
        {
            ipair x = q.top();
            q.pop();
            res -= x.first * min(m, x.second);
            m -= x.second;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long w[510][510], D[510][510], w2[510][510];
long long S[510][510], S2[510][510];
int main() {
	int i, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			if (i == j)continue;
			scanf("%lld", &w[i][j]);
			if (i < j)w2[i][j] = w[i][j];
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			S[i][j] = S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1] + w[i][j];
			S2[i][j] = S2[i - 1][j] + S2[i][j - 1] - S2[i - 1][j - 1] + w2[i][j];
		}
	}
	for (i = 1; i <= n; i++) {
		D[i][0] = S2[i][i];
		for (j = 1; j < i; j++) {
			D[i][j] = 1e18;
			long long u = S2[i][i] - S2[j][i] - S2[i][j] + S2[j][j];
			for (k = 0; k < j; k++) {
				D[i][j] = min(D[i][j], D[j][k] + u + S[i][k] - S[j][k]);
			}
		}
	}
	long long res = 1e18;
	for (i = 0; i < n; i++)res = min(res, D[n][i]);
	printf("%lld\n", res);
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
int main(){
  int x;
  cin>>x;
  while(1){
    if(IsPrime(x)==true)break;
    x++;
  }
  cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 256
import math


a, b = map(int, input().split())

pred_a = math.ceil(a / 0.08)
pred_b = b * 10

ans = []
for i in range(13):
    for j in range(10):
        if pred_a+i == pred_b+j and int((pred_a+i)*0.08) == a and int((pred_b+j)*0.1) == b:
            ans.append(pred_a+i)
if len(ans)==0:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 9200
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] data = S.toCharArray();
        int N = S.length();
        int zero_count = 0;
        int one_count = 0;
        for (int i = 0; i < N; i++) {
            if (data[i] == '0')  {
                zero_count += 1;
            }
            if (data[i] == '1') {
                one_count += 1;
            }
        }
        System.out.println(S.length() - Math.abs(zero_count - one_count));
    }
}


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

int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n - 1; i++)
  {
    int m;
    cin >> m;
    a[m-1]++;
  }
  for(int i = 0; i < n; i++)
  {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 4048
N,M = map(int,input().split())
requests = []
for _ in range(M):
        a,b = map(int,input().split())
        requests.append([a,b])

ans = 1
requests = sorted(requests, key=lambda x:x[1])
b = requests[0][1]
for i in range(M):
        if requests[i][0] < b:
                continue
        else:
                ans += 1
                b = requests[i][1]

print(ans)

Measured memory_bytes: 22108
#include<bits/stdc++.h>
using namespace std;
int a[1000001];
int main()
{
	int n,m,i;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		n-=a[i];
	}
	if(n>=0)cout<<n;
	else cout<<-1;
	return 0;
}

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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());

    auto check = [&](auto mid){
        int64_t res = 0;
        for (auto &a: A)
            res += ceil(a / mid) - 1;
        return res <= k;
    };

    double l = 0, r = 1e10;
    for (int i = 0; i < 100; i++){
        auto mid = (l + r) / 2;
        (check(mid) ? r : l) = mid;
    }

    cout << int(ceil(r)) << endl;
}

Measured memory_bytes: 4024
// AOJ ITP1_2_A
#include<cstdio>

int main()
{
	int a, b;
	scanf( "%d%d", &a, &b );

	if( a < b )
		puts("a < b");
	else if( a > b )
		puts("a > b");
	else
		puts("a == b");

	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (1000000007);

int main()
{
	int h,w; cin>>h>>w;
	char grid[h+1][w+1]; ll dp[1005][1005];
	for (int i=1; i<=h; i++)
		for (int j=1; j<=w; j++)
		{
			char x; cin>>x; grid[i][j]=x;
			dp[i][j]=0;
		}
	grid[0][1]='.'; dp[0][1]=1; grid[1][0]='#'; dp[1][0]=0;
	for (int i=1; i<=h; i++)
	{
		for (int j=1; j<=w; j++)
		{
			dp[i][j] = ( dp[i-1][j]*(grid[i-1][j]=='.') + dp[i][j-1]*(grid[i][j-1]=='.') )%MOD;
		}
	}
	cout<<dp[h][w]<<endl;
	return 0;
}

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

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root, *nil;

void insert(int k){
  struct Node *y=nil, *x=root, *z;

  z = malloc(sizeof(struct Node));
  z->key=k;
  z->right=nil;
  z->left=nil;
  while(x!=nil){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==nil)root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *n){
  if(n==nil)return;
  inorder(n->left);
  printf(" %d",n->key);
  inorder(n->right);
}

void preorder(struct Node *n){
  if(n==nil)return;
  printf(" %d",n->key);
  preorder(n->left);
  preorder(n->right);
}

struct Node * find(struct Node *n, int i){
  while(n!=nil && i!=n->key){
    if(i < n->key)n=n->left;
    else n=n->right;
  }
  return n;
}

int main(){
  int i, n, s;
  char c[10];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s", c);
    if(strcmp(c,"find")==0){
      scanf("%d", &s);
      struct Node *t=find(root, s);
      if(t!=nil)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(c, "insert")==0){
      scanf("%d", &s);
      insert(s);
    }
    else if(strcmp(c, "print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include <stdio.h>

int ruizyo(int a, int n){
    int i, ret = 1;
    for(i = 0; i < n; i++){
        ret *= a;
    }
    return ret;
}

int main(){
    int a, b;

    scanf("%d %d", &a, &b);

    if(a == 0){
        if(b != 100)    printf("%d\n", b);
        else    printf("101\n");
    }else{
        if(b != 100)    printf("%d\n", ruizyo(100, a)*b);
        else    printf("%d\n", ruizyo(100, a)*b + ruizyo(100, a));
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, n = 0, m = 0;
	char t;
	while (1)
	{
		cin >> a;
		if (cin.eof()) break;
		cin >> t >> b >> t >> c;
		if (a*a + b*b == c*c) n++;
		if (a == b) m++;
	}
	cout << n << endl << m << endl;
}

Measured memory_bytes: 0