akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	k := readi()
	n := readi()
	a := atoi(readSlice())

	var max int
	for i := 0; i < n; i++ {
		if min(abs(a[(i+1)%n]-a[i]), abs(k-a[i]+a[(i+1)%n])) > max {
			max = min(abs(a[(i+1)%n]-a[i]), abs(k-a[i]+a[(i+1)%n]))
		}
	}
	fmt.Println(k - max)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

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

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

Measured memory_bytes: 10496
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

    ll n,k;
    cin >> n >> k;
    while(n >= k-n){
        if(n < k) swap(n,k);
        n = n%k;
    }
    cout << n << endl;

    

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var aa string
	fmt.Scanf("%s", &aa)
	// SUN,MON,TUE,WED,THU,FRI,SAT
	mm := map[string]int{"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}

	fmt.Printf("%d\n", mm[aa])
}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

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

    int rest = N % 500;
    if (rest <= A) cout << "Yes" << endl;
    else cout << "No" << 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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input sheet
    vector<vector<int>> matrix(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            int a;
            cin >> a;
            matrix.at(i).at(j) = a;
        }
    }

    // N loop
    int N;
    cin >> N;
    vector<int> choice(N);
    for (int i = 0; i < N; i++) {
        cin >> choice.at(i);
    }

    // check
    // O(9 * N)
    vector<vector<int>> ans{
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
    };

    rep(i, 3) {
        rep(j, 3) {
            rep(k, N) {
                if (matrix.at(i).at(j) == choice.at(k)) {
                    ans.at(i).at(j) = -1;
                }
            }
        }
    }

    // check the bingo
    // horizontal
    bool is_bingo = false;
    rep(i, 3) {
        if (ans[i][0] == -1 && ans[i][1] == -1 && ans[i][2] == -1) {
            is_bingo = true;
        }
    }
    // vertical
    rep(i, 3) {
        if (ans[0][i] == -1 && ans[1][i] == -1 && ans[2][i] == -1) {
            is_bingo = true;
        }
    }
    // diagonal
    if (ans[0][0] == -1 && ans[1][1] == -1 && ans[2][2] == -1) {
        is_bingo = true;
    } else if (ans[2][0] == -1 && ans[1][1] == -1 && ans[0][2] == -1) {
        is_bingo = true;
    }

    if (is_bingo) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    int X, a, b;
    cin >> X;
    a = X / 100;
    b = X%100;
    if (b > a * 5){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll x,n,i,j;
    ll ans=0;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    for(i=1;i<(n-1);i++)
    {
        if(arr[i-1]>arr[i]&&arr[i+1]<arr[i])
        ans++;
        else if(arr[i-1]<arr[i]&&arr[i+1]>arr[i])
        ans++;
    }
    cout<<ans;
}
    


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;
using ull = size_t;

ll N, M;
vector<ll> X;

void input() {
    cin >> N >> M;
    X.resize(M);
    for (auto& x : X) cin >> x;
}

void solve() {
    sort(X.begin(), X.end());
    vector<ull> diff(M - 1);
    for (ull i = 0; i < M - 1; i++) {
        diff[i] = X[i + 1] - X[i];
    }
    sort(diff.begin(), diff.end(), [](auto l, auto r) {return l > r;});
    ull ans = 0;
    for (ull i = N - 1; i < diff.size(); i++)
        ans += diff[i];
    cout << ans << endl;
}

int main() {
    input();
    
    solve();
    
    return 0;
}



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

