akhauriyash/Code-Regression huggingface dataset:
count=0
n=int(input())
l=list(map(int,input().split()))
if n==1 or n==2:
    print(0)
else:
    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 abs(l[i]-l[j])<l[k]<l[i]+l[j]:
                    count+=1
                    
    print(count)

Measured memory_bytes: 68336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

ll n, a, b;
ll h[100010];

bool c(ll num) {
	ll sum = 0;
	REP(i, n) {
		ll k = h[i] - b*num;
		if (k > 0) {
			sum += (k / (a - b) + (k % (a - b) != 0));
		}
	}
	return sum > num;
}

int main() {
	cin >> n >> a >> b;
	REP(i, n) {
		cin >> h[i];
	}
	ll r = 0, l = 2000000001;
	while (l - r > 1) {
		ll mid = (r + l) / 2;
		if (c(mid))r = mid;
		else l = mid;
	}
	cout << l << endl;
}

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

using namespace std;
typedef long long int ll;
int main()
{
  int k;
  cin>>k;
  int sum=0;
  for(int i=1;i<(1e7);i++)
  {
      sum=(sum*10+7)%k;
      if(sum==0)
      {
          cout<<i<<endl;
          return 0;

      }
  }

   cout<<-1<<endl;


   return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int a,b,c; cin >> a >> b >> c;
  if(a==5 && b==5 && c==7){cout << "YES" << endl; return 0;}
  if(a==5 && b==7 && c==5){cout << "YES" << endl; return 0;}
  if(a==7 && b==5 && c==5){cout << "YES" << endl; return 0;}
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#include <iomanip>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }


int main(){
int N,M;
cin >> N >> M;
vector<pair<long long ,long long>> A(N+M);
for(int i = 0; i<N;i++){
	long long a;
	cin >> a ;
	A[i].first = a;
	A[i].second = 1;
}
for(int i = 0; i< M;i++){
	long long a,b;
	cin >> a >> b;
	A[N+i].first = b;
	A[N+i].second = a;
}
sort(A.begin(),A.end());
long long ans = 0;
int cnt = 0;
for(int i = N+M-1;i >0;i--){
	if(cnt<N){
		if(cnt+A[i].second<=N){
	ans+=A[i].first*A[i].second;
	cnt += A[i].second;
		}
		else{
			ans+=A[i].first*(N-cnt);
			break;
		}
}
}

cout << ans << endl;

}

Measured memory_bytes: 3328
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)

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

const int N = 1e5 + 10 , mod =  1000000007;



int main(){
    SPEED;

    ll n; cin >> n;

    ll arr[n];

    forn(i,0,n)cin >> arr[i] ;

    ll pres[n+1];
    memset(pres , 0 , sizeof(pres));

    forn(i,0,n)pres[arr[i]]++;

    ll sum = 0;

    forn(i,1,n+1){
    	sum += (ll)(pres[i] * (pres[i] - 1 ))/2 ;
    }

    forn(k , 0 , n){
    	cout << (ll)sum - ((pres[arr[k]] * (pres[arr[k]] -1 ))/2 )+ (((pres[arr[k]] -1)*(pres[arr[k]]-2))/2) << endl ;
    }

    
    return 0;
}
      
       


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3]))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

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


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        //long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var ans = 0;
        var tmp = n;

        IEnumerable<long> aaa = PrimeFactors(tmp);
        List<long> list = aaa.ToList();
        var hash = new HashSet<long>(list);
        foreach (var item in hash)
        {
            for (long k = 1; Math.Pow(item, k) <= n; k++)
            {
                long z = (long)Math.Pow(item, k);
                if (tmp % z == 0 || tmp == z)
                {
                    tmp = tmp / z;
                    ans++;
                }
                else
                {
                    break;
                }
            }
            if (tmp == 1) break;
        }

        // 出力
        Console.WriteLine(ans);
    }

    //素因数分解
    public static IEnumerable<long> PrimeFactors(long n)
    {
        long i = 2;
        long tmp = n;

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                yield return i;
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;//最後の素数も返す
    }

}

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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    vector<int> a(m);
    for(int i = 0; i < m; ++i) cin >> a[i];

    int ans = n;

    for(int i = 0; i < m; ++i) {
        ans -= a[i];
    }

    if(ans < 0) cout << -1;
    else cout << ans;
}

