akhauriyash/Code-Regression huggingface dataset:
#<B>
s = input()
a = s[:len(s)//2]
a = a[::-1]
if len(s) % 2 == 0:
    b = s[len(s) // 2:]
else:
    b = s[len(s) // 2 + 1:]

ans = 0
for (x, y) in zip(a, b):
    if x != y:
        ans += 1
print(ans)
        


Measured memory_bytes: 9052
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long double ld;
typedef long long int lli;
typedef pair <lli, lli> pii;
#define pb push_back
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
#define all(x) x.begin(), x.end()
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const lli N = 3e3 + 10, N2 = 2e5, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300;
const ld PI = 3.141592653589793;

lli dp[N][N];
pii par[N][N];
string ans, s, t;

void p (lli x, lli y) {
	if (!x || !y)
		return;
	if (s[x - 1] == t[y - 1])
		ans += s[x - 1];
	p (par[x][y].f, par[x][y].s);
}

int32_t main() {
	fast;
	cin >> s >> t;
	for (lli i = 1; i <= s.size(); i++)
		for (lli j = 1; j <= t.size(); j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				par[i][j] = {i - 1, j - 1};
				continue;
			}
			dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
			if (dp[i][j] == dp[i - 1][j])
				par[i][j] = {i - 1, j};
			else
				par[i][j] = {i, j - 1};
		}
	p (s.size(), t.size());
	reverse (all(ans));
	cout << ans << '\n';
	return 0;
}


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

#define TRUE	(1)
#define FALSE	(0)

int count_num(int *array, int elem, int key);
void copy_array(int *to_array, int *from_array, int elem);
void print_array(int *a, int elem);
int is_equall_array(int *a, int *b, int elem);

int main(void)
{
	int i;
	int n;
	int *s, *tmp, *prev;
	int op_count;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0) break;
		
		s = (int *)malloc(sizeof(int) * n);
		tmp = (int *)malloc(sizeof(int) * n);
		prev = (int *)malloc(sizeof(int) * n);
	
		for (i = 0; i < n; i++) scanf(" %d", (s + i));
		
		for (op_count = 0; 1; op_count++){
			for (i = 0; i < n; i++) *(tmp + i) = count_num(s, n, *(s + i));
			
			copy_array(prev, s, n);
			copy_array(s, tmp, n);
			
			if (is_equall_array(s, prev, n) == TRUE) break;
		}
		
		printf("%d\n", op_count);
		print_array(s, n);
		
		free(s), free(tmp), free(prev);
	}
	
	
	return (0);
}

int count_num(int *array, int elem, int key)
{
	int i, cnt;
	
	for (i = cnt = 0; i < elem; i++){
		if (*(array + i) == key) cnt++;
	}
	
	return (cnt);
}

void copy_array(int *to_array, int *from_array, int elem)
{
	int i;
	
	for (i = 0; i < elem; i++) *(to_array + i) = *(from_array + i);
}

void print_array(int *a, int elem)
{
	int i;
	
	for (i = 0; i < elem; i++){
		printf("%d%c", *(a + i), (i != (elem - 1)? ' ' : '\n'));
	}
}

int is_equall_array(int *a, int *b, int elem)
{
	int result;
	int i;
	
	for (result = TRUE, i = 0; i < elem; i++){
		if (*(a + i) != *(b + i)){
			result = FALSE;
			break;
		}
	}
	
	return (result);
}


