akhauriyash/Code-Regression huggingface dataset:
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define rep(n) for(Int x = 0; x < n; x++)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (x[x.size()-1])

using namespace std;

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

bool compX (const Point &p1, const Point &p2) {
  return p1.x < p2.x;
}

bool compY (const Point &p1, const Point &p2) {
  return p1.y < p2.y;
}

#define MAX_N 100
Int N;
vector<Point> red, blue;
vector<bool> rused(MAX_N, false);

void input() {
  cin >> N;
  Point p_;
  loop(n,0,N) {
    cin >> p_;
    red.push_back(p_);
  }
  loop(n,0,N) {
    cin >> p_;
    blue.push_back(p_);
  }
}

bool can(Point r, Point b) {
  return r.x < b.x && r.y < b.y;
}

void solve() {
  sort(span_all(red), compY);
  sort(span_all(blue), compX);

  Int count = 0;
  loop(b_i, 0, blue.size()) {
    Int max_ = -1;
    loop(r_i, 0, red.size()) {
      if (!rused.at(r_i) && red.at(r_i) < blue.at(b_i)) max_ = r_i;
    }

    if (max_ > -1) {
      rused.at(max_) = true;
      count++;
    }
  }
  cout << count << endl;
}

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


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

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::iter::once;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let (n, d) = read!(f64, f64);

    let ans = (n / (2.0 * d + 1.0)).ceil();

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iiii tuple<int, int, int, int>
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define dd pair<double, double>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int M = 1e3;
double e = 1e-8;

double f(vector<ii>& a, double x, double y) {
    double res = 0;
    for (auto& i : a)
        res = max(res, (i.fi - x) * (i.fi - x) + (i.se - y) * (i.se - y));
    return sqrt(res);
}

double dx(vector<ii>& a, double x, double y) {
    return (f(a, x + e, y) - f(a, x - e, y)) / e;
}

double dy(vector<ii>& a, double x, double y) {
    return (f(a, x, y + e) - f(a, x, y - e)) / e;
}

bool test(vector<ii>& a, double L, double x, double y) {
    return f(a, x, y) > f(a, x - dx(a, x, y) * L, y - dy(a, x, y) * L);
}

double cal_L(vector<ii>& a, double x, double y, double tdx, double tdy) {
    double lef = 0, rig = 1000;
    int cnt = 100;
    while (cnt--) {
        double l1 = (lef + lef + rig) / 3;
        double l2 = (lef + rig + rig) / 3;
        if (f(a, x - tdx * l1, y - tdy * l1) > f(a, x - tdx * l2, y - tdy * l2))
            lef = l1;
        else
            rig = l2;
    }
    return lef;
}

void solve() {
    int n;
    cin >> n;
    vector<ii> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i].fi >> a[i].se;

    int cnt = 1000;
    double L = 1000, x = 0, y = 0;
    while (cnt--) {
        double tdx = dx(a, x, y), tdy = dy(a, x, y);

        L = cal_L(a, x, y, tdx, tdy);

        x -= tdx * L;
        y -= tdy * L;
    }
    cout << fixed << setprecision(15) << f(a, x, y) << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(void){
    int A,B,C,X;
    cin >> A >> B >> C >> X;

    static int count,tmp;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                tmp = (500*i)+(100*j)+(50*k);
                if((tmp % X == 0) && (tmp / X == 1)) count++;
            }
        }       
    }

    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n + 1];
		for (int i = 1; i < a.length; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		for (int i = 1; i < a.length; i++) {
			a[i] += a[i - 1];
		}

		Map<Long, Long> map = new HashMap<Long, Long>();
		for (int i = 0; i < a.length; i++) {
			putCntMap(map, a[i]);
		}

		long ans = 0;
		for (Long l : map.keySet()) {
			long x = map.get(l);
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	}

	static void putCntMap(Map<Long, Long> map, Long key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1L);
		}
	}
}


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

long long solve(long long h, long long w) {
    long long result = h * w;
    for (long long i = 1; i < h; i++) {
        long long cut1[3], cut2[3];
        cut1[0] = i * w;
        auto rest = h - i;
        cut1[1] = rest / 2 * w;
        cut1[2] = (rest - (rest / 2)) * w;
        cut2[0] = cut1[0];
        cut2[1] = w / 2 * rest;
        cut2[2] = (w - (w / 2)) * rest;
        auto p1 = minmax_element(cut1, cut1 + 3), p2 = minmax_element(cut2, cut2 + 3);
        result = min({result, *p1.second - *p1.first, *p2.second - *p2.first});
    }
    return result;
}

