akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e3 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	readarr(p, a);
	readarr(q, b);
	readarr(r, c);
	
	sort(p + 1, p + a + 1, greater<int>());
	sort(q + 1, q + b + 1, greater<int>());
	
	vi v;
	FOR (i, 1, x) v.pb(p[i]);
	FOR (i, 1, y) v.pb(q[i]);
	FOR (i, 1, c) v.pb(r[i]);
	
	sort(all(v), greater<int>());
	
	int sum = 0;
	FOR (i, 0, x + y - 1) sum += v[i];
	print(sum);
}















Measured memory_bytes: 8432
from itertools import  product
h,w=map(int,input().split())

s=[]
for i in range(h):
    s.append(list(map(str,input())))

#print(s)
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            print(s[i][j],end="")
        else:
            count=0
            for z in product((0, 1, -1), repeat=2):
                x,y=z
                
                if x!=0 or y!=0:
                    if 0<=(i-x) and (i-x)<h and 0<=(j-y) and (j-y)<w and s[i-x][j-y]=='#':
                        count+=1
            print(count,end="")
    print()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(ll i=ll(x);i<(ll)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<ll,ll>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    ll n;
    cin>>n;
    vector<lP>mp1(100005),mp2(100005);
    rep(i,n){
        ll v;
        cin>>v;
        if(i%2==0){
            mp1[v].first++;
            mp1[v].second=v;
        }
        else {
            mp2[v].first++;
            mp2[v].second=v;
        }
    }
    sort(mp1.begin(),mp1.end(),greater<P>());
    sort(mp2.begin(),mp2.end(),greater<P>());
    ll num;
    if(mp1[0].second==mp2[0].second){
        num=max(mp1[0].first+mp2[1].first,mp1[1].first+mp2[0].first);
    }
    else {
        num=mp1[0].first+mp2[0].first;
    }
    ll ans=n-num;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define pb push_back
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fst first
#define snd second
#define mset(a,v) memset((a),(v),sizeof(a))
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
typedef long long ll;
const int N=200500;
const ll mod=1e9+7;
ll f[N];
ll mul(ll a, ll b){a*=b;return a%mod;}
int sum(int a, int b){a+=b;return a%mod;}
int sub(int a, int b){a-=b;a+=mod;return a%mod;}
int be(ll b, int e){
	ll r=1;
	while(e){
		if(e&1)r=mul(r,b);
		b=mul(b,b);
		e/=2;
	}
	return r;
}
ll C(ll n, ll k){
	if(k>n)return 0;
	ll r=f[n];
	r=mul(r,be(f[k],mod-2));
	r=mul(r,be(f[n-k],mod-2));
	return r;
}
int dp[N];
int n,m,k;
typedef pair<int,int> ii;
int main(){FIN;
	f[0]=1;
	fore(i,0,N-1)f[i+1]=mul(f[i],(i+1));
	cin>>n>>m>>k;
	vector<ii> w;
	fore(i,0,k){
		int x,y;cin>>x>>y;
		x--;y--;
		w.pb({x,y});
	}
	w.pb({n-1,m-1});
	sort(ALL(w));
	fore(i,0,k+1){
		auto p=w[i];
		dp[i]=C(p.fst+p.snd,p.fst);
		fore(j,0,i){
			auto q=w[j];
			if(p.fst<q.fst||p.snd<q.snd)continue;
			dp[i]=sub(dp[i],mul(dp[j],C(p.fst+p.snd-q.fst-q.snd,p.fst-q.fst)));
		}
	}
	cout<<dp[k]<<"\n";
}

Measured memory_bytes: 1920
S, T = input(), input()
def different(A, B):
    res = 0
    for a, b in zip(A, B):
        if a != b:
            res += 1
    return res

lenS = len(S)
lenT = len(T)
Change = [different(S[i:i+lenT], T) for i in range(lenS-lenT+1)]
print(min(Change))

Measured memory_bytes: 9116
"use strict";

function main(input) {
  input = input.trim();
  let num = parseInt(input);
  const result = num + num ** 2 + num ** 3;
  console.log(result);
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;

int ans[2*100010];

void solve(void){
    int N;
    cin >> N;
    if (N%2==0) {
        rep(N, i) {
            int a; cin >> a;
            if (i%2==0) ans[N/2+i/2] = a;
            else ans[N/2-(i+1)/2] = a;
        }
    }
    else {
        rep(N, i) {
            int a; cin >> a;
            if (i%2==0) ans[N/2-i/2] = a;
            else ans[N/2+(i+1)/2] = a;
        }
    }

    rep(N, i) cout << ans[i] << ' ';
    cout << '\n';
}

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


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

int main(){
    int m, f, r;

    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1){break;}

        if(m == -1 || f == -1){
            cout << "F" << endl;
        }else if(m + f >= 80){
            cout << "A" << endl;;
        }else if(m + f >= 65){
            cout << "B" << endl;
        }else if(m + f >= 50){
            cout << "C" << endl;
        }else if(m + f >= 30 && r >= 50){
            cout << "C" << endl;
        }else if(m + f >= 30 && r < 50){
            cout << "D" << endl;
        }else{
            cout << "F" << endl;
        }
    }
    return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool ok = true;
  for (int i = 0; i < S.size(); i++)
  {
    if (i == A)
    {
      if (S[i] != '-')
      {
        ok = false;
        break;
      }
    }
    else
    {
      if (S[i] == '-')
      {
        ok = false;
        break;
      }
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a == b) {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26192
import java.io.*;

class Main{
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        private static void swap(int[] A, int i, int j){
                int tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
        }

        private static void printArray(int[] A){
                for(int i=0; i<A.length; i++){
                        System.out.print(A[i]);
                        if(i!=A.length-1)
                                System.out.print(" ");
                }
                System.out.println();
        }

        public static void main(String[] args) throws IOException{
                int N = Integer.parseInt(br.readLine());
                String[] iline = br.readLine().split(" ");
                int[] A = new int[N];
                int count = 0;
                for(int i=0; i<N; i++)
                        A[i] = Integer.parseInt(iline[i]);
                for(int i=0; i<N; i++){
                        for(int j=N-1; j>i; j--)
                                if(A[j]<A[j-1]){
                                        swap(A, j, j-1);
                                        count++;
                                }
                }
                printArray(A);
                System.out.println(count);
        }
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int out = 0;
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    if(i == 0){
      for(int j = 0; j < s.size(); j++){
        if(s.at(j) == '.') count++;
        out = count;
      }
    }else{
      if(s.at(i - 1) == '.' & s.at(i) == '.'){
        count--;
      }else if(s.at(i - 1) == '#' & s.at(i) == '#'){
        count++;
      }else if(s.at(i - 1) == '.' & s.at(i) == '#'){
        count--;
      }else if(s.at(i - 1) == '#' & s.at(i) == '.'){
        count++;
      }
      if(out > count){ 
        out = count;
      }
    }
    if(i == s.size() - 1){
      int count2 = 0;
      for(int j = 0; j < s.size(); j++){
        if(s.at(j) == '#') count2++;
      }
      if(out > count2) out = count2;
    }
  }
  cout << out;
}

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

int main(){
	int k,n,l[55],ans=0;

	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>l[i];

	sort(l,l+n,greater<int>());
	for(int i=0;i<k;i++)ans+=l[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char cc;
    cin >> cc;

    if(cc == 'a' || cc == 'o' || cc == 'u' || cc == 'e' || cc == 'i')
        cout << "vowel";
    else
        cout << "consonant";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, int>;

bool pairCompare(const P &firstElof, const P &secondElof)
{
    return firstElof.second < secondElof.second;
}

bool pairComparefirst(const P &firstElof, const P &secondElof)
{
    return firstElof.first < secondElof.first;
}

int main()
{
    int n;
    cin >> n;
    vector<P> X;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        P pair;
        pair.first = i, pair.second = temp;
        X.push_back(pair);
    }
    sort(X.begin(), X.end(), pairCompare);
    vector<P> Y = X;
    for (int i = 0; i < n; i++)
        Y[i].second = i;
    sort(Y.begin(), Y.end(), pairComparefirst);
    for (int i = 0; i < n; i++)
    {
        if (Y[i].second < n / 2)
            cout << X[n / 2].second << endl;
        else
            cout << X[n / 2 - 1].second << endl;
    }

    return 0;
}


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

int main() {
  int N;
  vector<int> A(100000);
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  vector<int> ans(100000);
  for(int i=0; i<N; i++) ans[A[i]-1] = i+1;
  for(int i=0; i<N; i++) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
using ll = long long;
using namespace std;

ll lcm(ll x, ll y){
    ll a=max(x,y);
    ll b=min(x,y);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    
    long long a, b;
    cin >> a >> b;
    
    ll r = lcm(a, b);
    
    cout << a*b/r << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
 public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
  int n = scan.nextInt();
  int[] array = new int[n];
  for(int i = 0; i < n; i++){
   array[i] = scan.nextInt();
  }
  System.out.print(array[n - 1]);
  for(int i = 2; i <= n; i++){
   System.out.print(" " + array[n - i]);
  }System.out.println();
 }
}

Measured memory_bytes: 19008
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
count = 0

loop{
    n == 1 && break
    flg = 0
    for i in 1..n-1
        arr[i] > arr[i-1] && next
        if arr[i] < arr[i-1]
            arr[i],arr[i-1] = arr[i-1],arr[i]
            count += 1
            flg += 1
        end
    end
    flg == 0 && break
}

puts arr.join(" ")
puts count

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

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return (0);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#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 rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,sum,ans=999999999;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    for(ll i=-100;i<=100;i++){
        sum=0;
        rep(j,n){
            sum+=pow(abs(i-a[j]),2);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n, mx, sum = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    mx = a[0];
    for (int i = 1; i < n; ++i) {
        sum += a[i];
    }
    if (mx < sum)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

const int ALPHABET = 26;
const int N = 55;

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

  vector<vector<int>> cnt(n, vector<int> (ALPHABET));
  rep(i,n) {
    string s;
    cin >> s;

    int m = s.size();
    for (int j = 0; j < m; j++) {
      int idx = s[j] - 'a';
      cnt[i][idx]++;
    }
  }

  vector<int> minimum(ALPHABET, N);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < ALPHABET; j++) {
      minimum[j] = min(minimum[j], cnt[i][j]);
    }
  }

  string answer = "";
  for (int i = 0; i < ALPHABET; i++) {
    answer += string(minimum[i], (i + 'a'));
  }

  cout << answer << endl;

}



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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
  int K,c,i,sum;
  while (1){
    scanf("%d",&K);
    if (K==0)break;
    sum=0;
    for (i=0 ; i < (K*K-K)/2 ; i++){
      scanf("%d",&c);
      sum=sum+c;
    }
    printf("%d\n",sum/(K-1) );
  }
  
  return 0;
}

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

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    ll n;
    cin >> n;
    ll ans = (n * (n - 1)) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define int ll

