akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
# 整数の入力
S = input()
T = input()

S_len = len(S)
T_len = len(T)
diff_len = S_len - T_len
tmp_count = 0
mached = 100000

for i in range(diff_len + 1):
    for j in range(T_len):
        if T[j] != S[j + i]:
            tmp_count = tmp_count + 1
    if tmp_count < mached:
        mached = tmp_count
    tmp_count = 0

print(mached)


Measured memory_bytes: 8928
#include <stdio.h>

int main(){
	int i;
	int a[10];
	int m1,m2,m3;
	
	for(i = 0;i<10;i++){
		scanf("%d",&a[i]);
	}
	
	m1 = a[0];
	m2 = 0;
	m3 = 0;
	for(i=1;i<10;i++){
		if (m1 < a[i]){
			m3 = m2;
			m2 = m1;
			m1 = a[i];
			continue;
		}
		if (m2 < a[i]){
			m3 = m2;
			m2 = a[i];
			continue;
		}
		if (m3 < a[i]){
			m3 = a[i];
			continue;
		}
	}
	printf("%d\n",m1);
	printf("%d\n",m2);
	printf("%d\n",m3);
	
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;
const LL N = 400005;

LL n;
LL a[N],b[N];

LL chk(LL x){
	LL ls[2]; ls[0] = ls[1] = n + 1;
	b[0] = 2; b[n << 1] = 2;
	for(LL i = 1;i <= (n << 1) - 1;i ++) b[i] = (a[i] > x);
	for(LL i = n;i <= (n << 1) - 1;i ++){
		if(b[i] == b[i + 1]) ls[b[i]] = min(ls[b[i]],i - n);
	}
	for(LL i = n;i >= 1;i --){
		if(b[i] == b[i - 1]) ls[b[i]] = min(ls[b[i]],n - i);
	}
//	cout << x << ' ' << ls[0] << ' ' << ls[1] << endl;
	if(ls[0] == n + 1 && ls[1] == n + 1) return x == n ? 1 : 0;
	return ls[0] < ls[1];
}

int main(){
	ios::sync_with_stdio(false);
	LL l,r,mid,ans = 1;
	cin >> n;
	for(LL i = 1;i <= (n << 1) - 1;i ++) cin >> a[i];
	l = 1; r = (n << 1) - 1;
	while(l <= r){
		mid = (l + r) >> 1;
		if(chk(mid)){
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
using namespace std;
#define P 10007
int main(){
  int w,n;
  cin>>w>>n;

  int a[n];
  int dp[w+1];
  dp[0]=0;
  for(int i=1;i<=w;i++)dp[i]=P;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    for(int j=0;j+a[i]<=w;j++){
      dp[j+a[i]]=min(dp[j]+1,dp[j+a[i]]);
    }
  }
  cout<<dp[w]<<endl;
}

Measured memory_bytes: 3276
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  vector<ll> dp(N + 1, 0);
  for (ll i = 0; i < N + 1; i++) {
    dp[i] = i;
  }

  for (ll i = 0; i < N + 1; i++) {
    ll pow6 = 6;
    while (i + pow6 < N + 1) {
      dp[i + pow6] = min(dp[i + pow6], dp[i] + 1);
      pow6 *= 6;
    }

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

  cout << dp[N] << endl;
  return 0;
}


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

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

    ll x, k, d;

    cin >> x >> k >> d;

    x = abs(x);

    ll z = x / d;

    if(z > k)
    {
        cout << abs(x - (d*k));
    }

    else
    {
        x -= (z*d);

        k = k - z;

        if(k %2 == 0)
        {
            cout << abs(x);
        }

        else
        {
            cout << abs(x-d);
        }

    }


}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

int n,m;
priority_queue<long long int> arr;
//long long int arr[1000000];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		long long int s=0;
		scanf("%lld",&s);
		arr.push(s);
	}
//	sort(arr,arr+n);
//	for(int i=n-1;i>0;i--){
//		arr[i]=
//	}
	for(int i=0;i<m;i++){
		long long int tt=arr.top()*0.5;
//		printf("%d \n",tt);
		arr.pop();
		arr.push(tt);
	}
	long long int sum=0;
	for(int i=0;i<n;i++){
		sum+=arr.top();
		arr.pop();
//		arr[i]=arr[i]+arr[i-1];
	} 
	printf("%lld",sum);
//	cout<<endl;
//	long long int sum=0;
//	for(int i=0;i<n;i++){
//		sum+=arr[i];
//		printf("%d\n",sum);
//	}
//	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1400
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[500][500] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> a ;
	b = 0;
	while (true) {
		if (b * b == a) {
			break;
		}
		if (b * b > a) {
			b--;
			break;
		}
		b++;
	}

	cout << b*b << endl;
	

	return 0;

}


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