int main() {
    long long h, w;
    cin >> h >> w;
    long long result = solve(h, w);
    result = min(result, solve(w, h));
    cout << result;
    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	for(int i = 1 ; i <= N ; i += 2){
		--K;
	}
	cout << (K>0?"NO":"YES") << endl;
	return 0;
}


Measured memory_bytes: 256
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  int n; cin >> n;
  vll a(n); f (i, 0, n) cin >> a[i];
  int count = 0, ans = 0;
  f (i, 1, n) {
    if (a[i] <= a[i-1]) {
      count++;
      ans = max(ans, count);
    } else {
      count = 0;
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}
double max(double a, double b) {
	if (a < b) return b;

	return a;
}




vector<ll> A;
int main() {
	ll N;
	cin >> N;
	A.resize(N);
	ll K = 0;
	rep(i, N) {
		cin >> A[i];
		K += A[i];
	}

	if (K % (N * (N + 1) / 2) != 0 || K < (N * (N+1))/2) {
		cout << "NO" << endl;
		return 0;
	}

	K /= (N * (N + 1) / 2);

	ll sum = 0;
	rep(i, N - 1) {
		if ((K - (A[i + 1] - A[i])) >= 0 && (K - (A[i + 1] - A[i])) % N == 0) {
			sum += (K - (A[i + 1] - A[i])) / N;
			continue;
		}

		else {
			cout << "NO" << endl;
			return 0;
		}
			
		
	}

	if (sum <= K) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  if(a[0]==5 && a[1]== 5 && a[2]== 7){
    cout << "YES" << endl;
  }else{
  cout <<"NO" << endl;
}
  return 0;
}


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

int main(){
    string s,t ;
    int slen,tlen;

    cin >> s >> t;

    slen = s.length();
    tlen = t.length();

    if( slen == tlen - 1 ){
        for( int i = 0; i < s.length(); i++ ){
            if( s[i] != t[i] ){
                cout << "No\n";
                return 0;
            }
        }
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";

    return 0;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    ll N;
    std::cin >> N;
    std::vector<ll> A(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    std::vector<ll> accsum(N + 1, 0);
    REP(acc_i, N) {
        accsum[acc_i + 1] = accsum[acc_i] + A[acc_i];
    }

    ll ans = LINF;
    for(int i = 1; i < N; i++) {
        chmin(ans, abs(accsum[i] - (accsum[N] - accsum[i])));
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3456
import java.util.*;

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

    int n = sc.nextInt();
    int answer = Integer.MAX_VALUE;
    int count;
    long A;

    for (int i = 0; i < n; i++) {
      A = sc.nextInt();
      count = 0;

      while (A % 2 == 0) {
        A = A / 2;
        count += 1;
      }

      if (count < answer) {
        answer = count;
      }
    }

    System.out.println(answer);
  }
}


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

double w;

const char *Classify(double w) {
  if (48.00 >= w) return "light fly";
  if (48.00 < w && 51.00 >= w) return "fly";
  if (51.00 < w && 54.00 >= w) return "bantam";
  if (54.00 < w && 57.00 >= w) return "feather";
  if (57.00 < w && 60.00 >= w) return "light";
  if (60.00 < w && 64.00 >= w) return "light welter";
  if (64.00 < w && 69.00  >= w) return "welter";
  if (69.00 < w && 75.00  >= w) return "light middle";
  if ( 75.00 < w && 81.00  >= w) return "middle";
  if (81.00 < w && 91.00  >= w) return "light heavy";
  if (91.00 < w) return "heavy";
}

int main() {
  while (1) {
    if (scanf("%lf", &w) != 1) break;
    puts(Classify(w));
  }
}

Measured memory_bytes: 2540
#include <cstdio>
#include <algorithm>

using namespace std;

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

	scanf("%d %d %d", &a, &b, &c);

	if (b - a == c - b) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string a, b, c; cin >> a >> b >> c;
    cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int h,n;
  cin>>h>>n;
  int x;
  long long sum=0;
  for(int i =0;i<n;++i)
   { cin>>x;
    sum+=x;
    }
  if(sum>=h)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
  
  }

Measured memory_bytes: 384
#include<iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0){
            cout<<" "<<i;
            continue;
        }
        else if(i%10==3){
            cout<<" "<<i;
            continue;
        }
        int j=i;
        while(j>0){
            if(j%10==3){
                cout<<" "<<i;
                break;
            }
            j/=10;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3104
import java.util.*;
import java.util.stream.IntStream;

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

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

        for (int i=0;i<n;i++){
            a[i] = sc.nextInt();

        }

        int currentIndex = 0;
        int goalIndex = 1;
        int tryCount = n;

        while (currentIndex != goalIndex && tryCount > 0){
            int index = a[currentIndex];
            currentIndex = index-1;
            --tryCount;
        }

        if(currentIndex == goalIndex){
            System.out.print(n- tryCount);
            return;
        }

        System.out.print(-1);
    }
}

