akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n, x;
    cin >> n >> x;
    
    int mn = 2e9;
    
    int sum = 0;
    int can = 0;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(can + a >= x){
            
        }
        else{
            can += a;
            cnt++;
        }
        sum += a;
        mn = min(mn, a);
    }
    if(can >= x) cout << cnt;
    else cout << cnt + (x - can) / mn;
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


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

int main() {
  int x;
  cin >> x;
  
  for(int i=1; i<=1e5; i++){
    if((i*(i+1))/2 == x){
      cout << i << endl;
      break;
    }
    else if((i*(i+1))/2 < x && x < ((i+1)*(i+2))/2){
      cout << i+1 << endl;
      break;
    }
  }
	return 0;
}


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

int main(){
    long long  N, M;
    cin >> N >> M;
    long long l = 1;
    long long r = M + 1;
    while(l<r){
        cout << l << " " << r << endl;
        l++;
        r--;
    }
    l = M + 2;
    r = 2*M + 1;
    while(l<r){
        cout << l << " " << r << endl;
        l++;
        r--;
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

LL A[100005];
LL suff[100005];
int main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for (int i = 0; i <= N; i++) {
		cin >> A[i];
	}
	if (N == 0 && A[0] == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (A[0] != 0) {
		cout << -1 << endl;
		return 0;
	}

	for (int i = N; i >= 0; i--) {
		suff[i] = suff[i + 1] + A[i];
	}
	LL ans = 1;
	LL x = 1;
	for (int d = 1; d <= N; d++) {
		LL L = x, R = min(2 * x, suff[d]);
		if (d == N && 2 * x < suff[d]) {
			cout << -1 << endl;
			return 0;
		}
		if (R < L) {
			cout << -1 << endl;
			return 0;
		}
		x = (R - A[d]);
		ans += R;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5208
num = int(input())
mochi = []
for _ in range(num):
    mochi.append(int(input()))

result = 0
maxMochi = 0
for tmp in range(num):
    if max(mochi) == maxMochi:
        mochi.pop(mochi.index(max(mochi)))
        continue

    maxMochi = max(mochi)
    result += 1
    mochi.pop(mochi.index(max(mochi)))

print(result)

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/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);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int m = 1_000_000_007;
        int dp[][][][] = new int[4][4][4][100];
        // 0A 1G 2C 3T

        for (int i=0; i<4; i++) {
            for (int j=0; j<4; j++) {
                for (int k=0; k<4; k++) {
                    dp[i][j][k][2] = 1;
                }
            }
        }
        dp[0][1][2][2] = 0;
        dp[0][2][1][2] = 0;
        dp[1][0][2][2] = 0;

        for (int c=2; c<=N-2; c++) {
            for (int i=1; i<=4; i++) {
                for (int j=1; j<=4; j++) {
                    for (int k=1; k<=4; k++) {
                        for (int l=1; l<=4; l++) {
                            if(isOk(i, j, k, l)){
                                dp[j-1][k-1][l-1][c+1] = (dp[j-1][k-1][l-1][c+1] + dp[i-1][j-1][k-1][c])%m;
                            }
                        }
                    }
                }
            }
        }

        int sum = 0;
        for (int i=0; i<4; i++) {
            for (int j=0; j<4; j++) {
                for (int k=0; k<4; k++) {
                    sum = (sum + dp[i][j][k][N-1])%m;
                }
            }
        }
        out.println(sum);
    }

boolean isOk(int a, int b, int c, int d) {
        String s1 = String.valueOf(1000*a + 100*b + 10*c + d);
        String s2 = String.valueOf(1000*b + 100*a + 10*c + d);
        String s3 = String.valueOf(1000*a + 100*c + 10*b + d);
        String s4 = String.valueOf(1000*a + 100*b + 10*d + c);
        if(!s1.contains("123") && !s2.contains("123") && !s3.contains("123") && !s4.contains("123")){
            return true;
        } else {
            return false;
        }
    }

}
}



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

