akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int N;
int G[210][210];
const int INF = 100100100;

int COLOR[210];

bool dfs(int v, int c) {
    COLOR[v] = c;
    rep(nv, N) {
        if (nv == v) continue;
        if (G[v][nv] != 1) continue;

        if (COLOR[nv] == c) return false;
        if (COLOR[nv] == 0 && !dfs(nv, -c)) return false;
    }
    return true;
}

int main() {
    cin >> N;
    rep(i, N) {
        string s;
        cin >> s;
        rep(j, s.size()) {
            if (s[j] == '1') G[i][j] = 1;
            else G[i][j] = INF;
        }
        G[i][i] = 0;
    }

    if (!dfs(0, 1)) {
        cout << -1 << endl;
        return 0;
    }

    rep(k, N) rep(i, N) rep(j, N) chmin(G[i][j], G[i][k] + G[k][j]);
    int d = 0;
    rep(i, N) {
        rep(j, N) {
            if (G[i][j] == INF) continue;
            chmax(d, G[i][j]);
        }
    }
    cout << d + 1 << endl;
}


Measured memory_bytes: 384
a = gets.chomp
hash = Hash.new(0)
a.each_char do |c|
  hash[c] += 1
end
ans = 1 + a.size * (a.size - 1) / 2
hash.values.select { |n| n > 1 }.each do |n|
  ans -= n * (n - 1) / 2
end
puts ans


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

int main() {
    string s, t;
    cin >> s >> t;
    ll ans = 0;
    rep(i,3) if (s[i]==t[i]) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>

int main(void)

{

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0)

{

printf("Yes\n");

}else{

printf("No\n");

}

return 0;

}

Measured memory_bytes: 1012
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

type person struct {
	num int
	a   int
}

type byA []person

func (p byA) Len() int           { return len(p) }
func (p byA) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func (p byA) Less(i, j int) bool { return p[i].a < p[j].a }

func main() {
	n, _ := strconv.Atoi(input())
	people := make([]person, n)
	for i := 0; i < n; i++ {
		a, _ := strconv.Atoi(input())
		people[i] = person{i + 1, a}
	}
	sort.Sort(byA(people))
	for i := 0; i < n-1; i++ {
		fmt.Print(people[i].num, " ")
	}
	fmt.Println(people[n-1].num)
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n , l[300005] = {} , r[300005] = {} , ans;
    string s;
    
    cin >> n;
    cin >> s;
    
    ans = n;
    
    for(int i=0 ;i<n ;i++ ){
        if(s[i] == 'E'){
            l[i+1]++;
        } else {
            r[i+1]++;
        }
        l[i+1] += l[i] , r[i+1] += r[i];
    }
    
    for(int i=1 ;i<=n ;i++ ){
        ans = min(ans , r[i-1] + l[n] - l[i]);
    }
    
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);


		//??°?????????
		while(true){
			//?????°?????£?¨? //??????????????????
			int answer = 0;

			//??°???1?????????
			int num1 = sc.nextInt();

			//??????????????????
			String computing = sc.next();

			//??°???2?????????
			int num2 = sc.nextInt();

			//?????¶??? ?????????????????????£????????????
			if(computing.equals("?")){
				break;
			}
			//?????¶??? ?????????????????£????¨????
			//?¶??????? +
			if(computing.equals("+")){
				answer = num1 + num2;
				System.out.println(answer);
			//????????? -
			}else if(computing.equals("-")){
				answer = num1 - num2;
				System.out.println(answer);
			//?????? *
			}else if(computing.equals("*")){
				answer = num1 * num2;
				System.out.println(answer);
			//????????? /
			}else if(computing.equals("/")){
				answer = num1 / num2;
				System.out.println(answer);
			}
		}

	}
}

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

