akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
// #include <numbers>
using namespace std;

int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double pi = acos(-1);
    double alpha = m * pi / 30, beta = pi * h / 6 + m * pi / 360;
    cout << std::fixed << std::setprecision(15) << sqrt(a * a + b * b - 2 * a * b * cos(alpha - beta)) << endl;
    // cout <<  << endl;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    int ls=s.length();
    int ans=0;
    for (int i=1;i<ls;i++){
        if (s[i]==s[i-1]){
            if (s[i-1]=='0')
                s[i]='1';
            else
                s[i]='0';
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }

    public static int Gcd(int a, int b)
    {
	if (a < b){ return Gcd(b, a); }
	while (b != 0)
	{
	    var r = a % b;
	    a = b;
	    b = r;
	}
	return a;
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], k = tmp[1];
	int[] a = ReadIntArray();

	bool ans = true;
	
	if (n == 1)
	{
	    ans = (a[0] == k);
	}
	else
	{
	    int g = Gcd(a[0], a[1]);
	    int m = Math.Max(a[0], a[1]);
	    for (int i = 2; i < n; i++)
	    {
		g = Gcd(g, a[i]);
		m = Math.Max(m, a[i]);
	    }

	    ans = (k <= m) && (k%g == 0);
	}

	WriteLine(ans ? "POSSIBLE" : "IMPOSSIBLE");
    }
}


Measured memory_bytes: 20960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; ++i){
        ans += i * (n + 1 - i) + 1;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;
ll ma=1000000007;
ll power(ll p,ll t){
if(t==0)
    return 1;
ll y=power(p,t/2);
y=(y*y)%ma;
if(t%2==1)
    y=(y*p)%ma;
return y;
}


int mod(int a){
if(a>=0)
    return a;
else return -a;
}



 int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll x=b-a+1;
ll y,z,p;
if(a%c==0){
    y=b/c-a/c+1;
}
else{
    y=b/c-a/c;
}
if(a%d==0){
    z=b/d-a/d+1;
}
else z=b/d-a/d;
ll f=(c*d)/__gcd(c,d);
if(a%f==0){

    p=b/f-a/f+1;
}
else p=b/f-a/f;


cout<<(x-(y+z-p))<<endl;


}











Measured memory_bytes: 256
a, b = map(int, input().split())
if a % 2 == 0:
  if b % 2 == 0:
    if (b-a)//2%2 == 0:
      print(b)
    else:
      print(b^1)
  else:
    if (b-a+1)//2%2 == 0:
      print(0)
    else:
      print(1)
else:
  if b % 2 == 0:
    if (b-1-a)//2%2 == 0:
      print(a^b)
    else:
      print(a^b^1)
  else:
    if (b-a)//2%2 == 0:
      print(a)
    else:
      print(a^1)  
    

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

int main(){
  string n;
  cin >> n;
  int ans=0;
  for(int i=0;i<(int)n.size();i++){
    char a=n.at(i);
    int x=a-'0';
    ans+=x;
  }
  if(ans%9==0){
    cout << "Yes" << endl;
  }else{
   cout << "No" << endl;
  } 
}

