akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int a[100010];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int cnt = 0;
	int ans = 0;
	rep(i, n) {
		cin >> a[i]; cnt ^= a[i];
	}
	for (int i = 40; i >= 0; i--) {
		if ((cnt >> i) & 1) {
			rep(j, n) {
				if (((a[j] - 1) ^ a[j]) == (1 << (i + 1)) - 1) {
					ans++; cnt ^= (a[j] - 1) ^ a[j];
					break;
				}
			}
		}
	}
	if (!cnt)cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    string s[n]; for (int i = 0; i < n; i++) cin >> s[i];
    int ans = 0;
    for (string &t : s)
        for (int i = 0; i < t.size()-1; i++)
            if (t[i] == 'A' && t[i+1] == 'B') ans++;
    // cerr << ans << endl;
    int ca = 0, cb = 0, cba = 0;
    for (string &t : s) {
        if (t[0] == 'B' && t[t.size()-1] == 'A') cba++;
        else if (t[0] == 'B') cb++;
        else if (t[t.size()-1] == 'A') ca++;
    }
    if (cba > 0) {
        ans += cba - 1;
        if (ca > 0) ca--, ans++;
        if (cb > 0) cb--, ans++;
    }
    ans += min(ca, cb);
    cout << ans << endl;
}


Measured memory_bytes: 896
x,y=map(int,input().split())
A=[1, 3, 5, 7, 8, 10, 12]
B=[4, 6, 9, 11]
C=[2]
if x in A:
  a=1
elif x in B:
  a=2
else:
  a=3
if y in A:
  b=1
elif y in B:
  b=2
else:
  b=3
if a==b:
  print("Yes")
else:
  print("No")

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

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

const ll INF = 1LL << 60;

void solve(void){
  ll n; cin >> n;

  vector<ll> dp(n+10, INF);
  dp[0] = 0;

  for(ll i = 1; i <= n; ++i) {
    ll power = 1;
    while(power <= i) {
      dp[i] = min(dp[i], dp[i-power] + 1);
      power *= 6;
    }

    ll power2 = 1;
    while(power2 <= i) {
      dp[i] = min(dp[i], dp[i-power2] + 1);
      power2 *= 9;
    }
  }

  cout << dp[n] << endl;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 1024
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    string s, ans;
    getline(cin, s);
    int q;
    cin >> q;
    bool st = 0;
    vector < vector <char> > v(2);
    while (q--){
        int t;
        cin >> t;
        if (t == 1){
            st = !st;
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            f -= 1;
            v[f^st].pb(c);
        }
    }
    for (int i = v[0].size()-1; i >= 0; i--){
        ans += v[0][i];
    }
    ans += s;
    for (char c : v[1]){
         ans += c; 
    }
    if (st){
        for (int i = ans.length()-1; i >= 0; i--){
            cout << ans[i];
        }
    }
    else cout << ans;
    return 0;
}


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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")


#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------


void solve()
{
	int arr[3];cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);cout<<arr[0]+arr[1]<<"\n";
	

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

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///    cout<<"Case #"<<a+1<<": ";
        solve();
    }
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
}


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

int main(){
    long long A, B, C;
    cin >> A >> B >> C;
    
    long long r = A % B;
    long long min_r = r;
    while(true){
        if(r == C){
            cout << "YES" << endl;
            break;
        }

        r = (r + A) % B;
        if(min_r == r){
            cout << "NO" << endl;
            break;
        }
        
        if(min_r > r){min_r = r;}
        

    }

    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#define MAX 2000000

int n,A[MAX+1];

void maxHeapify(int);

int main(){

  int i;
  
  scanf("%d",&n);
  
  for(i = 1 ; i <= n ; i++){
    scanf("%d",&A[i]);
  }
  for(i = n/2 ; i >= 1 ; i--){
    maxHeapify(i);
  }
  for(i = 1 ; i <= n ; i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}

void maxHeapify(int i){

  int l,r;
  int temp,largest;
  
  l = 2 * i;
  r = 2 * i + 1;
  
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= n && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }

  if(r <= n && A[r] > A[largest]){
    largest = r;
  }
  
  // i の子の方が値が大きい場合
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
      maxHeapify(largest);// 再帰的に呼び出し
  }
}



Measured memory_bytes: 3804
#include<iostream>

using namespace std;