int main(){
  int n,d,x,a;
  cin>>n>>d>>x;
  for(int i=0; i<n; i++){
    cin>>a;
    int cnt = 0;
    for(int j=1; j<=d; j++){
      if(j==cnt*a+1){
	x++;
	cnt++;
      }
    }
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    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();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=200050;
int n,k;
int a[maxn];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	if(k>=n) puts("0");
	else
	{
		ll sum=0;
		for(int i=1;i<=n-k;i++) sum+=a[i];
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int r;
    cin >> r;
    cout << (double)r * 2 * M_PI << endl;
    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
  IOS;
  ll n;cin>>n;
  vector<ll> a(n-1),b(n-1),c(n-1);
  rep(i,n-1) cin>>a[i]>>b[i]>>c[i],a[i]--,b[i]--;
  ll q,k;cin>>q>>k;k--;
  vector<ll> x(q),y(q);
  vector<pair<ll,ll>> g[n];
  rep(i,n-1){
    g[a[i]].push_back({b[i],c[i]});
    g[b[i]].push_back({a[i],c[i]});
  }
  vector<ll> to_k(n,-1);
  queue<ll> que;
  que.push(k);
  to_k[k]=0;
  while(!que.empty()){
    auto tmp=que.front();
    que.pop();
    for(auto c:g[tmp]){
      if(to_k[c.first]==-1){
        to_k[c.first]=to_k[tmp]+c.second;
        que.push(c.first);
      }
    }
  }
  rep(i,q){
    ll x,y;cin>>x>>y;x--;y--;
    cout<<to_k[x]+to_k[y]<<endl;
  }
}

Measured memory_bytes: 13952
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def check(n):
    ans=1
    c=0
    for i in range(1,100):
        c+=i
        if(n<c):
            break
        ans=i
    return ans

N=int(input())
if(N>1):
    arr=factorization(N)
    ans=0
    for i in range(len(arr)):
        ans+=check(arr[i][1])
    print(ans)
else:
    print(0)

Measured memory_bytes: 9504
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	int h, w, K;
	cin >> h >> w >> K;
	int s[10][1000];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			s[i][j] = c - '0';
		}
	}

	int ans = mod;
	for (int i = 0; i < (1 << (h - 1)); i++) {
		int res = 0;
		vector<int> v;
		int startw = 0;
		for (int j = 0; j < h - 1; j++) {
			if ((i & (1 << j)) > 0) {
				v.push_back(0);
				res++;
			}
		}
		v.push_back(0);
		// cout << i << endl;
		for (int j = 0; j < w; j++) {
			int nowind = 0;
			for (int k = 0; k < h; k++) {
				if (s[k][j] == 0) {
					if ((i & (1 << k)) > 0) {
						nowind++;
					}
					continue;
				}
				if (v[nowind] == K) {
					if (startw == j) {
						res = mod;
						j = w;
						break;
					}
					res++;
					v = vector<int>(v.size(), 0);
					startw = j;
					j--;
					break;
				}
				v[nowind]++;
				if ((i & (1 << k)) > 0) {
					nowind++;
				}
				// cout << "\t";
				// for (int p = 0; p < v.size(); p++) {
				// 	cout << v[p] << " ";
				// }
				// cout << endl;
			}
		}
		ans = min(ans, res);
		// cout << res << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans += s[i] - '0';
  }
  if (ans % 9 == 0) cout << "Yes";
  else cout << "No";
}

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

using namespace std;
using ll = long long;

class UnionFind{
  private:
	vector<int> data;

  public:
	UnionFind(int n) : data(n,-1) {}
	int root(int i) { return data[i] < 0 ? i : data[i] = root(data[i]); }
	int size(int i) { return -data[root(i)]; }
	bool same(int x, int y) {return root(x) == root(y); }
	bool connected() {return size(0) == (int)data.size(); }

	bool unit(int i,int j){
		i = root(i);
		j = root(j);
		if(i != j){
			data[i] += data[j];
			data[j] = i;
		}
		return i != j;
	}
};

int main()
{
	int n, m; cin >> n >> m;
	UnionFind tree(n);
	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b; a--, b--;
		tree.unit(a,b);
	}
	int nax = 0;
	for(int i = 0; i < n; i++) {
		nax = max(nax, tree.size(i));
	}
	cout << nax << endl;
}

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

class MainClass {
  public static void Main (string[] args) {
	  // 入力
    var str = Console.ReadLine().Split(' ');
    var str2 = Console.ReadLine().Split(' ');
    bool flag = false;
    //処理
    for(var i = int.Parse(str[0]);; i++){
      flag = false;
      foreach(var s in i.ToString()){
        if(str2.Any(x => x == s.ToString())){
          flag = true;
          break;
        }
      }
      if(!flag){
        Console.WriteLine(i);
        return;
      }
    }
    //出力
    
  }
}


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

using namespace std;

int main(){

  int R;

  cin >> R;

  if(R < 1200){
    cout << "ABC" << endl;
  }else if(R < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }

  
  return 0;
}


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

using i64 = int64_t;

