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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

constexpr int MOD = 1e9+7;

int main() {
    int N; cin >> N;
    vector<int> A(N); cin >> A;
    vector<int> C(N + 1);
    C[0] = 3;
    ll ans = 1;
    rep(i, N) {
      (ans *= C[A[i]]) %= MOD;
      C[A[i] + 1]++;
      C[A[i]]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		double result = 0;
		for (int i = 1; i <= N; i++) {
			int j = 1;
			while (i * j < K) j *= 2;
			result += 1. / j;
		}
		System.out.println(result / N);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << '\n'
 
using ll = long long;
using namespace std;
 
const int N = 3010;
int dp[N][N];
char s[N], t[N];
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
 
#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif
 
	cin >> s >> t;
	int n = strlen(s), m = strlen(t);
 
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (s[i] == t[j]){
				dp[i + 1][j + 1] = 1 + dp[i][j];
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}
	}
 
	string ans;
	int i = n, j = m;
	while (i != 0 && j != 0)
	{
		while (i > 0 && dp[i][j] == dp[i - 1][j])
			--i;
		if (i == 0)
			break;
		while (j > 0 && dp[i][j] == dp[i][j - 1])
			--j;
		if (j == 0)
			break;
		ans += s[i - 1];
		--i;
		--j;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
 
	return 0;
}

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
//int dx[] = {0,1,0,-1};
//int dy[] = {-1,0,1,0};

//   cout<<std::setprecision(12)<<
mapll mpp;
int main()
{
    ll i,j,k,l,m,n,a,b;

    cin >> a >> b;
    if(a%2==0)
    {
        mpp[2]++;
        while(a%2==0)a/=2;
    }
    for(i=3;i*i<=a;i+=2)
    {
        if(a%i == 0)
        {
            mpp[i]++;
            while(a%i==0)a/=i;
        }
    }
    if(a>2)mpp[a]++;
    ll cnt = 0;
    if(b%2==0)
    {
        cnt += (mpp[2]==1);
        while(b%2==0)b/=2;
    }
    for(i=3;i*i<=b;i+=2)
    {
        if(b%i==0)
        {
         cnt += (mpp[i]==1);
         while(b%i==0)b/=i;
        }
    }
    if(b>2)
    {
        cnt += (mpp[b]==1);
    }

    cout<<cnt+1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define re(i , n) for(Long i = 0; i < (Long)n ; i++)
#define rer(i, a, b) for (Long i = a, to = b; i < to; i++)
#define rll(x) Long x;cin>>x;
#define rll2(x,y) Long x,y;cin>>x>>y;
#define rll3(x,y,z) Long x,y,z;cin>>x>>y>>z;
#define rll4(x,y,z,a) Long x,y,z,a;cin>>x>>y>>z>>a;
#define rs(s) string s;cin>>s;
using namespace std;
 
typedef long long Long;
typedef pair<Long,Long> pll;
typedef pair<Long,pll> tll;
 
typedef vector<Long> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<Long> si;
 
 
const long double PI = acos(-1);
const Long MX=2e5 + 1;
const Long MOD=1000000007;
const Long MX2=9223372036854775806;
 
 
int main(){
	rll4(a,b,c,k);
	Long resp=0;
	resp+=min(k,a);
	resp-=(k>(a+b))*min(k-a-b,c);
	cout<<resp;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int s = scanner.nextInt();
		int ans = 0;
		
		int[] n = new int[k + 1];
		for (int i = 0; i <= k; i++) {
			n[i] = i;
		}
		
		
		// x, y , z <= k, x+y+z=s <=> x+y = s-z;
		for (int i = 0; i < n.length; i++) {
			int x = i;
			for (int j = 0; j < n.length; j++) {
				int y = j;
				int z = s - x - y;
				if (z>=0 && z<=k) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		
		scanner.close();
	}

}

Measured memory_bytes: 21588
#include <iostream>

using namespace std;
int arr[250];
int main(){
    int x,y;
    cin>>x>>y;
    arr[1] = 300000;
    arr[2] = 200000;
    arr[3] = 100000;
    if(x==1 && y==1){
        cout<<1000000<<endl;
        return 0;
    }
    cout<<arr[x]+arr[y]<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.BitSet;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Osenbei
 * JOI 7th, Pre 5
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int R, C;
			R = parseInt(st.nextToken());
			C = parseInt(st.nextToken());
			if ((R | C) == 0) break;

			BitSet[] CR = new BitSet[C];
			for (int i = 0; i < C; i++) {
				CR[i] = new BitSet(R);
			}

			for (int i = 0; i < R; i++) {
				st = new StringTokenizer(br.readLine());
				for (int j = 0; j < C; j++) {
					if (st.nextToken().equals("1")) CR[j].set(i);
				}
			}

			//solve
			int max = 0;

			for (int i = 0; i < 1 << R; i++) {
				BitSet[] _CR = new BitSet[CR.length];
				for (int j = 0; j < C; j++) {
					_CR[j] = (BitSet) CR[j].clone();
				}
				BitSet flip = new BitSet(R);
				for (int j = 0; j < R; j++) {
					if ((i >> j & 1) == 1) flip.set(j);
				}
				//
				int count = 0;
				for (int j = 0; j < C; j++) {
					_CR[j].xor(flip);
					int bits = _CR[j].cardinality();
					count += (bits > R - bits ? bits : R - bits);
				}
				max = Math.max(max, count);
			}

			System.out.println(max);
		}
	}
}

Measured memory_bytes: 290372
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
    n = parseInt(readline())
    a = parseMap(split(readline()))

    ans = 0
    for i in 1:n
        while mod(a[i],2) == 0
            a[i] /= 2
            ans += 1
        end
    end

    println(ans)
end

main()


Measured memory_bytes: 112648
N = int(input())
c = input()
r_num = 0
w_num = 0
for i in range(N):
    if c[i] == "R":
        last_r = i
        r_num += 1
    
for i in range(r_num):
    if c[i] == "W":
        w_num += 1
print(w_num)        

Measured memory_bytes: 67508
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

long long power(int a, int b){
	long long ret = 1;
	for(int i=b;i>0;i--){
		ret *= a;
	}
	return ret;
}

int main(void){
	string a, b, c;
	cin >> a >> b >> c;
	transform(a.begin(), a.end(), a.begin(), ::toupper);
	transform(b.begin(), b.end(), b.begin(), ::toupper);
	transform(c.begin(), c.end(), c.begin(), ::toupper);
	cout << a.at(0) << b.at(0) << c.at(0) << endl;
	return 0;
}

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

void svtr(vector<int> &a){
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
}

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

  if(e-a>k)
    cout << ":(";

  else
    cout << "Yay!";
  return 0;
}


