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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=0;
  rep(i,n){
    ll a; cin>>a;
    if(i%2==0 & a%2==1) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1e9+7
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    ll N;
    cin>>N;
    cout<<N*(N-1)/2<<endl;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n,count=0;
	cin >> n;
	char* a = new char[n];
	cin >>a;
	for (int i = 0;i < n;i++)
	{
		if (a[i] == 'A' && a[i + 1] == 'B' && a[i + 2] == 'C')  count++;
	}
	cout << count << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	int sum = 0;
	int ans = 0;
	while(n--) {
		int x;
		std::cin >> x;
		ans += sum * x;
		sum += x;
	}
	std::cout << ans << '\n';
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int Q=in();
	map<string,int> M;
	REP(i,Q){
		int q=in();
		if(q==1){
			string key=in<string>();
			out(M.find(key)!=M.end()?M[key]:0);
		}
		else if(q==2){
			M.erase(in<string>());
		}
		else{
			string key=in<string>();
			M[key] = in();
		}
	}
	return 0;
}


Measured memory_bytes: 25740
#include <bits/stdc++.h>
 using namespace std;
 
int senntou(int x){
  int first=x;
  while(first>9){
    first/=10;
  }
  return first;
}
int matubi(int x){
  return x%10;
}

int main(){
 int N;
 cin>>N;
  int ans=0;
 vector<vector<int>>memo(9,vector<int>(9,0));
 /* for(int i=1;i<=N;i++){
    
    int first=i;
     while(first>9){
   first/=10;
  }
    int end=i%10;*/
     string s=to_string(N);
 
   /* int first=s[0];
    int end=i%10;
    
    if(end != 0){
      memo[first][end]++;
    }
   
    
  }*/
  for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
      int part=0;
        if(N<10){
        if(i==j && N>=i+1)part++;
      }
      else  if(N<100){
        if(i==j)part++;
       
        if(s[0]-'0'>i+1)part++;
        
        else if(s[0]-'0'==i+1 &&s[1]-'0'>=j+1){
          part++;
         
        }
        
      }
        else if(N<1000){
        if(i==j)part++;
        part++;
        if(s[0]-'0'>i+1)part+=10;
        else if(s[0]-'0'==i+1){
          part+=s[1]-'0';
          if(s[2]-'0'>=j+1) part++;
        }
      }
      else if(N<10000){
        if(i==j)part++;
        part++;
        part+=10;
        if(s[0]-'0'>i+1)part+=100;
        else if(s[0]-'0'==i+1){
          part+=10*(s[1]-'0')+(s[2]-'0');
          if(s[3]-'0'>=j+1)part++;
        }
      }
      else if(N<100000){
        if(i==j)part++;
        part++;
        part+=10;
        part+=100;
        if(s[0]-'0'>i+1)part+=1000;
        else if(s[0]-'0'==i+1){
          part+=100*(s[1]-'0')+10*(s[2]-'0')+(s[3]-'0');
          if(s[4]-'0'>=j+1)part++;
        }
      }
      else if(N<1000000){
        if(i==j)part++;
        part++;
        part+=10;
        part+=100;
        part+=1000;
        if(s[0]-'0'>i+1)part+=10000;
        else if(s[0]-'0'==i+1){
          part+=1000*(s[1]-'0')+100*(s[2]-'0')+10*(s[3]-'0')+(s[4]-'0');
          if(s[5]-'0'>=j+1)part++;
        }
      }
      memo[i][j]=part;
    }
  }
        
  for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
      ans+= memo[i][j]*memo[j][i];
    }
  }
  cout<<ans<<endl;
}
 
  
 