int main(){
    int n;
    while(cin >> n, n != 0){
        vector<i64> v;
        i64 sum = 0;
        for(int i=0;i<n;++i){
            i64 tmp;
            cin >> tmp;
            v.push_back(tmp);
            sum += tmp;
        }
        double mean = sum / (double)n;
        int ans = 0;
        for(int i=0;i<n;++i){
            if(v[i] <= mean)ans++;
        }

        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	if (n < 1000) {
		cout << "ABC" << endl;
	} else {
		cout << "ABD" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        x: usize
    }
    let mut n = 100;
    let mut ans = 0;
    while n < x {
        n += n / 100;
        ans += 1;
    }
    println!("{}", ans);
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,a,b;
    cin >>n>>a>>b;
    ll d=abs(a-b);
    if(d%2==0)puts("Alice");
    if(d%2==1)puts("Borys");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

void solve() {
    int n, a, b, c, d;
    std::cin >> n >> a >> b >> c >> d;
    std::cout << std::min((n + a - 1) / a * b, (n + c - 1) / c * d)
              << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	if (a > b * 2){
		printf("%d",a-b*2);
	}
	
	else {
		printf("0");
	}
	
	return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,mn,cnt=0;
    string s;
    cin>>n>>s;
    rep(i,1,n){
        if(s[i]=='E')cnt++;
        mn=cnt;
    }
    rep(i,1,n){
        if(s[i-1]=='W')cnt++;
        if(s[i]=='E')cnt--;
        if(mn>cnt)mn=cnt;
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 720
import sys
n=int(input())
s=input()
if n%2==1:
    print("No")
    sys.exit()
else:
    s1=s[:n//2]
    s2=s[n//2:]
    # print(s1,s2)
    if s1==s2:
        print("Yes")
    else:
        print("No")

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

using namespace std;

#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef vector< pair<int,int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int,int> pii;

const ll INF= ll (1e18);
const int MOD= 1e9+7;

int main()
{
    vi v;
    int graph[10][10]={0};

    int n,m;
    cin>>n>>m;

    while(m--)
    {
        int u,v;
        cin>>u>>v;

        graph[u][v]=1;
        graph[v][u]=1;
    }

    for(int i=0;i<n;i++)
        v.pb(i+1);

 int cnt=0;

    do
    {
        int flag=0;

        if(v[0]!=1)
            break;

        for(int i=0;i<=n-2;i++)
        {
            if(graph[v[i]][v[i+1]]!=1)
            {
                flag=1;
                break;
            }
        }

        if(flag==0)
            cnt++;

    }while(next_permutation(v.begin(),v.end()));

    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include <stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{   
    int A ,B;
    cin>>A>>B;

    int s1,s2,s3;

    s1 = 2*A-1;
    s2 = 2*B-1;
    s3 = A + B;
    cout<<max(s1,max(s2,s3));

    return 0;
}

Measured memory_bytes: 256
require'complex'
nd=gets.chomp.split(" ").map(&:to_i)
x=[]
nd[0].times do|i|
	x[i]=gets.chomp.split(" ").map(&:to_i)
end
cnt=0
(nd[0]-1).times do|i|
	for j in i+1..nd[0]-1
		res=0
		nd[1].times do|k|
			res+=(x[i][k]-x[j][k])**2
		end
		ans=Math.sqrt(res).floor
		cnt+=1 if(Math.sqrt(res).to_f==ans.to_f)
	end
end
p cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define PI 3.1415926535897932
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n; cin>>n;
    ll sum=0;
    f(i,1,n+1) {
        if(i%3!=0 && i%5!=0) sum+=i;
    }
    cout<<sum;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main() {
    int a=0;
    string S; cin>>S;
    if (S[0]=='R' || S[1]=='R' || S[2]=='R') a=1;
    if ((S[0]=='R' && S[1]=='R') || (S[1]=='R' && S[2]=='R')) a=2;
    if (S[0]=='R' && S[1]=='R' && S[2]=='R') a=3;
    cout << a << endl;
}

Measured memory_bytes: 3572
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, m) = intList()
    val x = intList().sorted()
    if (n >= m) {
        println("0")
        return
    }

    val d = 1.until(m).map { i ->
        Math.abs(x[i] - x[i - 1])
    }.sortedDescending().drop(n - 1).sum()

    println(d.toString())
}


Measured memory_bytes: 52604
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


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

  int n, m;
  int coin[20];

  cin >> n >> m;

  int dp[50001];

  rep(i, m){
    cin >> coin[i];
  }

dp[0] = 0;

  REP(i, 1, 50001){
    dp[i] = 100000;
  }

  rep(i, n+1){
    rep(j, m){
      if(i + coin[j] <= n){
        dp[i + coin[j]] = min(dp[i + coin[j]], dp[i] + 1);
      }
    }
  }

  cout << dp[n] << endl;







}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
int x[MAX_N], y[MAX_N];

vector<int> graph[MAX * 2 + 20];

int node2conn[MAX * 2 + 20];

void dfs(int node, int conn) {
  if (node2conn[node] >= 0) return;  // visited

  node2conn[node] = conn;

  for (auto &child : graph[node]) {
    dfs(child, conn);
  }
}

int main(void) {
  // Here your code !

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &(x[i]), &(y[i]));

    int node_x = x[i];
    int node_y = y[i] + MAX;

    graph[node_x].push_back(node_y);
    graph[node_y].push_back(node_x);
  }

  for (int i = 0; i < MAX * 2 + 20; ++i) {
    node2conn[i] = -1;
  }

  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    dfs(node_x, i);
  }

  unordered_set<int> xs;
  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    xs.insert(node_x);
  }

  unordered_map<int, ll> conn2xnodenum;
  for (auto &e : xs) {
    conn2xnodenum[node2conn[e]] += 1LL;
  }

  unordered_set<int> ys;
  for (int i = 0; i < n; ++i) {
    int node_y = y[i] + MAX;
    ys.insert(node_y);
  }

  unordered_map<int, ll> conn2ynodenum;
  for (auto &e : ys) {
    conn2ynodenum[node2conn[e]] += 1LL;
  }

  unordered_set<int> conns;
  for (int i = 0; i < MAX * 2 + 20; ++i) {
    int conn = node2conn[i];
    if (conn < 0) continue;
    conns.insert(conn);
  }

  ll ans = 0LL;

  for (auto &key : conns) {
    ans += conn2xnodenum[key] * conn2ynodenum[key];
  }

  ans -= (ll)(n);

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 19896
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
s = LS2()
for i in range(N):
    if s[i] == 'o':
        s[i] = 0
    else:
        s[i] = 1

for a,b in [(0,0),(0,1),(1,0),(1,1)]:  # 1,2番目の動物で全探索
    A = [0]*N
    A[0] = a
    A[1] = b
    for i in range(2,N):
        A[i] = A[i-2] ^ A[i-1] ^ s[i-1]
    if A[0] == A[-2] ^ A[-1] ^ s[-1] and A[1] == A[-1] ^ A[0] ^ s[0]:
        A = ['S' if A[i] == 0 else 'W' for i in range(N)]
        print(''.join(A))
        exit()

print(-1)


Measured memory_bytes: 83964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> SP(N);
    rep(i, N)
    {
        string s;
        int p;
        cin >> s >> p;
        SP[i] = {{s, -p}, i};
    }
    vector<pair<pair<string, int>, int>> tmp;
    tmp = SP;
    sort(tmp.begin(), tmp.end());
    rep(i, N)
    {
        cout << tmp[i].second + 1 << endl;
    }
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> l(n);
    map<int64_t, int64_t> m;
    m[0L] = -1L;
    for (auto i : irange(0L, n)) {
        auto it = --m.upper_bound(a[i]);
        l[i] = it->second;

        ++it;
        m.erase(it, m.end());
        m[a[i]] = i;
    }

    vector<int64_t> r(n);
    m.clear();
    m[0L] = n;
    for (auto i : irange(0L, n) | reversed) {
        auto it = --m.upper_bound(a[i]);
        r[i] = it->second;

        ++it;
        m.erase(it, m.end());
        m[a[i]] = i;
    }

    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        // cerr << l[i] << " " << r[i] << endl;
        ans += a[i] * (r[i] - i) * (i - l[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
string S;
int acc[3][4010];
int c[300];


signed main(){
    cin >> N;
    cin >> S;

    c['R'] = 0;
    c['G'] = 1;
    c['B'] = 2;

    rep(i, 0, 3) rep(j, 0, N){
        acc[i][j+1] = acc[i][j];
        if(c[S[j]] == i) acc[i][j+1]++;
    }

    int ans = 0;
    rep(i, 0, N) rep(j, i+1, N){
        if(S[i] == S[j]) continue;
        int cnt = 0;
        char c1 = S[i];
        char c2 = S[j];
        if(c1 < c2) swap(c1, c2);
        if(c1 == 'R' and c2 == 'G'){
            cnt += acc[2][N]-acc[2][j+1];
            if(2*j-i < N and S[2*j-i] == 'B') cnt--;
        }
        else if(c1 == 'R' and c2 == 'B'){
            cnt += acc[1][N]-acc[1][j+1];
            if(2*j-i < N and S[2*j-i] == 'G') cnt--;
        }
        else if(c1 == 'G' and c2 == 'B'){
            cnt += acc[0][N]-acc[0][j+1];
            if(2*j-i < N and S[2*j-i] == 'R') cnt--;
        }
        ans += cnt;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
n, m = gets.chomp.split.map(&:to_i)

list = Array.new(n+2, 0)
m.times do |i|
  l, r = gets.chomp.split.map(&:to_i)
  list[l] += 1
  list[r+1] -= 1
end

sum = [0]
count = 0
(1..n).each do |i|
  sum[i] = sum[i-1] + list[i]
  count += 1 if sum[i] == m
end

puts(count)

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

if A > B:
    print(0)
   
elif N == 1 and A != B:
    print(0)
    
elif N == 2:
    print(1)
    
elif A == B:
    print(1)
    
else:
    print((B * (N - 1) + A - (A * (N - 1) + B) + 1))
    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	char n;
	ll ans=0;
	cin>>n;
	cout<<(char)(n+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
// constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;

int n;
double r[510];
double pos[510];

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> r[i];
        pos[i] = r[i];
    }
}

void solve() {
    pos[0] = r[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            pos[i] = max(pos[i], pos[j] + 2 * sqrt(r[i] * r[j]));
        }
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, pos[i] + r[i]);
    }
    cout << setprecision(20) << ans << endl;
}

int main(int argc, char *argv[]) {
    input();
    solve();
    return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
 

//cout<<""<<endl;
int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll ma=-1000000000000000001;
  ma=max(ma,max(d*b,a*c));
  ma=max(ma,max(d*a,c*b));
  
  cout<<ma<<endl;
  
}






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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    int NN = N;
    vector<lint> A(N, 0);
    rep(i, N) cin >> A[i];
    sort(all(A));
    reverse(all(A));

    N = N - 1;

    lint ans = A[0];
    N--;

    for (int i = 1; i < NN; i++) {
        if (N == 0) break;
        ans += A[i];
        N--;
        if (N == 0) break;
        ans += A[i];
        N--;
        if (N == 0) break;
    }

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


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

using namespace std;

const int N = 200010;
const int MOD = (int)1e9 + 7;

inline int add(int u, int v) {
    return (u += v) >= MOD ? u - MOD : u;
}

inline int sub(int u, int v) {
    return (u -= v) < 0 ? u + MOD : u;
}

inline int mul(int u, int v) {
    return (long long)u * v % MOD;
}

inline int power(int u, int v) {
    int res = 1;
    while (v) {
        if (v & 1) res = mul(res, u);
        u = mul(u, u);
        v >>= 1;
    }
    return res;
}

inline int inv(int u) {
    return power(u, MOD - 2);
}

int n, m, k;
int fac[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    fac[0] = 1;
    for (int i = 1; i <= n * m; i++) {
        fac[i] = mul(fac[i - 1], i);
    }
    int delta = mul(fac[n * m - 2], inv(mul(fac[k - 2], fac[n * m - k])));
    auto get = [&](int n, int m) {
        int res = mul(m, m);
        res = mul(res, n - 1);
        res = mul(res, n);
        res = mul(res, n + 1);
        res = mul(res, inv(6));
        return res;
    };
    int res = add(get(n, m), get(m, n));
    res = mul(res, delta);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            #if i != n // i:
            divisors.append(n//i)

    return divisors

div = make_divisors(N)

for i in range(len(div)//2):
  a = div[2*i]
  b = div[2*i+1]
  ans = a + b - 2
  if i==0:
    tmp = ans
  else:  
    tmp = min(ans, tmp)
print(tmp)

Measured memory_bytes: 3264
d,g = map(int,input().split())
p=[]
c=[]
for i in range(d):
    pp,cc=map(int,input().split())
    p.append(pp)
    c.append(cc)
ans =100000
for i in range(2**d):
    score=0
    cnt=0
    other=[]
    bina = format(i,"b").zfill(d)
    for j in range(len(bina)):
        if bina[j]=="1":
            score += p[j]*100*(j+1) + c[j]
            cnt+=p[j]
        else:
            other.append(j)
    if score<g:
        x = g-score
        k = other[-1]
        if (p[k]-1)*(k+1)*100<x:
            continue
        cnt += -(-x//(100*(k+1)))
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), x.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  REP(i, n){
    int t;
    cin >> t;
    a[i] = --t;
  }
  REP(i, n) cin >> b[i];
  REP(i, n-1) cin >> c[i];

  int ans = 0;
  REP(i, n){
    ans += b[a[i]];
    if(a[i] != n-1){
      if(a[i+1] == a[i] + 1) ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector <int> v;
int i,x;
for(i=0;i<n;i++){
cin>>x;
v.push_back(x);
}
int c=0;
sort(v.begin(),v.end());
for(i=0;i<n-1;i++)
c+=v[i];
if(v[n-1]<c)
cout<<"Yes";
else
cout<<"No";
return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] cnt = new int[n];
            for (int i = 1; i < n; i++) {
                cnt[i] = (i % 10) + cnt[i / 10];
            }
            int ans = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                ans = Math.min(ans, cnt[i] + cnt[n - i]);
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 24788
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let (n, k, c): (usize, usize, usize) = (sc.read(), sc.read(), sc.read());
    let s = sc.chars();

    let mut pos: usize = 0;
    let l: Vec<usize> = (0..k)
        .map(|_| {
            while s[pos] == 'x' {
                pos += 1;
            }
            pos += c + 1;
            pos - c - 1
        })
        .collect();

    let mut pos: usize = n - 1;
    let r: Vec<usize> = (0..k)
        .map(|i| {
            while s[pos] == 'x' {
                pos -= 1;
            }
            if i + 1 < k {
                pos -= c + 1;
                pos + c + 1
            } else {
                pos
            }
        })
        .collect();

    for (x, y) in l.iter().zip(r.iter().rev()) {
        if x == y {
            write!(out, "{}\n", x + 1).ok();
        }
    }
}


Measured memory_bytes: 6028
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s string
	var K int
	fmt.Scan(&s, &K)
	n := len(s)

	lst := []string{}
	for i := 0; i < n; i++ {
		lst = append(lst, s[i:])
	}
	sort.Strings(lst)
	dic := map[string]struct{}{}

	for i := range lst {
		for j := 0; j < len(lst[i]); j++ {
			tmp := lst[i][:j+1]
			if _, in := dic[tmp]; !in {
				K--
				dic[tmp] = struct{}{}
			}
			if K == 0 {
				fmt.Println(tmp)
				return
			}
		}
	}
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

int main(){
  int member[4][3][10]={0};                  //??????????????????????±????????????????
  int i,j,k;                            //??????????????°??????
  int n;                          //??\??????????????±??°
  int a,b,c,d;                      //a????£????b?????????c?????¨?±????d????????°

  cin >> n;                         //??\??????????????±??°?????\???

  for(i=0;i<n;i++){
    cin >> a >> b >> c >> d;
      member[a-1][b-1][c-1] += d;                //??\??????????£????????????¨?±?????????°?????£??\
}


for(i=0;i<4;i++){
  for(j=0;j<3;j++){
    for(k=0;k<10;k++){
        cout << ' ' << member[i][j][k];                   //?????¨?±???????????????°?????¨???
    }
    cout << endl;
  }
  if(i<3){
    cout << "####################" << endl;              //?£???\?????????????????????????????\??????
  }
}

return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) {
    cin >> a[i];
  }

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

  cout << a[N-1] - a[0] << endl;
}

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

typedef long long ll;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ONLINE_JUDGE

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif

  ll N, K;
  vector<ll> a;
  const ll MOD = 1000000007;

  cin >> N >> K;
  // indexを1からはじまるようにする
  a.push_back(0);
  REP(i, N) {
    ll n;
    cin >> n;
    a.push_back(n);
  }
  // dp[i][j]
  // i番目の子供までにj個の飴を与えた場合の組み合わせの数
  // 答えはdp[N][K]
  ll dp[N + 1][K + 1];

  REP(i, N + 1) {
    REP(j, K + 1) {
      dp[i][j] = 0;
    }
  }

  dp[0][0] = 1;
  // dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] + ... + dp[i - 1][j - a(i)]
  // 素朴な方法 O(NK^2)
  // FOR(i, 1, N + 1)REP(j, K + 1) {
  //   FOR(k, 0, a[i] + 1) {
  //     if (j - k >= 0) {
  //       dp[i][j] += dp[i - 1][j - k] % MOD;
  //     }
  //   }
  // }

  // 累積和を使う
  // dp[i][j] = Σ[k=j-a[i]...j]dp[i-1][k]
  // dp[i][j] = Σ[k=0...j]dp[i-1][k] - Σ[k=0...(j -a[i] - 1)]dp[i-1][k]
  FOR(i, 1, N + 1) {
    ll cum[K + 2];

    // cum[j] = dp[i - 1][0] + ... + dp[i - 1][j - 1]

    // cum[1] = dp[i - 1][0]
    // cum[2] = dp[i - 1][0] + dp[i - 1][i]
    // :
    // cum[j + 1] = dp[i - 1][0] + dp[i - 1][1] + ... + dp[i - 1][j]
    // :
    // cum[K] = dp[i - 1][0] + ... + dp[i - 1][K - 1]
    // cum[K + 1] = dp[i - 1][0] + ... + dp[i - 1][K]
    cum[0] = 0;
    FOR(j, 1, K + 1 + 1) {
      cum[j] = (cum[j - 1] + dp[i - 1][j - 1]) % MOD;
    }

    FOR(j, 0, K + 1) {
      // cum[j - a[i]] = dp[i - 1][0] + dp[i - 1][1] + .... + dp[i - 1][j - a[i] - 1]
      dp[i][j] = (cum[j + 1] - cum[max<ll>(0, j - a[i])] + MOD) % MOD;
    }
  }

  // REP(i, N + 1) {
  //   REP(j, K + 1) {
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }

  cout << dp[N][K];
}

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

using namespace std;

typedef long long ll;
ll n, m, A[100050], ss[100050], linear[100050];
void print(){
	int cur = 0, cur2 = 0;
	for(int i = 1; i<=m; i++){
		cur += linear[i];
		cur2 += ss[i];
		printf("%d ", cur*i+cur2);
	}
	printf("\n");
}
int main(){
//	freopen("mx0.txt","r",stdin);
	cin >> n >> m;
	for(ll i = 0; i<n; i++){
		cin >> A[i];
		if(i == 0) continue;
		int s = A[i-1], t = A[i];
		if(s < t){
			linear[s+1]--;
			linear[t+1]++;
			ss[1] += t-s;
			ss[s+1] -= t-s;
			ss[s+1] += t+1;
			ss[t+1] -= t+1;
			ss[t+1] += t-s;
		}else{
			linear[1]--;
			linear[t+1]++;
			linear[s+1]--;
			ss[1] += t+1;
			ss[t+1] -= t+1;
			ss[t+1] += t+m-s;
			ss[s+1] -= t+m-s;
			ss[s+1] += t+m+1;
		}
	}
	ll ans = 1000000000000;
	for(ll i = 1; i<=m; i++){
		ss[i] += ss[i-1];
		linear[i] += linear[i-1];
		ans = min(ans, linear[i]*i+ss[i]);
	}
	cout << ans;
}


Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main() { 
    int sum; 

    while( cin >> sum ) {

	int count = 0;
	
	for(int i=0;i<10;i++)
	for(int j=0;j<10;j++)
	for(int k=0;k<10;k++)
	for(int l=0;l<10;l++)
	if( i + j + k + l == sum)
    count++;
    
    cout << count << "\n";
	}
    return 0; 
} 


Measured memory_bytes: 3048
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, k, c[20], p[20], ans, s;
int fun(int x)
{
	int cnt = 0, cur = 0;
	while (cur < 32) {
		if (x & 1) cnt++;
		x = x >> 1;
		cur++;
	}
	return cnt;
}


int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			s--;
			c[i] += 1 << s;
		}
	}
	for (int i = 0; i < m; i++) cin >> p[i];
	int ub = 1 << (n);
	for (int i = 0; i < ub; i++) {
		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (fun(i&c[j]) % 2 != p[j]) {
				ok = false;
				break;
			}
		}
		if (ok) ans++;
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256