akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	static HashMap<String,Boolean> map;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String in = sc.nextLine();
			String[] a = in.split(" ");
			int n = Integer.parseInt(a[0]);
			int m = Integer.parseInt(a[1]);
			int[] C = new int[n];
			int[] V = new int[n];
			int[] D = new int[n];
			int[] L = new int[n];
			for(int i = 0; i < n; i++) {
				in = sc.nextLine();
				in = sc.nextLine();
				a = in.split(" ");
				C[i] = Integer.parseInt(a[0]);
				V[i] = Integer.parseInt(a[1]);
				D[i] = Integer.parseInt(a[2]);
				L[i] = Integer.parseInt(a[3]);
			}
			int MAX = 0;
			int[][][] dp = new int[n+1][m+1][3];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j <= m; j++) {
					for(int k = 0; ; k++) {
						if(j + C[i] * k > m) break;
						dp[i+1][j + C[i] * k][0] = Math.max(dp[i+1][j + C[i] * k][0], dp[i][j][0] + V[i] * k);
						dp[i+1][j + C[i] * k][1] = Math.max(dp[i+1][j + C[i] * k][1], dp[i][j][1] + D[i] * k);
						dp[i+1][j + C[i] * k][2] = Math.max(dp[i+1][j + C[i] * k][2], dp[i][j][2] + L[i] * k);
					}
				}
			}
			for(int i = 0; i <= m; i++) {
				MAX = Math.max(dp[n][i][0], MAX);
				MAX = Math.max(dp[n][i][1], MAX);
				MAX = Math.max(dp[n][i][2], MAX);
			}
			System.out.println(MAX);
			
			
			
			
		}
		
	}
 }

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define RE(i,n) FOR(i,1,n)
#define R(i,n) REP(i,n)
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int,int>
#define LD long double