int main(){
    int a[31];
    int n;
    while(cin>>n&&n){
        a[1]=1;
        a[2]=2;
        a[3]=4;
        for(int i=4;i<=n;i++){
            a[i]=a[i-1]+a[i-2]+a[i-3];
        }
        cout<<((a[n]-1)/3650)+1<<endl;
    }
}


Measured memory_bytes: 3084
package main

import "fmt"

func main() {
	arr := scanNums(2)
	X := arr[0]
	Y := arr[1]
	res := ""
	assumedA := 2*X - Y/2
	assumedB := Y/2 - X
	if Y%2 != 0 {
		res = "No"
	} else {
		if assumedA >= 0 && assumedB >= 0 {
			res = "Yes"
		} else {
			res = "No"
		}
	}
	fmt.Print(res)
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

int main(){
  int n,d;
  cin>>n>>d;
  int a[n][d];
  for(int i=0;i<n;i++){
      for(int j=0;j<d;j++){
          cin>>a[i][j];
      }
  }
  int ans=0;
  for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
          int sum=0;
          for(int k=0;k<d;k++){
              sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
          }
          int m = sqrt(sum);
          if(sum==m*m){
              ans++;
          }
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def bingo_judge(li,a,b,c,d,e,f,flag):
    if li[a-1][b-1] + li[c-1][d-1] + li[e-1][f-1] == 3:
        return True
    if flag:
        return True
    else:
        return False

card = []
card_judge = []
for i in range(3):
    li = list(map(int, input().split()))
    card.append(li)
    card_judge.append([0,0,0])
N = int(input())
for i in range(N):
    number = int(input())
    for t in range(3):
        for u in range(3):
            if number == card[t][u]:
                card_judge[t][u] = 1
flag = False
flag = bingo_judge(card_judge,1,1,2,1,3,1,flag)
flag = bingo_judge(card_judge,1,2,2,2,3,2,flag)
flag = bingo_judge(card_judge,1,3,2,3,3,3,flag)
flag = bingo_judge(card_judge,1,1,1,2,1,3,flag)
flag = bingo_judge(card_judge,2,1,2,2,2,3,flag)
flag = bingo_judge(card_judge,3,1,3,2,3,3,flag)
flag = bingo_judge(card_judge,1,1,2,2,3,3,flag)
flag = bingo_judge(card_judge,1,3,2,2,3,1,flag)
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9312
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> ab(n);
    ll res = 0;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        res -= b;
        ab[i] = a + b;
    }
    
    sort(ab.begin(), ab.end(), greater<int>());
    int num = ceil((double)n / 2);
    ll sum = 0;
    for(int i = 0; i < n; i += 2){
        sum += ab[i];
    }
    res += sum;
    
    cout << res << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
 int S,s,m,h;
 
 scanf("%d",&S);

 h=S/3600;
 m=(S-h*3600)/60;
 s=(S-h*3600-m*60);

 printf("%d:%d:%d\n",h,m,s);

 return 0;
}

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

int main(){
  int N;
  cin >> N;
  int B[N - 1];
  for(int i = 0; i < N - 1; i++){
    cin >> B[i];
  }
  int sum = B[0] + B[N - 2];
  for(int i = 0; i < N - 2; i++){
    if(B[i] > B[i + 1]){
      sum += B[i + 1];
    }
    else{
      sum += B[i];
    }
  }
  cout << sum << endl;
}

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


int N;
int a;
int c0 = 0;

