akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
int main(){
string s;
  ll k;
  cin>>s>>k;
  ll memo=0;
  for(ll i=0;i<s.length();i++){
  if(s[i]!='1'||(k-1)==i){
    memo=i;
    break;
  }
  }
  cout<<s[memo];
 
return 0;
}


Measured memory_bytes: 256
// Aizu Vol-2 0298: Bus Timetable
// 2017.8.6

#include <stdio.h>

#define MAX 200
int t[MAX + 2], N;

int main()
{
	int i, j, k, h, m;


	for (N = j = 0; j < 2; j++) {
		scanf("%d", &k);
		for (i = 0; i < k; i++) {
			scanf("%d%d", &h, &m);
			t[N++] = h * 100 + m;
		}
	}
	for (i = 0; i < N; i++) {
		k = i;
		for (j = i + 1; j < N; j++) if (t[k] > t[j]) k = j;
		if (k != i) { int s = t[k]; t[k] = t[i], t[i] = s; }
	}
	printf("%d:%02d", t[0] / 100, t[0] % 100);
	for (i = 1; i < N; i++) {
		if (t[i] != t[i - 1]) printf(" %d:%02d", t[i] / 100, t[i] % 100);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 616
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region UnionFind
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);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

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

int main()
{
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m); rep(i, m)
	{
		int x, y; cin >> x >> y;
		--x, --y;
		a[i] = x; b[i] = y;
	}
	int res = 0;
	rep(i, m)
	{
		UnionFind uf(n);
		rep(j, m)
		{
			if (i == j)continue;
			uf.merge(a[j], b[j]);
		}
		bool bridge = false;
		rep(j, n)if (!uf.issame(0, j))bridge = true;
		if (bridge)++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
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 mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
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<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll r; cin >> r;
    cout << r*r << endl;
}

Measured memory_bytes: 764
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		vector<char> before(n);
		vector<char> after(n);

		REP(i, n) {
			cin >> before[i] >> after[i];
		}

		int m;
		cin >> m;
		string str;

		REP(i, m) {
			char c;
			cin >> c;

			REP(j, n) {
				if(c == before[j]) {
					c = after[j];
					break;
				}
			}

			str.push_back(c);
		}

		cout << str << endl; 
	}
}

Measured memory_bytes: 1336
package main

import (
	"fmt"
	"os"
)