Measured memory_bytes: 3704
#include "bits/stdc++.h"
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    vector<int> alpha1(26), alpha2(26);
    for (int i = 0; i < S.size(); i++) {
        alpha1[S[i] - 'a']++;
        alpha2[T[i] - 'a']++;
    }

    bool flag = true;
    sort(alpha1.begin(), alpha1.end());
    sort(alpha2.begin(), alpha2.end());
    for (int i = 0; i < 26; i++) {
        if (alpha1[i] != alpha2[i]) flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 776
n = int(input())
v = list(map(int, input().split()))

odd = {}
even = {}

for i in range(len(v)):
    if i % 2 == 1:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1
    else:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1

#ソートして一番目、二番目を見る
odd_sorted  = sorted(odd.items(), key = lambda x : -x[1])
even_sorted  = sorted(even.items(), key = lambda x : -x[1])




#候補が同じ場合
if odd_sorted[0][0] == even_sorted[0][0]:
    #奇数も偶数も2番目が存在する？
    if len(odd.keys()) > 1 and len(even.keys()) > 1:
        #数が大きい方を採用
        if odd_sorted[0][1] > even_sorted[0][1]:
            ans_odd = odd_sorted[0][0]
            ans_even = even_sorted[1][0]
        elif odd_sorted[0][1] < even_sorted[0][1]:
            ans_odd = odd_sorted[1][0]
            ans_even = even_sorted[0][0]
        else:
            #両者が一致した場合
            if odd_sorted[1][1] >= even_sorted[1][1]:
                ans_odd = odd_sorted[1][0]
                ans_even = even_sorted[0][0]
            elif odd_sorted[1][1] < even_sorted[1][1]:
                ans_odd = odd_sorted[0][0]
                ans_even = even_sorted[1][0]

    #お互いに二番目が存在しない(ただし数は必ず一致するのでどちらか)
    elif len(odd.keys()) == 1 and len(even.keys()) == 1:
        ans_odd = -1
        ans_even = even_sorted[0][0]
    #奇数に2番目が存在しない
    elif len(odd.keys()):
        ans_odd = odd_sorted[0][0]
        ans_even = even_sorted[1][0]
    #偶数に2番目が存在しない
    else: #len(even.keys()):
        ans_odd = odd_sorted[1][0]
        ans_even = even_sorted[0][0]

else:
    ans_odd = odd_sorted[0][0]
    ans_even = even_sorted[0][0]

ans = 0
for i in range(len(v)):
    if i % 2:
        if v[i] != ans_odd:
            ans += 1
    else:
        if v[i] != ans_even:
            ans += 1


print(ans)

Measured memory_bytes: 20720
#include <iostream>
#include <vector>

typedef long long ll;
const ll INF = 1e12;

ll gcd(ll a, ll b)
{
  while (b > 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

ll lcm(ll a, ll b) {
  ll gcd_val = gcd(a, b);
  return a / gcd_val * b;   // over flow 防止のため、割り算を先にする
}

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0);

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    ans += va[i] - 1;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<Int> s;//累積和
Int N;

bool isOK_R(Int x, Int i) {

	if (s[x] - s[i] < s[N] - s[x]) {
		return true;
	}
	else {
		return false;
	}
}

Int binary_search_R(Int i) {
	Int ng = N;
	Int ok = i; 

	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;

		if (isOK_R(mid, i)) ok = mid;
		else ng = mid;
	}
	return ok;
}

bool isOK_L(Int x,Int i) {

	if (s[x]-s[0]<s[i]-s[x]) {
		return true;
	}
	else {
		return false;
	}
}

Int binary_search_L(Int i) {
	Int ng = i; 
	Int ok = 0; 

	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;

		if (isOK_L(mid,i)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N;

	vector<Int> A(N);
	for (Int i = 0; i < N; i++) {
		cin >> A[i];
	}

	s.resize(N + 1);
	for (Int i = 0; i < N; i++) {
		s[i + 1] = s[i] + A[i];
	}

	Int ans = INF;
	Int tempL, tempR;
	Int mx, mn;
	for (Int i = 2; i <= N - 2; i++) {//真ん中の切れ目
		//左半分の最適化
		tempL = binary_search_L(i);
		if (abs(s[tempL] - (s[i] - s[tempL])) > abs(s[tempL + 1] - (s[i] - s[tempL + 1]))) {
			tempL++;
		}

		//右半分の最適化
		tempR = binary_search_R(i);
		if (abs((s[N]-s[tempR]) - (s[tempR] - s[i])) > abs((s[N]-s[tempR+1]) - (s[tempR+1] - s[i]))) {
			tempR++;
		}

		mx = max({ s[tempL],s[i] - s[tempL],s[tempR] - s[i],s[N] - s[tempR] });
		mn = min({ s[tempL],s[i] - s[tempL],s[tempR] - s[i],s[N] - s[tempR] });

		ans = min(ans, mx - mn);

	}

	cout << ans << "\n";

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

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

    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<ll>> v(h, vector<ll>(w, 0));

    rep(i, b) rep(j, a)
    {
        v[i][j]=1;
    }
    repi(i,b,h)repi(j,a,w){
        v[i][j]=1;
    }

    rep(i,h)rep(j,w){
        cout<<v[i][j];
        if(j==w-1)cout<<endl;
    }
}


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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
using ll = long long;
#define pb push_back
int main()
{
  ll A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  ll first_sum = A*X + B*Y;
  ll second   = (max( X,Y) *2) * C;
  ll third;
  if (X > Y) {
    // ll third    = (min(X,Y)*2) * C +  (max(X,Y)-min(X,Y)) * 
    third    = Y*2*C + (X-Y)*1*A;
  } else {
    third    = X*2*C + (Y-X)*1*B;
  }


  //while ( ! ((X<=0) && (Y<=0) )) {
  //  second -= A-C;
  //  X-=1;
  //  second -= B-C;
  //  Y-=1;
  //}
  cout << min(min(first_sum, second), third) << endl;
} 

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

string a, b;

int main(void)
{
	cin >> a >> b;
  
  	int ans = 0;
  	for (int i = 0; i < a.size(); i++)
      	if (a[i] != b[i])
          	++ans;
  
  	cout << ans;
  	return 0;
}


Measured memory_bytes: 3844
import collections
N, M = [int(_) for _ in input().split()]
A = sorted([int(_) for _ in input().split()])
n_m = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
m_n = {}
for a in A:
    m_n[n_m[a]] = a
dp = collections.defaultdict(lambda: -float('inf'))
dp[0] = 0
for i in range(1, N + 1):
    dp[i] = max(dp[i - m] + 1 for m, n in m_n.items())
ans = ''
ms = sorted(m_n.keys(), key=lambda _: m_n[_], reverse=True)
d = dp[N]
while N:
    for m in ms:
        if dp[N - m] == dp[N] - 1:
            N -= m
            ans += str(m_n[m])
            break
print(ans)


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

int n, m;
int edge[11][11];

int isOn(int bitmask, int i)
{
    if ((bitmask & (1 << i)) != 0) {
        return 1;
    }
    return 0;
}

int setBit(int bitmask, int i)
{
    bitmask = (bitmask | (1 << i));
    return bitmask;
}

int go(int u, int bitmask)
{
    if (bitmask == ((1 << n) - 1)) {
        return 1;
    }
    int i, res = 0;
    for (i = 1; i <= n; i++) {
        if (isOn(bitmask, i) == 0 && edge[u][i] == 1) {
            res += go(i, setBit(bitmask, i));
        }
    }
    return res;
}

int main( )
{
    cin >> n >> m;
    while (m--) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edge[u][v] = 1;
        edge[v][u] = 1;
    }
    cout << go(0, 1) << '\n';
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
	fastio();
	string s;cin>>s;
	bool flag=0;
	for(int i=0;i<=2;i++)
	{
		if(s[i]==s[i+1])
			flag=1;
	}
	if(flag==1)
	{
		cout<<"Bad"<<endl;
	}
	else
	{
		cout<<"Good"<<endl;
	}

	return 0;
}	

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;
  cin >> a >> b;
  if(a >= 10 || b >= 10){
    cout << -1 << endl;
    return 0;
  }
  cout << a*b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N;
    cin>>N;
    vector<long> A(N);
    for(int i=0;i<N;i++) cin>>A.at(i);
    
    long M=0-INF,d=-1;
    for(int i=0;i<N;i++){
        if(A.at(i)>M){
            M=A.at(i);
            d=i;
        }
    }
    
    for(int i=0;i<N;i++){
        if(i!=d)cout<<M<<endl;
        else{
            long Q=0-INF;
            for(int j=0;j<N;j++){
                if(j!=d && A.at(j)>Q) Q=A.at(j);
            }
            
            cout<<Q<<endl;
        }
    }
}