Measured memory_bytes: 2024
//@sakshjha
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define pi 3.14159265358979
const ll MOD = 1000000007;
const ll N=200005;
int main()
{
    IOS
    ll n;
    cin>>n;
    ll a[n],i,dp[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for(i=1; i<n; i++)
    {
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        if(i-2>=0)
        {
            dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A, B;
        
        A = scan.nextInt();
        B = scan.nextInt();
        
        if ((A * B) % 2 == 0) {
            System.out.println("No");
        }
        else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23892
use num::Num;
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        q: usize,
        c: [usize; n],
        queries: [(Usize1, Usize1); q],
    }
    let mut pi: Vec<Option<usize>> = vec![None; n+1];
    let mut ps = vec![vec![]; n];
    for i in 0..n {
        if let Some(num) = pi[c[i]] {
            ps[num].push(i);
        }
        pi[c[i]] = Some(i);
    }
    let mut qs = vec![vec![]; n];
    for i in 0..q {
        let (l, r) = queries[i];
        qs[l].push((r, i));
    }

    let mut ans = vec![0; q];
    let mut d: BIT<usize> = BIT::new(n);
    for x in (0..n).rev() {
        for &y in &ps[x] {
            d.add(y, 1);
        }
        for &query in &qs[x] {
            let r = query.0;
            let i = query.1;
            ans[i] = (r-x+1) - d.sum(r);
        }
    }

    for &a in &ans {
        println!("{}", a);
    }
}

struct BIT<T> {
    n: usize,
    d: Vec<T>,
}

impl<T> BIT<T>
where
    T: Num + Copy + Clone,
{
    fn new(n: usize) -> Self {
        BIT {
            n: n,
            d: vec![T::zero(); n + 1],
        }
    }

    fn add(&mut self, mut i: usize, x: T) {
        i += 1;
        while i <= self.n {
            self.d[i] = self.d[i] + x;
            i += i & i.wrapping_neg();
        }
    }

    fn sum(&self, mut i: usize) -> T {
        let mut x = T::zero();
        i += 1;
        while i != 0 {
            x = x + self.d[i];
            i -= i & i.wrapping_neg(); 
        }
        x
    }

    fn sums(&self, l: usize, r: usize) -> T {
        self.sum(r - 1) - self.sum(l - 1)
    }
}


Measured memory_bytes: 90984
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
double dp[100001];
int main() {
	int N, K;
	cin >> N >> K;
	dp[K] = 1;
	for (int i = K - 1; i >= 1; i--) {
		dp[i] = dp[min(i * 2, K)] * 0.5;
	}
	double ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i >= K) {
			ans += 1.0 / N;
		}
		else {
			ans += dp[i] * (1.0 / N);
		}
	}
	printf("%.15lf\n", ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int MAXN = 1e4;
const int INF = 1e9;

int dp[N];
int val[N], cost[N];

int main() {
	int h, n; cin >> h >> n;
	for (int i = 0; i < n; i++)
		cin >> val[i] >> cost[i];
	fill(dp, dp + N, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = val[i]; j <= MAXN; j++)
			dp[j] = min(dp[j], dp[j - val[i]] + cost[i]);
	cout << *min_element(dp + h, dp + N);
}

Measured memory_bytes: 640
# Here your code !
a,b = gets.chomp.split(" ").map{|u| u.to_i}
count = 0
if (b < 0)
    puts ((b-a +1)%2 == 0)? "Positive" : "Negative"
else
    puts (a<0)? "Zero" : "Positive" 
end

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=998244353;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
 string s;
  cin >> s;
  ll n=s.length();
 if(n%2) {
   cout << "No" << endl;
 }
   else {
   string h="";
   rep(i,0,n/2) h+="hi";
   if(s==h) cout << "Yes" << endl;
   else cout << "No" << endl;
 } 
  
 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


//AGC003
//NがあったらSがないといけない
//WがあったらEがないといけない
int main() {
    string S;
    cin >> S;

    bool hasN = false;
    bool hasW = false;
    bool hasS = false;
    bool hasE = false;

    REP(i,S.size())
    {
        if(S[i] == 'N')hasN = true;
        if(S[i] == 'W')hasW = true;
        if(S[i] == 'S')hasS = true;
        if(S[i] == 'E')hasE = true;
    }

    string res = "Yes";

    if(hasN != hasS)
    {
        res = "No";
    }

    if(hasW != hasE)
    {
        res = "No";
    }

    cout << res << endl;
    
}

Measured memory_bytes: 256
class Dice:
    same_dice_index = ((0, 1, 2, 3, 4, 5), (0, 2, 4, 1, 3, 5), (0, 3, 1, 4, 2, 5),
                       (0, 4, 3, 2, 1, 5), (1, 0, 3, 2, 5, 4), (1, 2, 0, 5, 3, 4),
                       (1, 3, 5, 0, 2, 4), (1, 5, 2, 3, 0, 4), (2, 0, 1, 4, 5, 3),
                       (2, 1, 5, 0, 4, 3), (2, 4, 0, 5, 1, 3), (2, 5, 4, 1, 0, 3),
                       (3, 0, 4, 1, 5, 2), (3, 1, 0, 5, 4, 2), (3, 4, 5, 0, 1, 2),
                       (3, 5, 1, 4, 0, 2), (4, 0, 2, 3, 5, 1), (4, 2, 5, 0, 3, 1),
                       (4, 3, 0, 5, 2, 1), (4, 5, 3, 2, 0, 1), (5, 1, 3, 2, 4, 0),
                       (5, 2, 1, 4, 3, 0), (5, 3, 4, 1, 2, 0), (5, 4, 2, 3, 1, 0))

    def __init__(self, str_list):
        self.faces = str_list

    def is_same(self, dice):
        for i in Dice.same_dice_index:
            for n, j in enumerate(i):
                if dice.faces[n] != self.faces[j]:
                    break
            else:
                return True
        return False

    def is_unique(self, dices_list):
        for i in dices_list:
            if self.is_same(i):
                return False
        return True

import sys

n = int(sys.stdin.readline())

dices = []

for i in range(n):
    str_list = sys.stdin.readline().split()
    new_dice = Dice(str_list)
    if not new_dice.is_unique(dices):
        print('No')
        break
    dices.append(new_dice)
else:
    print('Yes')

Measured memory_bytes: 7872
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;



int main(){
    int a,b;
    cin>>a>>b;
    int c=b-a;
    c*=c+1;
    c/=2;
    cout<<c-b<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int k, r;
    cin >> k >> r;
    if (k < 10)
    {
        cout << (r + (100 * (10 - k))) << endl;
        return 0;
    }
    else
    {
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(), x.end()
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
T ceil(T a, T b) { return a / b + !!(a % b); }

string t;

string solve()
{
    int n = t.size();
    rep(i, n)
    {
        if(t[i]=='?'){
             t[i]='D';
        }
    }

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

    cin >> t;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3776
a=sorted(list(map(int,input().split())))
x=a[2]-a[0];y=a[2]-a[1]
if x%2==y%2:
  print((x-y)//2+y)
else:
  if x%2==0:
    print(x//2+(y+1)//2+1)
  else:
    print(y//2+(x+1)//2+1)

Measured memory_bytes: 3060
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int n;cin>>n;
cout<<ceil((double)n/(double)2);

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,x;
	int flag = 0;
	int A[3][3];
	for(int i=0;i<3;i++){
		scanf("%d %d %d",&A[i][0],&A[i][1],&A[i][2]);
	}
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&x);
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(A[j][k] == x)
					A[j][k] = 0;
			}
		}
	}
	for(int i=0;i<3;i++){
		if(A[0][i]==A[1][i]&&A[1][i]==A[2][i]&&A[2][i]==0)
			flag = 1;
	}
	for(int i=0;i<3;i++){
		if(A[i][0]==A[i][1]&&A[i][1]==A[i][2]&&A[i][2]==0){
			flag = 1;
		}
	}
	if(A[0][0]==A[1][1]&&A[1][1]==A[2][2]&&A[2][2]==0){
  		flag = 1;
  	}
  	if(A[0][2]==A[1][1]&&A[1][1]==A[2][0]&&A[2][0]==0){
      	flag = 1;
    }
    if(flag==1)
    	printf("Yes");
    else
    	printf("No");
}

Measured memory_bytes: 128
while True:
    t, y = map(int, input().split())
    if t == 0 and y == 0:
        break
    for i in range(t):
        if i == 0 or i == (t - 1):
            print("#"*y)
        else:
            print("#{}#".format("."* (y - 2)))

    print("")


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

int N,M;
vector<int>G[100];
bool used[100];
bool dfs(int p,int s){
    used[p]=true;
    bool ret=false;
    for(int i=0;i<G[p].size();i++){
        int to=G[p][i];
        if(to==s)return true;
        if(used[to])continue;
        ret|=dfs(to,s);
    }

    return ret;
}

int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
    }

    bool f=false;
    for(int i=0;i<N;i++){
        fill_n(used,N,false);
        f|=dfs(i,i);
    }

    cout<<f<<endl;
    return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char c1[100],c2[100];
int main()
{
	scanf("%s%s",c1+1,c2+1);
	int len1=strlen(c1+1),len2=strlen(c2+1);
	if(len1+1!=len2){
		printf("No");
	}
	else{
		for(int i=1;i<=len1;i++){
			if(c1[i]!=c2[i]){
				printf("No");
				return 0;
			}
		}
		printf("Yes");
	}
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string S; cin >> S;
  int l = S.length();
  string result = "NO";
  rep(i,7) {
    string tmp = S.substr(0,i) + S.substr(l-(7-i),7-i);
    if (tmp=="keyence") result = "YES";
  }
  cout << result << endl;
  return 0;
}

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


Measured memory_bytes: 640
n, k = map(int,input().split())
P = list(map(int,input().split()))

# for i in range(n-k+1):
#     pp = P[i:i+k]
#     pp.sort()
#     print(P[:i] + pp + P[i+k:])

A = []
B = []
VA = [0] * n
VB = [0] * n
import heapq
for i in range(k):
    heapq.heappush(A, P[i])  # 最小値用
    heapq.heappush(B, -P[i])  # 最大値用

ans = 1
for i in range(n-k):
    b = -heapq.heappop(B)
    while VB[b] == 1:
        b = -heapq.heappop(B)
    a = heapq.heappop(A)
    while VA[a] == 1:
        a = heapq.heappop(A)
    # print(i,a,b,A,B)
    # print(P[k+i] ,b ,P[i] , a)
    if not(P[k+i] > b and P[i] == a):
        ans += 1
        # print(i)
    heapq.heappush(A, a)
    heapq.heappush(B, -b) 
    heapq.heappush(A, P[k+i])
    heapq.heappush(B, -P[k+i])

    VA[P[i]] = 1
    VB[P[i]] = 1

# print("ans",ans)

AA = []
for i in range(n-1):
    if P[i+1] - P[i] >= 0:
        AA.append(1)
    else:
        AA.append(0)
s = sum(AA[:k-1])
t = 0
r = 0
if s == k-1:
    t += 1
    r = 1
for i in range(n-k):
    # print(AA)
    s += AA[k-1+i]
    s -= AA[i]
    if s == k-1:
        t += 1
        r += 1
    else:
        ans += max(0, r-1)
        r = 0
ans += max(0, r-1)
# print("t",t)
print(ans - max(0, t-1))

Measured memory_bytes: 124752
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	bool flag = false;
	int i;

	for (i = 0; i < (int)s.size(); i++){
		if (s[i] == 'C'){
			flag = true;
			break;
		}
	}

	if (!flag){
		cout << "No" << endl;
		return 0;
	}

	flag = false;

	for (; i < (int)s.size(); i++){
		if (s[i] == 'F'){
			flag = true;
			break;
		}
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;


}


Measured memory_bytes: 256
a,b = map(int,input().split())
s = input()
S = list(s)
c = 0
for i in S:
    if i == "-":
        c += 1
        if c > 1:
            print("No")
            exit()
            
if s.isdecimal() is True:
    print("No")
    exit()
    
if len(s) != a + b + 1:
    print("No")
    exit()
    
if s[:a].isdecimal() is True and S[a] == "-":
    print("Yes")
    
else:
    print("No")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0)
        return a;
    else
        return gcd(b, a%b);
}

