akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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 a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(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); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int memo[100000], table[100000];
ll ans = 0;
int main(){
  ll x; cin>>x;
  ll n = (ll)((-1+sqrt(1+8*x))/2);
  if(n != ((-1+sqrt(1+8*x))/2)){
    n++;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 3544
S = input()
a = S[0]
b = 0
acount = 1
bcount  = 1
for i in range(1,4):
    if a == S[i]:
        acount += 1
    elif b == S[i]:
        bcount += 1
    else:
        if b == 0:
            b = S[i]

if acount == 2 and bcount == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n, m;
vector<ll> a, dp;

ll f(ll val) {
    ll ans = 0;
    rep(i, n) {
        auto it = lower_bound(all(a), val - a[i]);
        ans += n - (it - a.begin());
    }
    return ans;
}

ll g(ll val) {
    ll ans = 0;
    rep(i, n) {
        auto it = lower_bound(all(a), val - a[i]);
        ll idx = it - a.begin();
        ans += dp[n] - dp[idx] + (n - idx) * a[i];
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> m;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    dp.resize(n + 1, 0);
    rep(i, n) dp[i + 1] = dp[i] + a[i];
    ll l = 0, h = LONG_LONG_MAX / 2 - 1;
    while((l + 1) < h) {
        ll x = (l + h) / 2;
        if (f(x) > m) l = x;
        else h = x;
    }
    ll ans = g(h) + (m - f(h)) * l;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

ll A,P;
ll ans;
int main(){
  cin >> A >> P;
  ans = (A*3+P)/2;
  cout << ans << endl;
}


Measured memory_bytes: 888
#include <stdio.h>

long long factorial(long long n)
{
	if(n>0)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}
int main(void)
{
	long long n;
	scanf("%lld",&n);
	printf("%lld\n",factorial(n));
	return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        long[] a = new long[n];
        long initial = 1024*1024*1024*2-1;
        StringBuilder bd = new StringBuilder();
        Arrays.fill(a, initial);
        for (int i=0; i<q; i++) {
            int com = sc.nextInt();
            if (com == 0) {
                int x = sc.nextInt();
                long y = sc.nextLong();
                a[x] = y;
            }
            else if (com == 1){
                int x = sc.nextInt();
                int y = sc.nextInt();
                long Min = initial;
                for (int j=x; j<y+1; j++) {
                    if (Min > a[j]) {
                        Min = a[j];
                    }
                }
                bd.append(Min + "\n");
            }
        }
        System.out.print(bd);
    }
}


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  string s, t;
  cin >> n >> s >> t;

  rep(i, 0, n) {
    if(s.substr(i) == t.substr(0, n - i)) {
      cout << n + i << endl;
      return 0;
    }
  }
  cout << n * 2 << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
bc=[]
for i in range(M):
  bc.append(list(map(int,input().split())))

bc.sort(key=lambda x:x[1],reverse=True)
nbc=[0]*N
inde=0
for i in range(M):
  for j in range(bc[i][0]):
    if inde<=N-1:
      nbc[inde]=bc[i][1]
      inde+=1
      if inde==N:
        break
  if inde==N:
    break
  
ind=N
for i in range(N):
  if A[i]>=nbc[i]:
    ind=i
    break

print(sum(nbc[:ind])+sum(A[ind:]))

Measured memory_bytes: 32972
#include<iostream>
#include<cstdio>

using namespace std;

#define n 8
#define free -1
#define not_free 1

int row[n],col[n],dpos[2*n-1],dneg[2*n-1];
bool x[n][n];

void initialize()
{
    for(int i=0;i<n;i++){
        row[i]=free;
        col[i]=free;
    }
    for(int i=0;i<2*n-1;i++){
        dpos[i]=free;
        dneg[i]=free;
    }
}

void printboard()
{
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(x[i][j]){
                if(row[i]!=j){
                    return ;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(row[i]==j){
                cout<<"Q";
            }else{
                cout<<".";
            }
        }
        cout<<endl;
    }
}

void recursive(int i)
{
    if(i==n){
        printboard();
        return ;
    }
    for(int j=0;j<n;j++){
        if(not_free==col[j]||not_free==dpos[i+j]||not_free==dneg[i-j+n-1]){
            continue;
        }
        row[i]=j;
        col[j]=dpos[i+j]=dneg[i-j+n-1]=not_free;
        recursive(i+1);
        row[i]=col[j]=dpos[i+j]=dneg[i-j+n-1]=free;
    }
}

int main()
{
    initialize();
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            x[i][j]=false;
        }
    }
    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        int r,c;
        cin>>r>>c;
        x[r][c]=true;
    }
    recursive(0);
    return 0;
}
/*
2
2 2
5 3
*/



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if(s == u) cout << a-1 << " " << b << "\n";
	else cout << a << " " << b-1 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 10027, inf = 0x3f3f3f3f;