Measured memory_bytes: 3200
# https://atcoder.jp/contests/abc063/tasks/arc075_b
# 問題文あなたが散歩していると、突然 N 体の魔物が出現しました。
# それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
# 体力が 0以下となった魔物は直ちに消滅します。
# 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
# 一回の爆発では、以下のように魔物の体力を減らすことができます。
# 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
# 爆発の中心となる魔物の体力は A 減り、
# その他の魔物の体力はそれぞれ B 減る。
# ここで、A と B はあらかじめ定まった値であり、A>B である。
# すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
# 制約入力値はすべて整数である。
# 1≤N≤10^5
# 1≤B<A≤10^9
# 1≤hi≤10^9

# N A B
# h1
# h2
# :
# hN

# 4 5 3
# 8
# 7
# 4
# 2

# 2

# 2 10 4
# 20
# 20

# 4

# 5 2 1
# 900000000
# 900000000
# 1000000000
# 1000000000
# 1000000000

# 800000000

N, A, B = gets.split.map(&:to_i)
H = []
N.times {
  H << gets.to_i
}

A_B = A - B

class Integer
  def able?
    counter = self
    bself = B * self
    b2 = - bself + A_B - 1
    H.each do |value|
      next if value <= bself
      counter -= ((value + b2)/(A_B))
      break if counter < 0
    end
    counter >= 0
  end