class SegmentTree{
    int n;
    vector<ll> node;

    public:
    SegmentTree(vector<ll> v){
        n = 1;
        while(v.size() > n) n *= 2;
        node.resize(2*n-1);

        for(int i = 0; i < v.size(); i++)
            node[i+n-1] = v[i];
        for(int i = n-1; i >= 0; i--)
            node[i] = gcd(node[2*i+1], node[2*i+2]);
    }

    void update(int x, ll t){
        x += n-1;
        node[x] = t;
        while(x > 0){
            x = (x-1) / 2;
            node[x] = gcd(node[2*x+1], node[2*x+2]);
        }
    }

    ll getgcd(int c, int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;

        if(b <= l || r <= a)
            return c;

        if(a <= l && r <= b)
            return node[k];

        int lval = getgcd(c, a, b, 2*k+1, l, (r+l)/2);
        int rval = getgcd(c, a, b, 2*k+2, (r+l)/2, r);
        return gcd(lval, rval);
    }
};

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    SegmentTree tree(A);

    ll ans = 0;
    REP(i,N){
        ll c;
        if(i == 0)
            c = A[1];
        else
            c = A[0];

        tree.update(i, c);
        ll tmp0 = tree.getgcd(c, 0, i);
        ll tmp1 = tree.getgcd(c, i+1, N);
        ll tmp = gcd(tmp0, tmp1);
        chmax(ans, tmp);
        tree.update(i, A[i]);
    }

    cout << ans << endl;
    return 0;
}


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

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}