Measured memory_bytes: 3628
function main(inputs) {
  var N = Number(inputs.shift());
  var a = Number(inputs.shift());
  var b = Number(inputs.shift());
  var c = Number(inputs.shift());
  var pairs = [];
  for(var i=0;i<N;i++){
    pairs.push(Number(inputs.shift()));
  }
  var ans = Number.MAX_SAFE_INTEGER;
  start: for(var i=0, iend=Math.pow(4, N);i<iend;i++){
    var str = ("00000000"+i.toString(4)).slice(-N);
    var a_len=0,b_len=0,c_len=0, mp=0;
    if(str.indexOf("1")>=0&&str.indexOf("2")>=0&&str.indexOf("3")>=0){
      for(var j=0,jend=str.length;j<jend;j++){
        if(str[j]=='1'){if(a_len) mp+=10; a_len += pairs[j];}
        else if(str[j]=='2'){if(b_len) mp+=10;  b_len += pairs[j];}
        else if(str[j]=='3'){if(c_len) mp+=10; c_len += pairs[j];}
      }
      ans = Math.min(ans, Math.abs(a_len-a)+Math.abs(b_len-b)+Math.abs(c_len-c)+mp);
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/\s+/));


Measured memory_bytes: 12188
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> cities;
    vector<int> pref[n];
    REP(i, m)
    {
        int p, y;
        cin >> p >> y;
        p--;
        pref[p].push_back(y);
        cities.push_back(make_pair(p, y));
    }
    REP(i, n)
    sort(pref[i].begin(), pref[i].end());

    REP(i, m)
    {
        auto pos = lower_bound(pref[cities[i].first].begin(), pref[cities[i].first].end(), cities[i].second);
        int dist = distance(pref[cities[i].first].begin(), pos);
        printf("%06d%06d\n", cities[i].first + 1, dist + 1);
    }
}

Measured memory_bytes: 7796
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <list>

int main() {
	int count;
	std::list<int> rod;
	
	int pairValue[4];
	int activeIndex = 0;

	scanf("%d", &count);
	rod.resize(count);

	auto itr = rod.begin();
	for(int L10 = 0; L10 < count; L10++,itr++) {
		scanf("%d", &(*itr));
	}
	rod.sort();
	rod.reverse();
	for(auto &&n : rod) {
		if(pairValue[activeIndex] == n) {
			pairValue[activeIndex + 1] = n;
			activeIndex += 2;
			if(activeIndex == 4) {
				long long n = (long long)pairValue[0] * (long long)pairValue[2];
				printf("%lld", n);
				return 0;
			}
		}
		else {
			pairValue[activeIndex] = n;
		}
	}

	printf("0");

	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y;
string s,t;
// < ----------- func eh ---------------- ? //


// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,k;
	cin>>a>>b>>k;

	if(k >= a) {
		k-=a;
		a = 0;
	}
	else {
		a-=k;
		k = 0;
	}

	if(k) {
		b = max(0ll,b-k);
	}

	cout<<a<<" "<<b;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    #define rep(i, n) for (i = 0; i < n; i++)
    #define rrep(i, n) for (i = n; i >= 0; i--)
    #define max(a, b) (a > b ? a : b)
    #define min(a, b) (a < b ? a : b)
     
    int main() {
        int n;
        scanf("%d", &n);
     
        int x = n * 800;
        int y = (n / 15) * 200;
     
        printf("%d\n", x - y);
        return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<int, int> m;
    rep (i, n) {
        int a; cin >> a;
        m[a]++;
    }
    int ans = 0;
    for (auto [x, k] : m) ans += k & 1;
    cout << ans << "\n";
    return 0;
}

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

#define fio                           \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
	fio;
	ll t, a, n, q, k, i, m, c, u, f, j, p, x, y, s, b, d;
 cin>>n;
vector<int>v(n,0),V(n,0);
for(auto& h: v)
cin>>h;

c=INT_MIN;
for(i=0;i<n;i++)
{
	c=max(c,(ll)v[i]);
	V[i]=c;
}


c=0;
for (i = 0; i < n; i++)
c+=V[i]-v[i];
cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
using Graph_c = vector<vector<char>>;
using ll=long long;
// 幅優先探索
struct Z{
  ll y;
  ll x;
  ll depth;
};

ll H,W,y,x,depth;
vector<ll> y_vec={1,0,-1,0};
vector<ll> x_vec={0,1,0,-1};
Graph_c A,B;
queue<Z> q;

ll bfs(){
  while(!q.empty()){
    Z now=q.front(); q.pop();
    y=now.y, x=now.x, depth=now.depth;
    for(ll i=0; i<4; i++){
      Z next={y+y_vec[i], x+x_vec[i], depth+1};
      if(A[next.y][next.x]=='.'){
        A[next.y][next.x]='#';
        q.push(next);
      }
    }
  }
  return depth;
}

int main(){
  cin>>H>>W;
  A.assign(H+2, vector<char>(W+2, '#'));
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      char a; cin>>a;
      A[i][j]=a;
    }
  }
  B=A;
  ll ans=0;
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      if(A[i][j]=='#') continue;
      A[i][j]='#';
      Z start={i,j,0};
      q.emplace(start);
      ans=max(ans,bfs());
      A=B;
    }
  }
  cout<<ans<<endl;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

