akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define F first 
#define S second 
#define PB push_back
#define MP make_pair 
#define rep(i,a,b) for (ll i=a;i<b;i++)

typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{

    string s;

    cin >>s;

    int j = s.length()-1; 
    int cnt=0; 
    rep(i,0,s.length()/2)
    {
        if(s[i]!=s[j])
        {
            cnt++; 
        }
        j--; 
    }
    cout<<cnt<<endl;


    return 0; 
}



Measured memory_bytes: 256
def main():
    N = int(input())
    p = list(map(int, input().split()))

    diff = 0
    for i in range(N):
        if (i+1) != p[i]:
            diff += 1
    if (diff == 2) | (diff == 0):
        return "YES"
    return "NO"
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, p;
  
  cin >> a >> p;

  cout << ((a * 3) + p) / 2 << endl;
  return 0;
}



Measured memory_bytes: 256
use std::io::stdin;
use std::cmp::min;

fn read_line() -> Vec<String> {
    let mut line = String::new();
    stdin().read_line(&mut line).expect("Failed to read line");
    return line.trim().split_whitespace().map(|s| s.to_string()).collect();
}

struct Reader {
    v: Vec<String>,
    n: usize,
}

impl Reader {
    fn new() -> Reader {
        let v = read_line();
        return Reader { v: v, n: 0 };
    }
    fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
        if self.n == self.v.len() {
            self.v = read_line();
            self.n = 0;
        }
        let x = self.v[self.n].parse().expect(&self.v[self.n]);
        self.n += 1;
        return x;
    }
    fn nexts<T>(&mut self, n: usize) -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            v.push(self.next());
        }
        return v;
    }
}

fn main() {
    let mut r = Reader::new();
    let n: usize = r.next();
    let a: usize = r.next();
    let b: usize = r.next();

    if a + b > n + 1 || (a as u64) * (b  as u64) < (n as u64) {
        println!("-1");
        return;
    }

    let mut ans: Vec<usize> = Vec::new();
    let mut rem = n;
    let mut cum = 0;

    for i in 0..a {
        let m = min(b, rem - (a - i - 1));
        rem -= m;
        for j in (cum..(cum+m)).rev() {
            ans.push(j+1);
        }
        cum += m;
    }
    println!("{}", ans.iter().fold(String::new(), |mut x, y| {
        x.push_str(" ");
        x.push_str(&y.to_string());
        x
    }).trim());
}


Measured memory_bytes: 13204
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[200005],pos[200005],vis[200005];
int main()
{
	int n,ans=0,x=1;ll k;scanf("%d%lld",&n,&k); 
	for(int i=1;i<=n;++i) 
	scanf("%d",&a[i]); 
	do 
	{
	vis[x]=1;
	if(ans==k)
	{
		printf("%d",x);return 0;
	}
	pos[ans++]=x;
	x=a[x];
	}while(!vis[x]);
	k-=ans;ans=0;
	do
	{
		vis[x]=2;
		pos[ans++]=x;
		x=a[x];
	}while(!(vis[x]&2));
	printf("%d",pos[k%ans]);
}

Measured memory_bytes: 5976
#include<bits/stdc++.h>
#define ll long long
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
inline int read()
{
	static char buf[1<<21],*p1,*p2;
	int f=0,c=1; char ch=gc();
	while(ch<'0'||ch>'9') { if(ch=='-') c=-1; ch=gc(); }
	while(ch>='0'&&ch<='9') { f=f*10+ch-'0'; ch=gc(); }
	return c*f;
}
const int M=5010,mod=1e9+7;
constexpr int he (int x,int y) { return x+y>=mod?x+y-mod:x+y; }
constexpr int cha(int x,int y) { return x>=y?x-y:x+mod-y; }
constexpr int mul(int x,int y) { return 1ll*x*y%mod; }
inline void add(int &x,int y) { x=he(x,y); }
vector<int> v[M];
int dp[M][M],f[M],siz[M],g[M];
int n,m,x,y;
void dfs(int x,int fa)//
{
	siz[x]=1; dp[x][1]=1;
	for(int k=0;k<v[x].size();++k)
	{
		int y=v[x][k];// 下面用i,j了，这里用k吧 
		if(y==fa) continue;
		dfs(y,x);//我竟然会忘这一句…… 
		memset(f,0,sizeof(int)*(siz[x]+siz[y]+1));//注意这里要加y 
		for(int i=1;i<=siz[x];++i) //1
			for(int j=0;j<=siz[y];++j)//0
				add(f[i+j],mul(dp[x][i],dp[y][j]));
		memcpy(dp[x],f,sizeof(int)*(siz[x]+siz[y]+1));
		siz[x]+=siz[y];
	}
	for(int i=1;i<=siz[x];++i) add(dp[x][0],mul(dp[x][i],g[i]));
	dp[x][0]=cha(0,dp[x][0]);//容斥系数 
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	n=read();
	for(int i=1;i<n;++i)
	{
		x=read(); y=read();
		v[x].push_back(y);
		v[y].push_back(x);
	}
	g[0]=1;
	for(int i=2;i<=n;i+=2) g[i]=mul(g[i-2],i-1);
	dfs(1,0);
	cout<<cha(0,dp[1][0]);
	return 0;
}