void dfs(int s, int p, int par[], ll dp[][2], vector<int> G[]){
    par[s] = p;
    for(auto x:G[s]) {
        if(x == p) continue;
        dfs(x,s,par,dp,G);
    }
    dp[s][0] = add(dp[s][0],dp[s][1]);
    if(par[s]>=0) dp[par[s]][0] = mul(dp[par[s]][0],dp[s][0]);
    if(p>=0 && par[p]>=0) dp[par[p]][1] = mul(dp[par[p]][1],dp[s][0]);
}

int main(){
    int N; cin >> N;
    vector<int> G[N];
    REP(i,N-1) {
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int par[N];
    ll dp[N][2];
    REP(i,N)REP(j,2) dp[i][j] = 1;
    dfs(0,-1,par,dp,G);
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 16000
// #include <bits/stdc++.h>//C++のライブラリすべてinclude
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<limits>//ex numeric_limits<int>::max()
#include<math.h>
#define llong long long
#define INF 999999999

using namespace std;

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

    int a[3];
    for (int i = 0; i < 3; ++i)
    {
        cin>> a[i];
    }
    sort(a, a+3, greater<int>());
    cout << (a[0]*10+a[2])+a[1]<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

//#define int long long

//#define ENABLE_TRACE
#ifdef ENABLE_TRACE
#define TRACE cout << __func__ << "()" << endl;
#define TRACE1(a) cout << __func__ << "(" << a << ")" << endl;
#define TRACE2(a, b) cout << __func__ << "(" << a << ", " << b << ")" << endl;
#else
#define TRACE
#define TRACE1(a)
#define TRACE2(a, b)
#endif  // #ifdef ENABLE_TRACE

using namespace std;

// Greatest Common Divisor
int Gcd(int a, int b) {
  TRACE2(a, b);
  if (a % b == 0)
    return b;
  return Gcd(b, a % b);
}

void Main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  for (int i = 0; ; i++) {
    if (i % 2 == 0) {
      c -= b;
      if (c <= 0) {
        cout << "Yes" << endl;
        return;
      }
    } else {
      a -= d;
      if (a <= 0) {
        cout << "No" << endl;
        return;
      }
	}
  }
}

int32_t main() {
  Main();
  return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        int[] p = new int[5];
        p[0] = int.Parse(Console.ReadLine());
        p[1] = int.Parse(Console.ReadLine());
        p[2] = int.Parse(Console.ReadLine());
        p[3] = int.Parse(Console.ReadLine());
        p[4] = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        bool x = true;
        for(int i = 0; i < 4; i++)
        {
            for(int j = i + 1; j < 5; j++)
            {
                if (p[j] - p[i] > k)
                    x = false;
            }
        }
        if (x)
            Console.WriteLine("Yay!");
        else
            Console.WriteLine(":(");
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main(void)
{
	int mod = 1e9+7;
	int n;
	scanf("%d", &n);
	long long s = 1;
	for (int i = 1; i <= n; i++)
	{
		s = ((s%mod)*(i%mod))%mod;
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
for i in range(0, n):
	x1,y1,x2,y2,x3,y3,x4,y4 = map(float,raw_input().split())
 
	z1 = (x1 - x2) * (y3 - y4)
	z2 = (x3 - x4) * (y1 - y2)
 
	if abs(z1 - z2) < 1e-10:
		print "YES"
	else:
		print "NO"

Measured memory_bytes: 6292
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,kk,x=0,y=0,m;
  cin >> n;
  int p[n+1],q[n+1];
  int k[8]={0,1,2,6,24,120,720,5040};
  for(int i=0;i<n;i++){
    cin >>p[i];
  }
  for(int i=n-2;0<=i;i--){
    m=0;
    for(int ii=i+1;ii<n;ii++){
      if(p[ii]<p[i]){
        m++;
      }
    }
    x+=m*k[n-i-1];
  }
  for(int i=0;i<n;i++){
    cin >>q[i];
  }
  for(int i=n-2;0<=i;i--){
    m=0;
    for(int ii=i+1;ii<n;ii++){
      if(q[ii]<q[i]){
        m++;
      }
    }
    y+=m*k[n-i-1];
  }
  cout << max(x,y)-min(x,y) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int a[100001];
map<int,int> mp;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]=i;
	}
	sort(a,a+n);
	int ans=0;
	rep(i,n){
		if(mp[a[i]]%2!=i%2)
		ans++;
	}
	cout<<ans/2;
	re 0;
}


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

using namespace std;

#define EPS (1e-6)
#define equals(a,b) (fabs((a)-(b))<EPS)

inline int sign(const double &x){
    if(x>EPS) return 1;
    else if(x<-EPS) return -1;
    return 0;
}

/*   点  */
struct Point{
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point p) { return Point(x-p.x,y-p.y); }
    Point operator * (double k) { return Point(k*x,k*y); }
    Point operator / (double k) { return Point(x/k,y/k); }

    //向量的大小
    double abs(){ return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point & p) const{
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point & p) const {
        return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
    }
};

