akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
K, A = [], []
for _ in range(N):
    ka = list(map(int, input().split()))
    k = ka.pop(0)
    K.append(k)
    A.append(ka)

count = [0] * M
for i in range(N):
    for j in range(len(A[i])):
        count[A[i][j]-1] += 1
print(len([i for i, x in enumerate(count) if x == N]))


Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

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

int main(){
    string s;
    cin >> s;
    int ans[s.size()];
    rep(i, s.size()) ans[i] = 0; 
    int idxl = -1;
    int idxr = -1;
    int nl = 0;
    int nr = 1;
    for(int i = 1; i < s.size(); i++){
        if (s[i] == 'L') {
            if (s[i-1] ==  'R') {
                idxr = i-1;
                idxl = i;
                nl++;
            }else{
                nl++;
            }
            
        }else{
            if (s[i-1] == 'L') {
                ans[idxl] = (nl - nl / 2) + (nr / 2);
                ans[idxr] = (nr - nr / 2) + (nl / 2);
                nl = 0;
                nr = 1;
            }else{
                nr++;
            }
        }
    }
    ans[idxl] = (nl - nl / 2) + (nr / 2);
    ans[idxr] = (nr - nr / 2) + (nl / 2);
    rep(i, s.size()) cout << ans[i] << " ";
    cout << endl;
}

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

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

    int *b = new int[m];
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    vector< vector<int> > a;
    a.resize(n);
    for(int i=0;i<n;i++){
        a[i].resize(m);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        int sum=c;
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
        }
        if(sum>0){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, sum, a[105];
int main() {
	cin >> n;
	cin >> a[1];
	for (int i = 2; i <= n; i ++) {
		cin >> a[i];
		if (a[i - 1] == a[i]) {
			sum ++;
			a[i] = -1;
		}
	}
	cout << sum;
	return 0;
}


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

using namespace std;

int main() {
	long long int N, K;
	cin >> N >> K;

	long long int ans = 0;
	for (size_t i = K + 1; i <= N; i++)
	{
		if (K == 0)
		{
			ans += N;
			continue;
		}
		long long int b = i;
		long long int a = (b - K)*(N / b) + max((long long int)0, (N%b - K + 1));
		ans += a;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
Long = list(map(int,input().split()))

sorted_Long = sorted(Long)

count = 0

for i in range(0,N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if sorted_Long[i] + sorted_Long[j] > sorted_Long[k]:
                if sorted_Long[i] != sorted_Long[j] and sorted_Long[j] != sorted_Long[k]:
                    # print(sorted_Long[i] , sorted_Long[j], sorted_Long[k])
                    count += 1

print(count)


Measured memory_bytes: 9136
x, n = map(int, input().split())
p = list(map(int,input().split()))
if x not in p:
    y = x
else:
    i = 1
    y = x
    while y == x:
        if x - i not in p:
            y = x - i
        elif x + i not in p:
            y = x + i
        i += 1
print(y)

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a;i<n;i++)
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}


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

int findSumOfDegits(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    for (int i = 0; i <= N; i++)
    {
        int sum = findSumOfDegits(i);
        if (A <= sum and sum <= B)
            ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy


def main():
    N = int(input())
    a = list(map(int, input().split()))

    ans = 0
    for i, e in enumerate(a):
        if (i + 1) % 2 == 1 and e % 2 == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

//1834

int main(){
    int N;
  	double T,A,H,num=0,temp=10000;
    cin>>N>>T>>A;
    for(int k=0;k<N;k++){
       cin>>H;
       if(temp>abs(A-(T-H*0.006))) {temp=abs(A-(T-H*0.006));num=k+1;}
    }
	cout<<num<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n, k; cin>>n>>k;
    int ans = 0;
    int sum = 0;
    for(int i=0; i<n; i++){
        int cur = 1;
        bool valid = false;
        while(i < n){
            if((sum + (cur - 1)) / cur <= k){
                valid = true;
                break;
            }
            cur++;
            i++;
        }

        sum += cur;

        if(valid){
            ans++;
        }
    }

    cout << ans << endl;
}


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

int main(){
  long long N;
  cin >> N;
  long long ans = 0;
  for(int i=1; i<=N; i++){
    if(i%3==0 || i%5==0)continue;
    // if(i%3==0)continue;
    // if(i%5==0)continue;
    ans+=i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;

int main(){
    int n, k;
    vector<int> a;
    cin >> n;
    
    double avg = 0;
    
    int i = 0;
    
    for(i = 0; i < n; i++){
        cin >> k;
        a.push_back(k);
        avg += k;
    }
    
    avg /= n;
    
    double d = 114514;
    
    for(i = 0; i < n; i++){
        if(d > abs(avg - a[i])){
            d = abs(avg - a[i]);
        }
    }
    
    for(i = 0; i < n; i++){
        if(a[i] == avg - d || a[i] == avg + d){
            cout << i << endl;
            break;
        }
    }
    
}


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

int main(){
	int n, i;
	int a[100];
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	for(i = n-1; i >= 0; i--){
		if(i != n-1){
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	
	return 0;	
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int a, b, c, d;
  if(scanf("%d %d %d %d", &a, &b, &c, &d)==1);
  printf("%s\n",(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d)?"Yes":"No");
  return 0;
}

Measured memory_bytes: 128
xyh=[]
n=gets.to_i
n.times{if (s=gets.split.map(&:to_i))[2]!=0 then xyh << s end}
if xyh.size==1 then puts xyh.join(" ");exit end
101.times do |x|
  101.times do |y|
    h=xyh[0][2]+(x-xyh[0][0]).abs+(y-xyh[0][1]).abs
    1.upto(xyh.size-1) do |i|
      if h-(x-xyh[i][0]).abs-(y-xyh[i][1]).abs!=xyh[i][2]
        break
      elsif i==xyh.size-1
        puts [x,y,h].join(" ")
        exit
      end
    end
  end
end


Measured memory_bytes: 1788
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  string s;
  cin >> s;
  int n = len(s);
  vector<string> xd = {"eraser", "erase", "dreamer", "dream"};
  for (auto t: xd){
    int m = len(t);
    forn(i,n-m+1){
      bool ok = 1;
      forn(j,m){
        if(s[i+j] != t[j]) ok = 0;
      }
      if (ok){
        forn(j,m){
          s[i+j] = '.';
        }
      }
    }
  }
  


  int cnt = 0;
  forn(i,n) cnt += s[i] == '.';
  debug() << imie(s);
  if (cnt == n){
    cout << "YES";
  } else{
    cout << "NO";
  }
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
1000000000000000000


*/

Measured memory_bytes: 3748
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

int main() {
	ll n, a[100005], y1 = 0, y2 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll s = 0;
	for (int i = 0; i < n; i++) {
		s += a[i];
		if (i % 2 == 0) {
			if (s <= 0) {
				y1 += abs(s) + 1;
				s = 1;
			}
		}
		else {
			if (s >= 0) {
				y1 += s + 1;
				s = -1;
			}
		}
	}
	s = 0;
	for (int i = 0; i < n; i++) {
		s += a[i];
		if (i % 2 == 0) {
			if (s >= 0) {
				y2 += s + 1;
				s = -1;
			}
		}
		else {
			if (s <= 0) {
				y2 += abs(s) + 1;
				s = 1;
			}
		}
	}
	cout << min(y1, y2) << endl;
	return 0;
}

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

int N, K;
string S;

int main() {
    cin >> N >> K >> S;
    
    vector<int> cnt;
    int c = 0;
    for (int i = 0; i < N; i++) {
        if (i < N-1 && S[i] == S[i+1]) {
            c++;
        }
        else {
            c++;
            cnt.push_back(c);
            c = 0;
        }
    }

    if (K >= cnt.size()/2) {
        cout << N-1 << endl;
    }
    else {
        int ans = 0;
        for (int i = 0; i < cnt.size(); i++) {
            ans += (cnt[i] - 1);
        }

        cout << ans + 2*K  << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1020
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split() |> Array.map int

let rec resolver s i =
    if i = N then N - s + 1
    elif A.[i] = s then resolver (s + 1) (i + 1)
    else resolver s (i + 1)

if not (A |> Array.contains 1) then -1
else resolver 1 0
|> stdout.Write


Measured memory_bytes: 36316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    std::string s;
    std::cin >> s;

    int n0=0, n1=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0') n0++;
        if(s[i]=='1') n1++;
    }

    std::cout << s.size()-abs(n1-n0) << "\n";
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> b[i];
    }
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        arr[i] = i + 1;
    }
    int ac = 0, bc = 0;
    if(arr == a) ac = 1;
    if(arr == b) bc = 1;
    for(int i = 2; i <= 1000000; ++i){
        next_permutation(all(arr));
        if(arr == a && ac == 0) ac = i;
        if(arr == b && bc == 0) bc = i;
    }
    cout << abs(ac - bc);
}


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

using namespace std;

#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int N, W, v[100];
	llong w[100];
	vector<llong> dp(100001, inf);
	dp[0] = 0;

	cin >> N >> W;
	for(int i = 0; i < N; i++)
		cin >> w[i] >> v[i];
	for(int i = 0; i < N; i++)
		for(int j = 100000; j >= v[i]; j--)
			dp[j] = min(dp[j], dp[j-v[i]] + w[i]);

	for(int i = 100000; i >= 0; i--)
		if(dp[i] <= W){
			cout << i << endl;
			break;
		}

	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define INF 1000000001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;

  for (int i = 0; i < n; i++) {
    if (a[i] == i + 1) {
      ans++;
    }
  }
  if (ans == 0) {
    cout << ans << endl;
    return 0;
  }

  vector<int> ren;
  // cerr << ren.size() << endl;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == i + 1 && a[i + 1] == i + 2) {
      cnt++;
    } else {
      if (cnt != 1) {
        ren.push_back(cnt);
        cnt = 1;
      }
    }
  }
  for (int i = 0; i < ren.size(); i++) {
    ans -= ren[i] / 2;
  }

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

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;


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

   char a;
   rep(i,n.size()){
       a = n[i];
   }

   if (a == '3'){
       cout << "bon" << endl;
   }
   else if (a == '0' || a == '1' || a == '6' || a == '8'){
       cout << "pon" << endl;
   }
   else{
       cout << "hon" << endl;
   }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int N; // 頂点数
const int MAX_N = 300;
const int INFC = 1000000000;
vector<vector<int>> d(MAX_N, vector<int>(MAX_N, INFC));
  // d[u][v]...辺e=(u,v)のコスト。存在しない場合はINF, 但しd[i][i]=0とする

void warshall_floyd() {
  rep(i, N) d[i][i] = 0;
  for (int k=0; k<N; k++) for (int i=0; i<N; i++) for (int j=0; j<N; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

vector<int> r;
int res = INFC;

int main() {
  int M; cin >>N >>M;
  int R; cin >>R;
  r.assign(R, 0);
  rep(i, R) cin >>r.at(i);
  rep(i, R) r.at(i)--;
  rep(i, M){
    int a,b,t; cin >>a >>b >>t; a--; b--;
    d[a][b] = t; d[b][a] = t;
  }
  warshall_floyd();
  vector<int> a(R); rep(i, R) a[i] = i;
  sort(all(a));
  do {
    int ans = 0;
    for (int i=0; i<R-1; i++){
      int v = r[a[i]], nv = r[a[i+1]];
      ans += d[v][nv];
    }
    res = min(res, ans);
  } while (next_permutation(all(a)));

  cout <<res <<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  int n,k; cin>>n>>k;
 /* double rate,ans=0;
  vec r(n);
  rep(i,n)cin>>r[i];
  
  sort(r.begin(),r.end());
  
  rep(i,k){
    ans=(ans+r[n-k+i])/2;
  }

  //cout<<fixed<<setprecision(10);
  */
  cout<<n*k<<endl;
}


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

int N;
string S;

bool judge(int s, int g){
    if(g == s || g == s+1 || g == s+2) return true;
    else if(s+2<N && S[s+2]!='#') return judge(s+2, g);
    else if(s+1<N && S[s+1]!='#') return judge(s+1, g);

    return false;
}

int main(){
    int A, B, C, D;
    cin >> N >> A >> B >> C >> D >> S;
    A--;  B--;  C--;  D--;
    if(C<D){
        if(judge(A, C) && judge(B, D)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        vector<int> openArea;
        for(int i=B-1; i<D; i++){
            if(S[i]=='.' && S[i+1]=='.' && S[i+2]=='.'){
                openArea.push_back(i);
            }
        }
        for(int i:openArea){
            if(judge(B, i+1) && judge(A, i) && judge(i+1, D) && judge(i, C)){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}



Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int A, B, C, D;

  std::cin >> A >> B >> C >> D;

  if (B < C || D < A) {
    std::cout << 0 << std::endl;
  }
  else {
    std::cout << std::min(B, D) - std::max(A, C) << std::endl;
  }

  return 0;
}


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

using ll=long long; 

void solve(){
	int h,w;
	cin>>h>>w;
	vector<string> fld(h);
	for(auto& e:fld)cin>>e;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			int cnt=0;
			if(fld[i][j]=='.'){
				for(int ii=-1; ii<2; ii++){
					for(int jj=-1; jj<2; jj++){
						int x=i+ii,y=j+jj;
						if(x<h&&x>=0&&y<w&&y>=0){
							cnt+=fld[x][y]=='#';
						}
					}
				}
				fld[i][j]=char(cnt+48);
			}
			
		}
	}
	for(auto& e:fld)cout<<e<<endl;
}	

signed main(){
	//while(1)
	solve();
}

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

int main() {
  int N, K;
  int count = 0;
  
  cin >> N >> K;
  
  vector<int> h(N);
  
  for(int i = 0;i < N;i++) {
    cin >> h.at(i);
    
  	if(h.at(i) >= K)
      count++;
	else
      ;
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------


int main(){
  long long int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  int ans = 0;
  int x=0;
  while(x<n){
    if(x==0){
      x += k;
      ++ans;
    }else{
      x += (k-1);
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const double r = 1.08;
int n;
int solve(int n){
    for(int i=1;i<=n;++i){
        //printf("%d\n",(int)(i*r));
        if(((int)(i*r))==n) return i;
    }
    return -1;
}
int main(){
    scanf("%d",&n);
    n=solve(n);
    if(n==-1) printf(":(\n");
    else printf("%d\n",n);
} 

Measured memory_bytes: 256
import sys
import statistics

input = sys.stdin.readline

def main():
    while True:
        n = int(input().rstrip())
        if n == 0:
            sys.exit()
        s = list(map(int, input().rstrip().split()))
        print(statistics.pstdev(s))
        
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 7072
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll n;
ll a[114514];
signed main() {
	ll ans = 0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	ggr
}

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

int main()
{
    int N;
    int ans = 0;
    cin >> N;
    int c = N;
    while (N)
    {
        ans += N % 10;
        N /= 10;
    }
    if (c % ans)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    long double a, b;
    cin >> a >> b;

    cout << (ll)(a * b) << endl;
}


Measured memory_bytes: 3732
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()

if a == 0:
    print(b)
    quit()

def cal(a,c):
    block_count = a // (c*2)
    tmp = a % (c*2)
    if tmp < c:
        tmp = 0
    else:
        tmp -= c-1
    return block_count * c + tmp
res = 0
ln = len(bin(b)) - 2 #2進数に直した時の桁数
for i in range(ln):
    c = pow(2,i)
    if (cal(b,c) - cal(a-1,c)) % 2:
        res += c
    # print(cal(a,c),cal(b,c))

print(res)

Measured memory_bytes: 64492
n = gets.to_i
s = gets.chomp
t = gets.chomp

str = Array.new(n+1)

for i in 0..n
  str[i] = s + t.slice(-i, i)
end

for i in 0..n
  if str[i].slice(-n, n) == t
    puts str[i].size()
    exit
  end
end



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

int main() {

  int n;
  cin >> n;

  vector<long long> a(87);
  a.at(0) = 2;
  a.at(1) = 1;

  for(int i=2; i<87; i++)
    a.at(i) = a.at(i-1) + a.at(i-2);
    
  cout << a.at(n) << endl;

}


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

ll f(ll n) {
  if (n == 0) return 0;
  ll res = 0;
  return n/5 + f(n/5);
}

int main() {
    ll n;
    cin >> n;
    if (n%2!=0) {
      cout << 0 << endl;
      return 0;
    }
    ll ans = f(n/2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mx  100001
#define ll long long
#define pb push_back

int main(){
    int ans=INT_MAX;
    string s,t;
    cin>>s>>t;
    int lenS=s.size();
    int lenT=t.size();
    for(int i=0; i<lenS-lenT+1; i++){
        int cnt=0;
        for(int j=0; j<lenT; j++){
            if(s[i+j]!=t[j])cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define all(X) X.begin(),X.end()
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int ans,D,M;
int main()
{
    go;
    cin>>M>>D;
    for(int i=22;i<=D;i++)
    {
        int x=i%10;
        int y=(i/10)%10;
        if(x<2||y<2) continue;
        ans+=(x*y<=M&&x*y>=1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, L, N * 2);
  sort(all(L));
  int ans = 0;
  rep(i, 0, N * 2) {
    ans += min(L[i], L[i + 1]);
    i++;
  }
  print(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

struct Node{
	Node(){
		left_child = right_child = parent = -1;
	};
	int left_child,right_child,parent;
};

void preORDER(Node order[],int id){
	printf(" %d",id);
	if(order[id].left_child != -1) preORDER(order,order[id].left_child );
	if(order[id].right_child != -1) preORDER(order,order[id].right_child );
}

void inORDER(Node order[],int id){
	if(order[id].left_child != -1) inORDER(order,order[id].left_child );
	printf(" %d",id);
	if(order[id].right_child != -1) inORDER(order,order[id].right_child );
}

void postORDER(Node order[],int id){
	if(order[id].left_child != -1) postORDER(order,order[id].left_child );
	if(order[id].right_child != -1) postORDER(order,order[id].right_child );
	printf(" %d",id);
}

int main(){
	int n,id,left,right,root_id;
	scanf("%d",&n);
	Node order[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left,&right);
		if(left != -1){
			order[id].left_child = left;
			order[left].parent = id;
		}
		if(right != -1){
			order[id].right_child = right;
			order[right].parent = id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(order[root_id].parent == -1) break;
	}

	printf("Preorder\n");
	preORDER(order,root_id);
	printf("\n");

	printf("Inorder\n");
	inORDER(order,root_id);
	printf("\n");

	printf("Postorder\n");
	postORDER(order,root_id);
	printf("\n");
}



Measured memory_bytes: 2764
lambda {
  n = readline.to_i
  s = readlines.map(&:to_i).sort
  total = s.inject(&:+)
  if total % 10 != 0
    puts total
    return
  end

  s.select!{|t| t % 10 != 0}
  if s.empty?
    puts 0
  else
    puts total - s.first
  end
}.call



Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{

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

		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;

			int number = n - 1;

			for (int k = n + 1; k <= (2 * n) - 1; k++) {
				for (int d = 2; d <= Math.sqrt(k); d++) {
					if (k % d == 0) {
						number--;
						break;
					}
				}

			}
			if (n == 1)
				number = 1;
			System.out.println(number);
		}

	}

}


Measured memory_bytes: 27544
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        
        
        void solve()
        {
        	int n;
        	cin>>n;
        	double d;
        	cin>>d;
        	int cnt=0;
        	loop(i,n)
        	{
        		double x,y;
        		cin>>x>>y;
        		
        		double ans=sqrt(x*x+y*y);
        		if(ans<=d)
        		cnt++;
			}
			cout<<cnt;
		}
        signed main()
        {
        	solve();
		}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int X,Y,Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y << endl;

}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = [int(input()) for _ in range(N)]
    total = sum(S)
    if total % 10 != 0:
        print(total)
        exit()
    for s in sorted(S):
        if s % 10 != 0:
            print(total - s)
            exit()
    print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62436
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;


int main(){
	ll n;
	cin >> n;
	ll x[10000];

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

	sort(x, x+n);
	
	int count = 0;
	for (int i = n - 1; i >= 2; i--){
		for (int k = i - 1; k >= 1; k--){
			for (int j = k-1; j >= 0; j--){
				if (x[k] + x[j]>x[i]) {
					count++;
				}
				else break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

namespace ABC138
{
	class Program
	{
		static void Main(string[] args)
		{

			string s;
			int a ;
			a = int.Parse(Console.ReadLine());
			s = Console.ReadLine();
				
			
			if (a >= 3200)
				Console.WriteLine(s);
			else if (a < 3200)
				Console.WriteLine("red");
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, x; cin >> N >> x;
    vector<ll> A(N);
    REP(i, 0, N) cin >> A[i];

    ll ans = 0;
    REP(i, 0, N - 1) {
        ll diff = (A[i] + A[i + 1]) - x;
        if (diff < 1) continue;

        ll d1 = min(diff, A[i + 1]);
        diff -= d1;
        ll d2 = min(diff, A[i]);
        A[i + 1] -= d1;
        A[i] -= d2;
        ans += d1 + d2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None

class BST:
    def __init__(self):
        self.root = None
    def insert(self, key):
        x = self.root
        y = None
        z = Node(key)
        while x != None:
            y = x
            x = x.left if z.key < x.key else x.right
        if y == None: self.root = z
        else:
            if z.key < y.key: y.left = z
            else: y.right = z
    def print_tree(self):
        def inorder(node):
            if node:
                inorder(node.left)
                print('',node.key, end='')
                inorder(node.right)
        def preorder(node):
            if node:
                print('',node.key, end='')
                preorder(node.left)
                preorder(node.right)
        inorder(self.root)
        print()
        preorder(self.root)
        print()

tree = BST()
for e in [0]*int(input()):
    e = input()
    if e[0] == 'i': tree.insert(int(e[7:]))
    else:
        tree.print_tree()


Measured memory_bytes: 57900
#include <stdio.h>
int main ()
{
	int A,B,C;
	scanf ("%d%d%d",&A,&B,&C);
	if (A==5&&B==5&&C==7 || A==7&&B==5&&C==5 || A==5&&B==7&&C==5){
		printf ("YES");
	}else{

		printf ("NO");
	}

	return 0 ;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

using LD = long double;

LD mypow(LD p, LD r){
  LD ans = 1;
  rep(i,r) ans *= p;
  return ans;
}

LD calc(LD p, LD q, LD r){
  LD tmp = mypow((LD)p/(p+q), 2*r); // p^r / (p+q)^r
  LD ans = tmp;

  LD comb = 1;
  rep(i,r){
    comb = comb * (r-i) / (i+1);
    dbg(comb);
    tmp = tmp / p / p * q * q;
    ans += comb * tmp;
  }
  return (1.0 + ans) / 2.0;
}

int main(){
  LD m,n,x;
  LD k,l,y;
  scanf("%Lf %Lf %Lf %Lf %Lf %Lf", &m, &n, &x, &k, &l, &y);

  printf("%.7Lf\n", calc(m,n,x) * calc(k,l,y));

  return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N, K; cin >> N >> K;
    vector<int> x(N);
    rep(i, 0, N) cin >> x[i];
    int ans = 0;
    rep(i, 0, N){
        ans += 2 * min(x[i], K - x[i]);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int n,x;
  cin >> n;
  int a[n],c[n-1];
  int sum = 0;
  for(int i = 0 ;i < n;i++)cin >> a[i];
  for(int i = 0;i < n;i++){
    cin >> x;
    sum += x;
  }
  for(int i = 0; i < n-1 ;i++)cin>>c[i];
  int pre = a[0];
  for(int i = 1;i<n;i++){
    if(pre+1==a[i])sum += c[pre-1];
    pre = a[i];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for (int i = 0; i < k; i++) cin >> a[i];
	for (int i = k; i < n; i++){
		cin >> a[i];
		if (a[i] > a[i - k]) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 5192
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

def main():
    N = ir()
    A = lr()
    A.sort()
    if N == 1:
        print(1)
        exit()
    MOD = 10 ** 9 + 7
    l = []
    first = A[0]
    l = [x//gcd(x, first) for x in A[1:]]
    x = lcm(l) #B[0]
    answer = x%MOD

    for i in range(1, N):
        answer += first * x // A[i]

    print(answer%MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4208
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	unordered_map<int, int> mp;
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
		mp[A[i]]++;
	}

	sort(all(A));

	int ans = 0;

	rrep(i, 0, N) {
		int k = 0;
		int x = A[i];
		while (x) {
			k++;
			x /= 2;
		}
		int p = (1 << k) - A[i];

		int add;
		if (A[i] == p) {
			add = min(mp[A[i]], mp[p]) / 2;
			mp[A[i]] -= add * 2;
		}
		else {
			add = min(mp[A[i]], mp[p]);
			mp[A[i]] -= add;
			mp[p] -= add;
		}
		ans += add;
		dump(A[i], add);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17652
#include<stdio.h>

int main(){
  int a,b,c = 0,d = 0;
  scanf("%d %d",&a,&b);
  if(a >= 0&&b <= 100){
    c = a * b;
    d = (2 * a) + (2 * b);
    printf("%d %d\n",c,d);
  }
  return 0;
}

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

int main(){
    int n;
    int a[200];
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    
    for(int i = n-1; i >= 0; i--){
        cout << a[i];
        if(i != 0){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    double N, D;
    cin >> N >> D;
    int count = 0;
    for (int i=0; i<N; i++) {
        double x, y;
        cin >> x >> y;
        if (D >= sqrt(pow(x, 2.0) + pow(y, 2.0))) {
            count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll, ll> P;

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

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

#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>

ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return abs(a); }

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

ll ceil(ll a, ll b) {
	if (a % b == 0) {
		return a / b;
	}
	return a / b + 1;
}

int main() {
	ll n;
	cin >> n;
	ll left = 1, right = 1;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		ll next = max(ceil(left,x), ceil(right,y));
		left = next * x;
		right = next * y;
	}
	cout << left+right << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################

int main() {
int  x=D(),a=D(),b=D();
int A=abs(a-x);
int B=abs(b-x);


if(A<B){
cout<<"A";
}else
cout<<"B";


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=2010;
int n;
struct da{int v,id;}q[maxn];
long long dp[maxn][maxn];
inline bool cmp(da aa,da bb){return aa.v>bb.v;}
long long dfs(int l,int r)
{
	if (dp[l][r]!=-1) return dp[l][r];
	if (l>r) return 0;
	da now=q[l+n-r];
	dp[l][r]=max(dp[l][r],dfs(l,r-1)+1ll*now.v*abs(r-now.id));
	dp[l][r]=max(dp[l][r],dfs(l+1,r)+1ll*now.v*abs(l-now.id));
return dp[l][r];
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&q[i].v),q[i].id=i;
	sort(q+1,q+n+1,cmp);
	memset(dp,-1,sizeof dp);
	printf("%lld\n",dfs(1,n));
return 0;
}

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

int N,M;
int main(){
	map<string,int> m;
	cin >> N;
	for(int i=0;i<N;i++){
		string S;
		cin >> S;
		m[S]++;
	}
	cin >> M;
	for(int i=0;i<M;i++){
		string S;
		cin >> S;
		m[S]--;
	}
	int ans = 0;
	for(auto i = m.begin();i!=m.end();i++){
		int a = i->second;
		if(ans<a) ans = a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(calc(a-1) ^ calc(b))
}

func calc(n int) int {
	if n%4 == 0 {
		return n
	} else if n%4 == 1 {
		return 1
	} else if n%4 == 2 {
		return 1 ^ n
	} else {
		return 0
	}
}


Measured memory_bytes: 512