Measured memory_bytes: 256
fn main() {
    #[allow(unused_imports)]
    use std::io::{Read, Write, BufWriter};
    let mut a = Vec::new();
    std::io::stdin().read_to_end(&mut a).unwrap();
    let a = String::from_utf8(a).unwrap();
    let mut a = a.split_whitespace();
    #[allow(unused_mut,unused_variables)]
    let mut b = BufWriter::new(std::io::stdout());
    macro_rules! yomu { () => (a.next().unwrap().parse().unwrap()) }
    #[allow(unused_macros)]
    macro_rules! kaku { ($($arg:tt)*) => (writeln!(b, $($arg)*).unwrap()) }
    #[allow(unused_imports)]
    use std::cmp::{min, max};

    let l: i64 = yomu!();
    let r: i64 = yomu!();
    let r = min(r, l + 2019);
    let mut ans = 10_i64.pow(18);
    for i in l..r+1 {
        for j in i+1..r+1 {
            ans = min(ans, i * j % 2019);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
use std::io::Read;

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

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();
    let n: isize = iterator.next().unwrap().parse().unwrap();

    let x: isize =
        if n < b {
            n
        } else if n % b == 0 {
            n - 1
        } else {
            n - n % b - 1
        };

    let ans = (a * x) / b - a * (x / b);

    return ans.to_string();
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
string s,t;
vector<string> str;
int main()
{
	cin>>s>>t;
	if(s.size()<t.size())
	{
		puts("UNRESTORABLE");
		return 0;
	}
	int n=t.size();
	for(int i=0;i<=s.size()-n;i++)
	{
		string z=s.substr(i,n);
		bool flag=true;
		for(int j=0;j<n;j++)
			if(z[j]!=t[j]&&z[j]!='?')
			{
				flag=false;
				break;
			}
		if(flag)
		{
			string o=s;
			for(int j=0;j<n;j++)
				o[i+j]=t[j];
			for(int j=0;j<o.size();j++)
				if(o[j]=='?')
					o[j]='a';
			str.push_back(o);
		}
	}
	if(str.size()==0)
		puts("UNRESTORABLE");
	else
	{
		sort(str.begin(),str.end());
		cout<<str[0]<<endl;
	}
	return 0;
}

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

char s[233333];
int sum[30];
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    long long res=(long long )len * (len+1)/2 + 1 - len;
    memset(sum,0,sizeof sum);
    for (int i=1;i<=len;i++)
        {
            res-= (long long )sum[s[i]-'a'];
            //cout<<sum[s[i]-'a']<<endl;
            sum[s[i]-'a'] ++;
        }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 384
def main():
    n = int(input())
    l = list(map(int,input().split()))
    s = 0
    lmax = max(l)

    l.remove(lmax)

    for i in l:
        s += i
    if lmax < s :
        print("Yes")
    elif lmax >= s :
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define foreach(itr, c) for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++)
#define fill(a, b) memset(a, b, sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<char> vs;
typedef vector<pi> vpi;

using namespace std;

int triangle(int N, vi L)
{
    int count = 0;

    if (N < 3)
    {
        return 0;
    }

    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                if ((L[i] != L[j] && L[i] != L[k]) && L[j] != L[k])
                {
                    if (L[i] + L[j] > L[k])
                    {
                        count++;
                    }
                }
            }
        }
    }
    return count;
}

int main()
{
    int N;

    cin >> N;

    vi L(N);

    rep(i, N)
    {
        cin >> L[i];
    }

    sort(all(L));

    cout << triangle(N, L);
}

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

const int MOD = 1e9 + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    string s;
    cin >> s;
    ll num = 0, ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            int len = s.size() - i - 1;
            ans += modpow(2, num, MOD) * modpow(3, len, MOD);
            num++;
            ans %= MOD;
        }
    }
    ans += modpow(2, num, MOD);
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.TreeSet;

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

    static class BShiritori {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            TreeSet<String> t = new TreeSet<>();
            String s = in.next();

            for (int i = 1; i < n; i++) {
                t.add(s);
                char c = s.charAt((s.length() - 1));
                String nextword = in.next();
                if (t.contains(nextword) || (c != nextword.charAt(0))) {
                    out.println("No");
                    return;
                }
                s = nextword;
            }
            out.println("Yes");
        }

    }
}



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

using namespace std;

const auto NMAX = 100000 + 5;
int h[NMAX];
int dp[NMAX];

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

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
class Node
  attr_accessor :state, :depth
  attr_reader :parent

  def initialize(state, parent)
    @state = state
    @parent = parent
    @depth = parent.nil? ? 0 : parent.depth + 1
  end

  def goal?(limit, max)
    nums.size == limit && sum == max
  end

  def bad_end?(limit, max)
    nums.length > limit || sum > max
  end

  def nums
    parent.nil? ? [state] : parent.nums << state
  end

  def sum
    nums.inject(:+)
  end
end

STDIN.read.split("\n").each do |line|
  limit, max = line.split.map(&:to_i)

  next if limit == 0 && max == 0

  goals = []
  10.times do |i|
    init_node = Node.new(i, nil)
    queue = [init_node]
    black_list = [init_node.nums.sort]

    loop do
      break if queue.empty?

      elem = queue.shift

      goals << elem if elem.goal?(limit, max)

      next if elem.bad_end?(limit, max)

      10.times do |j|
        next if elem.nums.include?(j)
        new_node = Node.new(j, elem)
        new_nums = new_node.nums.sort
        next if black_list.include?(new_nums)
        black_list << new_nums
        queue << new_node
      end
    end
  end

  puts goals.map { |e| e.nums.sort }.uniq.size
end

Measured memory_bytes: 10848
n=int(input())
an=list(map(int,input().split()))
answer_sum=sum(an)
max_syo=an[0]
for i in an:
    if i<max_syo:
        max_syo=i
max_dai=an[0]
for l in an:
    if l>max_dai:
        max_dai=l
print(max_syo,max_dai,answer_sum)


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

using std::cerr;
using std::endl;

#define int long long

const int N = 2e5 + 233;