#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace boost::multiprecision;
using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll L;
    cin >> L;
    cpp_dec_float_50 x = L / 3.0;
    cout << setprecision(30) << x * x * x << endl;
}

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

int gcd(int a, int b) { if (!b)return a; return gcd(b, a%b); }
int main() {
	int x, y; cin >> x >> y;
	cout << gcd(max(x, y), min(x, y)) << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

template<typename T>
struct BIT{
    vector<T> bit;
    BIT(int n) : bit(n+1) {}
    void add(int a,T w){
        for(int x=++a; x < bit.size(); x+=(x&(-x)) ){
            bit[x] += w;
        }
    }
    // return v[0]+v[1]+...+v[a-1];
    T sum(int a){
        T ret=0;
        for(int x=a;x>0;x-=(x&(-x)) ){
            ret+=bit[x];
        }
        return ret;
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n+1];
    BIT<ll> b(n+2);
    for(int i=0;i<=n;i++){
        cin>>a[i];
    }
    if(n==0){
        if(a[0]==1){
            cout << 1 << endl;
            return 0;
        }
        cout << -1 << endl;
        return 0;
    }
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }


    ll ans = 1;
    queue<int> q;
    for(int i=1;i<=n+1;i++){
        q.push(i);
    }
    ll t[n+1]={};
    b.add(0,1);
    b.add(1,-1);
    for(int i=1;i<=n;i++){
        ll tmp = a[i];
        while(a[i]){
            int p = q.front();
            if(p > i){
                cout << -1 << endl;
                return 0;
            }
            ll su1 = b.sum(p), su2 = b.sum(p+1);
            ll ma = su1*2 - t[p] - su2;
            // if(i==p)ma+=t[p];
            if(ma == 0){
                q.pop();
                continue;
            }
            if(i==1){
                cerr << p << " " << ma << " " << endl;
            }
            ll ret = min(a[i],ma);
            a[i] -= ret;
            ans += (i-p+1)*ret;
            su2 += ret;
            // if(i==p)su2-=ret;
            b.add(p, ret);
            b.add(i, -ret);
            if(su2+t[p] == su1*2)q.pop();
            // cerr << i << " " << p << " " << a[i] << " " << ans  << endl;
        }
        t[i] += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6092
N = int(input())
S = input()

def z_algorithm(s):
    n = len(s)
    res = [0] * n
    i = 1
    j = 0
    while i < n:
        while i + j < n and s[j] == s[i + j]:
            j += 1
        res[i] = j
        
        if j == 0:
            i += 1
            continue
            
        k = 1
        while i + k < n and k + res[k] < j:
            res[i + k] = res[k]
            k += 1
            
        i += k
        j -= k
        
    return res

ans = 0
for i in range(N):
    lcp = z_algorithm(S[i:])
    tmp = max(min(lcp[j], j) for j in range(N - i))
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 79864
n = gets.to_i
s = gets.chomp

x = Array(n)
x = [0]
c = 0
1.upto(n - 1).each do |i|
  if s[i - 1] == 'W'
    c += 1
  end
  x[i] = c
end

c = 0
(n - 2).downto(0).each do |i|
  if s[i + 1] == 'E'
    c += 1
  end
  x[i] += c
end

puts x.min

Measured memory_bytes: 4868
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

void score(int D, int c[], int s[][26], int t[]){
    int pen_day[26]={1};
    for(int i=0; i<26; i++){
        pen_day[i]=1;
    }
    int score=0;
    
    for(int i=0; i<D; i++){
        int type=t[i]-1;
        pen_day[type]=0;
        //満足度増加
        score+=s[i][type];
        //満足度低下
        for(int j=0; j<26; j++){
            int dec=c[j]*pen_day[j];
            score-=dec;
        }
        //日数追加
        for(int j=0; j<26; j++){
            pen_day[j]++;
        }        
        printf("%d\n", score);
    }
}

int main(void){
    int D, c[26], s[365][26], t[365];

    //入力
    scanf("%d", &D);
    for(int i=0; i<26; i++){
        scanf("%d", &c[i]);
    }
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            scanf("%d", &s[i][j]);
        }
    }
    for(int i=0; i<D; i++){
        scanf("%d", &t[i]);
    }

    //出力
    /*
    printf("%d\n", D);
    for(int i=0; i<26; i++){
        printf("%d ", c[i]);
    }
    printf("\n");
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            printf("%d ", s[i][j]);
        }
    }
    */

   /*ここから処理*/
   /*
    int num=1;
    for(int i=0; i<D; i++){
        printf("%d\n", num);
        num++;
        if(num>26) num=1;
    }
    */

   score(D, c, s, t);


    return 0;
}