using namespace std;

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

const int INF = 1e9 + 7;

pi a[200005];

int32_t main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i].S >> a[i].F;
	sort(a, a+n);
	int t= 0;
	for(int i=0;i<n;i++) {
		t += a[i].S;
		if(t > a[i].F) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s.size() % 2 == 1)
    {
        int count = 0;
        int pos = s.size() / 2;
        for(int i = 0;i + pos < s.size() && pos - i >= 0;i++)
        {
            if(s[pos - i] != s[pos + i])
            {
                count++;
            }
        }
        cout << count;
    }
    else
    {
        int count = 0;
        int pos = s.size() / 2;
        for(int i = 0;i + pos < s.size() && pos - 1 - i >= 0;i++)
        {
            if(s[pos - 1 - i] != s[pos + i])
            {
                count++;
            }
        }
        cout << count;
    }
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int tmp, sum = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    a.at(i) = tmp;
    sum += tmp;
  }
  
  sort(a.begin(), a.end(), greater<int>());
  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i += 2) {
    Alice += a.at(i);
  }
  Bob = sum - Alice;
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 3600
const int m=10000000+10;
bool[m] pp;

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);

  if(n==1){
    writeln(0);
    return;
  }
  if(n==2){
    writeln(0);
    return;
  }
    
  mp();
  int cnt=0;
  for(int p=1; p<=n; p++){
    if(pp[p] && pp[p+2]){
      cnt++;
    }
  }
  writeln(cnt*2);
}

