akhauriyash/Code-Regression huggingface dataset:
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

lst = inputs[1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p lst
end

flag1 = true
for i in 1..lst.size-1
  if lst[i-1] > lst[i]
    flag1 = false
    break
  end
end

if flag1 == true
  puts "YES"
  exit
end

for i in 0..lst.size-2
  for j in i+1..lst.size-1
    flag2 = true
    tmp_lst = lst.clone
    tmp_lst[i], tmp_lst[j] = tmp_lst[j], tmp_lst[i]
    for k in 1..lst.size-1
      if tmp_lst[k-1] > tmp_lst[k]
        flag2 = false
      end
    end
    break if flag2 == true
  end
  break if flag2 == true
end

if flag2 == true
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 2300
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = Integer.MAX_VALUE;

        ArrayList<Integer> pol = new ArrayList<Integer>();
        int num = 1;
        int po = num*(num+1)*(num+2)/6;
        while(po < 1000000){
            pol.add(new Integer(po));
            num++;
            po = num*(num+1)*(num+2)/6;
        }

        int[] cnt = new int[1000000];
        int[] cnt2 = new int[1000000];
        Arrays.fill(cnt, INF);
        Arrays.fill(cnt2, INF);
        cnt[0] = 0;
        cnt2[0] = 0;
        for(int i=0; i<pol.size(); i++){
            int pp = pol.get(i);
            for(int j=pp; j<1000000; j++){
                cnt[j] = Math.min(cnt[j], cnt[j-pp]+1);
                if(pp%2==1) cnt2[j] = Math.min(cnt2[j], cnt2[j-pp]+1);
            }
        }

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

            System.out.println(cnt[n]+" "+cnt2[n]);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main() {
  int N, i, judge = 0;
  string hina;
  
  cin >> N;
  
  for(i = 0; i < N; i++)
  {
    cin >> hina;
    
    if(hina == "Y")
      judge = 1;
  }

  if(judge == 1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


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

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

  sort(s.begin(), s.end());

  for(char i='a';i<='z';i++){
    if(find(s.begin(),s.end(),i)==s.end()){
      cout << i << endl;
      return 0;
    }
  }

  cout << "None" << endl;
}


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

int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  int ans=0;
  int count=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    if(i==0){
      ans++;
      continue;
    }
    if(count==0&&A[i]<A[i-1])count=1;
    else if(count==0&&A[i]>A[i-1])count=2;
    else if(count==2&&A[i]<A[i-1]){
      count=0;
      ans++;
    }
    else if(count==1&&A[i]>A[i-1]){
      count=0;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3756
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

read = sys.stdin.buffer.read

a, b, c, k = map(int, read().split())
for i in range(k):
    if a >= b:
        b *= 2
    else:
        c *= 2
if a < b and b < c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 65636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n, k;
  cin >> n >> k;
  vi p(n);
  rep(i, n) cin >> p[i];
  sort(ALL(p));
  int ans = 0;
  rep(i, k) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3624
from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(m):
  l2=[]
  a,b=map(int,input().split())
  l2.append(a)
  x=list(map(int,input().split()))
  ct=0
  for i in range(n):
    if i+1 in x:
      ct+=2**i
  l2.append(ct)
  l.append(l2)

dp=[[999999999999 for i in range(2**n)] for j in range(m+1)]
dp[0][0]=0
for i in range(1,m+1):
  for j in range(2**n):
    dp[i][j|l[i-1][1]]=min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]])
  for j in range(2**n):
    dp[i][j]=min(dp[i][j],dp[i-1][j])

if dp[m][2**n-1]<10**11:
  print(dp[m][2**n-1])
else:
  print(-1)


Measured memory_bytes: 81880
#include"iostream"
#include"algorithm"
using namespace std;