func run() int {
	var a1, a2, a3 int
	fmt.Scanf("%d %d %d\n", &a1, &a2, &a3)

	if a1+a2+a3 >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

ll INF = 1e13;

int main() {
    ll k; cin >> k;
    ll n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i ,n ) cin >> a.at(i);

    ll ans = INF;
    sort(a.begin(), a.end());

    ll sum = 0;
    ll gap = 0;
    rep(i, n-1){
        gap = max(gap, a.at(i+1)-a.at(i));
        sum += a.at(i+1) - a.at(i);  
    }

    sum +=  k - a.at(n-1) + a.at(0);
    gap = max(gap, k -a.at(n-1) + a.at(0));
    sum = sum - gap;

    cout << sum << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int M=0;
  for(int i=1;i<=N;i++){
    int c=0;
    int tmp =i;
    while(1){
      if(tmp%2==1 || tmp<2) break;
      tmp /=2;
      c++;
    }
    M = max(M,c);
  }
  cout << pow(2,M) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
bool isso(long long int a) {
	if (a == 1 || a == 0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
pair<bool,int> caves[1199][1199];
pair<int,int> dp[1199][1199];
vector<pair<int, int>>places(1010000);

int main() {
	{
		for (int i = 0; i < 1199; ++i) {
			for (int j = 0; j < 1199; ++j) {
				caves[i][j] = { false,-1 };
			}
		}
		int num = 1;
		int ny = 600;
		int nx = 600;
		int roopnum =2;
		int way = 2;
		while (num <= 1000000) {
			for (int i = 0; i < roopnum / 2; ++i) {
				caves[ny][nx] = { isso(num),num };
				places[num] = { ny,nx };
				ny += dy[way]; nx += dx[way];
				num++;
			}
			roopnum++;
			way = (way + 1) % 4;
		}
	}
	while (1) {
		int m, n; cin >> m >> n;
		if (!m)break;
		for (int i = 0; i < 1199; ++i) {
			for (int j = 0; j < 1199; ++j) {
				dp[i][j] = { -1,-999999 };
			}
		}
		int ny = places[n].first;
		int nx = places[n].second;
		if (caves[ny][nx].first) {
			dp[ny][nx] = { caves[ny][nx].second,1 };
		}
		else {
			dp[ny][nx] = { -1,0 };

		}
		for (int y = 0; y < 1198; ++y) {
			for (int x = 1; x < 1198; ++x) {
				for (int ax = -1; ax <= 1; ++ax) {
					const int newy = y + 1;
					const int newx = x + ax;
					bool so = (caves[newy][newx].first)&&(caves[newy][newx].second <= m);
					const int newsonum = dp[y][x].second + so;
					if (dp[newy][newx].second < newsonum) {
						dp[newy][newx].second = newsonum;
						if (so) {
							dp[newy][newx].first = caves[newy][newx].second;
						}
						else {
							dp[newy][newx].first = dp[y][x].first;
						}
					}
					else if (dp[newy][newx].second == newsonum) {
						if (so) {
							dp[newy][newx].first = caves[newy][newx].second;
						}
						else {
							dp[newy][newx].first = max(dp[newy][newx].first, dp[y][x].first);
						}
					}
				}
			}
		}
		int maxso = 0;
		int maxnum = 0;
		for (int x = 0; x < 1199; ++x) {
			if (maxso == dp[1198][x].second) {
				maxnum = max(maxnum, dp[1198][x].first);
			}
			else if(maxso<dp[1198][x].second){
				maxso = dp[1198][x].second;
				maxnum = dp[1198][x].first;
			}
		}
		cout << maxso << " " << maxnum << endl;

	}

	return 0;
}

Measured memory_bytes: 33104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
    } 
    int d = 0;
    for (auto x : mp) {
        d += x.se - 1;
    }
    d += d%2;

    int ans = n - d;

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

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int X;

void solve(){
    cout << 10 - X / 200 << endl;
}

int main(){
    cin >> X;

    solve();
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;

int main() {
	int x, y, s;
	while(cin >> x >> y >> s, x|y|s) {
		int ans=0;
		for(int i=1; i<s; i++) {
			int a = i*(100+x)/100;
			int b = ceil((s-a)*100.0/(100+x));
			if(b <= 0 || a+b*(100+x)/100 != s) continue;
			ans = max(ans, i*(100+y)/100+b*(100+y)/100);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	
	long long i,j,k,n,m,p=0;
	cin>>i>>j;
	m=(i*j)/( __gcd(i,j));
	
	cout<<m;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

bool comp_output(pair<ll, pair<ll, pl>> a, pair<ll, pair<ll, pl>> b){
    return a.S.S.F < b.S.S.F;
}

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

    // solution comes here

    ll N;   cin >> N;
    vl even(N/2), odd(N/2);
    bool ALLSAME=true;
    rep(i, N/2) {
        cin >> odd[i] >> even[i];
        if(odd[i]!=even[i] or (i and odd[i-1]!=odd[i]))
            ALLSAME = false;
    }

    if(ALLSAME) {
        cout << N/2 << nl;
        return 0;
    }

    sortup(odd);
    sortup(even);

    ll ocnt=1, ecnt=1, oMAX=1, oMIN=1, eMAX=1, eMIN=1, O, E;
    for(ll i=1; i<N/2; i++) {
        if(odd[i-1]==odd[i]) ocnt++;
        else ocnt=1;
        if(ocnt>=oMAX) {
            O = odd[i];
            oMIN = oMAX;
            oMAX = ocnt;
        }
        else if(ocnt > oMIN) oMIN = ocnt;

        if(even[i-1]==even[i]) ecnt++;
        else ecnt=1;
        if(ecnt>=eMAX) {
            E = even[i];
            eMIN = eMAX;
            eMAX = ecnt;
        }
        else if(ecnt > eMIN) eMIN = ecnt;
    }

    if(O!=E) cout << N - oMAX - eMAX << nl;
    else cout << min(N-oMAX-eMIN, N-oMIN-eMAX) << nl;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int,string> Pis;

vector<bool> IsPrime;
void sieve(int max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    }
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(int i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(int j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
int main(){
  int x;
  cin>>x;
  sieve(x);
  while(IsPrime[x]==0){
    x++;
    sieve(x);
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
class SegTree:
	"""
	0-indexed
	"""
	def __init__(self,size,func,init_val,undef):
		self.specSize = size
		self.datSize = 1
		self.compareFunc = func		# suppose to min or max
		self.INIT_VAL = init_val	# 0 etc
		self.UNDEFINED_VAL = undef	# 1e18 -1e18 etc
		# num:size以上の最小の2のべき乗
		self.datSize = 2**size.bit_length()

		# the tree is implemented by sequencial list
		# (1-indexed, 0 is not use.)
		self.datTree = [self.INIT_VAL for _ in range(2*self.datSize+1)]

	def update(self, i, val ):
		"""
		i: index(1-ordered)
		"""
		# i -= 1	# 1-orderで指定され、内部では0-Order想定?
		# i += (self.datSize - 1)
		i += self.datSize
		self.datTree[i] = val
		while 1 < i:
			i >>= 1
			self.datTree[i] = self.compareFunc( self.datTree[i<<1|0], self.datTree[i<<1|1] )

	def query(self,a,b):
		return self.query_(a,b,0,0,self.datSize)

	def query_(self,a,b,i,l,r):
		""" get minimun/maximum value of range[a,b)
		all 1-indexed
		i is the root vertex of search 
		l,r is range of the root vertex(not use)
		"""
		ret = self.UNDEFINED_VAL

		a += self.datSize
		b += self.datSize
		while a < b:
			if b & 1:
				b -= 1
				ret = self.compareFunc(ret, self.datTree[b])

			if a & 1:
				ret = self.compareFunc(ret, self.datTree[a])
				a += 1

			a >>= 1; b >>= 1

		return ret

	def printTree(self):
		print(self.datTree)


def LongestSeaquence(A,K):
	N = len(A)
	lis = 0

	# === Range Maximum Query ===
	MAX_A = max(A)
	tree = SegTree(MAX_A+1,max,0,-1e18)
	# tree.update( 0, 1 )

	for n in range(N):
		x = A[n]
		l = max(0,x-K)
		r = min(MAX_A,x+K)
		tmp = tree.query(l,r+1)+1
		tree.update( x, tmp )
		lis = max(lis, tmp)

	return lis

def main():
	N,K = map(int,input().split())
	A = [ int(input()) for _ in range(N)]

	print(LongestSeaquence(A,K))



if __name__ == "__main__":
	main()

Measured memory_bytes: 166904
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n , m ,i;
	cin >> n >> m;
	int tot=0;
	vector<int> a(n);
	for(i = 0 ;i<n ;i++){
		cin >> a[i];
		tot += a[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(), a.end());
	if(a[m-1]*4*m >= tot){	cout<<"Yes";}
	else{	cout<<"No";	}
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var A = AB[0];
            var B = AB[1];
            Console.WriteLine(12<A?B:5<A?B/2:0);
        }
    }
}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
#-----

def count_brackets(brackets):
    L = R = 0
    L_rev = R_rev = 0
    max_R = -float("inf")
    max_L = -float("inf")
    
    
    for i in range(len(brackets)):
        if brackets[i] == "(":
            L += 1
        else:  # brackets[i] == ")"
            R += 1
            max_R = max(max_R, R - L)
        
        if brackets[len(brackets)-1-i] == "(":
            L_rev += 1
            max_L = max(max_L, L_rev - R_rev)
        else:  # brackets[len(brackets)-1-i] == ")"
            R_rev += 1
    
    if max_L < 0: max_L = 0
    if max_R < 0: max_R = 0
    
    return max_L, max_R


tmp_cnt1 = []  #  the number of "("  >=  the number of ")"
tmp_cnt2 = []  #  the number of "("  <   the number of ")"

for S in S_list:
    cnt_L,cnt_R = count_brackets(S)

    if cnt_L == cnt_R == 0:
        continue
    
    if cnt_L >= cnt_R:
        tmp_cnt1.append( (cnt_L,cnt_R) )
    else:
        tmp_cnt2.append( (cnt_L,cnt_R) )


tmp_cnt1.sort(key=lambda x: x[1])
tmp_cnt2.sort(key=lambda x: -x[0])


sum_bracket = 0
flag = True

for cnt_L,cnt_R in (tmp_cnt1 + tmp_cnt2):
    sum_bracket -= cnt_R
    if sum_bracket < 0:  flag = False
    
    sum_bracket += cnt_L
    if sum_bracket < 0:  flag = False
    
    if flag == False:
        break


if (sum_bracket == 0) and flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 245900
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;
typedef pair<int, int> pii;
typedef pair<double, pii> pdpii;

const double EPS = 1e-9;

class UnionFindTree {
private:
	vector<int> parent;
	vector<int> rank;

public:
	explicit UnionFindTree(int n = 0) :
		parent(n), rank(n)
	{
		for(int i = 0; i < n; ++i){ parent[i] = i; }
	}
	int find(int x){
		if(parent[x] == x){ return x; }
		parent[x] = find(parent[x]);
		return parent[x];
	}
	int unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y){ return x; }
		if(rank[x] < rank[y]){
			parent[x] = y;
			return y;
		}else if(rank[x] > rank[y]){
			parent[y] = x;
			return x;
		}else{
			parent[y] = x;
			++rank[x];
			return x;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(3);
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		vector<double> x(n), y(n), z(n), r(n);
		for(int i = 0; i < n; ++i){
			cin >> x[i] >> y[i] >> z[i] >> r[i];
		}
		vector< vector<double> > mat(n, vector<double>(n));
		for(int i = 0; i < n; ++i){
			for(int j = i + 1; j < n; ++j){
				double dx = x[i] - x[j], dy = y[i] - y[j], dz = z[i] - z[j];
				double dist = sqrt(dx * dx + dy * dy + dz * dz);
				double rsum = r[i] + r[j];
				if(dist > rsum){
					mat[i][j] = mat[j][i] = dist - rsum;
				}else{
					mat[i][j] = mat[j][i] = 0.0;
				}
			}
		}
		vector<pdpii> edges(n * (n - 1) / 2);
		for(int i = 0, k = 0; i < n; ++i){
			for(int j = i + 1; j < n; ++j, ++k){
				edges[k] = pdpii(mat[i][j], pii(i, j));
			}
		}
		sort(edges.begin(), edges.end());
		UnionFindTree uft(n);
		double answer = 0.0;
		for(int i = 0; i < edges.size(); ++i){
			double c = edges[i].first;
			int a = edges[i].second.first, b = edges[i].second.second;
			if(uft.same(a, b)){ continue; }
			answer += c;
			uft.unite(a, b);
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1484
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B
#???????????? 17:55~

def maxHeapify(heap, index):
    left_index = 2 * index
    right_index = 2 * index + 1

    if left_index < len(heap) and heap[left_index] > heap[index]:
        largest_index = left_index
    else:
        largest_index = index

    if right_index < len(heap) and heap[right_index] > heap[largest_index]:
        largest_index = right_index

    if largest_index != index:
        heap[index], heap[largest_index] = heap[largest_index], heap[index]
        maxHeapify(heap, largest_index)
    
def main():
    n_node = int(input())
    target_list = [""] + [int(n) for n in input().split()]
    for i in range(1, int(len(target_list) / 2) + 1)[::-1]:
        maxHeapify(target_list, i)
        
    print(*target_list)
if __name__ == "__main__":
    main()

Measured memory_bytes: 65560
A, B, C, D = gets.split(' ').map(&:to_i)

if C<D
  n,m = C,D 
else 
  n,m = D,C
end
while m%n != 0
  n,m = m%n, n
end

lcm = C*D/n

p B - A + 1 - ((B/C)-((A-1)/C)) - ((B/D)-((A-1)/D)) + ((B/lcm)-((A-1)/lcm))

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

int main(void) {
  int n;

  std::string str;

  std::cin >> n;

  if (n <= 999) {
    std::cout << "ABC" << std::endl;
  } else {
    std::cout << "ABD" << std::endl;
  }

  return 0;
}

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

int main() {
    int n,k; cin >> n >> k;
    vector<int> l(n);
    for(int i =0 ;i < n; i ++) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = 1; i <= k; i ++) {
        ans += l[n-i];
    }
    cout << ans << endl;
}

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

int main()
{
  unsigned int N, M;
  std::cin >> N >> M;
  std::vector<unsigned long long> highArray(N);
  std::vector<bool> goodArray(N, true);
  for(auto& high : highArray)
  {
    unsigned long long H;
    std::cin >> H;
    high = H;
  }
  
  for(int i = 0; i < M; ++i)
  {
    unsigned int A, B;
    std::cin >> A >> B;
    
    const int aIdx = A - 1;
    const int bIdx = B - 1;
    if(goodArray[aIdx])
	    goodArray[aIdx] = highArray[aIdx] > highArray[bIdx];
    
    if(goodArray[bIdx])
	    goodArray[bIdx] = highArray[aIdx] < highArray[bIdx];
  }
  
  int cnt = 0;
  for(const auto& good : goodArray)
  {
    if(good)
      ++cnt;
  }
  
  std::cout << cnt << std::endl;
  return 0;
}


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

using namespace std;
using ll = long long;

#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
#define in cin
#define out cout

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

	int n, k;
	cin >> n >> k;
	int v;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		cin >> v;
		if(v >= k) {
			cnt++;
		}
	}
	cout << cnt << endl;
}



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

int main(){
  
  int a;
  	cin >> a;
    
  if (a==0) cout << 0 <<endl;
  	else if (a == 111) cout << 3 <<endl;
  	else if (a == 1 || a== 10 || a == 100) cout << 1 << endl;
      else cout << 2 <<endl;
}

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

int N, M;
vector< vector<bool> > route(0);
vector< bool > reached(0);

void search(int &count, int P){
  
  reached.at(P-1) = true;
  for(int i=0; i<N; i++){
    if(!reached.at(i)) goto skip;
  }
  count++;
  
  skip:
  
  for(int i=0; i<N; i++){
    if(route.at(P-1).at(i) && !reached.at(i)) search(count, i+1);
  }
  
  reached.at(P-1) = false;
  return;
  
}

int check(){
  
  int count = 0;
  search(count, 1);
  return count;
  
}

int main() {
  
  cin >> N >> M;
  for(int i=0; i<N; i++){
    reached.push_back(false);
    route.push_back(vector<bool>(N, false));
  }
  for(int i=0; i<M; i++){
    int a, b; cin >> a >> b;
    route.at(a-1).at(b-1) = true;
    route.at(b-1).at(a-1) = true;
  }
  
  int ans = check();
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   for(ll i=0;i<n;i++)cin>>arr[i];
   ll hold[n];
   memset(hold,0,sizeof(hold));
   bool pos = 1;
   vector<ll> v;
   for(ll i=n-1;i>-1;i--)
   {
       ll cnt = 0;
       for(ll j=2*(i+1);j<=n;j+=i+1)
            cnt+=hold[j-1];
       
       if(cnt%2 == arr[i])
            hold[i] = 0;
       else 
       {
           hold[i] = 1; 
           v.pb(i+1);
       }
       
       
   }
   
   cout<<v.size()<<"\n";
   for(ll i=0;i<v.size();i++)
        cout<<v[i]<<" ";
   
   return 0;
}

Measured memory_bytes: 5108
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

h, w, kk = na()
mp = []
for i in range(h):
    mp.append(ns())

ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        ct = 0
        for k in range(h):
            for l in range(w):
                if i>>k&1:
                    if j>>l&1:
                        if mp[k][l] == "#":
                            ct += 1
        if ct == kk:
            ans += 1
print(ans)


Measured memory_bytes: 68676
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c=0
for i in range(0, N):
    if B[i]-A[i]>=0:
        c+=A[i]
        B[i]=B[i]-A[i]
    else:
        c+=B[i]
        B[i]=0
    if A[i+1]-B[i]>=0:
        A[i+1]=A[i+1]-B[i]
        c+=B[i]
    else:
        c+=A[i+1]
        A[i+1]=0
print(c)

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

int main(){
  int N;
  cin >> N;
  vector<long long> monsters(N+1);
  for (int i = 0; i < N+1; i++) {
    cin >> monsters.at(i);
  }
  reverse(monsters.begin(),monsters.end());
  
  vector<long long> savers(N);
  for (int i = 0; i < N; i++) {
    cin >> savers.at(i);
  }
  reverse(savers.begin(),savers.end());
  
  long long kotae;
  long long nokori = monsters.at(0);
  long long a;

  for (unsigned int i = 0; i < savers.size() ; i++) {
    a = nokori + monsters.at(i+1);
    if (savers.at(i) >= a) {
      kotae = kotae + a;
      nokori = 0;
    }
    else{
      kotae = kotae + savers.at(i);
      if (savers.at(i) >= nokori) {
	nokori = a - savers.at(i);
      }
      else {
	nokori = a - nokori;
      }
    }
  }

  cout << kotae <<endl;
  
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long LL;
typedef pair<int,int>PII;
const LL inf = 1 << 30;
const int mod = 998244353;
map<int,int>mp;
map<int,int>mp1;
map<PII,int>::iterator it;
const int maxn = 1e5;
struct point{
    int x,y,flag;
}s,q;
int n;
int a[100005];
 
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	double ans = a[n] * 1.0 / 2;
	double mi = inf;
	int num;
	for(int i = 1; i <= n - 1; i++)
	{
		if(abs(a[i] - ans) < mi)
		{
			num = a[i];
			mi = abs(a[i] - ans);
		}
	}
	printf("%d %d\n", a[n], num);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int sum[514][514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, Q, l, r, p, q;
	cin>>n>>m>>Q;
	REP(i, m){
		cin>>l>>r;
		FOR(j, r, n+1){
			++sum[l][j];
		}
	}
	REP(i, Q){
		cin>>p>>q;
		int ans=0;
		FOR(j, p, q+1){
			ans+=sum[j][q]-sum[j][p-1];
		}
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>

using namespace std;


int kousin(int num, int cost[10], int c[10][10]){
    int pre_cost = cost[num];
    int now = 0;
    for (int i = 0; i < 10; i++){
        //printf("cost_vec[%d] : %d\n",i,cost[i]);
    }
    //printf("*********************\n");

    for(int i = 0; i < 10; i++){
        now = pre_cost + c[i][num];
        if(now < cost[i]){
            cost[i] = now;
            kousin(i,cost,c);
        }
    }

    return cost[10];
}

int main(){
    int H,W;
    cin >> H >> W;
    int c[10][10];
    int A[H][W];
    for(int i = 0; i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i <H; i++){
        for(int j =0; j<W; j++){
            cin >> A[i][j];
        }
    }

    //printf("Lets Start!\n");

    // それぞれの数字の1まで移動させるコスト
    int cost[10];

    for(int i = 0; i < 10; i++){
        cost[i] = c[i][1];
    }
    for(int i = 0; i < 10; i++){
        kousin(i,cost,c);
    }

    int result = 0;

    for(int i = 0; i <H; i++){
        for(int j =0; j<W; j++){
            if(A[i][j] != -1){
                result += cost[A[i][j]];
            }
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 384
using System;

public class Rounding
{
    public static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries);
        int X = Int32.Parse(input[0]);
        int A = Int32.Parse(input[1]);
        if (X < A)
        {
            Console.WriteLine(0);
        }
        else 
        {
            Console.WriteLine(10);
        }
    }
}

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

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  int now = 0;
  for (char c : s) {
    if (c == 'A' || c == 'C' || c == 'G' || c == 'T') now++;
    else now = 0;
    ans = max(ans, now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static final int INF = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		String s = sc.next();
		char c[] = s.toCharArray();
		int a[] = new int[n];
		for(int i=0;i<n;i++) a[i] = c[i] - '0';
		
		int now = 1;
		int cnt = 0;
		List<Integer> ls = new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(now == a[i]) {
				cnt++;
			}
			else {
				ls.add(cnt);
				cnt = 1;
				now = 1 - now;
			}
		}
		ls.add(cnt);
		
		if(a[n-1] == 0) ls.add(0);
				
		int len = ls.size();
		
		if(len/2<=k) {
			System.out.println(n);
			return;
		}
		
		int sum[] = new int[len+1];
		for(int i=0;i<len;i++) sum[i+1] = sum[i] + ls.get(i);
		
		int ans = 0;
		for(int i=0;i<len;i+=2) {
			if(i + k*2 + 1 >= len + 1)break;
			ans = Math.max(ans,sum[i + k*2 + 1] - sum[i]);			
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 28292
import math
a,b,h,m=map(int,input().split())
h1=h*30+(0.5*m)
m1=m*6
kakudo=min(abs(h1-m1),360-abs(h1-m1))
print(math.sqrt( (a**2)+(b**2)-2*a*b*(math.cos(math.radians(kakudo))) ))

Measured memory_bytes: 9512
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        char[] sca = S.toCharArray();
        BIT[] cnts = new BIT[26];
        for(int i=0;i<26;i++){
            cnts[i] = new BIT(N+10);
        }
        for(int i=0;i<N;i++){
            int ind = sca[i]-'a';
            cnts[ind].addTo(i + 1, 1);
        }
        int Q = sc.nextInt();
        for(int i=0;i<Q;i++){
            int qt = sc.nextInt();
            if(qt == 1){
                int iq=sc.nextInt()-1;
                String cq=sc.next();
                int toc=cq.charAt(0)-'a';
                int fromc = sca[iq]-'a';
                if(fromc != toc) {
                    cnts[fromc].addTo(iq + 1, -1);
                    sca[iq] = cq.charAt(0);
                    cnts[toc].addTo(iq + 1, 1);
                }
            }else{
                int lq=sc.nextInt();
                int rq=sc.nextInt();
                int sum=0;
                for(int k=0;k<26;k++){
                    BIT b = cnts[k];
                    if(b.sumTo(rq)-b.sumTo(lq-1)>0){
                        sum++;
                    }
                }
                System.out.println(sum);
            }
        }


    }
    private static class BIT {
        int[] vals;
        int len;

        BIT(int n) {
            len = n;
            vals = new int[len + 1];
            Arrays.fill(vals, 0);
        }

        public void addTo(int ind, int val) {
            while (ind <= len) {
                vals[ind] += val;
                ind += ind & (-ind);
            }
        }

        public int sumTo(int ind) {
            int sum = 0;
            while (ind > 0) {
                sum += vals[ind];
                ind -= ind & (-ind);
            }
            return sum;
        }
    }
}


Measured memory_bytes: 132812
import sys
input = sys.stdin.readline
S = int(input())
stan=10**9
if S < stan:
	print("0 0 1 0 0 "+str(S))
elif S != 10**18:
	L = S//(stan)
	left = (L+1)*stan - S
	for i in range(1,stan):
		if left%i == 0 and left//i <= stan:
			ans1 = i
			ans2 = left//i
			break
	print("0 0 "+str(stan)+" "+str(ans1)+" "+str(ans2)+" "+str(L+1))
else:
	print("0 0 1000000000 0 1000000000 1000000000")

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n, a, b = 0;
	int m, s;
	vector<P> v;
	while (1)
	{
		v.clear();
		cin >> n; if (n==0)
		{
			return 0;
		}
		REP(i, n)
		{
			cin >> a;
			REP(j, 4){
				cin >> m >> s;
				b = b + m * 60 + s;
			}
			v.push_back(P(b, a));
			b = 0;
		}
		sort(v.begin(), v.end());
		cout << v[0].second << endl
			<< v[1].second << endl
			<< v[n - 2].second << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >>  a >> b >> x;
    if(x<=a+b&&x>=a){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N;
	cin >> N;
	vector<int> V(N), C(N);
	for(int i = 0; i < N; i++) cin >> V[i];
	for(int i = 0; i < N; i++) cin >> C[i];

	int res = 0;
	for(int i = 0; i < N; i++){
		if(V[i] > C[i]) res += V[i] - C[i];
	}	

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var R, S, P int
	fmt.Scan(&R, &S, &P)
	var t []byte
	fmt.Scan(&t)
	// dp[i][j] iまで見たとき、j(0:r,1:s,2:p)出したときのスコア
	dp := make([][]int, n)
	for i := range dp {
		dp[i] = make([]int, 3)
	}
	var ans int
	for i := 0; i < min(k, n); i++ {
		var idx int
		for j := i; j < n; j += k {
			if i == j {
				switch t[j] {
				case 'r':
					dp[j][2] = P
				case 's':
					dp[j][0] = R
				case 'p':
					dp[j][1] = S
				}
			} else {
				dp[j][0] = max(dp[j-k][1], dp[j-k][2])
				dp[j][1] = max(dp[j-k][0], dp[j-k][2])
				dp[j][2] = max(dp[j-k][0], dp[j-k][1])
				switch t[j] {
				case 'r':
					dp[j][2] += P
				case 's':
					dp[j][0] += R
				case 'p':
					dp[j][1] += S
				}
			}
			idx = j
		}
		score := max(max(dp[idx][0], dp[idx][1]), dp[idx][2])
		ans += score
	}
	fmt.Println(ans)
}

type scanner struct {
	sc *bufio.Scanner
}

var sc *scanner

func init() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	sc = &scanner{sc: s}
}

func (s *scanner) nextInts(ints ...*int) {
	for i := range ints {
		s.sc.Scan()
		*ints[i], _ = strconv.Atoi(s.sc.Text())
	}
}

func (s *scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main() {
 int n;cin>>n;
  int v[n],c[n];
  for(int i=0 ;i<n;i++) cin>>v[i];
  for(int i=0 ;i<n;i++) cin>>c[i];
  
  int sum=0;
  
   for(int i=0 ;i<n;i++) {
     if(v[i]>c[i]) sum+=v[i]-c[i];
   }
  
  cout<<sum<<endl;
}


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

int main(void){
  int n;
  cin >> n;
  ll sum = 0LL;
  auto a = vector< ll >(n);
  for(int i = 0;i < n;++i){
    cin >> a[i];
    sum += a[i];
  }
  ll res = numeric_limits<ll>::max();
  ll acc = a[0];
  for(int i = 1;i < n;++i){
    res = min(res, (ll)abs(sum - acc * 2));
    acc += a[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
vector<ll>v ;
ll n,k,r,s,p ;
ll dp[N][4] ;
ll fun(ll i,ll j)
{
    if(i>=n)
        return 0 ;
    else if(dp[i][j]!=-1)
        return dp[i][j] ;
    else
    {
        ll ans=0 ;
        for(ll u=1;u<=3;u++)
        {
            if(u==j)
                continue ;

            if(u==1)
            {
                if(v[i]==2)
                {
                    ans=max(ans,r+fun(i+k,u)) ;
                }
                else
                    ans=max(ans,fun(i+k,u))  ;
            }
            else if(u==2)
            {
                if(v[i]==3)
                {
                    ans=max(ans,s+fun(i+k,u)) ;
                }
                else
                    ans=max(ans,fun(i+k,u))  ;

            }
            else
            {
                if(v[i]==1)
                {
                    ans=max(ans,p+fun(i+k,u)) ;
                }
                else
                    ans=max(ans,fun(i+k,u))  ;
            }
        }
        return dp[i][j]=ans ;
    }
}
int main()
{
   fast ;
   cin>>n>>k>>r>>s>>p ;
   string y ;
   cin>>y ;
   for(ll i=0;i<y.length();i++)
   {
       if(y[i]=='r')
       {
           v.pb(1) ;
       }
       else if(y[i]=='s')
       {
           v.pb(2) ;
       }
       else
        v.pb(3) ;
   }
   for(ll i=0;i<N;i++)
   {
       for(ll j=0;j<4;j++)
        dp[i][j]=-1 ;
   }
   ll ans= 0;
   for(ll i=0;i<k;i++)
   {
       ans+=fun(i,0) ;
   }

   cout<<ans ;

}


Measured memory_bytes: 12148
N = int(input())
s = input()
t = input()
l1 = len(s)
l2 = len(t)
ans = l1+l2
for i in range(1,min(l1,l2)+1):
    if s[l1-i:] == t[:i]:
        ans = l1+l2-i
print(ans)

Measured memory_bytes: 61456
from bisect import bisect_left, bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    max_index_A = bisect_left(A, b)
    max_index_C = N - bisect_right(C, b)
    ans += (max_index_A) * (max_index_C)

print(ans)


Measured memory_bytes: 23968
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '+') {
                n++;
            } else {
                n--;
            }
        }
        System.out.println(n);
    }
}


Measured memory_bytes: 78668
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		Hill hills[] = new Hill[n];

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

		for(int i = 0; i < m; i++){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;

			hills[a].pq.add(hills[b]);
			hills[b].pq.add(hills[a]);
		}

		int count = 0;
		for(int i = 0; i < n; i++){
			if(hills[i].pq.size() == 0 ||  hills[i].h > hills[i].pq.peek().h){
				count++;
			}
		}

		System.out.println(count);
	}
}

class Hill implements Comparable<Hill>{
	int h;
	PriorityQueue<Hill> pq = new PriorityQueue<Hill>();

	Hill(int h){
		this.h = h;
	}

	@Override
	public int compareTo(Hill h1) {
		// TODO 自動生成されたメソッド・スタブ
		return h1.h - this.h;
	}
}

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

int main() {
  int a, p;
  string s;
  cin >> a >> p >> s;
  //大文字変換
  //小文字変換の場合は0x20を引く
  s[p - 1] = s[p - 1] + 0x20;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
	int n, tmp;
	int *array;
	
	while(cin >> n){
		array = (int *)calloc(n, sizeof(int));
		
		for(int i = 0; i < n; i++){
			cin >> array[i];
		}
		sort(array, array+n);
		
		tmp = array[0];
		for(int i = 1; i < (n); i++){
			array[i] += array[i-1];
			tmp += array[i];
		}
		
		cout << tmp << endl;
		free(array);
	}
	
	return 0;
}

Measured memory_bytes: 0
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut p: Vec<usize> = Vec::new();
    for i in 0..n {
        let r: usize = iterator.next().unwrap().parse().unwrap();
        let c: usize = iterator.next().unwrap().parse().unwrap();
        p.push(r);
        if i == n - 1 {
            p.push(c);
        }
    }

    let mut costs: Vec<Vec<usize>> = vec![vec![0; n]; n];
    for i in 1..n {
        for j in 0..n - i {
            costs[i][j] = std::usize::MAX;
            for k in 0..i {
                costs[i][j] = min(
                    costs[i][j],
                    costs[k][j] + costs[i - 1 - k][j + 1 + k] + p[j] * p[j + k + 1] * p[j + i + 1]
                )
            }
        }
    }

    return format!("{}", costs[n - 1][0]);
}



Measured memory_bytes: 5036
from collections import deque

def bfs():
  d = deque([0])
  depth = [0]*(N)
  visited = [0]*N
  de = 1
  
  visited[0] = 1
  while len(d) > 0:
    ind = d.popleft()
    de = depth[ind] + 1
    for i in graph[ind]:
      if visited[i] == 1:
        depth[i] = min(depth[i],de)        
        continue
      d.append(i)
      depth[i] = de
      visited[i] = 1

  return depth
    

N,M = map(int,input().split())
graph = {}
depth = [0]*(N+1)
for i in range(N):
  graph[i] = []
  
for i in range(M):
  a,b = map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

depth = bfs()
print('Yes')
for i in range(1,N):
  
  de = depth[i]
  l = graph[i]
  for li in l:
    if depth[li] == de-1:
      print(li+1)
      break

  


  

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();

			Console.WriteLine(firstLine[2] + " " + firstLine[0] + " " + firstLine[1]);
		}
	}
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		if(a <= c && c <= b)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
 
}

Measured memory_bytes: 21844
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n;
    cin >> n;
    set<int> st;
    int f = 0;
    rep(i, 0, n){
        int x;
        cin >> x;
        if(x > 0 && x < 400) st.insert(0);
        else if(x > 399 && x < 800) st.insert(1);
        else if(x > 799 && x < 1200) st.insert(2);
        else if(x > 1199 && x < 1600) st.insert(3);
        else if(x > 1599 && x < 2000) st.insert(4);
        else if(x > 1999 && x < 2400) st.insert(5);
        else if(x > 2399 && x < 2800) st.insert(6);
        else if(x > 2799 && x < 3200) st.insert(7);
        else f++;
    }
    int mn = st.size(), mx = st.size() + f;
    if(mn == 0) mn = 1;
    cout << mn << " " << mx;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


Measured memory_bytes: 256
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = nums[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,x,y;
	cin >> n >> x >> y;
	x--,y--;
	vector<vector<int>> ad(n);
	for(int i=1;i<n;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		ad[a].push_back(b);
		ad[b].push_back(a);
	}
	
	vector<int> dist(n);
	function<void(int,int,int)> dfs=[&](int cur,int par,int di){
		for(int ch:ad[cur]){
			if(ch==par) continue;
			dfs(ch,cur,di+1);
		}
		dist[cur]=di;
	};
	dfs(y,-1,0);
	
	vector<int> dist2(n);
	function<void(int,int,int)> dfs2=[&](int cur,int par,int di){
		for(int ch:ad[cur]){
			if(ch==par) continue;
			dfs2(ch,cur,di+1);
		}
		dist2[cur]=di;
	};
	dfs2(x,-1,0);
	int res=0;
	for(int i=0;i<n;i++){
		if(dist[i]<dist2[i]) continue;
		res=max(res,dist[i]);
	}
	cout << (res-1) << "\n";
	return 0;
}


Measured memory_bytes: 14208