void mp(){
  foreach(i; 0..m) pp[i]=true;
  pp[0]=pp[1]=false;
  for(int i=2; i*i<=m; i++){
    if(pp[i]){
      for(int j=2; i*j<m; j++){
        pp[i*j]=false;
      }
    }
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}




Measured memory_bytes: 12240
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
import math
def dist(x0, y0, x1, y1):
    return ((x0-x1)**2+(y0-y1)**2)**0.5
ans = 10**18
eps = 10**(-7)
for i in range(N):
    for j in range(i):
        for k in range(j):
            xi, yi = xy[i]
            xj, yj = xy[j]
            xk, yk = xy[k]
            a = xi
            b = yi
            c = xj
            d = yj
            e = xk
            f = yk

            aa = a * a
            bb = b * b
            cc = c * c
            dd = d * d
            ee = e * e
            ff = f * f
            try:
                py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

                px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a))\
                if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))
            except:
                continue

            r = math.hypot(px - a, py - b)
            flag = True
            for l in range(N):
                xl, yl = xy[l]
                if math.hypot(xl-px, yl-py)<=r+eps:
                    continue
                flag = False
            if flag:
                ans = min(ans, r)
for i in range(N):
    for j in range(i):
        xi, yi = xy[i]
        xj, yj = xy[j]
        px, py = (xi+xj)/2, (yi+yj)/2
        r = dist(xi, yi, xj, yj)/2
        flag = True
        for l in range(N):
            xl, yl = xy[l]
            if math.hypot(xl-px, yl-py)<=r+eps:
                continue
            flag = False
        if flag:
            ans = min(ans, r)