const LL INF = 1e18;
int n;
int rx[N], ry[N], rc[N], bx[N], by[N], bc[N];
namespace MCMF {
	int edc = 1, S, T;
	int head[N], cur[N], vis[N];
	LL dis[N];
	struct edge { int lst, to, cap, flow; LL c;}e[N * 6];
	void Add(int a, int b, int c, int d) {
		e[++edc] = (edge) { head[a], b, c, 0, -d}, head[a] = edc;
		e[++edc] = (edge) { head[b], a, 0, 0, d}, head[b] = edc;
	}
	bool spfa() {
		memcpy(cur, head, sizeof head);
		fill(dis, dis + N - 1, INF);
		dis[S] = 0; queue<int>Q; Q.push(S);
		while(!Q.empty()) {
			int u = Q.front();Q.pop();
			vis[u] = 0;
			go(u) if(e[i].cap - e[i].flow > 0 && Min(dis[v], dis[u] + e[i].c)) {
				if(!vis[v]) vis[v] = 1, Q.push(v);
			}
		}
		return dis[T] != INF;
	}
	typedef pair<int, LL> pii;
	#define mp make_pair
	pii dfs(int u, int b) {
		if(u == T || !b) return mp(b, 0);
		pii res(0, 0), f;
		vis[u] = 1;
		for(int &i = cur[u]; i; i = e[i].lst)
		if(e[i].cap - e[i].flow > 0 && dis[u] + e[i].c == dis[e[i].to] && !vis[e[i].to]) {
			f = dfs(e[i].to, min(b, e[i].cap - e[i].flow));
			res.first += f.first;
			res.second += f.second + e[i].c * f.first;
			e[i].flow += f.first;
			e[i ^ 1].flow -= f.first;
			b -= f.first;
			if(!b) break;
		}
		vis[u] = 0;
		return res;
	}
	LL mcmf() {
		LL res = 0;
		while(spfa()) res += dfs(S, inf).second;
		return -res;
	}
}
int main() {
#ifdef fwat
#endif
	using namespace MCMF;
	n = gi();
	rep(i, 1, n) {
		rx[i] = gi(), ry[i] = gi(), rc[i] = gi();
	}
	rep(i, 1, n) {
		bx[i] = gi(), by[i] = gi(), bc[i] = gi();
	}
	S = n * 10 + 5, T = S + 1;
	rep(i, 1, n) {
		Add(S, i, rc[i], 0);
		Add(i, i + n * 1, rc[i],  rx[i] + ry[i]);
		Add(i, i + n * 2, rc[i], -rx[i] - ry[i]);
		Add(i, i + n * 3, rc[i],  rx[i] - ry[i]);
		Add(i, i + n * 4, rc[i], -rx[i] + ry[i]);
		Add(i + n * 1, n * 10 + 1, rc[i], 0);
		Add(i + n * 2, n * 10 + 2, rc[i], 0);
		Add(i + n * 3, n * 10 + 3, rc[i], 0);
		Add(i + n * 4, n * 10 + 4, rc[i], 0);
	}
	rep(i, 1, n) {
		Add(i + n * 9, T, bc[i], 0);
		Add(i + n * 5, i + n * 9, bc[i],  bx[i] + by[i]);
		Add(i + n * 6, i + n * 9, bc[i], -bx[i] - by[i]);
		Add(i + n * 7, i + n * 9, bc[i],  bx[i] - by[i]);
		Add(i + n * 8, i + n * 9, bc[i], -bx[i] + by[i]);
		Add(n * 10 + 1, i + n * 6, bc[i], 0);
		Add(n * 10 + 2, i + n * 5, bc[i], 0);
		Add(n * 10 + 3, i + n * 8, bc[i], 0);
		Add(n * 10 + 4, i + n * 7, bc[i], 0);
	}
	printf("%lld\n", mcmf());
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  map<int,int>mp;
  int cnt=0;
  rep(i,n){
    int x;
    cin >> x;
    if(x<400)mp[0]++;
    else if(x<800)mp[1]++;
    else if(x<1200)mp[2]++;
    else if(x<1600)mp[3]++;
    else if(x<2000)mp[4]++;
    else if(x<2400)mp[5]++;
    else if(x<2800)mp[6]++;
    else if(x<3200)mp[7]++;
    else cnt++;
  }
  int ans=0;
  for(int i=0;i<=7;i++){
    if(mp[i]>0){
      ans++;
    }
  }
  if(ans>0)cout << ans << " " << ans+cnt << endl;
  else cout << 1 << " " << cnt << endl;
    
}


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

