akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii Dir[8] = { //?????????
	{ 0,1 },{ 0,-1 },{ 1,0 },{ -1,0 },
	{ 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 }
};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
int r;
vector<ll> v;
ll c = 1, n, k;

class Graph {
public:
	int vn;
	vector<vector<pii>> g;
	vector<int> depth;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		
	}
};



int TDiam(Graph& graph) {
	vector<bool> al(graph.vn);
	function<pii(int,int)> func = [&](int cur, int dis) {
		pii Max = { dis,cur };
		al[cur] = 1;
		REP(i, graph.g[cur].size()) {
			if (!al[graph.g[cur][i].first]) {
				Max = max(Max,func(graph.g[cur][i].first, dis+graph.g[cur][i].second));
			}
		}

		return Max;
	};

	pii S = func(0,0);
	al = vector<bool>(graph.vn);
	pii G = func(S.second,0);

	return G.first;
}

signed main() {
	int n;
	scanf("%d", &n);

	Graph graph(n);

	REP(i, n-1) {
		int a, b, w;
		scanf("%d %d %d", &a, &b, &w);
		//a--; b--;
		graph.con(a, b,w);
	}

	printf("%d\n", TDiam(graph));

	return 0;
}

Measured memory_bytes: 15960
import itertools

N = int(input())

# 素数リストアップ
primes = []
for n in range(2,N+1):
    if 0 not in map(lambda m: n%m, range(2,n)):
        primes.append(n)

# N! 素因数分解
factors = [0]*len(primes)
for n in range(2,N+1):
    for i in range(len(primes)):
        p = primes[i]
        while n % p == 0 :
            n /= p
            factors[i] += 1

def count(fs):
    num = 0
    for v in itertools.permutations(factors, len(fs)):
        if False not in map(lambda i: fs[i]<=v[i]+1, range(len(v))):
            num +=1
    return num
                                    

num = 0
num += count([75])
num += count([3,25])
num += count([5,15])
num += int(count([3,5,5])/2)
print(num)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[105000];
int main(){
	int n;
	scanf("%d", &n);
	for(int i=1;i<=n;i++)scanf("%d", &a[i]);
	sort(a+1, a+1+n);
	ll p=0, q=0;
	for(int i=n-1;i>=1;i--){
		if(a[i]==a[i+1]){
			if(p==0)p=a[i];
			else {
				q=a[i];
				break;
			}
			i--;
		}
	}
	printf("%lld\n", p*q);
}



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

