akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner kbs = new Scanner(System.in);
		int n,m;
		n = kbs.nextInt();
		m = kbs.nextInt();
		int s = 0;
		for(int i = 0;i < m;i++) {
			int x = kbs.nextInt();
			s = s + x;
		}
		n = n - s;
		if (n < 0) {
			n = -1;
		}
		System.out.printf("%d", n);
		kbs.close();
	}
}


Measured memory_bytes: 46212
import math
import heapq

A = []
inp = input()
while True:
    if inp == 'end':
        break
    elif inp[0] == 'e':
        print(-heapq.heappop(A))
    elif inp[0] == 'i':
        heapq.heappush(A, -int(inp[7:]))
    inp = input()

Measured memory_bytes: 47240
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] > 2) {
      if (a[i] % 2) {
        ret += a[i] / 2;
        a[i] = 1;
      } else {
        ret += a[i] / 2 - 1;
        a[i] = 2;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) {
      int j = i + 1;
      for (; j < n && a[j] == 2; ++j);
      if (j < n && a[j] == 1) {
        ret += j - i;
        i = j;
      } else {
        ret += j - i - 1;
        i = j;
      }
    } else if (a[i] == 2) {
      ret += 1;
    }
  }
  printf("%lld\n", ret);
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	int res = 0;
	for (int i = 1; i + 1 < N; i++) {
		res += (p[i - 1] < p[i]) == (p[i] < p[i + 1]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e6+5;
int n,ans;
int main(){
	n=read();
	vector<int> a(n);
	vector<int> vis(maxn);
	for(int i=0;i<n;i++) a[i]=read();
	for(int i=0;i<n;i++){
		int x=a[i];
		if(vis[x]){
			vis[x]=2;
			continue;
		}
		for(int j=x;j<maxn;j+=x) ++vis[j];
	}
	for(int i=0;i<n;i++){
		if(vis[a[i]]==1) ++ans;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

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

typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2) cout << (a - b) * -1 << endl;
    else cout << a - b << endl;
    return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    
    vector<vector<int>> vec(M);
    
    for(int i = 0; i < M;i++){
        int k;cin >> k;
        vec[i].resize(k);
        for(int j = 0; j < k;j++ ){
            cin >> vec[i][j];
            --vec[i][j];
        }
    }
    
	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

    int ans = 0;
    for(int i = 0; i < (1 << N);i++){
        bool ok = true;
        for(int j = 0; j < M ;j++){
            int c = 0;
            for(int id:vec[j]){
                if((i >> id)&1){
                    ++c;
                }
            }
            c %= 2;
            if(c != p[j]){
                ok = false;
            }
        }
        if(ok){
            ++ans;
        }
    }
    
    cout << ans << endl;
    
    return 0;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(int argc, char* argv[])
{
	int Min=1000;
	string S;
	cin>>S;
	char *pStr=(char*)S.c_str();
	for (int i=0;i<S.length()-2;i++){
		char p[10];
		memset(p,'\0',10);
		strncpy(p,pStr+i,3);
		int x=atol(p);
		x-=753;
		if (x<0){
			x=-x;
		}
		if (Min>x){
			Min=x;
		}
	}		
	cout<<Min<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1,1);
    
    for (int i = 2; i <= N; i++) {
        int a = i;
        for (int j = 2; j <= i; j++) {
            while (a%j==0) {
                a/=j;
                A[j]++;
            }
            if(a == 1) break;
        }
    }
    
    map<int,int> B;
    rep(i,N+1){
        if(A[i] >= 3 && A[i] < 5){
            B[3]++;
        }else if(A[i] >= 5 && A[i] < 15){
            B[5]++;
        }else if(A[i] >= 15 && A[i] < 25){
            B[15]++;
        }else if(A[i] >= 25 && A[i] < 75){
            B[25]++;
        }else if(A[i] >= 75){
            B[75]++;
        }
    }
    
    int ans = 0;
    
    ans += B[75];
    
    ans += B[75]*(B[5]+B[15]+B[25]+B[3]+B[75]-1);
    ans += B[25]*(B[5]+B[75]+B[15]+B[3]+B[25]-1);
    
    
    ans += B[75]*(B[5]+B[15]+B[25]+B[75]-1);
    ans += B[25]*(B[5]+B[15]+B[75]+B[25]-1);
    ans += B[15]*(B[5]+B[75]+B[25]+B[15]-1);
    
    
    ans += B[3]*(B[5]+B[15]+B[75]+B[25])*((B[5]+B[15]+B[75]+B[25])-1)/2;
    ans += (B[5]+B[15]+B[75]+B[25])*((B[5]+B[15]+B[75]+B[25])-1)*((B[5]+B[15]+B[75]+B[25])-2)/2;
    
    /*
    for(auto i : B){
        cout << i.first << " - " << i.second << endl;
    }
    
    rep(i,N+1) cout << A[i] << " "; cout << endl;
    */
    
    cout << ans << endl;
    
    return 0;
}



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(2*M);
    rep(i, 2*M) {
        cin >> a[i];
    }
    vector<int> ans(N);
    rep(i, N) {
        cout << count(a.begin(), a.end(), i+1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
const int inf=0x3f3f3f3f;
int n,k;
ll a[200050];
bool vis[200050];
vector<int >g[200050];
void dfs(int t,ll val)
{
    vis[t]=1;
    a[t]+=val;
    for(int i=0;i<g[t].size();i++)
    {
        int v=g[t][i];
        if(!vis[v])
        {
            dfs(v,a[t]);
        }
    }
}
int main()
{
    //freopen("/Users/zilongzhang/Desktop//l.txt","r",stdin);
       scanf("%d %d",&n,&k);
        for(int i=1;i<=n-1;i++) {
            int x, y;
            scanf("%d %d", &x, &y);
            x--;
            y--;
            g[x].push_back(y);
            g[y].push_back(x);
        }
        while(k--)
        {
            int l,b;
            scanf("%d %d",&l,&b);
            l--;
            a[l]+=b;
        }
        dfs(0,0);
        for(int i=0;i<n;i++)
            printf("%lld ",a[i]);
    return 0;
}


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

int main(){
    int q, n;
    cin >> q;
    while(q--){
        cin >> n;
        int cnt = 0;
        while(n >= 10){
            int tmp = n, k = 0;
            while(tmp >= 10){
                tmp /= 10;
                k++;
            }
            tmp = n, n = 0;
            for(int i = 0; i < k; i++){
                int dig = 10;
                for(int j = 0; j < i; j++) dig *= 10;
                n = max(n, (tmp / dig) * (tmp % dig));
            }
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


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

int n;
set<string> t;
string s;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    while(n--){
        cin>>s;
        t.insert(s);
    }
    cout<<t.size()<<endl;

    return 0;
}

Measured memory_bytes: 19248
/* Fibonacci Number */
#include<stdio.h>

int x[45];
int fib(int n);

int main(){
  int n; /* 0<=n<=44*/
  int i;

  for(i=0;i<45;i++){
    x[i]=-1;
  }

  scanf("%d",&n);

  printf("%d\n",fib(n));

  return 0;
}

int fib(int n){
  if(x[n]!=-1){
    return x[n];
  }
  if(n==0)return 1;
  else if(n==1)return 1;
  else{
    x[n]=fib(n-1)+fib(n-2);
    return  x[n];
  }
}

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

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

    ll sum = 0;
    for (size_t a = 1; a <= K; a++)
    {
        for (size_t b = 1; b <= K; b++)
        {
            for (size_t c = 1; c <= K; c++)
            {
                ll temp1 = gcd(a, b);
                ll temp2 = gcd(b, c);
                sum += gcd(temp1, temp2);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a;
	cin >> a;
	printf("%d\n", 3 * a * a);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] WHN = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long W = WHN[0];
            long H = WHN[1];
            long N = WHN[2];
            Boolean[,] color = new Boolean[W, H];

            for (int j = 0; j < N; j++)
            {
                long[] xya = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                long x = xya[0];
                long y = xya[1];
                long z = xya[2];
                if (z == 1)
                {
                    //xの左側
                    for (int f = (int)x; 0 < f; f--)
                    {
                        for (int k = 0; k < H; k++)
                        {
                            color[f - 1, k] = true;
                        }
                    }
                }
                else if (z == 2)
                {
                    //xの右側
                    for (int f = (int)x; f < W; f++)
                    {
                        for (int k = 0; k < H; k++)
                        {
                            color[f, k] = true;
                        }
                    }
                }
                else if (z == 3)
                {
                    try
                    {
                        //yの下
                        for (int k = (int)y; 0 < k; k--)
                        {
                            for (int f = 0; f < H; f++)
                            {
                                color[f, k - 1] = true;
                            }
                        }
                    }
                    catch
                    {
                        color[1, 0] = true;
                    }
                }
                else if (z == 4)
                {
                    //yの上
                    for (int k = (int)y; k < H; k++)
                    {
                        for (int f = 0; f < W; f++)
                        {
                            color[f, k] = true;
                        }
                    }
                }
            }
            int cnt = 0;
            for(int f = 0; f < W; f++)
            {
                for(int k = 0; k < H; k++)
                {
                    if (!color[f, k])
                    {
                        cnt++;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 29460
def resolve():
    # 達成スコアを決める
    # 修行回数がK以下を達成できるスコアを二分探索
    def check(X):
        cnt = 0
        for i in range(N):
            a = X // F[i]
            if a < A[i]:  # 修行をしてスコアを最小化する
                cnt += A[i] - a
        return cnt <= K

    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()), reverse=True)

    ok = 10 ** 12 # 最大スコア a: 10**6 * x:10**6
    ng = -1
    while ok - ng > 1:
        X = (ok + ng) // 2
        if check(X):
            ok = X
        else:
            ng = X

    print(ok)


if __name__ == "__main__":
    resolve()


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

int main(void)
{
	string str;
	cin >> str;
	
	int k, u, p, c, res;
	k = u = p = c = res = 0;
	for (int i = 0; i < str.size(); i++){
		if (str[i] == 'K') k++;
		if (str[i] == 'U') u++;
		if (str[i] == 'P') p++;
		if (str[i] == 'C') c++;
	}
	while (0 < k && 0 < u && 0 < p && 0 < c){
		res++;
		k--;
		u--;
		p--;
		c--;
	}
	
	cout << res << endl;
	
	return 0;
}

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

int main(){
  int x;
  cin>>x;
  if(x==1||x==2||x==3){
    cout<<1<<endl;
    return 0;
  }
  int a;
  int kotae=0;
  for(int i=2;i<32;i++){
    for(int j=2;j<32;j++){
      a=pow(i,j);
      if(a<=x){
        //cout<<a<<endl;
        kotae=max(kotae,a);
      }
    }
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	char ch, h;
	cin>>ch>>h;
	if(ch>h)
		cout<<">";
	else if(ch<h)
		cout<<"<";
	else
		cout<<"=";
	return 0;
}

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

happy = 0

if 500 <= x :
    sho_a = (x // 500)
    happy = sho_a * 1000
    x = x - (sho_a * 500)
    sho_b = x // 5
    happy = happy + sho_b * 5
else : 
    sho_b = x // 5
    happy = sho_b * 5

print(happy)

Measured memory_bytes: 3060
//***********************************JAI SAI RAM***************************************//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ios>
using namespace std;
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define endl '\n'
void solve()
{
    ll n,m,i,j,k,l,o,p,q,r,t,num,den;
     vector<pair<ll,ll>> v1;
     map<pair<ll,ll>,ll> mp;
    long double x;
    cin>>n;
    for(i=0;i<n;i++)
    {
         cin>>x;

         o=llround(x*1000000000.0);
         num=o;
         //cout<<num<<endl;
         den=1000000000;
         p=__gcd(num,den);
         num/=p;
         den/=p;
        p=0;
        while(num>0&&num%2==0)
        {
            num/=2;
            p++;
        }
        q=0;
        while(num>0&&num%5==0)
        {
            num/=5;
            q++;
        }
        while(den>0&&den%2==0)
        {
            den/=2;
            p--;
        }
        while(den>0&&den%5==0)
        {
            den/=5;
            q--;
        }
        mp[{p,q}]++;
        v1.push_back({p,q});
    }
    ll ans=0;
    for(i=0;i<n;i++)
    {
        ll x,y;
        x=v1[i].first;
        y=v1[i].second;
        mp[v1[i]]--;
        for(auto it:mp)
        {
           if(it.first.first+x>=0&&it.first.second+y>=0)
           ans+=it.second;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

ll dp[100005][100][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int d;
    cin >> d;
    for (int i = 0; i < (s[0] - '0'); i++) dp[0][i % d][0] += 1;
    dp[0][(s[0] - '0') % d][1] = 1;
    for (int i = 1; i < s.length(); i++) {
        for (int j = 0; j < d; j++) {
            for (int k = 0; k <= 9; k++) {
                dp[i][j][0] += dp[i - 1][(j - k + 10 * d) % d][0];
                if (k < (s[i] - '0')) dp[i][j][0] += dp[i - 1][(j - k + 10 * d) % d][1];
                if (k == (s[i] - '0')) dp[i][j][1] += dp[i - 1][(j - k + 10 * d) % d][1];
                dp[i][j][0] %= mod;
                dp[i][j][1] %= mod;
            }
        }
    }
    cout << (dp[s.length() - 1][0][0] + dp[s.length() - 1][0][1] - 1 + mod) % mod;
    return 0;
}

ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {
    int gcd(int a, int b) {
        if (a > b) return gcd(b, a);
        if (a == 0) return b;
        return gcd(b % a, a);
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }

        int[] ls = new int[n];
        int[] rs = new int[n];
        for (int i = 0; i < n; i++) {
            int j = n - i - 1;
            if (i == 0) {
                ls[i] = as[i];
                rs[j] = as[j];
            } else {
                ls[i] = gcd(ls[i - 1], as[i]);
                rs[j] = gcd(rs[j + 1], as[j]);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans = Math.max(ans, rs[1]);
            } else if (i == n - 1) {
                ans = Math.max(ans, ls[n - 2]);
            } else {
                ans = Math.max(ans, gcd(ls[i - 1], rs[i + 1]));
            }
        }
        System.out.println(ans);
    }

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


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

import sys
from math import hypot

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def dijkstra(N: int, nodes: list, src: int) -> list:
    """ ダイクストラ(頂点数, 隣接リスト(0-indexed), 始点) """
    from heapq import heappush, heappop

    # 頂点[ある始点からの最短距離] (経路自体を知りたい時はここに前の頂点も持たせる)
    res = [INF] * N
    # スタート位置
    que = [(0, src)]
    res[src] = 0
    # キューが空になるまで
    while len(que) != 0:
        # srcからの距離, 現在のノード
        dist, cur = heappop(que)
        if res[cur] < dist:
            continue
        # 出発ノードcurの到着ノードでループ
        for nxt, cost in nodes[cur]:
            # 今回の経路のが短い時
            if dist + cost < res[nxt]:
                res[nxt] = dist + cost
                # 現在の移動距離をキューの優先度として、早い方から先に処理するようにする
                heappush(que, (dist+cost, nxt))
    # ノードsrcからの最短距離リストを返却
    return res

sx, sy, tx, ty = MAP()
N = INT()
XYR = []
for i in range(N):
    x, y, r = MAP()
    XYR.append((x, y, r))
# 始点と終点も半径0の円とする
XYR.append((sx, sy, 0))
XYR.append((tx, ty, 0))
N += 2

# 各円を頂点としたグラフとみなす
nodes = [[] for i in range(N)]
for i in range(N):
    x1, y1, r1 = XYR[i]
    for j in range(i+1, N):
        x2, y2, r2 = XYR[j]
        dist = hypot(x1-x2, y1-y2)
        # 2円間の距離(重なっていれば0)
        cost = max(dist - (r1+r2), 0)
        nodes[i].append((j, cost))
        nodes[j].append((i, cost))

res = dijkstra(N, nodes, N-2)
print(res[N-1])


Measured memory_bytes: 126600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x[100],a;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>x[i];
    cin>>a;
    while(cin>>a)
        if(x[a-1]!=2019&&x[a-1]+1!=x[a])
            x[a-1]++;
    for(int i=0;i<n;i++)
        cout<<x[i]<<endl;
}



Measured memory_bytes: 3104
# -*- conding: utf-8 -*-
import math
N = int(input())
S = input()

count_R = 0
count_G = 0
count_B = 0
for s in S:
  if s == "R":
    count_R += 1
  elif s == "G":
    count_G += 1
  else:
    count_B += 1

count = 0
for i in range(N-2):
  for j in range(i+1, (N+1+i)//2):
    if S[i] != S[j] and S[i] != S[j+(j-i)] and S[j] != S[j+(j-i)]:
      count += 1

print(count_R * count_G * count_B - count)

Measured memory_bytes: 73392
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int N,M,X,Y;
int mX, mY;
int main() {
	cin >>N>>M>>X>>Y ;
	mX = X;
	mY = Y;
	for (int i = 0; i < N;i++) {
		int x;
		cin >> x;
		mX = max(x, mX);
	}
	for (int i = 0; i < M;i++) {
		int y;
		cin >> y;
		mY = min(mY, y);
	}
	if (mX>=mY) {
		cout << "War";
	}
	else {
		cout << "No War";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i=0; i<s.length(); i++){
            char c = s.charAt(i);
            if(c==','){
                System.out.print(" ");
            }else{
                String t = String.valueOf(c);
                System.out.print(t);
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

ll calc(ll x, ll d, const vector<ll>& A) {
    // 1~d桁まで見て、xを自由に決める
    rep(i, d) {
        ll one = 0, zero = 0;
        rep(j, A.size()) {
            if ((A[j] >> (d - 1 - i)) & 1) {
                one++;
            }
            else {
                zero++;
            }
        }
        if (one > zero) {
            x = x * 2 + 0;
        }
        else {
            x = x * 2 + 1;
        }
    }
    return x;
}

ll xorA(ll x, const vector<ll>& A) {
    ll v = 0;
    rep(i, A.size()) {
        v += x ^ A[i];
    }
    return v;
}

ll dfs(ll x, ll d, ll K, const vector<ll>& A) {
    if (d <= 0) {
        return x;
    }
    if ((K & (1LL << (d-1))) == 0) {
        // xのdビット目は0
        x = dfs(2 * x, d - 1, K, A);
        return x;
    }
    if (K == (1LL << d) - 1) {
        x = calc(x, d, A);
        return x;
    }

    ll x1 = dfs(2 * x + 1, d - 1, K - (1LL << (d - 1)), A);
    ll v1 = xorA(x1, A);

    ll x2 = 2 * x + 0;
    x2 = calc(x2, d - 1, A);
    ll v2 = xorA(x2, A);

    if (v1 > v2) {
        return x1;
    }
    return x2;
}


void Main()
{
    ll n, K;
    cin >> n >> K;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll digit = 0;
    for (ll t = K; t > 0; t /= 2) digit++;
    
    ll x = dfs(0, digit, K, A);
    ll res = xorA(x, A);
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> P;

int n,w,d,p,s;
P c[101];

int main(){
	while(cin>>n>>w>>d&&w){
		rep(i,n+1)c[i]=make_pair(0,0);
		c[0]=make_pair(w,d);
		c[2]=make_pair(1,1);
		rep(i,n){
			cin>>p>>s;
			p--;
			int ww=c[p].first,dd=c[p].second;
			for(int j=p;j<i;j++)c[j]=c[j+1];
			s%=2*(ww+dd);
			if(s<ww){
				c[i]=make_pair(min(s,ww-s),dd);
				c[i+1]=make_pair(max(s,ww-s),dd);
			}
			if(ww<s&&s<ww+dd){
				s-=ww;
				c[i]=make_pair(ww,min(s,dd-s));
				c[i+1]=make_pair(ww,max(s,dd-s));
			}
			if(ww+dd<s&&s<ww*2+dd){
				s-=ww+dd;
				c[i]=make_pair(min(s,ww-s),dd);
				c[i+1]=make_pair(max(s,ww-s),dd);
			}
			if(ww*2+dd<s){
				s-=ww*2+dd;
				c[i]=make_pair(ww,min(s,dd-s));
				c[i+1]=make_pair(ww,max(s,dd-s));
			}
			//rep(j,n+1)cout<<c[j].first<<","<<c[j].second<<(j<n?"/":"\n");
		}
		int c2[101];
		rep(i,n+1)c2[i]=c[i].first*c[i].second;
		sort(c2,c2+n+1);
		rep(i,n+1)cout<<c2[i]<<(i<n?" ":"\n");
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;

  return 0;

}


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

using namespace std;
	
int main(){
	string s,t;
	cin >> s >> t;
	
	vector<pair<bool,int>> down(26),up(26);
	
	
	for(int i=0;i<26;i++){
		down[i].first=false;
		down[i].second=0;
		up[i].first=false;
		up[i].second=0;
	}
		
	//上から下
	for(int i=0;i<s.size();i++){
		
		int AL_index=(int)(s[i]-('a'));
		int Now_dist=(int)(s[i]-t[i]);
		
		if(down[AL_index].first==true){
			if(down[AL_index].second==Now_dist){
				continue;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
			
		if(down[AL_index].first==false){
			down[AL_index].first=true;
			down[AL_index].second=Now_dist;
		}
	}
	
	//下から上
	for(int i=0;i<t.size();i++){
		int AL_index=(int)t[i]-int('a');
		int Now_dist=(int)(t[i]-s[i]);
		
		if(up[AL_index].first==true){
			if(up[AL_index].second==Now_dist){
				continue;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
			
		if(up[AL_index].first==false){
			up[AL_index].first=true;
			up[AL_index].second=Now_dist;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 776
L, R = map(int, input().split())
mod_n = 2019
if (mod_n) < (R - L + 1):
    R = L + mod_n

v = []
for i in range(L,R+1):
    v.append(i % mod_n)

ans = 2020
for i in range(len(v)-1):
    for j in range(i+1,len(v)):
        #print("{} {}".format(v[i],v[j]))
        mul_v = v[i] * v[j] % mod_n
        if mul_v < ans:
            #print("{} {} {} {}".format(v[i],v[j],i, j))
            ans = mul_v

print(ans)


Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N;
    cin >> N;
    vector<int> s(N);
    rep(i,N) cin >> s[i];
    sort(begin(s), end(s));
    rep(i,N) rep(j,i) {
        auto r = lower_bound(begin(s), end(s), s[i]+s[j]);
        auto l = upper_bound(begin(s), r, s[i]-s[j]);
        l = upper_bound(l, r, s[j]-s[i]);
        ans += r - l;
        auto b = begin(s);
        if (r > b+i && b+i >= l) {
            --ans;
        }
        if (r > b+j && b+j >= l) {
            --ans;
        }
    }
    cout << ans/3 << endl;
}


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

typedef struct{
  int correct;
  int wrong[10];
  int pena;
  int team_id;
} Log;

bool operator>(const Log &l1,const Log &l2){
  if(l1.correct != l2.correct) return (l1.correct > l2.correct);
  else if(l1.pena != l2.pena) return (l1.pena < l2.pena);
  else return (l1.team_id < l2.team_id);
}

int main(){
  int t,p,r;
  while(cin>>t>>p>>r,t){
    Log log;
    for(int i=0;i<10;i++)
      log.wrong[i]=0;
    log.correct=log.pena=0;
    vector<Log> vec(t,log);
    for(int i=0;i<t;i++)
      vec[i].team_id=i+1;

    for(int i=0;i<r;i++){
      int tid,pid,time;
      string str;
      cin>>tid>>pid>>time>>str;
      tid--;
      pid--;
      if(str=="WRONG"){
	vec[tid].wrong[pid]++;
      }else if(str=="CORRECT"){
	vec[tid].correct++;
	vec[tid].pena+=(vec[tid].wrong[pid]*1200+time);
      }
    }

    sort(vec.begin(),vec.end(),greater<Log>());
    for(int i=0;i<t;i++){
      cout<<vec[i].team_id<<" "<<vec[i].correct<<" "<<vec[i].pena<<endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1244
from sys import stdin
import sys
import math
import random
from decimal import Decimal
import itertools as it


H, W, K = [int(x) for x in stdin.readline().rstrip().split()]
# A = list(map(int, input().split()))
c = []
for i in range(H):
    c.append(list(input()))
# print(c)
# for i in range(H):
a = [[(0,)]]
a2 = [[(0,)]]
b = []
b2 = []
for i in range(1, H+1):
    b.append(i)
for i in range(1, H):
    a.append(list(it.combinations(b, i)))
for i in range(1, W+1):
    b2.append(i)
for i in range(1, W):
    a2.append(list(it.combinations(b2, i)))
# print(a)
b.append(0)
b2.append(0)
ans = 0
ans1 = 0
for iw, vw in enumerate(a2):
    for kw in range(len(vw)):
        for ih, vh in enumerate(a):
            for kh in range(len(vh)):
                vw[kw] = list(vw[kw])
                vh[kh] = list(vh[kh])
                ans = 0
                for iww in range(1, W+1):
                    if iww not in vw[kw]:
                        for ihh in range(1, H+1):
                            if ihh not in vh[kh]:
                                if c[ihh-1][iww-1] == '#':
                                    ans += 1
                # print(vw[kw],vh[kh],ans)
                if ans == K:
                    ans1 += 1
print(ans1)


Measured memory_bytes: 10196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if (m == -1 && f == -1 && r == -1){
				break ;
			}
			if (m == -1 || f == -1) {
				System.out.println("F");
			}else if(m + f >= 80){
				System.out.println("A");
			}else if(m + f >= 65){
				System.out.println("B");
			}else if(m + f >= 50){
				System.out.println("C");
			}else if(m + f >= 30){
				if (r >= 50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}
		}
	}
}


Measured memory_bytes: 26372
import bisect
try:
    while True:
        a = map(int, raw_input().split(','))
        b = [0] * 11
        for i in range(10):
            b[i + 1] = b[i] + a[i]
        print bisect.bisect_left(b, float(a[-2]) * b[-1] / (a[-1] + a[-2]))
except:
    pass

Measured memory_bytes: 4292
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    ll A,B; cin>>A>>B;

    cout<<(A*B)/__gcd(A,B)<<endl;

    return 0;

}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const a = parseInt(input[0].split(" ")[0], 10);
  const b = parseInt(input[0].split(" ")[1], 10);
  const c = (a + b) / 2

  console.log((a + b) % 2 === 0 ? c : 'IMPOSSIBLE')
}


// *出力
// number
// console.log('%d', );
// string
// console.log('%s', );

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22080
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int num;
    for (int i = 1;; ++i) {
        scanf("%d", &num);
        if(0 == num) {
            break;
        }else {
            printf("Case %d: %d\n", i, num);
        }
    }
    return 0;
}

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

long long gcd(long long x,long long y){
  if(x<y)swap(x,y);
  if(y==0)return x;
  return gcd(y,x%y);
}
long long lcm(long long x,long long y){
  return x/gcd(x,y)*y;
}
long long a,b,c,d;
long long f(long long x){
  return x-(x/c)-(x/d)+x/lcm(c,d);
}
int main(){
  
  cin>>a>>b>>c>>d;
  long long ans=f(b)-f(a-1);
  cout<<ans<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const ll mod = 998244353;
 
ll F[10101010], FI[10101010];
ll n, ans;
 
ll inv(ll x) { return x > 1? mod / x * (mod - inv(mod % x)) % mod : 1; }
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll i, t;
	
	cin >> n;
	
	for(i = 1, F[0] = 1; i <= n; i ++){
		F[i] = F[i - 1] * i % mod;
    }
	
	FI[n] = inv(F[n]);
	
	for(i = n, ans = 1; i; i --){
		FI[i - 1] = FI[i] * i % mod;
		ans = ans * 3 % mod;
    }
	
	for(i = n, t = 2 * F[n] % mod; i + i > n; i --){
		ans = (ans - t * FI[n - i] % mod * FI[i]) % mod;
		t = t * 2 % mod;
    }
	
	cout << (ans + mod) % mod << "\n";
	
	return 0;
}

Measured memory_bytes: 157952
package main

import (
  "fmt"
)

func main() {

  var n int

  fmt.Scan(&n)

  if n % 2 == 0 {
    fmt.Println(0.5)
  } else {
    m := float32(n)
    fmt.Println(float32((n/2)+1) / m)
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

string s, t;
int dp[3001][3001];

int main() {
   cin >> s >> t;
   for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
         if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
         else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
   }
   // cout << dp[s.size()][t.size()] << endl;
   string ans = "";
   int i = (int)s.size();
   int j = (int)t.size();
   while (i > 0 && j > 0) {
      if (dp[i][j] == dp[i - 1][j]) i--;
      else if (dp[i][j] == dp[i][j - 1]) j--;
      else {
         ans = s[i - 1] + ans;
         i--;
         j--;
      } 
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 35456
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
	long x=1,y=1;
	for(int i=1;i<=K;i++)
	{
		x=x*(N-i+1)%MOD;
		y=y*i%MOD;
	}
	return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

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

    int N, K;
    cin >> N >> K;
    VI a(N);
    REP(i,N) cin >> a[i];

    LL ans = INF*INF;
    REP(bit, 1<<N){
        if (__builtin_popcount(bit) >= K && bit & (1<<0)){
            LL M = a[0], cost = 0;
            FOR(i,1,N){
                if (bit & (1<<i)){
                    if (a[i] <= M) {
                        M++;
                        cost += M-a[i];
                    }
                    else {
                        M = a[i];
                    }
                }
                else {
                    M = max(M, (LL)a[i]);
                }
            }
            ans = min(ans, cost);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll L,K;cin>>L;
  K=L;
  ll digit=0,add_edge_num=-1;
  while(K){
  	if(K&1){
  		add_edge_num++;
  	}
  	K=K>>1;
  	digit++;
  }
  ll n,m;n=digit;m=2*(digit-1)+add_edge_num;
  cout<<n<<" "<<m<<endl;

  ll add_edge_val=ll(pow(2,digit-1));
  rep(i,digit-1){
  	cout<<digit-i-1<<" "<<digit-i<<" "<<ll(pow(2,digit-i-2))<<endl;
  	cout<<digit-i-1<<" "<<digit-i<<" "<<0<<endl;
  	if(L&(1<<(digit-2-i))){
  		cout<<digit-i-1<<" "<<digit<<" "<<add_edge_val<<endl;
  		add_edge_val+=ll(pow(2,digit-i-2));
  	}
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long p[100005],N,Q,A;
int main() {
    cin>>N>>Q;
    for (int i=0;i<N;i++)scanf("%lld",&p[i]);
    for (int i=0;i<Q;i++){
        long long sum=0,R=0;cin>>A;
        long long cnt=0;
        for(int i=0;i<N;i++){
            while (R<N && sum+p[R]<=A) {
                sum+=p[R++];
            }
            if(sum>0){sum-=p[i];}
            cnt+=R-i;
            if(R<i+1)R=i+1;
        }
        cout << cnt << endl;
    }
    return 0;
}

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


int main(){
    double n,x;
    string u;
    double ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
     cin>>x>>u;
     //cout<<u<<endl;
     if(u=="BTC"){
        ans+=(380000.0*x);
            //cout<<ans<<endl;
        }
     else{
        ans+=x;
     }
    }
  cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outi(ll i){cout<<i<<endl;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

int main(){
    string s;cin>>s;
    int n=s.size();
    ll ans=0;
    rep(i,n/2){
        if(s[i]!=s[n-i-1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, P = map(int, input().split())
ans = 1
def main(n, p):
  if n == 1:
    return P
  global ans
  for i in range(2, int(p**(2/n))):
    t = i**n
    if p % t == 0:
      ans *= i
      return main(n, p//t)
  return ans

print(main(N, P))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<ll>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl

/*int gcd(int a,int b){
    while(a%=b&&b%=a);
    return a+b;
}*/

int main(){
    int n;
    cin>>n;
    //vi a(n);
    int a;
    int ans=0;
    REP(i,n){
        cin>>a;
        ans+=(a-1);
    }
    cout<<ans<<endl;
    return 0;
}


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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

typedef std::tuple<string,int,int> mytuple;

/*input*/
int n;
vector<tuple<string,int,int>> input;

/*funcs*/
bool mycompare( const mytuple &lhs, const mytuple &rhs )
{
    if (std::get<0>(lhs) != std::get<0>(rhs)) return std::get<0>(lhs) < std::get<0>(rhs);
    if (std::get<1>(lhs) != std::get<1>(rhs)) return std::get<1>(lhs) > std::get<1>(rhs);
    return std::get<2>(lhs) < std::get<2>(rhs);
}

/*main*/
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        int p;
        cin>>s>>p;
        input.push_back(make_tuple(s,p,i+1));
    }
    vector<tuple<string,int,int>> sorted=input;
    sort(input.begin(),input.end(),mycompare);
    for(int j=0;j<input.size();j++){
        cout<<get<2>(input[j])<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N, D;
  cin >> N >> D;
  int view = 1 + 2*D;
  int ans = N / view;
  if(N%view!=0)ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("kmp.in","r",stdin);freopen ("kmp.out","w",stdout);
#define mod 1000000009
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum,ans[N];

char s[N];

int main()
{
	fast;
	cin>>s+1;
	n=strlen(s+1);
	ar[1]=1;
	ar[0]=0;
	fo(i,2,n)
	{
		if(s[i]=='L')
			ans[i]+=ar[i%2],ans[i-1]+=ar[(i+1)%2],ar[1]=0,ar[0]=0;
		else
		ar[i%2]++;
	}
	ar[1]=0;
	ar[0]=0;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='R')
			ans[i]+=ar[i%2],ans[i+1]+=ar[(i+1)%2],ar[1]=0,ar[0]=0;
		else
		ar[i%2]++;
	}
	fo(i,1,n)
	cout<<ans[i]<<sp;

}



/*     cd onedrive\desktop\kod
cls


*/

Measured memory_bytes: 3456
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e7 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m , k ;
    cin >> n >> m >> k ;
    vector<string> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ; 
    }
    int L = (n - 1) ;
    int ans = INF ;
    for(int i = 0; i < (1 << L); i++){
        vector<int> pos ;
        for(int j = 0; j < L; j++){
            if ( (1 << j) & i ) {
                pos.push_back(j) ;
            }
        }
        int div = (int)pos.size() ;
        vector<int> parts((int) pos.size() + 1);
        bool ok = true ;
        for(int col = 0; col < m; col++){
            int idx = 0 ; 
            for(int row = 0; row < n; row++){
                parts[idx] += (v[row][col] == '1');
                if ( idx < (int)pos.size() && row == pos[idx] ){
                    idx++;
                }
            }
            debug() << imie(parts) ;
            int nax = 0 ;
            for(int j = 0; j < (int)parts.size(); j++){
                nax = max(nax, parts[j]);
            }
            if ( nax > k ){
                div++;
                for(int &c : parts) c = 0 ;
                idx = 0 ;
                for(int row = 0; row < n; row++){
                    debug() << imie(row) imie(col);
                    parts[idx] += (v[row][col] == '1');
                    if ( idx < (int) pos.size() && row == pos[idx] ){
                        idx++;
                    }
                }
                debug() << "====" imie(parts);
                nax = 0 ;
                for(int j = 0; j < (int)parts.size(); j++){
                    nax = max(nax, parts[j]);
                }
                if ( nax > k ) {
                    ok = false;
                    break ;
                }
            }
        }
        if ( ok ) ans = min(ans, div) ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256