int main(){
    cin >> N;

    for (int i = 1; i < N + 1; i++){
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1) c0++;
    }
    cout << c0 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    REP(i, n, 1000)
    {
        if (i % 111 == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
 char b[10];
  cin >> b;
  int length=0;
  int max=0;
  for(int i=0;i<10;i++){
    
    
  	if (b[i]=='A' || b[i]=='T'||b[i]=='G'||b[i]=='C'   )
      length++;
    else if (max<=length){
        max=length;
        length=0;
    }
    else
      length=0;
  }
  if(length>max)
    max=length;
  cout << max;
}


Measured memory_bytes: 256
#include <stdio.h>  
  

int gcd(int a, int N)  
{  
    if (a == 0) 
        return N;  
    return gcd(N % a, a);  
}  
  
  
int lcm(int a, int N)  
{  
    return (a*N)/gcd(a, N);  
}  
  
 
int main()  
{  
    int a=2,N;
	scanf("%d",&N);  
    printf("%d", lcm(a, N));  
    return 0;  
}  

Measured memory_bytes: 1712
#include <iostream>
#include <utility>
#include <tuple>
#include <algorithm>
#include <vector>
using namespace std;

string hoge(int x) {
	string ans = to_string(x);
	while (ans.size() <= 5) {
		ans = "0" + ans;
	}

	return ans;
}

int main(void) {
	int N, M;
	cin >> N >> M;

	vector<tuple<int, int, int>> a;

	for (int i = 0; i < M; i++) {
		int p, year;
		cin >> p >> year;
		
		a.emplace_back(p, year, i);
		//tuple<int, int, int> b = {p, year, i};
		//a[i] = b;
	}

	//sort(a, a+M);
	sort(a.begin(), a.end());

	int num = 1;
	for (int i = 0; i < M; i++) {
		if (i == 0) {
			num = 1;
			get<1>(a[i]) = num;
			//cout << hoge(get<0>(a[i])) << hoge(num) << endl;
		} else if (get<0>(a[i])== get<0>(a[i-1])) {
			num += 1;
			get<1>(a[i]) = num;
			//cout << hoge(get<0>(a[i])) << hoge(num) << endl;
		} else {
			num = 1;
			get<1>(a[i]) = num;
		}
	}

	for (int i = 0; i < M; i++) {
		int tmp;
		tmp = get<0>(a[i]);
		get<0>(a[i]) = get<2>(a[i]);
		get<2>(a[i]) = tmp;
	}

	sort(a.begin(), a.end());

	for(int i = 0; i < M; i++) {
		cout << hoge(get<2>(a[i])) << hoge(get<1>(a[i])) << endl;
	}

	//for(int i = 0; i < M; i++) {
	//	for (int j = 0; j < M; j++) {
	//		if (get<2>(a[j]) == i) {
	//			cout << hoge(get<0>(a[j])) << hoge(get<1>(a[j])) << endl;
	//		}
	//	}
	//}
}


Measured memory_bytes: 2804
from collections import defaultdict
N = int(input())
defdict = defaultdict(int)
for _ in range(N):
  st = input()
  fst = st[0]
  if fst in "MARCH":
  	defdict[fst]+=1
V = list(defdict.values())
NV =  len(V)
ans = 0
for i in range(NV):
  for j in range(i+1,NV):
    for k in range(j+1,NV):
      ans+=V[i]*V[j]*V[k]
print(ans)

Measured memory_bytes: 9480
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

inline int toInt(string s) { stringstream ss(s); int x; ss >> x; return x; }

int main() {
  int n;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    int sh = toInt(s.substr(0, 2));
    int lg = toInt(s.substr(3));
    double argSh = sh*5*6;
    double argLg = lg*6; argSh += argLg/12;
    
    double hen = abs(argSh-argLg);
    hen = min(hen, 360.0-hen);
    if(0<=hen && hen<30) cout << "alert" << endl;
    else if(90<=hen && hen<=180) cout << "safe" << endl;
    else cout << "warning"<< endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
        out << x << ' ';
    return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n;
    cin>>n;
    vii a(n);
    cin>>a;
    bool f=false;
    for(ll i=2;i<n;i++)
    {
        if(a[i-2].F==a[i-2].S && a[i-1].F==a[i-1].S && a[i].F==a[i].S)
        {
            f=true;
            break;
        }
    }
    if(f)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

void print(ll i, ll j, ll d) {
  cout << i + 1 << " " << j + 1 << " " << d << endl;
}

struct edge {
  ll u, v, d;
};

int main() {
  ll L;
  cin >> L;

  vector<ll> bits;
  while (L > 0) {
    bits.push_back(L % 2);
    L /= 2;
  }
  reverse(bits.begin(), bits.end());

  vector<edge> E;
  REP(i, 0, bits.size() - 1) {
    E.push_back((edge) { (ll) bits.size() - i - 2, (ll) bits.size() - i - 1, 0 });
    E.push_back((edge) { (ll) bits.size() - i - 2, (ll) bits.size() - i - 1, 1LL << i });
  }
  ll s = 1LL << (bits.size() - 1);
  REP(i, 1, bits.size()) {
    if (bits[i] == 1) {
      E.push_back((edge) { 0, i, s });
      s += 1LL << ((ll) bits.size() - i - 1);
    }
  }

  cout << bits.size() << " " << E.size() << endl;
  REP(i, 0, E.size()) cout << E[i].u + 1 << " " << E[i].v + 1 << " " << E[i].d << endl;
}

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

void solve(void)
{
    int xx[] = {0, 1};
    int yy[] = {1, 0};
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    vector<vector<int>> f(h, vector<int>(w, -1));
    int sy = 0, sx = 0;
    f[sy][sx] = 0;
    queue<pair<int, int>> q;
    q.push({sy, sx});
    while (!q.empty())
    {
        auto s = q.front();
        q.pop();
        int y = s.first, x = s.second;
        rep(i, 2)
        {
            int ny = y + yy[i], nx = x + xx[i];
            if (ny >= h || nx >= w)
                continue;
            if (a[ny][nx] == '#' && f[ny][nx] == -1)
                f[ny][nx] = f[y][x] + 1, q.push({ny, nx});
        }
    }
    map<int, int> mp;
    rep(i, h) rep(j, w) if (a[i][j] == '#') mp[f[i][j]]++;
    rep(i, h) rep(j, w)
    {
        if (f[i][j] == -1 && a[i][j] == '#')
        {
            cout << "Impossible" << endl;
            return;
        }
    }
    bool flag = true;
    for (auto i : mp)
    {
        if (i.first == -1)
            continue;
        if (i.second > 1)
            flag = false;
    }
    if (flag)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
}
int main(void)
{
    solve();
}

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

using namespace std;

int H, W;
int MapData[25][25];

int solve(int row, int col) {
	int sum;

	sum = 0;
	for (int i = 0; i < H; ++i) {
		if (i == row) {
			continue;
		}
		for (int j = 0; j < W; ++j) {
			if (j == col) {
				continue;
			}
			sum += min(abs(i - row), abs(j - col)) * MapData[i][j];
		}
	}

	return sum;
}

int main() {
	int ans;

	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> MapData[i][j];
		}
	}

	ans = 2000000000;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ans = min(ans, solve(i, j));
		}
	}
	cout << ans << endl;

	return 0;
}


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