bool dp[1000010]={};

int main(){
    int n; scanf("%d",&n);
    dp[0]=1;
    rep(j,0,6)rep(i,0,1000001)if(dp[i])dp[min(1000001,i+100+j)]=1;
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto& a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

void Main() {
  int h, n;
  cin >> h >> n;
  vector<int> dp(h + 1, INF);
  dp[0] = 0;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    rep(j, h) {
      if (j + a > h)
        dp[h] = min(dp[j] + b, dp[h]);
      else
        dp[j + a] = min(dp[j] + b, dp[j + a]);
    }
  }
  cout << dp[h] << endl;
}

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


Measured memory_bytes: 256
def main():
    N, T, *AB = map(int, open(0).read().split())

    dp = [0] * (T + max(AB[::2]))
    for w, v in sorted(zip(*[iter(AB)] * 2)):
        for i in reversed(range(T)):
            if dp[i + w] < dp[i] + v:
                dp[i + w] =  dp[i] + v

    print(max(dp))

main()


Measured memory_bytes: 41708
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,w,dp[50][5],ans,cnt,rans;
vector<int> v;
void re(void){
    for(int i=0;i<5;i++){
        v={};
        cnt=0;
        for(int j=h-1;j>=0;j--){
            if(dp[j][i]!=0)v.push_back(dp[j][i]);
            else cnt++;
        }
        while(cnt--)v.push_back(0);
        for(int j=h-1;j>=0;j--){
            dp[j][i]=v[h-j-1];
        }
    }
    return ;
}
int ch(void){
    ans=0;
    for(int i=0;i<h;i++){
        if(dp[i][0]==dp[i][1]&&dp[i][0]==dp[i][2]&&dp[i][0]==dp[i][3]&&dp[i][0]==dp[i][4]){
            ans+=dp[i][0]*5;
            dp[i][0]=dp[i][1]=dp[i][2]=dp[i][3]=dp[i][4]=0;
        }
        else if(dp[i][0]==dp[i][1]&&dp[i][0]==dp[i][2]&&dp[i][0]==dp[i][3]){
            ans+=dp[i][0]*4;
            dp[i][0]=dp[i][1]=dp[i][2]=dp[i][3]=0;
        }
        else if(dp[i][1]==dp[i][2]&&dp[i][1]==dp[i][3]&&dp[i][1]==dp[i][4]){
            ans+=dp[i][1]*4;
            dp[i][4]=dp[i][1]=dp[i][2]=dp[i][3]=0;
        }
        else if(dp[i][0]==dp[i][1]&&dp[i][0]==dp[i][2]){
            ans+=dp[i][0]*3;
            dp[i][0]=dp[i][1]=dp[i][2]=0;
        }
        else if(dp[i][1]==dp[i][2]&&dp[i][1]==dp[i][3]){
            ans+=dp[i][1]*3;
            dp[i][1]=dp[i][2]=dp[i][3]=0;
        }
        else if(dp[i][2]==dp[i][3]&&dp[i][2]==dp[i][4]){
            ans+=dp[i][2]*3;
            dp[i][2]=dp[i][3]=dp[i][4]=0;
        }
    }
    if(ans==0)return 0;
    rans+=ans;
    return 1;
}
int main(void){
    while(1){
    cin>>h;
    if(h==0)return 0;
    rans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<5;j++)cin>>dp[i][j];
    }
    while(1){
        if(ch()==0)break;
        re();
        for(int i=0;i<h;i++){
            for(int j=0;j<5;j++){
                //cout<<dp[i][j];
            }
            //cout<<endl;
        }
    }
    cout<<rans<<endl;
    }
}



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

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	vector<int>w(N);
	for(auto &i:w)cin>>i;
	vector<int>v(4);
	for(auto i:w){
		v[i%3]++;
	}
	if(v[0]==N){
		cout<<1<<endl;
		return 0;
	}
	if(v[1]==N){
		cout<<min(3,N)<<endl;
		return 0;
	}
	if(v[2]==N){
		cout<<min(3,N)<<endl;
		return 0;
	}
	int ans=1;
	if(v[1]>=2){
		ans=max(ans,2+min(v[2],v[1]-2)*2+v[0]);
	}
	if(v[1]>=3){
		ans=max(ans,3+min(v[2],v[1]-3)*2+v[0]);
	}
	if(v[2]>=2){
		ans=max(ans,2+min(v[1],v[2]-2)*2+v[0]);
	}
	if(v[2]>=3){
		ans=max(ans,3+min(v[1],v[2]-3)*2+v[0]);
	}
	if(v[1]&&v[2]){
		ans=max(ans,2+min(v[1]-1,v[2]-1)*2+v[0]);
	}
	if(v[1]){
		ans=max(ans,1+min(v[1]-1,v[2])*2+v[0]);
	}
	if(v[2]){
		ans=max(ans,1+min(v[2]-1,v[1])*2+v[0]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4684
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [u64; n],
        b: [u64; n],
    }

    let mut a_cnt = 0;
    let mut b_cnt = 0;
    for i in 0..n {
        if a[i] < b[i] {
            a_cnt += (b[i] - a[i]) / 2;
        } else if a[i] > b[i] {
            b_cnt += a[i] - b[i];
        }
    }

    println!("{}", if a_cnt >= b_cnt { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdlib>
#include<stack>
using namespace std;

int main(void) {
	string str;
	int number[1000],count = 0;
	stack<int> num;
	while(cin >> str) {
		if (str[0] == '+') {
			int a = num.top(); num.pop();
			int b = num.top(); num.pop();
			num.push(a + b);
		} else if (str[0] == '-') {
			int b = num.top(); num.pop();
			int a = num.top(); num.pop();
			num.push(a - b);
		} else if (str[0] == '*') {
			int a = num.top(); num.pop();
			int b = num.top(); num.pop();
			num.push(a * b);
		} else if (str[0] == ' ') {
		}else{
			num.push(atoi(str.c_str()));
		}
	}
	cout << num.top() << endl;
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
}

Measured memory_bytes: 256
N,A,B,C = list(map(int, input().split()))

S = []
for n in range(N):
    S.append(input())

q = []
ans = 'Yes'
for n in range(N):
    s = S[n]
    if n < N-1:
        s1 = S[n+1]
    else:
        s1 = ''
    
    if s == 'AB':
        if A ==0 and B==0:
            ans = 'No'
            break
        elif A == B:
            if s1 == 'AC':
                A += 1
                B -= 1
                q.append('A')
            elif s1 == 'BC':
                A -= 1
                B += 1
                q.append('B')
            else:
                A -= 1
                B += 1
                q.append('B')
        
        elif A > B:
            A -= 1
            B += 1
            q.append('B')
        else:
            A += 1
            B -= 1
            q.append('A')
            
    elif s == 'AC':
        if A ==0 and C==0:
            ans = 'No'
            break
        elif A == C:
            if s1 == 'AB':
                A += 1
                C -= 1
                q.append('A')
            elif s1 == 'BC':
                A -= 1
                C += 1
                q.append('C')
            else:
                A -= 1
                C += 1
                q.append('C')
        elif A > C:
            A -= 1
            C += 1
            q.append('C')
        else:
            A += 1
            C -= 1
            q.append('A')
                    
    elif s == 'BC':
        if C ==0 and B==0:
            ans = 'No'
            break
        elif C == B:
            if s1 == 'AC':
                C += 1
                B -= 1
                q.append('C')
            elif s1 == 'AB':
                C -= 1
                B += 1
                q.append('B')
            else:
                C -= 1
                B += 1
                q.append('B')
        elif C > B:
            C -= 1
            B += 1
            q.append('B')
        else:
            C += 1
            B -= 1
            q.append('C')

            
if ans == 'No':
    print(ans)
else:
    print(ans)
    for key in q:
        print(key)

Measured memory_bytes: 17116
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<functional>

using namespace std;

vector<int> rep(vector<int> _a, int st, int end, int tar) {

	
	for (int i = st; i >= end; i++) {
		_a[i] = tar;
	}
	return _a;
}

int main()
{
	int N, K;
	int in, min;
	int  count = 0;
	vector<int> a;

	scanf("%d %d",&N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d",&in);
		a.push_back(in);
	}

	//sort(a.begin(), a.end());
	//min = a[0];

	N -= K;
	count++;
	K--;
	count += N / K;
	if (N%K != 0) count++;

	printf("%d",count);

	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    vector<int> a(3);
    rep(i, 3) cin >> a[i];

    sort(ALL(a));

    OP((a[2] * 10) + a[1] + a[0]);

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecInt(A, N);
    sort(A.begin(), A.end());
    if (A.front() + 1 < A.back()){
        puts("No");
        return 0;
    }
    if (A.front() == A.back()){
        const int color = A.back();
        if (color == N - 1){
            puts("Yes");
            return 0;
        }
        // color != N - 1
        if (color <= N / 2){
            puts("Yes");
        }else{
            puts("No");
        }
    }else{
        const int color = A.back();
        int unique = 0;
        for (auto& a : A){
            if (a == A.front()) ++unique;
        }
        if (color <= unique){
            puts("No");
            return 0;
        }
        // unique < color
        if (color - unique <= (N - unique) / 2){
            puts("Yes");
        }else{
            puts("No");
        }
    }
}


Measured memory_bytes: 640
#!/usr/bin/perl

my ($a,$b,$c) = map {$_ - 0} split(/\s+/o,<STDIN>);

if( $a > $b ){
  my $t = $a;
  $a = $b;
  $b = $t;
}
if( $b > $c ){
  my $t = $b;
  $b = $c;
  $c = $t;
}

my $g = ($c - $a) + ($c - $b);

if( ($g % 2) == 1 ){
  my $g2 = 1 + (( $g + 1 ) / 2);
  print "$g2\n";
} else {
  my $g2 = $g / 2;
  print "$g2\n";
}

exit(0);



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

using namespace std;
int main()
{
	string N;
	cin >> N;
	int a = 0;
	for (int i = 0; i < N.size(); i++) {
		char n = N[i];
		a = a + (n - '0');
	}
	if (a%9 == 0) {
		cout <<"Yes";
	}
	else {
		cout << "No";

	}
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int q;
  cin >> q;
  vector<int> ans(100001,0);
  vector<bool> prime(100001,true);
  prime[0]=prime[1]=false;
  for(int i=2;i<400;i++){
    if(prime[i]){
      for(int j=i*2;j<=100000;j+=i){
        prime[j]=false;
      }
    }
  }
  ans[0]=ans[1]=0;
  for(int i=2;i<=100000;i++){
    ans[i]=ans[i-1]+(prime[i]&prime[(i+1)/2]?1:0);
  }
  int l,r;
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << ans[r]-ans[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
/* CM one day */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
const int inf = (int)1e17;
const int N = (int)1e5+5;
int32_t main(){

	FASTIO;
	string s;
	cin >> s;
	if(s.find('7')!=string::npos){
		cout << "Yes\n";
	}
	else
		cout << "No\n";
    return 0;

}

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

bool solve(vector<int> a)
{
	int mn=*min_element(begin(a),end(a)),mx=*max_element(begin(a),end(a));
	if(mn<(mx+1)/2)
		return false;
	for(int x=mn+1;x<=mx;x++)
		if(count(begin(a),end(a),x)<2)
			return false;
	if(mx&1)
		return count(begin(a),end(a),mn)==2;
	else
		return count(begin(a),end(a),mn)==1;
}

int main()
{
	for(int n;cin>>n && n;){
		vector<int> a(n);
		for(int& x:a) cin>>x;
		cout<<(solve(a)?"Possible":"Impossible")<<endl;
	}
}


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


int main(){
    int H,M,N;
    cin >> H>>M>>N;
    
    //行の方が大きいなら、なぁ…
    if (H>=M){
        cout<< (N+H-1)/H <<endl;
    }
    else{
        cout << (N+M-1)/M <<endl;
    }
}

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

int main(void){
	int N;
	cin>>N;
	char S[N];
	for(int i=0;i<N;i++){
		cin>>S[i];
	}
	int num_arr[N];
	int num=0;
	for(int i=0;i<N-1;i++){
		if(S[i+1]=='E'){
			num++;
		}
	}
	num_arr[0]=num;
	for(int i=0;i<N-1;i++){
		if(S[i]=='W'){
			if(S[i+1]=='W'){
				num_arr[i+1]=num_arr[i]+1;
			}else{
				num_arr[i+1]=num_arr[i];
			}
		}else{
			if(S[i+1]=='W'){
				num_arr[i+1]=num_arr[i];
			}else{
				num_arr[i+1]=num_arr[i]-1;
			}
		}
	}
	int ans=num_arr[0];
	for(int i=0;i<N;i++){
		if(num_arr[i]<ans){
			ans=num_arr[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


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



int main(){
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	int a = x2-x1;
	int b = y2-y1;
	
	int x3 = x2-b,y3=y2+a;
	int x4=x3-a,y4=y3-b;
	
	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import collections
def main():
    li = list(map(int,input().split()))
    respondents = [int(input()) for i in range(li[2])]
    number_of_respondes = respondes_number_of_participants(respondents)
    check_surviver(number_of_respondes,li[0],li[1],li[2])


def respondes_number_of_participants(respondents):
    return collections.Counter(respondents)


def check_surviver(number_of_respondes,number_of_participants,gived_points,number_of_questions):
    for i in range(number_of_participants):
        if number_of_respondes[i+1]:
            if gived_points - number_of_questions + number_of_respondes[i+1] > 0:
                print("Yes")
            else:
                print("No")
        else:
            if gived_points - number_of_questions > 0:
                print("Yes")
            else:
                print("No")

main()


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

int main() {
  
  int H, N; cin >> H >> N;
  
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    H -= A;
  }
  
  if (H <= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include<iomanip>
#define int long long

using namespace std;
signed main() {
	int N;
	std::cin >> N;
	
	std::vector<int> A(N + 1);
	vector<int> B(N);
	
	for (auto& a : A) {
		cin >> a;
	}
	for (auto& b : B) {
		cin >> b;
	}



	int result = 0;

	for (int i = 0; i < N; i++) {
		if (A[i] >= B[i]) {
			result += B[i];
			A[i] -= B[i];
			B[i] = 0;



		}
		else {
			result += A[i];
			B[i] -= A[i];
			A[i] = 0;





			if (A[i+1] >= B[i]) {
				result += B[i];
				A[i+1] -= B[i];
				B[i] = 0;
			}
			else {
				result += A[i+1];
				B[i] -= A[i+1];
				A[i + 1] = 0;

			}



		}



	}



	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1792
//package A;
//A - Circle
import java.util.Scanner;

public class Main {
    private Main(int r){
        System.out.println(r*r);
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int r = scanner.nextInt();
        Main result = new Main(r);
    }
}


Measured memory_bytes: 36052
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
sort_a =  sorted(a)

max_1 = sort_a[-1]
max_2 = sort_a[-2]
l = [max_2 if x == max_1 else max_1 for x in a]
print(*l)

Measured memory_bytes: 20368
#include<iostream>
#include<algorithm>
using namespace std;
int i[300000];
int an[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c=0,d,e,f,g;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>i[n];
  }
  for(int n=a-1;n>=0;n=n-2){
    an[c]=i[n];
    c++;
  }
  if(a%2==0){
    for(int n=0;n<a;n=n+2){
      an[c]=i[n];
      c++;
    }
  }
  else{
    for(int n=1;n<a;n=n+2){
      an[c]=i[n];
      c++;
    }
  }
  for(int n=0;n<a;n++){
    if(n!=0) cout <<' ';
    cout <<an[n];
  }
  cout <<'\n';
  return(0);
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
int main(void){
  int h,w,k;
  cin>>h>>w>>k;
  vii s=vii(h,vi(w,0));
  vii ans=vii(h,vi(w,0));
  int num=1;
  rep(i,h)rep(j,w){
     char tmp;
     cin>>tmp;
     if(tmp=='#'){
       s[i][j]=1;
       ans[i][j]=num;
       num++;
     }else{
       s[i][j]=0;
     }
  }
  rep(j,w){
    int now=0;
    rep(i,h){
      if(ans[i][j]!=0){
        now=ans[i][j];
        rep(k,h){
          if(ans[k][j]==0){
            ans[k][j]=now;
          }else if(ans[k][j]==now){
            break;
          }
        }
      }
    }
  }
  rep(j,w){
    rep(i,h-1){
      if(ans[i+1][j]==0){
        ans[i+1][j]=ans[i][j];
      }
    }
  }
  rep(j,w-1){
    rep(i,h){
      if(ans[i][j+1]==0){
        ans[i][j+1]=ans[i][j];
      }
    }
  }
  rep(j,w-1){
    rep(i,h){
      if(ans[i][w-j-2]==0){
        ans[i][w-j-2]=ans[i][w-j-1];
      }
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1536
s=list(input())
w=['N','W','S','E']
q=[]
for i in range(4):
    if s.count(w[i])>0:
        q.append(1)
    else:
        q.append(0)
if q[0]==q[2] and q[1]==q[3]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
counter = Counter(A)
ans = sum(A)

for i in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * counter[B]
    counter[C] += counter[B]
    counter[B] = 0
    print(ans)


Measured memory_bytes: 24016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int main() {
	int a, b;
	
	cin >> a >> b;
	if (a == b) puts("Draw");
	else if (a == 1) puts("Alice");
	else if (b == 1) puts("Bob");
	else if (a > b) puts("Alice");
	else puts("Bob");
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;

const int N_MAX = 100001;
int N, A[N_MAX];
int ans, temp;
bool flag = false;

int battle(int N, int A[]) {
	flag = false;
	sort(A, A + N);
	ans = A[0];
	for (int i = 1; i < N; i++) {
		if (A[i] % A[0] != 0) {
			A[i] = A[i] % A[0];
			flag = true;
		}
	}
	if (flag) battle(N, A);
	else return ans;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	cout << battle(N, A) << endl;
}

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

int arr[200000];

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


    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);


    bool flag = true;
    for(int i=0;i<n-1;++i){
             
        if(arr[i]==arr[i+1]){
            cout<<"NO"<<endl;
            flag = false;

            break;
        }
        else{
            continue;
        }
    }
    if(flag){
        cout<<"YES"<<endl;
    }


    return 0;
}


Measured memory_bytes: 1024
import sys

MOD = 10 ** 9 + 7

N = int(input())
As = list(map(int, input().split()))

As.sort()

if N % 2: # 奇数
    for i in range(N):
        if As[i] != (i + 1) // 2 * 2:
            print(0)
            sys.exit(0)
else: # 偶数
    for i in range(N):
        if As[i] != i // 2 * 2 + 1:
            print(0)
            sys.exit(0)

ans = 1
for _ in range(N // 2):
    ans = (ans * 2) % MOD
print(ans)


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

int main(){
    int a;
    cin >> a;
    int ans = a * a * a + a * a + a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

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

	vec_i dp[2];
	dp[0] = vec_i(1000*n+1, W+1);
	dp[1] = vec_i(1000*n+1, W+1);

	int pos = 0;
	rep(i, n){
		int w, v;
		cin >> w >> v;

		dp[1-pos][v] = min(dp[pos][v], w);
		rep(j, dp[0].size()){
			if(dp[pos][j] + w <= W){
				dp[1-pos][j+v] = min(dp[1-pos][j+v], dp[pos][j] + w);
			}
			dp[1-pos][j] = min(dp[1-pos][j], dp[pos][j]);
		}
		pos = 1 - pos;
	}

	int ans = 0;
	rep(i, dp[0].size()){
		if(dp[pos][i] <= W){
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm> 
#include <cstdio>
#include <cstring>
#include <iostream>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
inline char nc() {
//	return getchar(); 
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();} 
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef pair<int, int> pii;
const int maxn = 1000 + 5; 
int H, W, A, B;
int C, D;
int val[maxn];
pii cnt[maxn];
inline int cmp(const pii &a, const pii &b) {
	return a > b;
}
void print(int x) {
	memset(val, 0, sizeof(val)); 
	sort(cnt + 1, cnt + W + 1, cmp);
	for(int i = 1; i <= x; ++i) {
		val[cnt[i].se] = 1;
		--cnt[i].fi;
	} 
	for(int i = 1; i <= W; ++i) printf("%d", val[i]);
	printf("\n");
}
void print(int a, int b, int c, int d) {
	for(int i = 1; i <= b; ++i) cnt[i] = pii(B, i);
	for(int i = b + 1; i <= W; ++i) cnt[i] = pii(D, i);
	while(a--) {
		print(A);
	}
	while(c--) {
		print(C);
	}
}
bool solve() {
	C = W - A;
	D = H - B;
	for(int i = 0; i <= H; ++i) {
		for(int j = 0; j <= W; ++j) {
			if(A * i + C * (H - i) == B * j + D * (W - j)) {
				print(i, j, H - i, W - j);
				return 1;
			}
		}
	}
	return 0;
}
int main() {
	read(H), read(W), read(A), read(B);
	if(!solve()) puts("-1");
	return 0;
} 

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int r, g, b; cin >> r >> g >> b;
    int c = 100 * r + 10 * g + b;
    if(c % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll x; cin >> x;
  ll a = x/500; ll b= (x%500)/5;
  ll ans = a*1000+b*5;
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys, math

readline = sys.stdin.readline

N = int(readline())
A = [int(readline()) for i in range(N)]

top1 = max(A)
top1_ind = A.index(top1)

A[top1_ind] = -1
top2 = max(A)
A[top1_ind] = top1

for i in range(N):
    if i == top1_ind:
        print(top2)
    else:
        print(top1)


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

int main(){
    string S;
    cin >> S;
    ll N;
    N = S.size();
    ll a=0,b=0;
    for(int i = 0; i < N; i++)
        if(S[i] == '0') a++;
        else b++;
    cout << 2*min(a,b) << "\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;
vector<pair<int,int>>g[maxn];
vector<int>clr(maxn);
int n,m;
void dfs(int u,int p,int c){
	for(auto [v,i]:g[u]){
		if( v != p ){
			++c;
			c %=m;
			clr[i] = c;
			dfs(v,u,c);
		}
	}	
}
int32_t main(){
	IOS
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		g[u].push_back({v,i});
		g[v].push_back({u,i});
	}
	m = 0;
	for(int i=1;i<=n;i++){
		m=max(m,(int)g[i].size());
	}
	dfs(1,0,-1);
	cout << m << endl;
	for(int i=1;i<n;i++){
		cout << clr[i]+1 << " ";
	}
	cout<< endl;

	
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 12144