Measured memory_bytes: 1768
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int H, W, N, a[11234];
int tmp[11234], c[112][112];

int main()
{
	in >> H >> W >> N;
	rep(i, N) { in >> a[i]; }

	int seek = 0;
	rep(i, N)
	{
		for (int j = seek; (j - seek) < a[i]; ++j)
		{
			tmp[j] = i + 1;
		}
		seek += a[i];
	}
	int for_flag = 0;	// 右へ
	seek = 0;
	rep(i, H*W)
	{
		rep(x, H)
		{
			if (for_flag == 0)
			{
				rep(y, W)
				{
					c[x][y] = tmp[x*W + y];
					++seek;
				}
				for_flag = 1;
			}
			else
			{
				for (int y = W - 1; y >= 0; --y)
				{
					c[x][y] = tmp[x*W + ((W - 1) - y)];
					++seek;
				}
				for_flag = 0;
			}
		}
	}

	rep(i, H)
	{
		rep(j, W - 1) { out << c[i][j] << " "; }
		out << c[i][W - 1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a = sc.nextInt();
        
        if (a == 1){
            System.out.println("0");
        } else {
            System.out.println("1");
        }
    }
}

Measured memory_bytes: 35652
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include<bits/stdc++.h>
using namespace std;
const  long long     mx=1e5+100;

#define      mod     1e9+7
#define      pai     acos(-1)
#define      ff      first
#define      ss      second
#define      ll      long long
#define      pb      push_back
#define      mp      make_pair
#define      fi      freopen("input.txt","r",stdin);
#define      fo      freopen("output.txt","w",stdout);
#define      fast    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

//typedef pair<ll,ll> pi;
//typedef map<ll,ll> mi;


int main()
{
    fast;
    ll i,j,a=-1,b=-1,c,x,y,z,n,m,t;
    cin>>n;
    set<ll>st;
    map<ll,ll>freq;
    for(i=0;i<n;i++)
    {
        cin>>m;
        st.insert(m);
        freq[m]++;
    }
    ll area=0;
    vector<ll>vec;
    for(auto p=st.rbegin();p!=st.rend();p++)
    {
        if(freq[*p]>=2)
        {
            vec.pb(*p);
        }
        if(vec.size()==2)
        {
            break;
        }
    }
    if(vec.size()==1)
    {
        a=vec[0];
        x=freq[a];
        if(x>=4)
        {
            area=a*a;
        }
        else
        {
            area=0;
        }
    }
    else if(vec.size()==2)
    {
        a=vec[0];
        b=vec[1];
        x=freq[a];
        y=freq[b];

        if(x>=4)
        {
            area=max(area,(a*a));
        }
        else
        {
            if(x>=2&&y>=2)
            {
                area=max(area,(a*b));
            }
            else
            {
                area=0;
            }
        }
    }
    else
    {
        area=0;
    }
    cout<<area<<endl;
    return 0;



//...........................................  ٱلْحَمْدُ لِلَّٰهِ‎  ...........................................................
}



Measured memory_bytes: 14484
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  int c[n];
  int a[n][m];
  for(int i=0;i<n;++i){
    cin >> c[i];
    for(int j=0;j<m;++j) cin >> a[i][j];
  }
  
  long long min=100000000;
  long long ma;
  int N;
  N = (int)pow(2.0,n);
  int ni;
  int b[n];
  long long sei[m]={};
  int check;
  for(int i=0;i<N;++i){
    ni = i;
    for(int j=0;j<n;++j){
      b[j] = ni%2;
      ni = (ni-b[j])/2;
    }
    ma = 0;
    //sei
    for(int j=0;j<n;++j){
      if(b[j]==1){
        for(int k=0;k<m;++k){
          sei[k] += a[j][k];
        }
        ma += c[j];
      }
    }
    check = 0;
    for(int k=0;k<m;++k){
      if(sei[k]>=x)check++;
      sei[k] = 0;
    }
    if(check==m && ma < min) min = ma;
  }
  if(min==100000000) cout<<"-1"<<endl;
  else cout<<min<<endl;
    
    
              
 
}

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

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int[] appearanceArr = new int[n+1];
		int[] aArr = new int[n];
		for(int i = 0 ; i < n; i++) {
			int a = fs.nextInt();
			appearanceArr[a]++;
			aArr[i] = a;
		}
		
		long allAppearance = 0;
		
		for(int i = 0; i < n+1;i++) {
			int appearance = appearanceArr[i];
			if(appearance < 2) {
				continue;
			}
			allAppearance += conv2(appearance);
		}
		
		for(int i = 0; i < n; i++) {
			int aVal = aArr[i];
			int appearance = appearanceArr[aVal];
			if(appearance < 2) {
				System.out.println(allAppearance);
				continue;
			}
			System.out.println(allAppearance - conv2(appearance) + conv2(appearance-1));
		}
	}
	
	public long conv2(int n) {
		if(n < 2) {
			return 0;
		}
		long longN = (long)n;
		return longN*(longN-1)/2;
	}
	
	

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 81288
S = int(input())
mod = 10**9+7