Measured memory_bytes: 256
//abc094_c.cpp
//Sat Apr 21 20:34:28 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

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

	int x[n];
	int y[n];
	for (int i=0;i<n;i++){
		cin >> x[i];
		y[i] = x[i];
	}

	sort (x,x+n);

	int largermid = x[n/2-1];
	int smallermid = x[n/2];

//	cout << largermid << " " << smallermid << endl;

	for (int i=0;i<n;i++){
		if (y[i] <= largermid){
			cout << smallermid << endl;
		}else {
			cout << largermid << endl;
		}
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 1 << 18;

ll dat[N];
int n;

void set_n(int nn){
	n = 1;
	while (n < nn) n *= 2;
}

void update(int i, ll x){
	i += n - 1;
	dat[i] = x;
	while (i > 0){
		i = (i - 1) / 2;
		dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
}

ll query(int a, int b, int l, int r, int i){
	if (b <= l || r <= a) return 0;
	if (a <= l && r <= b) return dat[i];

	return max(query(a, b, l, (l + r) / 2, i * 2 + 1),
		query(a, b, (l + r) / 2, r, i * 2 + 2));
}
ll query(int a, int b){ return query(a, b, 0, n, 0); }


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	set_n(n);
	rep(i, n){
		update(a[i] - 1, query(0, a[i]) + a[i]);
	}

	cout << accumulate(ALL(a), 0ll) - query(0, n + 1) << endl;

}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define rep(i,f,n) for(int i=(f); (i) < (n); i++)
#define repe(i,f,n) for(int i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;

vector<int> check;

int
digit(ll val)
{
  int count = 0;
  while(val >= 1){
    val /= 10;
    count++;
  }
  return count;
}

int
main() 
{

  int n; cin >> n;
  vector<ll> arr(n);
  rep(i, 0, n) cin >> arr[i];

  int count = 0;
  ll min = MAX;
  ll ans = 0;
  rep(i, 0, n){
    if(arr[i] <= 0){
      count++;
      arr[i] *= -1;
    }
    ans += arr[i];
    if(arr[i] < min) min = arr[i];
  }

  if(count % 2 == 0){
    cout << ans << endl;
  } else {
    cout << ans - min * 2 << endl;
  }

}




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

const ll mod = 1000000007;
const double eps = 1e-8;

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

string repeat(char c, int n) {
    string res = "";
    for (int i=0; i<n; ++i) res += c;
    return res;
}

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    string ST = S;
    for (int i=N-1; i>=0; --i) ST += S[i];
    ST += '{';
    
    char a = *min_element(S.begin(), S.end());

    vector<int> idx; // 辞書順最小が最長で連続する区間の先頭位置
    int len = 1; // 最長連続数
    int c = 0;
    for (int i=0; i<=2*N; ++i) {
        if (ST[i] == a) c ++;
        else if (0 < c) {
            if (N <= i && len <= c) {
                if (len < c) {
                    idx.clear();
                    len = c;
                }
                idx.push_back(i - c);
            }
            c = 0;
        }
    }

    ll m = len;
    for (int i=0; i<K-1 && m<N; ++i) m *= 2;
        
    if (N <= m) {
        cout << repeat(a, N) << endl;
        return 0;
    }

    vector<string> opt;
    for (int i=0; i<(int)idx.size(); ++i) {
        string t = repeat(a, m);
        for (int j=idx[i]-1; j>=idx[i]-(N-m); --j) {
            t += ST[j];
        }
        opt.push_back(t);
    }
    cout << *min_element(opt.begin(), opt.end()) << endl;

    return 0;
}

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

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


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    string sc = s;
    int l = s.length();
    int len = l/2;
    string sub1 = s.substr(0,len);
    string sub2 = s.substr((l+3)/2-1,len);
    string sub1c = sub1;
    string sub2c = sub2;
    reverse(sc.begin(),sc.end());
    reverse(sub1c.begin(),sub1c.end());
    reverse(sub2c.begin(),sub2c.end());
    if(s==sc && sub1==sub1c && sub2==sub2c)
        cout << "Yes";
    else
        cout << "No";
    
    return 0;
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 != 0)
    {
        cout << "No\n";
        return 0;
    }
    bool ok = true;
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[i + n / 2])
            ok = false;
    }
    if (ok)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (A, B) = listOfInt()
    val ans = when(A) {
        in 0..5 -> 0
        in 6..12 -> B / 2
        else -> B
    }
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) } //{ it.toInt() }