end

# T回で倒しきれるか？ を二分探索
# ng = 0, ok = h.max
ng = 0
ok = 1 << 30
mid = 0
while (ok - ng) > 1
  mid = (ng + ok)/2
  if mid.able?
    ok = mid
  else
    ng = mid
  end
end
puts ok

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

int main()
{
    long long n, i, l, cnt = 0;
    string s;
    cin >> s;
    l = s.size();

    for(i=0; i<l; i++){
        if(i%2 == 0 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))
            cnt++;
        else if(i%2 == 1 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))
            cnt++;
    }
    if(l == cnt)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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


int main() {
  
  int n;
  cin>>n;
  
  vector<int> p(n);
for (int i = 0; i < n; i++) {
  cin >> p.at(i);
}
  
  int sw=0;
  
  for (int i = 1; i < n-1; i++) {
    if((p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1))
       ||(p.at(i+1)<p.at(i)&&p.at(i)<p.at(i-1))){
         sw++;
       }
  }

       cout<<sw<<endl;
     
}


 
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for(int i = 0, i##_len = (N); i < i##_len; ++i)
#define REPS(i, N) for(int i = 1, i##_len = (N); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

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

using namespace std;

struct Edge {
  int to, cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};

int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  vector<vector<Edge>> g = vector<vector<Edge>>(N + 1);
  REP(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    g[a[i]].push_back(Edge(b[i], -c[i]));
  }

  vector<ll> d = vector<ll>(N + 1, INF);
  bool neg = false;
  d[1] = 0;
  REP(i, N) {
    REPS(v, N + 1) {
      REP(k, g[v].size()) {
        Edge e = g[v][k];
        if(d[v] != INF && d[v] + e.cost < d[e.to]) {
          d[e.to] = d[v] + e.cost;
          if(i == N - 1 && e.to == N - 1) {
            neg = true;
          }
        }
      }
    }
  }
  if(neg) {
    cout << "inf" << endl;
  } else {
    cout << -d[N] << endl;
  }
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a = (a + d - 1) / d;
    c = (c + b - 1) / b;
    cout << (a < c ? "No" : "Yes") << endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len;
multiset<int> s;

int main(){
	scanf("%d",&len);
	for(int i=1; i<=len; i++){
		int a; scanf(" %d",&a);
		if(s.empty() || *s.begin() >= a) s.insert(a);
		else{
			auto it = --s.lower_bound(a);
			s.erase(it); s.insert(a);
		}
	}
	printf("%d\n",(int)s.size());
}

Measured memory_bytes: 4992
let () =
  let s = read_line () in
  print_endline @@
  if
    Array.fold_left ( && ) true @@
    Array.init (String.length s) @@ fun i ->
      match s.[i], i mod 2 with
      | ('R' | 'U' | 'D'), 0
      | ('L' | 'U' | 'D'), 1 -> true
      | _ -> false 
  then "Yes"
  else "No"


Measured memory_bytes: 384
//
// Projction and Reflection
//
// verified:
//   AOJ Course CGL_1_A: Projection
//   AOJ Course CGL_1_B: Reflection
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

/* Point */
using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acos(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};

inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}

/* Line */
struct Line : vector<Point> {
    Line(Point a = Point(0.0, 0.0), Point b = Point(0.0, 0.0)) {
        this->push_back(a);
        this->push_back(b);
    }
    friend ostream& operator << (ostream &s, const Line &l) {return s << '{' << l[0] << ", " << l[1] << '}';}
};