int main() {
	int N,K;
	string S;
	cin >> N >> S >> K;
	K--;
	for (int i = 0;i<S.size(); ++i) {
		if (S[i]!=S[K]) {
			S[i] = '*';
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int r = -1;
  F0R(i, 5) {
    int a;
    cin >> a;
    if (a != i + 1) r = i + 1;
  }
  cout << r;
}
#endif


Measured memory_bytes: 3580
A,B=map(int,input().split());B+=1
print(sum(((((B//(2*(2**j)))*(2**j)+max(0,(B%(2*(2**j)))-2**j))-((A//(2*(2**j)))*(2**j)+max(0,(A%(2*(2**j)))-2**j)))%2)*(2**j) for j in range(41)))

Measured memory_bytes: 3064
N, A, B, C = map(int, input().split())

def rec(Y):
    if len(Y) == 0:
        return [(0, 0, 0, 0)]
    
    y = Y.pop()
    tmp = rec(Y)
    return [(t[0]+y, t[1], t[2], t[3]+(10 if t[0]>0 else 0)) for t in tmp] + [(t[0], t[1]+y, t[2], t[3]+(10 if t[1]>0 else 0)) for t in tmp] + [(t[0], t[1], t[2]+y, t[3]+(10 if t[2]>0 else 0)) for t in tmp] + [(t[0], t[1], t[2], t[3]) for t in tmp]


X = rec([int(input()) for i in range(N)])
mi = 10**20
for a, b, c, mp in X:
    if a>0 and b>0 and c>0:
        mi = min(mi, abs(A-a) + abs(B-b) + abs(C-c) + mp)
    
print(mi)

Measured memory_bytes: 53308
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll dp[1005][20005]={0};
int main(){
	cin>>N;
	vector<pair<pair<ll, ll>, ll> > data;
	rep(i,N){
		ll w,s,v;
		cin>>w>>s>>v;
		data.pb(mp(mp(w+s,w),v));
	}
	sort(all(data));
	rep(i,N){
		ll w=data[i].first.second;
		ll s=data[i].first.first - w;
		ll v=data[i].second;
		//cout<<v<<endl;
		rep(j,20001){
			dp[i+1][j]=dp[i][j];
			if(j-w<=s&&j>=w){
				maxs(dp[i+1][j],dp[i][j-w]+v);
			}
		}
	}
	ll ans=0;
	/*rep(i,N){
		rep(j,50){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	rep(i,20001)maxs(ans,dp[N][i]);
	cout<<ans<<endl;
}

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

namespace AtCoder.BC085
{
    public class B
    {
        public static void Main()
        {
            List<int> m = new List<int> { };
            int c = int.Parse(Console.ReadLine());
            for (int i = 0; i < c; i++)
            {
                m.Add(int.Parse(Console.ReadLine()));
            }

            Console.WriteLine(m.Distinct().Count());
        }
    }
}

Measured memory_bytes: 18560
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  long long N;
  scanf("%lld",&N);
  long long ans = 0;
  long long i = 1;
  if (N%2==1){
    printf("0\n");
  } else {
    long long power = 10;
    while(N>=power){
      //printf("power=%lld\n",power);
      ans += (long long)(N/power);
      //      printf("ans=%lld\n", ans);
      power *= 5;
      i++;
    }
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x])
			return self.table[x]

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

	def get_size(self, x):
		return self.size[self.find(x)]

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

block = [[] for _ in range(n)]
for _ in range(k):
	a, b = map(int, input().split())
	block[a-1].append(b-1)
	block[b-1].append(a-1)

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

print(*ans)

Measured memory_bytes: 87620
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;

    for(int i=0; i<n; i++){
      int h = sc.nextInt();
      if(k<=h){
        count += 1;
      }
    }
    System.out.println(count);
  }  

}

Measured memory_bytes: 45220
S = input()
S_damy = S
sum_S = 0
plus = 2**(len(S)-1)
for i in range(plus):
    for j in range(len(S)-1):
        if i >> j & 0b1:
            sum_S += int(S_damy[len(S)-1-j:])
            if S_damy:
                S_damy = S_damy[:len(S)-1-j]

        if j == len(S)-2 and S_damy:
            sum_S += int(S_damy)
    S_damy = S
if len(S) == 1:
    print(S)
else:
    print(sum_S)

Measured memory_bytes: 39792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
 
using namespace std;


bool ans(vector<int> a)
{
	int s;
	s=a[1]-a[0];
	for(vector<int>::size_type i = 1; i<a.size(); i++)
	{
		int kari;
		kari=a[i]-a[i-1];
		if(kari != s) return false;
	}
	return true;
}

int main(void)
{
	int n;
	while(cin>>n && n)
	{
		vector<int>a,b;
		int kari;
		
		for(int i=0; i<n+1; i++)
		{
			cin>>kari;
			a.push_back(kari);
		}

		b = a;

		for(vector<int>::size_type i = 0; i < a.size(); ++i)
		{
			int h;
			h = a[i];
			a.erase(a.begin() + i);
			if(ans(a))
			{
				cout<<h<<endl;
				break;
			}
			a = b;
		}
	}

    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    ll a;
    long double b;
    cin >> a >> b;

    ll c = b * 100 + 0.5;
    ll ans = a * c / 100; 

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> va[i];
    va[i]--;
  }

  vector<int> cnts(n, 0);
  for (int i = 0; i < va.size(); i++) {
    cnts[va[i]]++;
  }

  for (int i = 0; i < cnts.size(); i++) {
    cout << cnts[i] << '\n';
  }

  return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s, t;
    int a, b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    cout << a - (s == u ? 1 : 0) << " " << b - (t == u ? 1 : 0) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;
    if(A==B){
        cout<<"Draw";
    }else if(B==1 && A!=1){
        cout<<"Bob";
    }else if (A==1 && B!=1){
        cout<<"Alice";

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

        }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>
 
using namespace std;

typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define endl "\n"
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  cout << 1-n << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define endl '\n'
const int mod=1e9+7,u=1e5+5;

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

    int n,k;
    cin>>n>>k;
    vector<int> arr(n+1);
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    vector<bool> dp(k+1,0);
    for(int i=0;i<=k;i++){
        for(int j=1;j<=n;j++){
            if(arr[j]<=i and !dp[i-arr[j]]){
                dp[i]=1;
                break;
            }
        }
    }
    cout<<(dp[k]?"First":"Second");

    return 0;
}

Measured memory_bytes: 256
N = int(input())
max_sub = -1145148101919#とりうる最小の値
min_value = int(input())
for i in range(1,N):
    r=int(input())
    max_sub=max(max_sub,r-min_value)#最小値
    min_value=min(min_value,r)#最小値の保持、毎回更新する
print(max_sub)


Measured memory_bytes: 5608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            int height = sc.nextInt();
            int weight = sc.nextInt();
            
            if(height == 0 && weight == 0) break;
        
            for(int i = 0; i < height; i++){
                for(int j = 0; j < weight; j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34416
def 解():
    iN = int(input())
    aC = [0] *(10** 5+2)
    dsA = set()
    for a in [int(_) for _ in input().split()]:
        aC[a] += 1
    iMax = 0
    for a in range(1,10**5 + 1):
        iMax = max(iMax,sum(aC[a-1:a+2]))
    print(iMax)
解()


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

int main()
{
    int s[1000],n,total;
    double m,a;
   
    while (cin >> n && n) {
        total = 0;
        for (int i=0; i<n; i++ ){
            cin >> s[i];
            total+=s[i];
        }
        m = (double)total / n;

        double smTotal=0.0;
        for (int i=0; i<n; i++ ){
            smTotal += (s[i]-m)*(s[i]-m);
        }
        a = sqrt(smTotal/n);

        cout << fixed << a << endl;
    }

    return 0;
}


Measured memory_bytes: 3288
using System;


public class A{
	
	public static void Main(){
	
		string str = Console.ReadLine();
		string[] args = str.Split(' ');
		int n = Int32.Parse(args[0]);
		int i = Int32.Parse(args[1]);
		Console.WriteLine( n - i + 1 );
		
	}
	
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  bool f = true;
 
if (a!=b) {
  for ( int i = a ; i < b+1 ; i++ ) {
    if (i%n==0) {
      cout << "OK" << endl;
       f = false;
      break;
    }
  }

  
  if (f) {
    cout << "NG" << endl;
  }
}
  else {
    if (a%n==0) {
      cout << "OK" << endl;
     }
    else {
      cout << "NG" << endl;
    }
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
signed main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    k--;
    s[k]+=32;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

    string s,t;
    cin>>s>>t;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)){
            c++;
        }
    }
    cout<<c<<endl;





}



Measured memory_bytes: 3916
/*input
10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
*/

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>




#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define forstl(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.f<<" , "<<it.s<<endl;} cerr<<endl
#define PI           3.14159265358979323846

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define pdd pair<double, double>
#define in(v,n) vll v(n);rep(i,n) cin>>v[i]


using namespace std;
ll n;
int check(ll arr[],ll val,ll k){
	ll ans=0;
	rep(i,n){
		if(arr[i]%val==0)ans+=(arr[i]/val)-1;
		else ans+=(arr[i]/val);
	}
	// cout<<ans<<' '<<val<<endl;
	if(ans<=k) return 1;
	else return 0;
	// cout<<val<<' '
}

int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;
	// cout<<std::fixed<<std::setprecision(35);
	// cin>>T;while(T--)
	{
		ll t,i,j,x,y,m,l,d,k;
		cin>>n>>k;
		ll arr[n];
		ll mx=0;
		rep(i,n) {cin>>arr[i];mx=max(mx,arr[i]);}
		ll low=1,high=mx;
		while(low<high-1){
			// cout<<low<<' '<<high<<endl;
			ll mid=(low+high)/2;
			if(check(arr,mid,k)==1){
				high=mid;
			}
			else low=mid+1;
			// cout<<check(arr,mid,k)<<' '<<mid<<endl;

		}
		// cout<<low<<' '<<high<<endl;
		if(check(arr,low,k)==1) cout<<low<<endl;
		else if(check(arr,low+1,k)==1) cout<<low+1<<endl;
		else cout<<high<<endl;
	}
}

Measured memory_bytes: 5100
#include<stdio.h>
#include<string.h>
int main(){
    char num[1005];
    int sum, i;
    while(1){
        scanf("%s", &num);
        sum = 0;
        i = strlen(num);
        if(i == 1 && num[0] == '0') break;
        for(i=i-1;i>=0;i--){
            sum += num[i] - '0';
        }
        printf("%d\n", sum);
    }
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		long[] A = new long[N];
		long[] sum = new long[N+1];
		for(int i = 0;i < N;i++) {
			long k = scn.nextLong();
			A[i] = k;
			sum[i+1] = sum[i]+k;
		}
		long L = sum[N];
		long b = L/2;
		long ans = Long.MAX_VALUE;
		int p = 0;
		for(int i=0;i<N+1;i++) {
			if(sum[i] > b) {
				p=i;
				break;
			}
		}
		ans = Math.min((L-2*sum[p-1]), 2*sum[p]-L);
		System.out.println(ans);
	}

}


Measured memory_bytes: 86544
package main

import (
	"fmt"
)

func calc(A int64) int64 {
	ans := int64(0)
	cnt := (A + 1) / 2
	ans += cnt % 2
	if A % 2 == 0 {
		ans += A
	}
	return ans
}

func main() {
	A, B := int64(0), int64(0)
	_, _ = fmt.Scan(&A, &B)
	fmt.Println(calc(B) ^ calc(A - 1))
}


Measured memory_bytes: 512
public class Main {
  private static void solve() {
    int n = ni();
    char[] s = ns();
    
    int[] sumE = new int[n + 1];
    int[] sumW = new int[n + 1];
    for (int i = 0; i < n; i ++) {
      int e = 0;
      int w = 0;
      if (s[i] == 'W') {
        w ++;
      } else {
        e ++;
      }
      sumE[i + 1] = sumE[i] + e;
      sumW[i + 1] = sumW[i] + w;
    }
    
    int min = Integer.MAX_VALUE;
    for (int i = 0; i < n; i ++) {
      int l = sumW[i];
      int r = sumE[n] - sumE[i + 1];
      min = Math.min(min, l + r);
    }
    System.out.println(min);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 30932
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	d, t, s = tin()
	#s = input()	
	return 'Yes' if d <= t*s else 'No'
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	long long N, M;
	cin >> N >> M;
	vector<int>A(M);
	vector<int>B(M);
	vector<long long>Ans(M + 1);
	for (int n = 0; n < M; ++n) {
		cin >> A[n] >> B[n];
		--A[n];
		--B[n];
	}
	UnionFind uf(N);
	Ans[M] = (N - 1)*N / 2;
	for (int n = 0; n < M; ++n) {
		Ans[M - 1 - n] = Ans[M - n];
		if (!uf.issame(A[M - 1 - n],B[M - 1 - n])) {
			long long x = uf.size(A[M - 1 - n]);
			long long y = uf.size(B[M - 1 - n]);
			Ans[M - 1 - n] += (x * x + y * y - (x + y)*(x + y)) / 2;
			//Ans[M - 1 - n] -= x* y;
		}
		uf.merge(A[M - 1 - n], B[M - 1 - n]);
	}
	
	for (int n = 0; n < M; ++n) {
		cout << Ans[n+1] << endl;
	}
	return 0;
}


Measured memory_bytes: 5068
N = int(input())
h = list(map(int, input().split()))

count = 0

while any(h):
  lists = [i for i, x in enumerate(h) if x > 0]
  i  = lists[0]
  start = i
  end = i
  while end + 1 < N and h[end + 1] > 0:
    end += 1
  for index in range(start, end + 1):
    h[index] -= 1
  count += 1

print(count)


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

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

vector <pll> V;
ll S[202020];
ll n, l1, l2, r1, r2, cnt, ans;

int main()
{
	ll i, j, a, b;
	
	scanf("%lld", &n);
	
	l1 = l2 = 1e9; r1 = r2 = 0;
	
	for(i=1; i<=n; i++){
		scanf("%lld%lld", &a, &b);
		V.emplace_back(a, i);
		V.emplace_back(b, i);
		l1 = min(l1, min(a, b));
		l2 = min(l2, max(a, b));
		r1 = max(r1, min(a, b));
		r2 = max(r2, max(a, b));
	}
	
	ans = (r1 - l1) * (r2 - l2);
	
	sort(V.begin(), V.end());
	
	for(i=0, j=0; i<n+n; i++){
		for(; j<n+n && cnt<n; j++){
			S[V[j].second] ++;
			if(S[V[j].second] == 1) cnt ++;
		}
		
		if(cnt == n){
			ans = min(ans, (r2 - l1) * (V[j - 1].first - V[i].first));
		}
		
		S[V[i].second] --;
		if(S[V[i].second] == 0) cnt --;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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


int main(){
  ll x;
  cin >> x;
  ll ans;
  ans = (x / 11) * 2;
if(x % 11 != 0){
  if(x % 11 <= 6) ans++;
  else ans += 2;
}
  print(ans);
}




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

ll number[2 * 100005];
ll sub_number[2 * 100005];

int main() {
    int N;
    ll min_ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> number[i];
        sub_number[i] = number[i] - i;
    }
    sort(sub_number + 1, sub_number + N + 1);
    ll b = sub_number[(N + 1) / 2];
    for (int i = 1; i <= N; i++) min_ans += abs(sub_number[i] - b);
    cout << min_ans << endl;
    return 0;
}

Measured memory_bytes: 3328
n = int(input())
s = input()

candidates = [0 for i in range(10 ** 3)]

count = 0
for i in range(1000):
    tmp_pass = '{:03}'.format(i)

    index_0 = s.find(tmp_pass[0])
    if index_0 != -1 and index_0 < len(s) - 2:
        s_1 = s[index_0 + 1:]
        index_1 = s_1.find(tmp_pass[1])
        if index_1 != -1 and index_1 < len(s_1) - 1:
            s_2 = s_1[index_1 + 1:]
            # print(tmp_pass)
            # print(s_2)
            # index_2 = s_2.find(tmp_pass[2])
            # print(index_2)
            if s_2.find(tmp_pass[2]) != -1:
                count += 1

print(count)


Measured memory_bytes: 3188
while true do
s=STDIN.gets
a =s.split[0].to_i
op=s.split[1]
b =s.split[2].to_i
break if op == "?"
puts sprintf("%d\n",a+b) if op == "+"
puts sprintf("%d\n",a-b) if op == "-"
puts sprintf("%d\n",a*b) if op == "*"
puts sprintf("%d\n",a/b) if op == "/"
end

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

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

    vector<Int> A(N);
    rep(i,N) cin >> A[i];

    vector<Int> S = {A[0]};
    rep1(i,N-1) S.push_back(S[i-1]+A[i]);

    Int ans = 1e18;
    for(int i=2; i<N-1; i++){
        // 左側 [0, i) 
        Int left_sum = S[i-1];
        int mid_l = lower_bound(S.begin(), S.begin()+i, left_sum/2) - S.begin();

        pair<Int,Int> left = {S[mid_l], left_sum-S[mid_l]};
        if(mid_l != 0){
            pair<Int,Int> left2 = {S[mid_l-1], left_sum-S[mid_l-1]};
            if (abs(left2.first-left2.second) < abs(left.first-left.second)){
                left = left2;
            }
        }

        int mid_r = lower_bound(S.begin()+i, S.end(), (S.back() + left_sum)/2) - S.begin();
        pair<Int,Int> right = {S[mid_r] - left_sum, S.back()-S[mid_r]};
        if(mid_r != i){
            pair<Int,Int> right2 = {S[mid_r-1] - left_sum, S.back()-S[mid_r-1]};
            if (abs(right2.first-right2.second) < abs(right.first-right.second)){
                right = right2;
            }
        }

        Int M = max(left.first, max(left.second, max(right.first, right.second))); 
        Int m = min(left.first, min(left.second, min(right.first, right.second)));
        ans = min(ans, M-m);
    }

    cout << ans << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, k) ans += p[i];

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

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<memory.h>
using namespace std;
int main()
{
  int n,m,ans,c[1000001];
  string s;
  while(cin>>n>>m>>s,n){
    memset(c,0,sizeof(c));
    for(int i=m-3;i>=0;i--){
      if(s.substr(i,3)=="IOI")c[i]=c[i+2]+1;
    }
    ans=0;
    for(int i=0;i<m;i++)if(c[i]>=n)ans++;
    cout<<ans<<endl;
  }
}

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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,P[10]={},Q[10]={},n[10]={},a=1,b=1,x=1;
    cin>>N;

    for(int i=0;i<N;i++){
        n[i]=i+1;
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        cin>>Q[i];
    }

    do{

        if(memcmp(n,P,sizeof(n))==0)a=x;
        if(memcmp(n,Q,sizeof(n))==0)b=x;
        x++;

    }while(next_permutation(n,n+N));


    cout<<abs(a-b)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.track", "r", stdin );
	string str = "";
	int n = 24;
	int i,j;

	map<double, pair<int, int> > race; // time, number of person, number of race

	for (i = 0; i < n; ++i){
		int number = 0;
		double time = 0.0;

		getline (cin, str );
		stringstream ss (str );

		ss >> number >> time;

		race.insert (make_pair (time, make_pair (number, i / 8) ) );
	} // end for
	
	vector<map<double, int> > res;

	for (i = 0; i < 4; ++i){
		j = 0;
		map<double, pair<int, int> >::iterator it = race.begin();
		for (; it != race.end(); ++it ){
			double time = (*it).first;
			double num  = (*it).second.first;
			double ra   = (*it).second.second;
			if (( i == 3 || ra == i ) && j < 2){
				map<double, int> r;
				r.insert (make_pair (time, num ) );
				res.push_back (r);
				++j;
				race.erase (it);
			} // end if
		} // end for
	} // end for

	for (i = 0; i < 8; ++i){
		map<double, int>::iterator itres = res[i].begin();
		for (; itres != res[i].end(); ++itres){
			double time = (*itres).first;
			int num = (*itres).second;
			printf ("%d %.2f\n", num, time );
		} // end for
	} // end for

	return 0;
}

Measured memory_bytes: 0
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val aList = readLongList()

    var ans = ModInt(0)
    var e = ModInt(1)
    val two = ModInt(2)
    for (i in 0 until 60) {
        val countOne = aList.count { ((it shr i) and 1) == 1L }
        val countZero = aList.size - countOne
        ans += ModInt(countOne.toLong()) * ModInt(countZero.toLong()) * e
        e *= two
    }
    println(ans)
}

/** always positive number (Use for minus)
 * MODは素数（フェルマーの小定理を利用するため）
 */
class ModInt(x: Long, val MOD: Long = 1000000007L) {
    val x = ((x % MOD) + MOD) % MOD

    operator fun unaryMinus() = ModInt(-x, MOD)

    operator fun plus(other: ModInt): ModInt {
        var value = x + other.x
        if (value >= MOD) { value -= MOD }
        return ModInt(value, MOD)
    }

    operator fun minus(other: ModInt): ModInt {
        var value = x + MOD - other.x
        if (value >= MOD) { value -= MOD }
        return ModInt(value, MOD)
    }

    operator fun times(other: ModInt): ModInt {
        val value = (x * other.x) % MOD
        return ModInt(value, MOD)
    }

    operator fun div(other: ModInt) = this * other.inverse()

    override fun toString() = x.toString()


    /** O(log(n)) */
    private fun pow(n: Long): ModInt {
        var ret = ModInt(1L, MOD)
        var x = this
        var k = n
        while (k > 0) {
            if ((k and 1L) == 1L) { ret *= x }
            x *= x
            k = k shr 1
        }
        return ret
    }

    /**  O(log(MOD)) */
    private fun inverse() = pow(MOD - 2)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 80684
import java.util.*;
class Main{
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        if (n % 2 == 1) {
            n = n / 2 + 1;
        } else if (n % 2 == 0) {
            n = n / 2;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 22996
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

template<typename T>
class LineSet {
private:
  std::map<T,T> L;// 傾き→切片
  T max_a, min_a;
public:
  LineSet(T ai) : L(), max_a(-ai), min_a(ai) {}
  void push(T a, T b){// push ax + b
    min_a = std::min(min_a,a);
    max_a = std::max(max_a,a);
    
    if(L.empty()){
      L[a] = b;
      return;
    }
    
    if(L.size() == 1){
      if(L.find(a) != L.end())
        L[a] = std::min(L[a],b);
      else
        L[a] = b;
      return;
    }

    if(a == min_a or a == max_a){
      if(L.find(a) != L.end())
        L[a] = std::min(L[a],b);
      else
        L[a] = b;
    }

    if(L.find(a) == L.end()){
      auto ll = L.lower_bound(a);
      auto lr = prev(ll);
      if((a-lr->first)*(b-ll->second) >= (ll->first-a)*(lr->second-b))
        return;
    }else{
      L[a] = std::min(L[a],b);
    }

    if(L.find(a) == L.end() or L[a] != b){
      return;
    }
    
    while(1){
      auto ll = L.find(a);
      if(ll == L.begin()) break;
      auto lm = prev(ll);
      if(lm == L.begin()) break;
      auto lr = prev(lm);
      if((lm->first-lr->first)*(lm->second-ll->second) < (ll->first-lm->first)*(lr->second-lm->second))
        break;
      L.erase(lm);
    }
    while(1){
      auto lr = L.find(a);
      auto lm = next(lr);
      if(lm == L.end()) break;
      auto ll = next(lm);
      if(ll == L.end()) break;
      if((lm->first-lr->first)*(lm->second-ll->second) < (ll->first-lm->first)*(lr->second-lm->second))
        break;
      L.erase(lm);
    }
  }
  T get(T x){
    // T ans = 2e18;
    // for(auto [a, b] : L){
    //   ans = std::min(ans,a*x+b);
    // }
    // return ans;
    if(L.size() == 1){
      auto [a, b] = *L.begin();
      return a*x + b;
    }
    T la = min_a, ra = max_a;
    while(ra-la > 1){
      T m = (la+ra)/2;
      auto r = L.upper_bound(m);
      assert(r != L.begin());
      assert(r != L.end());
      auto l = prev(r);
      if(l->first*x+l->second < r->first*x+r->second){
        ra = l->first;
      }else{
        la = r->first;
      }
    }
    auto [a, b] = *L.lower_bound(la);
    T ret = a*x+b;
    auto itr = L.lower_bound(la);
    if(itr != L.end() and next(itr) != L.end()){
      auto nex = next(itr);
      ret = std::min(ret,nex->first*x + nex->second);
    }
    if(itr != L.begin()){
      auto pre = prev(itr);
      ret = std::min(ret,pre->first*x + pre->second);
    }
    return ret;
  }
};


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

int main(){
  long long N, C;
  cin >> N >> C;
  vector<long long> H(N);
  LineSet<long long> cht(1e9);
  for(int i = 0; i < N; ++i){
    cin >> H[i];
  }
  vector<long long> dp(N);
  cht.push(-2*H[0],H[0]*H[0]);
  for(int i = 1; i < N; ++i){
    dp[i] = cht.get(H[i]) + H[i]*H[i] + C;
    cht.push(-2*H[i],dp[i]+H[i]*H[i]);
  }
  cout << dp.back() << endl;
}


Measured memory_bytes: 18848
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
q=gi
ar=[]
ans=[]
q.times do
  inp=gsmi
  case inp[0]
  when 0
    if inp[1]==0
      ar.unshift inp[2]
    else
      ar<<inp[2]
    end
    
  when 1
    ans<<ar[inp[1]]
  when 2
    if inp[1]==0
      ar.shift
    else
      ar.pop
    end
  end
end
puts ans


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

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    int sum = 0;
    rep(i,n){
        cin >> w[i];
        sum += w[i];
    }
    int mini = sum;
    int prefix_sum = 0;
    rep(i,n){
        cin >> w[i];
        prefix_sum += w[i];
        mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

k = 0
for i in range(10**3):
    if i * (i-1) // 2 == n:
        k = i
        break
else:
    print("No")
    exit()

ans = [[] for _ in range(k)]
cnt = 1
for i in range(k):
    for j in range(i+1, k):
        ans[i].append(cnt)
        ans[j].append(cnt)
        cnt += 1

print("Yes")
print(k)
for i in range(k):
    print(k-1, *ans[i])


Measured memory_bytes: 9416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm> 

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e4;

int a,b,c;

char s[N];

int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	cin>>a;
	scanf("%s",s+1);
	b=0;
	fo(i,1,a)b=b+(s[i]=='R');
	if(b>a-b)puts("Yes");else puts("No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int r,c;
        r=sc.nextInt();
        c=sc.nextInt();
        
        int table[][]=new int[r+1][c+1];
        
        int sum;
        int i,j,k;
        for(i=0;i<r;i++){
            sum=0;
            for(j=0;j<c;j++){
                table[i][j]=sc.nextInt();
                sum+=table[i][j];
            }
            table[i][j]=sum;
        }
        for(j=0;j<c+1;j++){
            for(k=0;k<r;k++)table[i][j]+=table[k][j];
        }
        
        for(i=0;i<r+1;i++){
            for(j=0;j<c+1;j++){
                if(j==0)System.out.printf("%d",table[i][j]);
                else System.out.printf(" %d",table[i][j]);
            }
            System.out.printf("\n");
        }

    }
}


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

int main() {
    int t, n;
    while (cin >> t, t) {
        cin >> n;
        int total = 0;
        for (int i = 0; i < n; i++) {
            int s, f;
            cin >> s >> f;
            total += f - s;
        }
        if (total >= t) cout << "OK" << endl;
        else cout << t - total << endl;
    }
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"

using namespace std;

int main() {
	string A, B, C;
	cin >> A >> B >> C;

	if (A.back() == B.front() && B.back() == C.front()) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[2];
    a[0] = n % 10;
    a[1] = n / 10;
    if(a[0] == 9 || a[1] == 9){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
    IOS;
    int T=1;
    //cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        if(s[2]==s[3]&&s[4]==s[5])
            cout<<"Yes";
        else
            cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
w = np.array(input().split(),dtype=np.int64)
min = (np.sum(w))
for i in range(n):
    if min > np.absolute(np.sum(w[0:i]) - np.sum(w[i:])):
        min = np.absolute(np.sum(w[0:i]) - np.sum(w[i:]))
print(min)

Measured memory_bytes: 20776
#include<stdio.h>
int main(void)
{
	int i,j,h,w;
	char a[105][105];
	scanf("%d %d",&h,&w);
	for(i=1;i<=h;i++) scanf("%s",a[i]);
	for(i=0;i<=h+1;i++){
		for(j=0;j<=w+1;j++){
			if(i==0 || i==h+1) printf("#");
			else {
				if(j==0 || j==w+1) printf("#");
				if(j>=0 && j<w) printf("%c",a[i][j]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  vector<int> l(n);
  int west = 0;
  for(int i = 0; i < n; i++){
    l[i] = west;
    if(s[i] == 'W') west++;
  }
  int east = 0;
  int ans = 1e9;
  for(int i = n-1; i >= 0; i--){
    ans = min(l[i] + east, ans);    
    if(s[i] == 'E') east++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1812