using namespace std;

typedef long long ll;

int main() {
    ll n, m; cin >> n >> m;
    n = __gcd(n, m);
    int mx = (n % 2 == 0) + 1;
    while(n % 2 == 0)
        n >>= 1;
    for(ll i = 3; i * i <= n; ++i)
        if(n % i == 0) {
            mx += 1;
            while(n % i == 0)
                n /= i;
        }
    if(n > 1) mx += 1;
    cout << mx;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
const ll mod=998244353;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int k;
	cin>>k;
	int ans=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int x=1;x<=k;x++)
			{
				int y=gcd(i,j);
				ans+=gcd(y,x);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3596
N=int(input())
kyoku = [list(map(str,input().split())) for x in range(N)]
S = input()
Sum=0
i=0
for x in range(0,N):
    if kyoku[x][0]==S:
        AA=x
for x in range(AA+1,N):
    Sum=Sum+int(kyoku[x][1])
print(Sum)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc170/tasks/abc170_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<int, int> mp;
    REP(i, N) {
        int t;
        cin >> t;
        mp[t]++;
    }
    // 入力値の最大値
    int maxv = (*mp.rbegin()).first;
    // 入力値の2倍以上を保存
    bitset<1000001> bt;
    int ans = 0;
    for (auto x : mp) {
        // 重複なし
        if (x.second == 1 && !bt[x.first]) {
            ans++;
        }
        // 重複している数も2倍以上を計算
        for (int mul = 2; x.first * mul <= maxv; mul++) {
            bt.set(x.first * mul);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16224
#include <bits/stdc++.h>
using namespace std;
//#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  string s;cin>>s;

  int a=INF,z=0;
  for(int t=0;t<(int)s.size();t++){
    if(s[t]=='A')a=min(a,t);
    if(s[t]=='Z')z=max(z,t);
  }

  cout<<z-a+1<<endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))

s = 0
ans = 0
while s <= N-1:
  i = s
  temp = 0
  while i <= N-2 and A[i] >= A[i+1]:
    temp += 1
    i += 1
  ans = max(ans,temp)
  s = i+1
print(ans)
  

Measured memory_bytes: 14252
H, W = map(int, input().split())
grid = []
grid.append(' '*(W + 2))
for i in range(H):
    grid.append(' ' + str(input()) + ' ')
grid.append(' '*(W + 2))

ans = []
for i in range(1,H+1):
    R = ''
    for j in range(1,W+1):
        count = 0
        if grid[i][j] == '#': R += '#'
        else:
            loop = [(i-1,j-1), (i-1,j), (i-1,j+1), (i,j-1), (i,j+1), (i+1,j-1),(i+1,j),(i+1,j+1)]
            for tmp in loop:
                if grid[tmp[0]][tmp[1]] == '#': count += 1
            R += str(count)
    ans.append(R)

for i in range(H):
    for j in range(W):
        print(ans[i][j], end='')
    print()

Measured memory_bytes: 3444
a=list(map(int,input().split()))
if a[0]<0:
    a[0]=-a[0]
x=a[0]%a[2]
y=a[0]//a[2]
if y>=a[1]:
    print(a[0]-a[1]*a[2])
elif (a[1]-y)%2==1:
    print(a[2]-x)
else:
    print(x)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  char c[500][500];
  cin>>h>>w;
  char r[500][500];
  char b[500][500];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
       cin>>c[i][j];
       r[i][j]='.';
       b[i][j]='.';
    }
  }
  for(int i=0;i<h;i++){
    if(i%2){
      for(int j=0;j<w-1;j++){
        r[i][j]='#';
      }
      b[i][w-1]='#';
    }else{
      for(int j=1;j<=w-1;j++){
        b[i][j]='#';
      }
      r[i][0]='#';
    }
  }
  for (int i=0;i<h;i++){
    for (int j=0;j<w;j++){
      if(c[i][j]=='#'){
        r[i][j]='#';
        b[i][j]='#';
      }
    }
  }
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cout<<r[i][j];
      }
      cout<<endl;
  }
