akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

using namespace std;

using ll = int64_t;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template <class T, class U>
ostream &operator<<(ostream &os, pair<T, U> const &p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math {
ll gcd(ll u, ll v) {
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;

    return ((m / math::gcd(m, n)) * n);
}
}  // namespace math

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}
    bool unionSet(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) { return root(x) == root(y); }
    ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    ll size(ll x) { return -data[root(x)]; }
};

template <class T, class U>
pair<T, U> operator+(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first + b.first, a.second + b.second);
}

template <class T, class U>
pair<T, U> operator-(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first - b.first, a.second - b.second);
}

ll bound(function<bool(ll)> f, ll ng, ll ok) {
    while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}


int main(void) {
    ll n;
    cin >> n;

    cout << 180 * (n - 2) << endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

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

int binarySearch_l(lld* p, int n, lld target){
    int l = 0, r = n-1;
    int m = (l+r+1)/2;
    while(l < r){
        if(*(p + m) <= target){
            l = m;
        }else{
            r = m-1;
        }
        m = (l+r+1)/2;
    }
    return m;
}
int binarySearch_r(lld* p, int n, lld target){
    int l = 0, r = n-1;
    int m = (l+r)/2;
    while(l < r){
        if(target <= *(p + m)){
            r = m;
        }else{
            l = m+1;
        }
        m = (l+r)/2;
    }
    return m;
}

lld calc(lld a){
    return a < 0 ? -1 * a : a;
}

int main(){
    int a, b, q;
    scanf("%d %d %d", &a, &b, &q);
    lld shrine[a], temple[b];
    rep(i, 0, a){
        scanf("%lld", &shrine[i]);
    }
    rep(i, 0, b){
        scanf("%lld", &temple[i]);
    }
    qsort(shrine, a, sizeof(lld), cmpAsc);
    qsort(temple, b, sizeof(lld), cmpAsc);
    lld ans[q];
    rep(i, 0, q){
        lld point;
        scanf("%lld", &point);
        lld x  , y  , z;
        lld x_l, y_l, z_l;
        lld buf = LLONG_MAX;
        x = temple[binarySearch_l(temple, b, point)];
        x_l = calc(point - x);
        y = shrine[binarySearch_l(shrine, a, x)];
        y_l = calc(x - y);
        z = shrine[binarySearch_r(shrine, a, x)];
        z_l = calc(x - z);
        x_l += y_l < z_l ? y_l : z_l;
        if(buf > x_l){
            buf = x_l;
        }
        x = temple[binarySearch_r(temple, b, point)];
        x_l = calc(point - x);
        y = shrine[binarySearch_l(shrine, a, x)];
        y_l = calc(x - y);
        z = shrine[binarySearch_r(shrine, a, x)];
        z_l = calc(x - z);
        x_l += y_l < z_l ? y_l : z_l;
        if(buf > x_l){
            buf = x_l;
        }
        x = shrine[binarySearch_l(shrine, a, point)];
        x_l = calc(point - x);
        y = temple[binarySearch_l(temple, b, x)];
        y_l = calc(x - y);
        z = temple[binarySearch_r(temple, b, x)];
        z_l = calc(x - z);
        x_l += y_l < z_l ? y_l : z_l;
        if(buf > x_l){
            buf = x_l;
        }
        x = shrine[binarySearch_r(shrine, a, point)];
        x_l = calc(point - x);
        y = temple[binarySearch_l(temple, b, x)];
        y_l = calc(x - y);
        z = temple[binarySearch_r(temple, b, x)];
        z_l = calc(x - z);
        x_l += y_l < z_l ? y_l : z_l;
        if(buf > x_l){
            buf = x_l;
        }
        ans[i] = buf;
    }
    rep(i, 0, q){
        printf("%lld\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 3956
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
#define MP make_pair

int main(void) {
    string s;

    cin>>s;
    int n=s.length();

    bool jud=true;

    for (int i = 0; i < n; i++) {
        if(s[i]!=s[n-1-i]&&jud){
            jud=false;
            cout<<"No\n";
        }


    }
    for (int i = 0; i < (n-1)/2; i++) {
        if(s[i]!=s[((n-2)/2)-i]&&jud){
            jud=false;
            cout<<"No\n";
        }


    }
    for (int i = ((n+3)/2)-1; i < n; i++) {

        if(s[i]!=s[n-1-i]&&jud){
            jud=false;
            cout<<"No\n";
        }


    }
    if(jud)cout<<"Yes\n";
    
    return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)

Measured memory_bytes: 25896
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

//MODINT
//変数名.nでint型の数値を受け取る
struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
 
mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int ii() { int x; scanf("%d", &x); return x; }
long long il() { long long x; scanf("%lld", &x); return x; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od(double x) { printf("%.15f ", x); }
void os(const string &s) { printf("%s ", s.c_str()); }
auto op = [&](auto p) -> void{ cout << p; };
auto ov = [&](auto vec) -> void{ cout << vec; };
void br() { putchar('\n'); }
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << p.first << " " << p.second;}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
	}
	return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// ----- template end ---- //
 
// ------- library ------- //



// ----- library end ----- //



int main() {
  //intは2*1e+9ちょいまで
  int N,K;
  N = ii(); K = ii();
  vector<int> vals(N);
  rep(i, N) vals[i] = ii();

  int ans = INF;
  rep(i, N-K+1){
    int rig = max(vals[i+K-1], 0);
    int lef = min(vals[i], 0);
    chmin(ans,  rig - lef + min(abs(rig), abs(lef)) );
  }

  ol(ans); br();

  
// -- main() end -- //
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a'|| c == 'e'){

      cout << "vowel" <<endl;  
  }
  else if (c == 'i'|| c =='o'){

      cout << "vowel" <<endl;

  }
  else if (c == 'u'){

      cout << "vowel" <<endl;
      
  }
  else {

      cout << "consonant"<<endl;
  }

    
  
  
}


Measured memory_bytes: 256
#include<stdio.h>

main()

{
    int H, N, sum=0, i, j;
    scanf("%d%d",&H,&N);

    int A[N];

    for(i=0; i<N; i++)
    {
        scanf("%d",&A[i]);
        sum = sum + A[i];
    }

    if(sum >= H)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;

}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  if(n==0){
    if(m==100)
      cout<<101<<endl;
    else cout<<m<<endl;
  }else if(n==1){
    if(m==100)
      cout<<(m+1)*100<<endl;
    else cout<<m*100<<endl;
  }else{
    if(m==100)
      cout<<(m+1)*10000<<endl;
    else cout<<m*10000<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
# N
# a1 a2 ... an

_n = gets.chomp
as = gets.chomp.split(" ").map(&:to_i)

s = as.sort

alice = 0
bob = 0

a = true

s.reverse_each do |i|
  if a
    alice += i
  else
    bob += i
  end

  a = !a
end

puts alice - bob


Measured memory_bytes: 1788
#include<stdio.h>

int main(void){
    long int N,i;
    scanf("%ld",&N);
    long int A[N],count[N],sum=0;
    for(i=0;i<N;i++){
        scanf("%ld",&A[i]);
        count[i]=0;
    }
    for(i=0;i<N;i++){
        count[A[i]-1]++;
    }
    for(i=0;i<N;i++){
        sum+=count[i]*(count[i]-1)/2;
    }
    for(i=0;i<N;i++){
        printf("%ld\n",sum-count[A[i]-1]+1);
    }
    return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vv vector<ll>
#define pp pair<ll,ll>
#define ff first
#define ss second
#define vp vector<pp>
#define dd double
#define pb push_back
#define mp make_pair

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n;
    cin>>k;
    string s;
    cin>>s;
    s[k-1]=s[k-1]+32;
    cout<<s;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int ans[1000],i=0;
  char ch[1000];
  while(1){
    if(scanf("%s",ch)==EOF)break;
  
    if(ch[0]!='+'&&ch[0]!='-'&&ch[0]!='*')ans[i]=atoi(ch);
    else {
    if(ch[0]=='+')ans[i-2]+=ans[i-1];
    else if(ch[0]=='-')ans[i-2]-=ans[i-1];
    else if(ch[0]=='*')ans[i-2]*=ans[i-1];
    i-=2;
    }
    i++;
  }
    cout<<ans[0]<<endl;
    return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int num = 1;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(num == a) {
				num++;
			} else {
				ans++;
			}
		}
		if(num == 1) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 67500
#include<stdio.h>
int main(void){
    int a[3000]={},b[3000]={},i,j,m;
    i=0;
    while(1){
       scanf("%d %d",&a[i],&b[i]);
       if(a[i]==0&&b[i]==0){
           break;
       }
       i++;
    }
    for(j=0;j<i;j++){
        if(a[j]>b[j]){
            m=a[j];
            a[j]=b[j];
            b[j]=m;
        }
        printf("%d %d\n",a[j],b[j]);
    }
    return 0;
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pii, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, M;
    cin >> N >> M;
    dsu d(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        d.merge(A, B);
    }

    int ans = 0;
    vector<bool> seen(N);
    for (int i = 0; i < N; ++i) {
        if (!seen[d.leader(i)]) {
            seen[d.leader(i)] = true;
            ans++;
        }
    }

    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 3748
import sys
import heapq

N, M = list(map(int, input().split()))
jobs = []
for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue
    jobs.append((A, B))

jobs.sort(reverse=True)

q = []
ans = 0
for i in range(1, M + 1):
    while jobs and jobs[-1][0] <= i:
        A, B = jobs.pop()
        heapq.heappush(q, -B)

    if q:
        ans += -heapq.heappop(q)
print(ans)


Measured memory_bytes: 17204
// AOJ 1632 Scores of Final Examination
// bal4u 2019.8.12

#include <stdio.h>

typedef long long ll;

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i;
	char b[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

//// 本問題関連
int p[52][1002];
		
int main()
{
	int n, m, r, c, a, ans;
	
	while (n = in()) {
		m = in();
		for (r = 0; r < m; r++) for (c = 0; c < n; c++) p[r][c] = in();
		ans = 0;
		for (c = 0; c < n; c++) {
			a = 0; for (r = 0; r < m; r++) a += p[r][c];
			if (a > ans) ans = a;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	int n,k,q;
	cin >> n >> k >> q;
	int ans[n];
	 rep(i,n) {
                ans[i] = 0;
        }
	int a;
	rep(i,q) {
		cin >> a;
		ans[a-1] += 1;
	}
	rep(i,n) {
		if (0 < k + (ans[i] - q)) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#coding:utf-8
import fractions
a, b, c, d = map(int, input().split())

# cで割り切れる個数を求める
c_div = (b // c) - ((a-1) // c)
#print(c_div)

# dで割り切れる個数を求める
d_div = (b // d) - ((a-1) // d)
#print(d_div)

# cとd両方で割り切れる数を求める
cd = (c * d) // fractions.gcd(c, d)
cd_div = (b // cd) - ((a-1) // cd)
#print(cd_div)

div =  c_div  + d_div - cd_div

print((b-a+1)-div)

Measured memory_bytes: 5088
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
#define ll long long
using namespace std;

int main() {
	int a[6], max_n, max_d, ans = 0;
	max_d = 10;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (max_d > a[i] % 10 && a[i] % 10 != 0) {
			max_n = i;
			max_d = a[i] % 10;
		}
	}
	for (int i = 0; i < 5; i++) {
		if (i == max_n)continue;
		while (a[i] % 10 > 0)a[i]++;
	}
	for (int i = 0; i < 5; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

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

    int ans = 0;
    while((b-a) * (b-a+1) / 2 != b){
        b++;
        a++;
        ans++;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n)ans ^= a[i];
    rep(i,n)cout << (ans^a[i]) << " ";
    cout << endl;
}

Measured memory_bytes: 4708
class UnionFind():
    def __init__(self,n):
        # リンク情報　子→親の番号　親(根)→負のサイズ
        self.d=[-1 for i in range(n)]
    
    def find(self,x):
        if(self.d[x]<0):return x
        self.d[x]=self.find(self.d[x])
        return self.d[x]

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):return False
        if(self.d[x]>self.d[y]):x,y=y,x
        self.d[x]+=self.d[y]
        self.d[y]=x
        return True

    def same(self,x,y):return self.find(x)==self.find(y)
    def size(self,x):return -1*self.d[self.find(x)]

n,m,k=map(int,input().split())
uf=UnionFind(n)
deg=[0 for i in range(100005)]
to=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    uf.unite(a,b)
    deg[a]+=1
    deg[b]+=1

for i in range(k):
    a,b=map(int,input().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)

for i in range(n):
    ans=uf.size(i)-1-deg[i]
    for j in to[i]:
        if(uf.same(i,j)):ans-=1
    print(ans,end=" ")

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

int calc(std::vector<int> a, size_t i, int sum) {
  if (i == 0)
    return a.at(i);
  int x = a.at(i) + calc(a, i - 1, sum);
  a.at(i - 1) -= 1;
  int y = 9 + calc(a, i - 1, sum);
  return std::max(x, y);
}

int main(int argc, char *argv[]) {
  long n;
  std::cin >> n;
  std::vector<int> a;
  while (n >= 1) {
    a.push_back(n % 10);
    n /= 10;
  }
  std::reverse(a.begin(), a.end());

  std::cout << calc(a, a.size() - 1, 0) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C,D;
    cin >>A>>B>>C>>D;
    int x,y;
    x = (A+D-1)/D;
    y = (B+C-1)/B;
    if (x>=y)
    {
        cout<<"Yes"<<"\n";
    }
    else cout<<"No"<<"\n";



    return 0;
}


Measured memory_bytes: 3620
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BMaximumSum {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c, k;
	    in >> a >> b >> c >> k;
	    vector<int> v{a, b, c};
	    sort(v.begin(), v.end());
	    while(k > 0){
	        v[2] *= 2;
	        k--;
	    }
	    out << v[0] + v[1] + v[2] << endl;
	}
};


int main() {
	BMaximumSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t,dp[N],a[N],b[N];

ll f(int ind)
{
	if(ind<=0)
		return 0;
	if(dp[ind]!=-1)
		return dp[ind];
	ll t=INT_MAX;
	for(int i=1;i<=n;i++)
	{
		t=min(t,f(ind-a[i])+b[i]);
	}
	return dp[ind]=t;
}

int main()
{
	fast;
	memset(dp,-1,sizeof(dp));
	cin>>m>>n;
	// cout<<(n+m-1)/m
	fo(i,1,n)
	cin>>a[i]>>b[i];
	cout<<f(m);
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;

int inf = 1e9;

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

  ll n, m;
  cin >> n >> m;

  int a, b, c;
  vvi d(n, vi(n, inf));
  vvi used(n, vi(n, 0)), e(n, vi(n, -1));
  
  REP(i, n) d[i][i] = 0;
  REP(i, m){
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = d[b][a] = c;
    e[a][b] = e[b][a] = c;
  }

  REP(k, n){
    REP(i, n){
      REP(j, n){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  REP(s, n){
    REP(i, n){
      REP(j, n){
        if(e[i][j] > 0 && d[s][i] == d[s][j] + e[i][j]){
          used[i][j] = used[j][i] = 1;
        }
      }
    }
  }

  int ans = 0;
  REP(i, n){
    REP(j, n){
      if(e[i][j] > 0 && used[i][j] == 0) ans++;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;
ll a[3000][3000], dp[3000][3000][4];

void solve () {
	int n, m, k;
	cin >> n >> m >> k;
	ll x, y, val;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			a[i][j] = 0;
		}
	}
	for (int i = 0; i < k; i++) {
		cin >> x >> y >> val;
		x--; y--;
		a[x][y] = val;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int p = 0; p < 4; p++) 
				dp[i][j][p] = 0;
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			for (int p = 1; p < 4; p++) {
				if (i == n - 1 && j == m - 1) {
					dp[i][j][p] = a[i][j];
				}
				else if (i == n - 1) {
					dp[i][j][p] = max(a[i][j] + dp[i][j + 1][p - 1], dp[i][j + 1][p]);
				}
				else if (j == m - 1) {
					dp[i][j][p] = a[i][j] + dp[i + 1][j][3];
				}
				else {
					dp[i][j][p] = max({a[i][j] + dp[i + 1][j][3], a[i][j] + dp[i][j + 1][p - 1], dp[i][j + 1][p]});
				}
				for (int z = p - 1; z >= 0; z--) {
					dp[i][j][p] = max(dp[i][j][p], dp[i][j][z]);
				}
			}
		}
	}
	cout << dp[0][0][3] << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t = 1;
	while (t--) {
		solve();
	}
 	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int q;
    cin>>q;
    int flag=0;
    string mae,ushi;
    mae="";
    ushi="";
    for (int i = 0; i < q; ++i) {
        int ty;
        cin >> ty;
        if (ty == 1)flag = 1 - flag;
        else {
            int a;
            cin >> a;
            char c;
            cin >> c;
            if (a == 1 && flag == 0) { //前
                mae = c + mae;
            }
            if (a == 1 && flag == 1) {
                ushi = ushi + c;
            }
            if (a == 2 && flag == 0) {
                ushi = ushi + c;
            }
            if (a == 2 && flag == 1) {
                mae = c + mae;
            }
        }
    }
    if(flag==0) {
        cout << mae;
        cout << s;
        cout << ushi << endl;
    }
    else{
        s=mae+s+ushi;
        for (int i = 0; i < s.length(); ++i) {
            cout<<s[s.length()-i-1];
        }
    }
    return 0;
}

Measured memory_bytes: 1392
def solve():
    N, *Ll = map(int, open(0).read().split())
    Ll.sort()
    ans = 0
    
    for i in range(N-1, 0, -1):
        a = 0
        b = i - 1
        while(a < b):
            if Ll[a] + Ll[b] > Ll[i]:
                ans += b - a
                b -= 1
            else:
                a += 1
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3188
s = input()
ans = len(s)
for k in range(2):
    pen = 0
    for i in range(len(s)):
        if k == 0:
            if i % 2 == 0 and s[i] == '0':
                pen += 1
            if i % 2 == 1 and s[i] == '1':
                pen += 1
        if k == 1:
            if i % 2 == 0 and s[i] == '1':
                pen += 1
            if i % 2 == 1 and s[i] == '0':
                pen += 1
    ans = min(ans, pen)

print(ans)


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

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

    long long ai;
    vector<long long> a(n);
    vector<int> sum(42);
    for (int i = 0; i < n; i++)
    {
        cin >> ai;
        a.at(i) = ai;

        for (int bit = 0; bit <= 41; bit++)
        {
            if (ai & ((long long)1<<bit)) {
                sum.at(bit)++;
            }
        }
        
    }
    
    long long x = 0;
    bool down = false;
    int start = 41;
    while (!(k & ((long long)1<<start)) && start > 0) {
        start--;
    }
    for (long long i = start; i >= 0; i--) {
        if (k & ((long long)1<<i)) {
            if (sum.at(i) >= n - n / 2) {
                down = true;
            }
            else x |= ((long long)1<<i);
        }
        else {
            if (sum.at(i) < n / 2) {
                if (down) x |= ((long long)1<<i);
            }
        }
    }
    
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += a.at(i) ^ x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d",&n);
	static int l[499999],r[499999];
	rep(u,n-1) scanf("%d%d",l+u,r+u), l[u]--, r[u]--;

	static int depth[499999];
	rep(u,n-1){
		if(l[u]!=n-1) depth[l[u]]=depth[u]+1;
		if(r[u]!=n-1) depth[r[u]]=depth[u]+1;
	}

	static int leaf[500000]; // leaf[u] := ( 頂点 u を根とする部分木の葉の数 )
	static ll dp1[500000]; // dp1[u] := ( 頂点 u を根とする部分木について, セーブ機能を使わないときの答え )
	static ll dp2[500000]; // dp2[u] := ( 頂点 u を根とする部分木についての最適解 )
	leaf[n-1]=1;
	for(int u=n-2;u>=0;u--){
		leaf[u]=leaf[l[u]]+leaf[r[u]];

		dp1[u]=leaf[u]+dp1[l[u]]+dp1[r[u]];

		dp2[u]=1+dp2[l[u]]+depth[u]+1+dp2[r[u]];
		dp2[u]=min(dp2[u],leaf[l[u]]+dp1[l[u]]+1+dp2[r[u]]);
		dp2[u]=min(dp2[u],leaf[r[u]]+dp1[r[u]]+1+dp2[l[u]]);
	}

	printf("%lld\n",dp2[0]);

	return 0;
}

Measured memory_bytes: 16648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {

    int a,b;
    cin>>a>>b;
    string s="",t="";
    rep(i,a){
        s+=b+'0';
    }
    rep(i,b){
        t+=a+'0';
    }
    fin(min(s,t));
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	long long x,y;
	scanf("%lld%lld",&x,&y);
	long long z=y/x;
	int cnt=0;
	while(z>=1)
	{
		z=z/2;
		cnt++;
	} 
	printf("%d\n",cnt); 
	return 0;
}

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

int main(){
    int N; cin>>N;
    string S; cin>>S;
    
    //各文字の累積和
    vector<int> Rv(N),Gv(N),Bv(N);
    int R=0,G=0,B=0;
    rep(i,N){
        if(S[i]=='R') R++;
        if(S[i]=='G') G++;
        if(S[i]=='B') B++;
        Rv[i]=R; Gv[i]=G; Bv[i]=B;
    }
    
    // for(int x:Bv){
    //     cout << x << " ";
    // }
    
    ll ans=0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            if(S[i]==S[j]) continue;
            
            if((S[i]=='R' && S[j] =='G') || (S[j]=='R' && S[i] =='G')){
                ans += Bv[N-1] -Bv[j];
                if(2*j-i < N && S[2*j-i]=='B') ans--;
            }
            if((S[i]=='R' && S[j] =='B') || (S[j]=='R' && S[i] =='B')){
                ans += Gv[N-1] -Gv[j];
                if(2*j-i < N && S[2*j-i]=='G') ans--;
            }
            if((S[i]=='G' && S[j] =='B') || (S[j]=='G' && S[i] =='B')){
                ans += Rv[N-1] -Rv[j];
                if(2*j-i < N && S[2*j-i]=='R') ans--;
            }
        
        }
    }
    
    cout << ans << endl;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll recur(ll i,vector<ll>&v)
{
   // if(i==v.size()) return INT_MAX;
    if(i==v.size()-1) return 0;
    ll m1=recur(i+1,v)+abs(v[i+1]-v[i]);
    ll m2=LLONG_MAX;
    if(i+2<v.size()) m2=recur(i+2,v)+abs(v[i+2]-v[i]);
    return min(m1,m2);
}
void solve()
{
   ll n; cin>>n;
   ll k; cin>>k;
   vector<ll>v(n);
   rep(i,n) cin>>v[i];
   ll dp[n];
   dp[0]=0;
   dp[1]=abs(v[0]-v[1]);
   for(int i=2;i<n;i++)
   {
    dp[i]=-1;
       for(int j=i-1;j>=max((ll)0,i-k);j--)
        {
            if(dp[i]==-1)
                dp[i]=abs(v[i]-v[j])+dp[j];
            else dp[i]=min(dp[i],abs(v[i]-v[j])+dp[j]);
        }
   }
   cout<<dp[n-1];
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; ++i) cin >> d[i];
    sort(begin(d), end(d));

    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

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



int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int cal[3];
    cal[0] = a+b;
    cal[1] = b+c;
    cal[2] = a+c;
    int min = 500000;
    rep(i,3){
        if(cal[i] < min){
            min = cal[i];
        }
    }
    cout << min << endl;
    
    return 0;
}


























Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


//ABC088_b
int main() {
	int N;
	cin >> N;
	vector<int> vec(110);
	rep(i, N) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());

	int sum_a = 0;
	int sum_b = 0;
	rep(i, N) {
		if (i%2==0) {
			sum_a += vec.at(i);
		}
		else {
			sum_b += vec.at(i);
		}
	}
	cout << sum_a - sum_b << endl;
}

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

int main() {
  int a, b, c, r = 0;
  cin >> a >> b >> c;

  if (abs(c-a)+abs(b-c) <= abs(b-a)+abs(c-b)) r = abs(c-a)+abs(b-c);
  else r = abs(b-a)+abs(c-b);
  if (r >= abs(c-b)+abs(a-c)) r = abs(c-b)+abs(a-c);
  if (r >= abs(a-b)+abs(c-a)) r = abs(a-b)+abs(c-a);
  if (r >= abs(b-c)+abs(a-b)) r = abs(b-c)+abs(a-b);
  if (r >= abs(a-c)+abs(b-a)) r = abs(a-c)+abs(b-a);
  cout << r << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
    ll inf = 10e9 + 1;
    ll n, d, a;
    cin >> n >> d >> a;

    vector<pair<ll, ll>> m(n);
    for (int i = 0; i < n; i++){
        cin >> m[i].first >> m[i].second;
    }
    sort(m.begin(), m.end());

    int idx = 0;
    ll k, h;
    ll ans = 0;
    vector<ll> v(n + 1, 0);
    for (int i = 0; i < n; i++){
        v[i + 1] += v[i];
        h = m[i].second - v[i + 1];
        if (h <= 0) continue;
        k = (h + a - 1) / a;
        ans += k;
        pair<ll, ll> x(m[i].first + 2 * d, inf);
        idx = upper_bound(m.begin() + i, m.end(), x) - m.begin();
        v[i + 1] += k * a;
        v[idx + 1] -= k * a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void){
	long long int n,m=0,a=0,temp;
	scanf("%lld %lld",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%lld",&temp);
		a+=temp;
	}
	if(a>n){
		printf("-1");
	}else{
		printf("%lld",n-a);
	}
}

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

int main(){
  bool output;
  char before_char, current_char;
  cin >> before_char;
  output = false;
  for(int i=0; i<3; i++){
    cin >> current_char;
    if(before_char == current_char){
      output = true;
    }
     before_char = current_char;
  }
  if(output){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  } 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (1<<30)
using namespace std;

int N;

//bit動的計画法
int solve(vector< vector<int> > T){
    int SizeofSets = (1<<N);
    vector<int> dp(SizeofSets,INF);
    dp.at(0)=0;
    for(int i=1;i<SizeofSets;i++){
        for(int j=0;j<N;j++){
            if((i>>j)&1){
                int cur=T.at(j).at(0);
                for(int k=0;k<N;k++){
                    if(((i>>k)&1)&&(k!=j)){
                        cur=min(cur,T.at(j).at(k+1));
                    }
                }
                dp.at(i)=min(dp.at(i),dp.at(i-(1<<j))+cur);
            }
        }
    }
    return dp.at(SizeofSets-1);
}

int main(){
    cin >> N;
    while(N!=0){
        //Tを読む
        vector< vector<int> > T(N,vector<int>(N+1));
        for(int i=0;i<N;i++){
            for(int j=0;j<=N;j++){
                cin >> T.at(i).at(j);
            }
        }

        int ans = solve(T);
        cout << ans << endl;

        cin >> N;
    }
}


Measured memory_bytes: 3336
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int dis[305][305];

vector <pair<int, pii>> Vu;
int main() {
	int N, i, j;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			scanf("%d", &dis[i][j]);
			if (i < j) Vu.emplace_back(dis[i][j], pii(i, j));
		}
	}
	sort(all(Vu));

	ll ans = 0;
	for (auto it : Vu) {
		int x = it.second.first, y = it.second.second;
		bool chk = false;
		for (i = 1; i <= N; i++) {
			if (i == x || i == y) continue;
			if (dis[x][i] + dis[i][y] < dis[x][y]) return !printf("-1\n");
			if (dis[x][i] + dis[i][y] == dis[x][y]) chk = true;
		}
		if (!chk) ans += dis[x][y];
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 1276
import sys
readline = sys.stdin.readline
from collections import deque

def main():
    N, M = map(int, readline().rstrip().split())
    path = [[False] * N for _ in range(N)]
    for _ in range(M):
        a, b = map(int, readline().rstrip().split())
        path[a-1][b-1] = True
        path[b-1][a-1] = True
    
    que = deque([[0]])  # 訪れた順にノードを格納
    cnt = 0
    while que:
        visited = que.popleft()
        if len(visited) == N:
            cnt += 1
            continue
        pre = visited[-1]
        for next in range(N):
            if next not in visited and path[pre][next]:
                que.append(visited+[next])
            
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
 
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++) 
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll POW(ll x, ll n){
	ll res = 1;
	while(n){
		if(n%2)	res *= x;
		n >>= 1;
		x *= x;
		
		res %= MOD;
		x %= MOD;
	}
	
	return res;
}

ll C(ll a, ll b){
	if(b > a)	return 0;
	ll res = 1;
	
	rep(i, b){
		res *= (a - i);
		res %= MOD;
	}
	
	rep1(i, b){
		res *= POW(i, MOD-2);
		res %= MOD;
	}
	
	return res;
	
}

void solve(){
	ll n, a, b;
	cin >> n >> a >> b;

	cout << ((POW(2,n) - 1 - C(n,a) - C(n,b))%MOD + MOD) % MOD << '\n';
}

int main(){
	int T = 1;
	
	while(T--){
		solve();
	}
}




Measured memory_bytes: 384
import           Data.Array
import           Data.List

type Value = Int
type Cost = Int
type Score = Int
type Gem = (Value, Cost)

score :: Gem -> Score
score (v, c) = v - c

solve :: [Score] -> Score
solve scores = dp ! imax
  where
    dp = array (0, imax) [(i, f i) | i <- [0..imax]]
    f 0 = 0
    f i = let s = scores !! (i - 1) -- i番目のスコア
          in  maximum [ s                 -- i 番目だけ買う
                      , dp ! (i - 1)      -- i 番目を買わない
                      , dp ! (i - 1) + s  -- i 番目も買う
                      ]
    imax = length scores

main :: IO ()
main = do
  _ <- getLine -- N
  vs <- map read . words <$> getLine :: IO [Score]
  cs <- map read . words <$> getLine :: IO [Score]

  let scores = zipWith (curry score)  vs cs

  print $ solve scores


Measured memory_bytes: 636
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int c = scanner.nextInt();
		int[][] hyou = new int[r + 1][c + 1];
		for (int i = 0; i < r; ++i) {
			for (int j = 0; j < c; ++j) {
				hyou[i][j] = scanner.nextInt();
				hyou[r][j] += hyou[i][j];
				hyou[i][c] += hyou[i][j];
				hyou[r][c] += hyou[i][j];
			}
		}
		for (int i = 0; i <= r; ++i) {
			for (int j = 0; j <= c; ++j) {
				if (j != 0){
				    System.out.print(' ');
				} 
				System.out.print(hyou[i][j]);
			}
			System.out.println();
		}
	}
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a + b, b + c, c + a}) << endl;
    return 0;
}



Measured memory_bytes: 256
class Main {
  public static void main(String[] args) {
    int s = new java.util.Scanner(System.in).nextInt();
    int h = s / 3600;
    int m = (s - h * 3600) / 60;
    s = s % 60;
    System.out.println(h + ":" + m + ":" + s);
  }
}


Measured memory_bytes: 26368
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 200000
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
char s[maxn];
int cnt[maxn];
int n;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	int last=0,tot=0;
	for(int i=0;i<=n;i++)
		if(s[i]!=s[i+1]){
			cnt[++tot]=i-last+1;
			last=i+1;
		}
	int ans=0;
	for(int i=1;i<=tot;i++)
		if(cnt[i]%3==0)ans+=cnt[i]/3*2;
		else if(cnt[i]%3==1)ans+=cnt[i]/3*2+1;
		else{
			ans+=cnt[i]/3*2+1;
			if(i<tot)--cnt[i+1],++ans;
		}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int time = 0;
	VI T(N), V(N);
	REP(i, N) {
		cin >> T[i];
		if (i != 0)T[i] += T[i - 1];
	}
	REP(i, N)cin >> V[i];
	double v[101010];
	REP(i, 101010)v[i] = INF;
	int k = 0;
	int now = 0;
	while (now <= T[k] * 2) {
		//cout << now << endl;
		v[now] = min(v[now], (double)V[k]);
		now++;
		if (now > T[k] * 2) {
			k++;
			if(k!=N)v[now - 1] = min(v[now - 1], (double)V[k]);
		}
		if (k == N)break;
	}

	v[0] = 0;
	eFOR(i, 1, T[N - 1] * 2) {
		v[i] = min(v[i], v[i - 1] + 0.5);
	}
	v[T[N - 1] * 2] = 0;
	for (int i = T[N - 1] * 2 - 1; i > 0; i--) {
		v[i] = min(v[i], v[i + 1] + 0.5);
	}
	double ans = 0;

	eFOR(i, 1, T[N - 1] * 2) {
		//cout << v[i] << " " << i << endl;
		double tmp = (v[i] + v[i - 1]);
		
		
		ans += tmp * 0.25;
		//cout << i << " " << ans << endl;
	}

	

	printf("%.10f\n", ans);

	return 0;
}



Measured memory_bytes: 1024