int main() {
  ll x,j=0;
  cin >> x;
  bool a = true;
  while(a){
    if(x == 1){
      cout << 1 << endl;
      a = false;
    }
    if(x == 2){
      cout << 2 << endl;
      a = false;
    }
    for(ll i=2;i<x+j;i++){
      if((x+j)%i==0){
        j++;
        break;
      }
      if(i == x+j-1 && (x+j)%i!=0){
        cout << x+j << endl;
        a = false;
      }
    }
  }
  
 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    
    int ans = 0;
    int sum = 0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                sum = 500*i + 100*j + 50*k;
                //cout << "sum:" << sum << endl;
                if(sum == x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl; 
    return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
int n, k, arr[N];

bool check(int t){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        int ha = (arr[i] % t == 0) ? (arr[i] / t - 1) : (arr[i] / t);
        cnt += ha;
    }
    return (cnt <= k);
}

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

    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
    }

    int l = 1, r = 1e9, ans = -1;
    while(l <= r){
        int mid = l + (r - l) / 2;
        if(check(mid)){
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }

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

Measured memory_bytes: 4400
n, m = map(int, input().split())

shop = []
for i in range(n):
	shop.append(list(map(int, input().split())))

sorted_shop = sorted(shop, key=lambda x: x[0])

count = m
money = 0
for shop in sorted_shop:
	if count == 0:
		break
	if count >= shop[1]:
		count = count - shop[1]
		money += shop[0] * shop[1]
	else:
		money += shop[0] * count
		count = 0

print(money)

Measured memory_bytes: 29792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            b[i] = sc.nextInt();
        }
        sc.close();

        long[] num = new long[29];
        long ans = 0;
        
        for(int i=0; i<29; i++){
            int[] ta = new int[n];
            int[] tb = new int[n];
            for(int j=0; j<n; j++){
                ta[j] = a[j] % (2 << i);
                tb[j] = b[j] % (2 << i);
            }
            Arrays.sort(tb);
            int pow1 = (2 << i) / 2;
            int pow2 = 2*pow1, pow3 = 3*pow1, pow4=4*pow1;
            for(int j=0; j<n; j++){
                int tmp1 = myBinarySearch(tb, pow1 - ta[j]);
                int tmp2 = myBinarySearch(tb, pow2 - ta[j]);
                int tmp3 = myBinarySearch(tb, pow3 - ta[j]);
                int tmp4 = myBinarySearch(tb, pow4 - ta[j]);                
                //if(tmp1 < 0) tmp1 = -tmp1 - 1;
                //if(tmp2 < 0) tmp2 = -tmp2 - 1;
                num[i] += tmp2 - tmp1 + tmp4 - tmp3;
            }

            if(num[i] % 2 == 1) ans += (2 << i) / 2;
        }

        System.out.println(ans);
    }
    
    public static int myBinarySearch(int[] la, int key){
        int l = -1;
        int r = la.length;
        while(r - l > 1){
            int m = (l + r) >> 1;
            if(la[m] >= key){
                r = m;
            }else{
                l = m;
            }
        }
        return r;
    }
}

Measured memory_bytes: 147024
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    unordered_set<lint> colors;
    range(i, 0, 3) {
        lint color;
        cin >> color;
        colors.emplace(color);
    }
    cout << colors.size() << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int N, Q;
string S;

const int MAX = 5e5 + 5;
struct Segtree {
	ll t[2 * MAX];
	void build() {
		for (int i = MAX - 1; i > 0; i--)
			t[i] = t[i << 1] + t[i << 1 | 1];
	}
	void modify(int p, int value) {
		for (t[p += MAX] = value; p > 1; p >>= 1)
			t[p >> 1] = t[p] + t[p ^ 1];
	}
	ll query(int l, int r) {
		ll ret = 0;
		for (l += MAX, r += MAX; l < r; l >>= 1, r >>= 1) {
			if (l & 1) ret += t[l++];
			if (r & 1) ret += t[--r];
		}
		return ret;
	}
};