cout<<endl;
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cout<<b[i][j];
      }
      cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int times = 0;
		
		times = A * B;
		
		System.out.println(times);

	}

}


Measured memory_bytes: 35864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int cnt = 0;
  rep(i, n) cnt += s[i]-'0';
  rep(i, n) {
    if(cnt == n-2*i || cnt == 0) {
      cout << n-i << endk;
      break;
    }
    cnt -= s[i]-'0';
    cnt -= s[n-1-i]-'0';
  }
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int a[100010];
const int mod=998244353;
map<int,int> mp; 
int main()
{
	int n;
	cin >>n;
	int maxx=-1;
	for(int i=0;i<n;i++)
	{
		cin >>a[i];
		maxx=max(maxx,a[i]);
		mp[a[i]]++;
	}
	 ll sum=1;
	if(a[0]!=0||maxx>n-1) printf("0\n");
	else
	{
		for(int i=1;i<n;i++)
		{
			if(a[i]!=1)
			{
				int y=a[i];
				//while(mp[y--]==0);
				int x=mp[y-1];
				sum=sum%mod*(x%mod)%mod;
			}
		}
	printf("%llu",sum%mod);
	}
	return 0;
}

Measured memory_bytes: 5376
<?php

$input = explode(' ', trim(fgets(STDIN)));

$answer = [1,9,7,4];

foreach($input as $val){
    $key = array_search($val, $answer);
    if ($key === FALSE) {
        echo "NO";
        exit;
    }
    unset($answer[$key]);
}

echo "YES";
exit;

Measured memory_bytes: 4856
H,W=gets.chomp.split(" ").map(&:to_i)
A={}
H.times do
    array=gets.chomp.split("")
    array.each do |a|
        A[a]||=0
        A[a]+=1
        A[a]%=4
    end
end
values=A.map{|_,v|v}.sort
values.delete(0)
if H.odd? && W.odd?
    found=false
    values.each_with_index do |v,i|
        if v.odd?
            found=true
            values[i]-=1
            values.delete(0)
            break
        end
    end
    if !found
        puts "No"
        exit
    end
end
values.each do |v|
    if v.odd?
        puts "No"
        exit
    end
end
if H.odd?
    (W/2).times do
        values[0]-=2
        values.delete(0)
        if values.empty?
            puts "Yes"
            exit
        end
    end
end
if W.odd?
    (H/2).times do
        values[0]-=2
        values.delete(0)
        if values.empty?
            puts "Yes"
            exit
        end
    end
end
values.each do |v|
    if v%4==2
        puts "No"
        exit
    end
end
puts "Yes"


Measured memory_bytes: 14372
from collections import Counter

def orders(count, n):
    c = 1
    for k, v in count.items():
        if k == 0:
            if (n % 2 == 0 or v != 1):
                return 0
        elif (n - 1 - k) % 2 == 1 or v != 2:
            return 0
        else:
            c *= v
    return(c % (10 ** 9 + 7))