print(ans)







Measured memory_bytes: 49752
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vll x(n), y(m);
    mint xsum(0);
    mint ysum(0);
    REP(i,n){
        cin >> x[i];
    }
    REP(i,m) cin >> y[i];
    REP(i,n-1){
        mint t;
        t = mint((i+1)*(n-1-i));
        t *= mint(x[i+1]-x[i]);
        xsum += t;
    }
    REP(i,m-1){
        mint t;
        t = mint((i+1)*(m-1-i));
        t *= mint(y[i+1]-y[i]);
        ysum += t;
    }
    mint ans = xsum*ysum;
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 4760
//
//  main.cpp
//  oct_18 17 Code Festival QualB  C
//
//  Created by Shuangyi Zhang on 10/18/17.
//  Copyright © 2017 Shuangyi Zhang. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
vector<vector<long long>> g(100005);
long long n,m,a,b;
int used[100005];
int main() {
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i=1;i<=n;i++){
        used[i]=0;
    }
    queue<int> q;
    q.push(1);
    used[1]=1;
    while (!q.empty()){
        int x=q.front();
        q.pop();
        for (auto v:g[x]){
            if (used[v]==0){
                q.push(v);
                used[v]=-used[x];
            }else if (used[v]==used[x]){
                long long ans=(n-1)*n/2-m;
                printf("%lld",ans);
                return 0;
            }
        }
        
    }
    long long res1=0,res2=0;
    for (int i=1;i<=n;i++){
        if (used[i]==1){
            res1++;
        }else res2++;
    }
    printf("%lld",res1*res2-m);
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 1e6;

LL fact[MAXN] = {0}, ifact[MAXN] = {0};
void preprocess() {
	fact[0] = (ifact[0] = 1);
    for(int i = 1; i < MAXN; i++) {
		fact[i] = (fact[i-1]*i)%mod;
	}
	ifact[MAXN-1] = modinv(fact[MAXN-1], mod); ifact[0] = 1;
	for(LL i = MAXN-2; i > 0; i--){
		ifact[i] = (ifact[i+1]*(i+1))%mod;
	}
	assert((fact[2]*ifact[2])%mod == 1);
}