//两点间的距离
double getDistance(Point a,Point b){
    return (a-b).abs();
}

/*   向量  */
typedef Point Vector;

//向量a和b的内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
//向量a和b的外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

/*   线段  */
struct Segment{
    Point p1,p2;
};

/*   直线  */
typedef Segment Line;

//点到直线的距离
double getDistanceLP(Line l,Point p){
    return abs(cross(l.p2-l.p1,p-l.p1)/(l.p2-l.p1).abs());
}

//点到线段的距离
double getDistanceSP(Segment s,Point p){
    if(dot(s.p2-s.p1,p-s.p1)<0.0) return (p-s.p1).abs();
    if(dot(s.p1-s.p2,p-s.p2)<0.0) return (p-s.p2).abs();
    return getDistanceLP(s,p);
}

//判断p2与向量p1-p0的位置关系

const int COUNTER_CLOCKWISE = -1;   //逆时针
const int CLOCKWISE = 1;            //顺时针
const int ON_SEGMENT = 0;           //在线段上

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b)<EPS) return CLOCKWISE;
    return ON_SEGMENT;
}

//判断线段p1p2与线段p3p4是否相交
bool intersect(Point p1,Point p2,Point p3,Point p4){
    return ( ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
             ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0 );
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

//线段与线段的距离
double getDistance(Segment s1,Segment s2){
    if(intersect(s1,s2)) return 0.0;
    return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
               min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}

/* 直线正交
 * 判断向量a，b是否正交 =》a，b的内积为0
 */
bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

/* 直线平行
 * 判断向量a，b是否平行 =》a，b的内积为0
 */
bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

struct Circle{
    Point c;
    double r;
    Circle(Point c = Point() ,double r = 0.0 ):c(c),r(r){}
};

/*   多边形  */
typedef vector<Point> Polygon;

int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        Point p1,p2,p3,p4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y,&p4.x,&p4.y);
        printf("%.10f\n",getDistance(Segment{p1,p2},Segment{p3,p4}));
    }
    return 0;
}



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

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<ll> X(N), Y(N), Z(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i] >> Z[i];
    }
    const ll INF = 1LL<<60;
    ll ans = -INF;
    ll dp[2][2][2][M+1];
    for ( int t1 = 0; t1 < 2; t1++ ) {
        for ( int t2 = 0; t2 < 2; t2++ ) {
            for ( int t3 = 0; t3 < 2; t3++ ) {
                dp[t1][t2][t3][0] = 0;
                for ( int j = 1; j <= M; j++ ) {
                    dp[t1][t2][t3][j] = -INF;
                }
                ll s1 = 1 - 2 * t1;
                ll s2 = 1 - 2 * t2;
                ll s3 = 1 - 2 * t3;
                for ( int i = 0; i < N; i++ ) {
                    for ( int j = M; j >= 1; j-- ) {
                        if ( dp[t1][t2][t3][j-1] == -INF ) continue;
                        ll x = dp[t1][t2][t3][j-1] + s1 * X[i] + s2 * Y[i] + s3 * Z[i];
                        dp[t1][t2][t3][j] = max(dp[t1][t2][t3][j], x);
                    }
                }
                ans = max(ans, dp[t1][t2][t3][M]);
            }
        }
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<string>
#include<iomanip>
#include<iostream>
#include<math.h>
using namespace std;
#define NUM 100001

int main() {
	int r, D, x;
	
	cin >> r >> D >> x;

	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
def c_five_transportations(N, A, B, C, D, E):
    from math import ceil
    group_member = min((A, B, C, D, E))
    group_num = ceil(N / group_member)
    return 5 + (group_num - 1)

N, A, B, C, D, E = [int(input()) for _ in range(6)]
print(c_five_transportations(N, A, B, C, D, E))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int num[3][3];
	cin>>num[0][0]>>num[0][1]>>num[0][2]>>num[1][0]>>num[1][1]>>num[1][2]>>num[2][0]>>num[2][1]>>num[2][2];
	bool f=true;
	int num1=num[1][0]-num[0][0];
	for(int i=0;i<3;i++)
		if(num[1][i]-num[0][i]!=num1)
			f=false;
	num1=num[2][0]-num[1][0];
	for(int i=0;i<3;i++)
		if(num[2][i]-num[1][i]!=num1)
			f=false;
	num1=num[0][1]-num[0][0];
	for(int i=0;i<3;i++)
		if(num[i][1]-num[i][0]!=num1)
			f=false;
	num1=num[0][2]-num[0][1];
	for(int i=0;i<3;i++)
		if(num[i][2]-num[i][1]!=num1)
			f=false;
	if(f)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sen=0,maxe[2]={0,0},lo=0;
    string str[1000],s;
    while(cin>>s){
        lo=s.size();
        if(maxe[0]<lo){
            maxe[0]=lo;
            maxe[1]=sen;
        }
        str[sen]=s;
        sen++;
    }
    int co=-1,num;
    for(int i=0;i<=sen;i++){
        int cou=0;
        for(int j=i;j<=sen;j++)if(str[i]==str[j])cou++;
        if(co<=cou){
            co=cou;
            num=i;
        }
    }
    cout<<str[num]<<" "<<str[maxe[1]]<<endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(222222);
vi num(222222);
void dfs(ll now,ll par){
  for(auto e:E[now]){
    if(e == par)continue;
    num[e] += num[now]+1;
    dfs(e,now);
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi cnt(n);
  for(ll i = 1;i<n;i++){
    ll a;cin>>a;a--;
    E[i].pb(a);
    cnt[a]++;
  }
  for(int i=0;i<n;i++){
    if(cnt[i] == 0){
      dfs(i,-1);
    }
  }
  for(int i=0;i<n;i++)cout<<cnt[i]<<endl;
  return 0;
}


Measured memory_bytes: 27420
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    n = 1<<n;
    vector<int> a;
    multiset<int> st;
    rep(i,n){
        int x;
        cin>>x;
        st.insert(x);
    }
    a.push_back(*prev(st.end()));
    auto itr = st.end();
    --itr;
    st.erase(itr);
    while(st.size()){
        vector<int> b = a;
        for(auto x : a){
            auto itr = st.lower_bound(x);
            if(itr==st.begin()){
                cout<<"No"<<endl;
                return 0;
            }
            --itr;
            b.push_back(*itr);
            st.erase(itr);
        }
        b.swap(a);
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 14200
#include <stdio.h>
/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[][2], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i][1] < array[pivot][1]);
    do { j--; } while (array[pivot][1] < array[j][1]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { 
        swap(&array[i][0], &array[j][0]);
        swap(&array[i][1], &array[j][1]);
    }
  } while (i < j);

  swap(&array[pivot][0], &array[j][0]);
  swap(&array[pivot][1], &array[j][1]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[][2], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(){
    int N, AB[200000][2];
    int time=0;
    scanf("%d", &N);
    for(int i=0;i<N;i++)    scanf("%d %d", &AB[i][0], &AB[i][1]);
    
    quick_sort(AB, 0, N-1);
    for(int i=0;i<N;i++){
        if(time+AB[i][0] > AB[i][1]){
            printf("No");
            return 0;
        }
        time += AB[i][0];
    }
    printf("Yes");
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int a,b; cin >> a >> b;
    int ans;
    if(a>=13) ans = b;
    else if(a>=6 && a<=12) ans = b/2;
    else ans = 0;
    OUT(ans);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n;
	cin >> n;
	
	for(int i=n ; i<1000 ; i++)
	{
	    string temp = to_string(i);
	    if(temp[0] == temp[1] && temp[1] == temp[2]) 
	    {
	        cout << temp;
	        break;
	    }
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <utility>
#include <cctype>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

#define C const
#define R register
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define ld long double
#define ull unsigned long long
#define eps 1e-8
#define pi 3.141592653589793
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define PII pair<int,int>
#define sqr(a) ((a)*(a))
#define ls rt<<1
#define rs rt<<1|1
#define lowbit(i) ((i)&(-(i)))
#define FOR(i,a,b) for(R int i=(a);i<=(b);++i)
#define REP(i,a,b) for(R int i=(a);i>=(b);--i)
#define FOR_edge(i)  for(R int i=head[u];i;i=e[i].nxt)

using namespace std;

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

void judge() {
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
inline char nc() {
	static char buf[1000001],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
template <typename T> inline T Read() {
	R T s=0,w=1;
	R char c=nc();
	while(c<'0'||c>'9'){if(c=='-')w=-1;c=nc();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=nc();
	return s*w;
}
template <typename T> inline void Read(R T &s) {
	s=0;
	R T w=1;
	R char c=nc();
	while(c<'0'||c>'9'){if(c=='-')w=-1;c=nc();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=nc();
	s*=w;
}
template <typename T> inline void write(R T x) {
	if(x<0)  putchar('-'),x=-x;
	if(x>9)  write(x/10);
	putchar(x%10+'0');
}
template <typename T> inline void print(C T &x,C char &end) {
	write(x);
	putchar(end);
}

template <typename T> inline T gcd(C T &x,C T &y){return(y==0?x:gcd(y,x%y));}
template <typename T> inline void Swap(R T &x,R T &y){x^=y;y^=x;x^=y;}
template <typename T> inline void Swap_com(R T &x,R T &y){C T t=x;x=y;y=t;}
template <typename T> inline T POW(T x,T p,T mod) {
	R T res=1;
	while(p) {
		if(p&1)  res=(res*x)%mod;
		x=(x*x)%mod;  p>>=1;
	}
	return res;
}

///////////////////////////////////////////////////////////////////////////////
/////////////////////////////       Program       /////////////////////////////
/////////////////////////////        Heads        /////////////////////////////
/////////////////////////////    Don not touch    /////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#define read Read<int>
#define readll Read<ll>



int main() {
//	judge();
	ll a,b;  cin>>a>>b;
	ll c=b-a;
	ll t=(c+1)*c/2;
	cout<<(t-b)<<endl;
	
	return 0;
}


Measured memory_bytes: 256
N, K = [int(i) for i in input().split(" ")]
R, S, P = [int(i) for i in input().split(" ")]
T = list(input())

d = {"r":"p", "s":"r", "p":"s"}
r_d = {"p":"r", "r":"s", "s":"p"}

p_d = {"r":R, "s": S, "p": P}

t = [None]*len(T)
for i in range(len(T)):
    t[i] = d[T[i]]

pp = 0
c = {"r":1, "s": 1, "p": 1}
cont = False
a = list()
for i in range(len(t)):
    if i-K>=0:
        if t[i]==t[i-K]:
            if a[i-K]==t[i]:
                a.append("")
                continue
    a.append(t[i])
    pp+=p_d[t[i]]

print(pp)

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

typedef long long ll;

int n;
vector<int> G[200010];

int col[200010];
void dfs(int v,int p,int c){
	col[v]=c;
	for(int u: G[v]){
		if(u==p)continue;
		dfs(u,v,c^1);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	dfs(1,0,0);
	int cnt[2]={};
	for(int i=1;i<=n;i++){
		cnt[col[i]]++;
	}
	int a,b,c;
	a=b=c=n/3;
	if(n%3>=1)a++;
	if(n%3>=2)b++;
	
	static int ret[200010];
	static bool used[200010];
	for(int i=0;i<200010;i++){
		used[i]=false;
	}
	if(cnt[0]<=c||cnt[1]<=c){
		int t=0; if(cnt[0]>c)t=1;
		int CNT=0;
		for(int i=1;i<=n;i++){
			if(col[i]==t){
				CNT++;
				ret[i]=CNT*3;
				used[ret[i]]=true;
			}
		}
		CNT=1;
		for(int i=1;i<=n;i++){
			if(col[i]!=t){
				while(used[CNT])CNT++;
				ret[i]=CNT;
				used[ret[i]]=true;
			}
		}
	}
	else {
		cnt[0]=cnt[1]=0;
		int k=3;
		for(int i=1;i<=n;i++){
			if(3*cnt[col[i]]+1+col[i]<=n){
				ret[i]=3*cnt[col[i]]+1+col[i];
			}
			else {
				while(used[k])k+=3;
				ret[i]=k;
			}
			cnt[col[i]]++;
			used[ret[i]]=true;
		}
	}
	
	for(int i=1;i<=n;i++){
		printf("%d%c",ret[i],(i==n)?'\n':' ');
	}
}



Measured memory_bytes: 19328
use std::io::*;
use std::str::FromStr;

fn main() {
    let po: Vec<char> = "CODEFESTIVAL2016".chars().collect();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut ans = 0;
    for i in 0..s.len() {
        if po[i] != s[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
	int main() {
	string S, T;
	cin >> S >> T;
	int count = S.size();
	int flag = 0;
	while (count--)
	{
		if (S == T)
		{
			flag = 1;
			break;
		}
		S.insert(0," ");//S.size增加了1
		S[0]=S[S.size() - 1];//最后一个字符复制到第一个
		S.resize(S.size()-1);//调整S.size，将最后的字符去掉
	}
	if(flag)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    ll min_walk = 100000000000000;
    for (ll i = 1; i <= sqrt(N); ++i) {
        if (N % i == 0) {
            min_walk = min(min_walk, i + N/i - 2);
        }
    }
    cout << min_walk << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
cin>>n;
cout<<a[n-1]<<endl;


return 0;
}


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

const int H_MAX = 100;
const int W_MAX = 100;
const int INF = 1000000;

struct edge{
    int to, cap, rev;
    edge(int t, int c, int r): to(t), cap(c), rev(r){}
};

vector<edge> G[2 * W_MAX * H_MAX  +5];
bool used[2 * W_MAX * H_MAX + 5];

void add_edge(int from, int to, int cap){
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size()-1);
}

int dfs(int v, int t, int f){
    if (v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main(){
    int h, w;
    cin >> h >> w;
    int s = 2 * h * w;
    int t = 2 * h * w + 1;

    for(int i = 0; i < h; i++){
        char S[W_MAX + 5];
        cin >> S;
        for(int j = 0; j < w; j++){
            if (S[j] == 'X') add_edge(s, w * i + j + w * h, INF);
            add_edge(w * i + j, w * i + j + w * h, 1);
            if (i < h-1){
                add_edge(w * i + j + w * h, w * (i+1) + j, INF);
                add_edge(w * (i+1) + j + w * h, w * i + j, INF);
            }
            if (j < w-1){
                add_edge(w * i + j + w * h, w * i + (j+1), INF);
                add_edge(w * i + (j+1) + w * h, w * i + j, INF);
            }
            if (i == 0 || i == h-1 || j == 0 || j == w-1){
                add_edge(w * i + j + w * h, t, INF);
            }
        }
    }

    int ans = max_flow(s, t);
    if (ans > INF / 10) ans = -1;
    cout << ans << endl;
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && a!=c || b==c && b!=a || c==a && c!=b)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, i;
    cin >> n >> i;

    cout << n - i + 1 << endl;


    return 0;
}

Measured memory_bytes: 256