Segtree st[26];

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

	for (int i = 0; i < N; i++) st[S[i] - 'a'].modify(i, 1);

	cin >> Q;
	while (Q--) {
		int op;
		cin >> op;
		if (op == 1) {
			int i; char c;
			cin >> i >> c;
			i--;
			st[S[i] - 'a'].modify(i, 0);
			S[i] = c;
			st[S[i] - 'a'].modify(i, 1);
		}
		else {
			int a, b; cin >> a >> b;
			a--;
			int ans = 0;
			for (int i = 0; i < 26; i++)
				if (st[i].query(a, b)) ans++;
			cout << ans << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 206964
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> l(m),r(m),d(m);
    REP(i,m){
        cin >> l[i] >> r[i] >> d[i];
        l[i]--;
        r[i]--;
    }
    vector<vector<P>> e(n);
    REP(i,m){
        e[l[i]].push_back(P(r[i],d[i]));
        e[r[i]].push_back(P(l[i],-d[i]));
    }
    queue<int> q;
    vector<int> dd(n,INT_MAX/2);
    vector<int> visited(n,false);
    if(m==0){
        put("Yes");
        return 0;
    }
    REP(i,m){
        if(!visited[l[i]]){
            q.push(l[i]);
            dd[l[i]] = 0;
            while(!q.empty()){
                int p = q.front();
                q.pop();
                REP(i,e[p].size()){
                    int now = e[p][i].first;
                    if(!visited[now]){
                        dd[now] = dd[p]+e[p][i].second;
                        visited[now] = true;
                        q.push(now);
                    }else{
                        if(dd[now]!=dd[p]+e[p][i].second){
                            put("No");
                            return 0;
                        }
                    }
                }
            }
        }
        
    }
    /*q.push(l[0]);
    dd[l[0]] = 0;
    while(!q.empty()){
        int p = q.front();
        q.pop();
        REP(i,e[p].size()){
            int now = e[p][i].first;
            if(!visited[now]){
                dd[now] = dd[p]+e[p][i].second;
                visited[now] = true;
                q.push(now);
            }else{
                if(dd[now]!=dd[p]+e[p][i].second){
                    put("No");
                    return 0;
                }
            }
        }
    }*/
    put("Yes");
    return 0;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"unsafe"<<endl;else cout<<"safe"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int n,m;cin>>n>>m;
  Ans(n<=m);
}

Measured memory_bytes: 3644
def solve
  k = gets.to_i
  i = k
  j = k
  ans = 0
  (1..k).each do |o|
    (1..i).each do |p|
      (1..j).each do |q|
        ans += o.gcd(p).gcd(q)
      end
    end
  end
  p ans
end

solve

Measured memory_bytes: 14316
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
const long long mod=1e9+7;
const long long N=1000000000;
const ll val=1000005;
int in(){
int n;cin>>n;
return n;}
void _do_(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)cout<<k;
	else if(k>a&&k<=a+b)cout<<a;
	else cout<<a-(k-(a+b));
	cout<<endl;

}
signed main(){
fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<int> ans(40);
    rep(i, n) {
        int k; cin>>k;
        rep(j, k){
            int a; cin>>a;
            ans[a]++;
        }
    }
    int t=0;
    for(int i=1;i<=m;i++){
        if(ans[i]==n)t++;
    }
    cout << t <<endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
if H==1:
  print(1)
else:
  if W==1:
    print(1)
  elif W==2:
    print(H)
  else:
    if W%2==0:
      print((W//2)*H)
    else:
      if H%2==0:
        print(((W//2)+1)*(H//2) + (W//2)*(H//2))
      else:
        print(((W//2)+1)*((H//2)+1) + (W//2)*(H//2))
    
  

Measured memory_bytes: 3060
N=int(input())
ans=0
speech_l=[[] for _ in range(N)]
for i in range(N):
    tmp=int(input())
    for j in range(tmp):
        speech_l[i].append(list(map(int,input().split())))
for i in range(2**N):
    sw=0
    l=[1]*N
    tmp=N
    for j in range(N):
        if ((i >> j)&1):
            tmp-=1
            l[j]=0
    for j in range(N):
        if l[j] == 1:
            for k in speech_l[j]:
                if l[k[0]-1] != k[1]:
                    sw=1
    if sw==0:
        ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 9176
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[10001];
	int i;
	int joi, ioi;

	while (scanf("%s", str) != EOF){
		joi = ioi = 0;

	for (i = 0; i < strlen(str) - 2; i++){
		if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I'){
			joi++;
		}
		else if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
			ioi++;
		}
	}

	printf("%d\n", joi);
	printf("%d\n", ioi);
	}

	return (0);
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;
#define INF INT_MAX;
int main(){
  int N; cin >> N;
  int m=INF;
  for(int i=0;i<N;i++){
    int x; cin >> x;
    int cont=0;
    while(x%2==0) {
      x/=2;
      cont++;
    }
    m = min(cont,m);
  }
  cout << m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct piont{
	double x,y;
}p[10];
double mp[10][10];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf%lf",&p[i].x,&p[i].y);
//		cout<<p[i].x<<endl;
	} 
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			mp[i][j]=mp[j][i]=sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+((p[i].y-p[j].y)*(p[i].y-p[j].y)));
		} 
	}
	double ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans+=mp[i][j];
		} 
	}
	printf("%.10lf\n",ans/n);
} 

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

a = [list(map(int, input().split())) for i in range(n)]

#締め切りが早い仕事から始める
a.sort(key=lambda x: x[1])

time = 0
ans = True
for i in a:
  time += i[0]
  if i[1] < time:
    ans = False
    break

if ans:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 53600
import datetime
a, b = map(int, input().split())
d = datetime.datetime(2018, 1, 1)
count = 0
while d <= datetime.datetime(2018, a, b):
	if (d.strftime('%m') == d.strftime('%d')):
		count+=1
	d = d + datetime.timedelta(days=1)
print(count)

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

using namespace std;

	int S, W, E, N;

int main () {
	string s;
	cin >> s;
	for (int i = 0;i < s.size ();i ++) {
		if (s[i] == 'W') W = 1;
		if (s[i] == 'E') E = 1;
		if (s[i] == 'S') S = 1;
		if (s[i] == 'N') N = 1;
	}      
	if (W != E || S != N) {
		cout << "No";
	}
	else cout << "Yes";
	return 0;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int a, b;

int main(){
	scanf("%d %d", &a, &b);
	if(1LL * a * b <= 0){
		printf("Zero\n");
	}
	else if(a > 0 || (b - a + 1) % 2 == 0){
		printf("Positive\n");
	}
	else printf("Negative\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#define lli long long int
using namespace std;

int main() {
	// your code goes here
	lli x,k,n,c,las;
	c=0;
	cin>>n>>k;
	for(lli i=0;i<max(n,k);i++){
		cout<<min(n,k);
	}
	
	// cout<<0;
	// x='Z';
	// las=int('Z');
	// if('Z'-(s[0]+k)>=0)cout<<(char)(s[0]+2);
	// cout<<'Z'<<" "<<(s[0]+k);
	// SUN, MON, TUE, WED, THU, FRI, or SAT, 
	return 0;
}

Measured memory_bytes: 256
from functools import lru_cache

T = int(input())


def resolver(a, b, c, d):
    @lru_cache(maxsize=None)
    def _resolver(n):
        if n == 0:
            return 0
        elif n == 1:
            return d
        else:
            div5f = n // 5
            div5c = (n + 4) // 5
            div3f = n // 3
            div3c = (n + 2) // 3
            div2f = n // 2
            div2c = (n + 1) // 2
            return min(
                d * n,
                d * abs(n - div5f * 5) + c + _resolver(div5f),
                d * abs(n - div5c * 5) + c + _resolver(div5c),
                d * abs(n - div3f * 3) + b + _resolver(div3f),
                d * abs(n - div3c * 3) + b + _resolver(div3c),
                d * abs(n - div2f * 2) + a + _resolver(div2f),
                d * abs(n - div2c * 2) + a + _resolver(div2c),
            )

    return _resolver


for _ in range(T):
    N, A, B, C, D = map(int, input().split(' '))
    print(resolver(A, B, C, D)(N))


Measured memory_bytes: 20540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int l=s-i-j;
            if(l<=k and l>=0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int a, b, c, d;

int main() {
	fastio; cin >> a >> b >> c >> d;
	a = a/d + (a % d != 0);
	c = c/b + (c % b != 0);
	if (a >= c) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3648
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long double lb;
typedef long long ll;

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

const int N = 2e5 + 5;

int a[N], b[N];
int n; ll k;

bool check(ll mid) {
    ll sum = 0;
    for(register int i = 1; i <= n; i++) sum += max(0ll, a[i] - mid / b[i]);
    return sum <= k;
}

int main() {
    read(n); read(k);
    for(register int i = 1; i <= n; i++) read(a[i]);
    for(register int i = 1; i <= n; i++) read(b[i]);
    sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1);
    ll l = 0, r = 1e12, ans = 1e12;
    while(l <= r) {
        ll mid = (l + r) >> 1;
        if(check(mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 1792
package main

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

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var bs = NewBufScanner(in)
	var bw = NewBufWriter(out)
	defer bw.w.Flush()

	a := bs.IntScan()
	b := bs.IntScan()
	c := bs.IntScan()
	x := bs.IntScan()

	sum := 500 * a + 100 * b + 50 * c
	if sum < x {
		bw.Printf("0\n")
		return
	}

	cnt := 0
	for bg := 0; bg <= a; bg++ {
		if 500 * bg + 100 * b + 50 * c < x {
			continue
		}
		for md := 0; md <= b; md++ {
			if 500 * bg + 100 * md + 50 * c < x {
				continue
			}
			for sm := 0; sm <= c; sm++ {
				if 500 * bg + 100 * md + 50 * sm == x {
					cnt++
				}
			}
		}
	}
	bw.Printf("%d\n", cnt)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int k;
    cin>>k;
    string s="ACL";
    for(int i=0;i<k;i++){
        for(auto x:s) cout<<x;
    }
    cout<<"\n";
}

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

    solve();
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> a(N);for(int i=0;i<N;i++){cin >> a[i];}
    int x=0,y=0;
    sort(a.begin(),a.end(),greater<int>());
    for(int i=0;i<N;i++){
        if(i%2==0)x+=a[i];
        else y+=a[i];
    }
    cout << x-y << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

/**
 * Created by Ayushi on 07/07/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = r.readLine().split(" ");
        int n = Integer.parseInt(temp[0]);
        int a = Integer.parseInt(temp[1]);
        int b = Integer.parseInt(temp[2]);
        r.close();

        System.out.println(Math.min((n*a), b));
    }
}


Measured memory_bytes: 21204
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
-- end of templete


main = getInt >>= flip replicateM getInt >>= print . length . group . sort

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

int main() {
  int K, N, p;
  cin >> K >> N;
  vector<int> A(N+1);
  for (int i=1; i<=N; i++) {
    cin >> p;
    A[i]=p;
    A[0]=p;
  }
  int m=0;
  for (int i=1; i<=N; i++) {
    if (i==1) {
      m=K-(A[0]-A[1]);
    }
    else {
      m=max(m, A[i]-A[i-1]);
    }
  }
  cout << K-m << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define MOD 998244353
#define fi first
#define se second
#define IT vector < int > :: iterator
using namespace std;

const int NR = 2e5 + 10 , oo = 2e9 ;


void pres ()    {
    #ifndef ONLINE_JUDGE
    freopen("date.in", "r", stdin);
   // freopen("date.out", "w", stdout);
    #endif

}
ll steps ( ll y )   {
    if ( y <= 2 )   return 0 ;
    return 1LL + steps ( ( y - 1 ) / 2 ) ;
}
ll x , sol  , i;
 main()	{
  //  pres();


    cin >> x ;
    sol = 2 ;
    for ( i = 1 ; i <= x ; ++ i )    {
        sol = sol * 2 + 2 ;
    }
 //   cout << steps ( 15 ) << '\n' ;
    for ( ; steps ( sol ) == x ; sol ++ ) ;
       // cout << steps ( sol ) << ' ' << sol << '\n' ;// sol -- ;
    sol -- ;
    cout << sol ;


    return 0 ;


}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int dp[1001][1001];

void run(){
    string s1,s2;
    cin>>s1>>s2;
    rep(i,s1.length()+1)dp[i][0]=i;
    rep(i,s2.length()+1)dp[0][i]=i;
    REP(i,1,s1.length()){
        REP(j,1,s2.length()){
            dp[i][j]=min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(s1[i-1]!=s2[j-1])});
        }
    }
    cout<<dp[s1.length()][s2.length()]<<endl;
}


Measured memory_bytes: 7104
def merge_sort(arr):
 if len(arr) <= 1:
  return arr
 mid = len(arr) // 2
# ここで分割を行う
 left = arr[:mid]
 right = arr[mid:]
# 再帰的に分割を行う
 left = merge_sort(left)
 right = merge_sort(right)
# returnが返ってきたら、結合を行い、結合したものを次に渡す
 return merge(left, right)
def merge(left, right):
 merged = []
 l_i, r_i = 0, 0
# ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
 while l_i < len(left) and r_i < len(right):
    # ここで=をつけることで安定性を保っている
  if left[l_i] <= right[r_i]:
   merged.append(left[l_i])
   l_i += 1
  else:
   merged.append(right[r_i])
   r_i += 1

# 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
 if l_i < len(left):
  merged.extend(left[l_i:])
 if r_i < len(right):
  merged.extend(right[r_i:])
 return merged

X,Y,A,B,C = map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))
PP=merge_sort(P)
QQ=merge_sort(Q)
S=PP[A-X:A]+QQ[B-Y:B]+R
SS=merge_sort(S)
D=0
for r in range(X+Y):
 D+=SS[C+r]
print(D)


Measured memory_bytes: 130960
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

#define int long long
typedef pair<long long, long long> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
long long L;
long long X[100000], V[100000];
long long solve() {
  long long cur = 0, sum = 0;
  vector<P> st;
  st.pb(P(-1, 0));
  rep(i, N) {
    sum += V[i];
    if (sum-X[i] > cur) {
      cur = sum-X[i];
      st.pb(P(i, cur));
    }
  }
  sum = 0;
  long long m = st.back()._2;
  for (int i=N-1; i>=0; i--) {
    sum += V[i];
    assert(lower_bound(all(st), P(i, -1)) != st.begin());
    long long w = sum - 2LL*(L-X[i]) + (--lower_bound(all(st), P(i, -1)))->_2;
    m = max(m, w);
  }
  return m;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> L;
  rep(i, N) cin >> X[i] >> V[i];
  long long m = 0;
  m = max(m, solve());
  rep(i, N) X[i] = L-X[i];
  reverse(X, X+N);
  reverse(V, V+N);
  m = max(m, solve());
  cout << m << "\n";
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
char S[20];
ll i, j, k;
int main(){
    scanf("%s", S);
    ll Sn = strlen(S);
    if(Sn%2==1){
        printf("No");
        return 0;
    }
    i = 0;
    while(i<Sn){
        if(S[i]!='h'||S[i+1]!='i'){
            break;
        }
        i += 2;
    }
    if(i==Sn){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
obs = {}

class Observatory:
  def __init__(self, id, height):
    self.id = id
    self.height = height
    self.link = []

  def is_good(self):
    for id in self.link:
      if self.height <= obs[id].height:
        return False
    
    return True

n, m = map(int, input().split())
h_list = list(map(int, input().split()))

for i in range(1, n+1):
  obs[i] = Observatory(i, h_list[i-1])

for _ in range(m):
  a, b = map(int, input().split())
  obs[a].link.append(b)
  obs[b].link.append(a)

count = 0
for ob in obs.values():
  if ob.is_good():
    count += 1

print(count)

Measured memory_bytes: 102764
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  auto n=readln.chomp.to!(int);
  
  foreach(b; 0..(1<<3)){
    auto tmp=n, sum=0;
    foreach(i; 0..3){
      if((b>>i)&1) sum+=tmp%10;
      else sum-=tmp%10;
      tmp/=10;
    }
    sum+=tmp;
    if(sum==7){
      char[] s;
      foreach(i; 0..3){
        s~=(n%10)+'0';
        s~=(b>>i)&1 ? '+' : '-';
        n/=10;
      }
      s~=n+'0';
      reverse(s);
      writeln(s~"=7"); return;
    }
  }

  assert(false);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = n; i <= 999; ++i)
    {
        const int x = i / 100;
        const int y = i / 10 % 10;
        const int z = i % 10;
        if(x == y && y == z)
        {
            cout << i << '\n';
            break;
        }
    }
    
    return 0;
}

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

#define REP(i, n) for (long long i = 0; i < n; i++)
#define FOR(i, m, n) for (long long i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    long long x = 0, y = 0, t = 0;

    REP(i, N) {
        long long tt, xx, yy;
        cin >> tt >> xx >> yy;
        long long x_diff = abs(xx - x);
        long long y_diff = abs(yy - y);
        long long t_diff = tt - t;

        if (x_diff + y_diff > t_diff) {
            cout << "No" << endl;
            return 0;
        }

        if ((x_diff + y_diff) % 2 != t_diff % 2) {
            cout << "No" << endl;
            return 0;
        }

        x = xx;
        y = yy;
        t = tt;
    }

    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;

#define MOD 1000000007

string S;
int dp[2][13];

int main(){
    cin >> S;
    int L = S.size();

    int ans = 0;
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;

    for(int i = 0;i < L;++i){
        int cur = (i & 1);
        int nxt = (cur ^ 1);

        for(int j = 0;j < 13;++j)
            dp[nxt][j] = 0;

        if(S[i] == '?'){
            for(int j = 0;j < 13;++j){
                for(int k = 0;k < 10;++k){
                    int r = (10 * j + k) % 13;
                    dp[nxt][r] += dp[cur][j];
                    if(dp[nxt][r] >= MOD)
                        dp[nxt][r] -= MOD;
                }
            }
        }else{
            for(int j = 0;j < 13;++j){
                int r = (10 * j + S[i] - '0') % 13;
                dp[nxt][r] += dp[cur][j];
                if(dp[nxt][r] >= MOD)
                    dp[nxt][r] -= MOD;
            }
        }

        ans = dp[nxt][5];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
from collections import deque


def bfs(sx, sy, gx, gy):
    q = deque([(sx, sy)])
    cost[sx][sy] = 1
    while q:
        x, y = q.popleft()
        for dx, dy in nb:
            nx = x + dx
            ny = y + dy
            if 0 <= nx and nx < h and 0 <= ny and ny < w and grid[nx][ny] == "." and cost[nx][ny] == float("inf"):
                q.append((nx, ny))
                cost[nx][ny] = cost[x][y] + 1
                if nx == gx and ny == gy:
                    return cost[nx][ny]
    return -1


h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
cost = [[float("inf")] * w for _ in range(h)]
nb = [(-1, 0), (0, -1), (1, 0), (0, 1)]
black_cnt = 0
ans = 0

for i in range(h):
    black_cnt += str(grid[i]).count("#")

can_reach = bfs(0, 0, h - 1, w - 1)
if can_reach > 0:
    print(h * w - can_reach - black_cnt)
else:
    print(can_reach)

Measured memory_bytes: 3316
import sys
input=sys.stdin.readline
n=int(input())
A=tuple(map(int,input().split()))
DP=[[0]*(n+1) for _ in range(n+1)]
for j in range(1,n+1):
    for i in range(n-j+1):
        DP[j][i]=max(A[i]-DP[j-1][i+1],A[i+j-1]-DP[j-1][i])
print(DP[n][0])

Measured memory_bytes: 113244
import java.util.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int rep = sc.nextInt();

        for(int u = 0; u < rep; u++){
            String a = sc.next();
            String b = sc.next();

            int longer;
            if(a.length() > b.length()){
                longer = a.length();
            }else{
                longer = b.length();
            }

            int[] sum = new int[longer+1];
            int memory = 0;

            for(int i = 1; i <= longer; i++){
                if(a.length() >= i && b.length() >= i){
                    memory = Integer.parseInt("" + a.charAt(a.length()-i)) + Integer.parseInt("" + b.charAt(b.length()-i)) + memory;
                    sum[i-1] = memory % 10;
                    memory = memory / 10;
                }else if(a.length() >= i && b.length() < i){
                    memory = Integer.parseInt("" + a.charAt(a.length()-i)) + memory;
                    sum[i-1] = memory % 10;
                    memory = memory / 10;
                }else{
                    memory = Integer.parseInt("" + b.charAt(b.length()-i)) + memory;
                    sum[i-1] = memory % 10;
                    memory = memory / 10;
                }
            }
            sum[longer] = memory;

            if(longer > 80 || (longer == 80 && sum[80] > 0)){
                System.out.println("overflow");
                continue;
            }

            boolean zero_check = true;

            for(int i = longer; i > 0; i--){
                if(zero_check && sum[i] == 0){
                    continue;
                }else if(zero_check && sum[i] > 0){
                    zero_check = false;
                    System.out.print(sum[i]);
                }else{
                    System.out.print(sum[i]);
                }
            }
            System.out.println(sum[0]);

        }
    }
}

Measured memory_bytes: 17376
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define ld long double
#define print(a,n) rep(i,1,n)cout <<a[i] <<" ";
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// stoll(s);
int main()
{
   BRAHAMASTRA
   ll t; t=1;
//    cin >>t;
   while(t--)
   {
      ll n; cin >>n;
      if(n%1000 !=0)
      {
          ll rem = n/1000+1;
          cout <<rem*1000-n<<endl;
      }
      else cout <<0<<endl;
   }
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    if(s[2]== s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(){
	int N;
	cin >>N;
	string p;
	for(int i =1;i<=N;i++){
		int j,k,l;
		cin >> j;
		cin >> k;
		cin >> l;
		if(j*j+k*k==l*l||k*k+l*l==j*j||l*l+j*j==k*k)
			p = p+"YES\n";
		else
			p = p+"NO\n";
		
	}
	cout << p;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(T &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it == v.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}

bool dfs(vector<vector<pi>> &v, vb &visited, vi &x, int q) {
  visited[q] = true;
  for (auto &&u : v[q]) {
    if (visited[u.fst]) {
      if (x[u.fst] != x[q] + u.snd) return false;
      continue;
    } else {
      x[u.fst] = x[q] + u.snd;
      if (!dfs(v, visited, x, u.fst)) return false;
    }
  }
  return true;
}

bool solve(vector<vector<pi>> &v, vb &visited, vi &x) {
  REP(i, v.size()) {
    if (visited[i]) continue;
    if (!dfs(v, visited, x, i)) return false;
  }
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pi>> v(n);
  vi x(n);
  vb visited(n);
  REP(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    v[l].pb(mp(r, d));
    v[r].pb(mp(l, -d));
  }

  cout << (solve(v, visited, x) ? "Yes" : "No") << endl;
}


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

namespace ConsoleApp11
{
    class Class10
    {
         public static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<double> A = Console.ReadLine().Split().Select(x=>1/double.Parse(x)).ToList();
            double sum = A.Sum();
            double ans = 1 / sum;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int bubbleSort(int A[],int N );
int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int c;
	c = 0;
	for(int i;i<n;i++){
	scanf("%d",&a[i]);
	}
	c = bubbleSort(a , n);
	
	
	for(int i = 0;i<n;i++){
		printf("%d",a[i]);
		
		if(i != n-1)printf(" ");
	}
	printf("\n");
	printf("%d\n",c);
	return 0;
}

int bubbleSort(int A[],int N){
	int flag = 1;
	int change;
	int count = 0;
	while(flag){
		flag = 0;
		
		for(int j = N-1;j > 0;j--){
			if(A[j] < A[j-1]){
				change = A[j];
				A[j] = A[j-1];
				A[j-1] = change;
				flag = 1;
				count++;
			}
		}
	}
	return count;
}


Measured memory_bytes: 2096