LL nCr(int n, int r) {
    return (fact[n] * ((ifact[n-r] * ifact[r])%mod)) % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
	preprocess();
	LL n, m;
	cin >> n >> m;
	LL res = 0;
	if(abs(n - m) > 1) {
		res = 0;
	} else {
		if(n == m) {
			res = fact[n] * fact[m] % mod;
			res += fact[n] * fact[m] % mod;
		} else {
			res = fact[n] * fact[m] % mod;
		}
		res %= mod;
	}
	cout << res << '\n';
  return 0;
}


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

int main()
{
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	vector<int> ok(3001);
	ok[0] = 1;
	for (int i = 0; i <= 3000; i++) {
		if ((i >= C && ok[i - C]) || (i >= D && ok[i - D])) {
			ok[i] = 1;
		}
	}
	int r1 = 100 * A, r2 = 0;
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			for (int k = 0; k <= 3000; k++) if (ok[k]) {
				if (i * A * 100 + j * B * 100 + k <= F && k <= (i * A + j * B) * E) {
					int t1 = i * A * 100 + j * B * 100 + k, t2 = k;
					if (t1 * r2 < t2 * r1) {
						r1 = t1;
						r2 = t2;
					}
				}
			}
		}
	}
	cout << r1 << ' ' << r2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()

typedef struct class_tbl
{
	const char *name;
	double t1;
	double t2;
} class_t;

const class_t class[7] = {{"AAA", 35.50, 71.0}, {"AA" , 37.50, 77.0}, {"A"  , 40.00, 83.0},
                          {"B"  , 43.00, 89.0}, {"C"  , 50.00,105.0}, {"D"  , 55.00,116.0}, {"E"  ,70.00,148.0}};

int
main(int argc, char **argv)
{
	double t1, t2;
	while (scanf("%lf%lf", &t1, &t2) != EOF)
	{
		int i;
		for (i = 0; i < 7; ++i)
		{
			if (t1 < class[i].t1 && t2 < class[i].t2)
				break;
		}

		if (i < 7)
			printf("%s\n", class[i].name);
		else
			printf("NA\n");
	}

	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main(){
    int N;
    cin >>N;
    ll T[N];
    rep(i,0,N) cin >> T[i];
    ll c=T[N-1];
    rer(i,N,0){
        c=lcm(c,T[i]);
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;
bool use[10] = {};
int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, 10)use[i] = true;
	rep(i, 0, k) {
		ll M; cin >> M;
		use[M] = false;
	}

	rep(i, n, 100000) {
		ll t = i;
		bool next = false;
		while (t) {
			if (!use[t % 10]) {
				next = true;
				break;
			}
			t /= 10;
		}
		if (!next) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    sll n, k;
    cin >> n >> k;
    vector<int> hs(n);
    REP(i, n) {
        cin >> hs[i];
    }

    sort(hs.begin(), hs.end());
    int min_d = numeric_limits<int>::max();
    for (sll i = 0; i <= n - k; i++) {
        min_d = min(min_d, hs[i + k - 1] - hs[i]);
    }

    cout << min_d << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 640
def get_rect(c)
	x1 = x2 = y1 = y2 = -1

	0.upto($h-1) do |y|
		0.upto($w-1) do |x|
			if $d[y][x] == c then
				y2 = y
				next
			end
		end
	end

	($h-1).downto(0) do |y|
		0.upto($w-1) do |x|
			if $d[y][x] == c then
				y1 = y
				next
			end
		end
	end

	0.upto($w-1) do |x|
		0.upto($h-1) do |y|
			if $d[y][x] == c then
				x2 = x
				next
			end
		end
	end

	($w-1).downto(0) do |x|
		0.upto($h-1) do |y|
			if $d[y][x] == c then
				x1 = x
				next
			end
		end
	end

	return x1, x2, y1, y2
end

def check(c)
	x1, x2, y1, y2 = get_rect(c)

	for y in y1 .. y2
		for x in x1 .. x2
			if $d[y][x] == '.' then
				return false
			elsif $mt.find_index($d[y][x]) != nil then
				return false
			end
		end
	end

	$mt.push c

	for y in y1 .. y2
		for x in x1 .. x2
			if $d[y][x] != c && $d[y][x] != ' ' then
				if check($d[y][x]) == false then
					return false
				end
			end
		end
	end

	for y in y1 .. y2
		for x in x1 .. x2
			if $d[y][x] == c then
				$d[y][x] = ' '
			end
		end
	end

	return true
end

def search()
	$h.times do |y|
		$w.times do |x|
			if $d[y][x] != '.' && $d[y][x] != ' ' then
				if check($d[y][x]) == false then
					return false
				end
			end
		end
	end

	return true
end

n = gets.to_i

n.times do
	$h, $w = gets.split.map(&:to_i)

	$d = []
	$h.times do
		$d.push gets.chomp.split('')
	end

	$mt = []

	puts search() ? "SAFE" : "SUSPICIOUS"
end

Measured memory_bytes: 6128
D, G = map(int, input().split())

problems = [tuple(map(int, input().split())) for _ in range(D)]
ans = 10**10

for mask in range(1 << D):
    point = 0
    cnt = 0
    for i, (p, c) in enumerate(problems):
        if (mask & (1 << i)) > 0:
            cnt += p
            point += 100 * (i + 1) * p + c

    if point >= G:
        ans = min(ans, cnt)
        continue

    for i, (p, c) in enumerate(problems):
        if (mask & (1 << i)) > 0:
            continue
        ness = -(-(G - point) // (100 * (i + 1)))
        if ness <= p:
            ans = min(ans, cnt + ness)

print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.util.Map.Entry;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			double d = sc.nextDouble();
			if(d < 0) break;
			int n = (int)(d * 16.0); 
			if( (double)n != d*16.0 || (int)d > 256 ){
	            System.out.println("NA");
	            continue;
	        }
			for( int i=11; i>=0; i-- ){
				if(i == 3) System.out.print(".");
	            System.out.print(((n&(1<<i)) != 0? '1':'0'));
	        }
			System.out.println();

		}
	}
}

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

int main(){
  int n;
  long long int asum=0,bsum;
  string ans="Yes";
  cin>>n;
  vector<pair<int,int>> B;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    B.emplace_back(b,a);
  }
  sort(B.begin(),B.end());
  for(auto a :B){
    asum+=a.second;
    if(asum>a.first){
      ans="No";
      break;
    }
  }
  cout<<ans<<endl;
}
    

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

