akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Arrays;

public class Main {
    public static long a = (long)Math.pow(2, 60);
    public static long[] lst;
    public static long[] height;
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        //System.out.println(a);
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        lst = new long[N];
        
        Arrays.fill(lst, a);
        
        //System.out.println(lst[0]);
        
        height = new long[N];
        
        for (int i=0; i<N; i++) {
            height[i] = sc.nextInt();
        }
        
        //System.out.println(height[1]);
        
        System.out.println(tilAns(N));
    }
    static long tilAns(int n){
        if (lst[n-1] != a) {
            return lst[n-1];
        }
        
        if (n == 1) {
            lst[0] = 0;
            return 0;
        }
        
        if (n == 2) {
            lst[1] = tilAns(1) + Math.abs(height[1] - height[0]);
            return lst[1];
        }
        
        lst[n-1] = Math.min(tilAns(n-2) + Math.abs(height[n-1] - height[n-3]), tilAns(n-1) + Math.abs(height[n-1] - height[n-2]));
        return lst[n-1];
    }
}


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

int p,q,a,n;
int ans=0;

class Fraction{//ªð\·
public:
	int bo,shi;//ªêÆªq
	Fraction(int shi,int bo):bo(bo),shi(shi){};
};

Fraction my_plus(Fraction a,Fraction b){//ªÌ«µZ@ñª·éÆTLEµ½
	int new_bo=a.bo*b.bo;
	int new_shi=a.shi*(new_bo/a.bo)+b.shi*(new_bo/b.bo);
	return Fraction(new_shi,new_bo);
}

void dfs(int num,int now_bo,int mul,Fraction now){
	if(p*now.bo<q*now.shi) return;//} è@·ÅÉÚIÌlæèàå«¢ÌÅC±êÈã½ð«µÄà³Ê
	if(num>n) return;//§Àð´¦½
	if(p*now.bo==q*now.shi){//lªêv
		ans++;
		return;
	}
	for(int i=now_bo;i<12000;i++){//Ìlð«·
		if(mul*i>a) break;
		dfs(num+1,i,mul*i,my_plus(now,Fraction(1,i)));
	}
}