if __name__ == '__main__':
    n = int(input())
    count = Counter(map(int, input().split()))
    print(orders(count, n))

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

int main() {
  int N, M ;
  cin >> N >> M;
  
  vector<int> city(2*M);
  rep(i, 2*M) {
    cin >> city.at(i);
  }
  
  rep(i, N) {
    int ans = 0;
    
    rep(j, 2*M) {
      if (city.at(j) == i+1) {
        ans++;
      }
    }
    
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int ans=n;
  
  for(int i=0;i<=n-t.size();i++)
  {
    int k=i;
    int j=0;
    int c=0;
    while(j<t.size())
    {
      if(s[k]!=t[j])c++;
      k++;
      j++;
    }
    ans=min(c,ans);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans++
		d := 0
		for j := i + 1; j < n; j++ {
			i = j
			x := a[j] - a[j-1]
			if d == 0 && x != 0 {
				d = x
			}
			if (d > 0 && x < 0) || (d < 0 && x > 0) {
				i = j - 1
				break
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        int score = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (i % 2 ==1) {
                score += a[i];
            } else {
                score -= a[i];
            }
        }
        System.out.println(Math.abs(score));
    }

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
long long n,m,i,j,dp[100005][3],num[100005];
char c[100005];
int main()
{
	cin>>n;
	c[1]='+';
	for (i=1;i<=n;i++)
	{
		if (i!=1) cin>>c[i];
		cin>>num[i];
	}
	dp[1][0]=num[1];
	dp[1][1]=dp[1][2]=-0x2222222222222222ll;
	for (i=2;i<=n;i++)
	{
		if (c[i]=='+')
		{
			dp[i][0]=max(dp[i-1][1],dp[i-1][0])+num[i];
			dp[i][1]=dp[i-1][1]-num[i];
			dp[i][2]=dp[i-1][2]+num[i];
		}
		else
		{
			dp[i][0]=-0x2222222222222222ll;
			dp[i][1]=max(dp[i-1][0],dp[i-1][1])-num[i];
			dp[i][2]=max(dp[i-1][1],dp[i-1][2])+num[i];
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>

int main() {
  int num;
  std::cin >> num;

  int ans_count = 0;
  for (int i = 1; i <= num; i += 2) {
    int divisor_count = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) ++divisor_count;
    }
    if (divisor_count == 8) ++ans_count;
  }
  std::cout << ans_count << std::endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };



int main() {
	ll n;
	cin >> n;
	vector<pair<ll,ll>>v;
	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		v.pb({ a + b,a });
	}

	sort(all(v));
	reverse(all(v));
	
	int turn = 0;
	ll tkhs = 0;
	ll aok = 0;
	rep(i, 0, n) {
		if (turn == 0) {
			tkhs += v[i].second;
		}
		else {
			aok += v[i].first - v[i].second;
		}
		turn = !turn;
	}

	cout << tkhs - aok << endl;




	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    if (n < 1000) {
        cout << "ABC" << endl;
    }
    else {
        n -= 1000;
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <map> 
using namespace std;
int a,n,am;
map<int,int>m;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		m[a-1]++;
		m[a]++;
		m[a+1]++;
	}
	for(map<int,int>::iterator it=m.begin();it!=m.end();++it){
		am=(it->second>am?it->second:am);
	}
	printf("%d\n",am);
	return 0;
}


Measured memory_bytes: 7616
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;

//const int MAXN = (int)1e5 + 5;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int &x : arr)
        cin >> x;
    int ans = 0;
    int mn = INT_MAX;
    for (int i = 0; i < n; ++i) {
        if (arr[i] < mn) {
            ++ans;
            mn = arr[i];
        }
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A <= C && B >= C) {
         cout << "Yes" << endl;
    }
    else if(A >= C && B <= C) {
         cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vd v(n); rep(i,n) cin>> v[i];
	SORT(v);
	double ans = (v[0]+v[1])/2.0;
	if(n>2)rep2(i,2,n)ans = (ans+v[i])/2.0;
	out16(ans);
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int D;
    scanf("%d", &D);
    if(D==25) printf("Christmas");
    if(D==24) printf("Christmas Eve");
    if(D==23) printf("Christmas Eve Eve");
    if(D==22) printf("Christmas Eve Eve Eve");
    return 0;
}


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

int main(){
  int A,B,C,x;
  int k = 0;//何通りあるのかをカウントする変数
  int l = 0;
  cin>>A>>B>>C>>x;
  for(int a = 0;a <= A;a++){
    for(int b = 0;b <= B;b++){
      for(int c = 0;c <= C;c++){
        l = 500 * a + 100 * b + 50 * c;
        if(l == x){
          k++;
        }
      }
    }
  }
  cout<<k<<endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define sc1(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl1(a) scanf("%lld",&a)
#define scl2(a,b) scanf("%lld%lld",&a,&b)
#define scl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr1(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d ",a,b)
#define pr3(a,b,c) printf("%d %d %d ",a,b,c)
#define mii map<int,int>
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pair<int,int>>
#define mii map<int,int>
#define ll long long
#define ii pair<int,int>
#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rloop(i,a,b) for(int i=(a);i>(b);i--)
#define tr(it,c) for(decltype((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define mod 998244353
#define mod2 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL)
 
using namespace std;
int gcd(int a,int b)
{
	if(a<b)
	swap(a,b);
	if(b==0)
	return a;
	while((a=a%b)!=0)
	{
		swap(a,b);
	}
	return b;
}
ll modpow(ll x,int y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%mod2;
		y=y>>1;
		x=x*x%mod2;
	}
	return res;
}
ll ncr(int n,int r)
{
	ll f1=1,f2=1;
	loop(i,n-r+1,n+1)
	f1=f1*i%mod;
	loop(i,1,r+1)
	f2=f2*i%mod;
	return f1*modpow(f2,mod-2)%mod;
}
int *sieve(int n)
{
	int *lpf=new int[n+1];
	for(int i=1;i<=n;i++)
	lpf[i]=i;
	int rt=(int)floor(sqrt(n))+1;
	loop(i,2,rt)
	{
		if(lpf[i]!=i)
		continue;
		for(int j=i*i;j<=n;j+=i)
		{
			if(lpf[j]==j)
			lpf[j]=i;
		}
	}
	return lpf;
}









void solve()
{
	int n,k;
	cin>>n>>k;
	int l[n];
	loop(i,0,n)
	cin>>l[i];
	sort(l,l+n);
	int stt=1,end=1e9+1;
	while(stt!=end)
	{
		int mid=stt+(end-stt)/2;
		int cut=0;
		loop(i,0,n)
		{
			cut+=(l[i]-1)/mid;
		}
		if(cut<=k)
		end=mid;
		else
		stt=mid+1;
	}
	cout<<stt;
}

int main()
{
	SYNC;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t=1;
	//cin>>t;
	while(t--)
	{
		//cout<<"Case #"<<z+1<<": ";
		solve();
		cout<<"\n";
	}
}


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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    vector<pair<int, int>> vp;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a, b);
    }
    vector<int> cs(n, 0);
    map<pair<int, int>, int> I;
    vector<int> used(n, 0);
    queue<int> que;
    que.emplace(0);
    used[0] = 1;
    int k   = 0;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        if (k < (int)G[v].size()) k = G[v].size();
        int cur = 1;
        for (int u : G[v]) {
            if (used[u]) continue;
            if (cur == cs[v]) cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u]                                         = 1;
            que.emplace(u);
        }
    }
    cout << k << endl;
    for (auto p : vp) cout << I[p] << endl;
    return 0;
}