Measured memory_bytes: 52740
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> v[200005];
int dis[100005];
bool vis[100005];
bool bfs(int x)
{
    queue<int> q;
    q.push(x);
    while(!q.empty())
    {
        x=q.front();
        vis[x]=1;
        q.pop();
        for(int i=0;i<v[x].size();i++)
        {
            if(!vis[v[x][i].first])
            {
                dis[v[x][i].first]=v[x][i].second+dis[x];
                vis[v[x][i].first]=1;
                    q.push(v[x][i].first);

            }
            else {
            if(dis[v[x][i].first]!=v[x][i].second+dis[x])
            return 0;
            }
        }
    }
    return 1;
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++)
{
    int a,b,c;
    cin>>a>>b>>c;
    v[a].push_back({b,c});
            v[b].push_back({a,-c});

}
for(int i=1;i<=n;i++)
{
    if(!vis[i])
    {
        if(!bfs(i))
    {
    cout<<"No";
    return 0;
    }
    }
}
cout<<"Yes";
return 0;
}
 


Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x);
#define rl(x) scanf("%lld",&x);
#define pi(x) printf("%d",x);
#define pl(x) printf("%lld",x);
#define lfd() printf("\n");
#define sp() printf(" ");
int n,k;
int a[200100];
int cnt[200100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	vector<int> v;
	for(int i=1;i<=n;i++)
		if(cnt[i])
			v.push_back(cnt[i]);
	sort(v.begin(),v.end());
	if(v.size()<k){
		cout<<0<<endl;
		return 0;
	}
	int res=0;
	for(int i=0;i<v.size()-k;i++)
		res+=v[i];
	cout<<res<<endl;
	return 0;
}



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

#define ll long long
#define INF 99999999