template <class T> T gcd(T a, T b){
    if(b>a) T tmp = a, a=b, b=tmp;
    if(b==0) return a;
    else return gcd(b,a%b);
}
template <class T> T gcd_n(const vector<T> &V){
    T tmp=V[0];
    for( auto v : V) tmp = gcd(tmp, v);
    return tmp;
}
template <class T> T lcm(T a, T b){
    if(a==0 || b==0) return 0;
    else 
    {
        T g=gcd(a,b);
        return g*(a/g)*(b/g);
    }
}
template <class T> T lcm_n(const vector<T> &V){
    T gcd_ = gcd_n(V);
    T tmp = V[0];
    for(auto v : V) tmp = lcm(tmp, v);
    return tmp;
}

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> X(n, 0);
    REP(i, n) cin >> X[i];

    vector<int> dist(n, 0);
    REP(i, n) dist[i]=abs(X[i]-x);
    cout << gcd_n(dist)<< endl;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

import sys
import os
import math


while True:
    N = int(input())
    if N == 0:
        break
    scores = list(map(float, input().split()))
    n = len(scores)
    mean = sum(scores) / n

    variance = 0
    for score in scores:
        variance += (score - mean) ** 2
    variance /= n

    print(math.sqrt(variance))

Measured memory_bytes: 7684
from math import sqrt
Q = int(input())
for _ in range(Q):
    a,b = map(int,input().split())
    rank = a*b
    sqrank = int(sqrt(rank))
    ans = 2*sqrank - 2
    if sqrank**2 == rank:
        ans -= 1
    if sqrank*(sqrank+1) < rank:
        ans += 1
    if a == b:
        ans += 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int gcd(int x, int y){
  if(x<y) swap(x,y);
  while(y>0){
    int r = x%y;
    x = y;
    y = r;
  }

  return x;
}

int main(){
  int x,y; cin >> x >> y;
  cout << gcd(x,y) << endl;
}



Measured memory_bytes: 3088
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b] = input[0].map(Number);

  return ((b - a) * (b - a + 1)) / 2 - b;
};

console.log(main(read()));


Measured memory_bytes: 29628
#include<stdio.h>

int main(void){
        int i,j,k,n,x,cnt;
        while(1){
                cnt = 0;
                scanf("%d %d",&n,&x);

                if(n==0) break;

                for(i=1; i<n-1; i++)
                        for(j=i+1; j<n; j++)
                                for(k=j+1; k<=n; k++)
                                        if(i+j+k==x)
                                                cnt++;
                printf("%d\n",cnt);
        }
        return 0;
}

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max(0, min(B, D) - max(A, C));
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、スイッチの押し方とその時の秒数は次のように分けられる

1. A<C<B<D この時、秒数はB-C
2. A<C<D<B この時、秒数はD-C
3. C<A<B<D この時、秒数はB-A
4. C<A<D<B この時、秒数はD-A
5. A<B<C<D この時、秒数は0
6. C<D<A<B この時、秒数は0

ここから分かるように、求める秒数はmax(0, min(B, D)-max(A, C))である
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, M;
int nyu[100100];
vector<int> G[100100], rG[100100];
int par[100100];

signed main()
{
    cin >> N >> M;
    for(int i = 0; i < N - 1 + M; i++){
        int a, b;
        cin >> a >>b;
        G[b].pb(a);
        rG[a].pb(b);
        nyu[a]++;
    }
    queue<int> que;
    for(int i = 1; i <= N; i++){
        if(nyu[i] == 0){
            que.push(i);
        }
    }
    while(que.size()){
        int cur = que.front();
        que.pop();
        for(int i = 0; i < (int)rG[cur].size(); i++){
            int to = rG[cur][i];
            if(par[to] == 0){
                par[to] = cur;
            }
        }
        for(int i = 0; i < (int)G[cur].size(); i++){
            int to = G[cur][i];
            nyu[to]--;
            if(nyu[to] <= 0){
                que.push(to);
            }
        }
    }
    for(int i = 1; i <= N; i++){
        printf("%lld\n", par[i]);
    }

}
/*


*/




