akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        int aIdx = s.IndexOf('A');
        int zIdx = s.LastIndexOf('Z');

        Console.WriteLine(zIdx - aIdx + 1);
    }
}

static class MathUtil
{
    static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}

static class ConsoleUtil
{
    public static string[] StrArrayReadLine(char sepalator)
    {
        string str = Console.ReadLine();
        return str.Split(sepalator).ToArray();
    }
    public static string[] StrArrayReadLine()
    {
        string str = Console.ReadLine();
        if (str.Contains(','))
        {
            return str.Split(',').ToArray();
        }
        {
            return str.Split(' ').ToArray();
        }
    }
    public static int[] IntArrayReadLine()
    {
        return StrArrayReadLine().Select(s => int.Parse(s)).ToArray();
    }
    public static int[] IntArrayReadLine(char sepalator)
    {
        return StrArrayReadLine(sepalator).Select(s => int.Parse(s)).ToArray();
    }
    public static int IntReadLine() => int.Parse(Console.ReadLine());
}

Measured memory_bytes: 13180
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)



def main():
    input()
    x=[len(list(v))for k,v in groupby(input())]
    if x[0]==1:
        ans=3
    else:
        ans=6
    mod=10**9+7
    for i in range(1,len(x)):
        if x[i-1]==1 and x[i]==1:
            ans*=2%mod
        elif x[i-1]==1 and x[i]==2:
            ans*=2%mod
        elif x[i-1]==2 and x[i]==2:
            ans*=3%mod
    print(ans%mod)
if __name__ == '__main__':
    main()


Measured memory_bytes: 5184
#include <stdio.h>
#define TAPE_LEN (120*60)

int main(int argc, char *argv[]){
     int h, m, s, len;
     
     while(scanf("%d %d %d",&h,&m,&s), h!=-1){
	  len = TAPE_LEN -s -m*60 -h*3600;

	  printf("%02d:%02d:%02d\n",len/3600,(len/60)%60,len%60);

	  len*=3;
	  printf("%02d:%02d:%02d\n",len/3600,(len/60)%60,len%60);
     }

     return 0;
}

Measured memory_bytes: 0
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var num1 = Convert.ToInt32(input[0]);
        var num2 = Convert.ToInt32(input[1]);

        if ((double)(num1+num2)/2 == (num1+num2)/2) Console.WriteLine((num1+num2)/2);
        else Console.WriteLine((num1+num2)/2 + 1);
    }
}



Measured memory_bytes: 11220
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int H, W;
  cin >> H >> W;

  vector<int> cnt(26, 0);
  rep(i, H) {
    string s;
    cin >> s;
    rep(i, W) { cnt[s[i] - 'a']++; }
  }

  int p1 = 0, p2 = 0, p4 = 0;
  rep(i, 26) {
    p4 += cnt[i] / 4;
    p2 += cnt[i] % 4 / 2;
    p1 += cnt[i] % 2;
  }

  int q1 = (H % 2) * (W % 2);
  int q2 = (H % 2) * W / 2 + (W % 2) * H / 2;
  int q4 = (H / 2) * (W / 2);

  cerr << p1 << " " << p2 << " " << p4 << "\n";
  cerr << q1 << " " << q2 << " " << q4 << "\n";

  if (p4 >= q4 && (p4 - q4) * 2 + p2 >= q2) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int main() {
  LL n,m;
  cin >> n >> m;
  LL ans = 0;
  if(n<m/2){
    ans = n + (m - 2 * n) / 4;
  }else{
    ans = m / 2;
  }
  cout << ans << endl;

  return 0;
}


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

using ll = long long;

ll N;
ll A, B;