/* Projection */
Point proj(const Point &p, const Line &l) {
    DD t = dot(p - l[0], l[1] - l[0]) / norm(l[1] - l[0]);
    return l[0] + (l[1] - l[0]) * t;
}
Point refl(const Point &p, const Line &l) {
    return p + (proj(p, l) - p) * 2;
}


int main() {
    DD xp1, yp1, xp2, yp2; cin >> xp1 >> yp1 >> xp2 >> yp2;
    Line l(Point(xp1, yp1), Point(xp2, yp2));
    int Q; cin >> Q;
    for (int qu = 0; qu < Q; ++qu) {
        DD x, y; cin >> x >> y;
        Point p(x, y);
        Point res = proj(p, l);
        cout << fixed << setprecision(10) << res.x << " " << res.y << endl;
    }
}


Measured memory_bytes: 3268
#include <stdio.h>
#define N 100
#define W 100000

int main(void){
    int n,w;
    int wi[N+1], v[N+1];
    static long long int memo[N+1][W+1] = {};
    int i,j;
    
    scanf("%d %d", &n, &w);
    
    for(i = 1; i <= n; i++){
        scanf("%d %d", &wi[i], &v[i]);
    }
    
    for(i = 1; i <= n; i++){
        for(j = 1; j <= w; j++){
            memo[i][j] = memo[i-1][j];
            if(j-wi[i] >= 0){
                if(memo[i][j] < memo[i-1][j-wi[i]] + v[i]){
                    memo[i][j] = memo[i-1][j-wi[i]] + v[i];
                }
            }
            //printf("%d %d %lld\n", i, j, memo[i][j]);
        }
    }
    
    printf("%lld\n", memo[n][w]);
    
    return 0;
}

Measured memory_bytes: 78336
import java.util.Scanner;

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

		if (a % 2 == 0) {
			System.out.println(0.5);
		} else {
			System.out.println((double) ((int) ((a / 2) + 1) / a));
		}

	}
}

Measured memory_bytes: 21844
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    long[] a = new long[n];
    for(int i=0;i<n;i++){
      a[i] = nextLong();
      if(a[i]==0){
        System.out.println("0");
        System.exit(0);
      }
    }

    long ans = 1;

    long limit = (long)Math.pow(10,18);

    for(int i=0;i<n;i++){

      if(ans>limit/a[i]){
        System.out.println("-1");
        System.exit(0);
      }

      ans *= a[i];

      if(ans>limit){
        System.out.println("-1");
        System.exit(0);
      }

      //System.out.println("ans="+ans);

    }

    System.out.println(ans);

    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end(), greater<int>());
    deque<int> res;
    long sum=0;
    for(int i=0;i<N;i++){
        if(res.size() > 0){
            sum += (long)res.front();
            res.pop_front();
        }
        if(i == 0){
            res.push_back(A[i]);
        }else{
            res.push_back(A[i]);
            res.push_back(A[i]);        
        }
    }
    cout << sum << endl;
    return 0;
}



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

// max Rectangle in Histogram