Measured memory_bytes: 37800
from itertools import combinations

anntena = []
for _ in range(5):
    anntena.append(int(input()))

k = int(input())
frag = True

for combi in combinations(anntena, 2):
    if abs(combi[0] - combi[1]) > k:
        frag = False    
        break
    
if(frag):
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

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

  int A, B;
  cin >> A >> B;
  if (!(1 <= A && A <= 9)) {
    cout << -1 << endl;
    return 0;
  }
  if (!(1 <= B && B <= 9)) {
    cout << -1 << endl;
    return 0;
  }
  cout << A * B << endl;

  return 0;
}


Measured memory_bytes: 888
n, x = map(int, raw_input().split())
arr = map(int, raw_input().split())
ops = 0
for i in range(n-1):
    sum2 = arr[i] + arr[i+1]
    if sum2 > x:
        ops += min(sum2 - x, arr[i+1])
        arr[i+1] -= min(sum2 - x, arr[i+1])
    if arr[i] > x:
        ops += min(arr[i]-x, arr[i])
        arr[i] -= min(arr[i]-x, arr[i])
print ops
    

Measured memory_bytes: 11412
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else {
            System.out.println(a == b ? "a == b" : "a > b");
        }
    }
}



Measured memory_bytes: 26220
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


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

Measured memory_bytes: 256
from math import *
coordinate=[0,0]
degree = 0
while True:
  dist,delta_degree = list(map(int,input().split(",")))
  if [dist,delta_degree]==[0,0]:
    break
  coordinate[0] += dist*sin(degree*pi/180)
  coordinate[1] += dist*cos(degree*pi/180)
  degree += delta_degree