result = [[0 for _ in range(S+1)] for _ in range(S//3+2)]

for i in range(3,S+1):
  result[1][i] = 1

for i in range(2,S//3+2):
  tmp = 0
  for k in range(3*(i-1),S-2):
    tmp = (tmp+result[i-1][k])%mod
    result[i][k+3] = tmp

answer = 0
for i in range(1,S//3+2):
  answer = (answer+result[i][S])%mod
print(answer)

Measured memory_bytes: 78752
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    a -= b;
    vector<ll> h(n);
    cins(all(h));
    ll l = -1,r = 1e10;
    while(r-l > 1){
        ll m = (r+l)/2;
        ll cnt = 0;
        rep(i,n){
            if (h[i] <= m*b) continue;
            cnt += (h[i]-m*b-1)/a+1;
        }
        if (cnt <= m)  r = m;
        else l = m;
    }
    PRINT(r);
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  priority_queue<ll> q;
  rep(i, n) q.push(A[i]);
  rep(i, m) {
    ll tmp = q.top(); q.pop();
    q.push(tmp/2);
  }
  ll sum = 0;
  rep(i, n) {
    sum += q.top(); q.pop();
  }
  cout << sum << endk;
  return 0;
}


Measured memory_bytes: 5072
from functools import reduce

def gcds(a, b):
	while b:
		a, b = b, a % b
	return a

def gcd(*numbers):
  return reduce(gcds, numbers)

def solve():
  n, start = map(int, input().split())
  cities = input().split(" ")
  # Startを0からに変更
  cities = [int(i) - start for i in cities]
  print(abs(gcd(*cities)))

solve()

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

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int n,p,d1,d2;
	int A[10000],R,L;
	while(1){
		A[10000]={};
		R=0;
		L=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>p>>d1>>d2;
			A[i]=d1+d2;
			if(R<A[i]){
				R=A[i];
				L=p;
			}
		}
		cout<<L<<" "<<R<<endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
int main(void){
    int N,K;
    char S[50];
    scanf("%d %d",&N,&K);
    scanf("%s",S);
    if(S[K-1]=='A'){
        S[K-1]='a';
    }
    else if(S[K-1]=='B'){
        S[K-1]='b';
    }
    else{
        S[K-1]='c';
    }
    printf("%s",S);
    return 0;
    
}

	

Measured memory_bytes: 128
def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    if A[0] > x:
        diff = A[0] - x
        A[0] = x
        ans += diff
    if A[-1] > x:
        diff = A[-1] - x
        A[-1] = x
        ans += diff
    B = [a for a in A]
    ans1 = 0
    for i in range(N-1):
        s = A[i] + A[i + 1]
        if s <= x:
            continue
        diff = s - x
        if diff > A[i + 1]:
            A[i] -= diff - A[i + 1]
            A[i + 1] = 0
        else:
            A[i + 1] -= diff
        ans1 += diff

    ans2 = 0
    for i in range(N - 1):
        index = N - 1 - i
        s = B[index] + B[index - 1]
        if s <= x:
            continue
        diff = s - x
        if diff > B[index - 1]:
            B[index] -= diff - B[index - 1]
            B[index - 1] = 0
        else:
            B[index - 1] -= diff
        ans2 += diff
    ans += min(ans1, ans2)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[k-1] == 'A') s[k-1] = 'a';
    else if (s[k-1] == 'B') s[k-1] = 'b';
    else if (s[k-1] == 'C') s[k-1] = 'c';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

int K;cin>>K;
  string S;
  cin>>S;
  int B=S.size();
  for(int i=0;i<min(K,B);i++){
    cout<<S[i];
  }
  
  if(K<S.size()){
    cout<<"..."<<endl;
  }
}



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, n-m+1) rep(j, n-m+1) {
    bool flag = true;
    rep(k, m) rep(l, m) if(a[i+k][j+l] != b[k][l]) flag = false;
    if(flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) swap(a, b);
	if ((b - a) % 2 == 1) {
		dump("IMPOSSIBLE") return 0;
	}
	dump((b - a) / 2 + a)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,ans=0;
  cin>>n;
  vector<long long> vec(n);
  for (long long i = 0; i < n; i++) {
 cin>>vec.at(i);
  }
   sort(vec.begin(), vec.end()); 
    reverse(vec.begin(), vec.end());
  for (long long i = 0; i < n/2; i++) {
    ans+=vec.at(i)*2;
  }
  ans-=vec.at(0);
  if(n%2 != 0){
 ans+=vec.at(n/2);
  }
  cout<<ans<<endl;
}

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

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

    int a_idx = s.size();
    int z_idx = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A')
        {
            a_idx = min(a_idx, i);
        }
        if (s[i] == 'Z')
        {
            z_idx = max(z_idx, i);
        }
    }
    cout << z_idx - a_idx + 1 << endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if B % A == 0:
        ret = A + B
    else:
        ret = B - A
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