Measured memory_bytes: 20084
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
    n = readline() |> parseInt
    a = readline() |> split |> parseMap

    ans = 0
    for i in 1:n
        while mod(a[i],2) == 0
            a[i] /= 2
            ans += 1
        end
    end

    println(ans)
end

main()


Measured memory_bytes: 113372
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    vector<char> a = {'R', 'U', 'D'};
    vector<char> b = {'L', 'U', 'D'};
    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0 && count(a.begin(), a.end(), s[i]) == 0)
        {
            cout << "No" << endl;
            return 0;
        }
        else if (i % 2 == 1 && count(b.begin(), b.end(), s[i]) == 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
local floor = math.floor
-- binary search
-- https://golang.org/src/sort/search.go?s=2246:2286#L49
local function find_min_true(n, f)
    local function loop(i, j)
        if i == j then
            return i
        end
        local h = floor((i + j) / 2)
        if f(h) then
            return loop(i, h)
        else
            return loop(h + 1, j)
        end
    end
    return loop(1, n + 1)
end


local N = io.read("*n", "*l")
local S = io.read("*l")
local sub = string.sub
local find = string.find
local function search()
    -- false if len is OK
    local function judge(len)
        for l1=1,N+1-2*len do
            local subst = sub(S, l1, l1+len-1)
            local result = find(S, subst, l1+len, true)
            --print("len", len, "l1", l1, "subst", subst, "result", result)
            if result then
                return false
            end
        end
        return true -- len is NG
    end
    return find_min_true(2500, judge)
end
local ans = search()
if ans == 0 then
    print(0)
else
    print(ans-1)
end

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

int n,m,W;
vector<pii> objs[10001];
vector<int> allObj;
int dp[1<<15];
const int INF=1000000000;
void solve(){
    cin>>n>>m>>W;
    for(int i=0;i<n;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int w;
            cin>>w;
            objs[i].push_back(make_pair(w,allObj.size()));
            allObj.push_back(w);
        }
    }
    dp[0]=0;
    for(int mask=1;mask<(1<<(allObj.size()));mask++){
        int bit=0;
        int allSum=0;
        int res=INF;
        for(int j=0;j<allObj.size();j++){
            bit+=(mask>>j)&1;
            if((mask>>j)&1)allSum+=allObj[j];
        }
        if(bit==1||allSum<=W)res=1;
        else{
            for(int j=((mask-1)&mask);j;j=((j-1)&mask)){
                int k=(mask-j);
                res=min(res,1+dp[j]+dp[k]);
            }
        }
        dp[mask]=res;
    }
    // ツ湘」ツづ個階ツつゥツづァツ渉氾板づ可つィツづォツつキ
    int curMask=0;
    int prvRank=-1;
    int sumCost=0;
    for(int i=n-1;i>=0;i--){
        if(objs[i].size()>=1||i==0){
            if(curMask!=0){
                int diff=prvRank-i;
                sumCost+=dp[curMask]*diff;
            }
            if(prvRank==-1)sumCost+=abs(i-(m-1));
            prvRank=i;
            // bitツ療アツづーツ更ツ新
            for(int j=0;j<objs[i].size();j++)curMask|=(1<<objs[i][j].second);
        }
    }
    if(objs[0].size()==allObj.size())cout<<0<<endl;
    else cout<<sumCost<<endl;
}