bool check(string s)
{
	int n = s.length();
	for(int i = 0; i < n/2; i++)
	{
		if(s[i]!=s[n-1-i])
			return false;
	}
	return true;

}

int main(){
	string s;
	cin >> s;
	int n = s.length();
	string s1 = s.substr(0,(n-1)/2);
	string s2 ="";
	for(int i = (n+3)/2 - 1; i < n; i++)
		s2 += s[i];
	// cout << s1 << " " << s2 << endl;
	if(check(s) && check(s1) && check(s2))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    string s;
    cin >> s;

    set<char> c;
    irep(i, s.size()) {
        c.insert(s[i]);
    }
    if(c.size() == s.size()) {
        puts("yes");
    } else {
        puts("no");
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		double weight;

		while (sc.hasNext()) {
			weight = sc.nextDouble();
			if (weight <= 48.00) {
				System.out.println("light fly");
			} else if (weight <= 51.00) {
				System.out.println("fly");
			} else if (weight <= 54.00) {
				System.out.println("bantam");
			} else if (weight <= 57.00) {
				System.out.println("feather");
			} else if (weight <= 60.00) {
				System.out.println("light");
			} else if (weight <= 64.00) {
				System.out.println("light welter");
			} else if (weight <= 69.00) {
				System.out.println("welter");
			} else if (weight <= 75.00) {
				System.out.println("light middle");
			} else if (weight <= 81.00) {
				System.out.println("middle");
			} else if (weight <= 91.00) {
				System.out.println("light heavy");
			} else {
				System.out.println("heavy");
			}
		}
	}
}

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