void solve(){
    ll d = abs(A - B);
    if(d % 2 == 0) { cout << d / 2; return; }
    ll ans = min(min(A - 1, B - 1), min(N - A, N - B));
    ans += 1 + (d - 1) / 2;
    cout << ans;
}
int main(){
    cin >> N >> A >> B;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
map<int, ll> mp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        int A;
        cin >> A;
        ans += mp[i - A];
        mp[A + i]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26292
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> replicateM 5 (getl toInt) >>= print

solve :: [Int] -> Int
solve [p1,p2,p3,j1,j2] = (p1 `min` p2 `min` p3) + (min j1 j2) - 50

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

int main(void){
    string s;
    cin>>s;
    
    int N=s.size();
    int top=s[0]-'0';
    
    int ans=(top-1)+9*(N-1);
    
    for(int i=1;i<N;i++){
        if(s[i]!='9')break;
        if(i==N-1){
            ans=top+9*i;
        }
    }
    
    if(N==1)ans=top;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
r1, c1, r2, c2 = list(map(int, input().split()))
MOD = 10 ** 9 + 7

r = (r2 + 1)
l = (r1)
ans = 0

for i in range(0, c2):
    gyaku = pow((i + 2), MOD - 2, MOD)
    r *= (r2 + 1 + (i + 1))
    r *= gyaku
    l *= (r1 + (i + 1))
    l *= gyaku
    r %= MOD
    l %= MOD
    if i >= c1 - 1:
        ans += r
        ans -= l
    ans %= MOD
print(ans % MOD)

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    double ans = 0;
    vector<int> pl(17);
    for(int i = 1; i <= 17; i++){
        pl[i-1] = pow(2, i);
    }
    int p2;
    for(int i = 1; i <= n; i++){
        if(i >= k){
            ans += (1.0/n);
        }else{
            for(int j = 0; j < 17; j++){
                if(pl[j]*i >= k){
                    p2 = pl[j];
                    break;
                }
            }
            ans += (1.0/n)*(1.0/p2);
        }
    }
    printf("%.9lf\n", ans);
    return 0;
}


Measured memory_bytes: 512
H,W = (int(x) for x in input().split())
a = []
que = []
dis =[]
longDis = 0

for i in range(H):
    a += list(input().split())

h = -1
w = 0

for _ in range(H*W):
    com = [[0 for i in range(W)] for j in range(H)]
    k = 0
    dis = [k]
    l = 0

    if h < H-1:
        h += 1
    else:
        h = 0
        w += 1

    if a[h][w] != '.':
        continue

    que += [[h,w]]
    com[h][w] = 1
    i = h
    j = w
    
    while True:
        k = dis[l] + 1

        #上
        if i-1 >= 0 and a[i-1][j] == '.':
            if com[i-1][j] == 0:
                que += [[i-1,j]]
                dis += [k]
                com[i-1][j] = 1

        #下
        if i+1 < H and a[i+1][j] == '.':
            if com[i+1][j] == 0:
                que += [[i+1,j]]
                dis += [k]
                com[i+1][j] = 1

        #左
        if j-1 >= 0 and a[i][j-1] == '.':
            if com[i][j-1] == 0:
                que += [[i,j-1]]
                dis += [k]
                com[i][j-1] = 1 

        #右
        if j+1 < W and a[i][j+1] == '.':
            if com[i][j+1] == 0:
                que += [[i,j+1]]
                dis += [k]
                com[i][j+1] = 1

        l += 1

        if l == len(que):
            break
        
        i = que[l][0]
        j = que[l][1]

    for i in range(len(dis)):
        if dis[i] > longDis:
            longDis = dis[i]

    dis.clear()
    que.clear()

print(longDis)


Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(void){
    int N, i, sum=0, x;
    cin >> N;
    for(i=0; i<N; i++){
        cin >> x;
        if(x % 2 == 0){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;




int main(void){
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }

  int a = c[1][0] - c[0][0];
  int b = c[1][1] - c[0][1];
  int e = c[1][2] - c[0][2];

  int f = c[2][0] - c[0][0];
  int g = c[2][1] - c[0][1];
  int h = c[2][2] - c[0][2];

  if(a==b&&b==e&&f==g&&g==h) cout << "Yes " << endl;
  else cout << "No" << endl;


  return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n , t , flag = 0;
	cin >> n >> t;
	int ans = INT_MAX;
	for(int i = 0 ; i < n ; ++i){
		int ci , ti;
		cin >> ci >> ti;
		if(ti <= t){
			flag = 1;
			ans = min(ans,ci);
		}
	}
	if(flag == 0)cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> edge[N+1];
    int u, v;
    long long w;
    long long dist[N+1];
    bool check[N+1];
    fill_n(check, N+1, true);
    rep(i, N-1){
        cin >> u >> v >> w;
        edge[u].push_back((w%2)*(N+1) + v);
        edge[v].push_back((w%2)*(N+1) + u);
    }
    dist[1] = 0;
    check[1] = false;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int p = que.front();
        int n = edge[p].size();
        que.pop();
        rep(i, n){
            int q = edge[p][i] % (N+1);
            int r = edge[p][i] / (N+1);
            if(check[q]){
                dist[q] = dist[p] + r;
                que.push(q);
                check[q] = false;
            }
        }
    }
    rep2(i, 1, N+1){
        cout << dist[i] % 2 << endl;
    }
}

Measured memory_bytes: 6784
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,k=map(int,input().split())
A=list(map(int,input().split()))
l=40

def bit_cnt(X,d):
    c=0
    d=l-d
    for x in X:
        if x&(1<<d):
            c+=1
    return c

DP=[[0]*2 for _ in range(l+1)]
for i in range(1,l+1):
    if DP[i-1][1]:
        DP[i][1]=1
    cnt=bit_cnt(A,i)
    if cnt>=n-cnt:
        DP[i][0]=DP[i-1][0]+cnt*(1<<(l-i))
        if (k>>(l-i))&1:
            DP[i][1]=1
    else:
        if DP[i][1]:
            DP[i][0]=DP[i-1][0]+(n-cnt)*(1<<(l-i))
        else:
            if (k>>(l-i))&1:
                DP[i][0]=DP[i-1][0]+(n-cnt)*(1<<(l-i))
            else:
                DP[i][0]=DP[i-1][0]+cnt*(1<<(l-i))
print(DP[-1][0])

Measured memory_bytes: 63192
// -*- coding:utf-8-unix -*-
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::LinkedList;
use std::collections::VecDeque;
use std::fs::File;
use std::io;
use std::io::prelude::*;

const INF: i64 = 1223372036854775807;

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

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, 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")
    };
}

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn solve() {
    let n: i64 = read();
    let mut vec: Vec<i64> = read_vec();
    let mut proc: Vec<i64> = vec![];
    for i in 0..n as usize {
        for j in (0..vec.len()).rev() {
            if (vec[j] == (j + 1) as i64) {
                proc.push(vec[j]);
                vec.remove(j);
                break;
            }
        }

        if (proc.len() != i + 1) {
            println!("-1");
            return;
        }
    }
    proc.reverse();
    for p in proc.into_iter() {
        println!("{}", p);
    }
}
fn main() {
    solve()
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define INF 1000000000000000009
using namespace std;

long long n,a[200010],s[200010],ans=(long long)INF;
long long f[5];

pair<long long,long long> getans(long long l,long long r,long long val)
{
	long long pos=lower_bound(s+l,s+r+1,val/2)-s,ans=-1;
	if(pos<r){
		ans=max(ans,val-s[pos]);
	}
	if(pos>l){
		ans=max(ans,s[pos-1]);
	}
	return make_pair(ans,val-ans);
}

int main()
{
	cin>>n;
	for(long long i=1;i<=n;i++) scanf("%I64d",&a[i]),s[i]=s[i-1]+a[i];
	for(long long i=2;i<=n-2;i++){
		pair<long long,long long> x=getans(1,i,s[i]);
		pair<long long,long long> y=getans(i+1,n,s[i]+s[n]);
		f[1]=x.first,f[2]=x.second,f[3]=y.first-s[i],f[4]=y.second-s[i];
		sort(f+1,f+4+1);
		ans=min(ans,f[4]-f[1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().strip().split()))
    A.append(K+A[0])
    B=[0]*(N+1)
    for i in range(N):
        B[i]=A[i+1]-A[i]
    
    # print(A)
    # print(B)
    
    print(K-max(B))
    
main()

Measured memory_bytes: 26420
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

//ll so[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, };

int main(){
    ll n;
    cin>>n;
    if(n == 1){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 0;
    ll m = n;
    for(ll i=2;i<=(ll)sqrt(n);++i){
        ll k = i;
        for(ll j=1;j<100;++j){
            if(m % (ll)pow(k, j) == 0){
                ans++;
                m /= (ll)pow(k, j);
            }else{
                while(m % k == 0){
                    m /= k;
                }
                break;
            }
        }
        //cout<<m<<endl;
        if(m == 1){
            break;
        }
    }
    //cout<<m<<endl;
    if(m != 1){
        ans += 1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

const ll MAX_E = 2001;
const ll MAX_V = 1000;

struct edge
{
    ll from;
    ll to;
    ll cost;
}; // 頂点fromから頂点toへのコストcostの辺

edge es[MAX_E]; // 辺
ll d[MAX_V];    // 最短距離
ll V, E;        // Vは頂点数,Eは辺の数

// s番目の頂点から各頂点への最短距離を求める
bool bellman_ford(ll s)
{
    for (ll i = 0; i < V; i++)
    {
        d[i] = LLINF;
    }
    d[s] = 0;
    for (ll i = 0; i < V; i++)
    {
        for (ll j = 0; j < E; j++)
        {
            edge e = es[j];
            if (d[e.from] != LLINF && d[e.to] > d[e.from] + e.cost)
            {
                d[e.to] = d[e.from] + e.cost;
                if (i == V - 1 && e.to == V - 1)
                {
                    return false;
                }
            }
        }
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E;
    for (ll i = 0; i < E; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c *= -1LL;
        es[i] = edge{a, b, c};
    }
    bool flg = bellman_ford(0);
    if (!flg)
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << -d[V - 1] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;

int main() {
   Int v, e;
   std::cin >> v >> e;
   std::vector<Int> ss(e), ts(e), ws(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ws[i];
   std::vector<std::pair<Int, Int>> xs;
   rep(i, e) xs.emplace_back(ws[i], i);
   std::sort(xs.begin(), xs.end());
   std::vector<Int> ps(v, -1), ns(v,1);
   auto find = [&](Int x) {
      while( ps[x] != -1 ) {
         x = ps[x];
      }
      return x;
   };
   auto unite = [&](Int x, Int y) {
      x = find(x), y = find(y);
      if( x != y ) {
         if( not ( ns[x] <= ns[y] ) ) std::swap(x, y);
         ps[x] = y;
         ns[y] += ns[x];
      }
   };
   Int res = 0;
   rep(i, e) {
      Int k = xs[i].second;
      Int s = ss[k], t = ts[k];
      guard( find(s) != find(t) );
      unite(s, t);
      res += ws[k];
   }
   printf("%ld\n", res);
}

Measured memory_bytes: 7208
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
  int x, y, z;
  cin >> x >> y >> z;
  if((y * 10 + z) % 4 == 0){
    cout << "YES";
  } else {
    cout << "NO";
  }
}
        

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}

import scala.collection.mutable

object Main {
  val MODULO = 998244353L
  val powMemo = new mutable.HashMap[(Long, Long), Long]

  def pow(a: Int, b: Long): Long = {
    if (a == 0) {
      0
    } else if (a == 1) {
      1
    } else {
      powMemo.getOrElseUpdate((a, b), {
        if (b == 0) {
          1
        } else if (b % 2 == 0) {
          pow(a, b / 2) * pow(a, b / 2) % MODULO
        } else {
          pow(a, b - 1) * a % MODULO
        }
      })
    }
  }

  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val ds = in.readLine().split("\\s+").map(_.toInt)

    if (ds(0) != 0) {
      System.out.println("0")
      return
    }

    var dsList = ds.sorted.toList
    var result = 0L

    if (dsList.head == 0 && (dsList.tail == Nil || dsList.tail.head == 1)) {
      result = 1L
      var lastElementCount = 1

      dsList = dsList.tail
      for (i <- 1 until n if dsList.nonEmpty) {
        dsList.span(_ == i) match {
          case (as, bs) =>
            result = result * pow(lastElementCount, as.length) % MODULO
            lastElementCount = as.length
            dsList = bs
        }
      }
    } else {
      result = 0L
    }

    System.out.println(
      result
    )
  }
}


Measured memory_bytes: 49496
import sys
from collections import deque

def solve():
    readline = sys.stdin.readline

    H, W = map(int, readline().split())
    a, b = map(int, readline().split())
    c, d = map(int, readline().split())
    S = [readline().rstrip() for i in range(H)]

    a,b,c,d = (v - 1 for v in (a,b,c,d))

    INF = 10 ** 10

    groups = []

    visited = [[False] * W for i in range(H)]

    dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    def dfs(x, y, group):
        if not (0 <= x < H and 0 <= y < W):
            return
        
        if visited[x][y]:
            return
        
        if S[x][y] == '#':
            return
        
        group.append((x,y))
        visited[x][y] = True

        for dx, dy in dirs:
            dfs(x + dx, y + dy, group)

    for i in range(H):
        for j in range(W):
            if S[i][j] == '.' and not visited[i][j]:
                group = []
                dfs(i, j, group)
                groups.append(group)
    
    
    p2g = [[-1] * W for i in range(H)]
    for i,group in enumerate(groups):
        for x,y in group:
            p2g[x][y] = i
    
    G = len(groups)
    g_adj = [set() for i in range(G)]
    for i in range(H):
        for j in range(W):
            src = p2g[i][j]
            if src == -1:
                continue
            for x in range(max(0, i - 2), min(H - 1, i + 2) + 1):
                for y in range(max(0, j - 2), min(W - 1, j + 2) + 1):
                    if x == i and y == j:
                        continue
                    if p2g[x][y] == -1:
                        continue
                    g_adj[src].add(p2g[x][y])
    
    
    src_g = p2g[a][b]
    dst_g = p2g[c][d]

    visited = [False] * G
    q = deque()
    q.append((src_g, 0))

    while q:
        node, depth = q.popleft()

        if node == dst_g:
            print(depth)
            return

        for adj in g_adj[node]:
            if not visited[adj]:
                visited[adj] = True
                q.append((adj, depth + 1))
    
    print(-1)

solve()

Measured memory_bytes: 168488
import java.util.Scanner;

public class Main{
    
    public static void main (String[] args){
        
        Scanner sc = new Scanner (System.in);
        
        int N = sc.nextInt();
        int[] listB = new int [N-1];
        int [] listA = new int [N];
        
        for (int index=0; index<N-1; index++){
            listB[index]=sc.nextInt();
        }
        
        int lastNum = 0;
        
        for (int index=0; index<N-1; index++){
            int num = listB[index];
            listA[index]=num;
            if (index!=0){
                if (listA[index]>lastNum){
                    listA[index]=lastNum;
                }
            }
            lastNum = num;
        }
        
        listA[N-1]=listB[N-2];
        
        int total = 0;
        
        for (int index=0; index<N; index++){
            total+=listA[index];
        }
        
        System.out.println(total);
    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int A[510];
int sum[10000];
vector<int> V;
vector<int> a[10000];
int main()
{
	int N, K;
	cin >> N >> K;
	int S = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		S += A[i];
	}
	for (int i = 1; i * i <= S; i++) {
		if (S % i == 0) {
			if (i * i != S) V.push_back(S / i);
			V.push_back(i);
		}
	}
	sort(V.rbegin(), V.rend());
	for (int i = 0; i < V.size();i++) {
		for (int j = 0; j < N; j++) {
			a[i].push_back(A[j] % V[i]);
			sum[i] += (A[j] % V[i]);
		}
		sort(a[i].rbegin(), a[i].rend());
	}
	for (int i = 0; i < V.size(); i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			sum[i] -= a[i][j];
			cnt += V[i] - a[i][j];
			if (cnt == sum[i] && cnt <= K) {
				cout << V[i] << endl;
				return 0;
			}
		}
	}
	cout << 1 << endl;
}

Measured memory_bytes: 2816
n,x,y = map(int,input().split())
x,y = x-1,y-1
ans = [0]*(n)

for i in range(n):    
  for j in range(i+1,n):
    sp = min(abs(j-i), abs(x-i)+abs(j-y)+1)
    ans[sp]+=1
    
for a in ans[1:]:
  print(a)

Measured memory_bytes: 3572
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 

    int a,b;
    cin>>a>>b;
    int bketa=0;
    int b2=b;
    while(b2>0){
        b2/=10;
        bketa++;
    }
    int s=a*pow(10,bketa)+b;
    cerr<<s<<endl;
    for(int i=1;i<s;i++){
        if(s%i==0&&s/i==i){ cout<<"Yes"<<endl;return 0;}
    }

    cout<<"No"<<endl;

}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    #D - Wide Flip
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    ans=len(s)
    N=len(s)
    for i in range(len(s)-1):
        if s[i]!=s[i+1]:
            x=max(N-i-1,i+1)
            ans=min(ans,x)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 79504
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
int main() {
    double a, b, x;
    double pi = 3.1415926535897932384;
    cin >> a >>b >> x;
    double area = x / a;
    double ans = 0;
    if (abs(area - a*b / 2) < 1e-9) {
        // x/a = a*b/2; b = tan(ang) * a
        // tan(ang) = 2x / a^3
        ans = atan(area*2/(a*a)) * 180 / pi;

    } else if (area > a*b/2){ // full
        // area -= a*b/2;
        ans = atan(2.0*(b-area/a)/a) * 180 / pi;

    } else if (area < a*b/2) { // empty
        // x/a = b^2/2tan()
        ans = atan(b*b/(2*area)) * 180 / pi;
    }
    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr;
  rep(i, n) {
    int a;
    cin >> a;
    arr.push_back(a);
  }

  for (int i = k; i < n; i++) {
    if (arr[i] > arr[i - k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4288
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <set>

using namespace std;

int main() {
  string s;
  int k;
  set<string> sub;
  cin >> s >> k;
  int n = s.size();

  for (int i=0; i<n; i++) {
    for (int j=1; j<=k; j++) {
      sub.insert( s.substr(i, j) );
    }
  }

  auto it = sub.begin();
  for (int i=1; i<k; i++) it++;

  cout << *it << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int n=t.size();
  int m=s.size();
  int ans=10000;
  for(int i=0;i<m-n+1;i++){
    int cnt=0;
    for(int j=0;j<n;j++){
      if(s.at(i+j)==t.at(j)) cnt++;
    }
    ans=min(ans,n-cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
N = int(input())
W = [int(w) for w in input().split(' ')]

sum_of_W = sum(W)
answer = sum_of_W
for i in range(N):
    left = sum(W[:i:])
    right = sum(W[i::])
    answer = min(answer, abs(left-right))

print(answer)

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  string S;
  cin >> S;
  map<char, int> mp;
  for (int i = 0; i < S.size(); i++)
  {
    mp[S[i]]++;
  }
  if (mp.size() == 2 and mp[S[0]] == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;


ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

ll a[maxn];
int main()
{
  ios::sync_with_stdio(0);
  int n,k;
  cin >> n >> k;
  int j = 0;
  ll sum = 0;
  ll ans = 0;
  for(int i = 0 ; i < n ; i++)
  {
    cin >> a[i];
    sum += (a[i] + 1);
    if(i - j + 1 <= k)
      continue;
    sum -= (a[j] + 1);
    j++; 
    ans = max(ans, sum);
  }

  ans = max(ans, sum);

  cout << fixed << setprecision(6) <<  (ans/2.0) << endl;

  return 0;
}

Measured memory_bytes: 5372
s = str(input())

if 'SUN' in s :
  print(7)
  
elif 'MON' in s :
  print(6)
  
elif 'TUE' in s :
  print(5)
  
elif 'WED' in s :
  print(4)
  
elif 'THU' in s :
  print(3)
  
elif 'FRI' in s :
  print(2)
  
else :
  print(1)

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

using namespace std;

int N;
string s;
int t[100005];

void next(int i)
{
	if(!t[i]){
		if(s[i] == 'o') t[i+1] = t[i-1];
		else t[i+1] = !t[i-1];
	}
	else{
		if(s[i] == 'o') t[i+1] = !t[i-1];
		else t[i+1] = t[i-1];
	}
}

int main(void)
{
	cin >> N;
	cin >> s;
	
	for(t[0] = 0; t[0] <= 1; t[0]++){
		for(t[1] = 0; t[1] <= 1; t[1]++){
			next(1);
			for(int i = 2; i < N; i++){
				next(i);
			}
			if(t[0] != t[N]) continue;
			if(s[0] == 'o' && t[0] == 0 || s[0] == 'x' && t[0] == 1) if(t[1] != t[N-1]) continue;
			if(s[0] == 'o' && t[0] == 1 || s[0] == 'x' && t[0] == 0) if(t[1] == t[N-1]) continue;
			for(int i = 0; i < N; i++){
				if(t[i]) cout << "W";
				else cout << "S";
			}
			cout << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
	return 0;
}

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

const int dh[4] = {0,1,0,-1};
const int dw[4] = {1,0,-1,0};

int main(void){
    int H,W;
    cin >> H >> W;
    string field[H];
    for(int i=0;i<H;i++) cin >> field[i];

    int maxdistance = 0;
    for(int a=0;a<H;a++){
        for(int b=0;b<W;b++){
            if(field[a][b]=='#') continue;
            //cout << "start position: " << a << "," << b << endl;
            pair<int,int> sp(a,b);
            vector<vector<int>> dist(H,vector<int>(W,-1));
            queue<pair<int,int>> q;
            q.push(sp);
            dist[a][b] = 0;

            while(!q.empty()){
                pair<int,int> p = q.front(); q.pop();
                int h = p.first, w = p.second;
                
                for(int k=0;k<4;k++){
                    int nh = h + dh[k];
                    int nw = w + dw[k];

                    if(nh<0||nh>=H||nw<0||nw>=W) continue;
                    if(field[nh][nw]=='#') continue;
                    if(dist[nh][nw]!=-1) continue;

                    dist[nh][nw] = dist[h][w]+1;
                    maxdistance = max(maxdistance,dist[nh][nw]);
                    q.push(make_pair(nh,nw));
                }

            }
            /*
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(dist[i][j]!=-1) cout << dist[i][j];
                    else cout << '#';
                }
                cout << endl;
            }
            */
            
        }
    }
    cout << maxdistance << endl;
}

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

a_end = 0
b_start = 0
ab = 0
zz = 0
for n in range(N):
    s = input()
    ab = ab + s.count('AB')
    if s[-1] == 'A':
        a_end = a_end + 1
    if s[0] == 'B':
        b_start = b_start + 1
    if s[-1] != 'A' and s[0] != 'B':
        zz = zz + 1

print(ab + max(min(a_end, b_start, N - 1 - zz), 0))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int n=0;
    int x[5];
    for(int i=0;i<5;i++){
        cin>>x[i];
        if(x[i]==0){
            n=i+1;
        }
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 3620
// atcoder/abc132/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// Created by sz
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
	freopen("./input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	
	map<int, array<int, 2>> pos;

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			int x;
			cin >> x;
			pos[x] = { i,j };
		}
	}

	vector<vector<int> > a(3, vector<int>(3, 0));
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int b;
		cin >> b;
		if (pos.count(b)) {
			a[pos[b][0]][pos[b][1]] = 1;
		}
	}

	int have2 = 1, have3 = 1;
	for (int i = 0; i < 3; i++)
	{
		int have0 = 1, have1 = 1;
		for (int j = 0; j < 3; j++)
		{
			if (!a[i][j])have0 = 0;
			if (!a[j][i])have1 = 0;
		}

		if (have0 ||have1 ) {
			cout << "Yes\n";
			return 0;
		}

		if (!a[i][i]) have2 = 0;
		if (!a[i][2 - i])have3 = 0;
	}

	if (have2 || have3)
	{
		cout << "Yes\n";
		return 0;
	}
	
	cout << "No\n";
	

	
	return 0;
}


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

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define printlist(l) for(auto x: l) cout << x << ' '; cout << endl;

#define mod 1000000007
#define maxn 100005

ll n, x, y, m, q, t, k, a[maxn];

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

	string s;
	cin >> s;
	int l = s.length();
	int i = 0, j = l - 1;
	ll ans = 0;
	while(i < j){
		if(s[i]!=s[j])
			ans++;
		i++;
		j--;
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, M;
    cin >> N >> M;
    int a, sum = 0;
    Fp(i, 0, M){
        cin >> a;
        sum += a;
    }
    if(sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int w = scan.nextInt();
		int h = scan.nextInt();
		int n = scan.nextInt();
		int[] xn = new int[n];
		int[] yn = new int[n];
		int[] an = new int[n];

		for (int i = 0; i < n; i++) {
			xn[i] = scan.nextInt();
			yn[i] = scan.nextInt();
			an[i] = scan.nextInt();
		}

		int wl = 0;
		int wr = w;
		int hl = 0;
		int ht = h;
		for (int i = 0; i < n; i++) {
			switch (an[i]) {
			case 1:
				if (wl < xn[i]) {
					wl = xn[i];
				}
				break;
			case 2:
				if (wr > xn[i]) {
					wr = xn[i];
				}
				break;
			case 3:
				if (hl < yn[i]) {
					hl = yn[i];
				}
				break;
			case 4:
				if (ht > yn[i]) {
					ht = yn[i];
				}
				break;
			}
		}
		if (wr - wl < 0 || ht - hl < 0) {
			System.out.println(0);
		} else {
			System.out.println((wr - wl) * (ht - hl));
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void){
  int a,b,c;
  int ans = 0;
  scanf("%d %d %d", &a, &b, &c);
  
  for(int i=1;i<=c;i++){
    if(i*a<=b){
      ans = i;
    }
  }
    
  printf("%d",ans);
}

Measured memory_bytes: 128
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
from collections import *
from bisect import *
mod = 10**9+7

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
ans = sum(b)
for i, j in zip(a, a[1:]):
    if i+1 == j:
        ans += c[i-1]
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define N 2005
using namespace std;
int n,m,q;
char s[N];
int mp[N][N];
int sum[N][N],sm[N][N],smm[N][N];
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
        {
            mp[i][j]=s[j]-'0';
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+mp[i][j];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            if(mp[i][j]&&mp[i-1][j])cnt++;
            sm[i][j]=sm[i][j-1]+sm[i-1][j]-sm[i-1][j-1]+cnt;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int cnt=0;
            if(mp[i][j]&&mp[i][j-1])cnt++;
            smm[i][j]=smm[i][j-1]+smm[i-1][j]-smm[i-1][j-1]+cnt;
        }
    }
    int t1,t2,t3,t4;
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
        printf("%d\n",sum[t3][t4]-sum[t1-1][t4]-sum[t3][t2-1]+sum[t1-1][t2-1]-
               (sm[t3][t4]-sm[t3][t2-1]-sm[t1][t4]+sm[t1][t2-1])
               -(smm[t3][t4]-smm[t3][t2]-smm[t1-1][t4]+smm[t1-1][t2]));
    }
    return 0;
}


Measured memory_bytes: 64640
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
typedef long long ll;
using namespace std;
const int maxn=101000;
int n,k;
int num[maxn];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&num[i]);
    int pos=lower_bound(num+1,num+n+1,0)-num;
    if(n==1){
        printf("%d\n",abs(num[1]));
    }else if(num[n]<=0){
        printf("%d\n",abs(num[n-k+1])); //n n-k+1
    }else if(num[1]>=0){
        printf("%d\n",num[k]);
    }else{
        int ans=5e8+1000;
        int f=min(k,n-pos+1);
        for(int i=0;i<=f;i++){
            int j=k-i,ff=pos-1;
            if(ff<j) continue;//pos<j+1;pos>=j+1
            ans=min(ans,abs(i==0?0:num[pos+i-1])+2*abs(j==0?0:num[pos-j]));
            ans=min(ans,2*abs(i==0?0:num[pos+i-1])+abs(j==0?0:num[pos-j]));
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 640
import collections

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
c = collections.Counter(s)
d = collections.Counter(t)
counter = c -d
try:
        print(counter.most_common(1)[0][1])
except IndexError:
        print("0")

Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        int n = sc.nextInt();

        ArrayList<Integer> arrayList = new ArrayList<Integer>();

        for(int i=0; i<n; i++){
            int p = sc.nextInt();
            arrayList.add(p);
        }

        Collections.sort(arrayList);


        int size = arrayList.size();
        int leftHalf = size / 2 - 1;
        int rightHalf = leftHalf + 1;

        if(arrayList.get(leftHalf) == arrayList.get(rightHalf)){
            System.out.println(0);
        }else{
            System.out.println(arrayList.get(rightHalf) - arrayList.get(leftHalf));
        }

    }
}


Measured memory_bytes: 60964
#include <stdio.h>
#include <string.h>

int main(){
  char S[100001];
  int N;
  int n[100000];
  int sum;
  
  scanf("%s", S);
  N = strlen(S);

  char flag='R';
  int len =0;
  
  for(int i=0;i<N;i++)
    if( S[i] == flag){
      len++;
      n[i] = 0;
    }else{
      n[i-1] = len;
      len = 1;
      flag = S[i]; 
    }
  
  for(int i=N-1;i>=0;i--)
    if( S[i]==flag )
      n[i] = 0;
    else{
      if( S[i]=='R'){
	int r = n[i], l =len;
	n[i] = r/2 + l/2;
	n[i+1] = r/2 + l/2;
	if( r % 2 == 1)
	  n[i] +=1;
	if( l % 2 == 1)
	  n[i+1] += 1;
      }else{
	len = n[i];
	n[i] = 0;
      }
      flag = S[i];
    }
      
  for(int i=0;i<N-1;i++)
    printf("%d ",n[i]);
  printf("%d\n",n[N-1]);
  
  return 0;
}


Measured memory_bytes: 896
#include <cstdio>

char s[6];

int main()
{
    scanf("%s %s", &s[0], &s[3]);
    if (s[0] == s[5] && s[1] == s[4] && s[2] == s[3]) printf("YES\n");
    else printf("NO\n");

    return 0;
}

Measured memory_bytes: 128