int main() {
    int a,b,c;
    vector<int> array;
    cin >> a >> b >> c;
    int d;
    if (a < b)d = a;
    else d = b;
    for(int i = 1; i < d+1;i++)
    {
        if(a%i == 0 && b%i==0) array.push_back(i);
    }
    cout << array[array.size() - c] << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, x = li()
l = list(li())

cur = 0
ans = 1

for lli in l:
    cur += lli
    if cur <= x:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int h,w;

void solve(vector<string> &board , vector<vector<int>> &min_vv,int x,int y,int &ans,int count, bool streak){
    if (x < 0 || x > w-1 || y < 0 || y > h-1)return;
    if (board.at(y).at(x) == '#'){
        if(streak);
        else{
            count++;
            streak = true;
        }
    }
    else streak = false;
    if (count >= min_vv.at(y).at(x))return;
    min_vv.at(y).at(x) = count;

    solve(board,min_vv,x+1,y,ans,count,streak);
    solve(board,min_vv,x,y+1,ans,count,streak);
}



int main(void){
    // Your code here!
    cin >> h>> w;
    vector<string> board(h);
    vector<vector<int>> min_vv(h,vector<int>(w,10000));
    rep(i,h) cin >> board.at(i);
    int ans = 10000;
    solve(board,min_vv,0,0,ans,0,false);
    cout << min_vv.at(h-1).at(w-1) << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    float cf,cp;
    int n;
    cin>>n;
    cp=n*1.0;
    if(n%2!=0){
        cf=n/2+1;
    }
    else{
        cf=n/2;
    }

    cout<<cf/cp;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
#define N 100005
ll n,m;
int x[N],y[N],fa[N];
ll size[N],ans[N];
int find(int x){
	if(fa[x]!=x) fa[x]=find(fa[x]);
	return fa[x];
}
int main(){
	readl(n);
	readl(m);
	ll tot=n*(n-1)/2,cnt=0;
	for(int i=1;i<=n;i++) fa[i]=i,size[i]=1;
	for(int i=1;i<=m;i++){
		in2(x[i],y[i]);
	}
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=m;i>=1;i--){
		ans[i]=tot-cnt;
		if(find(x[i])!=find(y[i])){
			cnt+=size[find(x[i])]*size[find(y[i])];
			size[find(x[i])]+=size[find(y[i])];
			fa[find(y[i])]=find(x[i]);
		}
	}
	for(int i=1;i<=m;i++) printf("%lld\n",ans[i]);
	return 0;
}

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

const int MOD = 1000000007;

int main() {
  long long int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  long long int up = 0;
  long long int down = 0;

  for(int i=0;i<a.size();++i) {
    for(int j=i+1;j<a.size();++j) {
      if(a[i] > a[j]) down++;
      else if(a[i] < a[j]) up++;
    }
  }

  long long int ans = 0;

  ans += (down * k) % MOD;

  ans += ((k * (k-1) / 2) % MOD) * (up + down);

  ans %= MOD;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//


void solve(void)
{
  int N;cin>>N;
  vector<int> v1 (N,0);
  vector<int> v2 (N,0);
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    v1[i] = X;
  }
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    v2[i] = X;
  }
  int S1 = 0,S2 = 0;
  for (int i = 0; i < N; i++)
  {
    if(v1[i] > v2[i])
    {

      S1 += (v1[i] - v2[i]);
    }
    else
    {
      S2 += (v2[i] - v1[i])/2*2;
    }
    
  }
  // DEBUG(S1,S2,"\n");
  if(S2 < S1*2)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
  
  

  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 384
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tem = 1000
z = 0
for i in h:
  c = t-0.006*i
  d = c - a
  e = tem - a
  if d**2 < e**2:
    tem = c
    z = i 
aa = h.index(z) + 1
print(aa)


Measured memory_bytes: 3060
h,w = map(int,input().split())
list1 = []
list2 = []
 
for i in range(w):
  list2.append([])
 
for i in range(h):
  s = input()
  list1.append(s)
  for j in range(w):
    list2[j].append(s[j])
 
list3 = []
for i in range(h):
  list3.append([])
  
list4 = []
for i in range(w):
  list4.append([])
 
for i in range(h):
  tmp_list = list1[i].split('#')
  for tmp in tmp_list:
    leng = len(tmp)
    list3[i].extend([leng]*leng)
    list3[i].append(0)
    
for i in range(w):
  tmp_list = (''.join(list2[i])).split('#')
  for tmp in tmp_list:
    leng = len(tmp)
    list4[i].extend([leng]*leng)
    list4[i].append(0)
    
max_num = -1
for i in range(w):
  for j in range(h):
    list3[j][i] += list4[i][j]-1
    max_num = max(max_num, list3[j][i])
    
print(max_num)

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

int main() {
string S;
  cin >> S;
  
string A,B;
  int counter0=0;
  int counter1=0;
  int j;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++){{if(i<j){
    if(S.at(i)==S.at(j)){
      counter0++;}
    }
  }}
if(counter0==2){
  cout<< "Yes"<<endl;}
  else{cout<<"No"<<endl;}
                       
                       
  

    

}


Measured memory_bytes: 256
//Ash180-AtCoder:5 ~ Revisited ~ sdyui ~ C - One Quadrillion and One Dalmatians [Beginner Contest 171]
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define clock cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
#define forie(a,n) for(int i=(a);i<=(n);i++)
#define forje(b,m) for(int j=(b);j<=(m);j++)
#define forke(c,g) for(int k=(c);k<=(g);k++)
#define ffe(a,n,b,m) forie(a,n) forje(b,m)
#define fori(n) for(int i=0;i<n;++i)
#define forj(n) for (int j=0;j<n;++j)
#define fork(n) for (int k=0;k<n;++k)
#define rev(s)  reverse(s.begin(), s.end()) 
#define initblock(v,d) memset(v,d,sizeof(v))
#define ll long long
#define ull unsigned long long
#define re return 
using namespace std;
void Ash() 
{ 	
#ifndef ONLINE_JUDGE 
freopen("input.txt", "r", stdin); freopen("error.txt", "w", stderr); freopen("output.txt", "w", stdout); 
#endif 
}