int main() {
	// your code goes here
	int n;
	int k;
	cin >> n >> k;
	priority_queue<
	int,
	vector<int>,
	greater<int>
	> h;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		h.push(a);
	}
	int num = n - k;
	long long ans = 0;
	if(num <= 0){
		cout << ans << endl;
	}
	else{
		for(int i=0; i<n-k; i++){
			ans += h.top();
			h.pop();
		}
		
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input2";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("w32nimda");
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        Console.WriteLine(new string(InputList[0].ToCharArray().Reverse().ToArray()));
    }
}

Measured memory_bytes: 5540
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};

int main(){
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  bool t = false;
  rep(i,n-1) if(a[i]==a[i+1])t=1;
  if(t) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    char c;
    cin >> c;
    char ans = ++c;
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#define FOR(i, a, n) for(int i = (int)a; i <= (int)n; i++)
using namespace std;

int main() {
  double D, E;
  double x, y;
  double len, tol;

  while(1) {
    cin >> D >> E;
    if(D == 0 && E == 0) break;
    tol = 100.0;
    FOR(i, D/2, D) {
      x = i;
      y = D - i;
      len = sqrt(x * x + y * y) - E;
      if(len < 0)
        len = len * (-1);
      if(len < tol)
        tol = len;
      if(tol == 0)
        break;
    }
    cout << fixed << setprecision(12) << tol << endl;
  }
  return 0;
}



Measured memory_bytes: 3280
# coding: utf-8
#ABC095C_HalfandHalf.rb
a,b,c,x,y = gets.split.map(&:to_i)

ci = 0
sum = 0
ar = []
while true
  ai = x - ci
  bi = y - ci
  ai = 0 if ai < 0
  bi = 0 if bi < 0
  
  sum = (c * 2*ci) + (a * ai) + (b * bi)
  #puts "AB:#{2*ci}枚 A:#{ai}枚 B:#{bi}枚 #{sum}円"

  ar << sum
  ans = ar.min
  ar = [ans]
  ci += 1

  if (ai==0) && (bi==0)
    p ans
    exit
  end
  
end



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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }

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