for c in coordinate:
  print(int(c))

Measured memory_bytes: 7872
r,c,k = map(int, input().split())
rcv = [ [0]*c for _ in range(r) ]

for _ in range(k):
    ri,ci,vi = map(int, input().split())
    rcv[ri-1][ci-1] = vi

# dp[0] = [ [0]*c for _ in range(r) ]
# dp1 = [ [0]*c for _ in range(r) ]
# dp2 = [ [0]*c for _ in range(r) ]
# dp[3] = [ [0]*c for _ in range(r) ]
dp = [ [ [0]*c  for _ in range(r) ] for _ in range(4) ]


dp[1][0][0] = rcv[0][0]
for i in range(r):
    for j in range(c):
        if i+1 < r:
            dp[0][i+1][j] = max(dp[0][i][j], dp[1][i][j], dp[2][i][j], dp[3][i][j], dp[0][i+1][j])
            if rcv[i+1][j] > 0:
                dp[1][i+1][j] = max(dp[1][i+1][j],  max(dp[0][i][j], dp[1][i][j], dp[2][i][j], dp[3][i][j])+rcv[i+1][j])

        if j+1 < c:
            dp[0][i][j+1] = max(dp[0][i][j], dp[0][i][j+1])
            dp[1][i][j+1] = max(dp[1][i][j], dp[1][i][j+1])
            dp[2][i][j+1] = max(dp[2][i][j], dp[2][i][j+1])
            dp[3][i][j+1] = max(dp[3][i][j], dp[3][i][j+1])
            if rcv[i][j+1] > 0:
                dp[1][i][j+1] = max(dp[1][i][j+1], dp[0][i][j]+rcv[i][j+1])
                dp[2][i][j+1] = max(dp[2][i][j+1], dp[1][i][j]+rcv[i][j+1])
                dp[3][i][j+1] = max(dp[3][i][j+1], dp[2][i][j]+rcv[i][j+1])

ans = max(dp[0][r-1][c-1], dp[1][r-1][c-1], dp[2][r-1][c-1], dp[3][r-1][c-1])
print(ans)


Measured memory_bytes: 431140
import math

N, D = map(int, input().split())
X, Y = list(zip(*[list(map(int, input().split())) for _ in range(N)]))

ans = 0
for x, y in zip(X, Y):
    if math.sqrt(x ** 2 + y ** 2) <= D:
        ans += 1