int calc(vector<int> v) {
  int n = v.size();
  vector<int> L(n), R(n);

  // decreasing from top
  stack<int> st;
  for(int i=0; i < n; i++) {
    while(st.size() && v[st.top()] >= v[i]) st.pop();
    /////////
    L[i] = 0;
    if(st.size()) L[i] = st.top()+1;
    if(st.empty() || v[st.top()] != v[i]) st.push(i);
    /////////
  }
  st = stack<int>();
  for(int i=n-1; i >= 0; i--) {
    while(st.size() && v[st.top()] >= v[i]) st.pop();
    /////////
    R[i] = n-1;
    if(st.size()) R[i] = st.top()-1;
    if(st.empty() || v[st.top()] != v[i]) st.push(i);
    /////////
  }
  int res = 0;
  for(int i=0; i < n; i++) {
    res = max(res, v[i] * (R[i] - L[i] + 2));
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int h, w; cin >> h >> w;
  string s, t;

  // count from left, right
  vector< vector<int> > cl(w, vector<int>(h - 1, -1) ), cr(w, vector<int>(h - 1, -1) );

  for(int y=0; y < h; y++) {
    cin >> s;
    if(y != 0) {
      int l, r; l = r = 1;
      cl[0][y-1] = 1;
      cr[0][y-1] = 1;
      for(int x=1; x < w; x++) {
        int cnt = 0;
        for(int i=x-1; i <= x; i++) {
          if(s[i] == '.') cnt++;
          if(t[i] == '.') cnt++;
        }
        if(cnt % 2) l = 1;
        else l++;
        cl[x][y-1] = l;
      }
      for(int x=1; x < w; x++) {
        int cnt = 0;
        for(int i=x-1; i <= x; i++) {
          if(s[w-1-i] == '.') cnt++;
          if(t[w-1-i] == '.') cnt++;
        }
        if(cnt % 2) r = 1;
        else r++;
        cr[x][y-1] = r;
      }
    }
    t = s;
  }
  int ans = max(w, h);
  for(auto el : cl) ans = max(ans, calc(el));
  for(auto el : cr) ans = max(ans, calc(el));
  cout << ans << endl;
}



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

typedef  long long ll;
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;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n;
int main(){
    cin>>n;
    vector<int>value(n);
    rep(i,n)cin>>value.at(i);
    sort(value.begin(),value.end());
    double ans=(value.at(0)+value.at(1))/2.0;
    rep2(i,2,n){
        ans=(value.at(i)+ans)/2.0;
    }
    cout<<setprecision(6);
    cout<<ans<<endl;
    return 0;
}




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

L = []
R = []
for i in range(M):
  a, b = map(int, input().split())
  L.append(a)
  R.append(b)

minmin = max(L)
maxmax = min(R)

ans = maxmax - minmin + 1
if ans < 0:
  ans = 0
print(ans)


Measured memory_bytes: 10996
#include<stdio.h>

typedef struct{
  char suit;
  int num;
}CARD;

int main(){


  int i,j,a,b,n,minj,flag=1;
  CARD A[36],B[36],temp;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %c%d",&A[i].suit,&A[i].num);
    B[i].suit=A[i].suit;
    B[i].num=A[i].num;
  }


  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j].num < A[j-1].num){
	temp.suit=A[j].suit;
	temp.num=A[j].num;
	
	A[j].suit=A[j-1].suit;
	A[j].num=A[j-1].num;
	A[j-1].suit=temp.suit;
	A[j-1].num=temp.num;

      }
    }
  }



  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(B[j].num < B[minj].num){
	minj=j;
      }
    }
    temp.suit=B[i].suit;
    temp.num=B[i].num;
    B[i].suit=B[minj].suit;
    B[i].num=B[minj].num;
    B[minj].suit=temp.suit;
    B[minj].num=temp.num;
  }


  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if((A[i].num==A[j].num)&&(A[i].suit==B[b].suit)&&(A[i].num==B[b].num)&&(A[j].suit==B[a].suit)&&(A[j].num==B[a].num)){
	    flag=0;
	  }
	}
      }
    }
  }


  for(i=0;i<n-1;i++){
    printf("%c%d ",A[i].suit,A[i].num);
  }
  printf("%c%d\n",A[n-1].suit,A[n-1].num);
  printf("Stable\n");

  for(i=0;i<n-1;i++){
    printf("%c%d ",B[i].suit,B[i].num);
  }
  printf("%c%d\n",B[n-1].suit,B[n-1].num);
  if(flag==1){
    printf("Stable\n");
  }
  else printf("Not stable\n");


  return 0;
}



Measured memory_bytes: 2048
_ = input()
num_list = list(map(int, input().split()))
 
count = 0
 
while(True):
  is_even_list = [False if num % 2 else True for num in num_list]
  if False in is_even_list:
    break
  num_list = list(map(lambda num: num / 2, num_list))
  count += 1
 
print(count)

Measured memory_bytes: 9248
n = int(input())
s = 0
lst = []
al = [chr(ord('a') + i) for i in range(26)]

while True:
  if n == 0:
    break
  else:
    b = n%26
    if b == 0:
      b = 26
      n = (n-26)//26
    else:
      n = n//26
    
    lst.append(al[b-1])