int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    rep(i,0,n){
        cin >> a[i];
    }
    ll temp = 0;

    ll cnt = 0;
    rep(i,0,n){
        if(temp == 1 && a[i] > 0){
            cnt++;
            a[i]--;
        }
        
        cnt += a[i]/2;
        temp = a[i]%2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 4424
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int AB = min(A, B);
	int CD = min(C, D);
	OUT(AB + CD);

	return 0;
}

Measured memory_bytes: 256
#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);
  ll ans = 0;
  int l = 0;
  forn(i,n){
    if (s[i] == 'W') {
      ans += (ll)(i - l);
      l++;
    }
  }
  cout << ans << endl;
}

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

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

0 < 2 > 1 > 0

 */

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

int main() {
  int n;
  string a,b,c;
  cin >> n;
  cin >> a >> b >> c;
  int r=0;
  for(int i=0;i<n;i++){
      if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i])r+=2;
	  else if(!((a[i]==b[i])&&(b[i]==c[i]))){
        r++;
      }  
  }
  
  cout << r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int n, i, j;
  int k=1;
  int A[101][101],B[101],G[101];
  int sz, min, out = 0;
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
    }
  }

  B[0] = 0;
  G[0] = 1;
  for(i = 1; i < n; i++){
    G[i] = 0;
  }
  while(1){
    sz = 2001;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
        if(A[B[i]][j] < sz && A[B[i]][j] != -1 && G[j] != 1){
          sz = A[B[i]][j];
          min = j;
        }
      }
    }

    if(k != n){
      B[k] = min;
      G[min] = 1;
      out += sz;
      k++;
    }
    else break;
  }
  printf("%d\n", out);


  return 0;
}





Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 9999999999999999
#define MOD 1000000007

ll power(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a;
        a=a*a;
        b=b/2;
    }
    return ans;
}

ll onecount(ll N,ll n){
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(N&(1<<i)) ++cnt;
    }
    return cnt;
}

void func()
{
    ll d,t,s;
    cin>>d>>t>>s;
    double x=(d*1.0/s);
    double y=t;
    if(x<=y){
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    //solve();
    while(t--)
    {
        func();
    }

}


Measured memory_bytes: 3644
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] line = s.nextLine().split(" ");
		int v1 = Integer.parseInt(line[0]);
		int v2 = Integer.parseInt(line[1]);
		System.out.println(gcd(v1, v2));
	}

	public static int gcd(int v1, int v2) {
		if(v1<v2) {
			int tmp = v1;
			v1 = v2;
			v2 = tmp;
		}

		if(v1%v2 == 0) {
			return v2;
		} else {
			return gcd(v2, v1%v2);
		}
	}

}

Measured memory_bytes: 17308
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  vector< pair<pair<string, int>, int> > restaurant(N);
  for (int i = 0; i < N; ++i)
  {
    string s;
    int point;
    cin >> s >> point;
    restaurant[i] = make_pair(make_pair(s, -point), i + 1);
  }
  sort(restaurant.begin(), restaurant.end());

  for (int i = 0; i < N; ++i)
  {
    cout << restaurant[i].second << "\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		for(int i=0;i<N;i++) sc.nextInt();
		
		System.out.println((N-1+K-2)/(K-1));
	}

	public static int gcd(int a, int b) {
		return a%b==0 ? b : gcd(b,a%b);
	}
}


