akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] p = new int[2];
        for (int i = 0; i < 2; i++) {
            int a1, a2, a3;
            p[i] += a1 = in.nextInt();
            p[i] += a2 = in.nextInt();
            p[i] += a3 = in.nextInt();
            for (int j = 4; j <= 10; j++) {
                int aj = in.nextInt();
                if (aj > a1) {
                    p[i] += (aj - a1);
                    int c = a1;
                    a1 = aj;
                    aj = c;
                }
                if (aj > a2) {
                    p[i] += (aj - a2);
                    int c = a2;
                    a2 = aj;
                    aj = c;
                }
                if (aj > a3) {
                    p[i] += (aj - a3);
                    int c = a3;
                    a3 = aj;
                    aj = c;
                }
            }
        }
        System.out.println(new StringBuilder().append(p[0]).append(' ')
                .append(p[1]));
    }
}


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

int search_max_sugar(int max_sugar, set<int> &s){
    int res=0;
    for(auto s1: s) {
        if(s1 > max_sugar){break;}
        res = s1;
    }
    return res;
}

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    set<int> water,sugar;
    for(int i = 0; 100*a*i <= f ; i++){
        for(int j = 0; 100*a*i+100*b*j <= f; j++){
            water.insert(100*a*i+100*b*j);
        }
    }
    for(int i = 0; c*i <= f ; i++){
        for(int j = 0; c*i+d*j <= f; j++){
            sugar.insert(c*i+d*j);
        }
    }
    pair<int,int> ans;
    int tmp;
    double max_cardinality=-1.0;
    for(auto s: water){
        tmp = search_max_sugar(min(e*s/100, f-s) , sugar);
        double cardinality = (double)100*tmp/(s+tmp);
        if(max_cardinality < cardinality){
            max_cardinality = cardinality;
            ans.first = s+tmp;
            ans.second = tmp;
        }
    }



    cout << ans.first << " " << ans.second <<"\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int A , B;
    string S ,T ,U;
    cin >> S >> T >> A >> B >> U;
    if(U == S){
        A-=1;
        cout << A << " " << B << endl;
    }
    else if( U == T){
        B-=1;
        cout << A << " " << B <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

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

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

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

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

//DigitSum
long long DigitSum(long long N, long long K) {
	long long sum = 0;
	for (; N > 0; N /= K) sum += N % K;
	return sum;
}

int main() {
	ll n, s; cin >> n >> s;
	corner(n == s, n + 1);
	for (ll b = 2; b*b <= n; ++b) corner(DigitSum(n, b) == s, b);
	corner(n <= s, -1);
	for (ll t = (ll)sqrt(n); 1 <= t; --t) if((n - s) % t == 0) corner(DigitSum(n, (n-s)/t+1) == s,(n-s)/t+1);
	print(-1);
	return 0;
}



Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
MAX_DIGIT = 40

def main():
    N, K = map(int, readline().rstrip().split())
    K_bin = bin(K)[2:].zfill(MAX_DIGIT)
    A = list(map(int, readline().rstrip().split()))
    A = [bin(a)[2:].zfill(MAX_DIGIT) for a in A]
    dp = [[-1] * 2 for _ in range(MAX_DIGIT+1)]
    # dp[i][j=0,1] = f, 上からi桁まで決めて、j=0: 今のところkと一致, j=1: k未満が確定

    dp[0][0] = 0
    mul = 2 ** (MAX_DIGIT - 1)
    for d in range(MAX_DIGIT):
        cnt = len([1 for a in A if a[d] == '1'])  # Aで元々d桁目にビットが立っているものの個数
        gain0 = cnt * mul
        gain1 = (N - cnt) * mul

        # k未満が確定 -> k未満が確定
        if dp[d][1] != -1:
            # d桁目でk未満が確定しているので、d+1桁目では0でも1でも自由に大きい方を選べる
            dp[d+1][1] = max(dp[d+1][1], dp[d][1] + max(gain0, gain1))
        
        # 今のところkと一致 -> k未満が確定
        if dp[d][0] != -1:
            # Kのd桁目が1だったら、Xのd桁目は0にする
            if K_bin[d] == '1':
                dp[d+1][1] = max(dp[d+1][1], dp[d][0] + gain0) 

        # 今のところkと一致 -> 今のところkと一致
        if dp[d][0] != -1:
            # Kのd桁目と合わせる
            if K_bin[d] == '1':
                dp[d+1][0] = max(dp[d+1][0], dp[d][0] + gain1)
            else:
                dp[d+1][0] = max(dp[d+1][0], dp[d][0] + gain0)
        
        mul //= 2
    
    print(max(dp[MAX_DIGIT]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 17892
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


struct P
{
	int a, b;
	P(int x, int y) {
		int g = std::gcd(x,y);
		if(g!=0) {x/=g; y/=g;}
		a=x;b=y;
		if(a<0) {
			a*=-1;b*=-1;
		}
		if(a==0&&b<0) {
			b*=-1;
		}
	}
	bool operator<(const P rhs) const {
		if(a!=rhs.a) return a<rhs.a;
		return b<rhs.b;
	}
};

signed main() {
	int n;
	std::cin >> n;
	std::vector<std::pair<int,int> > a;
	std::map<P,int> map;
	rep(i,n) {
		int x,y;
		std::cin >> x >> y;
		a.emplace_back(x,y);
		map[P(x,y)]++;
	}


	for(auto x:map) {
		debug(x.first.a,x.first.b,x.second);
	}

	mint ans=1;
	mint ans2=0;
	if(map.count(P(0,0))) {
		ans2+=map[P(0,0)];
		map[P(0,0)]=0;
	}
	for(auto x:map) {
		if(x.second==0) continue;
		mint mul=mint(2).pow(x.second);
		P rev(-x.first.b,x.first.a);
		if(map.count(rev)) {
			debug(map[rev]);
			mul+=mint(2).pow(map[rev]);
			mul-=1;
			map[rev]=0;
		}
		ans*=mul;
	}
	debug(ans);
	print(ans+ans2-1);
	return 0;
}


Measured memory_bytes: 18688
#include <stdio.h>

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

	/* 	1+2 = 3
		1+3 = 4
		2+3 = 5
	*/

	if(a + b == 3)
		printf("3\n");
	else if(a + b == 4)
		printf("2\n");
	else
		printf("1\n");

	return 0;
}

Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort(reverse=True)
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if(l[i]!=l[j])and(l[j]!=l[k])and(l[i]!=l[k])and(l[i]<l[j]+l[k]):
        ans += 1
print(ans)



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

signed main () {
    int64_t k;
    cin >> k;
    int n = 50; 
    int64_t t = (k + 49) / 50 * 50;
    vector < int64_t > a(n, t / 50 + 49);
    while (t > k) {
        auto it = max_element(begin(a), end(a));
        for (auto &x : a)
            ++x;
        (*it) -= 51;
        --t;
    }
    cout << 50 << '\n';
    for(int i = 0; i < n; ++i)
        cout << a[i] << ' ';
    cout << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()
#define clr(a,v) memset((a),(v),sizeof(a))

using ll = long long;

constexpr int MAX_N = 100010;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll N, K;
std::vector<ll> G[MAX_N];
ll L[MAX_N], R[MAX_N], A[MAX_N];
bool used[MAX_N];
bool fl = true;

bool dfs( int v, int prv )
{
  used[v] = true;

  //printf( "(%d,%d)\n", v, prv );

  for( auto &u : G[v] ) if( !used[u] )
  {
    /*if( R[u] < L[v]-1 || R[v]+1 < L[u] )
    { fl = false; return false; }

    L[u] = std::max( L[u], L[v]-1 );
    R[u] = std::min( R[u], R[v]+1 );*/

    if( !dfs( u, v ) )
      return false;
  }

  if( R[prv] < L[v]-1 || R[v]+1 < L[prv] )
  { fl = false; return false; }

  L[prv] = std::max( L[prv], L[v]-1 );
  R[prv] = std::min( R[prv], R[v]+1 );

  return true;
}

void calc( int v, int prv )
{
  used[v] = true;

  //printf( "{%d}\n", v+1 );

  if( v == prv )
    A[v] = std::max( 0ll, L[v] );
  else if( L[v] <= A[prv]+1 && A[prv]+1 <= R[v] )
    A[v] = A[prv]+1;
  else if( L[v] <= A[prv]-1 && A[prv]-1 <= R[v] )
    A[v] = A[prv]-1;
  else
    fl = false;

  for( auto &u : G[v] ) if( !used[u] )
    calc( u, v );

  return;
}

int main()
{
  scanf( "%lld", &N );
  rep( i, N-1 )
  {
    ll a, b;
    scanf( "%lld%lld", &a, &b );
    --a; --b;
    G[a].emplace_back( b );
    G[b].emplace_back( a );
  }

  scanf( "%lld", &K );

  std::fill( L, L+N, -INF );
  std::fill( R, R+N, INF );

  rep( i, K )
  {
    ll V, P;
    scanf( "%lld%lld", &V, &P );
    --V;
    L[V] = R[V] = A[V] = P;
  }

  clr( used, false );

  dfs( 0, 0 );

  //rep( i, N )
    //printf( "[%d] [%d,%d]", i+1, L[i], R[i] );

  //puts( fl ? "[Yes]" : "[No]" );

  clr( used, false );

  calc( 0, 0 );

  //rep( i, N )
    //printf( "[%d] %lld\n", i+1, A[i] );

  if( !fl )
  {
    puts("No");

    return 0;
  }


  puts("Yes");

  rep( i, N )
    printf( "%lld\n", A[i] );
  
  return 0;
}

Measured memory_bytes: 13568
a, b = map(int, input().split())

A = []
A.append(list('.'*(b+2)))
for i in range(a):
    A.append(list('.'+input()+'.'))
A.append(list('.'*(b+2)))
count=0
for j in range(1, a+1):
    for k in range(1, b+1):
        if(A[j][k] == '#'):
            print('#', end='')
        else:
            for l in range(-1, 2):
                for m in range(-1, 2):
                    if(A[j+l][k+m]== '#'):
                        count+=1
            print(count, end='')
        count=0
    print()




Measured memory_bytes: 3444
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut n: u32 = sc.read();
    let mut a = n / 100;
    let mut b = n % 100;

    let mut yymm_flag = false;
    let mut mmyy_flag = false;
    if a >= 1 && a <= 12 {
        mmyy_flag = true;
    }

    if b >= 1 && b <= 12 {
        yymm_flag = true;
    }

    if yymm_flag && mmyy_flag {
        println!("{}", "AMBIGUOUS");
    } else if yymm_flag {
        println!("{}", "YYMM");
    } else if mmyy_flag {
        println!("{}", "MMYY");
    } else {
        println!("{}", "NA");
    }
}

Measured memory_bytes: 2040
<?php
fscanf(STDIN, "%s", $s['a']);
fscanf(STDIN, "%s", $s['b']);
fscanf(STDIN, "%s", $s['c']);

$t = 'a';
while ($s[$t]) {
	$n = $s[$t][0];
	$s[$t] = substr($s[$t], 1);
	$t = $n;
}
echo strtoupper($t), "\n";

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    int a,b,c,count=0;
    cin >> a >> b >> c ;
    if(c*a <= b){
        cout << c << endl;
        return 0;
    }
    else{
        while(1){
            ++count;
            if(count * a > b){
                cout << count-1 << endl;
                return 0;
            }
        }
    }
    return -1;
}

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

int main(){
    int frag;
    char s;
    cin >> s;

    frag = 0;
    vector<char> vec(26);
    vec = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

    for(int i=0; i<26; i++){
        if(s==vec.at(i)){
            frag = 1;
        }
    }

    if(frag==0){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dx[] = { -1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = { -1 , -1 , -1, 0 , 0 , 1 , 1 , 1};
int dy2[] = { -1 , 0 , 1 , -1, 1 , -1, 0, 1};

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	double d, t, s; cin >> d >> t >> s;
	if (t >= d / s) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3732
N,Q=map(int,input().split())
S=input()

s=[0]*(N+1)
for i in range(N):
  if i+1<N and S[i]=="A" and S[i+1]=="C":
    s[i+1]=s[i]+1
  else:
    s[i+1]=s[i]

for q in range(Q):
  l,r=map(int,input().split())
  print(s[r-1]-s[l-1])


Measured memory_bytes: 77252
N, M = map(int, input().split(' '))
nums = [1 for _ in range(N)]
has_balls = [False for _ in range(N)]
has_balls[0] = True

for _ in range(M):
    x, y = map(int, input().split(' '))
    x -= 1
    y -= 1

    if has_balls[x]:
        has_balls[y] = True

    nums[y] += 1
    nums[x] -= 1
    if not nums[x]:
        has_balls[x] = False



ret = 0
for h in has_balls:
    if h:
        ret += 1

print(ret)



Measured memory_bytes: 48584
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;


int main(){
    Shazam;
    int n,m; cin>>n>>m;
    int sx,sy,ex,ey; 
    cin>>sx>>sy>>ex>>ey;
    sx--;
    sy--;
    ex--;
    ey--;
    vector<int> xdir = {1,0,-1,0};
    vector<int> ydir = {0,1,0,-1};
    vector<string> g(n);
    for(string &s : g)
        cin>>s;
    vector<vector<int>> dis(n, vector<int> (m, 1e7));
    auto legal = [&](int x, int y){
        if(x<0||y<0||x>=n||y>=m||g[x][y]=='#') return false;
        return true; 
    };
    deque<int> xq, yq;
    xq.push_front(sx);
    yq.push_front(sy);
    dis[sx][sy] = 0;
    while(!xq.empty()){
        int fx = xq.front();
        int fy = yq.front();
        xq.pop_front();
        yq.pop_front();
        for(int i = 0; i < 4; i++){
            int x = fx + xdir[i];
            int y = fy + ydir[i];
            if(!legal(x,y)) continue;
            if(dis[x][y]>dis[fx][fy]){
                dis[x][y] = dis[fx][fy];
                xq.push_front(x);
                yq.push_front(y);
            }
        }
        for(int i = -2; i < 3; i++){
            for(int j = -2 ; j < 3; j++){
                int x = fx + i;
                int y = fy + j;
                if(!legal(x,y)) continue;
                if(dis[x][y]>dis[fx][fy]+1){
                    dis[x][y] = dis[fx][fy] + 1;
                    xq.push_back(x);
                    yq.push_back(y);
                }
            }
        }
    }
    cout<<((dis[ex][ey]==1e7)?-1:dis[ex][ey])<<endl;

    return 0;
}

Measured memory_bytes: 8728
#include <stdio.h>


int main() {
  int N = 0;
  int d[50] = {};
  int sum = 0;
  
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d" , d+i);
  }
  
  for (int i = 0; i < N-1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      sum += d[i] * d[j];
    }
  }
  
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 128
from heapq import heappop, heappush
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

# グラフを拡張してダイクストラ法を使う

def main():
    N,M,S = map(int, readline().split())

    E = [[] for _ in range(N+1)]
    for _ in range(M):
        u,v,a,b = map(int, readline().split())
        E[u].append((v, a, b))
        E[v].append((u, a, b))

    cd = map(int, read().split())
    CD = []
    for c, d in zip(*[iter(cd)]*2):
        CD.append((c, d))

    # Dijkstra
    # d[v][s] := 頂点vで,所持金sとなる最小の所要時間
    if S > 2500:
        S = 2500 - 1
    INF = 10**15
    d = [[INF] * 2500 for _ in range(N+1)]
    d[1][S] = 0

    Q = []
    heappush(Q, (0, S, 1))  # (所要時間, 所持金, 頂点)
    
    while Q:
        time, s, u = heappop(Q)
        if time > d[u][s]:
            continue
        
        c_u, d_u = CD[u-1]
        if s + c_u < 2500 and time + d_u < d[u][s + c_u]:
            d[u][s + c_u] = time + d_u
            heappush(Q, (time + d_u, s + c_u, u))
        
        for v, a, b in E[u]:
            if s >= a and time + b < d[v][s - a]:
                d[v][s - a] = time + b
                heappush(Q, (time + b, s - a, v))

    for i in range(2,N+1):
        print(min(d[i]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 26340
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun p -> p in
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 ps - (Array.fold_left max min_int ps + 1) / 2


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
   
    ll goukei =0;
 rep(i,m){
      cin >> a[i];
      goukei += a[i];
 }
 
 if(n-goukei >= 0) cout << n-goukei << endl;
 else       cout << -1 << endl;
    
}

Measured memory_bytes: 3704
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();	
		int y = scan.nextInt();
		int r = scan.nextInt();
		if((W>=(x+r))&&(x-r>=0)&&(H>=(y+r))&&(y-r>=0)) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 26336
a,b,c,k = map(int,(input().split()))

ans = 0

if a <= k:
    ans += a;
    k -= a
else:
    ans += k
    k = 0
if b <= k:
    k -= b
else:
    k = 0
if c <= k:
    ans -= c;
    k -= c
else:
    ans -= k
    k = 0


print(ans)


Measured memory_bytes: 9120
import scala.io.StdIn.readLine
 
object Main {
  def search(a:Array[Int],value:Int) = {
    def scan(l:Int,r:Int):Boolean = {
      val mid = (l+r)/2
      if(a(mid) == value) true
      else if(l>=r) false
      else if(a(mid)<value) scan(mid+1,r)
      else scan(l,mid-1)
    }
    scan(0,a.length-1)
  }
 
  def main(args:Array[String]) = {
    readLine
    val s = readLine.split(" ").map(_.toInt)
    readLine
    val t = readLine.split(" ").map(_.toInt)
    println(t.count(i=> search(s,i) ))
  }
}

Measured memory_bytes: 71724
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,ans=0,temp;

int main(){
    cin>>N;
    int A[N];
    rep(i,N)cin>>A[i];
    rep(i,N){
        for(int j=N-1;j>0;j--){
            if(A[j]<A[j-1]){
                temp=A[j];
                A[j]=A[j-1];
                A[j-1]=temp;
                ans++;
            }
        }
    }
    rep(i,N){
        if(i>0)cout<<" ";
        cout<<A[i];
    }
    cout<<"\n";
    out(ans);
}



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

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

using namespace std;

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

int main(){
    long long n; cin >> n;
    cout << (n-1)*n/2 << endl;
}

Measured memory_bytes: 256
a=[0,1,2,2,4,4,4,4,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64]
print(a[(int(input()))])


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

int N,L;
int x[5000];
int a[5000];
int dp[5000];
int mod=1000000007;

bool check(int p,int q){
  if(q==x[p])return true;
  if(a[p]==0)return false;
  if(q<x[p])return false;
  return ((q-x[p])%a[p]==0);
}

int main(){
  cin>>N>>L;
  for(int i=0;i<N;i++)cin>>x[i];
  for(int i=0;i<N;i++)cin>>a[i];
  int sum=1,d;
  for(int i=0;i<N;i++){
    for(int j=0;j<L;j++){
      d=check(i,j)*sum;
      sum=(sum+dp[j])%mod;
      dp[j]=d;
    }
    sum=0;
  }
  int ans=0;
  for(int i=0;i<L;i++)ans=(ans+dp[i])%mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
using namespace std;
 
int main() {
		int n,a,b;
	cin>>n>>a>>b;
	if(n*a>b){
		cout<<b<<endl;
	}
	else if(n*a<b){
		cout<<n*a<<endl;
	}
	else{
		cout<<b<<endl;
	}
 
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let r: usize = read();
    println!("{}", r*r);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
n,m=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
road=[[]*1 for i in range(n)]
for i in range(m):
  a=[int(x) for x in input().split()]
  road[a[0]-1].append(a[1]-1)
  road[a[1]-1].append(a[0]-1)
good=[]
for i in range(n):
  if road[i]==[]:
    good.append(i)
  else:
    check=[]
    for j in road[i]:
      if h[i]<=h[j]:
        check.append(False)
    if check==[]:
      good.append(i)
print(len(good))

Measured memory_bytes: 32972
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Right Triangle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", a * b / 2);
  return 0;
}


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

vector<int> g[100010],order;
int d[100010],anss[100010],r[100010],l[100010],par[100010],n,k;
bool ans;

void solve(int v,int p)
{
	l[v]=-INF-1;r[v]=INF+1;
	if(d[v]!=-1){
		l[v]=d[v];
		r[v]=d[v];
	}
	for(int i=0;i<g[v].size();i++){
		int nx=g[v][i];
		if(nx!=p){
			par[nx]=v;
			solve(nx,v);
			if(l[nx]<-INF/2) continue;
			if(l[v]<-INF/2){
				l[v]=l[nx]-1;
				r[v]=r[nx]+1;
			}
			else{
				if(abs(l[nx])%2==abs(l[v])%2){
					ans=true;
					return;
				}
				l[v]=max(l[v],l[nx]-1);
				r[v]=min(r[v],r[nx]+1);
			}
		}
	}
	if(l[v]>r[v]){
		ans=true;
	}
	order.push_back(v);
}

int make_it(int v,int pr)
{
	if(pr==0) return l[v];
	l[v]=max(l[v],anss[pr]-1);
	r[v]=min(r[v],anss[pr]+1);
	while(l[v]%2==anss[pr]%2) l[v]++;
	return l[v];
}

int main()
{
	memset(d,-1,sizeof(d));
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cin>>k;
	for(int i=1;i<=k;i++){
		int v,p;
		cin>>v>>p;
		d[v]=p;
	}
	solve(1,-1);
	reverse(order.begin(),order.end());
	if(ans){
		cout<<"No"<<endl;
		return 0;
	}
	else{
		cout<<"Yes"<<endl;
		for(int i=0;i<order.size();i++){
			int pu=order[i];
			anss[pu]=make_it(pu,par[pu]);
		}
		for(int i=1;i<=n;i++) cout<<anss[i]<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 13560
#include <iostream>
#include <climits>

int distsq(int r, int g, int b, int r_, int g_, int b_)
{
	return (r-r_)*(r-r_) + (g-g_)*(g-g_) + (b-b_)*(b-b_);
}

int main()
{
	std::string input;
	while (true) {
		getline(std::cin, input);
		if (input=="0") break;
		int r, g, b;
		r = std::stoi(input.substr(1,2), nullptr, 16);
		g = std::stoi(input.substr(3,2), nullptr, 16);
		b = std::stoi(input.substr(5,2), nullptr, 16);
		int min_d = INT_MAX;
		std::string res;
		if (min_d > distsq(r,g,b,0,0,0)) {
			min_d = distsq(r,g,b,0,0,0);
			res = "black";
		}
		if (min_d > distsq(r,g,b,0,0,255)) {
			min_d = distsq(r,g,b,0,0,255);
			res = "blue";
		}
		if (min_d > distsq(r,g,b,0,255,0)) {
			min_d = distsq(r,g,b,0,255,0);
			res = "lime";
		}
		if (min_d > distsq(r,g,b,0,255,255)) {
			min_d = distsq(r,g,b,0,255,255);
			res = "aqua";
		}
		if (min_d > distsq(r,g,b,255,0,0)) {
			min_d = distsq(r,g,b,255,0,0);
			res = "red";
		}
		if (min_d > distsq(r,g,b,255,0,255)) {
			min_d = distsq(r,g,b,255,0,255);
			res = "fuchsia";
		}
		if (min_d > distsq(r,g,b,255,255,0)) {
			min_d = distsq(r,g,b,255,255,0);
			res = "yellow";
		}
		if (min_d > distsq(r,g,b,255,255,255)) {
			min_d = distsq(r,g,b,255,255,255);
			res = "white";
		}
		std::cout << res << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3104
w = chomp(readline())
dict = Dict()
for i in 1:length(w)
    key = string(w[i])
    dict[key] = get(dict,key,0) + 1
end

mod_list = []
for key in keys(dict)
    mod_list = push!(mod_list,mod(dict[key],2))
end
sorted = sort(mod_list,rev=true)

if sorted[1] == 0
    println("Yes")
else
    println("No")
end

Measured memory_bytes: 110540
#include<stdio.h>
int main(void)
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1)
    {
        c -= b;
        if(c<=0)
        {
            printf("Yes");
            break;
        }
        a -= d;
        if(a<=0)
        {
            printf("No");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1728
import operator as op
from functools import reduce

N,K = list(map(lambda x: int(x),input().split()))
r = N-K
b = K

def ncr(n,r):
    r = min(n-r,r)
    if r == 0 or n == 0:
        return 1
    num_over = reduce(op.mul, range(n, n - r, -1))
    num_under = reduce(op.mul, range(1,r + 1))
    return num_over // num_under


for i in range(1,K+1):
    if r < i-1:
        print(0)
        continue
    r_res = r-i+1
    #r_pos = i+1
    b_res = b-i
    b_pos = i
    ans = (ncr(r_res+i,r_res)*ncr(b_res+(i-1),i-1))%(10**9+7)
    print(ans)

Measured memory_bytes: 3944
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i < n - 1:
        if a[i + 1] == a[i] + 1:
            ans += c[a[i] - 1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  




int powr(int a,  int b){
	int ret = 1;
	while(b){
		if(b&1) ret*=a;
		a*=a;
		b>>=1;
	}
	return ret;
}
void solve(){
	int x ;
	cin >> x ;
	for(int i = -200 ; i < 200 ; ++i){
		for(int j = -200 ; j < 200 ; j++){
			if(powr(i,5) - powr(j,5) == x){
				cout << i << ' ' << j << endl; 
				return ;
			}
		}
	}
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main(){
    int N, D;  cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D, 0));
    for(int i=0; i<N; i++) for(int j=0; j<D; j++)
        cin >> X[i][j];
    
    int ans = 0;
    for(int i=0; i<N; i++) for(int j=i+1; j<N; j++){
        int square_dist = 0;
        for(int d=0; d<D; d++){
            square_dist += (X[i][d] - X[j][d])*(X[i][d] - X[j][d]);
        }
        if(pow((int)sqrt(square_dist),2) == square_dist) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

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

    vector<pair<double, string>> coins_with_units;

    size_t n = 0;
    cin >> n;
    assert(2 <= n && n <= 10);

    double sum = 0;
    for(size_t i = 1; i <= n; ++i)
    {
        double coin;
        cin >> coin;

        string unit;
        cin >> unit;

        if (unit == "JPY") {
            assert(1 <= coin && coin <= pow(10, 8));
            sum += coin;
        } else if (unit == "BTC") {
            assert(0.00000001 <= coin && coin <= 100.00000000);
            sum += coin * 380000.0;
        } else {
            assert(false);
        }
    }

    printf("%.4lf\n", sum);
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

def get_divisors(n):
    divs = []
    for i in range(2, int(n**0.5)+1):
        c = 0
        while n % i == 0:
            n = n // i
            c += 1
        if c > 0:
            divs.append((i, c))
    if n > 1:
        divs.append((n, 1))
    return divs

divs = get_divisors(N)

ans = 0
for p, c in divs:
	i = 1
	while c >= i:
		c -= i
		ans += 1
		i += 1

print(ans)



Measured memory_bytes: 63664
<?php
    fscanf(STDIN, "%d", $a);
    fscanf(STDIN, "%d", $b);
    fscanf(STDIN, "%d", $c);
    fscanf(STDIN, "%d", $d);
    fscanf(STDIN, "%d", $e);
    fscanf(STDIN, "%d", $k);

    if($b-$a>$k){
        echo ":(\n";
    }
    elseif($c-$a>$k){
        echo ":(\n";
    }
    elseif($d-$a>$k){
        echo ":(\n";
    }
    elseif($e-$a>$k){
        echo ":(\n";
    }
    elseif($c-$b>$k){
        echo ":(\n";
    }
    elseif($d-$b>$k){
        echo ":(\n";
    }
    elseif($e-$b>$k){
        echo ":(\n";
    }
    elseif($d-$c>$k){
        echo ":(\n";
    }
    elseif($e-$c>$k){
        echo ":(\n";
    }
    elseif($e-$d>$k){
        echo ":(\n";
    }
    else{
        echo "Yay!\n";
    }
?>

Measured memory_bytes: 3700
/* Shubhulol */

//Header files
#include 			<bits/stdc++.h>
#include 			<ext/pb_ds/assoc_container.hpp>
#include			<ext/pb_ds/tree_policy.hpp>
#include 			<functional>

//Macros
#define 			ll long long
#define 			ld long double
#define 			db double
#define				str string
#define             lli long long int
#define 			ull unsigned long long
#define 			f(i,x,n) for(ll int i=x;i<n;i++)
#define 			re(j,x,n) for(ll int j=x;j>=n;j--)
#define 			f1(k,x,n) for(ll int k=x;k<=n;k++)
#define 			mp(x,y) std::make_pair(string(x),int(y))
#define 			pb push_back
#define 			input  file();
#define 			bit(x, i) (x >>(i - 1) & 1ll)
#define 			w() int x; cin>>x; while(x--)
#define 			all(v) (v).begin(),(v).end()
#define 			MAX 1000001
#define 			nl '\n';
#define  			c1(x) cin>>x;
#define				c2(x,y) cin>>x>>y;
#define 			c3(x,y,z) cin>>x>>y>>z;
#define 			c4(a,b,c,d) cin>>a>>b>>c>>d;
#define 			o1(x) cout<<x<<'\n';
#define 			o2(x,y) cout<<x<<" "<<y<<'\n';
#define 			o3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n';
#define 			o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<'\n';

//Variables
const ll MOD = 1e9 + 7;
const ll maximum = 1000000;
int inf = 0x3f3f3f3f;
ll infl = 0x3f3f3f3f3f3f3f3fLL;
ld infd = 1.0 / 0.0;

//inclusion
using namespace __gnu_pbds;
using namespace std;

//Unordered ds
typedef tree<pair<ll int, ll int>, null_type, less<pair<ll int, ll int> >, rb_tree_tag, tree_order_statistics_node_update>
new_data_set;

//Input file
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

//sorting map in Descending order

bool sortByVal(const pair<char, int> &a,
               const pair<char, int> &b) {
	return (a.second < b.second);
}


void solve() {
	str s;
	c1(s);
	if (s == "ABC") {
		o1("ARC");
	}
	if (s == "ARC")
	{
		o1("ABC");
	}
}
int main()
{
	input
	solve();
	return 0;
}


Measured memory_bytes: 3592
<?php
$n = (int)trim(fgets(STDIN));
$rs = [];
for ($i=1; $i <= $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	if (isset($rs[$input[0]])) {
		$rs[$input[0]][] = [
			$i,
			(int)$input[1]
		];
	}else{
		$rs[$input[0]] = [
			[$i,(int)$input[1]]
		];
	}
}
ksort($rs);
$result = [];
foreach ($rs as $s => $ps) {
	usort($ps, function($a, $b){
		return $b[1] - $a[1];
	});
	foreach ($ps as $v) {
		$result[] = $v[0];
	}
}

echo implode(PHP_EOL, $result);

Measured memory_bytes: 4728
// Problem : B - NarrowRectanglesEasy
// Contest : AtCoder - AtCoder Beginner Contest 056
// URL : https://atcoder.jp/contests/abc056/tasks/abc056_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, W;
	cin >> W >> a >> b;
	if(a>b) swap(a,b);
	if(a+W>=b){
	    cout << 0;
	    return 0;
	}
	cout << b-a-W;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m,deg[MAXN],u[MAXN],v[MAXN];
vector<int> G[MAXN];
bool del[MAXN];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u[i],&v[i]);
        G[u[i]].push_back(v[i]); G[v[i]].push_back(u[i]);
        deg[u[i]]++;deg[v[i]]++;
    }
    int cnt=0;
    for(int i=1;i<=n;i++) cnt+=deg[i]&1;
    if(cnt!=0) {puts("No"); return 0;}
    if(m<=n+1) {puts("No"); return 0;}
    if(m>=n+3) {puts("Yes"); return 0;}
    queue<int> que;
    memset(del,false,sizeof(del));
    cnt=n;
    for(int i=1;i<=n;i++) if(deg[i]==2) que.push(i);
    while(que.size())
    {
        int v=que.front();que.pop();
        del[v]=true; cnt--;
        vector<int> adj; adj.clear();
        for(auto to:G[v]) 
        {
            if(del[to]) continue;
            adj.push_back(to);
        }
        assert(adj.size()==2);
        G[adj[0]].push_back(adj[1]);G[adj[1]].push_back(adj[0]);
    }
    if(cnt==1)
    {
        int num=0;
        for(int i=1;i<=n;i++)
        {
            if(!del[i])
            {
                int res=0;
                for(auto to:G[i]) if(to==i) res++;
                if(res<=2) puts("No"); else puts("Yes");
                return 0;
            }
        }
    }
    else if(cnt==2) 
    {
        vector<int> vert;vert.clear();
        for(int i=1;i<=n;i++) if(!del[i]) vert.push_back(i);
        int u=vert[0],v=vert[1];
        int cnt1=0,cnt2=0;
        for(auto to:G[u]) if(to==v) cnt1++;
        for(auto to:G[v]) if(to==u) cnt2++;
        if(deg[u]==4&&deg[v]==4&&cnt1==4&&cnt2==4) puts("No"); else puts("Yes");
    }
    else puts("Yes");
    return 0;
}



Measured memory_bytes: 8448
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    vector <vector <int> > a(H);

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            int num;
            cin >> num;
            a[i].push_back(num);
        }
    }

    vector <int> y(0), x(0), Y(0), X(0);
    int count = 0;
    int sum = 0;

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            sum += a[i][j];
        }
        for (int j = 0; j < W - 1; j++){
            if (a[i][j] % 2 != 0){
                a[i][j] -= 1;
                a[i][j + 1] += 1;
                count ++;
                y.push_back(i + 1);
                x.push_back(j + 1);
                Y.push_back(i + 1);
                X.push_back(j + 2);
            }
        }        
        if (sum % 2 != 0 && i != H - 1){
            a[i][W] -= 1;
            a[i+1][W-1] += 1;
            count ++;
            y.push_back(i + 1);
            x.push_back(W);
            Y.push_back(i + 2);
            X.push_back(W);
        }
        sum = 0;
    }

    cout << count << endl;
    for (int i = 0; i < x.size(); i++){
        cout << y[i] << " " << x[i] << " " << Y[i] << " " << X[i] << endl;
    }
        
    return 0;
}

Measured memory_bytes: 5228
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

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

	if (a >= b && b >= c) {
		s = b + c;
	}
	else if (a >= c && c >= b) {
		s = b + c;
	}
	else if (b >= a && a >= c) {
		s = a + c;
	}
	else if (b >= c && c >= a) {
		s = a + c;
	}
	else if (c >= a && a >= b) {
		s = a + b;
	}
	else if (c >= b && b >= a) {
		s = a + b;
	}

	cout << s << endl;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int a, b, c; cin >> a >> b >> c;
  if (b < a) swap(a, b);
  if (a <= c && b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3576
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()

	nums := f(0, digit(n))
	result := 0
	for i := 0; i < len(nums); i++ {
		if nums[i] < 300 {
			continue
		}
		if nums[i] > n {
			continue
		}

		digit := make(map[int]bool, 10)
		for nums[i] > 0 {
			digit[nums[i]%10] = true
			nums[i] /= 10
		}
		if len(digit) == 3 {
			_, ok3 := digit[3]
			_, ok5 := digit[5]
			_, ok7 := digit[7]
			if ok3 && ok5 && ok7 {
				result++
			}
		}
	}

	fmt.Fprintln(out, result)
}

func digit(n int) int {
	ret := 1
	for n > 0 {
		ret++
		n /= 10
	}
	return ret
}

func f(n, d int) []int {
	nn := make([]int, 3)
	for i, b := range []int{3, 5, 7} {
		nn[i] = n*10 + b
	}
	if digit(nn[0]) == d {
		return nn
	}
	return append(nn, append(f(nn[0], d), append(f(nn[1], d), f(nn[2], d)...)...)...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func intMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 5480
module A
  sub Main(byval args() as string)
    dim arr() as string = split(console.readline())
    dim n,r,x as integer
  	n=arr(0):r=arr(1)
    if n>=10 then
      x=r
    else
      x=r+100*(10-n)
    end if
    console.writeline(x)
  end sub
end module

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

typedef long long ll;

int main(void)
{
    int x,y;
    cin >> x >> y;
    if(y > (4*x) || y < (2*x) || y % 2 != 0)
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3620