print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    long long target;
    cin >> target;

    int ans = 0;
    long long money = 100;
    while(true){
        money += money/100;
        ans++;
        if(money >= target) break;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
a,b=map(int,input().split())
ans=0
for i in range(b+1)[a:]:
  if len(str(i))%2==0:
    p=list(str(i))[:len(str(i))//2]
    q=list(reversed(list(str(i))[len(str(i))//2:]))
    if p==q:
      ans+=1
  else:
    s=list(str(i))[:len(str(i))//2+1]
    d=list(reversed(list(str(i))[len(str(i))//2:]))
    if s==d:
      ans += 1
print(ans)

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

const long a = 1e+9;

int main()
{
    int N, K, S;
    cin >> N >> K >> S;
    for (int i = 0; i < K; i++) {
        cout << S << " ";
    }
    if (S == a) {
        for (int j = K; j < N; j++) {
            cout << 1 << " ";
        }
    }
    else {
        for (int j = K; j < N; j++) {
            cout << S + 1 << " ";
        }
    }
    cout << endl;

    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

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

    int n, p; cin >> n >> p;
    string s; cin >> s;
    ll ans = 0;
    if(p == 2 || p == 5) {
        for(int i = 0, cur = 0; i < n; i++)
            if((s[i] - '0') % p == 0) ans += (i + 1);
    }
    else {
        unordered_map<int, int> mp{{0, 1}};
        for(int i = n - 1, cur = 0, b = 1; i >= 0; i--) {
            cur = ((b * (s[i] - '0')) + cur) % p;
            ans += mp[cur];
            mp[cur]++;
            b = (b * 10) % p;
        }
    }
    cout << ans << endl;
}

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

long long mod = 1000000007;

long long powmod(long long x, long long y){
  long long res = 1; 
  for(long long i = 0; i < y; i++){
    res = res * x % mod;
  }
  return res;
}


int main() {
  long long N;
  cin >> N;
  long long ans = powmod(10,N) - 2 * powmod(9,N) + powmod(8,N);
  ans %= mod;
  ans=(ans+mod)%mod;
  cout << ans << endl;  
}

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

int main() {
    int S, hour, minute, second;
    cin >> S;

    hour = S / 3600;
    S %= 3600;
    minute = S / 60;
    S %= 60;
    second = S;

    cout << hour << ":" << minute << ":" << second << endl;
}



Measured memory_bytes: 3092
Public Class Program
  Shared Sub Main()
    Dim nm As Integer() = Cin.IntArr()
    Dim n AS Integer = nm(0)
    Dim m As Integer = nm(1)
    Dim ans As String = "No"
    If m = n Then ans = "Yes"
    Console.WriteLine(ans)
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    cout << "ABC" + to_string(N);
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left


def main():
    n = int(input())
    a = [-1] * n
    for i in range(n):
        a[i] = int(input())

    ans = solve3(n, a)
    # print("ans={}".format(ans))
    print(ans)


def solve1(n, a):
    INF = 10 ** 9
    dp = [INF for i in range(n + 1)]
    for i in range(n):
        for j in range(1, i + 2):
            if j == 1 or a[i] > dp[j - 1]:
                dp[j] = min(dp[j], a[i])

    ret = 0
    for i in range(n + 1):
        if dp[i] < INF:
            ret = i
    return ret


def solve2(n, a):
    INF = 10 ** 9
    dp = [INF for i in range(n)]
    for i in range(n):
        for j in range(i + 2):
            if j == 0 or a[i] > dp[j - 1]:
                dp[j] = min(dp[j], a[i])
    ans = 0
    for i in range(n):
        if dp[i] < INF:
            ans = i + 1
    return ans


def solve3(n, a):
    INF = 10 ** 9
    dp = [INF for i in range(n)]
    for i in range(n):
        ix = bisect_left(dp, a[i])
        dp[ix] = a[i]
    ans = bisect_left(dp, INF)
    return ans


def solve4(n, a):
    INF = 10 ** 10
    dp = [INF for i in range(n)]
    for elt in a:
        ix = bisect_left(dp, elt)
        dp[ix] = elt

    ans = 0
    for i in range(n):
        if dp[i] < INF:
            ans = i + 1

    return ans


main()



Measured memory_bytes: 10488
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  char a[n][n],b[m][m];
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      cin>>a[i][j];
    }
  }
  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      cin>>b[i][j];
    }
  }
  int cnt=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(i+m-1>=n||j+m-1>=n)continue;
      for(int k=0; k<m; k++){
        for(int l=0; l<m; l++){
          if(b[k][l]==a[i+k][j+l]){
            cnt++;
          }
        }
      }
      	if(cnt==m*m){
          cout<<"Yes"<<endl;
          return 0;
        }
        cnt=0;
    }
  }
  cout<<"No"<<endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int n;

void kr(string s, int now_max) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }
    rep(i,now_max) {
        s.pb('a' + i);
        kr(s, now_max);
        s.pop_back();
    }
    s.pb('a' + now_max);
    kr(s,now_max+1);
    s.pop_back();
}

signed main() {
    cin >> n;
    kr("", 0);
}


Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    while(true){
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();
    if(m==-1 && f==-1 && r==-1) break;

if(m==-1||f==-1){
    System.out.println("F");
}else if(m+f >= 80){
    System.out.println("A");
}else if(65<=m+f && m+f<80){
    System.out.println("B");
}else if(50<=m+f && m+f<65){
    System.out.println("C");
}else if(30<=m+f && m+f<50){
    if(r>=50){
        System.out.println("C");
    }else{
        System.out.println("D");
    }
}else{
    System.out.println("F");
}
        }
    }
}