Measured memory_bytes: 13312
# -*- coding: utf-8 -*-

from math import gcd

def main():
     k = int(input())

     ans = 0

     for i in range(1, k+1):
          for j in range(1, k+1):
               for k in range(1, k+1):
                    ans += gcd(gcd(i, j), k)

     print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define Ms(s, n) memset(s, n, sizeof(s))
#define Rp(i,l,m) for(int i=l; i<m; ++i)
#define Rpd(i,l,m) for(int i=l; i>=m; --i)
#define Rpp(i,l,m) for(int i=l; i<=m; i++)
#define RpAll(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define All(a) (a).begin(), (a).end()
#define Fi first
#define Se second
#define Pb push_back
#define Pf push_front
#define Is insert
#define Sz(a) int((a).size())
#define ooi INT_MAX
#define ool LLONG_MAX
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a,ll b) {ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
inline ll fpow(ll n,ll k){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%MOD;n=n*n%MOD;}return r;}
const int base = 311;
const int N = 1e5 + 5;

ll n, m, k, test, a[N];
vector<int> v[140];
void Solve(){
    string s, t;
    cin >> s >> t;
    n = Sz(s);
    m = Sz(t);
    for(int i = 0; i < n; i++){
        v[s[i]].Pb(i);
    }
    k = -1;
    int cnt = 0, d = 0;
    for(int i = 96; i < 130; i++) v[i].Pb(ooi);
    for(int i = 0; i < m; i++){
        char c = t[i];
        d = int(upper_bound(v[c].begin(), v[c].end(), k) - v[c].begin());
        if(v[c][d] == ooi){
            k = -1;
            d = int(upper_bound(v[c].begin(), v[c].end(), k) - v[c].begin());
            if(v[c][d] == ooi) cout << -1, exit(0);
            else{
                k = v[c][d];
                cnt++;
            }
        }
        else{
            k = v[c][d];
        }
    }
    cout << n * cnt + v[t[m-1]][d] + 1;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed;
    Solve();
    return 0;
}




















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

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> c(n - 1), s(n - 1), f(n - 1);
  for (int i = 0; i < n - 1; i++) {
    std::cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < n; i++) {
    int64_t time = 0;

    for (int j = i; j < n - 1; j++) {
      const auto min = std::max(time, s[j]);

      if (min % f[j] == 0) {
        time = min + c[j];
      } else {
        time = (min / f[j] + 1) * f[j] + c[j];
      }
    }
    std::cout << time << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=5*1e5+5;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int a,b,c;
	cin>>a>>b>>c;
	int ans1=-1;
	int ans2=c-a-b;
	if(ans2<=0)
	{
		cout<<"No\n";
		return 0;
	}
	ans1=4*a*b;
	ans2=ans2*ans2;
	if(ans1<ans2)
	{
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}
// a+b+2*sqrt(a*b)<c
// 
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int A, B;

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

  cin >> A >> B;

  int ans = 0;
  for (int i = A; i <= B; i++) {
    std::string s = std::to_string(i);
    int sz = (int)s.size();
    bool f = true;
    for (int j = 0; j < sz / 2; j++) {
      if (s[j] != s[sz - j - 1]) {
        f = false;
        break;
      }
    }
    if (f) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

long long gcd(long long x, long long y){
  if (x<y) gcd(y,x);
  else if (y==0) return x;
  else gcd(y,x%y);
}

int main(){
  int N;
  cin >> N;
  vector<long long> x(N+1);
  for (int i=0; i<N+1; i++) cin >> x[i];
  sort(x.begin(), x.end());
  vector<long long> y(N);
  for (int i=0; i<N; i++){
    y[i] = x[i+1]-x[i];
  }
  long long ans=y[0];
  for (int i=1; i<N; i++){
    ans = gcd(y[i], ans);
  }
  cout << ans << endl;
}


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

int main() {
	int N,M,C;
	int B[20];
	int A[20];
	int ans = 0;
	
	
	cin >> N >> M >> C;
	for (int i = 0; i<M; i++) {
		cin >> B[i];
	}

	
	for (int i = 0; i<N; i++) {
		int calc = 0;
		for (int i = 0; i<M; i++) {
			cin >> A[i];
			calc +=  A[i] * B[i];
		}
		if (calc + C > 0) ans++;
	}
	
	cout << ans;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	vector<pair<ll, int>> xs(N);
	for(int i=0; i<N; i++) xs[i] = {A[i], i};
	sort(xs.begin(), xs.end());

	vector<int> b(N);
	for(int i=0; i<N; i++) b[xs[i].second] = i;

	int ans = 0;
	for(int i=0; i<N; i+=2){
		if(b[i]%2) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
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;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a,b,c,x,y;cin >> a >>b >>c >>x >>y;
    ll ans=0;
    if(a+b<=c*2){
        ans+=a*x+b*y;
        cout << ans <<endl;
        return 0;
    }
    ll z=min(x,y);
    ans+=c*2*z;
    if(x>y){
        ans+=min(a*(x-z),2*c*(x-z));
    }
    else{
        ans+=min(b*(y-z),2*c*(y-z));
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String[] s = new String[N];
    
    char[] chars = new char[10];
    StringBuilder sb;
    for (int i = 0; i < N; i++) {
      sc.next().getChars(0, 10, chars, 0);
      Arrays.sort(chars);
      sb = new StringBuilder();
      for (int j = 0; j < 10; j++) {
        sb.append(chars[j]);
      }
      s[i] = sb.toString();
    }
    Arrays.sort(s);
    
    long count = 1;
    long sum = 0;
    for (int i = 1; i < N; i++) {
      if (s[i].equals(s[i-1])) {
        count++;
        if (i == N-1) {
          sum += count * (count - 1);
        }
      } else {
        if (count == 1) {
          continue;
        } else {
          sum += count * (count - 1);
          count = 1;
        }
      }
    }
    
    System.out.println(sum / 2);
  }
}

Measured memory_bytes: 51448
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
double PI=acos(-1.0);
signed main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll cnt=0;
    rep(i,n){
        if(s[i]=='R')cnt++;
    }
    if(cnt>n-cnt)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int n,l;
  cin>>n>>l;
  string a;
  vector<string> list;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    list.push_back(a);
  }
  sort(list.begin(),list.end());
  for(int i=0;i<n;i++)
  {
    cout<<list.at(i);
  }
  cout<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const int mod = 1e9+7;
const ll INF = 1e12;
const int MAX = 1e5;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int n, w; // 変数
struct item {int va, we;};
item items[100];
ll dp[100][MAX+1];

ll rec(int i, int j) { // 重さの総和jまでで品物iまでを選んだときの価値の総和の最大
    if (j < 0) return -INF;
    if (dp[i][j] != -INF) return dp[i][j];
    if (i == 0) {
        if (items[i].we <= j) return dp[i][j] = items[i].va;
        else return dp[i][j] = 0;
    }
    ll x = rec(i-1, j);
    ll y = rec(i-1, j-items[i].we) + items[i].va;
    return dp[i][j] = max(x, y);
}

int main() {
// input
    cin >> n;
    cin >> w;
    rep(i, n) {
        cin >> items[i].we;
        cin >> items[i].va;
    }
// solve
    rep(i, n) {
        rep(j, w+1) {
            dp[i][j] = -INF;
        }
    }
    ll ans = rec(n-1, w);
// output
    cout << ans << "\n";
}

Measured memory_bytes: 81644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	int d,t,s;
	cin >> d >> t >> s;
	if(s*t >= d){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}





Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int a,b,c,d;
int main()
{ 
  cin >> a >> b >> c;
  if(a+b < b+c){d=a+b;
               }else{d=b+c;
                    }
  if(a+c < b+c && a+c < a+b){d=a+c;
                            }
  printf("%d",d);
}

Measured memory_bytes: 256
def make_d(n):
  d = []
  for i in range(1,int(n**(0.5))+1):
    if n%i == 0:
      d.append(i)
      d.append(n//i)
  return d
ans = 0
for i in range(1,int(input())+1):
  if i % 2 == 0:
    continue
  if len(make_d(i)) == 8:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define N 1000
#define INF 10000000

int M[N][N],P[N];
int min(int,int);

int main(){
  int i,j,k,n,l,r,c,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&r,&c);
    P[i]=r;
    P[i+1]=c;
  }
  
  for(i=1;i<=n;i++){
    M[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=M[i][k]+M[k+1][j]+P[i-1]*P[k]*P[j];
	M[i][j]=min(M[i][j],q);
      }
    }
  }

  printf("%d\n",M[1][n]);
  return 0;
}
int min(int a,int b){
  if(a<=b) return a;
  else return b;
}