int main() {
  int n, l, r, t;
  cin >> n;
  t = 0;

  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    t += (r - l + 1);
  }
  cout << t << endl;
}


Measured memory_bytes: 256
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
a,b  =ips()
if (a+b)%2:
    print("IMPOSSIBLE")
else:print((a+b)//2)

Measured memory_bytes: 23296
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  int tmp = 1;
  int num_cnt = 0;
  while(K > tmp){
    tmp *= 2;
    num_cnt += 1;
  }
  double nums_list[N];
  for(int i = 1; i <= N; i++){
    for(int j = 0;j <= num_cnt;j++){
      if(i*pow(2,j) >= K){
        nums_list[i-1] = pow(0.5,j) *(1 / double(N));
        break;
      }
    }
  }
  double nums_sum = 0;
  for(int i= 0; i < N; i++){
    nums_sum += nums_list[i];
  }
  cout << setprecision(12) << nums_sum;
}

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

namespace test1
{
    class Program
    {



        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<string> a = new List<string>();


            for (int index = 0; index < n; index++)
            {
                a.Add(Console.ReadLine());
            }

            if (new HashSet<string>(a).Count != a.Count())
            {
                Console.WriteLine("No");
                return;
            }

            string output = "Yes";
            char before  = a[0].ToCharArray().First();
            for (int index = 0; index < n; index++)
            {
                if (a[index].ToCharArray().First() != before)
                {
                    output = "No";
                    break;
                }

                before = a[index].ToCharArray().Last();
            }


            Console.WriteLine(output);




        }





    }
}