lst.reverse()
x = ''.join(lst)
print(x) 
    

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int64_t ans = 0;
    static int64_t dp[3001];
    for(int i=0; i<N; i++){
        for(int j=3000; j>A[i]; j--) add(dp[j], dp[j-A[i]]);
        add(dp[A[i]], i+1);
        add(ans, dp[S]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n;

int main(void) {
    int i, x;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; ++i) {
        x = i;
        
        if (x % 3 == 0) {
            printf(" %d", i);
            continue;
        }
        
        do {
            if (x % 10 == 3) {
                printf(" %d", i);
                break;
            }
        } while (x /= 10);
    }
    
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin >> n >> k;
    
    int zero_max = min(n-1, k);
    
    
    auto quick_pow= [](ll a, ll b) {
        ll res = 1;
        a %= mod;
        while (b) {
            if (b & 1) res = res * a % mod;
            a = a * a % mod;
            b >>= 1;
        }
        return res;
    };

    vector<int> fac(n+1), finv(n+1);
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= n; ++i)fac[i]=(ll)fac[i-1]*i%mod;
    finv[n] = quick_pow(fac[n], mod-2);
    for(int i = n-1; i; --i)finv[i] = (ll)finv[i+1]*(i+1)%mod;


    auto comb= [&](int n, int m){
        //n!/(m!(n-m)!)
        return (ll)fac[n] * finv[m] % mod * finv[n - m]% mod;
    };

    
    modular ans = 0;
    for (int i = 0; i <= zero_max; i++){
        ans += (modular)comb(n, i) * comb(n-1, i);
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




typedef long long ll;
#define INF INT_MAX/2
string S; int N;
unordered_map<ll, int> dp;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S; N = S.length();

    ll x = 0;
    dp[0] = 0;
    int ans = 0;
    rep(i, 0, N) {
        x ^= 1LL << (S[i] - 'a');
        
        int ma = INF;
        if (!dp.count(x)) dp[x] = INF;
        ma = min(ma, dp[x]);

        rep(i, 0, 26) {
            ll xx = x ^ (1LL << i);
            if (!dp.count(xx)) dp[xx] = INF;
            ma = min(ma, dp[xx]);
        }

        dp[x] = min(dp[x], ma + 1);
        ans = ma + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 170348
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<pair<int,int>> balls(n);

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

        balls[i] = make_pair(x, y);
    }

    vector<vector<pair<int,int>>> dist(n, vector<pair<int,int>>(n));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            dist[i][j].first = balls[i].first - balls[j].first;
            dist[i][j].second = balls[i].second - balls[j].second;
            // cout << dist[i][j].first << " " << dist[i][j].second << endl;
        }
    }

    map<pair<int,int>,int> mp;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            mp[dist[i][j]]++;
        }
    }

    int maxi = 0;
    for(auto i : mp){
        maxi = max(maxi, i.second);
    }

    cout << n - maxi << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int D, N;
	
	scanf("%d %d", &D, &N);
	
	if(D == 0){
		if(N >= 100)
			printf("%d", 101);
		else
			printf("%d", N);
	}
	else if(D == 1){
		if(N >= 100)
			printf("%d", 10100);
		else
			printf("%d", N*100);
	}
	else if(D == 2){
		if(N >= 100)
			printf("%d", 1010000);
		else
			printf("%d", N*10000);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,M;
  map<string,int> mp;
  string tmp;
  cin >> N;
  rep(i,N){
    cin >> tmp;
    mp[tmp]++;
  }
  cin >> M;
  rep(i,M){
    cin >> tmp;
    mp[tmp]--;
  }
  int ans = 0;
  for(auto m:mp){
    ans = max(ans,m.second);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	vector<ll> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	int dif = 2 * a[2] - a[1] - a[0];
	if (dif % 2 == 0)cout << dif / 2 << endl;
	else {
		cout << dif / 2 + 2 << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
	int i,j=0;
	char str[20],t[20];

	scanf("%s",str);

	for(i=0;str[i]!='\0';i++)
	{
      j=i;
	}
	for(i=0;i<j;i++)
	{
		t[i]=str[i];
		str[i]=str[j];
		str[j]=t[i];
		j-=1;
	}
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 944
def main():
    H, W = [int(s) for s in input().split()]
    sh, sw = [int(s) -1 for s in input().split()]
    gh, gw = [int(s) -1 for s in input().split()]
    maze = []
    for i in range(H):
        maze.append(input())
    queue = [(sh, sw)]
    skip = 0
    seen = {(sh, sw)}
    nqs = set()
    while queue:
        nq = []
        while queue:
            x, y = queue.pop()
            if x == gh and gw == y:
                print(skip)
                return
            for i,j in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                if 0 <= i+x < H and 0 <= j+y < W:
                    ns = (i+x, j+y)
                    if maze[i+x][j+y] == '.':
                        if ns in seen:
                            continue
                        seen.add(ns)
                        queue.append(ns)
            ns = (x,y)
            if ns not in nqs:
                nqs.add(ns)
                nq.append(ns)

        skip += 1
        queue = []
        for x, y in nq:
            for i in range(-2, 3):
                for j in range(-2, 3):
                    if 0 <= i+x < H and 0 <= j+y < W:
                        if maze[i+x][j+y] == '.':
                            ns = (i+x, j+y)
                            if ns not in seen:
                                seen.add(ns)
                                queue.append(ns)
        # print(queue)
    print(-1)

main()

Measured memory_bytes: 218404
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> dp(3);
	for(int days = 0;days<n;++days) {
		vector<int> c(3);
		vector<int> new_dp(3, 0);
		for(int i = 0;i<3;++i) {
			cin >> c[i];
		}
		for(int i = 0;i<3;++i) {
			for(int j = 0;j<3;++j) {
				if(j != i)
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
			}
		}
		dp = new_dp;
	}
	cout << max({dp[0],dp[1],dp[2]}) << '\n';
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    long n;
    std::cin>>n;
    std::vector<std::string> s(n);
    for(int i = 0;i < n;i++){
        std::cin>>s[i];
    }

    char ch[5] = {'M', 'A', 'R', 'C', 'H'};
    std::vector<long> v(5, 0);
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 5;j++){
            if(s[i][0] == ch[j]){
                ++v[j];
                break;
            }
        }
    }
    std::vector<int> a = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    std::vector<int> b = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    std::vector<int> c = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
    long res = 0;
    for(int i = 0; i < 10;i++){
        res += v[a[i]] * v[b[i]] * v[c[i]];
    }
    std::cout<<res<<std::endl;
    return 0;
}

