akhauriyash/Code-Regression huggingface dataset:
/* Manish Pant - insider_pants */
    
#include <bits/stdc++.h>
using namespace std;
    
#define F first
#define S second
#define endl "\n"
#define pb push_back
    
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
    
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll n, a, b;
void solve()
{
    ll t = a + b;

    ll ans = (n / t) * a;

    ll tt = n % t;
    ans += min(tt, a);

    cout<<ans<<endl;
}

int main()
{
    fast();
    cin>>n>>a>>b;
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    string s,t;
    cin>>s>>t;
    s+=s;
    int n=s.size();
    
    if(s.find(t)==string::npos){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	n := readInt()
	var ans string
	for i := 0; n != 0; i = 1 - i {
		if n%2 != 0 {
			ans = "1" + ans
			if i == 1 && n > 0 {
				n++
			}
			if i == 0 && n < 0 {
				n--
			}
		} else {
			ans = "0" + ans
		}
		n /= 2
	}
	if len(ans) == 0 {
		ans = "0"
	}
	println(ans)
}


Measured memory_bytes: 640
#include <iostream>0
using namespace std;
using ll = long long;
 
int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  if (N >= B) {
    cout << (B-1)*A/B << endl;
  }
  else {
    cout << N*A/B << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    ll n,m;
    cin >> n >> m;
    if(n==1&&m!=1){
        cout << m-2 << endl;
    }
    else if(m==1&&n!=1){
        cout << n-2 << endl;
    }
    else{
        ll ans =(n-2)*(m-2);
        //if(ans<0) ans=0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll H; cin >> H;
  ll N; cin >> N;
  ll sum = 0;
  for (int i=0; i<N; i++){
    ll a; cin >> a;
    sum += a;
  }
  if (H > sum) cout << no << endl;
  else cout << yes << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD=1e9+7;

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}
template<typename T> T extgcd(T a,T b,T &x,T &y){
    T d=a;
    if (b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    } else x=1,y=0;
    return d;
}
template<typename T> int digit(T n){
    string cnt=to_string(n);
    return cnt.size();
}

template<typename T> bool is_prime(T n){
    for (T i=2;i*i<=n;++i)
        if (n%i==0) return false;
    return 1<n;
}
template<typename T> vector<T> divisor(T n){
    vector<T> res;
    for (T i=1;i*i<=n;++i) if (n%i==0){
        res.emplace_back(i);
        if (i!=n/i) res.emplace_back(n/i);
    }
    return res;
}
template<typename T> map<T,int> prime_factor(T n){
    map<T,int> res;
    for (T i=2;i*i<=n;++i){
        while (n%i==0){
            ++res[i]; n/=i;
        }
    }
    if (n!=1) res[n]=1;
    return res;
}
vector<bool> prime_table(int n){
    vector<bool> prime(n+1,true);
    prime[0]=prime[1]=false;
    for (int i=2;i<=n;++i) if (prime[i]){
        for (int j=i+i;j<=n;j+=i) prime[j]=false;
    }
    return prime;
}
vector<int> primes(int n){
    vector<int> res;
    vector<bool> pt=prime_table(n);
    for (int i=2;i<=n;++i) if (pt[i]){
        res.emplace_back(i);
    }
    return res;
}

long long modpow(long long x,long long n,long long mod){
    long long res=1;
    while (n>0){
        if (n&1LL) res=res*x%mod;
        x=x*x%mod; n>>=1LL;
    }
    return res;
}
long long modinv(long long x,long long p){
    return modpow(x,p-2,p);
}

template<typename T>
T eular_phi(T n){
    T res=n;
    for (T i=2;i*i<=n;++i) if (n%i==0){
        res-=res/i;
        while (n%i==0) n/=i;
    }
    if (n!=1) res-=res/n;
    return res;
}
vector<int> eular_phi_table(int n){
    vector<int> eular(n+1);
    iota(eular.begin(),eular.end(),0);
    for (int i=2;i<=n;++i) if (eular[i]==i){
        for (int j=i;j<=n;j+=i) eular[j]-=eular[j]/i;
    }
    return eular;
};


// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_A

void NTL_1_A(){
    int n; cin >> n;
    map<int,int> ans=prime_factor(n);
    cout << n << ':';
    for (auto p:ans){
        for (int i=0;i<p.second;++i){
            cout << ' ' << p.first;
        }
    }
    cout << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_B

void NTL_1_B(){
    ll m,n; cin >> m >> n;
    cout << modpow(m,n,MOD) << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_C

void NTL_1_C(){
    int n; cin >> n;
    ll ans=1;
    for (;n--;){
        ll a; cin >> a;
        ans=lcm(ans,a);
    }
    cout << ans << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_D

void NTL_1_D(){
    int n; cin >> n;
    cout << eular_phi(n) << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_E

void NTL_1_E(){
    int a,b,x,y; cin >> a >> b;
    extgcd(a,b,x,y);
    cout << x << ' ' << y << '\n';
}


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


Measured memory_bytes: 3216
#include <iostream>

using namespace std;

using lint = long long;

lint gcd(lint a, lint b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

lint lcm(lint a, lint b)
{
	return a * b / gcd(a, b);
}

lint antiDiv(lint x, lint C, lint D)
{
	lint cx = x / C;
	lint dx = x / D;
	lint cdx = x / lcm(C, D);
	return x - cx - dx + cdx;

}
int main(void)
{
	lint A, B, C, D;
	cin >> A >> B >> C >> D;
	lint divA = antiDiv(A-1, C, D);
	lint divB = antiDiv(B, C, D);
	cout << divB - divA << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color

if __name__ == '__main__':
    N = int(input())
    LINK = [[]*(N+1) for i in range(N+1)]
    # LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    COLOR[1] = 1
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i])

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int n;
char s[125];

int main(){
	scanf("%d%s",&n,s);
	if(n%2==1){
		puts("No"); return 0;
	}
	bool ok = true;
	REP(i,n/2)ok = ok && (s[i] == s[i+n/2]);
	puts(ok ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstring>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erase(unique(all(v)),v.end());
#define pvec(v) rep(i,v.size()){ cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sizeof(m))

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}





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

	ll a = 0, b = 0, c = 0, d, e, ans = 0, n, ret = M, m, x = 0, y = 0;
	//bool x = false;
	string s,t;
	cin >> a >> b;
	if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0)cout << "Possible\n";
	else cout << "Impossible\n";
	return 0;
}

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

int main(){
	int a,b;
	int ans =0;
	cin >> a >> b;
	rep(i,2){
		if(a>b){ans += a--;
		}else{ans += b--;
		}
	}
	cout << ans << endl;


	return 0;
}


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

int main(){
    ll n,x;
    cin>>n>>x;
    ll len=0,count=1;
    for (int i = 0; i < n; ++i) {
        ll t;
        cin>>t;
        len+=t;
        if(len>x){
            cout<<count;
            return 0;
        }
        count++;
    }
    cout<<count;
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

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

    if(a <= b*c){
        cout <<"Yes"<<endl;
    }else cout << "No" <<endl;


    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include<algorithm>
#include<limits.h>
using namespace std;

int main() {
	short N, **a, n[1000] = {}, enemy, fin = 0, match = 0;
	int last_m[1000] = {};
	cin >> N;
	a = (short**)malloc(sizeof(short*) * N);
	for (int i = 0; i < N; i++)
		a[i] = (short*)malloc(sizeof(short) * (N - 1));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	for (int day = 1;; day++) {
		match = 0;
		for (int i = 0; i < N; i++) {
			if (last_m[i] == day)
				continue;
			if (n[i] == N - 1)
				continue;
			enemy = a[i][n[i]];
			if (a[enemy][n[enemy]] == i && last_m[enemy] != day) {
				if (++n[i] == N - 1)
					fin++;
				else
					last_m[i] = day;
				if (++n[enemy] == N - 1)
					fin++;
				else
					last_m[enemy] = day;
				match++;
			}
		}
		if (fin == N) {
			cout << day << endl;
			return 0;
		}
		if (!match) {
			cout << -1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include<cstdio>

int n;
int p[55] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int cnt[55];

int main() {
	scanf("%d", &n);
	for(int i=2;i<=n;i++) {
		int x = i;
		for(int j=0;j<25 && x>1;j++)
			while(x%p[j]==0) {
				x/=p[j];
				cnt[j]++;
			}
	}
	
	//for(int i=0;i<25;i++) printf("%d %d\n", i, cnt[i]);
	int ans = 0;
	for(int i=0;i<25;i++)
		if(cnt[i]>=74) ans++;
	for(int i=0;i<25;i++)
		for(int j=0;j<25;j++) {
			if (i==j) continue;
			if(cnt[i]>=14 && cnt[j]>=4) ans++;
			if(cnt[i]>=24 && cnt[j]>=2) ans++;
		}
	for(int i=0;i<25;i++)
		for(int j=0;j<25;j++)
			for(int k=j+1;k<25;k++) {
				if (i==j || i==k || j==k) continue;
				if(cnt[i]>=2 && cnt[j]>=4 && cnt[k]>=4) ans++;
			}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[10][10];
int main() {
    int n,m,cnt=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	    if(s[i][j]=='#') ++cnt;
    int x=1,y=1;
    while(x!=n||y!=m) {
	--cnt;
	if(s[x+1][y]=='#') ++x;
	else if(s[x][y+1]=='#') ++y;
	else return puts("Impossible"),0;
    }
    puts(cnt==1?"Possible":"Impossible");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
int n,m,a;
cin>>n>>m;
m=min(m,3*n-m);
if (m<n){
a=(m+1)*(m+2)/2;
}else{
int p=m-n,q=n-p,r=p+q+q;
a=(r+1)*(r+2)/2-3*q*(q+1)/2;
;
;
}
;
;
;
cout<<a<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i = 0; i < n; i++)
int p[200020];
int memo[200020];

int main(void)
{
    int n,k;
    int maxp = 0;

    cin >> n >> k;
    REP(i, n) cin >> p[i];
    REP(i, n-k+1) {
        if(i == 0) {
            REP(j, k) memo[0] += p[j];
        } else {
            memo[i] = memo[i-1]-p[i-1]+p[i + k -1];
        }
        if(memo[i] > maxp) {
            maxp = memo[i];
        }
//        cout << maxp << endl;
    }
    cout << fixed << setprecision(12) << (double)(maxp+k)/2.0 << endl;
    
}


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

int main() {
	vector<int> x(3);
	cin >> x[0] >> x[1] >> x[2];
	sort(x.begin(), x.end());
	int plus1 = x[2] - x[1];
	x[0] += plus1;
	int plus2 = (x[2] - x[0] + 1) / 2;
	int ans = plus1+plus2;
	if ((x[2] - x[0]) % 2) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input():
    return sys.stdin.readline()[:-1]
def pri(x):
    if type(x) is list:
        print('\n'.join(map(str, x)))
    else:
        print(x)

N, M = map(int, input().split())

cnt = N*(N-1)//2 + M*(M-1)//2
print(cnt)



Measured memory_bytes: 3572
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	P = list(rli())
	P.sort()
	print(sum(P[i] for i in range(k)))
	stdout.close()

if __name__ == "__main__":
	main()

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

int main(void){
  vector<int> numbers(3);
  for(int i = 0; i < 3; i++){
    cin >> numbers[i];
  }
  sort(numbers.begin(), numbers.end(), [](int a, int b){ return a > b; });
  cout << numbers[0]*10+numbers[1]+numbers[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;

int main()
{
	migmig ;
	ll a , v , b , w , t ; 
	cin>>a>>v>>b>>w>>t ; 
	v = v-w ; 
	a = abs(a-b) ; 
	if(t * v >= a)
	{
		cout<<"YES" ; 
	}
	else cout<<"NO" ; 

}
//////
////////
///////////




Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String nstr = scan.next();
		int k = scan.nextInt();
		int l = nstr.length();
		int[] n = new int[l];
		for(int i = 0; i<l; i++) {
			n[i] = Integer.parseInt(nstr.substring(i, i+1));	//n[i] : nのi+1桁目
		}

		int[][] dp0 = new int[l][k+1];
		int[][] dp1 = new int[l][k+1];

		dp0[0][0] = 1;
		dp0[0][1] = n[0]-1;
		dp1[0][0] = 0;
		dp1[0][1] = 1;

		int n0cnt = 1;	//非0の桁のカウント
		for(int i = 1; i < l; i++ ) {
			dp0[i][0] = 1;
			dp1[i][0] = 0;
			int nm1 = 0;	//n[i]-1 ただし，n[i] = 0のとき，0とする
			if(n[i] > 0) {
				nm1 = n[i]-1;
				n0cnt++;
			}
			for(int j = 1; j < k+1; j++) {
				dp0[i][j] = dp0[i-1][j] + dp0[i-1][j-1]*9 + dp1[i-1][j-1]*(nm1);
				if(n[i] > 0) {
					dp0[i][j] += dp1[i-1][j];
				}
				if(j == n0cnt) {
					dp1[i][j] = 1;
				}else {
					dp1[i][j] = 0;
				}
			}
		}


		System.out.println((dp0[l-1][k] + dp1[l-1][k]));
	}
}


Measured memory_bytes: 25684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int cnt=0;
	rep(i,s.size()){
		if(s[i]=='2') cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber
// 29 06 2020

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a*b/gcd(a, b));
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void bruce()
{
    cout << "\nExpected answer:\n";
    cout << "\nAnswer recieved:\n";
}

void task()
{
    //code here...

    int n, k, x, y;

    cin >> n >> k >> x >> y;

    ll ans = 0;
    if(k<=n){
        ans = k*x;
        n -= k;
        ans += n*y;
    }
    else{
        ans = n*x;
    }

    cout << ans << "\n";
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}





Measured memory_bytes: 3644
def main():
    n = int(input())
    A = list(map(int, input().split()))
    
    if A.count(0) != 0:
        print(0)
        return

    ans = 1

    for a in A:
        ans *= a
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)
    
main()
    

Measured memory_bytes: 87520
N = int(input())

flag = True
tmp = []
for i in range(N):
    W = str(input())
    if i == 0:
        tmp.append(W)
    else:
        if W in tmp:
            flag = False
        else:
            if tmp[-1][-1] != W[0]:
                flag = False
            tmp.append(W)

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


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

int main() {
    ll N;cin >> N;
    map<ll,int> mp;
    ll ans = 0;
    for (int i = 0;i < N;i++){
        ll A;cin >> A;
        ans += mp[i - A];
        mp[A + i]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 26276
input = gets.chomp.split(" ")
x = input[0]
y = input[1]
answer_1 = x.to_i / y.to_i
answer_2 = x.to_i % y.to_i
answer_3 = "%.10f" % "#{x.to_f / y.to_f}"
puts "#{answer_1} #{answer_2} #{answer_3}"

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

int N;
vector<long long> L(86);
long long ans;

long long luca(int n){
  if(n==0) return 2;
  if(n==1) return 1;
  if(L.at(n-1)==0){
    L.at(n-1)=luca(n-1);
  }
  if(L.at(n-2)==0){
    L.at(n-2)=luca(n-2);
  }
  return L.at(n-1)+L.at(n-2);
}

int main() {
  cin>>N;
  ans = luca(N);
  cout<<ans<<endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S,T;
    cin >> N>>S>>T;

    ll tmp = 0;

    if(S==T){
        cout << N << endl;
    }
    else{
        REP(i, N)
        {
            S.erase(0, 1);
            T.erase(T.size() - 1);
            tmp++;
            if (S == T)
            {
                break;
            }
        }
        cout << 2*tmp + (N - tmp)  << endl;
    }
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int odd,even;
		if(n % 2 == 1) {
			odd = n / 2 + 1;
			even = n / 2;
		}else {
			odd = n / 2;
			even = n / 2;
		}

		if(n == 1) {
			System.out.println(1);
		}else {
			double ans = (double)odd / (double)n;
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int64_t kRem = 998244353;

int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int64_t pow_remdiv(int64_t val, int64_t rem)
{
	return pow_rem(val, rem - 2, rem);
}

int64_t divide_rem(int64_t divident, int64_t dividor, int64_t rem)
{
	int64_t ret = pow_remdiv(dividor, rem);
	ret *= divident;
	ret %= rem;

	return ret;
}


vector<int64_t> factors;
vector<int64_t> finvs;
void precalc_nCr(int n, int64_t rem) {
	factors = vector<int64_t>(n + 1);
	finvs = vector<int64_t>(n + 1);

	{
		int64_t f = 1;
		factors[0] = 1;
		FOR_LE(i, 1, n) {
			f *= i;
			f %= rem;
			factors[i] = f;
		}
	}
	{
		int64_t inv = divide_rem(1, factors[n], rem);
		finvs[n] = inv;
		FOR_DW(i, n - 1, 0) {
			inv *= i + 1;
			inv %= rem;
			finvs[i] = inv;
		}
	}
}

int64_t nCr(int n, int k) {
	int64_t val = factors[n];
	val *= finvs[n - k];
	val %= kRem;
	val *= finvs[k];
	val %= kRem;
	return val;
}

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

	int64_t n; cin >> n;

	precalc_nCr(n, kRem);
	vector<int64_t> pow2(n / 2);
	pow2[0] = 1;
	FOR_LT(i, 1, n / 2) {
		pow2[i] = pow2[i - 1] * 2;
		pow2[i] %= kRem;
	}

	int64_t ans = 0;
	FOR_LE(k, n / 2 + 1, n) {
		int64_t val = nCr(n, k);
		val *= pow2[n - k];
		val %= kRem;
		ans += val;
		ans %= kRem;
	}

	ans *= 2;
	ans %= kRem;

	ans = pow_rem(3, n, kRem) - ans;
	if (ans < 0) ans += kRem;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 195584
n = int(input())
p = int(input().replace(" ",""))
q = int(input().replace(" ",""))
dic = []

import itertools
n_dic = range(1,n+1)
for v in itertools.permutations(n_dic, n):
    a = ""
    for i in range(n):
        a += str(v[i])
    dic.append(int(a))

ans = abs(dic.index(p)-dic.index(q))
print(ans)

Measured memory_bytes: 42204
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, count = 0;
	cin >> n;
	vector <int> arr(n + 1);
	for(int i = 1; i < n + 1; i++) {
		cin >> arr[i];
	}
	for(int i = 1; i < n + 1; i++) {
		if(i == arr[arr[i]]) {
			count++;
		}
	}
	cout << count / 2 << endl;

	return 0;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    int ans = n % k;
    if(ans == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

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

    int ans=0;
    rep(i,n){
        ll x=a[i];
        if(x%2==0){
            while(x%2==0){
                ans++;
                x/=2;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
/*
        Author: Prokash
                CSE48, JU
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,time,in;
    vector<ll>v;
    cin>>n>>time;
    for(ll i=0;i<n;i++)
    {
        cin>>in;
        v.push_back(in);
    }
    ll ans=time;
    for(ll i=0;i+1<n;i++)
    {
        ans+=(min(time,(v[i+1]-v[i])));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
alist = list(sorted(d.keys(), reverse = True))
amax = alist[0]
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
for a in alist:
  if a not in d:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  if t not in d:
    continue
  if a != t:
    if d[a] < d[t]:
      i = d[a]
    else:
      i = d[t]
  else:
    i = d[a] // 2
  result += i  
  if d[a] == i:
    del d[a]
  else:
    d[a] -= i
  if d[t] == i:
    del d[t]
  else:
    d[t] -= i
print(result)


Measured memory_bytes: 44592
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
    int x,n,y;

    cin>>x>>n;

    for(int i=0;i<n;i++)
        cin>>y,a[y]=1;

    if(n==0)
        cout<<x;
    else
    {
        int i=0,j=0;
        for(i=x;i>=0;i--)
            if(a[i]==0)
               break;

        for(j=x;j<=101;j++)
            if(a[j]==0)
               break;

        if(x-i<=j-x)
            cout<<i;
        else
            cout<<j;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<char> s(N);
    vector<char> t_f(N + 1);
    rep(i, 0, N) cin >> s.at(i);
    vector<pair<char, char>> p(4);
    p.at(0) = {'S', 'S'};
    p.at(1) = {'S', 'W'};
    p.at(2) = {'W', 'S'};
    p.at(3) = {'W', 'W'};
    
    for (int k = 0; k < 4; k++){
        vector<char> t(N + 1);
        t.at(0) = p.at(k).first;
        char A;
        rep(i, 0, N){
            if (i == 0){
                A = p.at(k).second;
            }
            else{
                A = t.at(i - 1);
            }
            char z;
            if (t.at(i) == 'W'){
                if (s.at(i) == 'o') z = 'x';
                else z = 'o';
            }
            else{
                if (s.at(i) == 'o') z = 'o';
                else z = 'x';
            }
            if (z == 'o'){
                if (A == 'S') t.at(i + 1) = 'S';
                if (A == 'W') t.at(i + 1) = 'W';
            }
            else{
                if (A == 'S') t.at(i + 1) = 'W';
                if (A == 'W') t.at(i + 1) = 'S';
            }
        }
        if ((p.at(k).second == t.at(N - 1)) && (t.at(0) == t.at(N))){
            rep(i,0,N){
                t_f.at(i) = t.at(i);
            }
            goto SKIP;
        }
        else{
            if (k == 3){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    SKIP:
    rep(i, 0, N){
        cout << t_f.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
int sp[20][MAXN];
int lg[MAXN];
int main() {
    int n, m, k;
    scanf("%d", &n);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", sp[0]+i);
    }
    lg[1] = 0; 
    lg[2] = 1;
    for (int i = 2; i < MAXN-5; ++i) {
        lg[i] = lg[i>>1]+1;
    }
    for (int j = 1; j<20; ++j) {
        for (int i = 0; i+(1<<j)-1<=n; ++i) {
            sp[j][i] = __gcd(sp[j-1][i], sp[j-1][i+(1<<j-1)]);
        }
    }
    //printf("%d %d %d\n", sp[1][1], sp[1][2], sp[2][0]);
    int ans = 0;
    int g1, g2;
    for (int i = 1, pre, nxt, j; i<=n; ++i) {
        g1 = 0, g2 = 0;
        pre = lg[i-1], nxt = lg[n-i];
        if (i > 1) g1 = __gcd(sp[pre][1], sp[pre][i-(1<<pre)]);
        if (i < n) g2 = nxt = __gcd(sp[nxt][i+1], sp[nxt][n-(1<<nxt)+1]);
        ans = max(ans, __gcd(g1, g2));
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 8320
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<queue>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

int main(){
    int n, m; cin >> n >> m;
    bool isac[n]; memset(isac, false, sizeof(isac));
    int wa[n]; memset(wa, 0, sizeof(wa));
    rep(i, m){
        int p; string s; cin >> p >> s; p--;
        if(s == "AC") isac[p] = true;
        else if (!isac[p]) wa[p] += 1;
    }
    int resac = 0, reswa = 0;
    rep(i, n){
        if(isac[i]){
            resac++;
            reswa += wa[i];
        }
    }
    cout << resac << " " << reswa << endl;
}

Measured memory_bytes: 768
def f(x):
    if x % 2 == 0:
        return x // 2
    else:
        return 3 * x + 1


s = int(input())
a = [s]
cnt = 1
while True:
    s = f(s)
    cnt += 1
    if s in a:
        print(cnt)
        break
    else:
        a.append(s)

Measured memory_bytes: 2940
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    d = [[inf]*w for i in range(h)]

    dy = [0, 1, 0, -1] 
    dx = [1, 0, -1, 0]
 
    que = deque([])
    for i in range(h):
        for j in range(w):
            if s[i][j] == '#':
                que.append((i, j))
                d[i][j] = 0

    ans = 0
    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]
 
            if 0 <= ny < h and 0 <= nx < w and s[ny][nx] != '#' and d[ny][nx] == inf:
                que.append((ny,nx))
                d[ny][nx] = d[p[0]][p[1]] + 1
                ans = max(ans, d[ny][nx]) 
    return ans

h, w = MAP()
s = []
for i in range(h):
    s.append(input())
print(bfs())


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


int main()
{
  int n,y,i,j,k;
  cin >> n >> y;
  bool flag = false;
  for(i = 0;i <= n;i++){
    for(j = 0;j <= n - i;j++){
      k = n - i - j;
      if(k >= 0){
        int sum = 1000*k + 5000*j + 10000*i;
        if(sum == y){
          flag = true;
          break;
        }
      }
    }
    if(flag) break;
  }
  if(flag) cout << i << " " << j << " " << k << endl;
  else cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int res=0;
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(i!=0 && a[i]==a[i-1]) continue;
        int cnt=1;
        for(int j=i-1;j>=0;j--){
            if(a[j]==a[i]-1) cnt++;
            else break;
        }
        for(int j=i+1;j<n;j++){
            if(a[j]<=a[i]+1) cnt++;
            else break;
        }
        res=max(cnt,res);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10, inf = 1e9 + 42;

struct edge {
	int v; ll w;
};

vector<edge> g[N];
ll c[N], lo = 1, hi = inf;
int depth[N];
bool seen[N];

void dfs(int u);

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		g[u].pb({v, w});
		g[v].pb({u, w});
	}
	dfs(1);
	cout << max(0ll, hi - lo + 1) << endl;
}

void dfs(int u) {
	seen[u] = true;
	if (depth[u] & 1) {
		hi = min(hi, c[u] - 1);
	} else {
		lo = max(lo, 1 - c[u]);
	}
	for (auto &e : g[u]) {
		if (!seen[e.v]) {
			c[e.v] = e.w - c[u];
			depth[e.v] = 1 + depth[u];
			dfs(e.v);
		} else if (depth[e.v] < depth[u] - 1) {
			if ((depth[u] - depth[e.v]) & 1) {
				if (c[u] + c[e.v] != e.w) {
					lo = hi + 1;
					break;
				}
			} else {
				ll temp = c[u] - c[e.v] + e.w;
				if (temp <= 0 or (temp & 1)) {
					lo = hi + 1;
					break;
				} else if (depth[u] & 1) {
					temp = c[u] - temp / 2;
				} else {
					temp = temp / 2 - c[u];
				}
				lo = max(lo, temp);
				hi = min(hi, temp);
			}
		}
	}
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

vint Z_algorithm(vint &W) {
    int i = 1, j = 0;
    vint Z(W.size());
    Z[0] = W.size();
    while (i < W.size()) {
        while (i + j < W.size() && W[i + j] == (W[j] ^ (W[i] ^ W[0]))) ++j;
        Z[i] = j; 
        if (j == 0) { ++i; continue; }
        int k = 1;
        while (Z[k] + k < j) Z[i + k] = Z[k], ++k;
        i += k, j -= k;
    }
    return (Z);
}
int main() {
    int N; cin >> N;
    vint A(N), B(N);

    for (auto &v : A) cin >> v;
    for (auto &v : B) cin >> v;
    copy(begin(A), end(A), back_inserter(B));
    copy(begin(A), end(A), back_inserter(B));
    
    vint ans = Z_algorithm(B);
    int cnt = 0;
    for (int i = N; i < 2 * N; i++) {
        if (ans[i] >= N) {
            cout << i - N << " " << (A[i - N] ^ B[0]) << el;
        }
    }

    return (0);
}


Measured memory_bytes: 8916
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int cnt = 0;
  string name;
  cin >> name;
  for(int i = 0;i < name.length()/2;i++)
  {
    if(name[i] != name[name.length()-1-i])
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import Counter

input()
d = Counter(map(int, input().split()))
d = dict(sorted(d.items(), reverse=True))
ans = []
for i, j in d.items():
    if len(ans) < 2 and j >= 4:
        ans.append(i)
        d[i] -= 2
    if len(ans) < 2 and j >= 2:
        ans.append(i)
        d[i] -= 2
    if len(ans) == 2:
        print(ans[0] * ans[1])
        break
else:
    print(0)

Measured memory_bytes: 34796
/*
 * Created by Dipta Das on 27-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    vector<vector<int>> ar (n, vector<int>(3));
    for (auto &i : ar) for (auto &j : i) cin >> j;
    vector<vector<ll>> dp (n, vector<ll> (3, 0));
    for (int i = 0; i < 3; ++i) dp[0][i] = ar[0][i];

    // 1 -> 2, 3
    // 2 -> 3%3 = 0, 4%3 = 1
    for (int i = 1; i < n; ++i) {
        /* dp[i][0] = ar[i][0] + max (dp[i-1][1], dp[i-1][2]); */
        /* dp[i][1] = ar[i][1] + max (dp[i-1][2], dp[i-1][0]); */
        /* dp[i][2] = ar[i][2] + max (dp[i-1][1], dp[i-1][0]); */
        for (int j = 0; j < 3; ++j) {
            dp[i][j] = ar[i][j] + max (dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
        }
    }


    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    


    return 0;
}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

int N, M;
vector<pii> g[MN];
bool vis[MN];
int x[MN];

void dfs(int v, int p)
{
	vis[v] = 1;
	x[v] = p;

	for (pii e : g[v]) {
		if (!vis[e.fi]) {
			dfs(e.fi, p + e.se);
		}
	}
}

int main() {
	cin >> N >> M;
	rep(i, M) {
		int l, r, d;
		cin >> l >> r >> d;
		--l; --r;
		g[l].eb(mp(r, d));
		g[r].eb(mp(l, -d));
	}

	rep(i, N) {
		if (!vis[i]) {
			dfs(i, 0);
		}
	}

	bool ok = 1;
	rep(i, N) {
		for (pii e : g[i]) {
			if (x[e.fi] != x[i] + e.se) {
				ok = 0;
			}
		}
	}
	puts(ok ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 11136
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;
    vector<int> b,w;
    for (int i = 0; i < (int)s.size(); i++){
        if (s[i] == 'B'){
            b.push_back(i);
        } else {
            w.push_back(i);
        }
    }
    sort(w.rbegin(), w.rend());
    int min_size;
    if ((int)b.size() < (int)w.size()){
        min_size = (int)b.size();
    } else {
        min_size = (int)w.size();
    }

    ll sum = 0;
    for (int i = 0; i < min_size; i++){
        if (w[i] - b[i] > 0){
            sum += w[i] - b[i];
        }
    }
    cout << sum << endl;

    return 0;
}


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

using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define rep0(i,n) for (int i=0; i<(n); i++)
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; }
#ifdef _DEBUG
string _format(string args) { string r = "", t; istringstream s(args); while (getline(s, t, ',')) r += t+":%d "; return r + "\n"; }
#define debug(...) do{printf(_format(#__VA_ARGS__).c_str(), __VA_ARGS__);}while(0)
#define FAST_IOSTREAM() do{}while(0);
#else
#define debug(...) do{}while(0)
#define FAST_IOSTREAM() do{std::ios::sync_with_stdio(false); std::cin.tie(nullptr);}while(0)
#endif

int main() {
    FAST_IOSTREAM();

    // k = 1..N-1 Sigma A(N- [k/2])
    // 4 3 2 1 
    // 4        
    // 4 3      i:1 i/2:0 -> 4
    // 4 2 3    i:2 i/2:1 -> 3
    // 4 2 3 1  i:3 i/2:1 -> 3
    int n;
    cin >> n;
    int a[n];
    rep0(i,n) cin >> a[i];
    sort(a,a+n,greater<int>());

    ll ans = 0;
    for(int i=1; i<n; i++) {
        debug(a[i-1], a[i], ans);
        ans += a[i/2];
    }
    cout << ans << endl;
}


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

using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	int a[205];
	for(int i=0;i<n;i++){
		a[i]=i+1+l-1;
	}
	int sum=0;
	for(int i=0;i<n;i++){
//		cout<<a[i]<<" ";
		sum+=a[i];
	}
	int f=1e9,ans=0;;
	for(int i=0;i<n;i++){
		int cnt=sum-a[i];
		if(abs(cnt-sum)<f){
			f=abs(cnt-sum);
			ans=cnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256