akhauriyash/Code-Regression huggingface dataset:
n,x,y=[int(j) for j in input().split()]
l=[[0]*n for i in range(n)]
ans=[0]*n
x-=1
y-=1
s=y-x-1
for i in range(n):
    for j in range(n):
        if i<j:
            ans[min(j-i,abs(i-x)+abs(j-y)+1,)]+=1

print('\n'.join(map(str,ans[1:])))





Measured memory_bytes: 75228
n = int(input())
a = 'abcdefghijklmnopqrstuvwxyz'
l = [input() for _ in range(n)]
res = []
for i in a:
    mi = 100
    for j in l:
        mi = min(mi, j.count(i))
    res.append(mi)
ans = ''
for i in range(26):
    ans += a[i]*res[i]
print(ans)

Measured memory_bytes: 3064
N = int(input())
S = input()
answer = ""
# アルファベットは26文字,Zの次はAにループするのでoed()で
# UniCode変換後にNを足し、それを%26を行った値を足す
for word in S:
    answer += chr( ord("A") + (ord(word)-ord("A")+N)%26 )

print(answer)

# //////////////////////////////////////////////////
# // ループさせる問題はループの個数の除算分で制御する //
# // 今回はAに,Aと文字の差にずらした分を26で除算する //
# //  ord()←→chr()でそれぞれUniCodeを経て変換可能　 //
# /////////////////////////////////////////////////

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 3333 , __ = _<<1 , mo = 1000000007;

template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}

int n,m,nm,per,tim;
lint f[__][__]={0};

inline int able(int a,int b)
{
	if(a>n || b>m || a<0 || b<0)return 0;
	if((n-a)%(per-1) || (m-b)%(per-1))return 0;
	return 1;
}

int main()
{
	n=ty(),m=ty(),nm=n+m,per=ty(),tim=(nm-1)/(per-1);
	f[0][0]=1;
	for(int i=0;i<tim;i++)
		for(int j=0;j<=nm;j++)
			if(f[i][j])
				for(int k=0;k<per && j+k<=nm;k++)
					ad(f[i+1][j+k],f[i][j]);
	lint ans=0;
	for(int i=0;i<tim;i++)
		for(int j=0;j<=nm;j++)
			for(int k=1;k<per && j+k<=nm;k++)
				if(able((per-1)*i+per-j-k,j+k))ad(ans,f[i][j]);
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 207232
# 解き直し
# 名前にTypicalって書いてあるのでTypicalです


n, m = map(int, input().split())
step_count = [0 for _ in range(n+1)]
ng_step = [False for _ in range(n+1)]
for _ in range(m):
  ng = int(input())
  ng_step[ng] = True

for i in range(n+1):
  if ng_step[i]:
    step_count[i] = 0
  else:
    if i==1:
      step_count[i] = 1
    elif i==2:
      step_count[i] = 1 + step_count[i-1]
    else:
      step_count[i] = (step_count[i-2]+step_count[i-1])%(10**9+7)

print(step_count[-1])

Measured memory_bytes: 7832
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	while(k--){
		int a,b;
		cin>>a>>b;
		if(n%2){
			cout<<1+(n/2-max(abs(n/2+1-a),abs(n/2+1-b)))%3<<endl;
		}else{
			int ca,cb;
			ca=n/2<a?n/2+1:n/2;
			cb=n/2<b?n/2+1:n/2;
			cout<<1+(n/2-1-max(abs(ca-a),abs(cb-b)))%3<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc163
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc163C();
			Console.Out.Flush();
        }

        public static void solve_abc163C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] res = new int[n];
            //int prev = a.Length > 1 ? a[0] != a[1] ? a[1] : a[0] : a[0];
            //int cnt = a.Length > 1 ? a[0] != a[1] ? 1 : 0 : 0;
            //List<int> children = new List<int>();
            for (int i = 0; i < a.Length; i++)
            {
                res[a[i] - 1]++;
            }

            for (int i = 0; i < res.Length; i++)
            {
                Console.WriteLine(res[i]);
            }
        }

        public static void solve_abc163B()
        {
            int[] nm  = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = nm[0];
            int m = nm[1];
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long sum = 0;
            for (int i = 0; i < m; i++)
            {
                sum += a[i];
            }
            Console.WriteLine(sum <= n ? n - sum : -1);
        }

        public static void solve_abc163A()
        {
            int r = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(2 * Math.PI * r);
        }
    }
}


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

using namespace std;

int main() {
  int n, t;
  cin >> n >> t;
  int mini = 10101;
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (y > t) continue;
    mini = min(mini, x);
  }
  if (mini != 10101) {
    cout << mini << '\n';
  } else {
    cout << "TLE";
  }
  return 0;
}


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