int n, A[N], B[N], C[N], vis[N];
long long sum, tmp1, tmp2, ans;
std::priority_queue<std::pair<int, int>> que;

signed main() {
  std::ios::sync_with_stdio(0);
  std::cin >> n;
  for (int i = 1; i <= n; ++i) {
    std::cin >> A[i] >> A[n + i];
    tmp1 += A[i], tmp2 += A[n + i];
  }
  for (int i = 1; i <= n * 2; ++i) {
    que.push({ A[i], i }), vis[i] = 1;
    if (que.size() > n)
      vis[que.top().second] = 0, que.pop();
  }
  for (int i = 1; i <= n; ++i) {
    B[i] = que.top().first;
    C[i] = que.top().second;
    if (C[i] > n) C[i] -= n;
    sum += B[i], que.pop();
  }
  ans = std::min(tmp1, tmp2);
  for (int i = 1; i <= n; ++i) {
    long long tmp = sum;
    if (!vis[i] && !vis[i + n])
      tmp += A[i] + A[n + i] - B[1] - B[2];
    else if (!vis[i] && vis[i + n])
      tmp += A[i] - (C[1] == i ? B[2] : B[1]);
    else if (!vis[n + i] && vis[i])
      tmp += A[n + i] - (C[1] == i ? B[2] : B[1]);
    ans = std::min(ans, tmp);
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 8176
import java.util.ArrayList;

class Event
{
	int e;
	int a;
}

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

		while( true )
		{
			int X, Y, Z;
			
			X = sc.nextInt();
			Y = sc.nextInt();
			Z = sc.nextInt();
			
			if ( X == Y && Y == Z && Z == 0 )
			{
				break;
			}
			
			Event ev[] = new Event[1+Y];
			double dp[][] = new double[1+Y][100*Y+1];
			int v[] = new int[X];
			
			for(int i = 0; i < X; ++i)
			{
				v[i] = sc.nextInt();
			}
			
			for( int i = 0; i < Z; ++i )
			{
				int n, e, a;
				n = sc.nextInt();
				e = sc.nextInt();
				a = sc.nextInt();
				ev[n] = new Event();
				ev[n].e = e;
				ev[n].a = a;
			}
			
			for(int i = 0; i <= Y; ++i)
			{
				for(int j = 0; j <= 100*Y; ++j)
				{
					dp[i][j] = Double.NEGATIVE_INFINITY;
				}
			}
			
			dp[0][0] = 1;
			for(int i = 0; i < Y; ++i)
			{
				for(int j = 0; j < 100*Y+1; ++j)
				{
					if( dp[i][j] == Double.NEGATIVE_INFINITY )
					{
						continue;
					}
				
					for(int k = 0; k < X; ++k) {
						int next = i+v[k];
						int nextProfit;
						
						int gain = 0;
						
						if( next >= Y ) {
							next = Y;
						}

						if( ev[next] != null ) {
							if( ev[next].e == 1 ) {
								next += ev[next].a;
							} else if( ev[next].e == 2 ) {
								gain = ev[next].a;
							} else if( ev[next].e == 3 ) {
								gain = -ev[next].a;
							}
						}

						if( next >= Y ) {
							next = Y;
						}
						
						nextProfit = j + gain;
						if( nextProfit < 0 ) nextProfit = 0;
						
						// System.out.println( next + " " + nextProfit + " " + i + " " + j );
						if( dp[next][nextProfit] == Double.NEGATIVE_INFINITY ) {
							dp[next][nextProfit] = 0;
						}
						dp[next][nextProfit] += dp[i][j] / X;
					}

					// double nextE = Math.max(0d, (dp[i]+gain)/X);

					// if( dp[next] == Double.NEGATIVE_INFINITY ) {
					// 	dp[next] = 0;
					//}
					// dp[next] += nextE / X;
					
					//dp[ next ] += nextE;
					// dp[next] += (dp[i] + gain) / X;
					// if( dp[next] < 0 ) dp[next] = 0;
				}
			}
			// System.out.println("----");
			for(int i = 0; i < dp.length; ++i){
				for(int j = 0; j < dp[i].length; ++j){
					if( dp[i][j] == Double.NEGATIVE_INFINITY ) {
						continue;
					}
					// System.out.println( i + " " + j + " "  + dp[i][j] );
				}
			}
			
			double res = 0;
			for(int j = 0; j < 100*Y+1; ++j){
				if( dp[Y][j] != Double.NEGATIVE_INFINITY ) {
					res += dp[Y][j] * j;
				}
			}
			
			System.out.println( (int)Math.floor(0.00000000001+res) );
		}
	}
}