void solve()
{
    ll n; cin>>n;
    string ans;
    while(n>0) { n--; ans+='a'+n%26; n/=26; }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

int main() { fast; Ash(); solve(); clock; return 0; } 


Measured memory_bytes: 3816
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,s,t;
    cin>>a>>b>>c>>d;
    cin>>e>>f>>g>>h;
    s=a+b+c+d;
    t=e+f+g+h;
    if(s>t) cout<<s;
    else    cout<<t;
    cout<<endl;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[200010],lst[200010],ans[200010] = {1};
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i <= 200000;i++) lst[i] = -1;
	for(int i = 0;i < n;i++){
		if(lst[a[i]] != -1 && (!i || a[i] != a[i - 1])) ans[i + 1] = (ans[i] + ans[lst[a[i]] + 1]) % MOD;
		else ans[i + 1] = ans[i];
		lst[a[i]] = i;
	}
	cout << ans[n] << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
long long IN(void)
{
  long long x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
signed main(void)
{
  char S[1000000];
  int a=0x7f7f7f7f,cusum[1000001]={0},len=0,max=0,min,temp,RT=2,rv[1000001]={0};
  if(scanf("%s",S)!=0)len=strlen(S);
  for(int i=0;i<len;i++)
  {
    temp=cusum[i]+((S[i]=='1')?1:-1);
    cusum[i+1]=rv[i+1]=temp;
    max=(cusum[i+1]<max)?max:cusum[i+1];
  }
  for(int i=len-1;i>=0;i--){rv[i]=(rv[i]<rv[i+1])?rv[i+1]:rv[i];}
  while(RT--)
  {
    temp=0,min=0;
    for(int i=0;i<len;i++)
    {
      if(S[i]=='?'){if(temp+rv[i+1]-cusum[i]+2<=max){temp++;}else temp--;}
      else if(S[i]=='0'){temp--;}
      else{temp++;}
      min=(min<temp)?min:temp;
    }
    a=(a<max-min)?a:max-min;
    max++;
  }
  return printf("%d\n",a),0;
}

Measured memory_bytes: 10524
#include<stdio.h>
int main ()

{
    int rslt1 , A , B , rslt2 ;

    scanf("%d%d" , &A ,&B);

    rslt1 = A+B ;
    rslt2 = rslt1%3 ;

    if(rslt2==0||B%3==0||A%3==0){
        printf("Possible\n");
    }
    else{
        printf("Impossible\n");
    }

    return 0 ;


}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int n;
	cin>>n;
	vi out(1000100,0);
	rep(i,n){
		int a;cin>>a;
		out[a]+=a;
	}
	loop(i,1,1000100)out[i]+=out[i-1];
	int m;
	cin>>m;
	vi b(m),c(m);
	rep(i,m)cin>>b[i];
	rep(i,m)cin>>c[i];
	rep(i,m)cout<<(c[i]<=out[b[i]]?"Yes":"No")<<endl;
}

Measured memory_bytes: 13668
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

int main(){
	int h, m, s;
	rep(i, 3){
		int t1, t2;
		cin >> h >> m >> s;
		t1 = 3600 * h + 60 * m + s;
		cin >> h >> m >> s;
		t2 = 3600 * h + 60 * m + s;
		t2 -= t1;
		h = t2 / 3600;
		m = (t2 % 3600) / 60;
		s = t2 % 60;
		cout << h << " "<< m << " " << s << endl;;
	}
	return 0;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

ll f(ll x)
{
	if (x == 0) return 0;
	if (x == 1) return 1;
	return 1 + 2 * f(x / 2);
}

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll x;
	cin >> x;
	cout << f(x) << "\n";

	return 0;
}


Measured memory_bytes: 256
def solve():
    S = input()
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            print(i+1,i+2)
            return
    
    for i in range(len(S)-2):
        if S[i] == S[i+2]:
            print(i+1,i+3)
            return

    print(-1,-1)
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 39280
N = int(input())
S = input()

ans = []
t = [0]*(N+1)

for i in range(N): #i人までにいる東向きの人
    if S[i] == "E":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for j in range(N):
    ans.append(j + t[N] - t[j]  - t[j+1])

print(min(ans))

Measured memory_bytes: 98332
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#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 PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	cout << (N>=1000?"ABD":"ABC") << endl;

	return 0;
}

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

using namespace std;