int main()
{
	while(cin>>p>>q>>a>>n && p!=0 && q!=0 && a!=0 && n!=0){
		ans=0;
		dfs(0,1,1,Fraction(0,2));
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 868
// AtCoder Begginer Contest 139 B
// https://atcoder.jp/contests/abc136/tasks/abc139_b

#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint A, B;
	cin >> A >> B;
	
	if (B == 1) {
		cout << 0 << endl;
	} else {
		uint C = (B - 1) / (A - 1);
		if (C * (A - 1) + 1 < B) {
			C++;
		}
		cout << C << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  char a,b;
  cin >> a >> b;
  if(a == b)cout << "H" << endl;
  else cout << "D" << endl;
}

Measured memory_bytes: 3532
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n,m = map(int,inp().split())
h = [int(u) for u in inp().split()]
adj = [[] for _ in range(n)]
for i in range(m):
    u,v = map(int,inp().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)
marked = [False for _ in range(n)]
cnt = 0
for u in range(n):
    if marked[u]: continue
    good = True
    for v in adj[u]:
        if h[u] <= h[v]:
            good = False
            break
        else: marked[v] = True
    if good: cnt += 1
out(str(cnt))

Measured memory_bytes: 94540
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll z = 0, a, b;
    cin >> n;
    while (n--) {
        cin >> a >> b;
        if (a < b) continue;
        else if (b + b > a) {
            if ((a - b) % 4 == 0 || (a - b) % 4 == 3) z ^= 1;
            continue;
        }
        while (a % b) {
            ll c = a / b + 1, d = a % b;
            a += d % c - d;
            if (a % b == 0) break;
            a = a * (b - 1) / b;
            //cout << a << ' ';
        }
        //cout << a / b << '\n';
        z ^= a / b;
    }
    if (z) cout << "Takahashi";
    else cout << "Aoki";
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int main(){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		char change[266]={0};
		rep(i,n){
			char a;
			char b;
			cin>>a>>b;
			change[a]=b;
		}
		
		
		int m;
		cin>>m;
		
		rep(i,m){
			char a;
			cin>>a;
			
			if(change[a]!=0){
				printf("%c",change[a]);
			}else{
				printf("%c",a);
			}
		}
		
		puts("");
	}
}

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

int main() {
  int N; cin >> N;
  vector<int> X(N);
  for (int i{}; i < N; ++i) {
    cin >> X[i];
  }

  int ans{1<<30};
  for (int i{1}; i <= 100; ++i) {
    int sum{};
    for (int j{}; j < N; ++j) {
      sum += pow(X[j] - i, 2);
    }
    ans = min(ans, sum);
  }

  cout << ans << endl;
}


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

int main() {
    int n,k; cin >> n >> k;
    int r,s,p; cin >> r >> s >> p;
    string t; cin >> t;
    //自分の出す手に変換
    for(int i=0; i<n; i++){
        if(t[i] == 'r') t[i] = 'p';
        else if(t[i] == 's') t[i] = 'r';
        else /*(t[i] == 'p')*/ t[i] = 's';
    }
    for(int i=0; i<n; i++){
        if(i+k<n){
            if(t[i] == t[i+k]) t[i+k] = 'x';
        }
    }
    long ans = 0;
    for(int i=0; i<n; i++){
        if(t[i] == 'r') ans += r;
        if(t[i] == 's') ans += s;
        if(t[i] == 'p') ans += p;        
    }
    //cout << t << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3716
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

void solve(string S) {
  for(auto &c: S) {
    c = 'x';
  }
  cout << S << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, L, A):
    for i in range(N - 1):
        if A[i] + A[i + 1] >= L:
            break
    else:
        print('Impossible')
        return
    print('Possible')
    for j in range(N - 1):
        if j == i:
            break
        print(j + 1)
    for j in range(N - 2, -1, -1):
        if j == i:
            break
        print(j + 1)
    print(i + 1)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, L = map(int, input().split())
    *A, = map(int, input().split())
    main(N, L, A)


Measured memory_bytes: 89636
n,m=map(int,input().split())
A=list(map(int,input().split()))
weight=[0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
    for a in A:
        if i+weight[a]<=n:
            dp[i+weight[a]]=max(dp[i+weight[a]],dp[i]*10+a)
print(dp[n])

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

using namespace std;
#define int long long

int32_t main()
{
	int n,w;
	cin>>n>>w;
	
	vector< pair<int,int> > a(n);
	int sum = 0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].first>>a[i].second;
		sum+=a[i].second;
	}
	
	
	int dp[sum+1];
	fill(dp,dp+sum+1,LONG_MAX);
	dp[0] = 0;
	

	for(int i=0;i<n;i++)
	{
		for(int j = sum;j>=a[i].second;j--)
		{
			if(dp[j-a[i].second]!=LONG_MAX)
			dp[j] = min(dp[j],dp[j-a[i].second]+a[i].first);
		}
	}
	int ans = 0;
	for(int i=1;i<=sum;i++)
	{
		if(dp[i]<=w)
		{
			ans = max(ans,i);
		}
	}

	cout<<ans;
}

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

using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int xorAll = 0;
    for (int i = 0; i < A.size(); ++i) {
        cin >> A[i];
        xorAll ^= A[i];
    }
    for (int i = 0; i < A.size(); ++i) {
        A[i] ^= xorAll;
        cout << A[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
int n,x,sum;
bitset<2000007>f;
int main(){
    cin>>n;
    f[0]=1;
    for(int i=1;i<=n;i++){
        cin>>x;
        f|=f<<x;
        sum+=x;
    }
 //   cout<<sum<<endl;
    for(int i=(sum+1)/2;i<=sum;i++){
        if(f[i]) {cout<<i<<endl;break;}
    }
    return 0;
}

Measured memory_bytes: 1024
/**
 * @author karayuu
 */
fun main() {
  val s = readLine()!!
  val a = s.slice(0..1).toInt() in 1..12
  val b = s.slice(2..3).toInt() in 1..12
  if (a && b) {
    println("AMBIGUOUS")
  } else if (a && !b) {
    println("MMYY")
  } else if (!a && b) {
    println("YYMM")
  } else {
    println("NA")
  }
}

Measured memory_bytes: 35828
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
    if i % 2:
        b[0] -= a[i]
    else:
        b[0] += a[i]
for i in range(1, n):
    b[i] = (a[i - 1] - b[i - 1] // 2) * 2
print(*b)

Measured memory_bytes: 64612
#include<bits/stdc++.h>
using namespace std;
main(){
  long long n,a;
  long long mins,FXmaxs=INT_MIN;
  cin>>n;
  cin>>mins;
  for(int i=1;i<n;i++){
    cin>>a;
    FXmaxs=max(FXmaxs,a-mins);
    mins=min(mins,a);
  }
  cout<<FXmaxs<<endl;
}

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

int main(void){
  int h,w,dame=0;
  cin >> h >> w;
  int delh[h]={},delw[w]={};
  string s[h];
  for(int i=0;i<h;i++){
      cin >> s[i];
      for(int j=0;j<w;j++){
          if(s[i][j]=='#'){
              dame++;
              break;
          }
      }
      if(dame==0){
          delh[i]++;
      }
      dame=0;
  }
  for(int j=0;j<w;j++){
      for(int i=0;i<h;i++){
          if(s[i][j]=='#'){
              dame++;
              break;
          }
      }
      if(dame==0){
          delw[j]++;
      }
      dame=0;
  }
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          if(delh[i]==0&&delw[j]==0){
              cout << s[i][j];
          }
      }
      if(delh[i]==0)      cout << endl;
  }
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(lambda a: int(a)*(-1), input().split()))

heapq.heapify(A)

for i in range(M):
    a = -heapq.heappop(A)//2
    heapq.heappush(A, -a)
    
print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
string s[107];
int a,b;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>b;
	a--;
	b--;
	for(int i=0;i<50;i++){
		for(int j=0;j<100;j++) s[i]+='.';
	}
	for(int i=50;i<100;i++){
		for(int j=0;j<100;j++) s[i]+='#';
	}
	for(int i=0;i<25;i++){
		for(int j=0;j<50;j++){
			if(b>0){
				b--;
				s[i*2][j*2]='#';
			}
		}
	}
	for(int i=49;i>=25;i--){
		for(int j=0;j<50;j++){
			if(a>0){
				a--;
				s[i*2][j*2]='.';
			}
		}
	}
	cout<<"100 100\n";
	for(int i=0;i<100;i++){
		cout<<s[i]<<"\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

int main(){
	while(1){
		int t;
		cin >> t;
		if(!t) break;

		int n;
		cin >> n;
		rep(i, n){
			int s, f;
			cin >> s >> f;
			t -= (f-s);
		}
		if( t <= 0) cout << "OK" << endl;
		else cout << t << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, m;
string A[50], B[50];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> A[i];
  FOR(i, 0, m) cin >> B[i];
  FOR(i, 0, n+1-m)FOR(j, 0, n+1-m){
    FOR(k, 0, m)FOR(l, 0, m) if(B[k][l]!=A[i+k][j+l]) goto bad;
    cout << "Yes" << endl;
    return 0;
    bad:;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
type bs_tree = Nil | Node of node and
     node = {
         key:int;
         mutable left:bs_tree;
         mutable right:bs_tree
       };;

let new_node key = {key=key;left=Nil;right=Nil};;

let insert t z =
  let rec loop y = function
      Nil -> y
    | Node x ->
       if z.key < x.key then
         loop (Node x) (x.left)
       else
         loop (Node x) (x.right)
  in
  let y = loop t t in
  match y with
    Nil -> (Node z)
  | Node y ->
     if z.key < y.key then
       y.left <- (Node z)
     else
       y.right <- (Node z)
    ;t
;;

let rec print_in = function
    Nil -> ()
  | Node x ->
     print_in (x.left);
     Printf.printf " %d" x.key;
     print_in (x.right)
;;

let rec print_pre = function
    Nil -> ()
  | Node x ->
     Printf.printf " %d" x.key;
     print_pre (x.left);print_pre (x.right)
;;

let () =
  let n = read_int () in
  let rec read t = function
      0 -> ()
    | i ->
       let com = Scanf.scanf "%s" (fun x -> x) in
       if com = "insert" then begin
           let arg = Scanf.scanf " %d\n" (fun x -> x) in
           let z = new_node arg in
           read (insert t z) (i-1)
         end
       else if com = "print" then begin
           let _ = Scanf.scanf "%s\n" (fun x -> x) in
           print_in t;print_newline ();
           print_pre t;print_newline ();
           read t (i-1)
         end
       else ()
  in read Nil n
;;

Measured memory_bytes: 28148
def powerf(a, b, md):
    """a^b mod md"""
    if b == 0:
        return 1

    if b % 2 == 0:
        pf2 = powerf(a, b // 2, md)
        return pf2**2 % md
    else:
        return (a * powerf(a, b-1, md)) % md


def comb(n, k, md):
    """nCk mod md"""
    from math import factorial

    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 and k == 0:
        return 1

    a = factorial(n) % md
    b = factorial(k) % md
    c = factorial(n-k) % md
    return a * powerf(b, md-2, md) * powerf(c, md-2, md) % md


M = 10**9 + 7

n, m, k = list(map(int, input().split()))
ans = 0
for dx in range(1, m):
    ans += dx * (m - dx) * n**2

for dy in range(1, n):
    ans += dy * (n - dy) * m**2

print(ans * comb(n*m-2, k-2, M) % M)

Measured memory_bytes: 5512
N = int(input())
S = input()
cnt = 0

for i in range(10):
    x100 = S.find(str(i))
    if x100 == -1:
        continue
    for j in range(10):
        x10 = S.find(str(j), x100 + 1)
        if x10 == -1:
            continue
        for k in range(10):
            if S.find(str(k), x10 + 1) != -1:
                cnt += 1

print(cnt)


Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const ll N = 1000;
int n, a[N] ;
vector<int> ans ;
int main()
{
	cin >> n ;
	for(int i = 1; i <= n ; i ++)
		cin >> a[i] ;
	for(int i = n ; i >= 1 ; i --){
		bool no = 0 ; 
		for(int j = i ; j >= 1 ; j --){
			if(a[j] == j){
				ans.push_back(j) ;
				for(int x = j ; x <= i ; x ++)
					a[x] = a[x+1] ;
				no = 1 ;
				break ;
			}
		}
		if(no == 0)
			return cout << -1, 0 ; 
	}
	for(int i = ans.size() - 1 ; i >= 0 ; i --)
		cout << ans[i] << endl ;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

K, N = MI()
A = LI()
A_dif = []

for i in range(1, N):
    a = A[i] - A[i - 1]
    A_dif.append(a)
A_dif.append(A[0] + K - A[-1])

print(K - max(A_dif))

Measured memory_bytes: 124628
#include<iostream>
#include<cmath>
using namespace std;
int n, q, a[100009], b[100009], c[100009], d[100009], e[100009];
int main() {
	cin >> n >> q; c[0] = 1;
	for (int i = 1; i <= q; i++) { cin >> a[i] >> b[i]; if (c[i - 1] == a[i])c[i] = b[i]; else if (c[i - 1] == b[i])c[i] = a[i]; else c[i] = c[i - 1]; }
	for (int i = 1; i <= n; i++) { d[i] = i; if (abs(d[i] - c[q]) <= 1)e[i] = 1; }
	for (int i = q; i >= 1; i--) {
		swap(d[a[i]], d[b[i]]);
		e[d[c[i - 1] - 1]] = 1; e[d[c[i - 1]]] = 1; e[d[c[i - 1] + 1]] = 1;
	}
	int cnt = 0; for (int i = 1; i <= n; i++)cnt += e[i];
	cout << cnt << endl;
	return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

double ***MEMO;

double counter(int N, int i, int j, int k) {
    // printf("%d, %d, %d\n", i, j, k);
    if (MEMO[i][j][k] != -1) {
        return MEMO[i][j][k];
    }else {
        double count = 0.0;

        if (i > 0) count += i * counter(N, i-1, j, k);
        if (j > 0) count += j * counter(N, i+1, j-1, k);
        if (k > 0) count += k * counter(N, i, j+1, k-1);

        double res = (count + N) / (i + j + k);
        MEMO[i][j][k] = res;
        return res;
    }
}

int main() {
    int N, sushis[3];
    scanf("%d", &N);

    for (int i = 0; i < 3; i++) sushis[i] = 0;

    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        sushis[tmp-1]++;
    }

    MEMO = (double ***)malloc(sizeof(double **) * (N+1));
    for (int i=0; i<N+1; i++) {
        MEMO[i] = (double **)malloc(sizeof(double *) * (sushis[1] + sushis[2] + 1));
        for (int j=0; j < sushis[1]+sushis[2]+1; j++) {
            MEMO[i][j] = (double *)malloc(sizeof(double) * sushis[2]+1);
            for (int k=0; k<sushis[2]+1; k++) {
                MEMO[i][j][k] = -1.0;
            }
        }
    }
    MEMO[0][0][0] = 0;

    printf("%.20lf\n", counter(N, sushis[0], sushis[1], sushis[2]));

    return 0;
}

Measured memory_bytes: 214656
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	
	lli a, b, c, d, gcd, lcm, ans;
	
	cin >> a >> b >> c >> d;
	
	ans = (b/c) - (a-1)/c;
	ans += ((b/d) - (a-1)/d);
	
	gcd = __gcd(c, d);
	lcm = (c*d) / gcd;
	
	ans -= ((b/lcm) - (a-1)/lcm);
	
	cout << (b-a+1) - ans << "\n";
	
	return 0;
}


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


int main(){
    ll a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

    









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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;

#define MX 1000100

ll fact[MX], dfact[MX];

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

void pre_calc()
{
	fact[0] = dfact[0] = 1;
	for (int i(1); i < MX; ++i)
	{
		fact[i] = fact[i - 1] * i % mod;
		dfact[i] = bin_pow(fact[i], mod - 2);
	}
}

ll C(ll n, ll k) { return fact[n] * dfact[n - k] % mod * dfact[k] % mod; }

int main()
{
	pre_calc();
	int n;
	cin >> n;
	ll ans(0);
	ll pre(0);
	for (int m(1); m < n; ++m)
		if (m * 2 >= n) {
			ll d = (2 * m - n) % mod;
			ll c = C(m - 1, d);
			ll cur = (mod - pre + C(m - 1, d) * fact[m] % mod * fact[n - 1 - m] % mod) % mod;
			pre += cur; pre %= mod;
			ans += cur * m; ans %= mod;
		}
	cout << ans;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	cout << (n == 3 || n == 5 || n == 7 ? "YES" : "NO") << endl;
	
	return 0;
}


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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)

vector<int> subset;
int solve(int grid[][15], int i, int n, int m, int x)
{
	if(i == n)
	{
		bool is_possible = true;
		int cost = 0;
		int sum[m] = {0};
		for(int p : subset)
		{	
			cost += grid[p][0];
			rep(j,1,m+1) sum[j-1] += grid[p][j];
		}
		for(int q : sum)
		{
			if(q < x)
			{
				is_possible = false;
			}
		}
		if(!is_possible) return INT_MAX;
		else return cost;
	}
	subset.push_back(i);
	int included = solve(grid, i+1, n, m, x);
	subset.pop_back();
	int not_included = solve(grid, i+1, n, m, x);
	return min(included, not_included);
}				

int main()
{
	FASTIO
	int n, m, x;
	cin >> n >> m >> x;
	int sum[m] = {0};
	int grid[n][15]; // grid[i][0] is the cost of the i th book
	rep(i,0,n)
	{
		rep(j,0,m+1)
		{
			cin >> grid[i][j];
			sum[j-1] += grid[i][j];
		}
	}
	//for(auto k : sum) cout << x << " ";
	//cout << "\n";
	bool is_achievable = true;
	for(auto k : sum)
	{	
		if(k < x)
		{
			is_achievable = false;
			break;
		}
	}
	if(!is_achievable) cout << "-1\n";
	else
	{
		cout << solve(grid, 0, n, m, x) << "\n";
	} 
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=1;i<=n;i++){
        cin>>arr[i-1];
    }

    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[0]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i-2]-arr[i-1]),dp[i-2]+abs(arr[i-3]-arr[i-1]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int n,k;
int main(){
	cin >>  n >> k ;
	int A[n];
	rep(i,n){
	cin>>A[i];
	}
	sort(A,A+n);
	int ans = 0;
	int count = 0;
	for(int i = n-1; i>=0; i--){
			count++;	
			ans+=A[i];
			if(count==k){
				break;
			}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll i,o,t,j,l,s,z;
  std::cin>>i>>o>>t>>j>>l>>s>>z;

  ll ans=o+(i/2)*2+(j/2)*2+(l/2)*2;

  if(i==0||l==0||j==0){
    std::cout<<ans;
    return 0;
  }

  chmax(ans,o+((i-1)/2)*2+((j-1)/2)*2+((l-1)/2)*2+3);

  std::cout<<ans;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll n;
    cin >> n;
    ll INF = 1e+9+7;
    ll ans = 1;
    ll z = 3, y = 0;
    vector<ll> c(100010, 0);
    for(ll i = 1; i <= n; i++){
        ll a;
        cin >> a;
        if(a==0) ans = ans*(3-c[a])%INF;
        else ans = ans*(c[a-1]-c[a])%INF;
        c[a]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"
#define ll long long
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define pb push_back
#define pb2 pop_back
#define ff first
#define ss second
#define debug(x) cout<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define IO ios_base::sync_with_stdio(0);cin.tie(NULL);
const char nl = '\n';
int main(){
    string s,t;cin>>s>>t;
    ll c=0;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i])c++;
    }
    cout<<c<<nl;
}


Measured memory_bytes: 3920
a,b,c=map(int,raw_input().split())
z=0
if a%2==1 or b%2==1 or c%2==1:
    z=0
else:
 while a!=b or b!=c or a!=c:
    l=[a,b,c]
    l.sort()
    if a%2==1 or b%2==1 or c%2==1:
        break
    else:
        an=b/2+c/2
        bn=a/2+c/2
        cn=a/2+b/2
        ln=[an,bn,cn]
        ln.sort()
        if ln==l:
            z=-1
            break
        else:
            a,b,c=ln
            z+=1
 if a==b and a==c:
    z=-1
print z


Measured memory_bytes: 2692
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

int main()
{
	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < a.size(); i++) cin >> a[i];

	// 累積GCD
	vector<int> left(n + 1), right(n + 1);
	for (int i = 0; i < n; i++) left[i + 1] = GCD(left[i], a[i]);
	for (int i = n - 1; i >= 0; i--) right[i] = GCD(right[i + 1], a[i]);

	int res = 0;
	for (int i = 0; i < n; i++)
	{
		int l = left[i];
		int r = right[i + 1];

		res = max(res, GCD(l, r));
	}
	cout << res << endl;
}


Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

    InputStream is;
    PrintWriter out;
    
    void solve(){
        //Enter code here
        int n = ni() , m = ni();
        while (m-- > 0) {
            n += 1;
            if (n == 24) n = 0;
        }
        out.println(n);
    }
    public static void main(String[] args) {
        Main play = new Main();
        play.run();
    }
    public void run(){
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }
    
    byte input[] = new byte[1024];
    int len = 0,ptr = 0;
    int readByte() {
        if(ptr >= len){
            ptr = 0;
            try{
                len = is.read(input);
            } catch(IOException e){
                throw new InputMismatchException();
            }
            if(len <= 0){
                return -1;
            }
        }
        return input[ptr++];
    }
    boolean isSpaceChar(int c) {
        return !( c >= 33 && c <= 126 );
    }
    int skip(){
        int b = readByte();
        while(b != -1 && isSpaceChar(b)){
            b = readByte();
        }
        return b;
    }
    
    char nc() {
        return (char)skip();
    }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    int ni() {
        int n = 0,b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){
            b = readByte();
        }
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        while(b >= '0' && b <= '9'){
            n = n * 10 + (b - '0');
            b = readByte();
        }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;
        int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){
            b = readByte();
        }
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        while(b>='0' && b<='9'){
            n = n * 10 + (b - '0');
            b = readByte();
        }
        return minus ? -n : n;
    }
    double nd() {
        return Double.parseDouble(ns());
    }
    float nf() {
        return Float.parseFloat(ns());
    }
    int[] na(int n){
        int a[] = new int[n];
        for(int i = 0;i < n;i++){
            a[i] = ni();
        }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i , b = skip();
        for (i = 0;i < n;i++){
            if (isSpaceChar(b)){
                break;
            }
            c[i] = (char)b;
            b = readByte();
        }
        return i == n ? c : Arrays.copyOf(c , i);
    }
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> W(N + 1), B(N + 1);
  W.at(N) = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (S.at(i) == '.') W.at(i) = W.at(i + 1) + 1;
    else W.at(i) = W.at(i + 1);
  }
  B.at(0) = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '#') B.at(i + 1) = B.at(i) + 1;
    else B.at(i + 1) = B.at(i);
  }
  int ans = 1000000;
  for (int i = 0; i <= N; i++) {
    ans = min(ans, W.at(i) + B.at(i));
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice = 0; int bob = 0;
  int ans = 0;
  for(int j = 0;j < n;j++){
    if(j%2 == 0){
      alice += a.at(j);
    }else{
      bob += a.at(j);
    }
  }
    ans = alice - bob;
    
  cout << ans << endl;    
  
  return 0;
}

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