Measured memory_bytes: 63932
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String s;
    char[] c, r;
    int i;

    for(;sc.hasNext();){
      s = sc.next();
      if(s.length() % 2 == 1)out.println("NA");
      else{
        c = new char[s.length()]; r = new char[s.length() / 2];
        for(i = 0;i < s.length();i++)c[i] = s.charAt(i);
        for(i = 0;i < s.length();i+=2){
          if(c[i] > '6' || c[i] < '1' || c[i + 1] > '5' || c[i + 1] < '1')break;
          r[i / 2] = (char)('a' + (c[i] - '1') * 5 + (c[i + 1] - '1'));
          if(r[i / 2] == (char)('a' + 26))r[i / 2] = '.';
          else if(r[i / 2] == (char)('a' + 27))r[i / 2] = '?';
          else if(r[i / 2] == (char)('a' + 28))r[i / 2] = '!';
          else if(r[i / 2] == (char)('a' + 29))r[i / 2] = ' ';
        }
        if(i < s.length())out.println("NA");
        else{
          for(i = 0;i < s.length() / 2;i++)out.print(r[i]);
          out.println();
        }
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 26296
var n,m,i,j:Longint;a:array[1..50]of Longint;
begin
	read(n,m);
	for i:=1 to m*2 do begin
		read(j);
		inc(a[j]);
	end;
	for i:=1 to n do begin
		writeln(a[i]);
	end;
end.


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 long long int a, b, c, temp, min, A, B;
 while(cin >> a >> b){
  if(a == 0){
    cout << "0" << " " << "0" << endl;
  }
  else if(b == 0){
    cout << "0" << " " << "0" << endl;
  }
  else if(a < b){
    temp = a;
    a = b;
    b = temp;

    A = a;
    B = b;

    while(1){
      c = A % B;
      if(c == 0) break;
      else if(c != 0){
        A = B;
        B = c;
      }
    }
    min = (a / B) * b;
    cout << B << " " << min << endl;
  }

    
  else if (a > b){
    A = a;
    B = b;

    while(1){
      c = A % B;
      if(c == 0) break;
      else if(c != 0){
        A = B;
        B = c;
      }
    }
    min = (a / B) * b;
    cout << B << " " << min << endl;
  }
  else if(a == b){
    cout << a << " " << a << endl;
  }

 }
 return 0; 
}

Measured memory_bytes: 1160
INT_MAX = 999999999999999999999999

N,_=gets.chomp.split(' ').map{|n| n.to_i}
s=gets.chomp
arr=Array.new(N)
[["S","S"],
["S","W"],
["W","S"],
["W","W"]
].each{|a,b|
	arr[0]=a
	arr[1]=b
	2.upto(N-1){|i|
		case ["So","Wx"].include?(arr[i-1]+s[i-1])
		when true
			arr[i] = arr[i-2]
		else
			arr[i] = (arr[i-2] == "W" ? "S" : "W")
		end
	}
	condlst = ["So","Wx"].include?(arr[N-1]+s[N-1])
	condfst = ["So","Wx"].include?(arr[0]+s[0])
	if(condlst && arr[N-2]==arr[0] ||
		!condlst && arr[N-2]!=arr[0])
		if(condfst && arr[N-1]==arr[1] ||
			!condfst && arr[N-1]!=arr[1])
			puts arr.join("")
			exit(0)
		end
	end
}
puts -1
	

Measured memory_bytes: 6780
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;
string str;
const int INF = 1 << 30;

double min(double a, double b) {
    return a > b ? b : a;
}
void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}
double dist(int a, int b) {
    return b + sqrt((a + b) * (a + b) - (a - b) * (a - b)) - a;
}

int main() {

    while(getline(cin, str)) {
        //begin input
        stringstream ss(str);
        int X;
        ss >> X;
        int radius[13];

        int i = 0;
        while(ss >> radius[i]) {
            i++;
        }
        int N = i;
        //end input
        
        vector<vector<double> > dp(1 << N, vector<double>(N, INF));
        for(int j = 0; j < N; j++) {
            dp[1 << j][j] = 2 * radius[j];
        }

        for(int i = 1; i < (1 << N); i++) {
            for(int j = 0; j < N; j++) {
                if((i >> j) & 1){
                    for(int k = 0; k < N; k++) {
                        if (!((i >> k) & 1)) {
                            //cout << i << " to " << (i | (1 << k)) << " : " << j << ", " << k << ", " << radius[j] << ", " << radius[k] << endl;
                            dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + dist(radius[j], radius[k]));
                        }
                    }
                }
            }
        }

        double mini = INF;
        for(int j = 0; j < N; j++) {
            mini = min(mini, dp[(1 << N) - 1][j]);
        }
        if (mini <= X) {
            //cout << mini << endl;
            cout << "OK" << endl;
        } else {
            //cout << mini << endl;
            cout << "NA" << endl;
        }

    }

    return 0;
}

Measured memory_bytes: 1612
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}

}

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