Measured memory_bytes: 13408
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector<double> x(N);
    vector<string> u(N);

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

    double ans = 0.0;

    for (int i = 0 ; i < N; i++) {
        if (u[i] == "BTC") {
            ans += x[i] * 380000.0;
        } else {
            ans += x[i];
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
int val[maxn];
int col[maxn];
set<int>v;

void solve()
{
	sa(n);
	repp(i,1,n)
	{
		sa(val[i]);
		v.insert(val[i]);
	}
	if(v.size()>2)
	{
		puts("No");
		return;
	}
	if(v.size()==1)
	{
		int a=*v.begin();

		if(n>=2*a||n==a+1)
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}
	}
	else
	{
		int a=*v.begin();
		int b=*(--v.end());
		if(b-a>1)
		{
			puts("No");
			return;
		}
		int c1=0,c2=0;
		repp(i,1,n)
		{
			if(val[i]==a)c1++;
			else c2++;
		}
		if(n-b>=b-c1&&b>c1)
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}

	}
}

int main()
{
	solve();
	//system("pause");
	return 0;
}







Measured memory_bytes: 5376
//============================================================================
// Name        : aoj2501.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#define INF 0x1fffffff
using namespace std;


int abs(int x){
	if(x < 0){
		return -x;
	}
	return x;
}