Measured memory_bytes: 98432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double s = 0;
        double are = 0;
        double circ = 0;
        
        s = 3.141592653589;
        are = r * r * s;
        circ = 2 * r * s;
        
    System.out.printf("%.6f %.6f\n", are, circ);    
    }
}



Measured memory_bytes: 28348
#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++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
    {
        swap(a, b);
    }
    rep(i, b)
    {
        cout << a;
    }

    return 0;
}

Measured memory_bytes: 256
dp=[10000 for i in range(200000)]
n=int(input())
dp[n]=0
for i in range(1,n+1):
    dp[n-i]=min(dp[n-i+59049],dp[n-i+46656],dp[n-i+7776],dp[n-i+6561],
    dp[n-i+1296],dp[n-i+729],dp[n-i+216],dp[n-i+81],
    dp[n-i+36],dp[n-i+9],dp[n-i+6],dp[n-i+1])+1
print(dp[0])

Measured memory_bytes: 4632
#include<bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 100000000;

int main(){
    int n, k;
    cin >> n >> k;
    ll x[n];
    REP(i, n){
        cin >> x[i];
    }
    ll tmp, y, ans = INT_MAX;
    REP(i, n-k+1){
        tmp = x[i+k-1] - x[i];
        y = min(abs(x[i+k-1]), abs(x[i]));
        ans = min(ans, tmp+y);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, k;
	cin >> n >> k;
	VecP p(n);
	rep(i, n) cin >> p[i].fs >> p[i].sc;
	sort(all(p));

	ll ans = 5*LINF;
	rep(l, n-1){
		REP(r, l+k-1, n){
			Vec y;
			REPN(i, l, r) y.pb(p[i].sc);
			sort(all(y));
			rep(i, y.size()-k+1){
				chmin(ans, (p[r].fs-p[l].fs)*(y[i+k-1]-y[i]));
			}
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	long long N,A,B;

	scanf("%lld %lld %lld",&N,&A,&B);

	if(A>B){
		printf("0\n");
		return 0;
	}
	if(A!=B&&N==1){
		printf("0\n");
		return 0;
	}

	long long max = A + B*(N-1);
	long long min = A*(N-1) + B;
	printf("%lld\n",max-min+1);

	return 0;
}


Measured memory_bytes: 128
[N, Y] = list(map(int, input().split()))
flag = False
for i in range(0, N+1):
  if 10000*i > Y:
    break
  for j in range(0, N+1-i):
    k = N-i-j
    total = 10000*i + 5000*j + 1000*k
    if total == Y:
      print("{} {} {}".format(i, j, k))
      flag = True
      break
  if flag:
    break

if flag == False:
  print("-1 -1 -1")

Measured memory_bytes: 3064
def f(n):
    low, high = -1100, 1100
    while high - low > 1:
        mid = (high + low) // 2
        if mid**5 <= n:
            low = mid
        else:
            high = mid
    return low

x = int(input())
for a in range(1000):
    b = f(a**5 - x)
    if a**5 - b**5 == x:
        print(a, b)
        quit()

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  map<ll,ll> m;
  vector<int> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
    m[A[i]]++;
  }
  ll ans(0);
  for(auto mi:m){
    ans += mi.first * mi.second;
  }
  int Q;
  cin>>Q;
  for(int i(0);i<Q;i++){
    int b,c;
    cin>>b>>c;
    int tmp = m[b];
    m[b] = 0;
    m[c] += tmp;
    ans -= (b-c)*tmp;
    cout << ans << endl;
  }
  return 0;
}




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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(A-2*B, 0) << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
        int h, w;
        int i, j;

        while(1){
                scanf("%d %d", &h, &w);

                if( h==0 && w==0 )
                        break;

                for( i=0 ; i<h ; i++ ){
                        for( j=0 ; j<w ; j++ )
                                putchar('#');
                        putchar('\n');
                }

                putchar('\n');
        }


        return 0;
}