int main(){
cin>>a;
char t='a';
int ans=a.size();
while(t<='z'){
	int cont,temp=0;
	cont=0;
	for(int i=0;i<a.size();i++){
		if(a[i]!=t)
		cont++;
		else{
		temp=max(temp,cont);
		cont=0;
		}
	}
	temp=max(temp,cont);
	ans=min(ans,temp);
	//cout<<ans<<t<<endl;
	t++;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[1000];
int n;
int k;
LL sum;
int main(){
    cin >> n >> k;
    sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    int Max = 1;
    for(int i=sqrt(sum);i>0;i--){
        if(sum%i == 0){
            vector <int> surplus; 
            int s_sum =0 ;
            for(int j=0;j<n;j++){
                surplus.push_back(a[j]%i); 
                s_sum += a[j]%i;
            }
            
            int ans = 0;
            sort(surplus.begin(),surplus.end());
            for(int j=n-1;j>=0;j--){
                if(s_sum == 0){
                    break;
                } 
                s_sum -= i;
                ans +=(i-surplus[j]);
                
            }
            if(ans <= k){
                Max = max(Max,i);
               // cout << "i=" << i <<endl;
            }
            
            int ii = sum/i;
            //cout << ii << endl;
            vector <int> surplus2; 
            int s_sum2 =0 ;
            for(int j=0;j<n;j++){
                surplus2.push_back(a[j]%ii); 
                s_sum2 += a[j]%ii;
            }
        
            int ans2 = 0;
            sort(surplus2.begin(),surplus2.end());
            for(int j=n-1;j>=0;j--){
                if(s_sum2 == 0){
                    break;
                }
                s_sum2 -= ii;
                ans2 +=(ii-surplus2[j]);
                //cout << "ii=" << ii << "s_sum2 = " << s_sum2 << "ans2 = " << ans2 << endl;
                 
            }
            if(ans2 <= k){
                Max = max(Max,ii);
               // cout << "ii=" << ii <<endl;
            }

        }
    }
    cout << Max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x,k,d;
	cin >> x>>k>>d;
	// x = abs(x);
	if(x<0)x=-1*x;
	// cout <<x<<endl;
	// cout <<x<<" "<<x<<" "<<x<<endl;
	long long int a = x/d;
	// cout<<a<<endl;
	if(a<k && -1*a<k){
	x = x - a*d;
	k = k-a;
	}
	else{
		if(x>0)cout << x-k*d<< endl; 
		else cout << x+k*d <<endl;
		return 0;
	}
	// cout << x <<endl;
	if(k%2==0)cout << x<<endl;
	else cout << abs(x-d)<<endl;
	return 0;
}
// 1000000000000000
// 1000000000000000
// 1000000000000000


Measured memory_bytes: 3628
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  t, x = map(int, readline().split())
  print(t/x)
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5248
#include <iostream>
int main(void)
{
    int array[2];
    while(std::cin >> array[0] >> array[1]){
        array[0] += array[1];
        array[1] = 0;
        do{
            array[0] /= 10;
            ++array[1];
        }while(array[0]);
        std::cout << array[1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <vector>
using namespace std;
int N_MAX = 100;
int main()
{
  int h,w;
  cin >> h >> w;
  string s[N_MAX];
  bool isb[N_MAX];
  string b="#";
  for(int i=0;i<h;){
    cin >> s[i];
    if(s[i].find(b)==string::npos)
      h--;
    else
      i++;
  }
  fill(isb,isb+w,0);
  for(int j=0;j<w;j++)
    for(int i=0;i<h;i++)
      if(b.compare(s[i].substr(j,1))==0){
        isb[j]=1;
        break;
      }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      if(isb[j])
        cout << s[i].substr(j,1);
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            int S = Integer.parseInt(br.readLine());
            System.out.println(S / 3600 + ":" + S % 3600 / 60 + ":" + S % 60);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 16864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;


void solve(){
  int n;
  cin>>n;
  cout<<(n+1)/2;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
/**
 *      ABC 61 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-16 16:43:04
**/

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

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

    int N; ll K; cin >> N >> K;
    ll a[N] = {}; ll b[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
    }
    ll d[100005] = {};

    for (int i = 0; i < N; ++i) {
        d[a[i]] += b[i]; 
    }
    ll count = 0;

    for (int i = 0; i < 100005; ++i) {
        count += d[i];
        if (count >= K){
            cout << i << endl; return 0;
        }
    }
}

Measured memory_bytes: 2560
import itertools

n=int(input())

a="".join(input().split())
b="".join(input().split())
#print(a,b)

nums=[str(i) for i in range(1,n+1)]
#print(nums)
ary=[]
cnt=1
a1=0
b1=0
for balls in itertools.permutations(nums, n):
    #print(int("".join(list(balls))))
    if str(a) == str(int("".join(list(balls)))):
        a1=cnt
        #print("a1")
    if str(b) == str(int("".join(list(balls)))):
        b1=cnt
        #print("b1")
    cnt+=1

print(abs(a1-b1))



Measured memory_bytes: 42972
N = int(input())
memo = {}
for _ in range(N):
    si = sorted(list(input()))
    si = "".join(si)
    try:
        memo[si] += 1
    except:
        memo[si] = 1

# 組み合わせの数
import math
def combinations_count(n, r):
    if n < r:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


ans = 0
for key in memo.keys():
    ans += combinations_count(memo[key],2)

print(ans)


Measured memory_bytes: 17808
Sdash = str(input())
T = str(input())

reslis = []

if len(Sdash) >= len(T):
    for i in range(len(Sdash) - len(T) + 1):
        res = Sdash
        temp = Sdash[i:i+len(T)]
        for k in range(len(T)):
            if T[k] == temp[k] or temp[k] == "?":
                res = list(res)
                res[k+i] = T[k]
                res = "".join(res)
            else:
                break
        else:
            reslis.append(res) 

if reslis:
    reslis = [st.replace("?", "a") for st in reslis]
    print(min(reslis))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int cnt = 0;

        for(int i=a; i<=b; i++){
            String sa = String.valueOf(i);
            if(sa.substring(0, 1).equals(sa.substring(4, 5)) 
                && sa.substring(1, 2).equals(sa.substring(3, 4))){
                    cnt++;
                }
        }

        System.out.println(cnt);

        scan.close();
    
    }

}

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

const int U = 0;
const int L = 1;
const int D = 2;
const int R = 3;

int H, W, N ;
int sr, sc  ;
string _S, _T ;
vector<int> S, T;

bool isin(int r, int c){
  return 0 <= r && r < H && 0 <= c && c < W;
}

bool solve(){
  // Left
  {
    int r = sr, c = sc;
    for(int i = 0; i < N; i++){
      if(S[i] == L){
        c--;
      }
      if(isin(r, c) == false) return true;
      if(T[i] == R){
        int nr = r, nc = c + 1;
        if(isin(nr, nc)){
          r = nr;
          c = nc;
        }
      }
    }
  }

  // Right
  {
    int r = sr, c = sc;
    for(int i = 0; i < N; i++){
      if(S[i] == R){
        c++;
      }
      if(isin(r, c) == false) return true;
      if(T[i] == L){
        int nr = r, nc = c - 1;
        if(isin(nr, nc)){
          r = nr;
          c = nc;
        }
      }
    }
  }


  // Up
  {
    int r = sr, c = sc;
    for(int i = 0; i < N; i++){
      if(S[i] == U){
        r--;
      }
      if(isin(r, c) == false) return true;
      if(T[i] == D){
        int nr = r + 1, nc = c;
        if(isin(nr, nc)){
          r = nr;
          c = nc;
        }
      }
    }
  }

  // Down
  {
    int r = sr, c = sc;
    for(int i = 0; i < N; i++){
      if(S[i] == D){
        r++;
      }
      if(isin(r, c) == false) return true;
      if(T[i] == U){
        int nr = r - 1, nc = c;
        if(isin(nr, nc)){
          r = nr;
          c = nc;
        }
      }
    }
  }
  return false;
}

int main(void){
  cin >> H >> W >> N ; 
  cin >> sr >> sc    ; 
  cin >> _S >> _T      ; 
  sr--; sc--;
  S.resize(N); T.resize(N);

  for(int i = 0; i < N; i++){
    if( _S[i] == 'U') S[i] = U;
    else if(_S[i] == 'L') S[i] = L;
    else if(_S[i] == 'D') S[i] = D;
    else if(_S[i] == 'R') S[i] = R;

    if( _T[i] == 'U') T[i] = U;
    else if(_T[i] == 'L') T[i] = L;
    else if(_T[i] == 'D') T[i] = D;
    else if(_T[i] == 'R') T[i] = R;
  }


  if(solve() == true){
    cout << "NO" << endl;
    return 0;
  }

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


Measured memory_bytes: 2312
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
typedef pair<LL,LL> P;
vector<P>v;
LL x[200001];
LL y[200001];

int main(){
	cin>>N;
	LL ma=0;
	LL mi=10e10;
	REP(i,N){
	    cin>>x[i]>>y[i];
	    if(x[i]>y[i]){
	       LL temp=x[i];
	       x[i]=y[i];
	       y[i]=temp;
	    }
	    mi=min(mi,x[i]);
	    ma=max(ma,y[i]);
	    v.push_back(P(x[i],y[i]));
	}
	sort(v.begin(),v.end());
	if(N==1){
	   cout<<0<<endl;
	   return 0;
	}
	//R=min,B=max
	LL ans;
	{
	   LL a=mi;
	   LL b=0;
	   LL c=10e10;
	   LL d=ma;
           REP(i,N){
               b=max(x[i],b);
               c=min(y[i],c);
           }
           ans=(b-a)*(d-c);
	}
	//R=min R=max
	{ LL red=ma-mi;
	  LL mma=v[v.size()-1].first;
	  LL mmi=v[0].first;
	  LL mmmi=10e10;
	  ans=min(ans,red*(mma-mmi));
	  REP(i,v.size()){
	      if(i==0)continue;
	      mmmi=min(v[i-1].second,mmmi);
	      mmi=min(mmmi,v[i].first);
	      mma=max(v[i-1].second,mma);
	     // cout<<mma<<" "<<mmi<<endl;
	      ans=min(ans,red*(mma-mmi));
	  }
	}
	cout<<ans<<endl;
	return(0);
}

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

int main() {
    int x;
    cin >> x;
    for(int a=0; a<=1000; a++) {
        for(int b=-1000; b<=1000; b++) {
            if(a*a*a*a*a - b*b*b*b*b == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	int n;
	ll ans=1,MOD=1000000007;
	string s,t;
	bool flag;	
	cin>>n>>s>>t;
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			if(s[i]==t[i])
			{
				ans=3;
				flag=true;
			}
			else
			{
				ans=6;
				flag=false;
				i++;
			}
		}
		else
		{
			if(s[i]==t[i])
			{
				if(flag)ans*=2;
				else ans*=1;
				ans%=MOD;
				flag=true;
			}
			else
			{
				if(flag)ans*=2;
				else ans*=3;
				ans%=MOD;
				flag=false;
				i++;
			}
		}
	}
	cout<<ans%MOD<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n + 1, 0);
  for (int i = 0; i < n;i++){
    cin >> a[i];
  }
  ll ans = 0;
  for (ll i = 0; i < n;i++){
    ans += a[i] / 2;
    a[i] %= 2;
    if(a[i]>0&&a[i+1]>0){
      ans++;
      a[i + 1]--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4020
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	/*input*/
	int a, b;	cin >> a >> b;
	/*calculation*/
	int ans;
	int tmp = (a+b)/2;
	double tmpd = (double)(a + b)/2;
	(tmpd - tmp > 0.0)?ans = tmp + 1:ans = tmp;
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+10;

void solve(){
    int n=0,m=0;
    string s;
    cin>>s;
    for (int i = 0; i < 3; ++i) {
        if (s[i]=='R') n++;
        else n=0;
        if (m<n)m=n;
    }
    cout<<m<<endl;
}
int main(){
    int _=1;
//    cin>>_;
    while(_--){
        solve();
    }
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int i, j;
  vector<int> C = {};
  vector<vector<int>> A = {};
  int sumArray[M];

  rep(i, N) {
    int Ctmp;
    cin >> Ctmp;
    C.push_back(Ctmp);

    vector<int> Aline = {};
    rep(j, M) {
      int Atmp;
      cin >> Atmp;
      Aline.push_back(Atmp);
    }

    A.push_back(Aline);
  }

  int ans = 12000000;

  int k;
  rep(i, (1 << N)) {
    int result = 0;
    rep(j, M) { sumArray[j] = 0; }
    rep(j, N) {
      if(i & (1 << j)) {
        rep(k, M) { sumArray[k] += A[j][k]; }
        result += C[j];
      }
    }

    rep(j, M) {
      if(sumArray[j] < X) break;
    }

    if(j == M) {
      ans = min(ans, result);
    }
  }

  if(ans == 12000000) ans = -1;
  cout << ans;

  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


int main(void)
{
    IOS
    const int C = 26;
    string S; cin >> S;
    vector<int> cnt(C), mx(C);

    REP(i,S.size()) {
        int c = S[i] - 'a';
        REP(j,C) {
            if (j == c) {
                mx[j] = max(mx[j],cnt[j]);
                cnt[j] = 0;
            } else {
                cnt[j]++;
            }
        }
    }
    REP(i,C) {
        mx[i] = max(mx[i],cnt[i]);
    }

    OUT(*min_element(ALL(mx)));


    return 0;
}

Measured memory_bytes: 256
L,N = [int(i) for i in input().split()]
snake = input()

d = 0
for i in range(L-1):
    if snake[i] == "o" and snake[i+1] == "o":
        d += 1

ans = L    
for i in range(N):
    ans += d * 3
    d *= 2

print(ans)


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> X(N);
    REP(i, N) cin >> X[i];
    ll ans = LONG_MAX;
    const ll minNum = 1;
    const ll maxNum = 100;
    for (ll i = minNum; i <= maxNum; ++i)
    {
        ll sumDist = 0;
        REP(j, N)
        {
            sumDist += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, sumDist);
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
VMAX = 10000
n = int(input())
A = list(map(int, input().split()))
s = min(A)
def solve():
    ans = 0
    V = [False] * n
    B = sorted(A)
    T = [0] * (VMAX + 1)
    for i in range(n):
        T[B[i]] = i
    for i in range(n):
        if V[i]:
            continue
        cur = i
        S = 0
        m = VMAX
        an = 0
        while True:
            V[cur] = True
            an += 1
            v = A[cur]
            m = min(m, v)
            S += v
            cur = T[v]
            if V[cur]:
                break
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s)
    return ans
print(solve())


Measured memory_bytes: 5764
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s;

    cin >> s;

    int ans = 0;
    forn(i, s.size() / 2) {
        ans += s[i] != s[s.size() - 1 - i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = [0] + LIST()
b = [0]*(n+1)

for i in range(n, 0, -1):
    j = i + i
    tmp = 0
    while j <= n:
        tmp += b[j]
        j += i
    if tmp % 2 != a[i]:
        b[i] = 1

print(sum(b))
for i in range(1, n+1):
    if b[i] == 1:
        print(i)

Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 2e5 + 10;
ll S[MAXN],T[MAXN];
ll X[MAXN];
ll D[MAXN];
ll N,Q;
map<ll,ll> mapp;

ll seg[16*MAXN];
ll lazy[16*MAXN];

void propogate(ll node,ll s,ll e){
    seg[node] = min(lazy[node],seg[node]);

    if(s!=e){
        lazy[2*node] = min(lazy[node],lazy[2*node]);
        lazy[2*node+1] = min(lazy[node],lazy[2*node+1]);
    }

    lazy[node] = 1e10;
}

void update(ll node,ll s,ll e,ll qs,ll qe,ll x){
    propogate(node,s,e);

    if(s > e || qe < s || qs > e) return;

    if(qs <= s && e <= qe){
        lazy[node] = x;
        propogate(node,s,e);
        return;
    }

    ll mid = (s+e)>>1;
    update(2*node,s,mid,qs,qe,x);
    update(2*node+1,mid+1,e,qs,qe,x);

    seg[node] = min(seg[2*node],seg[node]);
    seg[node] = min(seg[2*node+1],seg[node]); 
}

ll query(ll node,ll s,ll e,ll pos){
    propogate(node,s,e);

    if(s == e){
        return seg[node];
    }

    ll mid = (s+e)>>1;

    if(pos <= mid) query(2*node,s,mid,pos);
    else query(2*node+1,mid+1,e,pos);
}

void solve(){

    FOR(i,0,16*MAXN-1) lazy[i] = 1e10,seg[i] = 1e10;
    cin>>N>>Q;

    FOR(i,1,N){
        cin>>S[i]>>T[i]>>X[i];
        mapp[S[i]-X[i]];
        mapp[T[i]-X[i]-1];
    }

    FOR(i,1,Q){
        cin>>D[i];
        mapp[D[i]];
    }

    ll x = 1;

    for(auto z:mapp){
        mapp[z.first] = x++;
    }

    FOR(i,1,N){
        update(1,1,x,mapp[S[i]-X[i]],mapp[T[i]-X[i]-1],X[i]);
    }

    FOR(i,1,Q){
        ll val = query(1,1,x,mapp[D[i]]);
        if(val >= 1e10) cout<<-1<<endl;
        else cout<<val<<endl;
    }
}   

signed main(){

   FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 94976
void main()
{
    string s = readln.chomp;
    int w = readln.chomp.to!int;

    s.stride(w).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  int ans = min(n * a, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main()
{
    ll n, k, d, m, res ;
    cin >> n >> k >> d ;
    n=abs(n);
    m=n/d;
    if(m>k)
        cout << abs(n-(k*d));
    else
    {
        res = n-(m*d) ;
        k=k-m;
        if(k%2!=0)
            res=abs(res-d);
        cout << res ;
    }
    return 0;
}

Measured memory_bytes: 3680
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int[] data = new int[n];

      for (int i = 0;i<n ;i++ ) {
        data[i] = sc.nextInt();
      }
      Arrays.sort(data);

      System.out.println(Math.abs(data[0]-data[n-1]));

      }
    }


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
     int n,num;
     int s[15]={};
     cin >> n;
     for (int i=1; i<=n;i++){
          cin >> num;
          if (1<=num && num<=399) ++s[1];
             else if (400<=num && num<=799) ++s[2];
             else if (800<=num && num<=1199) ++s[3];
             else if (1200<=num && num<=1599) ++s[4];
             else if (1600<=num && num<=1999) ++s[5];
             else if (2000<=num && num<=2399) ++s[6];
             else if (2400<=num && num<=2799) ++ s[7];
             else if (2800<=num  && num <=3199) ++s[8];
             else ++s[9];
     } 
     int ans=0;
     for (int i=1;i<=8;i++)
          if (s[i]>0) ++ans;
    if (ans==0) cout << 1;
       else  cout << ans;
    ans=ans+s[9];
    cout << " " << ans;
    return 0;
}

Measured memory_bytes: 256