int main(){

    solve();

    return 0;
}

Measured memory_bytes: 1120
//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <bitset>
# include <queue>
# include <cstring>
# include <map>
# include <set>


#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
        
    int l,r,d;
    cin>>l>>r>>d;
    int ct= 0;
    for(int i = l; i <= r; i++){
        ct += (!(i%d));
    }
    cout << ct << endl;
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES

#pragma GCC optimize("Ofast,no-stack-protector") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") 
#pragma GCC optimize("unroll-loops") 
#pragma GCC optimize("fast-math")
  
#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
  
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
  
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}
  
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
  
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();   
    return 0;
}

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


Measured memory_bytes: 256
N = int(input())

matrix = []
for _ in range(N):
    matrix.append(list(map(int, input().split())))
    
dp_matrix = [[0, 0, 0]]

for i in range(N):
    dp_matrix_list = [0, 0, 0]
    for j in range(3):
        for k in range(3):
            if (j != k) and (dp_matrix_list[j] < dp_matrix[i][k] + matrix[i][j]):
                dp_matrix_list[j] = dp_matrix[i][k] + matrix[i][j]
    dp_matrix.append(dp_matrix_list)
    
print(max(dp_matrix[-1]))

Measured memory_bytes: 48468
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){
	fast;
	double n;
	cin>>n;
	cout<<fixed<<setprecision(9);
	double pi = 3.141592653;
	cout<<2*(pi)*n;
	return 0;
}

	