Measured memory_bytes: 2040
C = input()
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'
         ,'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

for i in range(26):
    if  C == alpha[i]:
        print(alpha[i+1])

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3616
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000003;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;cin>>s;s.pub('D');
	llint i,ans=0,A=0;
	for(i=0;i<s.size();i++){
		if(s[i]=='A'){A++;}
		else if(s[i]=='B'){
			if(s[i+1]=='C'){ans+=A;i++;}
			else{A=0;}
		}
		else if(s[i]=='C'){A=0;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 720
h, w, k = [ int(v) for v in input().split() ]
field = [ list(input()) for i in range(h) ]
ans_list = [ [0 for j in range(w)] for i in range(h) ]

t = 1
for i in range(h):
    for j in range(w):
        if field[i][j] == "#":
            ans_list[i][j] = t
            t += 1

for i in range(h):
    p = 0
    for j in range(w):
        if ans_list[i][j] != 0:
            p = ans_list[i][j]
        else:
            ans_list[i][j] = p
    p = 0
    for j in range(w-1,-1,-1):
        if ans_list[i][j] != 0:
            p = ans_list[i][j]
        else:
            ans_list[i][j] = p

for i in range(w):
    p = 0
    for j in range(h):
        if ans_list[j][i] != 0:
            p = ans_list[j][i]
        else:
            ans_list[j][i] = p
    p = 0
    for j in range(h-1,-1,-1):
        if ans_list[j][i] != 0:
            p = ans_list[j][i]
        else:
            ans_list[j][i] = p

for i in ans_list:
    print(*i)


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

int a[100010],n,m;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=m;i++) a[i]=rd();
	if (m==1)
	{
		if (a[1]==1) { puts("1");puts("1");puts("1");return 0; }
		printf("%d\n",a[1]);
		puts("2");
		printf("%d %d\n",1,a[1]-1);
		return 0;
	}
	if (m==2)
	{
		int mm=1;
		if (a[1]>1) mm++;
		if (a[2]>1) mm++;
		printf("%d %d\n",a[1],a[2]);
		printf("%d\n",mm);
		if (a[1]>1) printf("%d ",a[1]-1);
		printf("%d ",2);
		if (a[2]>1) printf("%d\n",a[2]-1);
		else printf("\n");
		return 0;
	}
	int cnt=0;
	for (int i=1;i<=m;i++) if (a[i]&1) cnt++;
	if (cnt>2) { puts("Impossible");return 0; }
	if (cnt==2)
	{
		int h1=0,h2=0;
		for (int i=1;i<=m;i++) if (a[i]&1) { if (!h1) h1=a[i];else h2=a[i]; }
		printf("%d ",h1);
		for (int i=1;i<=m;i++) if (!(a[i]&1)) printf("%d ",a[i]);
		printf("%d\n",h2);
		int mm=m-1;
		if (h1>1) mm++;if (h2>1) mm++;
		printf("%d\n",mm);
		if (h1>1) printf("%d ",h1-1);
		printf("%d ",2);
		for (int i=1;i<=m;i++) if (!(a[i]&1)) printf("%d ",a[i]);
		if (h2>1) printf("%d\n",h2-1);
		else printf("\n");
		return 0;
	}
	if (cnt==1)
	{
		int hh=0;
		for (int i=1;i<=m;i++) if (a[i]&1) hh=a[i];
		for (int i=1;i<=m;i++) if (!(a[i]&1)) printf("%d ",a[i]);
		printf("%d\n",hh);
		int mm=m;
		if (hh>1) mm++;
		printf("%d\n",mm);
		bool flag=false;
		for (int i=1;i<=m;i++)
		{
			if (a[i]&1) continue;
			if (!flag) printf("%d %d ",1,a[i]);
			else printf("%d ",a[i]);
			flag=true;
		}
		if (hh>1) printf("%d\n",hh-1);
		else printf("\n");
		return 0;
	}
	for (int i=1;i<=m;i++) printf("%d ",a[i]);
	puts("");
	int mm=m-1;
	if (a[1]>1) mm++;if (a[m]>1) mm++;
	printf("%d\n",mm);
	if (a[1]>1) printf("%d ",a[1]-1);
	printf("%d ",2);
	for (int i=2;i<m;i++) printf("%d ",a[i]);
	if (a[m]>1) printf("%d\n",a[m]-1);
	else printf("\n");
	return 0;
}

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