int main() {
	int lc[4], ans = INF, y[4], x[4], n;
	cin >> n;
	for(int i = 0;i < 4;i++){
		cin >> lc[i];
	}
	for(int m = 1;m <= n;m++){
		for(int i = 0;i < 4;i++){
			y[i] = (lc[i] - 1) / m;
			x[i] = (lc[i] - 1) % m;
		}
		ans = min(ans,abs(y[0] - y[1]) + abs(x[0] - x[1]) + abs(y[2] - y[3]) + abs(x[2] - x[3]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1164
import fractions


'''

最大公約数を求める
最大公約数を最大にするには何を変えれば良いか

最大値との最大公約数を求めて、最大になれば良い?

'''

n = list(map(int, input().split()))
A = list(map(int, input().split()))
right = []
left = []
for i,a in enumerate(A):
    if i ==0 :
        right.append(a)
    else:
        right.append(fractions.gcd(right[i-1],a))

for i,b in enumerate(reversed(A)):
    if i ==0 :
        left.append(b)
    else:
        left.append(fractions.gcd(left[i-1],b))

result = []

for i,r in enumerate(A):
    if i ==0:
        result.append(right[len(right)- 2])
    if i == len(A) -1:
        result.append(left[len(left) - 2])

    result.append(fractions.gcd(left[i -1], right[len(right) - i -2]))

print(max(result))








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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int h[110];



int main(){
    int n,ans=0;
    cin>>n;
    for(int i = 0; i < 110; i++)
    {
        h[i]=0;
    }
    
    for(int i = 0; i < n; i++)
    {
        cin>>h[i];
    }
    while(true){
        bool cont = false;
        bool end=true;
        for(int i = 0; i < n; i++)
        {
            if(cont)
            {
                if(h[i]==0)
                {
                    cont=false;
                }
                else
                {
                    h[i]--;
                }                
            }
            else
            {
                if(h[i]>0)
                {
                    ans++;
                    cont=true;
                    end=false;
                    h[i]--;
                }
            }            
        }
        if(end)
        {
            break;
        }
    }
    

    cout<<ans<<endl;

    return 0;
}

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

int main(void){
  int H,W;
  cin >> H >> W;
  for(int i=0;i<H;i++){
    vector<char> wide(W);
    for(int j=0;j<W;j++){
      cin >> wide.at(j);
    }
    for(int j=0;j<W;j++){
      cout << wide.at(j);
    }
    cout << endl;
    for(int j=0;j<W;j++){
      cout << wide.at(j);
    }
    cout << endl;
  }
}

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

void func(int num,int N, int max, string s){
  if(num > N){
    cout << s << endl;
  }else{
    for(int i = 'a'; i < max + 1; i++){
      if(i == max){
        func(num + 1, N, max+1, s + (char)i);
      }else{
        func(num + 1, N, max, s + (char)i);
      }
    }
  }
};

int main(){
  int N;
  cin >> N;
  func(1, N, 'a', "");
}

Measured memory_bytes: 1536
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    S = inp()
    print('Yes' if N % 2 == 0 and S[N // 2:] == S[:N // 2] else 'No')


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	private static int[] minSegment;

	private static int n;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] hList = new int[n];
		for(int i = 0; i < n; i++) {
			hList[i] = sc.nextInt();
		}

		int count = 0;
		boolean allzero = false;

		while(!allzero) {
			allzero = true;
			boolean zeroFlg = true;
			for(int i = 0; i < n; i++) {
				int h = hList[i];

				if(h > 0) {
					if(zeroFlg) {
						count++;
					}
					hList[i] = h-1;
					zeroFlg = false;
					allzero = false;
				} else {
					zeroFlg = true;
				}
			}

		}


		System.out.println(count);

	}

}



Measured memory_bytes: 23124
#include <bits/stdc++.h>                                                                               
using namespace std;
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
int main () {
  int h, w, n;
  cin >> h >> w >> n;
  int m = h;
  if  (w > h) {
    m = w;
  }
  cout << ceil((double)n/m) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  for (int i = 0; i < n; i++){
    cin >> m[i];
    x -= m[i];
  }
  sort(m.begin(), m.end());
  while(x>=m[0]){
    x -= m[0];
    n++;
  }
  cout << n << "\n";

  return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

_ = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)
cnt = np.count_nonzero(A < 0)
A = np.abs(A)
if cnt & 1:
    ans = A.sum() - A.min() * 2
else:
    ans = A.sum()
print(ans)


Measured memory_bytes: 22528
N, WW = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

inf = float('inf')
dp = [[inf] * (10 ** 5 + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(10 ** 5 + 1):
        dp[i + 1][j] = dp[i][j]
        if j - V[i] >= 0:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - V[i]] + W[i])

ans = -1

for i in range(10 ** 5 + 1):
    if dp[N][i] <= WW:
        ans = i

print(ans)


Measured memory_bytes: 310936
N,M = map(int,input().split())
A = list(map(int,input().split()))

csum = [0]
for a in A:
  csum.append(csum[-1]+a)
#print(csum)

MOD = {}
for c in csum:
  m = c%M
  if m in MOD:
    MOD[m] += 1
  else:
    MOD[m] = 1
#print(MOD)

ans = 0
for _,v in MOD.items():
  if v >= 2:
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 63256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if(A < C && C < B)
    cout << "Yes" << endl;
  else if(A > C && C > B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;

ll n, k[100];
char s[101];

char next(char c, char d) {
  if (d == 0) return c;
  if ('a' <= c && c <= 'z') {
    char temp = c - 'a' + 1;
    if (temp <= d) return next('Z', d - temp);
    return c - d;
  } else {
    char temp = c - 'A' + 1;
    if (temp <= d) return next('z', d - temp);
    return c - d;
  }
}

int main() {
  while (scanf("%lld", &n), n) {
    for (ll i = 0; i < n; i++) scanf("%lld", &k[i]);
    scanf("%s", s);
    for (ll i = 0; s[i] != 0; i++) {
      printf("%c", next(s[i], (char)k[i%n]));
    }
    printf("\n");
  }
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, m;
  cin >> N >> m;
  vector<int> c(m), d(m);
  for (int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }
  vector<int> cnt(N + 1, 0);
  for (int i = 0; i < m; i++){
    for (int j = c[i]; j < d[i]; j++){
      cnt[j]++;
    }
  }
  int ans = N + 1;
  for (int i = 0; i <= N; i++){
    if (cnt[i] > 0){
      ans += 2;
    }
  }
  cout << ans << endl;
}


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

int main() {
	int H,W;
	cin>>H>>W;
	
	
	for(int i=-1; i<=H; i++){
		for(int j=-1; j<=W; j++){
			if(i==-1 || i==H || j==-1 || j==W){
				cout<<'#';
			}
			else{
				char c;
				cin >> c;
				cout << c;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int M, Nmin, Nmax;
  while (cin >> M >> Nmin >> Nmax && M) {
    vector<int> P(M);
    REP(i, M) { cin >> P[i]; }
    int ans = 0, gap_max = 0;
    for (int i = Nmin; i <= Nmax; ++i) {
      int gap = P[i - 1] - P[i];
      if (gap >= gap_max) {
        ans = i, gap_max = gap;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2996