Measured memory_bytes: 26292
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		list.sort(Comparator.reverseOrder());
		int a = 0;
		int b = 0;
		for(int i = 0; i < list.size(); i++) {
			if(i % 2 == 0) {
				a += list.get(i);
			} else {
				b += list.get(i);
			}
		}
		System.out.println(a - b);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//main definations
#define endl "\n"
#define UI unsigned int
#define LLI long long int
#define ULLI unsigned long long int
#define PI 3.14159258
 
//codechef only
#define TC for(UI defined_i=1;defined_i<=t;defined_i++)
//int b_s(int arr[], int n, int find);
using namespace std;
void quickSort(int arr[],int start,int end);
int partition(int arr[],int start,int end);
void swap(int *a,int *b);
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}
void quickSort(int arr[],int start,int end){
	if(start<end){
		int position=partition(arr,start,end);
		quickSort(arr,start,position-1);
		quickSort(arr,position+1,end);
	}
}
int partition(int arr[],int start,int end){
	int pivot=arr[end];
	int pivotposition=start;
	for(int i=start;i<end;i++){
		if(arr[i]<pivot){
			swap(&arr[i],&arr[pivotposition]);
			pivotposition++;
		}
	}
	swap(&arr[end],&arr[pivotposition]);
	return pivotposition;
}
void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
}


/*
int b_s(int arr[], int n, int find){
	int start=0, end=n-1, mid=(start+end)/2;
	while(start<=end){
		if(arr[mid]==find){
			return mid;
		}
		else if(arr[mid]<find){
			start=mid+1;
			mid=(start+end)/2;
		}
		else{
			end=mid-1;
			mid=(start+end)/2;
		}
	}
	return -1;
}*/

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

int main(){
    int h,w;cin>>h>>w;
    vector<string> grids(h);for(int i=0;i<h;i++){cin>>grids[i];}

    vector<int> x = {0, 1, 1, 1, 0, -1, -1, -1};
    vector<int> y = {1, 1, 0, -1, -1, -1, 0, 1};

    int acc;
    for (int h_i=0;h_i<h;h_i++){
        for (int w_i=0;w_i<w;w_i++){
            acc = 0;
            if (grids[h_i][w_i] == '.'){
                for (int i=0;i<8;i++){
                    int w_p = w_i + x[i];
                    int h_p = h_i + y[i];
                    if (0<=w_p && w_p<w && 0<=h_p && h_p<h){
                        if (grids[h_p][w_p] == '#'){
                            acc++;
                        }
                    }
                }
                cout << acc;
            } else {
                cout << "#";
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,g,b,u;
    cin>>r>>g>>b;
    cin>>u;
    for(int i=0;i<u;i++){
        if(g<=r){
            g*=2;
            continue;
        }
        if(b<=g){
            b*=2;
            continue;
        }
    }
    if(g>r && b>g)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

int main() {
    int n , l;
    cin >> n >> l;
    vector<string> s(n);
    for (int i = 0;i < n; i++) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());

    for (int i = 0;i < n; i++) cout << s.at(i);

    cout << endl;
    return 0;
}

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

int main(){
    using namespace std;
    const int PRIME_MAX = 101010;
    vector<int> is_prime(PRIME_MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < PRIME_MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < PRIME_MAX; j += i) is_prime[j] = 0;
    }

    vector<int> v(PRIME_MAX+1, 0);
    for (int i = 1; i < PRIME_MAX; i++)
    {
        if(i%2==1 && is_prime[i] && is_prime[(i+1)/2]) v[i] = v[i-1] + 1;
        else v[i] = v[i-1];
    }
    
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int l, r; cin >> l >> r;
        cout << v[r] - v[l-1] << endl;
    }
}

Measured memory_bytes: 1408
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4) 
elif s=='THU':
    print(3) 