Measured memory_bytes: 3804
#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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

typedef long long ll;

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

void solve() {
    int N; cin >> N;
    set<int> primes;
    bool can_pairwise = true;
    int setwise = -1;
    REP(i,N) {
        int A; cin >> A;

        if (i == 0) setwise = A;
        else setwise = gcd(setwise,A);

        if(can_pairwise) {
            auto mp = prime_factor(A);
            for(const auto p: mp) {
                // cerr << p.first << endl;
                if(primes.count(p.first)) {
                    can_pairwise = false;
                } else primes.insert(p.first);
            }
        }
    }

    if(can_pairwise) cout << "pairwise coprime" << endl;
    else if (setwise == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

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

Measured memory_bytes: 7276
function check(n,x)
  if x==1
    return false
  end
  while n%x==0
    n=div(n,x)
  end
  n%x==1
end
function main()
  N=parse(Int,readline())
  ans=0
  for i=1:isqrt(N)
    if N%i==0
      if check(N,i)
        ans+=1
      end
      if i*i<N&&check(N,div(N,i))
        ans+=1
      end
    end
  end
  for i=1:isqrt(N-1)
    if (N-1)%i==0
      if i>1
        ans+=1
      end
      if i*i<N-1
        ans+=1
      end
    end
  end
  println(ans)
end
main()

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    string s;
    cin >> s;
    
    if(s[0] == s[1]) cout << "Bad" << endl;
    else if (s[1] == s[2]) cout << "Bad" << endl;
    else if (s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
    
    return 0;
}

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


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() 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)]
mod = 1000000007


s = S()


str1 = '10' * (len(s) // 2) + (len(s) % 2) * '1'
str2 = '01' * (len(s) // 2) + (len(s) % 2) * '0'



cnt1 = 0

for i in range(len(s)):
    if s[i] != str1[i]:
        cnt1 += 1


cnt2 = 0
for i in range(len(s)):
    if s[i] != str2[i]:
        cnt2 += 1



print(min(cnt1, cnt2))






Measured memory_bytes: 41840
max_diff = 0
max_diff_v = 0
sum = 0

def ceil(num)
  return ((num / 10) + 1) * 10 if num % 10 > 0
  num
end

5.times do |_|
  v = STDIN.gets.to_i
  ceil_v = ceil(v)
  diff = ceil_v - v
  max_diff, max_diff_v = diff, v if diff > max_diff
  sum += ceil_v
end

STDOUT.puts sum - ceil(max_diff_v) + max_diff_v

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    char a,b;
    cin>>a>>b;
    if(a<b)cout<<"<"<<endl;
    else if(a>b)cout<<">"<<endl;
    else cout<<"="<<endl;
    return 0;
}


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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int l,r,d;

int main()
{
    read(l),read(r),read(d);
    int x,y;
    if(l%d)x=l/d;
    else x=l/d-1;
    y=r/d;
    printf("%d\n",y-x);
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  vl cnt(100001);
  rep(i,n){
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll ans=0;
  rep(i,99999){
    ans=max(ans,cnt[i]+cnt[i+1]+cnt[i+2]);
  }
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

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

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

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int a[n], b[n], c[n];
	REP(i, n) cin >> a[i] >> b[i] >> c[i];
	
	int dp[n + 1][405][405];
	REP(i, n + 1) REP(j, 405) REP(k, 405) dp[i][j][k] = INF;
	
	dp[0][0][0] = 0;
	
	REP(i, n) {
		REP(j, 405) {
			REP(k, 405) {
				if (dp[i][j][k] == INF) continue;
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
			}
		}
	}
	
	int ans = INF;
	FOR(j, 1, 405) {
		FOR(k, 1, 405) {
			if (j * mb == k * ma) chmin(ans, dp[n][j][k]);
		}
	}
	
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 26496