int main(){
  ll H,W;
  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  if(H % 2 == 0){
    if(W % 2 == 0){
      cout << H / 2 * W << endl;
    }else{
      cout << H * (W - 1) / 2 + H / 2 << endl;
    }
  }else{
    ll tmp = (H - 1) * W / 2;
    ll a = W / 2;
    if(W % 2 == 0){
      cout << tmp + a << endl;
    }else{
      ll tmp = (H - 1) * (W - 1) / 2;
      ll b = H / 2;
      ll c = W / 2;
      cout << tmp + b + c + 1 << endl;
    }
  }

}


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: i64,
        m: usize,
        py: [(i64, i64); m],
    }
    let mut py = py;
    let mut x = 1;
    let mut py = py.into_iter().map(|c| {x+=1; (c.0, c.1, x)}).collect::<Vec<_>>();
    py.sort_by_key(|c| c.1);
    let mut p = vec![0; n as usize];
    let mut s = vec![(0, 0, 0); m];
    for (i, j) in py.into_iter().zip(0..) {
        p[(i.0 - 1) as usize]+=1;

        s[j].0 = i.0;
        s[j].1 = p[(i.0 - 1) as usize];
        s[j].2 = i.2;

    }
    s.sort_by_key(|c| c.2);
    for i in s {
        print!("{:>06}", i.0);
        println!("{:>06}", i.1);
    }
}

Measured memory_bytes: 13560
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    long long int  a,b,c;
    cin >> a>>b>>c;
    if((c-a-b)<=0){
        cout << "No";
        return 0;
    }
    
    long long int R=(c-a-b)*(c-a-b)-4*a*b;
    if(R<=0){
        cout << "No"<<endl;
    }else{
        cout << "Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int maxn = 110;
const int maxm = 100100;
const int inf = 1e9;

typedef long long int ll;
typedef pair<int,int> ii;

int dp[maxm];
int wei[maxn],val[maxn];
int n,m,total;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	
	for(int i=1;i<=n;++i)
	{		
		cin>>wei[i]>>val[i];
		total += val[i];
	}

	for(int i=1;i<=total;++i)
		dp[i] = inf;
	
	dp[0] = 0;

	
	for(int i=1;i<=n;++i)
	{
		int w = wei[i],v = val[i];

		for(int j=total;j>=v;j--)
		{
			dp[j] = min(dp[j],dp[j - v] + w);
		}
	}

 	for(int i=total;total>=0;--i)
 	{
 		if(dp[i] <= m)
 		{
 			cout<<i<<"\n";
 			return 0;
 		}
 	}

}

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

int f(char *S,int N){
  for(int i=0;i<N/2;i++){
    if(S[i]!=S[N-1-i]) return 0;
  }
  return 1;
}