template<class C> void mini(C& a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C& a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int q,h,s,d;
  cin >> q >> h >> s >> d;
  mini(h,2*q);
  mini(s,2*h);
  mini(d,2*s);
  int n;
  cin >> n;
  debug(q,h,s,d);
  cout << (n / 2) * d + (n % 2) * s << "\n" ; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{
  int H, W; cin >> H >> W;
  vector<vector<int>> arr(H);
  rep(i, 0, H){
    rep(k, 0, W){
      int a; cin >> a;
      arr[i].push_back(a);
    } 
  }

  int ans = 0;
  vector<vector<int>> display(250001);

  rep(h, 0, H){
    rep(w, 0, W - 1){
      if(arr[h][w] % 2 == 0) continue;
      display[ans].push_back(h + 1);
      display[ans].push_back(w + 1);
      display[ans].push_back(h + 1);
      display[ans].push_back(w + 2);
      ++ans;
      --arr[h][w];
      ++arr[h][w + 1];
    }
  }

  rep(h, 0, H - 1){
    if(arr[h][W - 1] % 2 == 0) continue;
      display[ans].push_back(h + 1);
      display[ans].push_back(W);
      display[ans].push_back(h + 2);
      display[ans].push_back(W);
      ++ans;
      --arr[h][W - 1];
      ++arr[h + 1][W - 1];

  }

  cout << ans << endl;

  rep(i, 0, ans){
    rep(k, 0, 4){
      cout << display[i][k];
      if(k != 3) cout << " ";
    }
    cout << endl;
  }

}


Measured memory_bytes: 14092
#include <cstdio>

void swap(int &a, int &b)
{
	int tmp = a;
	a = b;
	b = tmp;
}

void merge(int arr[], int l, int m, int r)
{
	int i, j, k; 
	int n1 = m - l + 1; 
	int n2 =  r - m; 

	int L[n1], R[n2]; 

	for (i = 0; i < n1; i++) 
		L[i] = arr[l + i]; 
	for (j = 0; j < n2; j++) 
		R[j] = arr[m + 1+ j]; 

	i = 0; 
	j = 0; 
	k = l; 
	while (i < n1 && j < n2) 
	{ 
		if (L[i] <= R[j]) 
		{ 
			arr[k] = L[i]; 
			i++; 
		} 
		else
		{ 
			arr[k] = R[j]; 
			j++; 
		} 
		k++; 
	} 

	while (i < n1) 
	{ 
		arr[k] = L[i]; 
		i++; 
		k++; 
	} 

	while (j < n2) 
	{ 
		arr[k] = R[j]; 
		j++; 
		k++; 
	} 
} 

void mergesort(int arr[], int l, int r)
{
	if (l < r)
	{
		int m = l + (r - l) / 2;

		mergesort(arr, l, m);
		mergesort(arr, m + 1, r);

		merge(arr, l, m, r);
	}
}

int main()
{
	int N, K;
	int H[200000];
	unsigned long long sumH = 0;

	scanf("%d %d", &N, &K);

	for (int i = 0; i < N; ++i)
		scanf("%d", &H[i]);

	mergesort(H, 0, N - 1);

	for (int i = 0; i < N - K; ++i)
		sumH += H[i];

	printf("%llu\n", sumH);
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
const int N=15;
int n,a[N],ans;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;for(int i=1;i<=n;++i)cin>>a[i];sort(a+1,a+1+n);
    for(int i=1;i<n;++i)ans+=a[i];ans+=a[n]>>1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int a[3];
    int aa[3];
    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
        if (a[i] % 2) { //odd
            aa[i] = 1;
            cnt++;
        } else {
            aa[i] = 0;
        }
    }
    int flg = 0;
    if (cnt == 1) {
        flg = 1;
        for (int i = 0; i < 3; ++i) { //全部1足してそれだけ1引けばそれ以外を1足した
            if (aa[i] == 1) {
                a[i]--;
            }
            a[i]++;
        }
    } else if (cnt == 2) { //1個だけ偶数
        flg = 1;
        for (int i = 0; i < 3; ++i) {
            if (aa[i] == 0) {
                a[i]--;
            }
            a[i]++;
        }
    }
    cnt = 0;
    if (flg == 1) {
        cnt++;
    }
    sort(a, a + 3);
    while (1) {
        if (a[0] == a[1] && a[1] == a[2]) {
            break;
        }
        if (a[2] - a[1] >= 2) {
            a[1] += 2;
        } else if (a[1] - a[0] >= 2) {
            a[0] += 2;
        } else {
            a[0]++; a[1]++;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

# 初期化
res = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            total = (500 * i) + (100 * j) + (50 * k)
            if total == x:
                res += 1 

print(res)

Measured memory_bytes: 3064
import Control.Monad

getInt :: IO Int
getInt = read <$> getLine


getInts :: IO [Int]
getInts = map read . words <$> getLine


getLines :: Int -> IO [String]
getLines x = replicateM x getLine


getIntLines :: Int -> IO [Int]
getIntLines x = map read <$> getLines x


getIntsLines :: Int -> IO [[Int]]
getIntsLines x = map (map read . words) <$> getLines x


main :: IO ()
main = do
  [n, h, w] <- getInts
  abs <- getIntsLines n

  print . length . filter (\[x, y] -> x >= h && y >= w) $ abs


Measured memory_bytes: 2044
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
cnt = 0
for I in range(2 ** h):
    I_lst = []
    for i in range(h):
        if (not((I >> i) & 1)):
            I_lst.append(i)
    for J in range(2 ** w):
        J_lst = []
        sum_black = 0
        for j in range(w):
            if (not((J >> j) & 1)):
                J_lst.append(j)
        # print(I, I_lst, J_lst)
        for I_nokori in I_lst:
            for J_nokori in J_lst:
                if C[I_nokori][J_nokori] == '#':
                    sum_black += 1
        if sum_black == k:
            cnt += 1
            # print('aaaaa', I, I_lst, J_lst)

print(cnt)

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

//ABC118A
int main(void) {
  int n, k, i, cou=0, a, b, tmp;
  scanf("%d %d", &a, &b);
  n=b%a==0 ? a+b : b-a;
  printf("%d", n);
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


vi solve(int M, int K) {
    vi ans;

    int P = 1 << M;
    if (!IN(K, 0, P-1)) {
        ans = {-1};
        return ans;
    }

    if (M == 0){
        ans = {0,0};
        return ans;
    } else if (M == 1) {
        if (K==0) {
            ans = {0,0,1,1};
            return ans;
        } else if (K==1) {
            ans = {-1};
            return ans;
        }
    } else {
        for(int i=0; i<P; ++i) {
            if (i != K) ans.pb(i);
        }
        ans.pb(K);
        for(int i=P-1; i>=0; --i) {
            if (i != K) ans.pb(i);
        }
        ans.pb(K);
    }
    return ans;
}

int main() {
    int M, K; cin >> M >> K;
    vi ans = solve(M,K);
    int L=ans.size();
    rep(i,L){
        printf("%d%c", ans[i], (i==L-1)?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 2932
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]

src.append(last_row)


for rc in range(r + 1):
    print(' '.join([str(a) for a in src[rc]]))

Measured memory_bytes: 7736
#include <stdio.h>
#include <string.h>
using namespace std;
typedef long long int ll;
constexpr int kMod = int(1E9 + 7);
int a[30][30];
ll dp[2][1 << 21];
int main() {
	int n;
	bool f = false;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
	dp[!f][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) if (a[i][j + 1]) {
			for (int k = 0; k < (1 << n); k++) if ((1 << j) & k) dp[f][k] += dp[!f][k ^ (1 << j)];
		}
		for (int j = 0; j < (1 << n); j++) dp[f][j] %= kMod;
		f = !f;
		memset(dp[f], 0, sizeof(dp[f]));
	}
	printf("%lld\n", dp[!f][(1 << n) - 1]);
}


Measured memory_bytes: 34504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

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

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

bool chk(vector<pii> v){
	int n = v.size();

	int l = 0;
	rep(i, n){
		if(l < -v[i].first) return false;
		l += v[i].second;
	}

	return l >= 0;
}

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

	int n;
	cin >> n;

	vector<pii> v;
	vector<pii> w;

	int sml = 0;
	rep(i, n){
		string s;
		cin >> s;

		int m = s.size();
		int mn = 1e7;
		int l = 0;
		rep(i, m){
			if(s[i] == '('){
				l++;
			}else{
				l--;
			}
			chmin(mn, l);
		}
		sml += l;
		if(l >= 0){
			v.push_back({mn, l});
		}else{
			w.push_back({mn - l, -l});
		}
	}

	if(sml != 0){
		cout << "No" << endl;
		return 0;
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	sort(w.begin(), w.end());
	reverse(w.begin(), w.end());

	if(chk(v) && chk(w)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 18784
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX_N 100000

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

  int cnt = 0;
  int dp[MAX_N];
  dp[0] = 0;
  dp[1] = 1;
  for (int i = 1; i <= N; i++) {
    if (i <= 5)
      dp[i] = dp[i - 1] + 1;
    else if (i <= 8)
      dp[i] = dp[i - 6] + 1;
    else if (i <= 9)
      dp[i] = dp[i - 9] + 1;
    else {
      int six = 6, nine = 9;
      while (i > six) six *= 6;
      while (i > nine) nine *= 9;
      if (i % six != 0) six /= 6;
      if (i % nine != 0) nine /= 9;
      dp[i] = min(dp[i - 1], min(dp[i - six], dp[i - nine])) + 1;
    }
  }

  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long lint;
const int MAX = 555;
int A[MAX][MAX];

struct Operation {
    int fy, fx, ty, tx;
    Operation() {}
    Operation(int fy, int fx, int ty, int tx) : fy(fy), fx(fx), ty(ty), tx(tx) {}
    void print() const {
        cout << fy+1 << " " << fx+1 << " " << ty+1 << " " << tx+1 << endl;
    }
};

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    vector<pair<int, int> > B;
    for (int i = 0; i < H; i++) {
        if (i%2 == 0) {
            for (int j = 0; j < W; j++) {
                B.emplace_back(i*W+j, A[i][j]);
            }
        } else {
            for (int j = W-1; j >= 0; j--) {
                B.emplace_back(i*W+j, A[i][j]);
            }
        }
    }
    vector<Operation> ans;
    for (int i = 0; i < H*W; ) {
        if (B[i].second % 2 == 1) {
            // 次の奇数を探す
            int next_odd_index = -1;
            for (int j = i+1; j < H*W; j++) {
                if (B[j].second % 2 == 1) {
                    next_odd_index = j;
                    break;
                }
            }
            if (next_odd_index == -1) {
                break;
            }
            for (int j = i; j < next_odd_index; j++) {
                const int p1 = B[j].first, p2 = B[j+1].first;
                ans.emplace_back(p1 / W, p1 % W, p2 / W, p2 % W);
            }
            i = next_odd_index + 1;
        } else {
            i++;
        }
    }
    cout << ans.size() << endl;
    for (const Operation op : ans) {
        op.print();
    }
    return 0;
}

Measured memory_bytes: 7280
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;
int N;
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...));
}
const int MOD = 1000000007;
void add(long long &a,long long b){
  a += b;
  if (a >= MOD) a -= MOD;
}

long long solve(int N){
  auto dp = make_vec<long long>(N+1,5,5,5);
  dp[0][0][0][0] = 1;
  for(int n = 0 ; n < N; n++){
    for(int i = 0; i < 5; i++){
      for(int j = 0 ;j < 5;j++){
        for(int k= 0;k < 5; k++){
          for(int l = 1;l< 5;l++){
            if (i == 1 && j == 2 && l == 3) continue;
            if (i == 1 && k == 2 && l == 3) continue;
            if (j == 1 && k == 2 && l == 3) continue;
            if (j == 2 && k == 1 && l == 3) continue;
            if (j == 1 && k == 3 && l == 2) continue;
            add(dp[n+1][j][k][l], dp[n][i][j][k]);
          }
        }
      }
    }
  }

  long long res = 0;
  for(int i = 1;i<5;i++){
    for(int j = 1; j < 5;j++){
      for(int k = 1;k < 5;k++){
        add(res,dp[N][i][j][k]);
      }
    }
  }
  return res;
}


signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  cout << solve(N) << endl;
  return 0;
}


Measured memory_bytes: 512
steps = int(input())
heights = [int(height) for height in input().split()]
costs = [0] * steps
for i in range(1, steps):
    if i == 1:
        costs[1] = costs[0] + abs(heights[0] - heights[1])
    else:
        one_step = costs[i-1] + abs(heights[i-1] - heights[i])
        two_steps = costs[i-2] + abs(heights[i-2] - heights[i])
        costs[i] = min([one_step, two_steps])
print(costs[steps-1])

Measured memory_bytes: 13928
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char s[110];
int main() {
	cin >> s;
	int k;
	scanf("%d", &k);
	for (int i = 0; i < strlen(s); ++i) {
		if (s[i] == '1') k--;
		else {
			putchar(s[i]);
			return 0;
		}
		if (k == 0) {
			putchar('1');
			return 0;
		}
	}
	return 0;
}

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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

vector<int> p;
vector<vector<int>> memo;
bool cur[10];
int ans,n,m;

void dfs(int a){
  if(a==n){
    bool temp=true;
    for(int i=0;i<m;i++){
      int sum=0;
      for(int j=0;j<(int)memo[i].size();j++){
        if(cur[memo[i][j]]) sum++;
      }
      if(sum%2!=p[i]) temp=false;
    }
    if(temp) ans++;
  }
  else{
    for(int i=0;i<2;i++){
      cur[a]=i;
      dfs(a+1);
    }
  }
}

int main() {
  cin>>n>>m;
  memo.resize(m);
  for(int i=0;i<m;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      s--;
      memo[i].push_back(s);
    }
  }
  p.resize(m);
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    p[i]=a;
  }
  ans=0;
  dfs(0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int a, b; cin >> a >> b;
	if (a > 0 && b > 0)cout << "Positive" << endl;
	else if (a <= 0 && 0 <= b)cout << "Zero" << endl;
	else cout << ((b - a) % 2 == 0 ? "Negative" : "Positive") << endl;


	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

ary = []
a.each_with_index{|x, i| ary.push([x, i]) }

ary = ary.sort{|lhs, rhs| rhs[0] <=> lhs[0] }

left = 0
right = 0

dp = Array.new(n) { Array.new(n + 1) { 0 } }

ary.each_with_index do |el, i|
  (0..i).each do |j|
    left = j
    right = i - j
    
    current = 0
    current = dp[i - 1][j] if i > 0
    
    if el[1] - left >= 0
      dp[i][left + 1] = [current + (el[1] - left) * el[0], dp[i][left + 1]].max
    end
    if (n - right - 1) - el[1] >= 0
      dp[i][left] = [current + ((n - right - 1) - el[1]) * el[0], dp[i][left]].max
    end
  end
end

puts dp[n - 1].max

Measured memory_bytes: 45808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s; cin>>s;
	int ind = -1;
	for(int i = 0; i < days.size(); i++){
		if(s == days[i]) ind = i+1;
	}
	cout<<8-(ind);
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define track(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=3e5+10;

int main()
{
	boost;
	ll n,q;
	cin>>n>>q;
	vector<pair<ll,mypair > > v;
	set<ll> s;
	std::vector<ll> ans(q,-1);
	for(ll i=0;i<n;i++)
	{
		ll x,y,t;
		cin>>x>>y>>t;
		x-=t;
		y-=t+1;
		v.pb(mp(t,mp(x,y)));
	}
	sort(all(v));
	std::map<ll, ll> ma;
	for(ll i=0;i<q;i++)
	{
		ll x;
		cin>>x;
		ma[x]=i;
		s.insert(x);
	}
	for(auto &i:v)
	{
		ll l,r,t;
		l=i.ss.ff;
		r=i.ss.ss;
		t=i.ff;
		while(s.size())
		{
			auto it=s.lower_bound(l);
			if(it==s.end() or (*it)>r ) break;
			ans[ma[*it]]=t;
			s.erase(it);
		}
	}
	for(auto &i:ans) cout<<i<<endl;
  	return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    string s;cin>>s;

    VI w(n),b(n);
    if(s[0] == '#'){
        w[0] = 1;
    }
    if(s[n-1] == '.'){
        b[n-1] = 1;
    }
    FOR(i,1,n){
        w[i] = w[i-1];
        if(s[i] == '#'){
            w[i] += 1;
        }
    }
    PER(i,n-1){
        b[i] = b[i+1];
        if(s[i] == '.'){
            b[i] += 1;
        }
    }

    int result = min(w[n-1],b[0]);
    REP(i,n-1){
        result = min(result, w[i]+b[i+1]);
    }
    cout<<result<<endl;

    
	return;
}

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

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

#define endl "\n"
#define int long long

const int MOD = 1e9 + 7;
const int INF = 2e15;

void debug(vector <int> &dp, int l, int r) {
	for (int i = 1; i <= r; i++) {
		if (dp[i] == INF) cout << "inf ";
		else cout << dp[i] << " ";
	}
	cout << endl;
}

signed main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;

	vector <int> heights(n + 1, 0);
	for (int i = 1; i <= n; i++) cin >> heights[i];

	vector <int> dp(n + 1, INF);
	dp[0] = 0;
	dp[1] = 0;

	for (int i = 2; i <= n; i++) {
		for (int j = max(i - k, 1LL); j < i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(heights[i] - heights[j]));
		}
	}

	//debug(dp, 0, n);
	cout << dp[n] << endl;
}

Measured memory_bytes: 4784
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n,k;
string s;

signed main(){
  cin >> n >> k;
  cin >> s;
  REP(i,s.size()){
    if(i!=k-1) cout << s[i];
    else cout << char(s[i]-'A'+'a');
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c = LI()
    r = 0
    t = min(b,c)
    r += t * 2
    b -= t
    c -= t
    t = min(a,c)
    r += t
    a -= t
    c -= t
    r += b
    if c > 0:
        r += 1

    return r


print(main())


Measured memory_bytes: 7880
#include<bits/stdc++.h>
using namespace std;
typedef pair<double, double> Point;
typedef pair<Point, Point> Segment; // (frm, to)
const double eps = 1e-9;

double norm(Point a) {
    return sqrt(a.first * a.first + a.second * a.second);
}
Point normalize(Point vec) {
    double d = norm(vec);
    return d < eps ? vec : Point(vec.first / d, vec.second / d);
}
Point normalize(Point vec, double len) {
    Point a = normalize(vec);
    return Point(a.first * len, a.second * len);
}
Point getvert(Point v) {
    return Point(-v.second, v.first);
}
Point getv(Point frm, Point to) {
    return Point(to.first - frm.first, to.second - frm.second);
}
Point getv(Segment a) {
    return getv(a.first, a.second);
}
double dist(Point a, Point b) {
    return norm(getv(a, b));
}
double getlen(Segment a) {
    return dist(a.first, a.second);
}

double cross(Point v, Point w) {
    return v.first * w.second - v.second * w.first;
}
bool iscross(Segment a, Segment b) {
    return cross(getv(a), getv(a.first, b.first)) * cross(getv(a), getv(a.first, b.second)) < eps && cross(getv(b), getv(b.first, a.first)) * cross(getv(b), getv(b.first, a.second)) < eps;
}

Segment getcrosses(Point a, double ra, Point b, double rb) {
    double c = dist(a, b);
    double d = (c * c + ra * ra - rb * rb) / (2 * c);
    Point p = normalize(getv(a, b), d);
    Point ctr = Point(p.first + a.first, p.second + a.second);
    double h = sqrt(ra * ra - d * d);
    Point pp = normalize(getvert(getv(a, b)), h);
    return Segment(Point(ctr.first + pp.first, ctr.second + pp.second), Point(ctr.first - pp.first, ctr.second - pp.second));
}

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) return 0;
        vector<Point> c(n);
        vector<int> r(n);
        vector<Segment> s(n - 1);
        for (int i = 0; i < n; ++i) {
            cin >> c[i].first >> c[i].second >> r[i];
            if (i) s[i - 1] = getcrosses(c[i - 1], r[i - 1], c[i], r[i]);
        }
        vector<Point> p;
        p.push_back(c[0]);
        for (auto i : s) {
            p.push_back(i.first);
            p.push_back(i.second);
        }
        p.push_back(c[n - 1]);
        vector<double> dp(n * 2, 1e9);
        dp[0] = 0;
        for (int i = 1; i < n * 2; ++i) {
            for (int j = 0; j < i; ++j) {
                bool ok = true;
                for (int k = (j + 1) / 2; k < (i - 1) / 2; ++k) {
                    if (!iscross(Segment(p[j], p[i]), s[k])) {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                    dp[i] = min(dp[i], dp[j] + dist(p[j], p[i]));
            }
        }
        printf("%.9lf\n", dp[n * 2 - 1]);
    }
}

Measured memory_bytes: 3172
#include<stdio.h>
#include<string.h>
#include<limits.h>
#define TMAX 1000001
#define PMAX 10002
char text[TMAX], pattern[PMAX];
int next[PMAX], skip[UCHAR_MAX + 1];
void Bmskip(int m);
void Bmnext(int m);
void Bmsearch(int n, int m);
int main(void) {
  int tlen, plen;
  pattern[0] = '@';
  text[0] = '?';
  scanf("%s%*c%s%*c", &text[1], &pattern[1]);
  tlen = strlen(text) - 1;
  plen = strlen(pattern) - 1;
  Bmskip(plen);
  Bmnext(plen);
  Bmsearch(tlen, plen);
}
void Bmskip(int m)
{
  int i;
  for (i = 0; i <= UCHAR_MAX; i++) skip[i] = m;
  for (i = 1; i < m; i++) skip[(int)pattern[i]] = m - i;
}
void Bmnext(int m)
{
  int i, j, s, g[m+1];
  for (i = 1; i <= m; i++) next[i] = 2 * m - i;
  for(j = m; j > 0; j--) {
    g[j] = i;
    pattern[m+1] = pattern[j];
    while (pattern[j] != pattern[i]) {
      if (next[i] > m - j) next[i] = m - j;
      i = g[i];
    }
    i--;
  }
  s = i;
  for (i = 1; i <= m; i++) {
    if (next[i] > s + m - i) next[i] = s + m - i;
    if (i >= s) s = g[s];
  }
}
void Bmsearch(int n, int m)
{
  int i, j;
  i = m;
  while (i <= n) {
    j = m;
    while (text[i] == pattern[j]) i--, j--;
    if (j == 0) {
      printf("%d\n", i);
      i += m + 1;
    } else {
      i += (skip[(int)text[i]] > next[j] ? skip[(int)text[i]] : next[j]);
    }
  }
}


Measured memory_bytes: 2112
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			int r ,c;
			r = scan.nextInt();
			c = scan.nextInt();
			int[][] matrix = new int[r + 1][c + 1];
			for(int i = 0; i < r ;i++){
				for(int j = 0 ; j < c;j++){
					matrix[i][j] = scan.nextInt();
				}
			}
			for(int i = 0 ;i < r;i++){
				int sum = 0;
				for(int j = 0; j < c;j++){
					sum += matrix[i][j];
				}
				matrix[i][c] = sum;
			}
			for(int i = 0 ; i <= c;i++){
				int sum = 0;
				for(int j = 0 ; j < r; j++){
					sum += matrix[j][i];
				}
				matrix[r][i] = sum;
			}
			for(int i = 0 ; i < matrix.length;i++){
				System.out.print(matrix[i][0]);
				for(int j = 1 ; j < matrix[i].length;j++){
					System.out.print(" " + matrix[i][j]);
				}
				System.out.println();
			}
		}finally{
			if(scan !=null)scan.close();
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  vi32 l(n); cin >> l;
  sort(all(l));
  i64 sum = 0;
  rep(i, n) rep(j, i) {
    int d = abs(l[i] - l[j]) + 1;
    int s = l[i] + l[j];
    int c1 = lower_bound(all(l), d) - l.begin();
    int c2 = lower_bound(all(l), s) - l.begin();
    int cnt = c2 - c1;
    if (d <= l[i] && l[i] < s) cnt--;
    if (d <= l[j] && l[j] < s) cnt--;
    amax(cnt, 0);
    sum += cnt;
  }
  cout << sum / 3 << endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A+B)==(C+D)) {
    cout << "Balanced" << endl;
  }
  else if((A+B)>(C+D)){
  	cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


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

int main(){
  int n=0, m=0;
  int tag = 0;
  cin >> n >> m;
  int a[n];
  float sum=0;
  for (int i=0;i < n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  
  for (int i = 0; i<n;++i){
    if(a[i] >= sum/(4*m)){
      ++tag;
    }
  }
  
  if (tag >= m){
    cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

typedef vector<vector<int>> Graph;
int x[] = {-1,-1,-1,0,0,0,1,1,1};
int y[] = {-1,0,1,-1,0,1,-1,0,1};
int W,H;
Graph C(51,vector<int>(51));
Graph seen(51,vector<int>(51));

void dfs(Graph &C, Graph &seen, int h, int w){
    seen[h][w] = 1;
    rep(i,9){
        int next_h,next_w;
        next_h = h+y[i];
        next_w = w+x[i];
        if(next_h<0||next_h>=H||next_w<0||next_w>=W)continue;
        if(C[next_h][next_w]==1&&seen[next_h][next_w]==0){
            dfs(C,seen,next_h,next_w);
        }
    }
}

int main(){
    while(true){
        cin >> W >> H;
        if(W==0&&H==0){
            return 0;
        }
        rep(i,H)rep(j,W){
            cin >> C[i][j];
            seen[i][j]=0;
        } 
        int num=0;
        rep(i,H){
            rep(j,W){
                if(C[i][j]==0 || seen[i][j]==1) continue;
                num++;
                dfs(C,seen,i,j);
            }
        }
        cout << num << endl;
    }
    return 0;
}


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

int main(void)
{
    unsigned int inputN, inputM, tmpQNum, ACCount = 0, WACount = 0;
    char result[3];
    int questionFlag[100001];
    unsigned int questionNumber[100001], tmpWACount[100001];

    scanf("%u%u", &inputN, &inputM);

    for (int index = 0; index < inputN; index++)
    {
        questionFlag[index] = 0;
        tmpWACount[index] = 0;
    }
    for (int index = 0; index < inputM; index++)
    {
        scanf("%d%s", &tmpQNum, result);
        if (questionFlag[tmpQNum - 1] == 0)
        {
            if (strcmp(result, "AC") == 0)
            {
                questionFlag[tmpQNum - 1] = 1;
            }
            else
            {
                tmpWACount[tmpQNum - 1]++;
            }
        }
    }
    for (int index = 0; index < inputN; index++)
    {
        if (questionFlag[index] == 1)
        {
            ACCount++;
            WACount += tmpWACount[index];
        }
    }

    printf("%d %d", ACCount, WACount);

    return 0;
}

Measured memory_bytes: 896
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb emplace_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
const int mod=1e9+7;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll binpow(ll a, ll b, ll m) 
{a %= m;b%=(m-1);ll res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1; }return res;}
void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,temp,x,y;
string str;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vll v(n);
read(v);
bool flag=1;
for(int i=0;i<n;i++)
{
   if(v[i]%2==0)
   {
       if(v[i]%3!=0 && v[i]%5!=0)
       {
           flag=0;
           break;
       }
   }
}
if(flag)
{
    cout<<"APPROVED";
}
else
cout<<"DENIED";






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    double a; cin >> a;
    double b; cin >> b;
    double h; cin >> h;
    double m; cin >> m;
    double a_rad = PI*(h+m/60)/6.;
    double b_rad = PI*m/30.;
    printf("%.18f", pow(a*a + b*b - 2.*cos(a_rad-b_rad)*a*b, 0.5));
    return 0;
}

Measured memory_bytes: 4304
import numpy as np
from collections import Counter

N,M = map(int, input().split())
An = [0] + list(map(int, input().split()))
An = np.array(An)

_ = Counter(np.cumsum(An%M) % M)
ans = 0
for i in _.values():
  ans += i*(i-1)//2

print(ans)

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

int compare_int(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}

int main(void)
{
	int a[50], b[50], n, x = 0;
	scanf("%d", &n);


		for (int i = 0;i < n;i++)
		{
			scanf("%d", &a[i]);
			b[i] = a[i];
		}
		qsort(b, n, sizeof(int), compare_int);


		for (int i = 0;i < n;i++)
		{
			if (a[i] != b[i])
				x++;
		}
				if (x<=2)
			{
				printf("YES");
				return 0;
			}
				printf("NO");
	return 0;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 10, M = 1010, INF = 0x3f3f3f3f;

int n, a, b, c;
int len[N];

int dfs(int u, int sa, int sb, int sc, int cnt)
{
	if (u >= n)
	{
		if (!sa || !sb || !sc) return INF;
		else return abs(a - sa) + abs(b - sb) + abs(c - sc) + (cnt - 3) * 10;
	}
	
	int res = INF;
	res = min(res, dfs(u + 1, sa, sb, sc, cnt));
	res = min(res, dfs(u + 1, sa + len[u], sb, sc, cnt + 1));
	res = min(res, dfs(u + 1, sa, sb + len[u], sc, cnt + 1));
	res = min(res, dfs(u + 1, sa, sb, sc + len[u], cnt + 1));
	return res;
}

int main()
{
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i ++ ) cin >> len[i];
	cout << dfs(0, 0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int k, x;
    cin >> k >> x;
    for(int i = x-k+1; i <= x+k-1; ++i){
        cout << i << " ";
    }
    return 0;
}


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

int main(){
	int N;
	int A[3][3];
	bool c[3][3];

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

	cin >> N;

	for(int i=0; i<N; i++){
		int b;
		cin >> b;
		for(int j=0; j<3; j++){
		  for(int k=0; k<3; k++){
		  	if(A[j][k]==b) {c[j][k]=true;}
		  }
		}
	}

	bool bingo=false;
	if(c[0][0] && c[0][1] && c[0][2])bingo=true;
	if(c[1][0] && c[1][1] && c[1][2])bingo=true;
	if(c[2][0] && c[2][1] && c[2][2])bingo=true;
	if(c[0][0] && c[1][0] && c[2][0])bingo=true;
	if(c[0][1] && c[1][1] && c[2][1])bingo=true;
	if(c[0][2] && c[1][2] && c[2][2])bingo=true;
	if(c[0][0] && c[1][1] && c[2][2])bingo=true;
	if(c[0][2] && c[1][1] && c[2][0])bingo=true;

	if(bingo)cout << "Yes" << endl;
	else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[100010], B[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
	ll ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		A[i] += ans;
		ans += (B[i] - (A[i] % B[i])) % B[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    
 
    public static void main(String[] args)  {
        new Main().solve();
    }

    void solve(){
        Scanner sc = new Scanner(System.in);
        int N,M;
        N = Integer.parseInt(sc.next());
        M = Integer.parseInt(sc.next());
        sc.close();

        int result;

        if(N==0){
            if(M==0){
                result = 0;
            }
            result = M*(M-1)/2;
        }
        else{
            result = N*(N-1)/2 + M*(M-1)/2;
        }
        
        System.out.println(result);

        

    }
}

Measured memory_bytes: 22996
import math
import collections
import fractions
import itertools
import functools
import operator

def ncr(n, r):
    if n < r: return 0
    r = min(r, n-r)
    if r == 0:
        return 1
    numer = functools.reduce(operator.mul, range(n, n-r, -1), 1)
    denom = functools.reduce(operator.mul, range(1, r+1), 1)
    return numer // denom % (10 ** 9 + 7)

def solve():
    n, k = map(int, input().split())
    for i in range(1,k+1):
        ans = (ncr(k-1, i-1) * ncr(n-k+1, i)) % (10**9+7)
        print(int(ans))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10644
k = gets.chomp.to_i

def gcd(p, q)
    if p % q == 0 then
        return q
    else
        return gcd(q, p % q)
    end
end

result = 0
for a in 1..k do
    for b in 1..k do
        t = gcd(a, b)
        for c in 1..k do
            result += gcd(t, c)
        end
    end
end

puts result

Measured memory_bytes: 14392
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    int ans = a - b - b;
    if (ans < 0) ans = 0;
    cout << ans << E;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
L,*A = `dd`.split.map &:to_i
INF = 10**15
dp = (0...5).map{ Array.new(L,INF) }

dp[0][0] = A[0]
dp[1][0] = A[0] == 0 ? 2 : (A[0]%2)
dp[2][0] = (A[0]+1)%2
dp[3][0] = A[0] == 0 ? 2 : (A[0]%2)
dp[4][0] = A[0]

trans = [
  [0,1,2,3,4],
  [1,2,3,4],
  [2,3,4],
  [3,4],
  [4],
]

(0...L-1).each{ |i|
  k = i+1
  (0...5).each{ |si| 
    trans[si].each{ |sk|
    v = case sk
    when 0; A[k]
    when 1; A[k] == 0 ? 2 : A[k]%2
    when 2; (A[k]+1)%2
    when 3; A[k] == 0 ? 2 : A[k]%2
    when 4; A[k]
    end + dp[si][i]
    dp[sk][k] = v if v < dp[sk][k]
    }
  }
}

p (0...5).map{ |s| dp[s][-1] }.min

Measured memory_bytes: 25928
#include<bits/stdc++.h>
#define taskname "test1"
#define int long long
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int x1, y1, x2, y2;     cin >> x1 >> y1 >> x2 >> y2;
    int x = x2 - x1, y = y2 - y1;
    cout << x2 - y << ' ' << y2 + x << ' ' << x1 - y << ' ' << y1 + x;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInt()
	b := nextInt()
	ans := 0
	rep := n / (a + b) //繰り返す回数
	mod := n % (a + b) //余り

	//繰り返しの分に余りの分を加算
	ans = rep * a
	if 0 < mod && mod <= a {
		ans += mod
	}
	if a < mod {
		ans += a
	}
	fmt.Println(ans)
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    int w, h, x, y;
    double area;
    int judge = 0;

    scanf("%d %d %d %d", &w, &h, &x, &y);
    area = (double)w*h/2;

    if(x + x == w && y + y == h) judge = 1;

    printf("%.10f %d\n", area, judge);
    return 0;
}

Measured memory_bytes: 128