elif s=='FRI':
    print(2)
else :
    print(1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/

int main(){
    ssd;
    string s,ans;
    cin>>s;
    for(auto &it : s) {
        if(it == '0' || it =='1') ans+=it;
        if(it == 'B' && ans.size()) ans.pop_back();
    }
    cout<<ans<<endl;
    return 0;
}

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

namespace AtCoder0829
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            //long N = long.Parse(Console.ReadLine());
            long[] DTS = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long D = DTS[0];
            long T = DTS[1];
            long S = DTS[2];

            if(D <= S * T) { Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}



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

int main(){
  int n,k;
  ll sum=0,work;
  cin >> n >>k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i= k;i<n;i++) sum+=a[i];
  cout << sum << endl;
}

Measured memory_bytes: 1792
a, b, c = map(int, input().split())
f = 0
s = 0
if a==5:f = f+1
if a==7:s = s+1
if b==5:f = f+1
if b==7:s = s+1
if c==5:f = f+1
if c==7:s = s+1
if f==2 and s==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

// 正の整数nが与えられたとき1からnまでの自然数のうちnと互いに素なものの個数を求める
long long euler_phi(long long n) {
  long long ret = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ret -= ret / i;
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) ret -= ret / n;
  return ret;
}

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

  cout << euler_phi(n) << endl;

  return 0;
}


Measured memory_bytes: 3096
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





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

  int n;
  cin>>n;
  int sum=0;
  vector<int> a(n);
  fa(v,a)cin>>v;

  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++)
      sum+=a[i]*a[j];
  }
  cout<<sum<<endl;


}


Measured memory_bytes: 256
def main():
    n = input()
    if len(n) == 1:
        print(int(n))
    elif len(n) == 2:
        print(9)
    elif len(n) == 3:
        print(10 + int(n) - 100)
    elif len(n) == 4:
        print(909)
    elif len(n) == 5:
        print(910 + int(n) - 10000)
    else:
        print(90909)


if __name__ == '__main__':
    """
    整数 N が与えられます。N 以下の正の整数のうち、(先頭に 0 をつけずに十進法で表記したときの)
    桁数が奇数であるようなものの個数を求めてください。

    制約
    1 ≤ N ≤ 10^5
    """
    main()

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

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

func main() {
	var (
		s string
		t string
	)
	fmt.Scan(&s, &t)

	sMap := make(map[rune]int)
	tMap := make(map[rune]int)
	for _, r := range s {
		sMap[r]++
	}
	for _, r := range t {
		tMap[r]++
	}

	var (
		sVals []int
		tVals []int
	)

	for _, v := range sMap {
		sVals = append(sVals, v)
	}
	for _, v := range tMap {
		tVals = append(tVals, v)
	}

	sort.Ints(sVals)
	sort.Ints(tVals)

	for i := 0; i < len(sVals); i++ {
		if sVals[i] != tVals[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=105,INF=1<<30;

struct edge{int from,to;ll dis;};

bool compare(edge a,edge b){
    return a.dis<b.dis;
}

int par[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)) par[root(b)]=root(a);
}

bool check(int a,int b){
    return root(a)==root(b);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        vector<edge> G(M);
        for(int i=0;i<M;i++){
            int a,b,c;cin>>a>>b>>c;
            a--;b--;
            G[i]={a,b,c};
        }
        sort(all(G),compare);
        int ans=INF;
        
        for(int i=0;i<M;i++){
            init(N);
            int cnt=0;
            for(int j=i;j<M;j++){
                if(!check(G[j].from,G[j].to)){
                    unite(G[j].from,G[j].to);
                    cnt++;
                }
                
                if(cnt==N-1){
                    ans=min(ans,int(G[j].dis-G[i].dis));
                    break;
                }
            }
        }
        
        if(ans==INF) ans=-1;
        
        cout<<ans<<endl;
    }
    
}