/******************************************************************************
	Main
******************************************************************************/
int main() {
	string s = "";
	cin >> s;
	string ans = "";
	if (s == "Sunny") {
		ans = "Cloudy";
	} else if (s == "Cloudy") {
		ans = "Rainy";
	} else if (s == "Rainy") {
		ans = "Sunny";
	} else {
		assert(0);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;


int main() {
	ll N;
	cin >> N;
	vector<string> ss(3);
	cin >> ss[0] >> ss[1] >> ss[2];
	ll ans = 0;
	for (int i = 0;i < ss[0].size();i++) {
		ll cnt = 0;
		for (int a = 0;a < 3;a++)
			for (int b = a + 1;b < 3;b++)
				if (ss[a][i] == ss[b][i])
					cnt++;
		if (cnt == 1)
			ans++;
		else if (cnt == 0)
			ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
ll solve() {
	var(ll, n, x);
	return 3 * (n - __gcd(n, x));
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i< s.length() / 2; i++)
		if (s[i] != s[s.length() - i - 1])
			ans++;
	cout << ans;

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;
ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  vector<vector<int>> ans(h, vector<int>(w, 0));
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(i < b){
        if(j < a) ans[i][j] = 0;
        else ans[i][j] = 1;
      }
      else{
        if(j < a) ans[i][j] = 1;
        else ans[i][j] = 0;
      }
    }
  }

  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
const int N = 1e5 + 100;
struct Node {
	int c,x,y;
}ps[N];
int n,k;
bool operator < ( Node & a,Node & b){
	return a.x%k > b.x%k;
}
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
char tmp[5];
int good[N];
void inp(){
	scanf("%d%d",&n,&k);
	for(int i =0 ;i<n;i++)
		scanf("%d%d%s",&ps[i].x, &ps[i].y, tmp)
				,ps[i].c = (tmp[0] == 'W'?0:1);
	sort(ps,ps+n);
	int ans = 0;
	for(int y = 0;y < k;y++){
		int p = 0, cntgood = 0;
		for(int i =0 ;i<n ;i++){
			good[i] = ( ps[i].c 
									== 
										(ps[i].x / k + (ps[i].y+y)/k )%2);
			cntgood+= good[i];
		}
		for(int x = 0;x < k;x++){
			while( p<n && ps[p].x%k + x >= k){
				cntgood -= good[p];
				good[p] = !good[p];
				cntgood += good[p];
				p++;
			}
			ans = max( ans,
									max( cntgood, n - cntgood )
										);
		}
	}
	printf("%d\n", ans);
}
//D.cc by xsthunder at Sun Jan 21 20:30:49 2018


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

#define fast ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
typedef long double ld;
int32_t main(){
	fast;
	int w,h,x,y;
	cin >> w >> h >> x >> y;
	
	if(2*x == w && 2*y == h){
		cout << fixed  << setprecision(10) << (ld)w*h/2 << " 1";
		return 0;
	}

	cout << fixed  << setprecision(10) << (ld)w*h/2 << " " << "0";
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> PII;
typedef pair <int, int> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef pair <ld, ld> PLD;
typedef pair <PLD, ld> PLDD;
typedef pair <PLL, ll> PLLL;
typedef unsigned int ui;
const int inf = 1e9+9;
const int mod = 1e9+7;
const ll MOD = 1e9+696969;
const long long INF = (ll)1e18+3;
int n, m, k, a, b, c, DL = 0, CC = 0, T;
#define maxn 1000100
int t[maxn];
string s;
char stos[maxn];

int main() {
	boost;
	cin >> s;
	int wyn = 0;

	FOR(i, 0, (int)s.length()-1) {
		if (stos[DL] == 'S' && s[i] == 'T') ++wyn, DL--;
		else stos[++DL] = s[i];
	}
	cout << DL;
}


Measured memory_bytes: 788
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];

	int ans = A[0] - 1, P = 2;
	REP(i, 1, N) {
		if (A[i] == P) {
			P++;
		}
		else if (P < A[i]) {
			ans += (A[i] - 1) / P;
		}
	}

	cout << ans << endl;



}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long dp[100009];
long long arr[100009];
int solve(int idx)
{
    if(idx==n-1) return 0;
    if(dp[idx]!=-1) return dp[idx];
    long long ans=LONG_LONG_MAX;
    for(int i=1;i<=k;i++)
    {
        if(idx+i>=n) break;
        ans=min(ans,solve(idx+i)+abs(arr[idx+i]-arr[idx]));
    }
    return dp[idx]=ans;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>arr[i];
    cout<<solve(0)<<endl;
    return 0;
}


Measured memory_bytes: 11408