int main(){
  char S[101],T[101],U[101];
  int N;
  scanf("%s",S);
  N=strlen(S);
  for(int i=0;i<(N-1)/2;i++) T[i]=S[i];
  for(int i=(N+3)/2-1;i<N;i++) U[i-(N+3)/2+1]=S[i];
  if(f(S,N)*f(T,(N-1)/2)*f(U,(N-1)/2)==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N - 1; i++)
  {
    set<int> a, b;
    for (int j = 0; j < i; j++)
      a.insert(S[j]);
    for (int j = i; j < N; j++)
      b.insert(S[j]);
    int num = 0;
    for (auto itr = a.begin(); itr != a.end(); itr++)
    {
      if (b.count(*itr))
        num++;
    }
    ans = max(ans, num);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int n,c1,c2,c3,c4,c5,c6,c7,c8,a,c9;
	c1=c2=c3=c4=c5=c6=c7=c8=c9=0;
	cin>>n;
	while(n--)
	{
		cin>>a;
		if(c1==0 && a<=399)
			c1++;
		else if(c2==0 && a>399 && a<=799)
			c2++;
		else if(c3==0 && a>799 && a<=1199)
			c3++;
		else if(c4==0 && a>1199 && a<=1599)
			c4++;
		else if(c5==0 && a>1599 && a<=1999)
			c5++;
		else if(c6==0 && a>1999 && a<=2399)
			c6++;
		else if(c7==0 && a>2399 && a<=2799)
			c7++;
		else if(c8==0 && a>2799 && a<=3199)
			c8++;
		else if(a>=3200)
			c9++;
	}

	if(c1==0 && c2==0 && c3==0 && c4==0 && c5==0 && c6==0 &&c7==0 && c8==0 && c9!=0)
		cout<<1<<" "<<c9;
	else
		cout<<c1+c2+c3+c4+c5+c6+c7+c8<<" "<<c1+c2+c3+c4+c5+c6+c7+c8+c9;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
int n,k;
int h[200000];
vector<int>dp(200000,INF);
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>h[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        if(i<k){
            for(int j=1;j<i+1;j++){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
        else{
            for(int j=1;j<k+1;j++){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    VP pr(N);
    rep(i, 0, N){
        cin >> pr[i].second >> pr[i].first; 
    }
    sort(ALL(pr));
    ll now = 0;
    rep(i, 0, N){
        if(now + pr[i].second > pr[i].first){
            cout << "No" << endl;
            return 0;
        }
        now += pr[i].second;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
//
//  main.cpp
//  20190808lesson
//
//  Created by Priscilla Leang on 8/8/19.
//  Copyright © 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x, y;
    bool b1 = false;
    cin>> x >> y;
    if (x<=8 && y <= 8){
        b1 = true;
    }
    if (b1 == true){
        cout << "Yay!";
    }
    if (b1 == false){
        cout << ":(";
    }
    return 0;
}


Measured memory_bytes: 256
array=gets.split("").map(&:to_i)
brray=[]
s=0
while s<3
  if array[s] == 1
    brray.push(9)
  else
    brray.push(1)
  end
  s+=1
end
puts 100*brray[0]+10*brray[1]+brray[2]


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

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

int main(){
  ll n,k;cin>>n>>k;
  ll a,b,ans1=0;
  if(k==0){
    rep(i,n){
      cin>>a>>b;
      if(a==0){
        ans1+=b;
      }
    }
    cout<<ans1<<endl;
    return 0;
  }
  ll temp=k;
  vector<ll> digit;
  ll cnt=0;
  while(temp){
    if(temp&1){
      digit.pb(cnt);
    }
    cnt++;
    temp=temp>>1;
  }
  sort(all(digit),greater<ll>());
  vector<pl> search_area;
  ll now=pow(2,digit[0]);
  rep(i,digit.size()){
    if(i==0){
      search_area.pb(mp(0,now-1));
    }else{
      search_area.pb(mp(now,now+pow(2,digit[i])-1));
      now+=pow(2,digit[i]);
    }
  }
  vector<ll> ans(search_area.size()+1);
  rep(i,n){
    cin>>a>>b;
    rep(j,search_area.size()){
      if(((search_area[j].se|a)==search_area[j].se)){
        ans[j]+=b;

      }
    }
    if((k|a)==k){
      ans[search_area.size()]+=b;
    }
  }
  auto maxIt = max_element(ans.begin(), ans.end());
  cout<<*maxIt<<endl;

  return 0;
}

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

int main(){
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(i%2==0 && s.at(i)=='1')count++;
    else if(i%2==1 && s.at(i)=='0')count++;
  }
  if(count<s.size()-count)cout<<count<<endl;
  else cout<<s.size()-count<<endl;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<int> H(N);
    REP(i,N) cin>>H[i];
    int ans = 1;
    for (int i=1;i<N;i++) {
        bool flag = true;
        for (int j=0;j<i;j++) {
            if (H[i] < H[j]) flag = false;
        }
        if (flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

ll ext_gcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll q = a / b;
  ll g = ext_gcd(b, a - q * b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}

// 逆元
ll mod_inv(ll a, ll m) {
  ll x, y;
  ext_gcd(a, m, x, y);
  x %= m;
  if (x < 0)
    x += m;
  return x;
}

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

  string s;
  cin >> s;

  // 桁数
  int digit = s.size();

  // dp[桁数][13で割ったあまり]
  vvll dp(digit + 1, vll(13));

  dp[0][0] = 1;

  ll keta = 1;
  rep(i, digit - 1) {
    keta = (keta * 10) % 13;
  }

  ll inv_ten = mod_inv(10, 13);

  for (int d = 0; d < digit; d++) {
    if (s[d] == '?') {
      rep(v, 10) {
        ll num = (keta * v) % 13;
        rep(i, 13) {
          dp[d + 1][(i + num) % 13] += dp[d][i];
          dp[d + 1][(i + num) % 13] %= mod;
        }
      }
    } else {
      ll num = (keta * ((ll)s[d] - '0')) % 13;
      rep(i, 13) {
        dp[d + 1][(i + num) % 13] += dp[d][i];
        dp[d + 1][(i + num) % 13] %= mod;
      }
    }
    keta = (keta * inv_ten) % 13;
  }

  cout << dp[digit][5] << endl;

  return 0;
}


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

int main(){
	int n,sum=0;
	string s;
	while(cin>>s){
		n=0;
		for(int i=0;i<s.size();i++){
			if(isdigit(s[i]))n = 10*n+s[i]-'0';
			else {
				sum += n;
				n=0;
			}
		}
		sum += n;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1184
use std::io::{self, Read, Write};
use std::str::{self, FromStr};

pub struct IO<R: Read, W: Write>(R, io::BufWriter<W>);

impl<R: Read, W: Write> IO<R, W> {
    pub fn new(reader: R, writer: W) -> Self {
        Self(reader, io::BufWriter::new(writer))
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
        .0
        .by_ref()
        .bytes()
        .map(|b| b.unwrap())
        .skip_while(|&b| (b as char).is_whitespace())
        .take_while(|&b| !(b as char).is_whitespace())
        .collect::<Vec<u8>>();

        unsafe { str::from_utf8_unchecked(token.as_slice()) }
        .parse()
        .ok()
        .expect("Can't parse it.")
    }

    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


fn main() {
    let (r, w) = (io::stdin(), io::stdout());
    let mut rw = IO::new(r.lock(), w.lock());

    let s: String = rw.read();
    println!("{}", s.chars().filter(|&c| c == '1').count());
}

Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] t = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();
            int sum = t.Sum();
            int m = int.Parse(Console.ReadLine());
            
            for (int i = 0; i < m; ++i)
            {
                int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                Console.WriteLine("{0}", sum - (t[input[0] - 1] - input[1]));
            }
        }
    }
}


Measured memory_bytes: 3032
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 100000;

char s[MAXN + 1]; int n;
int cnt[3];

void run() {
	scanf("%s", s); n = strlen(s);

	REP(i, 3) cnt[i] = 0; REP(i, n) ++cnt[s[i] - 'a'];
	int mn = cnt[0], mx = cnt[0]; FOR(i, 1, 3) { if (cnt[i] < mn) mn = cnt[i]; if (cnt[i] > mx) mx = cnt[i]; }
	printf("%s\n", mx - mn <= 1 ? "YES" : "NO");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
a = [0] * 100100
for i in range(1,100010):
    tmp = 0
    if is_prime(i) and is_prime((i+1)//2):
        tmp = 1
    a[i] = a[i-1] + tmp
q = inp()
for _ in range(q):
    l,r = inpl()
    print(a[r] - a[l-1])

Measured memory_bytes: 13340
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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

    int n;
    cin >> n;
    vector<long long> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    long long lcm = v[0], den = 0;
    for (int i = 1; i < n; i++)
        lcm = (lcm * v[i]) / __gcd(lcm, v[i]);
    for (int i = 0; i < n; i++)
        den += (lcm / v[i]);
    float ans = float(lcm) / float(den);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];// = new int[m];
    for (int i = 0;i<m;i++){
        cin>>b[i];
    }
    int a[n][m];// = new int[n][m]; 
    for (int i = 0;i<n;i++){
        for (int j = 0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int ans =0;
    
    for (int i = 0;i<n;i++){
        int tmp=c;
        for (int j = 0;j<m;j++){
            tmp += a[i][j]*b[j];
        }
        if (tmp>0){
            ans++;
        }
    }
    cout<<ans;

    
}


Measured memory_bytes: 3588
import collections
n=int(input())
v=list(map(int,input().split()))
odd=[]
even=[]
l1=[]
l2=[]
for i in range(n):
    if i%2==0:
        even.append(v[i])
    else:
        odd.append(v[i])
#print(even,odd)

c1=collections.Counter(odd)
values=list(c1.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c1.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l1.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
c2=collections.Counter(even)
values=list(c2.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c2.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l2.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
l1.sort(key=lambda x:x[1],reverse=True) #i=0,2,4...
l2.sort(key=lambda x:x[1],reverse=True) #i=1,3,5...

#print(l1,l2)
if l1[0][0]!=l2[0][0]:
    print(len(v)-l2[0][1]-l1[0][1])
else:
    if (len(l1)==1)and(len(l2)==1):
        print(len(v)-max(l1[0][1],l2[0][1]))
    elif len(l1)==1:
        print(len(v)-l1[0][1]-l2[1][1])
    elif len(l2)==1:
        print(len(v) - l1[1][1] - l2[0][1])
    else:
        print(min(len(v)-l1[0][1]-l2[1][1],len(v)-l1[1][1]-l2[0][1]))


Measured memory_bytes: 74500
#include<iostream>

using namespace std;


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

}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << "\n";
}

Measured memory_bytes: 3104
x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
	print(x-k*d)

else:
	k-=x//d
	x-=(x//d)*d
	rem=k%2
	if rem:
		print(d-x%d)
	else:
		print(x%d)
	

Measured memory_bytes: 9168
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

int main(){

  int n,w,h,s,t,x,y;

  while(true){
    cin >> n;
    if(n==0) break;
    cin >> w >> h;
    int field[100][100];
    
    rep(i,100) rep(j,100) field[i][j]=0;// 0 origin
    rep(i,n){ cin >> x >> y; field[y-1][x-1]=1;}
    
    cin >> s >> t;
    int ans=0;
    rep(i,h-t+1) rep(j,w-s+1){
      int cnt=0;
      rep(k,t) rep(l,s){
        if(field[i+k][j+l]==1) cnt++;
      }
      ans=max(ans,cnt);
    }
    cout << ans << endl;
  }

 }

Measured memory_bytes: 3028
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]

di = (0, 1, 0, -1) 
dj = (1, 0, -1, 0)

ans = 'Yes'
for i in range(h):
  if ans == 'No':
      break
  for j in range(w):
    if ans == 'No':
      break
    count = 0
    if s[i][j] == '#':
      for k in range(4):
        if i+di[k] < 0 or h <= i+di[k]:
          count += 1
          continue
        elif j+dj[k] < 0 or w <= j+dj[k]:
          count += 1
          continue
        else:
          if s[i+di[k]][j+dj[k]] == '#':
            break
          else:
            count += 1
    if count == 4:
      ans = 'No'
      break
          
print(ans)

Measured memory_bytes: 3064
def main():
    h,w,k=map(int,input().split())
    mod = 10**9+7
    b = [1,1,2,3,5,8,13,21,34]
    dp=[[0 for _ in range(w)]for j in range(h+1)]
    dp[0][0] = 1
    if w == 1:
        return 1

    for i in range(h):
        for j in range(w):
            if j == 0:
                dp[i+1][j]=(dp[i][j]*b[w-1]+dp[i][j+1]*b[w-2])%mod
            elif j == w-1:
                dp[i+1][j]=(dp[i][j]*b[w-1]+dp[i][j-1]*b[w-2])%mod
            else:
                dp[i+1][j]=(dp[i][j]*b[j]*b[w-1-j]+dp[i][j-1]*b[j-1]*b[w-1-j]+dp[i][j+1]*b[j]*b[w-2-j])%mod
    return dp[h][k-1]

print(main())

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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N, K;
  vector< int > g[100000];
  int v[100000];
  fill_n(v, 100000, INF);

  cin >> N;
  for(int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cin >> K;
  priority_queue< pair< int, int > > que;
  for(int i = 0; i < K; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    que.emplace(b, a);
    v[a] = b;
  }
  while(!que.empty()) {
    auto p = que.top();
    que.pop();
    for(auto &to : g[p.second]) {
      if(v[to] != INF) {
        if(abs(v[to] - v[p.second]) != 1) {
          cout << "No" << endl;
          return (0);
        }
      } else {
        v[to] = v[p.second] - 1;
        que.emplace(v[to], to);
      }
    }
  }

  cout << "Yes" << endl;
  for(int i = 0; i < N; i++) cout << v[i] << endl;

}

Measured memory_bytes: 7924
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = I()

    return a[k-1]


print(main())





Measured memory_bytes: 6472
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String t = sc.next();
	int lens = s.length();
	int lent = t.length();
	String t2 = t.substring(lens, lent);

	System.out.println(s.equals(t.substring(0,lens))&&t2.length()==1?"Yes":"No");
    }
}

Measured memory_bytes: 35700
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()


a,b=mi()

def f(x):
  
  if x%2==0:
    if (x//2)%2==0:
      s=0^x
      
    else:
      s=1^x
      
  else:
    if ((x+1)//2)%2==0:
      s=0
      
    else:
      s=1
      
  return s

print(f(a-1)^f(b))
    

Measured memory_bytes: 9200
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

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

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

pair<Weight, Edges> minimumSpanningForest(const Graph &g) {
  int n = g.size();
  UnionFind uf(n);
  priority_queue<Edge> Q;
  REP(u, n) FOR(e, g[u]) if (u < e->dst) Q.push(*e);

  Weight total = 0;
  Edges F;
  while ((int)F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.unionSet(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
    }
  }
  return pair<Weight, Edges>(total, F);
}

int main() {
    int n, m;
    while ( cin >> n >> m ) {
        if ( n == 0 && m == 0 ) break;
        Graph g(n);
        int sum = 0;
        for ( int i = 0; i < m; i++ ) {
            int a, b, c;
            cin >> a >> b >> c;
            g[a].push_back( Edge( a, b, c ) );
            g[b].push_back( Edge( b, a, c ) );
            sum += c;
        }

        cout << minimumSpanningForest(g).first << endl;
    }
    return 0;
}

Measured memory_bytes: 0
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"redcoder"# => r#"1"#,
r#"abcdabc"# => r#"2"#,

}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        s: chars,
    }

    let mut ans = 0;

    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - 1 - i] {
            ans += 1;
        }
    }

    ans.to_string()
}

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

using namespace std;
typedef long long ll;

const ll INF = 1145141919810893;

int N;
ll dp[400][400];
ll cost[400];
ll ruisekiwa[401];//idx i ~ idx j (i < j)は [i, j)

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> cost[i];
		ruisekiwa[i + 1] = cost[i] + ruisekiwa[i];
	}
	for (int i = 0; i < N; i++)for (int j = 0; j < N; j++)dp[i][j] = INF;

	for (int i = 0; i < N; i++)dp[i][i] = 0;

	for (int i = 1; i < N; i++) {
		for (int j = 0; j + i < N; j++) {
			ll ans = INF;
			if (i == 1) {
				dp[j][j + i] = ruisekiwa[j + i + 1] - ruisekiwa[j];
			}
			else {
				for (int k = j; k <= j + i - 1; k++) {
					int ll = j, lr = k, rl = k + 1, rr = j + i;
					ans = min(ans, dp[ll][lr] + dp[rl][rr]);
				}
				ans += ruisekiwa[j + i + 1] - ruisekiwa[j];
				dp[j][j + i] = ans;
			}
		}
	}
	
	cout << dp[0][N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1536
Input = list(input())
for i in range(4):
    Input[i] = int(Input[i])
Kouho = [[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]
flag = 0
for i in range(8):
    tmp = Input[0]
    if Kouho[i][0] == 0:
        tmp -= Input[1]
    else:
        tmp += Input[1]
    if Kouho[i][1] == 0:
        tmp -= Input[2]
    else:
        tmp += Input[2]
    if Kouho[i][2] == 0:
        tmp -= Input[3]
    else:
        tmp += Input[3]
    if tmp == 7:
        for j in range(4):
            Input[j] = str(Input[j])
        for j in range(3):
            if Kouho[i][j] == 0:
                Kouho[i][j] = '-'
            else:
                Kouho[i][j] ='+'
        Input.insert(1,Kouho[i][0])
        Input.insert(3,Kouho[i][1])
        Input.insert(5,Kouho[i][2])
        Input.insert(7,'=7')
        ans = ''.join(Input)
        print(ans)

        break



Measured memory_bytes: 3064
import java.util.*;

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

	class AOJ0565{
		public AOJ0565() {
			int a = Integer.MAX_VALUE;
			int b = Integer.MAX_VALUE;
			for(int i=0;i<3;i++)a = Math.min(a,in.nextInt());
			for(int i=0;i<2;i++)b = Math.min(b, in.nextInt());
			System.out.println(a+b-50);
		}
	}

}

Measured memory_bytes: 17172
def gcd(a,b):
    if b==0:
        return a
    
    return gcd(b,a%b)
  
def lcm(x,y):
    return (x*y) // gcd(x, y)

A,B,C,D=[int(x) for x in input().split()]

A_C=A//C
if C*A_C!=A:
  A_C+=1
B_C=B//C  
A_D=A//D
if D*A_D!=A:
  A_D+=1
B_D=B//D

E=lcm(C,D)
A_E=A//E
if E*A_E!=A:
  A_E+=1
B_E=B//E

print(B-A+1-(B_C-A_C+1+B_D-A_D+1-(B_E-A_E+1)))


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


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

    int N;
    cin >> N;
    int T[N];
    rep(i,N) cin >> T[i];
    int M;
    cin >> M;
    int P[M],X[M];
    rep(i,M) cin >> P[i] >> X[i];

    int sum=0;
    int ans=0;
    rep(i,N) sum+=T[i];
    rep(i,M) {
        ans=sum-T[P[i]-1]+X[i];
        cout << ans << endl;
    }


}


Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
#define Q 500


int main(){
  int i,len=0,key=0,s[N],t[Q],count=0;

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

  scanf("%d",&key);
  for( i = 0 ; i < key ; i++ ){
    scanf("%d",&t[i]);
    for(int j = 0 ; j < len ; j++ ){
      if( t[i] == s[j]){
        count++;
        break;
      }
    }
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2036
#include<cstdio>
using namespace std;

int n;
int a[10];
int main(){
    scanf("%d", &n);
    int l = 1, b = 1;
    for (int i=0; i<n; ++i){
        scanf("%d", a+i);
        l *= 3;
        if (a[i] % 2 == 0) b*= 2;
    }
    printf("%d\n", l - b);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
int n;
char s[101000];
char ans[101000];
bool check(){
	for (int i = 1; i < n-1; ++i)
	{
		if(s[i]=='o'&&ans[i]=='S'||s[i]=='x'&&ans[i]=='W'){
			ans[i-1] =='S' ? ans[i+1]='S' :ans[i+1] = 'W';
		}else{
			ans[i-1] =='S' ? ans[i+1]='W' :ans[i+1] = 'S';
		}
	}
	if((ans[n-1]=='S'&&s[n-1]=='o')||(ans[n-1]=='W'&&s[n-1]=='x')){
		if(ans[0]!=ans[n-2]){
			return false;
		}
	}else{
		if(ans[0]==ans[n-2]){
			return false;
		}
	}
	if((ans[0]=='S'&&s[0]=='o')||(ans[0]=='W'&&s[0]=='x')){
		if(ans[1]!=ans[n-1]){
			return false;
		}
	}else{
		if(ans[1]==ans[n-1]){
			return false;
		}
	}
	return true;
}
int main(){
	cin >> n;
	cin >> s;
	int i;
	for (i = 0; i < 4; ++i)
	{
		ans[0]= (i/2==0)?'S':'W';
		ans[1]= (i%2==0)?'S':'W';
		if(check()) break;
	}
	if(i==4){
		cout << "-1" << endl;
	}else{
		ans[n]='\0';
		cout << ans << endl;
	}
	// freopen("in.txt","r",stdin);
	return 0;
}


Measured memory_bytes: 512
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = {i, io.read("*n")}
end
table.sort(t, function(x, y) return x[2] < y[2] end)
local s = {}
for i = 1, n do s[i] = t[i][1] end
print(table.concat(s, " "))


Measured memory_bytes: 22200
#include <iostream>
#include <algorithm>
using namespace std;
int n, m[222],b[222];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>m[i];
	}
	for(int i=0;i<n;i++){
		while(m[i]%2==0){
			m[i]=m[i]/2;
			b[i]++;	
		}
	}
	sort(b,b+n);
	cout<<b[0];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MAX = 100010;
const int64_t MOD = 1000000007;

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

void initCombination()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int 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;
  }
}

int64_t nCk(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  int64_t N, bef = -1, aft = -1;
  cin >> N;
  vector<int64_t> A(N + 1), B(N + 1, -1);
  for (int i = 0; i <= N; i++)
  {
    cin >> A.at(i);
    if (B.at(A[i]) == -1)
    {
      B[A[i]] = i;
    }
    else
    {
      bef = B[A[i]];
      aft = N - i;
    }
  }
  initCombination();
  for (int64_t i = 1; i <= N + 1; i++)
  {
    int64_t base = nCk(N + 1, i);
    if (i - 1 <= bef + aft)
    {
      base = (base - nCk(bef + aft, i - 1) + MOD) % MOD;
    }
    cout << base << endl;
  }
}


Measured memory_bytes: 7160
#include<iostream>
using namespace std;
int main(){
  int n,a[200001]={};
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  int max=a[1]-a[0];
  int min=a[0];
  for(int i=1;i<n;i++){
      if(a[i]-min>max)max=a[i]-min;
      if(min>a[i])min=a[i];
  }
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 1948
s = gets.chomp.chars
t = gets.chomp.chars

n = s.size
m = t.size
ans = n

n.times do |i|
    break if i + m > n

    c = 0
    m.times do |j|
        c += 1 if s[i+j] != t[j]
    end
    ans = c if ans > c
end

p ans

Measured memory_bytes: 14244
import math
z=[]
ans=0
sumsum=0
N,D=(int(x) for x in input().split())
for i in range(N):
    a=input().split()
    #print(a)
    z.append(a)
#print(z)

for i in range(N):
    for j in range(i,N):
        for k in range(D):
            sumsum=sumsum+(int(z[i][k])-int(z[j][k]))**2
        if sumsum!=0 and math.sqrt(sumsum)%1==0:
            ans=ans+1
        sumsum=0

print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 2e5 + 10;
LL dp[N][5]; 
int a[N];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);	
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i-1][0] + a[i];
		for (int j = 1; j < 5; j++) {
			dp[i][j] = dp[i-1][j];
			for (int k = 0; k < j; k++) dp[i][j] = min(dp[i][j], dp[i-1][k]);
		}
		dp[i][1] += a[i] == 0 ? 2 : (a[i]%2 != 0);
		dp[i][2] += a[i]%2 != 1;
		dp[i][3] += a[i] == 0 ? 2 : (a[i]%2 != 0);
		dp[i][4] += a[i];		
	}
	LL ans = dp[n][0];
	for (int i = 1; i < 5; i++) ans = min(ans, dp[n][i]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=2e5+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

/*double p[N];
int n;
inline void dfs(int s,int n,double p) {
	if (n) {
		for (int i=0;;i++)
			if (s>>i&1) {
				::p[i]+=p;
				s^=1<<i;
				break;
			}
		for (int i=0;i<::n;i++)
			if (s>>i&1)
				dfs(s^(1<<i),n-1,p/(n*2-1));
	}
	}*/
int main()
{
	/*for (n=2;n<=20;n+=2) {
		for (int i=0;i<n;i++) p[i]=0;
		dfs((1<<n)-1,n>>1,1);
		for (int i=0;i<n;i++) printf("%.5lf ",p[i]);
		putchar(10);
		}*/
	int n=gi(),i;VI w;double ans=0,t=1.0/(n*2-1);
	for (i=0;i<n*2;i++) w.pb(gi());
	sort(w.begin(),w.end());
	for (i=0;i<n*2;i++) ans+=i*t*w[i];
	printf("%.10lf\n",ans);
	return 0;
}


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

int main()
{
	int x;
	cin>>x;
	if(x==1)
		cout<<'1';
	else
	{
		int large=0;
		for(int i=2;i<=(int)sqrt(x);i++)
		{
			for(int j=2;j<(int)sqrt(x);j++)
			{
				if(pow(i,j)<=x && pow(i,j)>large)
					large=pow(i,j);
				else if(pow(i,j)>x)
					break;
			}
		}
		cout<<large;
	}
	return 0;
}

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

int main(){
   int a, b;
   cin >> a;
   int arr[a];
   for(int i=0; i<a; i++){
      cin >> b;
      arr[b-1]=i+1;
   }
  for(int i=0; i<a; i++){
     cout << arr[i] << ' ';
  }
}


Measured memory_bytes: 1152
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TypeApplications #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.IntSet as Set
import qualified Data.List as L
import System.Random

main :: IO ()
main = do
  [d] <- readInts
  cs <- readInts
  dss <- replicateM d readInts
  -- replicateM d readInts >>= output d . solve 0
  -- let fmt s = show s ++ "\n"
  -- replicateM_ 365 $ (randomRIO @Int (1,26) >>= appendFile "tester/example/test.out" . fmt)
  replicateM_ 365 $ (randomRIO @Int (1,26) >>= print)
  -- return ()

solve :: Int -> [[Int]] -> [Int]
solve n dss
  | n < 365 = solve' n (dss !! n) : solve (n+1) dss
  | otherwise = []

solve' :: (Num a1, Ord a2, Ord a1, Enum a1) => p -> [a2] -> a1
solve' n dss = 1 + (snd $ maximum $ zip dss [0..] )

output :: Int -> [Int] -> IO ()
output d = mapM_ print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 4836
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    result = ""
    while N:
        result = str(N % 2) + result
        N = (N - N % 2) // -2
    print(result or 0)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int a = 0, b = 0, c = 0;
  fscanf(stdin, "%d %d %d", &a, &b, &c);
  if (a < b && b < c) {
    printf("Yes");
  }
  else {
    printf("No");
  }
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 1180
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

A, B, C = MI()
K = INT()

for i in range(K):
    if A >= B:
        B *= 2
        continue
    if B >= C:
        C *= 2
        continue
print("Yes" if B > A and C > B else "No")

Measured memory_bytes: 61732
import sys
for line in sys.stdin:
	n = int(line)
	cnt = 0
	for i in range(0, 10):
		for j in range(0, 10):
			for k in range(0, 10):
				for p in range(0, 10):
					if i+j+k+p == n:
						cnt += 1
						break
				if i+j+k == n: break
			if i+j == n: break
		if i == n: break
	print cnt


Measured memory_bytes: 4648
#include <bits/stdc++.h>
using namespace std;
int main() {
int A,B,C,D;
cin>>A>>B>>C>>D;
while(A>0||C>0){
    C-=B;
    if(C<=0){
        cout<<"Yes"<<endl;
        return 0;
    }
    A-=D;
    if(A<=0){
        cout<<"No"<<endl;
        return 0;
}
}
}

Measured memory_bytes: 3636
local N = io.read("n")
local H = {}
for i=1, N do
    H[i] = io.read("n")
end
local left = H[1] - 1
for i=2, N do
    if H[i] > left then
        left = H[i] - 1
    elseif H[i] == left then
        left = H[i]
    else
        print("No")
        return
    end
end
print("Yes")

Measured memory_bytes: 2424