Measured memory_bytes: 3168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

AB = LIST()

for i in range(2):
	if AB[i] == 1:
		AB[i] += 13

if AB[0] > AB[1]:
	print("Alice")
elif AB[0] < AB[1]:
	print("Bob")
else:
	print("Draw")


Measured memory_bytes: 13676
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	int n,ans=-1;
	cin >> n;
	vector<int> num(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> num[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			ans = max(ans, abs(num[i] - num[j]));
		}
	}
	cout <<ans << endl;
}


Measured memory_bytes: 256
S = input()
cnt_a = 0
cnt_b = 0
cnt_c = 0
for s in S:
    if s == 'a':
        cnt_a += 1
    elif s == 'b':
        cnt_b += 1
    else:
        cnt_c += 1
if abs(cnt_a - cnt_b) <= 1 and abs(cnt_b - cnt_c) <= 1 and abs(cnt_c - cnt_a) <= 1:
    print('YES')
else:
    print('NO')


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

using ld=long double;
using P=complex<ld>;

ld f(ld a,ld b,ld c){
    return acos((a*a+b*b-c*c)/(2*a*b))/2;
}
ld solve(ld a,ld b,ld c){
    ld tb=f(a,b,c),tc=f(a,c,b);
    return a/(1/tan(tb)+2+1/tan(tc));
}
int main(){
    vector<P> p(3);
    for(int i=0;i<3;i++){
        ld x,y;
        cin>>x>>y;
        p[i]={x,y};
    }
    ld l[3];
    for(int i=0;i<3;i++) l[i]=abs(p[i]-p[(i+1)%3]);
    ld res=0;
    for(int i=0;i<3;i++) res=max(res,solve(l[i],l[(i+1)%3],l[(i+2)%3]));
    cout<<fixed<<setprecision(10);
    cout<<res<<endl;
    return 0;
}

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


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

  a = a == 1 ? 14 : a;
  b = b == 1 ? 14 : b;
  if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>

using namespace std;

int main(void) {
 long long int a, b, tmp1, tmp2;
  cin >>  a >> b;
  for(int i=0;i<11000;i++) {
    tmp1 = (int)((double)i*0.08);
    tmp2 = (int)((double)i*0.1);
    if(tmp1==a&&tmp2==b) { cout << i << endl; return 0; }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
	int w, a, b, start_dis;
	scanf("%d%d%d", &w, &a, &b);
	start_dis = max(a, b) - (min(a, b) + w);
	if (start_dis>0) printf("%d\n", abs(max(a, b) - (min(a, b) + w)));
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <vector>

#define BUFFER_SIZE 4

int main() {

    char buffer[BUFFER_SIZE];

    for (int i = 0; i < 3; ++i) {
        scanf("%s", buffer);
        putchar(buffer[i]);
    }
    putchar('\n');

    return 0;

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    const ll INF = (1ll<<60);

    ll N;
    cin >> N;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];

    vector<ll> dp(N, INF);
    dp[0] = 0;
    REP(i, N){
    	if(i+1<N) dp[i+1] = min(dp[i] + abs(h[i+1]-h[i]), dp[i+1]);
    	if(i+2<N) dp[i+2] = min(dp[i] + abs(h[i+2]-h[i]), dp[i+2]);
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792