Measured memory_bytes: 976
/*https://atcoder.jp/contests/abc124/tasks/abc124_c*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	string s1, s2;
	int count = 0, flag = 1;
	cin >> s1;
	if (s1[0] == '0')
		s2 += '0', flag = 0;
	else if (s1[0] == '1')
		s2 += '1', flag = 1;
	for (int i = 1; i < s1.length(); i++)
	{
		if (flag == 0)
			s2 += '1', flag = 1;
		else if (flag == 1)
			s2 += '0', flag = 0;
	}
	for (int i = 0; i < s2.length(); i++)
	{
		if (s1[i] != s2[i])
			count++;
	}
	cout << count;
}

Measured memory_bytes: 3796
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
T = [S() for _ in range(n)]
S = []
for t in T:
    S.append("".join(sorted(t)))

ans = 0
tmp = Counter(S)
for k, v in tmp.items():
    if v > 1:
        ans += int(v*(v-1)//2)

print(ans)

Measured memory_bytes: 78680
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	int a, b, h;cin >> a >> b >> h;
	cout << (a + b) * h / 2;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
int a,b; cin >> a >> b;
cout << a-b+1<< endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int h = S / 3600;
		int m = (S % 3600) / 60;
		int s = (S % 3600) % 60;

		System.out.println(h + ":" + m + ":" + s);
	}

}

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

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

    if (a > x) {
        cout << "NO" << endl;
        return 0;
    }

    if (x - a <= b) {
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;

    return 0;
}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

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

typedef pair<int,int> pii;
typedef pair<int,int> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}



int main(){
	int n, k; cin>> n >>k;
	int cont = 0;
	rep(i,1,n){
		if(i%2!=0)
			cont++;
	}
	if(cont >= k)
		cout<<"YES";
	else 
		cout<<"NO";
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  // 上半分白，下半分黒
  vector<vector<char>> x(100, vector<char>(100, '#'));
  for(int i = 0; i < 50; i++){
    for(int j = 0; j < 100; j++){
      x.at(i).at(j) = '.';
    }
  }
  
  // 足りない分だけ上半分に黒，下半分に白を1マスずつ独立させて置く
  int white = 1, black = 1, i = 0, j = 0;
  
  // 黒を追加
  while(black < b){
    x.at(i).at(j) = '#';
    black++;
    if(j < 98){
      j += 2;
    }
    else{
      i += 2;
      j = 0;
    }
  }
  
  // 白を追加
  i = 51;
  j = 0;
  while(white < a){
    x.at(i).at(j) = '.';
    white++;
    if(j < 98){
      j += 2;
    }
    else{
      i += 2;
      j = 0;
    }
  }
  
  // 出力
  cout << "100 100" << "\n";
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      cout << x.at(i).at(j);
    }
    cout << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ

int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int h,w,k;
  cin >> h >> w >> k;
  VPii a(100000);
  
  int qw;
  
  rep(i,0,h){
    rep(j,0,w){
      cin >> qw;
      a[qw] = mp(i,j);
    }
  }
  
  Vi pr(h*w+10);
  repeq(i,1,k){
    pr[i]=0;
  }
  
  repeq(i,k+1,h*w){
    pr[i] = pr[i-k] + abs(a[i].FI-a[i-k].FI)+abs(a[i].SE-a[i-k].SE);
  }
  //Vout(pr);
  //abs(a[qw].FI-a[qw+k].FI)+abs(a[qw].SE-a[qw+k].SE)
  
  int Q,er,ans=0,now;
  cin >> Q;
  rep(i,0,Q){
    cin >> qw >> er;
    
    cout << pr[er]-pr[qw] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3456
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    //freopen("unionday.in", "r", stdin);
    //freopen("unionday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        read2(n,k);
        vi a(n);
        fr(i,n) cin >> a[i];
        srt(a);
        lli sum=0;
        fr(i,k) sum+=a[i];
        cout << sum;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>
#include <math.h>
int a[11000];
long f(int x,int y,int z){
	return x*x+y*y+z*z+x*y+y*z+z*x; 
}

int main(){
	long N,x,y,z;
	
	scanf("%ld",&N);
	long i,cnt=0,calc;
	for(x=1;x<=N;x++){
		for(y=1;y<N;y++){
			for(z=1;z<=N;z++){
				calc=f(x,y,z);
				if(calc>N)break;
				a[calc]++;
				
			}
		}
	}
	
	for(i=1;i<=N;i++)
		printf("%ld\n",a[i]);

	return 0;
}


Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

// 組み合わせを求める(グローバル汚さない版)
// 上の関数にまとめたバージョン
// nCk mod. p を出したくて、nが<1e7 かつ pが素数(1e9+7は素数)ならおk
// MAX 1e7で1400msぐらいかかるので注意(元版はそれの半分の時間で済む)
// 上と同じ2回目以降はキャッシュされるのでO(1)
// 第三引数は初回のみに使用する。 nCkのnの最大値を入れる(1e6+1推奨)。O(k)を使用する場合は不要
// else O(k) [nが固定されている必要はある]
// O(k)とO(n)の両方を選択することは出来ないのでそういったときはこの関数を命名分けて2個作る必要がある。
long long combination(int n, int k,int init_max_n = -1){
    static vector<ll> fac,finv,inv,big_n_tbl;
    static const int mod = 1e9+7;
    static bool big_n = false;
    static bool created = false;
    if (big_n) cerr << "big_n: trueのため、nは初期化時に使用した値になります" << endl;
    if (created && init_max_n != -1) cerr << "初期化済みのためinit_max_nの値は無視されます" << endl;
    if (!created) {
        if (init_max_n == -1) {
            cerr << "初期化に失敗しました。" << endl;
            exit(1);
        }
        if ( max(init_max_n,n) < 1e7+1) { // O(n) tbl
            fac.resize(init_max_n,0);
            finv.resize(init_max_n,0);
            inv.resize(init_max_n,0);
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < init_max_n; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }
        else { // O(k) table (nは変更不可)
            chmin(k,n-k);
            big_n_tbl.resize(k+1,1);
            inv.resize(k+2,1);
            FOR(i,1,k+1){
                inv[i+1] = mod - inv[mod%(i+1)] * (mod/(i+1)) % mod;
                big_n_tbl[i] = (i == 1) ? n : ((n-i+1)*inv[i])%mod * big_n_tbl[i-1];
                if (i==1) cerr<< "i:1 " << big_n_tbl[i] << endl;
                big_n_tbl[i]%=mod;
            }
            big_n = true;
        }
        created = true;
    }
    if (big_n) return big_n_tbl[k];
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void solve() {
    int N,K; cin >> N >> K;
    // initialize
    combination(N,K,1e7);
    FOR(i,1,K+1) cout << (combination(N-K+1,i) * combination(K-1,i-1))%ll(1e9+7) << endl;
}

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

Measured memory_bytes: 237628
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    nk = input[0].split(" ");
    hhh = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(nk[0], 10);
    var k = parseInt(nk[1], 10);
    var total=0;
    if (n<=k){console.log(total);
             }
    else{
    var H =[];total=0;
    for (i=0;i<n;i++){
        var h = parseInt(hhh[i], 10);
        total +=h;
        H[i]=h;
    }
  //  console.log(H);
    H.sort((a,b) => b-a);
  //  console.log(H);
    var ktotal=0;
    for(i=0;i<k;i++){ktotal+=H[i];}
   // console.log(total,ktotal);
    console.log(total-ktotal);
 }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


int main(){
    int a, b;
    cin >> a >> b;
    if (a <= b){
        rep(i, b){
            cout << a;
        }
        cout << endl;
    }
    else{
        rep(i, a){
            cout << b;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int a,b,c;

  int k;

  cin>>a>>b>>c>>k;


  for(int i=0;i<k;i++){
    if(a>=b&&a>=c){
      a=a*2;
    }else if(b>=a&&b>=c){
      b=b*2;
    }
    else if(c>=a&&c>=b){
      c=c*2;
    }
  }


  cout<<a+b+c<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N (100000+1000)
using namespace std;

int a[N],b[N],cnt,n,m;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1; i<=m; ++i)
	{
		scanf("%d",&a[i]);
		if (a[i]%2) b[++cnt]=i;
	}
	if (cnt>2) {puts("Impossible"); return 0;}
	if (m==1)
	{
		if (a[1]==1) printf("1\n1\n1\n");
		else printf("%d\n2\n1 %d\n",a[1],a[1]-1);
		return 0;
	}
	if (b[1]) swap(a[1],a[b[1]]);
	if (b[2]) swap(a[m],a[b[2]]);
	
	for (int i=1; i<=m; ++i)
		printf("%d%c",a[i]," \n"[i==m]);
	a[1]++; a[m]--;
	printf("%d\n",a[m]==0?m-1:m);
	for (int i=1; i<=m; ++i)
		if (a[i]!=0) printf("%d%c",a[i]," \n"[i==m]);
}

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

int main () {
  string s;
  cin >> s;
  
  int ans = 0;
  for (int i = 0; i < s.size()/2; i++) {
    if (s[i] != s[s.size()-1-i]) {
      ans ++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> V(N);
    rep(i, N) cin >> V[i];
    map<ll, ll> even, odd;
    rep(i, N) {
        if (i % 2) {
            odd[V[i]]++;
        } else {
            even[V[i]]++;
        }
    }
    ll max_even = -1;
    ll max_even_num = -1;
    ll max_odd = -1;
    ll max_odd_num = -1;
    for (auto p : even) {
        if (max_even < p.second) {
            max_even = p.second;
            max_even_num = p.first;
        }
    }
    for (auto p : odd) {
        if (max_odd < p.second) {
            max_odd = p.second;
            max_odd_num = p.first;
        }
    }
    if (max_even_num != max_odd_num) {
        cout << N - max_even - max_odd << endl;
    } else {
        ll max_even2 = 0;
        ll max_odd2 = 0;
        for (auto p : even) {
            if (max_even2 < p.second && p.first != max_even_num) {
                max_even2 = p.second;
            }
        }
        for (auto p : odd) {
            if (max_odd2 < p.second && p.first != max_odd_num) {
                max_odd2 = p.second;
            }
        }
        if (max_even2 > max_odd2) {
            cout << N - max_even2 - max_odd << endl;
        } else {
            cout << N - max_even - max_odd2 << endl;
        }
    }

}

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


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define long long ll;
int main()
{
    
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];
    int mini=INT_MAX;
    for(int i=1;i<=100;i++)
    {
        int sqs=0;
        for(int j=0;j<n;j++)
        {
            sqs+=(ar[j]-i)*(ar[j]-i);
        }
        if(sqs<=mini)
            mini=sqs;
    }
    cout<<mini;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  bool gyaku = false;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      gyaku = !gyaku;
    } else if (t == 2) {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (gyaku == false) {
          s.insert(s.begin(), c);
        } else {
          s.insert(s.end(), c);
        }
      } else if (f == 2) {
        if (gyaku == true) {
          s.insert(s.begin(), c);
        } else {
          s.insert(s.end(), c);
        }
      }
    }
  }
  if (gyaku == true) {
    for (int i = s.size() - 1; 0 <= i; i--) {
      cout << s[i] << flush;
    }
    cout << endl;
  } else {
    cout << s << endl;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main() {

int a, b;
int ave, rem;

cin >> a >> b;

ave = (a + b) / 2;
rem = (a + b) % 2;

if(rem == 0){
  cout << ave << endl;
}
else if(rem == 1){
  cout << ave + 1 << endl;
}

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int N, ct = 0;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N - 1; i++){
        if(a[i] == a[i + 1]){
            ct++;
            a[i + 1] = 100000;
        }
    }
    cout << ct << endl;
}

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

using namespace std;

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

	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe\n";
	else cout << "safe"	;
	
	return 0;
}

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

using namespace std;

const double PI = acos(-1);

int main()
{
  double n, m;
  cin >> m >> n;
  cout << fixed << setprecision(10) << m * sin(PI/m) * cos(n*PI / m) / cos((n - 1) * PI / m) << endl;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;

int A[1001000];

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    for (int i=1; i<=n; i++) cin>>A[i];
    int g = gcd(A[n-1], A[n]);
    bool sc = g == 1 ? true : false;
    for (int i=n-2; !sc && i>=1; i--) {
        g = gcd(g, A[i]);
        if (g == 1) sc = true;
    }
    if (!sc) {
        cout<<"not coprime";
        return 0;
    }
    set <int> pr;
    for (int i=n; i>=1; i--) {
        int cur = A[i];
        for (int j=2; j<=sqrt(cur); j++) {
            if (cur % j == 0) {
                if (pr.count(j)) {
                    cout<<"setwise coprime";
                    return 0;
                }
                pr.insert(j);
            }
            while (cur % j == 0) cur /= j;
        }
        if (cur > 1) {
            if (pr.count(cur)) {
                cout<<"setwise coprime";
                return 0;
            }
            pr.insert(cur);
        }
    }
    cout << "pairwise coprime";
    return 0;
}

Measured memory_bytes: 11348
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
s = list(S())
ans = 0
one_cnt = 0
z_cnt = 0
dp = []
flg = 0
for i in range(n):
    if s[i] == "1":
        one_cnt += 1
        z_cnt = 0
        if flg:
            if dp:
                ans += max(dp)
                dp = []
            flg = 0
        if i == n - 1 or s[i + 1] == "0":
            # 手付かず、左端だけ消した、右端だけ残す、全て消した。
            if dp:
                if one_cnt > 2:
                    ndp = [max(dp), max(dp[0] + pre, dp[1] + pre - 1, dp[2] + 1),
                           max(dp[0], dp[1], dp[2]) + one_cnt - 1,
                           max(dp[0], dp[1], dp[2]) + one_cnt]
                elif one_cnt == 2:
                    ndp = [max(dp), max(dp[0] + pre, dp[1] + pre - 1, dp[2] + 1),
                           max(dp[0] + pre, dp[1] + pre - 1, dp[2] + 1),
                           max(dp[0], dp[1], dp[2]) + 2]
                else:
                    ndp = [-INF, -INF, max(dp),
                           max(dp[0] + pre, dp[1] + pre - 1, dp[2] + 1)]
                dp = ndp
            else:
                dp = [0, -INF, -INF, -INF]
            pre = one_cnt
    else:
        z_cnt += 1
        one_cnt = 0
        if z_cnt >= 2:
            flg = 1

if dp:
    ans += max(dp)

print(ans)

Measured memory_bytes: 108124