int main()
{
    char str[26];
    int length;
    int flg=0;

    scanf("%s",str);
    length = strlen(str);

    for(int i=0;i<length;++i){
        for(int j=i+1;j<length;++j){
            if(str[i]==str[j]){
                flg=1;
            }
        }
    }
    
    if(flg==1){
        printf("no");
    }else{
        printf("yes");
    }
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0089
public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int ans = 0, before = 0;
		int[][] sum = new int[102][102];
		for (int i = 0; i <= 101; i++) fill(sum[i], 0);
		for (int i = 1; sc.hasNext(); i++) {
			String[] ss = sc.next().split(",");
			for (int j = 1; j <= ss.length; j++) {
				if (before < ss.length) {
					sum[i][j] = max(sum[i - 1][j - 1], sum[i - 1][j]) + new Integer(ss[j - 1]);					
				} else {
					sum[i][j] = max(sum[i - 1][j], sum[i - 1][j + 1]) + new Integer(ss[j - 1]);
				}

				ans = max(ans, sum[i][j]);
			}
			
			before = ss.length;
		}
		
		System.out.println(ans);		
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

constexpr ll mod = 1000000007;
 
int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    
    int cnt0 = 0;
    for (int x : a) {
        if (x == 0) {
            cnt0++;
        }
    }
 
    if (cnt0 > 3) {
        cout << 0 << endl;
        return 0;
    }
 
    ll color = (cnt0 == 1) ? 3 : 6;
 
    ll ans = 1;
    vector<ll> cur(1e5, 0);
    for (int i=0; i<n; i++) {
        if (a.at(i) == 0) {
            cur.at(0)++;
        } else {
            ans *= cur.at(a.at(i)-1) % mod;
            ans %= mod;
            cur.at(a.at(i))++;
            cur.at(a.at(i)-1)--;
        }
    }
    
    cout << ans * color % mod << endl;
 
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	// vector<vector<int>> a(26, vector<int>(0));
	// for(int i = 0; i < (int)s.size(); i++){
	// 	a.at(s.at(i) - 'a').push_back(i);
	// }
	// for(int i = 0; i < 26; i++){
	// 	for(int j = 0; j < (int)a.at(i).size(); j++){
	// 		cout << a.at(i).at(j) << " ";
	// 	}
	// 	cout << endl;
	// }
	// for(int i = 0; i < 26; i++){
	// 	vector<int> indexes = a.at(i);
	// 	if(indexes.size() <= 1){
	// 		continue;
	// 	}
	// 	for(int j = 1; j < (int)indexes.size(); j++){
	// 		if(indexes.at(j) - indexes.at(j - 1) <= 2){
	// 			cout << indexes.at(j - 1) << " " << indexes.at(j) << endl;
	// 			return 0;
	// 		}
	// 	}
	// }
	// cout << -1 << " " << -1 << endl;
	for(int i = 0; i < s.size() - 1; i++){
		if(s.at(i) == s.at(i + 1)){
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for(int i = 0; i < s.size() - 2; i++){
		if(s.at(i) == s.at(i + 2)){
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
  int a,b,c;

  cin >> a >> b >> c;

  if(a != b && a == c) cout << b << endl;
  if(a != b && b == c) cout << a << endl;
  if(b != c && a == b) cout << c << endl;

  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	int a[N];
  	int a_max = 0;
  	int a_min = 1000;
  	for(int i = 0;i < N;i++)cin >> a[i];
  	for(int i = 0;i < N;i++){	
  		a_max = max(a_max,a[i]);
  		a_min = min(a_min,a[i]);
    }
  	cout << a_max -a_min << endl;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)

#define revrep(i,a,b) for(int i = a; i > b; i--)
//#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define Sort(v) sort(all(v))


/* constant */
//const int inf = 100100100100100100;
const int mod = 998244353;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }
vector<int> cs(vector<int> arr){vector<int> tmp;if(arr.size() == 0) return tmp;tmp.push_back(arr[0]);rep(i,1,arr.size()){tmp.push_back(tmp.back() + arr[i]);}return tmp;}

/* math_library */
int gcd(int a, int b){ if(b == 0) return a; return gcd(b, a % b);}
int lcm(int a, int b){ return a * b / gcd(a,b);}
int ceil(int a, int b){ if(a % b == 0) return a/b; else return a/b + 1;}
int digitlen(int n){int t = n;int cnt = 0;while(t){cnt++;t /= 10;}return cnt;}
bool isprime(int n){if(n < 2) return false;if(n % 2 == 0 || n % 3 == 0 || n % 5 == 0) return false;for(int i = 7; i * i < n + 1; i += 2){if(n % i == 0) return false;}return true;}
int mod_pow(int x, int n, int m){if(n== 0) return 1;int res = mod_pow(x*x%m,n/2,m);if(n&1) res = res*x%m;return res;}
int digitsum(int n){int ret = 0;while(n){ret += n % 10;n /= 10;}return ret;}



/* main */


signed main(){

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

    int n, e; cin >> n >> e;

    vector<vector<int> > edges(n);
    vector<int> indig(n,0);

    rep(i,0,e){
        int f,t; cin >>  f >> t;
        edges[f].push_back(t);
        indig[t]++;
    }

    stack<int> noindigstk;
    rep(i,0,n){
        if(indig[i] == 0) noindigstk.push(i); 
    }
    
    vector<int> ans;

    while(not noindigstk.empty()){

        int v = noindigstk.top();
        noindigstk.pop();
        ans.push_back(v);

        rep(i,0,edges[v].size()){

            indig[edges[v][i]]--;
            if(indig[edges[v][i]] == 0) noindigstk.push(edges[v][i]);

        }

    }

    for(int e: ans){
        print(e);
    }







    




    








}   


Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define loop(I, N) for(int I = 1; I <= N; I++)
#define pool(I, N) for(int I = N; I >= 1; I--)
#define rep(I, N) for(int I = 0; I < N; I++)
#define per(I, N) for(int I = N - 1; I >= 0; I--)
#define FOR(I, L, R) for(int I = L; I <= R; I++)
#define FOD(I, R, L) for(int I = R; I >= L; I--)
#define SET(P, VAL) memset(P, VAL, sizeof(P));

char s[15];
int main() {
	scanf("%s", s);
	printf("2018");
	FOR(i, 4, strlen(s) - 1) printf("%c", (char)s[i]);
	printf("\n");
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int x = vs[2];
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

			int sum1 = 0, sum2 = 0;
			for (int i = 0; i < m; i++) {
				if (a[i] < x) {
					sum1++;
				} else {
					sum2++;
				}
			}
			int ans = Math.Min(sum1, sum2);
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 28332
n_num, a_num, b_num = map(int, input().split())

def digit_sum(num):
    str_num = str(num)
    digit_num = 0
    for s in str_num:
        digit_num += int(s)
    return digit_num

cnt = 0
for n in range(1, n_num+1):
    if a_num <= digit_sum(n) <= b_num:

        cnt += n
        
print(cnt)

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

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

    if (S.find("RRR") != string::npos) {
        cout << 3 << endl;
    } else {
        if (S.find("RR") != string::npos) {
            cout << 2 << endl;
        } else {
            if (S.find("R") != string::npos) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
    
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> T(N), A(N);
  for (int i = 0; i < N; ++i) {
    cin >> T[i] >> A[i];
  }
  pair<long, long> ans = make_pair(1, 1);
  for (int i = 0; i < N; ++i) {
    long long n = max(ceil((long double)ans.first / (long long)T[i]), ceil((long double)ans.second / (long long)A[i]));
    ans.first = T[i] * n;
    ans.second = A[i] * n;
  }
  cout << ans.first + ans.second << endl;
  return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s;
  bool flag = true; vl cnt(26,0);

  rep(i,ll(s.size())){
    rep(j,26){
      if(s[i] == small[j]) cnt[j]++;
    }
  }
      
  rep(i,26){
    if((cnt[i] % 2) == 1) flag = false;
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3636
//#pragma GCC optimize("O2")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pi>;
const int maxn = 2e2 + 55;
const int mod = 1e9 + 7;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll h, n, t;
	cin >> h >> n;
	for(int i = 0; i < n; i++)
		cin >> t, h-=t;
	if(h<=0) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int N;
int main(){
    cin>>N;
    int A[100][1000];
    for(int i=1;i<=2;i++){
        for(int j=1;j<=N;j++){
            cin>>A[i][j];
        }
    }

    vector<vector<int> > dp(3,vector<int>((N+1),0));

    for(int i=1;i<=2;i++){
        for(int j=1;j<=N;j++){
            dp[i][j]=A[i][j];
            if(i==1) dp[i][j]+=dp[i][j-1];
            else dp[i][j]+=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    cout<<dp[2][N]<<endl;

    return 0;

}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
#貪欲法じゃダメ？
ans = 0
for i in range(n):
    if b[i] >= a[i]:
        ans += a[i]
        b[i] -= a[i]
        a[i] = 0
    else:
        ans += b[i]
        b[i] = 0
        a[i] -= b[i]
    if b[i] >= a[i + 1]:
        ans += a[i + 1]
        a[i + 1] = 0
    else:
        ans += b[i]
        a[i + 1] -= b[i]
print(ans)

"""
#DPを書きたいぞ
ans = [0] * n #i番目の勇者が倒すモンスターの数
if b[0] >= a[1] + a[0]:
    ans[0] = a[1] + a[0]
elif ans[0] <= b[0]:
    ans[0] = 
"""

Measured memory_bytes: 18752
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;
string ask  (int out ){
 cout << out <<endl ;
 cout<<flush ;
 string s ;
 cin >> s;
 return s ;
}
int main ( ){
 cin >> n ;
 bool state = 0 ;
 string s = ask (0);
 if ( s[0] == 'M') state = 1 ;
 if ( s[0] == 'V') return 0;
 int lo = 1 , hi = n-1 ;
 while ( lo <= hi ){
    int mid = (lo+hi)>>1 ;
    string query = ask(mid);

    if ( query[0] == 'V') break;
    if ( (state && query[0] == 'M' && mid%2 != 0 ) || (!state && query[0] =='F' && mid%2 != 0 )
    || (state && query[0] == 'F' && mid%2 == 0 ) || (!state && query[0] =='M' && mid%2 == 0 ))
        { hi = mid-1 ;}
    else lo = mid+1;
  }
return 0 ;
}


Measured memory_bytes: 852
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

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

int main(){
    int n;
    cin >> n;
    vint a(n);
    REP(i, 0, n){
        cin >> a[i];
    }
//    unique(a.begin(), a.end());

    ll money = 1000;
    ll kabu = 0;
    REP(i, 0, a.size()){
        if(i == a.size() - 1){
            p(money + kabu*a[i]);
            return 0;
        }
        if(kabu == 0){
            if(a[i] < a[i + 1]){
                kabu += money / a[i];
                money -= kabu * a[i];
            }
        } else {
            if(a[i] > a[i + 1]){
                money += kabu*a[i];
                kabu = 0;
            }
        }
    }


}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  rep(i,n){
    int x; cin >> x;
    if(x%2==0){
      if(x%3!=0&&x%5!=0){cout<<"DENIED"<<endl; return 0;}
    }
  }

  cout<<"APPROVED"<<endl;
  return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
void solve()
{
int x;
cin>>x;
if(x==1)
cout<<0<<endl;
else if(x==0)
cout<<1<<endl;
}
int main()
{
//      #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
FASTIO
 long long int t=1;
// cin>>t;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b = 0, e = 0;
	string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'S') {
			b++;
		}
		else {
			if (b >= 1) {
				b--;
			}
			else {
				e++;
			}
		}
	}
	cout << b + e << endl;
	cin >> e;
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

#define LL long long

const int maxn=3e5+1e2;

int a[maxn],vis[maxn]={0};

int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	int cur=1,rel=m-1,now=k;
	if(m+k-1>n||(LL)k*(LL)m<(LL)n)
	{
		printf("-1\n");
		return 0;
	}
	while(cur<n)
	{
		int flag=0;
		rel--;
		if(n-cur<=rel+k)
		{
			now=now-k+n-cur-rel;
			//printf("%d\n",now);
			for(cur<=n;n-cur>rel;cur++)
			{
				a[cur]=now-flag;
				vis[now-flag]=1;
				flag++;
			}
			break;
		}
		for(;cur<=n&&n-cur>rel&&flag<k;cur++)
		{
			a[cur]=now-flag;
			vis[now-flag]=1;
			flag++;
			//printf("%d %d %d %d\n",cur,a[cur],flag,now);
		}
		if(n-cur<=rel)break;
		now+=k;
		//printf("\n%d\n",rel);
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			a[cur]=i;
			cur++;
		}
	}
	for(int i=1;i<=n;i++)printf("%d ",a[i]);
	return 0;
}

/*
10 5 3
*/

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <set>

#include <stdio.h>

using namespace std;

int nth(vector<int>& a, int e) {
  int l = 0, u = a.size() - 1;
  while (l <= u) {
    int m = (l + u) / 2;

    if (a[m] == e)
      return m;
    if (e < a[m])
      u = m - 1;
    else
      l = m + 1;
  }
  return -1;
}

int main() {
  vector<pair<int, int>> cities; // city, year
  unordered_map<int, vector<int>> p2y;	 // pref to years
  int n, m;

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    cities.push_back(pair<int, int>(p, y));
    p2y[p].push_back(y);
  }

  for (auto it = p2y.begin(); it != p2y.end(); it++) {
    sort(it->second.begin(), it->second.end());
  }

  for (int i = 0; i < cities.size(); i++) {
    int pref = cities[i].first;
    int year = cities[i].second;

    printf("%06d%06d\n", pref, 1 + nth(p2y[pref], year));
  }
}


Measured memory_bytes: 11036
package main
 
import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
 
func main() {
	sc.Split(bufio.ScanWords)
	fmt.Println(int(math.Pow(2.0, math.Floor(math.Log10(float64(nextInt())) / math.Log10(2.0)) + 1.0)) - 1)
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string w; cin >> w;
	int alf[26] = {};
	int len = w.length();
	rep(i,len){
		alf[w[i] - 'a']++;
	}
	rep(i, 26) {
		if (alf[i]%2) {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M, X = map(int, input().split())

# 参考書の値段
C_list = []

# 参考書が持つ理解度を上げる能力
A_list = []

for i in range(N):
    C_A_list = list(map(int, input().split()))
    C_list.append(C_A_list[0])
    A_list.append(C_A_list[1:])

A_list = np.array(A_list)

is_use_list = [False] * N

min_value = -1
understand_list = [0] * M
understand_list = np.array(understand_list)
c_total = 0

def dfs(i):

    global c_total
    global understand_list
        
        
    if min(understand_list) >= X:

        global min_value
        if min_value == -1 or c_total < min_value:
            min_value = c_total

    if i >= N:
        return


    is_use_list[i] = True
    understand_list = understand_list + A_list[i]
    c_total += C_list[i]
    dfs(i + 1)
    is_use_list[i] = False
    understand_list = understand_list - A_list[i]
    c_total -= C_list[i]
    dfs(i + 1)

dfs(0)

print(min_value)

Measured memory_bytes: 27252
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>
#include <math.h>           // sqrt()

#define MAX_N 1000

int
main(int argc, char** argv)
{
	double a, a2;
	double m;
	int s[MAX_N];
	int sum;
	int n;
	int i;

	while (true)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		sum = 0;
		for (i = 0; i < n; ++i)
		{
			scanf("%d", &s[i]);
			sum += s[i];
		}

		m = (double) sum / n;
		a2 = 0;
		for (i = 0; i < n; ++i)
			a2 += (s[i] - m) * (s[i] - m) / n;

		a = sqrt(a2);
		printf("%.8f\n", a);
	}

	return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  int sum = 0;
  int N_ = N;
  while(N_ > 0) {
    sum += N_ % 10;
    N_ /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//--- pE ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}


class Solution {
	Scanner scanner;

	public Solution() {
		scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			run_case();
		}
	}


	private void run_case() {
		int N = scanner.nextInt();
		String str = scanner.next();

		BIT[] bit = new BIT[26];
		for (int i=0; i<26; i++) {
			bit[i] = new BIT(N+1);
		}

		for (int i=0; i<str.length(); i++) {
			int idx = str.charAt(i) - 'a';
			bit[idx].addVal(i, 1);
		}

		int Q = scanner.nextInt();
		char[] str_sb = str.toCharArray();
		for (;Q-->0;) {
			int q = scanner.nextInt();

			if (q == 1) {
				int i = scanner.nextInt();
				char c = scanner.next().charAt(0);
				int n = str_sb[i-1] - 'a';
				int m = c - 'a';

				bit[n].addVal(i-1, -1);

				str_sb[i-1] = c;

				bit[m].addVal(i-1, 1);
			} else {
				int l = scanner.nextInt()-1;
				int r = scanner.nextInt()-1;
				int cnt = 0;
				for (int i=0; i<26; i++) {
					long t = bit[i].getSum(l, r);
					if (t > 0) cnt ++;
				}
				System.out.println(cnt);
			}
		}
		return;
	}


	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}

class BIT {
	public long[] arr;
	public BIT(int n) {
		arr = new long[n];
	}
	public long getSum(int i) {
		long sum = 0;
		for(i++;i > 0;i -= i&-i)sum += arr[i];
		return sum;
	}
	public long getSum(int l, int r) {
		return getSum(r) - getSum(l-1);
	}
	public void addVal(int i, long v) {
		if(v == 0)return;
		int n = arr.length;
		for(i++;i < n;i += i&-i)arr[i] += v;
	}
}


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

using namespace std;

void solve(void)
{
	int h, w;
	cin >> h >> w;
	vector<int> ps, qs;
	for (int i = 0; i < h; i++)
	{
		string g;
		cin >> g;
		for (int j = 0; j < w; j++)
		{
			if (g[j] == 'B')
			{
				ps.push_back(i+j);
				qs.push_back(i+w-j);
			}
		}
	}
	sort(ps.begin(), ps.end());
	sort(qs.begin(), qs.end());
	int ans = max(ps.back()-ps.front(), qs.back() - qs.front());
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}




Measured memory_bytes: 3216
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<ll> a(n);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<ll> b(n);
    
    b[0] = a[0];
    
    for (int i = 1; i < n; i++) {
        b[i] = b[i - 1] + a[i];
    }
    
    ll ans = 1LL << 60;
    
    for (int i = 1; i < n - 2; i++) {
        ll p0 = b[0], q0 = b[i] - b[0], p1 = b[i - 1], q1 = b[i] - b[i - 1];
        ll r0 = b[i + 1] - b[i], s0 = b[n - 1] - b[i + 1], r1 = b[n - 2] - b[i], s1 = b[n - 1] - b[n - 2];
    
        
        {
            int ok = -1;
            int ng = i;
            
            while(ng - ok > 1) {
                int m = (ng + ok) / 2;
                
                ll p = b[m], q = b[i] - b[m];
                
                if (p < q) {
                    ok = m;
                } else {
                    ng = m;
                }
            }
            
            if (ok != -1) {
                p0 = b[ok];
                q0 = b[i] - b[ok];
            }
            
            if (ng != i) {
                p1 = b[ng];
                q1 = b[i] - b[ng];
            }
            
        }
        
        
        {
            int ok = i;
            int ng = n - 1;
            
            while(ng - ok > 1) {
                int m = (ng + ok) / 2;
                
                ll r = b[m] - b[i], s = b[n - 1] - b[m];
                
                if (r < s) {
                    ok = m;
                } else {
                    ng = m;
                }
            }
            
            
            if (ok != i) {
                r0 = b[ok] - b[i];
                s0 = b[n - 1] - b[ok];
            }
            
            if (ng != n - 1) {
                r1 = b[ng] - b[i];
                s1 = b[n - 1] - b[ng];
            }
            
        }
        
        ans = min({ans, 
                   max({p0, q0, r0, s0}) - min({p0, q0, r0, s0}),
                   max({p1, q1, r0, s0}) - min({p1, q1, r0, s0}),
                   max({p0, q0, r1, s1}) - min({p0, q0, r1, s1}),
                   max({p1, q1, r1, s1}) - min({p1, q1, r1, s1})});
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


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

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


    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];

    ll ans = 0;
    RFOR(d,40,-1){
        if (d != -1 and !(K & (1LL<<d))) continue;

        ll tmp = 0;
        RREP(e,40){
            ll mask = 1LL << e;
            int num = 0;
            REP(i,N) if (A[i] & mask) num++;
            if (e > d) {
                if (K & mask) tmp += mask*(N-num);
                else tmp += mask*num;
            } else if (e == d) {
                tmp += mask*num;
            } else {
                tmp += mask*max(num,(int)N-num);
            }
        }

        ans = max(ans, tmp);
    }

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

Measured memory_bytes: 1152
#include <vector>
#include <cstdio>
#include <queue>

class Edge{
public:
	int start, to, weight;
	Edge(const int s = 0, const int t = 0, const int w = 0):start(s), to(t), weight(w){};
};
int main(){
	int n;
	std::scanf("%d", &n);
	std::vector<std::vector<Edge>> edge(n);
	for(auto i = 1; i < n; ++i){
		int s, t, w;
		std::scanf("%d %d %d", &s, &t, &w);
		edge.at(s).push_back(Edge(s, t, w));
		edge.at(t).push_back(Edge(t, s, w));
	}
	int max;
	auto func = [&](int start){
		std::queue<Edge> queue;
		std::vector<int> node(n, -1);
		node.at(start) = -1;
		queue.push(Edge(start, start, 1));
		for (auto i = 0; i < n; ++i){
			while (node.at(queue.front().to) >= 0){queue.pop();}
			node.at(queue.front().to) = node.at(queue.front().start) + queue.front().weight;
			for (auto e : edge.at(queue.front().to)){
				queue.push(e);
			}
		}
		max = 0;
		int minn;
		for (auto i = 0; i < n; ++i){
			if (max < node.at(i)){
				max = node.at(i);
				minn = i;
			}
		}
		return minn;
	};
	func(func(0));
	std::printf("%d\n", max);
}

Measured memory_bytes: 9256