Measured memory_bytes: 6144
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k * 50 == X:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
vector<pair<ll,ll>>gg;
ll k,x1;
vector<int> adj[100001];
int dp[100001];
ll solve(ll x)
{
  //debug(x);
  if( dp[x]!= -1)return dp[x];
  ll ans = 0;
  for (int i = 0; i < adj[x].size(); ++i)
  {
    ans = max(ans,1+solve(adj[x][i]));
  }
  debugs(x,ans);
  return dp[x]=ans;
}
int main()
{
  // flash;
  ll x1;
  cin>>k>>x1;
  memset(dp,-1,sizeof dp);
  for (int i = 0; i < x1; ++i)
  {
    ll yo;ll no;
    cin>>yo>>no;
    yo--,no--;
    adj[yo].pb(no);
  }
  ll ans = -INF;
  for (int i = 0; i < k; ++i)
  {
    /* code */
    //debug(i);
    ans = max(ans,solve(i));
  }
  cout<<ans;
  return 0;
}

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

int linearSearch(int a[], int n, int key) {
    int i = 0;
    a[n] = key;
    while (a[i] != key) {
        i++;
    }
    return i != n;
}

int main() {
    int n, a[10000+1], q, key, sum = 0;

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

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> key;
        if (linearSearch(a, n, key)) {
            sum++;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 3116
N,D=map(int,input().split())
X=[0 for i in range(N)]
res=0

for i in range(N):
    X[i]=list(map(int,input().split()))
    
for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d+=(X[i][k]-X[j][k])**2
        d=d**0.5
        if d.is_integer():
            res+=1
print(res)

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

long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}

int main() {
  srand (time(NULL));
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) neg -= c[j] * (i - last[j]);
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  /* reversed: 109149564 */
  /* sorted: 110465449 */
  /* stocahstic */
  
  for (int t = 1; t <= 10000000; ++t) {
    int dd = rand() % n;
    int tt = rand() % 26;
    int ot = options[dd];
    while (ot == tt) tt = rand() % 26;
    long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                        options, dd, tt, ot);
    if (ns > 0) {
      total += ns;
      options[dd] = tt;
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3580