Measured memory_bytes: 47520
#include<iostream>
using namespace std;
int main()
{
    int x,y,j;
    string ans="No";
    cin>>x;
    cin>>y;
    if(x<y)
    {
    for(int i=0;i<x+1;i++)
    {
        j=x-i;
        if(((i*2)+(j*4))==y)
        {
            ans="Yes";
            break;
        }
    }
    }
    cout<<ans;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  val x = readLine()!!.split(" ").map { it.toInt() }.sorted()
  var mpc = Array(m) { 0 }
  var mc = Array(m) { 0 }
  var p = 0
  for (i in 0 until n) {
    p++
    mc[x[i] % m]++
    if (i < n - 1 && x[i] == x[i + 1]) continue
    mpc[x[i] % m] += p / 2
    p = 0
  }
  var ans = mc[0] / 2
  if (m % 2 == 0) ans += mc[m / 2] / 2
  for (i in 1..(m - 1) / 2) {
    ans += if (mc[i] < mc[m - i]) {
      mc[i] + arrayOf((mc[m - i] - mc[i]) / 2, mpc[m - i]).min()!!
    } else {
      mc[m - i] + arrayOf((mc[i] - mc[m - i]) / 2, mpc[i]).min()!!
    }
  }
  println(ans)
}


Measured memory_bytes: 56312
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       ll d,t,s,i,j=0;
       std::cin >> d>>t>>s;
       if(s*t>=d)
       cout<<"Yes\n";
       else
       cout<<"No\n";
   }
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a + min(b, c), b + min(a, c)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
string S;
  cin  >>N >>S;
  
  int count=0;
  for (int i = 0; i+1 < S.size(); i++) {
  if(S.at(i) != S.at(i+1)){
    count++;
  }
}

  cout << count +1 <<endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 0
m = 1

for i in range(60):
    #mbit目に情報を持つものをすべて足し合わせる。
    #m = 1: 1bit目（2^0の位）、m=10: 2bit目（2^1の位）
    #sum = sigma(1の数 * 2^(m-1))
    one = sum(a_e & m for a_e in a)
    one //= m
    zero = n - one
    ans += one * zero * m
    ans %= MOD
    
    m <<= 1

print(ans)

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

int main() {
  int N, M, sum = 0;
  cin >> N >> M;

  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  double border = (double)sum/(4.0*(double)M);
  //cout << border << endl;

  if(A.at(M-1) >= border ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}


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

using P = pair<ll,ll>;
#define v first
#define w second

// v高い順（vが同じならw軽い方優先）
bool comp(P a, P b){
    return a.v == b.v ? a.w < b.w : a.v > b.v;
}

int main(void){
    int N,W;
    cin>>N>>W;
    vector<P> a(N);
    rep(i,N){
        ll v,w;
        cin>>v>>w;
        a[i] = {v,w};
    }
    vector<P> dp = {{0,0}};

    rep(i,N){
        vector<P> tmp;
        for(auto& s : dp){
            tmp.push_back(s);
            tmp.push_back({s.v + a[i].v, s.w + a[i].w});
        }

        sort(all(tmp),comp);
        dp.clear();
        ll w_border = W+1;
        for(auto& s : tmp){
            if( w_border > s.w){
                w_border = s.w;
                dp.push_back(s);
            }
        }
    }
    cout<<dp[0].v<<endl;
    return 0;
}



Measured memory_bytes: 3292
#include <algorithm>
#include <iostream>
#include <vector>

#define INF 1000000007

int main(){
    int n;
    std::cin >> n;

    std::vector<int> row(n), col(n);
    for(int i = 0; i < n; ++i){
        std::cin >> row.at(i) >> col.at(i);
    }

    // consider a n * n dp matrix with INF as the minimum value is the interest of this exercise
    std::vector<std::vector<int>> dp(n, std::vector<int>(n, INF));
    for(int l = n - 1; 0 <= l; --l){
        for(int r = 0; r < n; ++r){
            if(r == l){
                // set the dp value at self multiplication zero
                dp.at(l).at(r) = 0;
            }else if(r == l + 1){
                // multiply 2 matrixes
                dp.at(l).at(r) = row.at(l) * col.at(l) * col.at(r);
            }else if(r > l + 1){
                for(int m = l; m < r; ++m){
                    // examine the all dp values in every case where a separating point differs each other
                    dp.at(l).at(r) = std::min(dp.at(l).at(r), dp.at(l).at(m) + row.at(l) * col.at(m) * col.at(r)+ dp.at(m + 1).at(r));
                }
            }
        }
    }

    std::cout << dp.at(0).at(n - 1) << std::endl;

    return 0;
}


Measured memory_bytes: 3172