int main()
{
	int n;
	cin >> n;
	int m = 0;
	int ans = 100000000;
	while (n >= 0)
	{
		int sum = 0;
		int x = n;
		int y = m;
		for (int i = 0; i < 10; i++)
		{
			sum += x - (x / 6) * 6;
			x = x / 6;
			sum += y - (y / 9) * 9;
			y = y / 9;
		}
		ans = min({ ans,sum });
		n--;
		m++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

char read_char() {
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    return ch;
}

string read_word() {
    string ret;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    for (; ch != EOF && !isspace(ch); ch = getchar_unlocked())
        ret += ch;
    ungetc(ch, stdin);
    return ret;
}

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

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

int main() {
    auto N = read_int();

    int64_t ans = 0;
    for (int k = 1; k <= N; ++k) {
        // k <= xk <= N
        // ∴ 1 <= x <= N/k
        //
        // m = N/k とする
        //   k + 2k + ... + mk
        // = k (1 + ... + m)
        // = k m (m+1) / 2
        auto m = N/k;
        ans += k * m * (m+1) / 2;
    }
    cout << ans << LF;
}


Measured memory_bytes: 3232
import java.util.Scanner;
class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

      	int X = 0;
      
		int N = sc.nextInt();
      
		int [] M;
		M = new int[N];

		for (int i = 0; i < N; i++) {
			M[i] = sc.nextInt();
		}
      
		for (int i = 0; i < N - 1; i++) {
        	for (int j = i + 1; j < N ; j++) {
        		X = X + M[i] * M[j];
        	}
        }
      	
      	System.out.print(X);
		return;
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
    int i = 1;
	int num;
	int para;
    scanf("%d",&para);
    
	while (i <= para)
    {
    	num = i;
    	if ((num % 3 == 0) | (num % 10 == 3))
    	    printf(" %d",i);
    	else
    	{
    	    while (num)
    	    {
    		    num /= 10;
    		    if (num % 10 == 3)
    		    {
                    printf(" %d",i);
                    num = 0;
    		    }
    	    }
    	}
    	i++;
    }
    putchar('\n');
	
    return 0;
}



Measured memory_bytes: 2044
#include<stdio.h>

int main(void){
    int H,W,n;
    for(int i=0;i<100000;i++){
        scanf("%d%d",&H,&W);
        if(H==0&&W==0)  break;
        for(int m=0;m<H;m++){
            if(m==0||m==H-1){
                for(n=0;n<W;n++){
                    printf("#");
                }   
            }else{
                for(n=0;n<W;n++){
                    if(n==0||n==W-1){
                     printf("#");
                    }else{
                        printf(".");
                    }
                }
            }
        printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll c,r;
	cin >> c >> r;
	ll sum = c*r;
	if(c==1||r==1) cout << 1 << endl;
	else{
		if(sum&1) cout << (sum/2)+1 << endl;
		else cout << sum/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

n,m=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]

data=np.zeros((n+1,n+1))
for u in abc:
    a,b,c=u
    data[a,b]=c
    data[b,a]=c
qqq=shortest_path(data,directed=False).astype(int)

ans=0
for u in abc:
    a,b,c=u
    if qqq[a][b]!=c:
        ans+=1
print(ans)

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
   int a[5],b,c=0,d,e,k,n;
   cin>>n;
   vector < int > v(n),p(n);
   rep(i,0,n) cin>>v[i];
   rep(i,0,n) cin>>p[i];
   rep(i,0,n)
   {
       if(v[i]>p[i]) c+=v[i]-p[i];
   }
cout<<c;

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
  
  int a, b;
  
  cin >> a >> b;
  
  int multiplyNum = a * b;
  if(multiplyNum % 2 == 0)
  {
    cout << "Even";
  }
  else
  {
    cout << "Odd";
  }
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N, K = map(int, input().split())
x = np.array(list(map(float, input().split())))

for i in range(N):
	x[i] = (1 + x[i]) / 2

data = np.sum(x[:K])
ans = data

for i in range(N-K):
	data = data + x[i+K] - x[i]
	if data > ans:
		ans = data

print(ans)

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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long s64;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=3000+5,D=1e9+7;
s64 dp[2][N][2];
s64 solve(int n,int m)
{
	bool d=0;
	rep(i,0,n)dp[d][i][i==0]=1;
	rep(step,1,m)
	{
		rep(i,0,n)
		rep(k,0,1)dp[d^1][i][k]=dp[d][i][k]*2;
		rep(i,1,n)
		rep(k,0,1)dp[d^1][i-1][k]+=dp[d][i][k];
		rep(i,0,n-1)
		rep(k,0,1)dp[d^1][i+1][k]+=dp[d][i][k];
		d^=1;
		dp[d][0][1]+=dp[d][0][0];dp[d][0][0]=0;
		rep(i,0,n)
		rep(k,0,1)dp[d][i][k]%=D;
	}
	s64 ans=0;
	rep(i,0,n)ans+=dp[d][i][1];
	return ans%D;
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n,m;
	cin>>n>>m;
	printf("%d\n",int(solve(n-1,m-1)*4%D));
}



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

using namespace std;


int main(){
    string s; cin >> s;
    int ans = 0;
    int last = s.length()-1;
    for(int i = 0; i < s.length()/2; i++){
        if(s[i] != s[last])ans++;
        last--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int A, B;
int an[5000], br[5000]; //0-
int dp[5001][5001] = {}; //1-

int main() {

	cin >> A >> B;

	for (int i = 0; i < A; i++) {
		cin >> an[i];

		dp[i][0] = 0;
	}
	for (int i = 0; i < B; i++) {
		cin >> br[i];

		dp[0][i] = 0;
	}

	for (int i = 1; i <= A; i++) {
		for (int j = 1; j <= B; j++) {

			dp[i][j] = dp[i - 1][j];
			if (an[i-1] == br[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
			}

		}
	}

	int ans = 0;
	for (int i = 1; i <= A; i++) {
		for (int j = 1; j <= B; j++) {

			ans = max(ans, dp[i][j]);

		}
	}

	cout << ans << endl;


	return 0;
}




Measured memory_bytes: 100820
#include <stdio.h>

int main(int argc, const char * argv[])
{
    double a, b, c, d, e, f;
    double x, y;
    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
        y = (c * d - f * a) / (b * d - a * e);
        x = (c - b * y) / a;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int r, g, b;
	cin >> r >> g >> b;
	if((g*10+b)%4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,k) for(i=0;i<k;i++)
#define ALL(c) (c).begin(),(c).end()
#define deb(x) cerr<<#x<<"  = "<<x<<endl;
#define SZ(x) (x).size();
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define em emplace_back
#define ulli unsigned long long int
#define INF 1e18
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
void solve();

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main() {
	fastio;
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	int t;
	t=1;

    //cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

ll calc(ll a[],ll i,ll j,vector<vector<ll>> &sum,vector<vector<ll>> &dp)
{
    if(i==j)
        return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];

    ll ans=INF;

    for(int k=i;k<j;k++)
    {
        ans=min(ans,sum[i][j]+calc(a,i,k,sum,dp)+calc(a,k+1,j,sum,dp));
    }

    return dp[i][j]=ans;
}

void solve()
{
	ll n,i,j,k,c;
	cin>>n;

	ll a[n];

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

    vector<vector<ll>> dp(n,vector<ll>(n,-1));
    vector<vector<ll>> sum(n,vector<ll>(n));

    for(i=0;i<n;i++)
    {
        for(j=i;j<n;j++)
        {
            if(i==j)
                sum[i][j]=a[j];
            else
                sum[i][j]=sum[i][j-1]+a[j];
        }
    }

    cout<<calc(a,0,n-1,sum,dp)<<endl;
}


Measured memory_bytes: 5824
#include<bits/stdc++.h>
using namespace std;
int s,k,ans;
int main(){
	scanf("%d%d",&k,&s);
	for(int i=0;i<=k;i++){
		for(int j=0;j<=min(k,s-i);j++){
			int t=s-i-j;
			if(t<=k)ans++;
		}
	}
	printf("%d\n",ans);
    return 0;
}

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

using namespace std;

bool compare(int a, int b)
{
  return a > b;
}

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

  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  long long int temp;
  long long int p[A], q[B], r[C], pqr[A + B + C];
  for (int i = 0; i < A; i++)
    cin >> p[i];
  for (int i = 0; i < B; i++)
    cin >> q[i];
  for (int i = 0; i < C; i++)
    cin >> r[i];

  sort(p, p + A, compare);
  sort(q, q + B, compare);
  sort(r, r + C, compare);
  
  for (int i = 0; i < X; i++)
    pqr[i] = p[i];
  for (int i = 0; i < Y; i++)
    pqr[X + i] = q[i];
  for (int i = 0; i < C; i++)
    pqr[X + Y + i] = r[i];

  sort(pqr, pqr + X + Y + C, compare);
  long long int sum = 0;
  for (int i = 0; i < X + Y; i++)
    sum += pqr[i];

  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 8068
k = int(input())
li =[i+1 for i in range(9)]

c = 0
while len(li) < k:
    if li[c]%10 != 0:
        li.append(li[c]*10+li[c]%10-1)
    li.append(li[c]*10+li[c]%10)
    if li[c]%10 != 9:
        li.append(li[c]*10+li[c]%10+1)
    c +=1
    
print(li[k-1])

Measured memory_bytes: 7200
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<ull> vul;
typedef vector<pair<ll, ll>> vpl;
typedef pair<ll, ll> pl;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
ll dp[3010][3010];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	ll n_s = len(s);
	ll n_t = len(t);
	for (ll i = 1; i <= n_s; i++) {
		for (ll j = 1; j <= n_t; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	//cout << dp[n_s][n_t];
	ll i = n_s;
	ll j = n_t;
	string ans = "";
	while (i > 0 && j > 0) {
		if (s[i - 1] == t[j - 1]) {
			ans += s[i - 1];
			i--;
			j--;
		}
		else if (dp[i - 1][j] == dp[i][j]) {
			i--;
		}
		else {
			j--;
		}
	}
	Reverse(ans);
	cout << ans;
	return 0;
}

Measured memory_bytes: 74128
#include<iostream>
#include<cstring>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1010,M=20010;
 typedef pair<int,int> pii;
 int a[N][2];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i][0]>>a[i][1];
    bool flag=false;
    for(int i=3;i<=n;i++)
    {
        if(a[i-2][0]==a[i-2][1] && a[i-1][0]==a[i-1][1] && a[i][0]==a[i][1])
        {
            flag=true;
        }
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}  

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    vector<int> maxa(n-k+1);
    for(int i=0; i<k; i++){
        maxa[0] += v[i];
    }
    for(int i=1; i<n-k+1; i++){
        maxa[i] = maxa[i-1] + v[i+k-1] - v[i-1];
    }
    int maxnum = *max_element(maxa.begin(), maxa.end());
    double d = (maxnum + k) / 2.0;
    cout<<fixed<<setprecision(10) << d;
}


Measured memory_bytes: 1908
#include<stdio.h>
  
 int main()
{
  int a,b;

    int i,j,y = 0;

int x, w, z;

  scanf("%d",&a);

  int ar1[a];
  char ar2[12];
 
  for(i = 0;i < a;i++){
    scanf("%s %d",ar2,&b);
 
    if(ar2[0] == 'i'){
      ar1[i] = b;
    }
 
    else if(ar2[6] == 'F'){
      i -= 2;
      a -= 2;
    }
 
    else if(ar2[6]=='L'){
      i--;
      a--;
      y++;
    }
 
    else{
      i--;
      a--;
      x = 0;
      for(j = i; j >= 0;j--){
 
	if(x > 0)break;
 
	if(b == ar1[j]){
	  z = 0;
	  w = i - j;
	  x++;
	  while(w != z++)ar1[j + z - 1] = ar1[j + 1 + z - 1];
	  i--;
	  a--;
	}
      }
    }
  }
  for(i = 0;i < a - y;i++){
    if(i == a - y - 1)
      printf("%d\n",ar1[a - 1 - i]);
    else printf("%d ",ar1[a - 1 - i]);
  }
  return 0;
}



Measured memory_bytes: 5684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  if(a==1)
    out(1);
  else if(a==2||a==3)
    out(2);
  else if(4<=a&&a<8)
    out(4);
  else if(8<=a&&a<16)
    out(8);
  else if(16<=a&&a<32)
    out(16);
  else if(32<=a&&a<64)
    out(32);
  else 
    out(64);
}

Measured memory_bytes: 256
nm = [int(ai) for ai in input().split(' ')]
N = nm[0]
M = nm[1]
cakes = [[int(si) for si in input().split(' ')] for i in range(N)]
signs = [[(-1)**i, (-1)**j, (-1)**k] for i in range(2)
                                     for j in range(2)
                                     for k in range(2)]
answer = 0
for sign in signs:
    values = [sum([cake[i] * sign[i] for i in range(3)]) for cake in cakes]
    answer = max(sum(sorted(values, reverse=True)[:M]), answer)
print(answer)

Measured memory_bytes: 3360
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    ll N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    ll a;
    REP(i, N){
        cin >> a;
        A.push(a);
    }
    REP(i, M){
        ll t = A.top();
        A.pop();
        t = ll(t / 2);
        A.push(t);
    }
    ll sum = 0;
    while(!A.empty()){
        sum += A.top();
        A.pop();
    } 


    cout << sum <<endl;


    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s;

int main() {
	cin >> s;
	bool f = 0;
	rep(i, s.size()-1) {
		if (s[i] == 'A'&&s[i + 1] == 'C')f = 1;
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
string s[401];
ll H , W;
bool did[401][401];
ll a,b;
int dfs(int x,int y){
	did[x][y] = true;
	if(x>0)if(s[x][y]!=s[x-1][y]&&(not did[x-1][y])){
		if(s[x-1][y]=='#')b++;
		else a++;
		dfs(x-1,y);
	}
	if(x<H-1)if(s[x][y]!=s[x+1][y]&&(not did[x+1][y])){
		if(s[x+1][y]=='#')b++;
		else a++;
		dfs(x+1,y);
	}
	if(y>0)if(s[x][y]!=s[x][y-1]&&(not did[x][y-1])){
		if(s[x][y-1]=='#')b++;
		else a++;
		dfs(x,y-1);
	}
	if(y<W-1)if(s[x][y]!=s[x][y+1]&&(not did[x][y+1])){
		if(s[x][y+1]=='#')b++;
		else a++;
		dfs(x,y+1);
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> H >> W;
	FOR(i,0,H){
		cin >> s[i];
	}
	ll ans = 0;
	FOR(i,0,H){
		FOR(j,0,W){
			a=b=0;
			if(not did[i][j]){
				if(s[i][j]=='#')b++;
				else a++;
				dfs(i,j);
				//cout << i << " " << j << " " << k << endl;
				ans += a*b;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  int n,k;cin>>n>>k;
  
  int count=0;
  double ansn=0;
  
  for(int i=n;i>0;i--) {
    while(i*pow(2,count)<k) {
      count++;
    }
    ansn+=1.0/(n*pow(2,count));
  }
  
  cout<<setprecision(15)<<ansn<<endl;
  
}

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

using namespace std;

int main(){
    while(true){
        int n,m; cin >> n >> m;
        if(n == 0)break;
        vector<long long> h(n+1,0), w(m+1, 0);
        map<long long, int> r, c;
        for(int i = 1; i <= n; i++){
            cin >> h[i];
            h[i] += h[i-1];
        }
        for(int i = 1; i <= m; i++){
            cin >> w[i];
            w[i] += w[i-1];
        }
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n+1; j++){
                long long temp = h[j]-h[i];
                if(c.find(temp) != c.end()){
                    c[temp]++;
                }
                else{
                    c[temp] = 1;
                }
            }
        }
        for(int i = 0; i < m; i++){
            for(int j = i+1; j < m+1; j++){
                long long temp = w[j]-w[i];
                if(r.find(temp) != r.end()){
                    r[temp]++;
                }
                else{
                    r[temp] = 1;
                }
            }
        }
        int ans = 0;/*
        for(map<long long, int>::iterator itr = r.begin(); itr != r.end(); ++itr){
            cout << itr->first << " " << itr->second << endl;
        }*/
        //cout << "\n";
        /*for(map<long long, int>::iterator itr = c.begin(); itr != c.end(); ++itr){
            cout << itr->first << " " << itr->second << endl;
        }*/
        
        for(map<long long, int>::iterator itr = r.begin(); itr != r.end(); ++itr){
            if(c.find(itr->first) != c.end()){
                ans += itr->second * c[itr->first];
            }
        }
        cout  << ans << endl;
        //cout << "\n";
    }    
    return 0;
}


Measured memory_bytes: 38724
m,d = map(int,input().split())
cnt = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        if j >= 20:
            s = str(j)
            d10 = int(s[0])
            d1 = int(s[1])
            if i == d1*d10 and d1 >= 2:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
fun main(args: Array<String>) {
  val (A, B, C) = readInts()
  if (
    (A == B && B != C) || (B == C && C != A) || (C == A && A != B)
  ) {
    println("Yes")
  } else {
    println("No")
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37852
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long int LL;


vector<int >ve[N];
map< LL , int >ma;
LL a[N];
LL b=17;
LL ans;
void dfs(int u)
{
    a[u]=1;
    for(int i=0;i<ve[u].size();i++)
    {
        int v=ve[u][i];
        dfs(v);
        a[u]+=a[v]*b;
    }
    ans+=ma[a[u]];
    ma[a[u]]++;
    return ;
}

int main()
{
    int n;
        cin>>n;
        int u,v;
        for(int i=0;i<n-1;i++)
        {
            cin>>u>>v;
            ve[u].push_back(v);
        }
        ans=0;
        dfs(1);
        cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 21896
letters = {
    "a": 0,
    "b": 0,
    "c": 0,
    "d": 0,
    "e": 0,
    "f": 0,
    "g": 0,
    "h": 0,
    "i": 0,
    "j": 0,
    "k": 0,
    "l": 0,
    "m": 0,
    "n": 0,
    "o": 0,
    "p": 0,
    "q": 0,
    "r": 0,
    "s": 0,
    "t": 0,
    "u": 0,
    "v": 0,
    "w": 0,
    "x": 0,
    "y": 0,
    "z": 0,
}

while True:
    try:
        l = list(input())
        if len(l) == 0:
            break
        for c in l:
            cl = c.lower()
            if cl in letters:
                letters[cl] += 1
    except EOFError:
        break

ks = list(letters.keys())
vs = list(letters.values())

for i in range(len(ks)):
    print("%s : %s" % (ks[i], vs[i]))



Measured memory_bytes: 5568
import Data.List
import Debug.Trace
 
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve n k as
 
solve n k as =
  traceShow (l,r) $
  traceShow (lenl,lenr) $
  traceShow next $
  traceShow (ansl,ansr) $
  ans
  where
    (l,r) = span (>1) as
    lenl = --if length l >= k then length l + 1 else
      length l
    lenr = length r
    (ansl,next) = if lenl==0 then (0,0) else solve_ (lenl+1) k (0,0) 
    (ansr,_) =
      if lenr==1 then (0,0)
      else if lenr<=next+1 then (0,0)
           else solve_ (lenr-next) k (0,0)
    ans = ansl + ansr
    solve_ len k (ans,next) =
      if len <= k then (ans+1,k-len)
      else solve_ (len - (k-1)) k (ans+1,0) 

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

int main()
{
  int a,b;
  cin >> a >> b;

  

  if(a > b)
    {cout  << "a > b" << endl;}
  else if(a < b)
    {cout << "a < b"<< endl;}
  else if(a==b)
    {cout << "a == b" << endl;}

  return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextLong();
		}

		long ac = 0;
		long bc = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > b[i]) {
				bc += a[i] - b[i];
			} else if (b[i] - a[i] >= 2) {
				ac += (b[i] - a[i]) / 2;
			}
		}
		if (ac >= bc) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 43348
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 1<<18, rt = 1<<10;
ll count(int n, int k, int a) {
	int l = n-a+1;
	int m = l + (a - l%a)%a;
	int r = n-k+1;
	m = min(r, m);
	return max(0, m-l)*1ll*(l/a + 1) + max(0, r-m)*1ll*(m/a + 1);
}
int solve() {
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for(int i = 1; i <= n; i++) ans += count(n, k, i);
	if(k == 0) ans -= n;
	cout << ans << '\n';
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	solve();
}


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

int main()
{
    int Max=0,cu=0,n,x,y=0;
    scanf("%d",&n);
    scanf("%d",&y);
    n--;
    while(n--){
      scanf("%d",&x);
      if(x<=y){
        cu++;
      }
      else{
        if(Max<cu){
            Max=cu;
        }
        cu=0;
      }
      y=x;
    }
    if(Max<cu){
        Max=cu;
        }
    printf("%d",Max);
    return 0;
}


Measured memory_bytes: 256
import Data.List

main = do
  n <- readLn :: IO Int
  as <- getLine >>= return . map read . words :: IO [Int]

  let cntdiv4 = length $ filter (\x -> mod x 4 == 0) as
  let cntdiv2 = length $ filter (\x -> mod x 2 == 0 && mod x 4 /= 0) as

  let b = cntdiv4*2 + (if cntdiv2 >= 1 then (cntdiv2-1) else 0)
  putStrLn $ f $ b >= (n - 1)

  where
    f True = "Yes"
    f False = "No"


Measured memory_bytes: 33148
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int h, w, d;
    scanf("%d%d%d", &h, &w, &d);

    string s = "RGBY";
    int K = h+w;
    char grid[K+1][K+1];
    for(int i=0; i<=K; i+=d)for(int j=0; j<=K; j+=d){
        char c = s[i/d%2*2 + j/d%2];
        for(int x=0; x<d && i+x<=K; ++x)for(int y=0; y<d && j+y<=K; ++y){
            grid[i+x][j+y] = c;
        }
    }

    rep(i, h){
        rep(j, w) printf("%c", grid[i+j][i-j+w]);
        printf("\n");
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    mint ans=0;
    FOR(i,k,n+1){
        mint mini = mint(i-1)*i/2;
        mint maxi = mint(2*n-i+1)*i/2;
        ans+=maxi-mini+1;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3652
class Dijkstra():
    """ ダイクストラ法
    重み付きグラフにおける単一始点最短路アルゴリズム

    * 使用条件
        - 負のコストがないこと
        - 有向グラフ、無向グラフともにOK

    * 計算量はO(E*log(V))

    * ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
    """
    class Edge():
        """ 重み付き有向辺 """
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):
        """ 重み付き有向辺
        無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい

        Args:
            V(int): 頂点の数
        """
        self.G = [[] for i in range(V)]  # 隣接リストG[u][i] := 頂点uのi個目の隣接辺
        self._E = 0  # 辺の数
        self._V = V  # 頂点の数

    @property
    def E(self):
        """ 辺数
        無向グラフのときは、辺数は有向グラフの倍になる
        """
        return self._E

    @property
    def V(self):
        """ 頂点数 """
        return self._V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加する """
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路を格納したリストを返す
        Args:
            s(int): 始点s
        Returns:
            d(list): d[i] := 始点sから頂点iまでの最短コストを格納したリスト。
                     到達不可の場合、値はfloat("inf")
        """
        import heapq
        que = []  # プライオリティキュー（ヒープ木）
        d = [10**15] * self.V
        d[s] = 0
        heapq.heappush(que, (0, s))  # 始点の(最短距離, 頂点番号)をヒープに追加する

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            # キューに格納されている最短経路の候補がdの距離よりも大きければ、他の経路で最短経路が存在するので、処理をスキップ
            if d[v] < cost: continue

            for i in range(len(self.G[v])):
                # 頂点vに隣接する各頂点に関して、頂点vを経由した場合の距離を計算し、今までの距離(d)よりも小さければ更新する
                e = self.G[v][i]  # vのi個目の隣接辺e
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost  # dの更新
                    heapq.heappush(que, (d[e.to], e.to))  # キューに新たな最短経路の候補(最短距離, 頂点番号)の情報をpush
        return d

from math import sqrt

xs,ys,xt,yt=map(int,input().split())
N=int(input())
pro=Dijkstra(N+2)
node=[(xs,ys,0),(xt,yt,0)]
for i in range(0,N):
    x,y,r=map(int,input().split())
    node.append((x,y,r))

for i in range(0,N+2):
    for j in range(0,N+2):
        x1,y1,r1=node[i]
        x2,y2,r2=node[j]
        cost=max(0,sqrt((x1-x2)**2+(y1-y2)**2)-r1-r2)
        pro.add(i,j,cost)

ans=pro.shortest_path(0)
print(ans[1])

Measured memory_bytes: 160648
using System;

namespace AtCoder
{
    class Program
    {
        static IO io = new IO();

        static void Main(string[] args)
        {
            io.ReadSplit();
            string A = io.String();
            string B = io.String();
            string C = io.String();

            if ((A.Substring(A.Length - 1, 1) == B.Substring(0, 1)) && (B.Substring(B.Length - 1, 1) == C.Substring(0, 1)))
            {
                io.WriteLine("YES");
            }
            else
            {
                io.WriteLine("NO");
            }
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 11092
import sys

K=int(sys.stdin.readline().rstrip())
 
def gcd(a,b):

    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

cnt1 = 0
cnt2 = 0
cnt3 = 0
for n1 in range(0,K):
    cnt1 += n1+1
    for n2 in range(n1+1, K):
        temp = gcd(n1+1, n2+1)
        cnt2 += temp*6
        for n3 in range(n2+1, K):
            cnt3 += gcd(temp, n3+1)*6
        

ans = cnt1 + cnt2 + cnt3
print(ans)

Measured memory_bytes: 9212
#include <stdio.h>

int main(){
 int a,b;
 
 scanf("%d %d",&a,&b);

 if(a > b){
 
  printf("a > b\n");
 } 
 else if(a < b){

  printf("a < b\n");
 }
 else{
  
  printf("a == b\n");
 }

 return 0;
}

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

int main(void) {
	int N,i;
	scanf("%d",&N);
	for(i=1;i<10;i++){
		if(!(N%i) && (N/i)<10)
		{printf("Yes");return 0;}
	}
    printf("No");
    return 0;
}


Measured memory_bytes: 128
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , x , a[N] ;
bool mark[N] ;

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

	cin >> n >> x ;

	if (x == 1 || x == 2 * n - 1) return cout << "No\n" , 0 ;

	cout << "Yes\n" ;

	if (n == 2) return cout << "1 2 3\n" , 0 ;

	if (x < 2 * n - 2) {
		a[n - 1] = x ;
		a[n - 2] = x - 1 ;
		a[n - 3] = x + 1 ;
		a[n] = x + 2 ;
		
		mark[x - 1] = mark[x] = mark[x + 1] = mark[x + 2] = 1 ;
	}
	else {
		a[n - 1] = x ;
		a[n - 2] = x + 1 ;
		a[n - 3] = x - 1 ;
		a[n] = x - 2 ;
	
		mark[x - 2] = mark[x - 1] = mark[x] = mark[x + 1] = 1 ;
	}

	for (int i = 0 , p = 1 ; i < 2 * n - 1 ; i ++) {
		if (!a[i]) {
			while (mark[p]) p ++ ;
			mark[p] = 1 ;
			a[i] = p ;
		}
		cout << a[i] << '\n' ;
	}
}


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

int main(){
	// sengen
	int h,w;

	// nyuryoku
	cin >> h >> w;
	char s[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s[i][j];
		}
	}
	// keisan
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j] == '#'){
				cout << s[i][j];
			}else{
				int count = 0;
				for(int dx=-1;dx<2;dx++){
					for(int dy=-1;dy<2;dy++){
						int x=i+dx,y=j+dy;
						if(x>=0&&x<h&&y>=0&&y<w&&s[x][y] == '#'){
							count++;
						}
					}
				}
				cout << count;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
sum_T = sum(T)
M = int(input())
P, X = [], []
res = []
for i in range(M):
    pi, xi = map(int, input().split())
    res.append(sum_T - T[pi-1] + xi)

for r in res:
    print(r)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){

    string s;
    cin>>s;
    int i=0 , j=s.size()-1;
    int aLength=0;
    int zLength=0;

    while(true){
        if(s[i]=='A')
        {
            aLength=i;
            break;
        }
        i++;
    }

    while(true){
        if(s[j]=='Z'){
            zLength=j;
            break;
        }
        j--;
    }

    cout<<(zLength-aLength)+1<<endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int T = in.nextInt();
            int A = in.nextInt();
            int[] H = new int[N];
            for (int i = 0; i < N; i++) {
                H[i] = in.nextInt();
            }

            int bestI = -1;
            double bestDistance = (int) 1e9;
            for (int i = 0; i < N; i++) {
                double t = T - H[i] * 0.006;
                if (Math.abs(t - A) < bestDistance) {
                    bestDistance = Math.abs(t - A);
                    bestI = i;
                }
            }

            System.out.println(bestI + 1);
        }
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    int na,nb,nc,a=0;
    cin >> s >> t;
    na=s.size();
    nb=t.size();
    nc=na-nb;
    a=t.size();
    for(int  i=0;i<=nc;i++){
         int diff=0;
         for(int m=0;m<nb;m++){
             if(t[m]!=s[i+m]){
                 diff++;
             }
         }
         a=min(a,diff);
    }
    cout << a;
    return 0;
   
}


Measured memory_bytes: 3616