output = A[1]
for i in range(1, N):
    output = output * A[i]
    if output > pow(10, 18):
        output = -1
        break

for i in range(N):
    if A[i] == 0:
        output = 0

print(output)


Measured memory_bytes: 21540
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	string res = "APPROVED\n";
	REP(i, N) {
		int A;
		cin >> A;
		if (A % 2) continue;
		if (A % 3 && A % 5) res = "DENIED\n";
	}
	cout << res;

	return 0;
}

							

Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for a_plus_b in range(min(N, K) + 1):
    for a in range(a_plus_b + 1):
        b = a_plus_b - a
        gems = V[:a]
        if b > 0:
            gems += V[-b:]
        gems.sort()
        negative_gems = [g for g in gems if g < 0]
        ans = max(ans, sum(gems) - sum(negative_gems[:K - a_plus_b]))
print(ans)


Measured memory_bytes: 3064
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int n;

int mem[10][10];

pair<int, int> dig(int k) {
	int d1 = k % 10;
	int d2;
	while (k) {
		d2 = k % 10;
		k /= 10;
	}
	return make_pair(d2, d1);
}


int g(pair<int, int> p) {
	swap(p.first, p.second);
	int & ret = mem[p.first][p.second];
	if (ret != -1) {
		return ret;
	}
	ret = 0;
	for (int i = 1; i <= n; i++) {
		pair<int, int> cur = dig(i);
		if (cur == p) {
			ret++;
		}
	}
	return ret;

}