int main(){
    string s;
    cin >> s;
    vector<char> vec;
    for(int i = 0 ; i < 26 ; i++){
        vec.push_back('a' + i);
    }
    bool MAX = false;
    if(s.size() == 26){
        MAX = true;
        int i = 25;
        while(s[i] < s[i-1]){
            i--;
            if(s[i] == 'z'){
                break;
            }
        }
        s = s.substr(0, i);
    }
    for(int i = 0 ; i < s.size() ; i++){
        int left = 0 , right = vec.size() , mid;
        while(left < right){
            mid = (left + right) / 2;
            if(s[i] == vec[mid]){
                vec.erase(vec.begin() + mid);
                break;
            }else if(s[i] < vec[mid]){
                right = mid;
            }else{
                left = mid + 1;
            }
        }
    }
    if(s.size() == 0){
        cout << -1 << endl;
    }else if(MAX){
        while(vec[0] <= s[s.size()-1]){
            vec.erase(vec.begin());
        }
        s[s.size()-1] = vec[0];
        cout << s << endl;
    }else{
        cout << s << vec[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n), b(n), c(m), d(m);
  REP(i, n) { cin >> a[i] >> b[i]; }

  REP(i, m) { cin >> c[i] >> d[i]; }

  REP(i, n) {
    ll mini = 1e18, idx;
    REP(j, m) {
      ll dx = abs(a[i] - c[j]), dy = abs(b[i] - d[j]);
      ll d = dx + dy;
      if (d < mini) {
        mini = d;
        idx = j;
      }
    }
    cout << idx + 1 << endl;
  }
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.{Comparator, StringTokenizer}

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, A, B = sc.nextInt()
    val V = Array.fill[Long](N)(sc.nextLong())

    val dp = Array.ofDim[Long](N + 1, N + 1)
    val cnt = Array.ofDim[Long](N + 1, N + 1)
    (0 until N) foreach (i => cnt(i)(0) = 1)

    for {
      j <- 1 to N
      i <- 1 to N
    } {
      val v = dp(i - 1)(j - 1) + V(i - 1)
      val v0 = dp(i - 1)(j)
      if (v > v0) {
        dp(i)(j) = v
        cnt(i)(j) = cnt(i - 1)(j - 1)
      } else if (v == v0) {
        dp(i)(j) = v0
        cnt(i)(j) = cnt(i - 1)(j) + cnt(i - 1)(j - 1)
      } else {
        dp(i)(j) = v0
        cnt(i)(j) = cnt(i - 1)(j)
      }
    }

    type Avg = (Long, Int)
    implicit val O: Ordering[(Long, Int)] = Ordering.fromLessThan { (x, y) =>
      val (xv, xd) = x
      val (yv, yd) = y
      xv * yd < yv * xd
    }

    val averages = dp(N).zipWithIndex.slice(A, B + 1) map {
      case (v, j) => ((v, j), cnt(N)(j))
    }
    val (m, _) = averages.maxBy(_._1)
    val count = averages.filter(a => O.equiv(a._1, m)).map(_._2).sum

    println(f"${m._1.toDouble / m._2}%.6f")
    println(count)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 26956
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Dy = (-1,0,1,0)
Dx = (0,1,0,-1)
def main():
    H,W = map(int,input().split())
    grid = [input() for _ in range(H)]
    grid = [[1 if g == '#' else 0 for g in gr] for gr in grid]
    G = [[] for _ in range(H*W)]

    for i in range(H):
        for j in range(W):
            for dy,dx in zip(Dy,Dx):
                y = i + dy
                x = j + dx
                if y < 0 or y >= H or x < 0 or x >= W:
                    continue
                if grid[i][j]^grid[y][x] == 1:
                    G[i*W + j].append(y*W + x)
                    G[y*W + x].append(i*W + j)
    
    visited = [-1] * (H*W)
    ans = 0
    for i in range(W*H):
        if visited[i] >= 0:
            continue
        stack = [i]
        visited[i] = 0
        w = 1
        b = 0
        while stack:
            v = stack.pop()
            for e in G[v]:
                if visited[e] >= 0:
                    continue
                visited[e] = visited[v]^1
                if visited[e] == 1:
                    b += 1
                else:
                    w += 1
                stack.append(e)
        ans += b*w
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 74144
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

void func(int N,int S){

	int table[N],index = N-1,tmp;

	priority_queue<int> Q;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		Q.push(tmp);
	}

	while(!Q.empty()){
		table[index--] = Q.top();
		Q.pop();
	}

	int sum = 0,left,right,m,tmp_min;

	for(int i = 0; i < N-1; i++){
		left = i+1,right = N-1,m = (left+right)/2;

		tmp_min = N;

		while(left <= right){
			if(table[i] + table[m] > S){
				tmp_min = m;
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}
		if(tmp_min != N){
			sum += N - tmp_min;
		}
	}

	printf("%d\n",sum);
}

int main(){

	int N,S;

	while(true){
		scanf("%d %d",&N,&S);
		if(N == 0 && S == 0)break;

		func(N,S);
	}

	return 0;
}

Measured memory_bytes: 2716
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n):
        for j in range(i):
            for k in range(j):
                if l[j]+l[k] > l[i] and l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                    ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 68180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 2020;
int n, m, q;
int a[N];
bool vis[N];
vector<vi> b;
int main() {
	scanf("%d%d%d", &n, &m, &q);
	rep(i, 0, n) scanf("%d", a + i), b.pb({a[i], i});
	sort(all(b));
	int ans = 2e9;
	for(int l = 0, r = 0; l < sz(b); l = r) {
		vi sb;
		for(int i = 0, j = 0; i < n; i = j) {
			while(i < n && vis[i]) i++;
			j = i;
			vi b;
			while(j < n && !vis[j]) b.pb(a[j++]);
			sort(all(b));
			rep(k, 0, sz(b) - m + 1)
				sb.pb(b[k]);
		}
		sort(all(sb));
		if(sz(sb) >= q) {
			ans = min(ans, sb[q - 1] - sb[0]);
		//	dd(sb[q - 1]), de(sb[0]);
		}
		r = l;
		while(r < sz(b) && b[r][0] == b[l][0])
			vis[b[r++][1]] = 1;
		rep(i, 0, n) if(vis[i]) {
			int j = i + 1;
			while(j < n && !vis[j]) j++;
			if(j - i - 1 < m) {
				rep(_, i, j) vis[i] = 1;
			}
		}
	//	dd(l), dd(r), de(ans);
	}
	printf("%d\n", ans);
	return 0;
}



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



int main (){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string k = s;
    sort(k.begin(), k.end());
    ll ans = 0;
    rep(i,n){
        if(k[i]=='R'&&s[i]=='W'){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main () {
  double a, b, x;
  scanf("%lf %lf %lf", & a, &b, &x);
  if (x > (a * a * b) / 2) {
    printf("%0.10lf", atan((2 / a) * (b - (x / (a * a)))) * 180 / 3.141592654);
    return 0;
  }
  printf("%0.10lf", atan((a * b * b) / (2 * x)) * 180 / 3.141592654);
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
#define mod 1000000007
using namespace std;
int H, W, A, B, fact[222222], inv[222222], factinv[222222], z[222222];
inline int ncr(int xx, int yy) {
	if (xx < 0 || yy < 0 || xx < yy) return 0;
	return 1LL * fact[xx] * factinv[yy] % mod * factinv[xx - yy] % mod;
}
int main() {
	fact[0] = 1;
	for (int i = 1; i <= 200009; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
	inv[1] = 1;
	for (int i = 2; i <= 200009; i++) inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
	factinv[0] = 1;
	for (int i = 1; i <= 200009; i++) factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	cin >> H >> W >> A >> B;
	int ret = 0;
	for (int i = 0; i < W - B; i++) {
		int res = 1LL * ncr(A + i - 1, i) * ncr(W - i + H - A - 2, H - A - 1) % mod;
		ret = (ret + res) % mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define de(x) cerr << #x << " = " << x << endl;
long long a[2222];
long long Min[2222][2222];
int main()
{
 	long long n,x;
 	cin >> n >> x;
 	for(int i=0;i<n;i++)
 		cin>>a[i];


 	for(int i=0;i<n;i++)
 	{
 		long long mn = 1e15;
 		for(int j=i;;j = (j==n-1?0:j+1))
 		{
 			mn = min(mn, a[j]);
 			if (Min[i][j] != 0) break;
 			Min[i][j] = mn;
 		}
 	}

 	long long ans = 1e15;
 	for(int spells = 0; spells < n; spells++)
 	{
 		long long curent = spells * x;
 		for(int i=0;i<n;i++)
 		{
 			curent += Min[(i-spells+n)%n][i];
 		}
 		ans = min(ans, curent);
 	}
 	cout << ans;
 	return 0;
}


Measured memory_bytes: 34944
#include<iostream> 
#include<cstring> 
#include<limits.h> 
#include<algorithm>
#define ll long long
using namespace std;
 
ll dp[101][100005];
 
 ll knapsack(ll *sum, ll *weight, int n, int w)
 {
     if(n == 0) return 0;
     if(dp[n][w] != -1) return dp[n][w];
     if(w-weight[n-1] >= 0) return dp[n][w] = max(sum[n-1] + knapsack(sum,weight,n-1,w-weight[n-1]), knapsack(sum,weight,n-1,w));
     return dp[n][w] = knapsack(sum,weight,n-1,w);
 }
 
int main()
{
    memset(dp, -1, sizeof(dp));
    int n,w; cin >> n >> w; ll sum[n], weight[n];
    
    for(int i = 0; i < n; ++i) cin >> weight[i] >> sum[i];
    cout << knapsack(sum,weight,n,w);
}

Measured memory_bytes: 82060
#include <stdio.h>
#define Q 8
#define A -1
#define U 1
#define true 1
#define false 0


int row[Q],col[Q],rt[2*Q-1],l[2*Q-1];
int X[Q][Q];

void syokika(){
  int i;
  for(i=0;i<Q;i++){
    row[i]=A;
    col[i]=A;
  }
  for(i=0;i<2*Q-1;i++){
    rt[i]=A;
    l[i]=A;
  }
}

void print(){
  int i,j;

  for(i=0;i<Q;i++){
    for(j=0;j<Q;j++){
      if(X[i][j]==true){
	if(row[i] != j)return;
      }
    }
  }
  for(i=0;i<Q;i++){
    for(j=0;j<Q;j++){
       if(row[i] == j)printf("Q");
       else printf(".");
    }
    printf("\n");
  }
}


void recursive(int i){
  int j;
  if(i == Q){
    print();
    return;
  }

  for(j=0;j<Q;j++){
    if(U == col[j] || U == rt[i+j] || U == l[i-j+Q-1])continue;
    row[i]=j;
    col[j]=U;
    rt[i+j]=U;
    l[i-j+Q-1]=U;
    recursive(i+1);
    row[i]=A;
    col[j]=A;
    rt[i+j]=A;
    l[i-j+Q-1]=A;
  }
}

int main(){
  syokika();

  int i,j,u,r,c;
  

  for(i=0;i<Q;i++){
    for(j=0;j<Q;j++){
      X[i][j]=false;
    }
  }

    scanf("%d",&u);

    for(i=0;i<u;i++){
      scanf("%d %d",&r,&c);
      X[r][c]=true;
    }

    recursive(0);

    return 0;
}

      


  
    
	     



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
    int N;
    cin>>N;
    int A[N];
    int a;
    int L=100000;
    int counter[L];
    int ans=0;
    REP(i,L) counter[i] = 0;
    REP(i,N) {
        cin>>a;
        a--;
        A[i]=a;
        counter[a]++;
    }
    int even=0;
    REP(i,L){
        if (counter[i]!=0){
            ++ans;
            if (counter[i]%2 == 0){
                ++even;
            }
        }
    }
    if (even%2 == 1) --ans;
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A =[]
max = 0
next = 0
for _ in range(N):
    a = int(input())
    A.append(a)
    if a > max:
        next = max 
        max = a
    elif a > next:
        next = a
for a in A:
    if a == max:
        print(next)
    else:
        print(max)

Measured memory_bytes: 12512
S = input()
ACGT = ""
ans = 0
for i in range(len(S)):
    for j in range(len(S)-i):
        if(S[i+j] != "A" and S[i+j] != "C" and S[i+j] != "G" and S[i+j] != "T"):
            break
        ACGT = ACGT + S[i+j]
    ans = max(ans,len(ACGT))
    ACGT = ""
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String [] a = new String [2];
    a[0] = "";
    a[1] = "";
    for (int i=0;i<2;i++){
      for (int j=0;j<n;j++){
        String t = scan.nextInt()+"";
        a[i] += t;
      }
    }

    String c = a[0];
    String d = a[1];
    int[] gg1 = new int[2];
    boolean[] check1 = new boolean[n];
    int[] gg2 = new int[2];
    boolean[] check2 = new boolean[n];
    int[] e = find(c,"",n,gg1,check1);
    int[] f = find(d,"",n,gg2,check2);
    if (e[1] >= f[1]){
      System.out.println(e[1]-f[1]);
    }
    else{
      System.out.println(f[1]-e[1]);
    }
  }

  public static int[] find(String a,String b,int n, int[] count,boolean[] check){

    if (b.length() == n){
      count[0] += 1;
      if (a.equals(b)){
        count[1] = count[0];
      }
      return count;
    }

    for (int i=0;i<n;i++){
      if (check[i] == false){
        String current = b;
        int l = i+1;
        b += l+"";
        check[i] = true;
        count = find(a,b,n,count,check);
        if (count[1] !=0 ){
          return count;
        }
        check[i] = false;
        b = current;
      }
    }
    return count;
  }
}


Measured memory_bytes: 49956
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
  static class FastScanner
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    String next() {
      while(!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {}
      }
      return st.nextToken();
    }
    
    int nextInt() {
      return Integer.parseInt(next());
    }
    
    long nextLong() {
      return Long.parseLong(next());
    }
    
  }
  
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    int n = fs.nextInt();
    int k = fs.nextInt();
    int[] arr = new int[n];
    for(int i = 0; i < n; ++i) {
      arr[i] = fs.nextInt();
    }
    int[] dp = new int[n];
    for(int i = 1; i < n; ++i) {
      int min = Integer.MAX_VALUE;
      for(int j = 1; j <= k; ++j) {
        int val = Integer.MAX_VALUE;
        if(i-j >= 0) {
          val = dp[i-j] + (int)Math.abs(arr[i-j]-arr[i]);
        }
        if(val < min) {
          min = val;
        }
        
      }
      dp[i] = min;
    }
    PrintWriter out = new PrintWriter(System.out);
    out.println(dp[n-1]);
    out.close();
  }
}


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

int main()
{
	long long s{}, min{1000};
	scanf("%lld", &s);
	while (s >= 100)
	{
		min = std::min(std::abs(s % 1000 - 753), min);
		s /= 10;
	}
	printf("%lld\n", min);

	return 0;
}

Measured memory_bytes: 256
a = [int(_) for _ in input().split()]
if len(a) == 4 and all(1 <= item <= 100 for item in a):
    if a[3] >= abs(a[2] - a[0]):
        print('Yes')
    elif a[3] >= abs(a[0] - a[1]) and a[3] >= abs(a[1] - a[2]):
        print('Yes')
    else:
        print('No')
else:
    print('hoge!')

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

#define MorsheD ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;

int main() {
	// ===================
	MorsheD;
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	// ===================

	string a, b;

	cin >> a >> b;

	int res = 10000, lenA = a.size(), lenB = b.size(), diff = lenA - lenB;

	for (int i = 0; i < diff + 1; ++i) {
		// cout << i << '\n';
		int cnt = lenB;
		for (int j = 0, k = i; j < lenB && k < lenA; ++j, ++k) {
			if (a[k] == b[j]) {
				cnt--;
			}
		}
		// cout << cnt << '\n';
		res = min(res, cnt);
	}

	cout << res << '\n';

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define int ll
//#define int __int128
//#define ll __int128
typedef pair<int, int   > pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
//typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {

    int n;
    cin >> n;
    vi a(n);
    int ans = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            ans += sum / 2;
            sum = 0;
        }

        sum += a[i];
    }
    ans += sum / 2;
    cout << ans;
    

}

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

int main() {
  string s;
  cin >> s;
  
  int cost = 700;
  
  for(int i = 0; i < 3; i++) {
    if (s.at(i) == 'o') cost += 100;  
  }
  cout << cost << endl;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a, b;
    while(cin>>a>>b) {
        if(a==0 && b==0) break;
        if(a<=b) cout<<a<<' '<<b<<'\n';
        else cout<<b<<' '<<a<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  print(1.0 * (N - N / 2) / N);
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 5;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here
ll n,k;
int arr[maxi];
bool check(ll x)
{
	ll c = 0;
	for (int i = 0; i < n; ++i)
		c += (arr[i]-1) / x;
	return c <= k;
}

int main()
{
	IOS;
	cin >> n >> k;
	int max_val=0;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
		max_val = max(max_val, arr[i]);
	}
	ll start = 1, end = max_val, mid;
	while (start < end)
	{
		mid = start + (end - start) / 2;
		if (check(mid))
			end = mid;
		else
			start = mid+1;
	}
	cout <<start<< endl;
	return 0;
}


Measured memory_bytes: 4392