int main() {
	memset(mem, -1, sizeof(mem));
	cin >> n;
	ll ret = 0;
	for (int i = 1; i <= n; i++) {
		ret += g(dig(i));
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct uftree{
	int par[200005];
	int rank[200005];
	uftree(){
	}
	void init(int n){
		for(int i=0;i<n;i++){
			par[i]=i;
			rank[i]=0;
		}
	}
	int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			par[x]=y;
		}else{
			if(rank[x]==rank[y])rank[x]++;
			par[y]=x;
		}
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}
};

uftree uf;

int n,m;
vector<int> ai;
int a[100005],b[100005];
int c[100005];
P p[100005];
int l[200005],r[200005];
vector<P> G[100005];
bool flag[100005];
vector<int> ans;

int dfs(int v,int pr){
	flag[v]=true;
	int sum=c[v];
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i].first;
		if(pr!=nv){
			sum+=dfs(nv,v);
		}
	}
	return sum;
}

int dfs2(int v,int pr){
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i].first;
		if(pr!=nv){
			int gg=dfs2(nv,v);
			if(gg==1){
				ans.push_back(G[v][i].second);
				c[v]^=1;
				c[nv]^=1;
			}
		}
	}
	return c[v];
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		ai.push_back(a[i]);
	}
	sort(ai.begin(),ai.end());
	for(int i=0;i<n;i++){
		p[i]=P(a[i],b[i]);
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		c[i]=p[i].second;
	}
	for(int i=n;i>=1;i--){
		c[i]^=c[i-1];
	}
	uf.init(n+1);
	for(int i=0;i<m;i++){
		scanf("%d%d",&l[i],&r[i]);
		l[i]=lower_bound(ai.begin(),ai.end(),l[i])-ai.begin();
		r[i]=upper_bound(ai.begin(),ai.end(),r[i])-ai.begin();
		if(!uf.same(l[i],r[i])){
			uf.unite(l[i],r[i]);
			G[l[i]].push_back(P(r[i],i));
			G[r[i]].push_back(P(l[i],i));
		}
	}
	memset(flag,false,sizeof(flag));
	for(int i=0;i<=n;i++){
		if(flag[i])continue;
		int ct=dfs(i,-1);
		if(ct%2==1){
			printf("-1\n");
			return 0;
		}
		dfs2(i,-1);
	}
	printf("%d\n",ans.size());
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		printf("%d%c",ans[i]+1,i+1==ans.size()?'\n':' ');
	}
	if(ans.size()==0){
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 11768
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ll gcd(ll a, ll b)
{
    if (a < b) return gcd(b, a);
    ll r;
    while (r = a % b)
    {
        a = b;
        b = r;
    }
    return b;
}

bool Solve(ll A, ll B, ll C, ll D)
{
    if (B > A)
    {
        return false;
    }
    else if (B > D)
    {
        return false;
    }
    else if (C >= B)
    {
        return true;
    }

    assert(B <= A && B <= D && C < B);

    const ll g = gcd(B, D);
    const ll tmp = B - g + (A % g);
    return tmp <= C;
}

void _main()
{
    int T;
    cin >> T;
    rep(i, 0, T)
    {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;

        cout << (Solve(A, B, C, D) ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int R = 0;
    int B = 0;
    for(char c : S) {
        if(c == 'R') R++;
        else if(c == 'B') B++;
    }

    cout << (R > B ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



double solve(long long L) {
    return (double)(L) * (double)(L) * (double)(L) / 27;
}

int main() {
    long long L;
    while (cin >> L)
        cout << fixed << setprecision(10) << solve(L) << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define dump(x) cerr << #x << " : " << x << '\n'

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int d = a - b;
    cout  << max(0, c - d) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    vector<int>ds(N);
    for (int i=0; i<N; i++)cin >> ds[i];
    sort(all(ds));
    int last = -1;
    int ans = 0;
    for (int i=0; i<N; i++){
        if(last != ds[i]){
            ans++;
            last = ds[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=105;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}int n,Mx[MAXN],fa[MAXN],dep[MAXN],rt1,rt2;vector<int>G[MAXN];
int DFS(int x,int f){
	fa[x]=f;int Mx=x;
	for(auto y:G[x])if(y!=f){dep[y]=dep[x]+1;int t=DFS(y,x);dep[t]>dep[Mx]?Mx=t:0;}
	return Mx;
}void DFS2(int x,int f){
	int tmp=0;
	for(auto y:G[x])if(y!=f)dep[y]=dep[x]+1,DFS2(y,x),tmp++;
	Mx[dep[x]]=max(Mx[dep[x]],tmp);
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n-1){int x=read(),y=read();G[x].push_back(y),G[y].push_back(x);}
	dep[0]=1,rt1=DFS(1,0),dep[rt1]=1,rt2=DFS(rt1,0);int len=(dep[rt2]+1)>>1;
	cout<<len<<" ";
	if(dep[rt2]&1){
		int u=rt2;Rep(i,1,len-1)u=fa[u];
		dep[u]=1,DFS2(u,0);ll s=1,ans;
		Rep(i,1,len-1)s=s*Mx[i];ans=s;
		for(int v:G[u]){
			memset(Mx,0,sizeof(Mx));
			Mx[1]=2,dep[u]=dep[v]=2,DFS2(u,v),DFS2(v,u);
			ll s=1;Rep(i,1,len)s*=Mx[i];ans=min(ans,s);
		}cout<<ans<<'\n';
	}else{
		int u=rt2,v;Rep(i,1,len-1)u=fa[u];v=fa[u];
		Mx[1]=2,dep[u]=dep[v]=2,DFS2(u,v),DFS2(v,u);
		ll s=1;Rep(i,1,len)s*=Mx[i];cout<<s<<'\n';
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int vec[200004],vv[200004];
int main() {
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  int N;
  cin >> N;
  for (int X=0; X<N-1; X++){
    cin >> vec[X];
    vv[vec[X]-1]+=1;
  }
  for (int X=0; X<N; X++){
    cout << vv[X] << endl;
  }
}


Measured memory_bytes: 5136
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const int INF = 1e9 + 10;
const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;

        int dx = tx - sx;
        int dy = ty - sy;

        cout<<string(dy,'U')<<string(dx,'R');
        cout<<string(dy,'D')<<string(dx,'L');
        cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
        cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
        cout<<endl;



return 0;
}







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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	vector<ll> v(5);
	REP(i, 5) cin >> v[i];
	std::cout << find(ALL(v), 0) - v.begin() + 1 << std::endl;
	return 0;
}


Measured memory_bytes: 3564