akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int int64_t
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi C(N);
  rep(i,0,N) cin>>C[i];
  vi dp(N);
  vi A(200001,-1);
  A[C[0]]=0;
  rep(i,1,N){
    dp[i]=dp[i-1];
    if(A[C[i]]!=-1&&C[i]!=C[i-1]){
        dp[i]=(dp[A[C[i]]]+dp[i])%MOD;
        dp[i]=(dp[i]+1)%MOD;
    }
    A[C[i]]=i;
  }
  cout<<(dp[N-1]+1)%MOD<<endl;
  }



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

int main(){
  int n,i,j;
  int ans=1,max=0;
  cin>>n;
  int h[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  for(i=1;i<n;i++){
    if(h[i-1]>max)max=h[i-1];
    if(max<=h[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

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

    bool ans = true;
    rep(i, N) {
        if (a[i] != 0) ans = false;
    }

    // 全て0
    if (ans) {
        puts("Yes");
        return 0;
    }

    // 3の倍数でなければ不可能
    if (N % 3 != 0) {
        puts("No");
        return 0;
    }

    map<int, int> m;
    rep(i, N) {
        m[ a[i] ]++;
    }

    int X = m.size();

    if (X == 2) {
        if (m[0] == N / 3) {
            puts("Yes");
        } else {
            puts("No");
        }
        return 0;
    }

    if (X == 3) {
        vector<int> v;
        for (auto j : m) {
            v.push_back(j.first);
        }

        int x = v[0] ^ v[1] ^ v[2];
        if (x != 0) {
            puts("No");
            return 0;
        }

        ans = true;
        for (auto i : m) {
            if (i.second != N / 3) ans = false;
        }

        if (ans) {
            puts("Yes");
            return 0;
        }
    }

    puts("No");
}

Measured memory_bytes: 4224
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
using ll = long long;
 
 
int main() {
  ll A;
  double B;
 
  ll ans;
  cin >> A >> B;
  int C = round(B*100);
  //cout << (double)A << B << endl;
  
  ans = (ll)A * C / 100;
 
  //cout << fixed << setprecision(1);
  cout << ans << endl;
 
  return 0;
 
}

Measured memory_bytes: 3760
function main(input) {
  
  var inputArr = input.split('');
  var sum = 0;
  for (var i=0;i<4;i++){
    if(inputArr[i] == '+') {
    	sum += 1;
    } else {
    	sum -= 1;
    }
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	ios::sync_with_stdio(0); 
    	cin.tie(NULL); 
    	cout.tie(NULL);
     
    	int n,m;
    	cin >> n >> m;
    	vector<long long int> h(n);
    	vector<bool> ans(n,1);
    	int count = 0;
    	for (auto &i: h)
    		cin >> i;
    	for (int i = 0; i < m; i++) {
    		int a,b;
    		cin >> a >> b;
    		a--; b--;
    		if (h[a] >= h[b])
    			ans[b] = 0;
    		if (h[b] >= h[a])
    			ans[a] = 0;
    	}
    	for (bool b: ans)
    		count += b ? 1 : 0;
    	cout << count;
    }

Measured memory_bytes: 3956
n = int(input())
A=[]
for i in range(n):
    A.append(int(input()))

S = sorted(A,reverse=True)
maxa = S[0]
maxa2 = S[1]
B=[]
B = [maxa2 if a==maxa else maxa for a in A]

for b in B:
    print(b)


Measured memory_bytes: 20604
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

all = (10 **N) % mod
no_zero = (9**N) % mod
no_nine = (9**N) 
no_zero_nine = 8 ** N

A = 1
no_zero = 1
no_nine = 1
no_zero_nine = 1

for i in range(N):
    A = A * 10 % mod
    no_zero = no_zero * 9 % mod
    no_zero_nine = no_zero_nine * 8 % mod

ans = (A - (no_zero * 2 - no_zero_nine)) % mod
    

print(ans)


Measured memory_bytes: 12264
fun main(arg: Array<String>) {
    var S = readLine()!!
    var L = S.length
    var M = mutableListOf<Char>()
    for (n in 0 until L) {
        M.add(S[n])
        if (M.size >= 2 && M[M.lastIndex - 1] == 'S' && M[M.lastIndex] == 'T') {
            M.removeAt(M.lastIndex) //remove 'T'
            M.removeAt(M.lastIndex) //remove 'S'
        }
    }
    println(M.size)
}


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

int main(){
  map<string, int> M;
  int q, query, x;
  string key;
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    scanf("%d", &query);
    if(query == 0){
      cin >> key >> x;
      M[key] = x;
    }else if(query == 1){
      cin >> key;
      if(M.count(key) == 0){
        printf("%d\n", 0);
      }else{
        printf("%d\n", M[key]);
      }
    }else{
      cin >> key;
      M.erase(key);
    }
  }
  return 0;
}



Measured memory_bytes: 27956
Option Strict On

Module Module1
    Dim A, B, X As Long
    Dim ans As String


    Sub Main()
        'let'
        Dim tmp() As Long =
            Array.ConvertAll(Of String, Long) _
            (Console.ReadLine().Split(), AddressOf Long.Parse)
        A = tmp(0)
        B = tmp(1)
        X = tmp(2)

        'var'
        ans = "YES"

        If X < A OrElse A + B < X Then ans = "NO"

        Console.WriteLine(ans)

    End Sub




End Module

Measured memory_bytes: 13140
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<vector<ll>> items;

vector<vector<vector<ll>>> dp;

void solve(const int R, const int C, const int K) {
    for (int r = 0; r <= R; r++) {
        for (int c = 0; c <= C; c++) {
            for (int n = 0; n < 4; n++) {
#ifdef DEBUG
                printf("r: %d, c: %d, n: %d, score: %lld\n", r, c, n, dp[r][c][n]);
#endif
                // down
                if (r < R) {
                    // get item
#ifdef DEBUG
                    printf("[down, get] += %lld\n", items[r + 1][c]);
#endif
                    chmax(dp[r + 1][c][1], dp[r][c][n] + items[r + 1][c]);

                    // not get item
                    chmax(dp[r + 1][c][0], dp[r][c][n]);
                }

                // right
                if (c < C) {
                    // get item
                    if (n < 3) {
#ifdef DEBUG
                        printf("[right, get] += %lld\n", items[r][c + 1]);
#endif
                        chmax(dp[r][c + 1][n + 1], dp[r][c][n] + items[r][c + 1]);
                    }

                    // not get item
                    chmax(dp[r][c + 1][n], dp[r][c][n]);
                }
            }
        }
    }
}

int main(void) {
    int R, C, K;
    cin >> R >> C >> K;

    items.resize(R + 1, vector<ll>(C + 1, 0LL));
    for (int k = 0; k < K; k++) {
        int r, c, v;
        cin >> r >> c >> v;
        items[r][c] = v;
    }

    dp.resize(R + 1);
    for (int r = 0; r <= R; r++) {
        dp[r].resize(C + 1, vector<ll>(4, 0));
    }

    solve(R, C, K);

    ll ans = 0;
    for (int i = 0; i < 4; i++) {
        chmax(ans, dp[R][C][i]);
    }
    cout << ans << endl;

    return 0;
}


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

// [l, r]にあるkの倍数の数
ll g(ll l, ll r, ll k) {
  ll m = l + (k - l % k) % k;
  if(m > r) return 0;
  return (r - m) / k + 1;
}

// [1, x]のFizzBuzz Stringの長さ
ll f(ll x) {
  ll ret = 0;
  for(ll p = 1, i = 1; p <= x; p *= 10, i++) {
    ll l = p, r = x >= p * 10 ? p * 10 - 1 : x;
    ll n3 = g(l, r, 3);
    ll n5 = g(l, r, 5);
    ll n15 = g(l, r, 15);
    ll n = (r - l + 1) - (n3 + n5 - n15);
    ret += n3 * 4 + n5 * 4 + n * i;
  }
  return ret;
}

int main(void) {
  ll S;
  cin >> S;

  ll l = 0, h = 100000000000000000LL;
  while(l + 1 < h) {
    ll m = (l + h) / 2;
    if(f(m) < S) l = m;
    else h = m;
  }

  ll t = S - f(l) - 1;
  string ans = "";
  REP(i, l + 1, l + 200) {
    if(i % 3 == 0 && i % 5 == 0) ans += "FizzBuzz";
    else if(i % 3 == 0) ans += "Fizz";
    else if(i % 5 == 0) ans += "Buzz";
    else ans += to_string(i);
  }
  cout << ans.substr(t, 20) << endl;
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  rep(i, N) cin >> A[i], A[i]--;
  rep(i, N) cin >> B[i];
  rep(i, N - 1) cin >> C[i];
  ll ans = 0;
  rep(i, N) {
    ans += B[A[i]];
    if (i && A[i] - 1 == A[i - 1]) {
      ans += C[A[i - 1]];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

const int MAXN = 1000000;
Int fact[MAXN], inv[MAXN];

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

Int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

char s[100005];
char st;
void rec(char a, char b){
    if (a == 'T' && b == 'F') st = 'F';
    else st = 'T';
}

int main(){
    cin.tie(0);
    
    int N; cin >> N;
    for (int i = 0; i < N; i++){
        cin >> s[i];
    }
    st = s[0];
    for (int i = 1; i < N; i++){
        rec(st, s[i]);
    }
    cout << st << endl;

}



Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

int main() {
	long long int N, M;
	cin >> N >> M;
	vector<pair<long long int, long long int>> drink_list;
	long long int temp1, temp2;
	long long int ans = 0;
	long long int num = M;

	for (long long int i = 0; i < N; i++) {
		cin >> temp1 >> temp2;

		drink_list.push_back(make_pair(temp1, temp2));
	}

	sort(drink_list.begin(), drink_list.end());

	for (long long int i = 0; i < N; i++) {
		if (num > drink_list[i].second) {  // 買占め
			ans += drink_list[i].first * drink_list[i].second;
			num -= drink_list[i].second;
		} else {
			ans += drink_list[i].first * num;
			break;
		}
	}

	cout << ans << endl;

//	long long int A, B;
//	long long int diff;
//	cin >> A>> B;
//
//	diff = B - A;
//
//	for(long long int i = 0; i < diff ; i++){

	//}





}


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

int n, i;
int h [100005];
int dp [100005];

int main ()
    {
    scanf ("%d",&n);
    for (i=1; i<=n; i++)
        scanf ("%d",&h[i]);
    fill (dp+2, dp+n+1, 1000000001);
    for (i=1; i<=n; i++)
        {
        dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
        }
    printf ("%d\n",dp[n]);
    return 0;
    }


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int weight[n];
  for (int i=0;i<n;i++) cin >> weight[i];
  
  int w_sum[n];
  w_sum[0] = weight[0];
  for (int i=1;i<n;i++) w_sum[i] = w_sum[i-1] + weight[i];
  
  int min = 10000;
  for (int i=0;i<n;i++){
    if (min >= abs(w_sum[n-1]-2*w_sum[i])) min = abs(w_sum[n-1]-2*w_sum[i]);
  }
 
  cout << min << endl;
}

Measured memory_bytes: 256
#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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    vector<int> nums(300, 0);
    ++nums[A];
    --nums[B];
    ++nums[C];
    --nums[D];
    rep(i, 1, 300)
    {
        nums[i] += nums[i - 1];
    }
    int ans = 0;
    rep(i, 0, 300)
    {
        if (nums[i] >= 2) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--, b--, c--, d--;
    if (c < b || c < d)
    {
        bool f = true;
        for (int i = a; i < c; i++)
            if (s[i] == '#' && s[i + 1] == '#')
                f = false;
        for (int i = b; i < d; i++)
            if (s[i] == '#' && s[i + 1] == '#')
                f = false;
        cout << (f ? "Yes" : "No") << endl;
    }
    else
    {
        bool f = true;
        for (int i = a; i < c; i++)
            if (s[i] == '#' && s[i + 1] == '#')
                f = false;
        for (int i = b; i < d; i++)
            if (s[i] == '#' && s[i + 1] == '#')
                f = false;
        bool g = false;
        for (int i = b; i <= d; i++)
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
                g = true;
        cout << (f && g ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){
    ll n;
    ll ans=1LL,cnt=0LL;
    cin >> n;
    vector<ll> data(n);
    rep(i,n){
        cin >> data.at(i);
        if(data.at(i)==0LL){
            cout << 0 << endl;
            return 0;
        }

    }
    rep(i,n){
        if(ans>1000000000000000000LL/data.at(i)){
            cout << -1 << endl;
            return 0;
        }
        ans*=data.at(i);

    }
    if(ans>1000000000000000000LL || ans<0LL){
            cout << -1 << endl;
            return 0;
        }
    
    cout << ans << endl;



 
}

Measured memory_bytes: 4004
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/17/20 22:14:12
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> tree[n];
  for (int i = 0; i < n-1; i++) {
    int a,b; cin>>a>>b; a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  vector<int> dist(n, n);
  queue<int> qs;
  qs.push(n-1);
  dist[n-1] = 0;
  while (not qs.empty()) {
    auto q = qs.front(); qs.pop();
    int d = dist[q];
    for (auto t:tree[q]) {
      if (dist[t] < d)
        continue;
      qs.push(t);
      dist[t] = d+1;
    }
  }
  vector<int> path;
  path.push_back(0);
  int d = dist[0];
  while (d > 0) {
    for (auto t:tree[path.back()]) {
      if (dist[t] == d-1) {
        path.push_back(t);
        break;
      }
    }
    d--;
  }
  vector<int> color(n, 0);
  color[path[(path.size()+1)/2-1]] = 1;
  color[path[(path.size()+1)/2]] = 2;

  qs = {};
  qs.push(path[(path.size()+1)/2-1]);
  int bs = 1;
  while (not qs.empty()) {
    auto q = qs.front(); qs.pop();
    for (auto t:tree[q]) {
      if (color[t] != 0) continue;
      color[t] = 1;
      bs++;
      qs.push(t);
    }
  }

  cerr<<bs<<" "<<n-bs<<endl;
  cout << (bs > n-bs ? "Fennec" : "Snuke") << endl;

  return 0;
}


Measured memory_bytes: 10128
#include <stdio.h>
#define N 80

int main (void)
{
	int p, q;
	int i;
	while (scanf("%d%d", &p, &q) == 2)
	{
		int r[N];
		int b = -1;
		int n;
		r[0] = p % q;
		for(n = 1; b == -1 && r[n-1]; ++n)
		{
			r[n] = (r[n-1] * 10) % q;
			for (i = 0; i < n; ++i)
			{
				if (r[i] == r[n])
				{
					b = i;
					break ;
				}
			}
		}
		for (i = 0; i < n - 1; ++i)
			putchar('0' + r[i] * 10 / q);
		puts ("");
		if (b != -1)
		{
			for (i = 0; i < b; ++i)
				putchar (' ');
			for (i = b; i < n - 1; ++i)
				putchar ('^');
			puts ("");
		}
	}
	return ( 0 );
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string S;
    cin>>S;
    int N=S.size();
    vector<char> c(N,'a');
    rep(i,N) {
        c.at(i)=S.at(i);
    }
    sort(c.begin(),c.end());
    bool ok=true;
    rep(i,N-1) {
        if(c.at(i)==c.at(i+1)) ok=false;
    }
    if(ok) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
void aout(void){
	cout<<ans<<endl;
}
void out(int a){
	cout<<a<<endl;
}
int main(void){
  cin.tie(0);
ios::sync_with_stdio(false);

	int n,m,i,j;
	cin>>n>>m;
	pair<int,int> p[m];
	for(i=0;i<m;++i)cin>>p[i].first>>p[i].second;
	vector<int> d,s;
	for(i=0;i<m;++i){
		if(p[i].second==n)d.push_back(p[i].first);
		if(p[i].first==1)s.push_back(p[i].second);
	}
  sort(d.begin(),d.end());
  sort(s.begin(),s.end());
  i=0;
  j=0;
	while(i<d.size()&&j<s.size()){
      if(d[i]>s[j])++j;
      else if(d[i]<s[j])++i;
      else{
				cout<<"POSSIBLE\n";
				return 0;
      }
	}
	cout<<"IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 2812
fn main() {
    let n = read::<usize>();

    let mut ret = 0;
    for i in 1..n+1 {
        let s = i.to_string();
        if s.len() % 2 == 1 {
            ret += 1;
        }
    }
    println!("{}", ret)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


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

int main()
{
	int n;
	cin>>n;
	string s,sol[4];
	cin>>s;
	sol[0]="SS";
	sol[1]="SW";
	sol[2]="WS";
	sol[3]="WW";
	for(int j=0;j<4;j++)
	{
		for(int i=1;i<=n-1;i++)
		{
			if(sol[j][i]=='W')
				if(s[i]=='o')
					if(sol[j][i-1]=='W') sol[j]+="S"; else sol[j]+="W";
				else
					if(sol[j][i-1]=='W') sol[j]+="W"; else sol[j]+="S";
			else
				if(s[i]=='x')
					if(sol[j][i-1]=='W') sol[j]+="S"; else sol[j]+="W";
				else
					if(sol[j][i-1]=='W') sol[j]+="W"; else sol[j]+="S";		
		}
		//cout<<sol[j]<<" "<<j<<"\n";
		if(sol[j][0]=='W')
		{
			if(s[0]=='o')
			{
				if(sol[j][n-1]==sol[j][1])
				{
					continue; 
				}
			}
			else
			{
				if(sol[j][n-1]!=sol[j][1])
				{
					continue;
				}
			}
		}	
		else
		{
			if(s[0]=='o')
			{
				if(sol[j][n-1]!=sol[j][1]) 
				{
					continue; 
				}
			}
			else
			{
				//cout<<"!!!";
				if(sol[j][n-1]==sol[j][1])
				{
					continue;
				}
			}
		}
		
		if(sol[j][n]==sol[j][0])
		{
			cout<<sol[j].substr(0,n);
			return 0;
		}
	}
	cout<<-1;
	return 0;
}
/*
15
xxxoxoxoxxooxxx
*/

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N, M;
    cin >> N >> M;

    dsu uf(N);
    for_(i,0,M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.merge(a, b);
    }

    cout << (int)uf.groups().size() - 1 << endl;
}

Measured memory_bytes: 8876
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

const int maxn = 100000 + 5;
int N, K;
int mem[maxn];
vector<int> vec;

int solve()
{
	sort(mem, mem+N);
	for(int i = 0; i+K-1 < N; i++)
	{
		vec.push_back(mem[i+K-1] - mem[i]);
		//cout << vec[i] << endl;
	}
	sort(vec.begin(), vec.end());
	return vec[0];
}

int main()
{
	cin >> N >> K;
	for(int i = 0; i < N; i++) cin >> mem[i];
	printf("%d\n", solve()); 
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  int count = 0;
  
  rep2(i,1,n-1)
    if((a[i-1]-a[i])*(a[i+1]-a[i])<0)count++;
  cout << count << endl;
}

Measured memory_bytes: 256
/*input
3
1 2 3
1 2
2 3
*/
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

const int N = 3007;

int n, win[N], num[N];
vector<int> child[N];
pair<int, int> a[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &a[i].first), a[i].second = i;
		num[a[i].second] = a[i].first;
	}

	for(int i = 1; i < n; ++i){
		int a, b; scanf("%d%d", &a, &b);
		child[a].push_back(b);
		child[b].push_back(a);
	}

	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i)
		if(win[a[i].second] == 0)
			for(int v:child[a[i].second]) win[v] |= num[v] > a[i].first;

	for(int i = 1; i <= n; ++i)
		if(win[i]) printf("%d ", i);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    for(int i = sx; i < tx; i++){
        ans += "R";
    }
    for(int i = sy; i < ty; i++){
        ans += "U";
    }
    for(int i = sx; i < tx; i++){
        ans += "L";
    }
    for(int i = sy; i < ty; i++){
        ans += "D";
    }
    ans += "D";
    for(int i = sx; i <= tx; i++){
        ans += "R";
    }

    for(int i = sy; i <= ty; i++){
        ans += "U";
    }

    ans += "L";
    ans += "U";
    for(int i = sx; i <= tx; i++){
        ans += "L";
    }

    for(int i = sy; i <= ty; i++){
        ans += "D";
    }
    ans += "R";

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

Measured memory_bytes: 3536
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 22 00:26:09 2020

@author: Kanaru Sato
"""

l,r = list(map(int, input().split()))
mod = 2019

if l//mod != r//mod:
    ans = 0
else:
    ans = 10000
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            tmp = (i*j)%mod
            if tmp < ans:
                ans = tmp

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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()
{
	int N,i;
	cin >> N >> i;
	cout << N-i+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, Q;
vector<vector<int>> tree;
vector<ll> add;
vector<ll> ans;

void dfs(int v, int p, ll sum) {
    sum += add[v];
    ans[v] = sum;

    for (int u : tree[v]) {
        if (u != p) {
            dfs(u, v, sum);
        }
    }
}

int main() {
    cin >> N >> Q;
    tree.resize(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;

        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    add.resize(N);
    rep(i, Q) {
        int p, x;
        cin >> p >> x;

        add[p - 1] += x;
    }

    ans.resize(N);
    dfs(0, -1, 0);

    rep(i, N) {
        cout << ans[i] << (i == N - 1 ? '\n' : ' ');
    }
}

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

 
int main() {
    int n;
    cin>>n;
    map<char,int> S;
    string s1;
    cin>>s1;
    rep(i,s1.length()){
        S[s1[i]]++;
    }

    for(int i=1;i<n;i++){
       string sf;
       cin>>sf;
       map<char,int> SF;
       rep(i,sf.length()){
        SF[sf[i]]++;
       }
       for(auto p:S){
           if(SF.count(p.first))S[p.first]=min(SF[p.first],S[p.first]);
           else S.erase(p.first);
       }
 
    }
    
    for(auto p:S){
        rep(i,p.second)cout<<p.first;
    }

}

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

using namespace std;

int main()
{
    float pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286;
    float a;
    int r;
    scanf("%d",&r);
    a=2*pi*r;
    printf("%f",a);
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;

int a[200005];
int b[200005];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
           int n,m,k;
           cin>>n>>m>>k;
           rep(i,1,n+1)cin>>a[i];
           rep(i,1,m+1)cin>>b[i];
           rep(i,1,n+1)a[i]+=a[i-1];
           rep(i,1,m+1)b[i]+=b[i-1];

           int ans=0;
           int l=1,r=n+m;
           while(l<=r)
           {
                int mid=(l+r)>>1;
                bool ok=false;
                rep(i,0,n+1)
                {
                    int rem=mid-i;
                    if(rem<0 || rem>m)continue;
                    if(a[i]+b[rem]<=k)
                    {
                        ok=true;
                        break;
                    }
                }
                if(ok){ans=max(ans,mid);l=mid+1;}
                else
                r=mid-1;
           }
           cout<<ans<<endl;
      }
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 6736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define upmin(ans,ansx) (ans)=min((ans),(ansx))
#define upmax(ans,ansx) (ans)=max((ans),(ansx))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MOD (1000000009)
#define MAXN (500005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

int A, B;

int main() {
    scanf("%d%d", &A, &B);
    if(A <= 0 && 0 <= B) { puts("Zero"); return 0; }
    if(0 <= A) { puts("Positive"); return 0; }
    A = -A; if(B < 0) A += B+1;
    puts((A&1) ? "Negative" : "Positive");
    return 0;
}

Measured memory_bytes: 256
/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/

#define VERNIY st();int ver=0,niy=0,hbk=0

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
#include <set>
#define LLU unsigned long long int
#define LL long long int
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vpd vector<pair<int,int>>
#define vLL vector<long long int>
#define vpLL vector<pair<long long int,long long int>>
#define vLLU vector<unsigned long long int>
#define vpLLU vector<pair<unsigned long long int,unsigned long long int>>
#define pd pair<int,int>
#define pLL pair<long long int,long long int>
#define pLLU pair<unsigned long long int,unsigned long long int>
#define qd queue<int>
#define qpd queue<pair<int,int>>
#define maxpqd priority_queue<int>
#define minpqd priority_queue<int, vector<int>, greater<int>>
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein freopen("in.txt","r",stdin);
#define fileout freopen("out.txt","w",stdout);

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}
inline void scllu(LLU &a){scanf("%I64u",&a);}
inline void scdllu(LLU &a,LLU &b){scanf("%I64u %I64u",&a,&b);}
inline void sctllu(LLU &a,LLU &b,LLU &c){scanf("%I64u %I64u %I64u",&a,&b,&c);}

template<class Ver>
inline void prd(Ver a){cout<<a<<"\n";};
template<class Ver>
inline void prdd(Ver a,Ver b){cout<<a<<" "<<b<<"\n";};
template<class Ver>
inline void prtd(Ver a, Ver b, Ver c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){printf("asd\n");}
template<class Ver>
inline void debugd(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver>
inline void debugdd(Ver a,Ver b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver>
inline void debugtd(Ver a,Ver b,Ver c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265

void st()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main()
{
	VERNIY;
	string s;
	cin>>s;
	forin(i,0,s.length())
	if(s[i]=='1')++ver;
	prd(ver);	

	return 0;
}

/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(W: int, H: int, x: int, y: int):
    print(W*H/2,int(W/2 == x and H/2== y))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(W, H, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e18;
const int maxn = 300002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
  ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
      if (n & 1) res = (res * x) % mod;
      x = (x * x) % mod;
      }
      return res;
  }
int32_t main()
{ 
  IOS

  
    int n;
    cin>>n;
  int p = n;
  int len = 1;
  for(int i = 1;i<=20;i++){
    if(power(26,i)<p){
      p-=power(26,i);
    }
    else {
      len = i;
      break;
    }

  }
  n = p;
  for(int i = 0;i<len;i++){
    for(int j = 0;j<26;j++){
      if((j+1)*power(26,len-i-1)>=n){
        cout<<char('a'+j);
        n -= (j)*power(26,len-i-1);
        break;
      }
    }
  }
  cout<<endl;
  

  

  
  
  
}

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


using namespace std;

#define re return
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 0; i < int(n); i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long double ld;

ll n, l = 2, r = 2;
vector<ll> a;

int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	//freopen("a.in", "r", stdin);
	cin >> n;
	a.resize(n);
	forn (i, n) cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		r -= r % a[i];
		if (l % a[i]) l += a[i] - l % a[i];
		r += a[i] - 1LL;
		if (l > r) {
			cout << "-1\n";
			re 0;
		}
	}
	cout << l << " " << r;
	re 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll  long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
		/*#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif*/
fast();

       ll n,a,b;
        cin >> n>>a>>b;
        
        if(a<b)
        	 swap(a,b);
         if((a-b)%2==0)
        {
        	 ll ans=(a-b);
        	ans/=2;
        	cout<<ans<< endl;
        }
        else

        {

        	 ll a1=a-1;
        	ll a2=(n-b);
        	if(a1<a2)
        	{
                ll temp=b;
                a-=b;
                ll res=(a-1)/2+b;
                //ll r=(a+b-1)/2;
        		//cout << a1 << endl;
        	  res=min(a1,res);
             cout << res << endl;
        	}
        	else

        	{   cerr<<"else"<<endl;
                ll temp=(n-a+1);
                b+=temp;
                ll res=abs(n-b)/2 +temp;
                  res=min(res,a2);
                cout<<res<< endl;
        	}

        }
    


return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk; 
	 cin>>n>>m;
	 ll s=0;
	 for(i=0;i<n;i++)
	 {
	 	cin>>a>>b;
	 	if(a*a+b*b<=m*m)
	 	s++;
	  } 
	  cout<<s<<endl;
} 

Measured memory_bytes: 3632
def main():
    N = int(input())

    if N == 1:
        print(1)
        return

    lst = erastosthenes(N)
    plist = [i for i in range(3, N + 1, 2) if lst[i]]
    plist = [2] + plist

    mod = 1000000007
    ans = 1
    for p in plist:
        cnt = 0
        i = 1
        while 1:
            x = p ** i
            if x > N:
                break
            cnt += N // x
            i += 1
        ans = ans * (cnt + 1) % mod
    print(ans)

def erastosthenes(n):
    prime = [0, 1] * ((n + 1) // 2)
    if not n % 2:
        prime += [0]
    prime[1], prime[2] = 0, 1

    sqrt = n ** 0.5
    i = 3
    while i <= sqrt:
        for j in range(i ** 2, n + 1, i):
            prime[j] = 0
        i += 2
    return prime

main()


Measured memory_bytes: 3064
#include<cstdio>
#include<stdlib.h>

#define H_MAX 50
#define H_MIN 2
#define W_MAX 50
#define W_MIN 2
#define CICADA_MAX 9
#define CICADA_MIN 0


class CICADA
{
	public:
		// Public member function
		int Search( void );
		int GetValue( void );
	private:
		// Private member variable
		int H = 0, W = 0;			// height, width
		int blk[H_MAX][W_MAX]={ { 0 } };		// Number of cicadas per block
		int cicada[W_MAX]={0};		// Total of cicadas
		int cicadabak[W_MAX]={0};	// Total of cicadas of one block above
};



int CICADA::Search(void)
{
	int result=0;
	
	for( int i = 0; i < W; i++ )
	{
		for( int j = 0; j < i+1; j++)
		{
			cicada[i] += blk[0][j];
		}
	}
	
	for( int i = 1; i < H; i++ )
	{
		for( int j = 0; j < W; j++)
		{
			cicadabak[j] = cicada[j];
			if( j == 0 )
			{
				cicada[j] = cicadabak[j] + blk[i][j];
			}
			else if( cicadabak[j] > cicadabak[j-1] )
			{
				cicada[j] = cicadabak[j-1] + blk[i][j];
			}
			else
			{
				cicada[j] = cicadabak[j] + blk[i][j];
			}
			cicadabak[j] = cicada[j];
		}
	}
	
	result = cicada[W-1];
	for( int i = 0; i < W; i++ )
	{
		for( int j = i+1; j < W; j++)
		{
			cicada[i] += blk[H-1][j];
		}
		if( cicada[i] < result)
		{
			result = cicada[i];
		}
	}
	
	printf("%d\n", result);
	
	return 0;
}



int CICADA::GetValue(void)
{
	char c;
	
	scanf( "%d %d%*c", &H, &W );
	
	for( int i = 0; i < H; i++ )
	{
		for( int j = 0; j < W; j++ )
		{
			scanf( "%c", &c );
			blk[i][j] = c - '0';
			
			if( ( blk[i][j] > CICADA_MAX ) || ( blk[i][j] < CICADA_MIN ) || ( blk[0][0] != 0 ) || ( blk[H-1][W-1] != 0 ) )
			{
				return -1;
			}
		}
		scanf("%*c");
	}
	
	return 0;
}



int main(void)
{
	CICADA Cicada;
	
	if( Cicada.GetValue() == -1 )
	{
		return -1;
	}
	
	Cicada.Search();
	
	return 0;
}




Measured memory_bytes: 2772
while (n,x = gets.split.map(&:to_i)) != [0,0] do
  count = 0
  check_arr = Array.new
  test_arr  = Array.new
  c = 0
  (1..n).each {|i|
    (i+1..n).each {|j|
      (j+1..n).each {|k|
        if (i + j + k) == x && i != j && i != k && j != k
          test_arr.clear
          test_arr = i,j,k
          if c == 0 
            check_arr[c] = i,j,k
            c += 1
            # puts "if c == 0の中"
            count += 1
          else
            check_num = 0
            (0..(c - 1)).each {|c|
              # puts "eachの中"
              if check_arr[c].sort == test_arr.sort  
                # puts "breakしまーす"
                break
              end
              # puts "check_numを１増やしまーす"
              check_num += 1
            }
            if check_num == c 
                # print check_arr[c].sort
                # puts
                # print test_arr.sort
                # puts
                check_arr[c] = i,j,k 
                c += 1
                # puts "elseの中"
                count += 1
            end
          end
        end
      }
    }
  }
  puts count
end






Measured memory_bytes: 6908
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# define mid (l+r>>1)
using namespace std;
const int MAX=2e3+1;
int n,k,q;
int a[MAX],b[MAX];
int read()
{
	int x=0;
	char ch=getchar();
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);x=x*10+ch-48,ch=getchar());
	return x;
}
bool look(int l,int r)
{
	int ans=0;
	for(int y=1,x=1;x<=n;x=y+1,y=x)
	  {
	  	if(a[x]<l) continue;
		for(;y<=n&&a[y]>=l;++y);
		int num=0;
		for(int j=x;j<y;++j)
		  if(a[j]<=r) ++num;
		ans+=min(num,max(0,y-x-k+1));
	  }
	return ans>=q;
}
int main()
{
	n=read(),k=read(),q=read();
	for(int i=1;i<=n;++i)
	  b[i]=a[i]=read();
	sort(b+1,b+1+n);
	int minn=b[q]-b[1],L=unique(b+1,b+1+n)-b-1;
	for(int i=1;i<=L;++i)
	  {
	  	int l=i,r=L,ans=1e9;
	  	while(l<=r)
	  	if(look(b[i],b[mid])) ans=b[mid]-b[i],r=mid-1;
	  	else l=mid+1;
		minn=min(minn,ans);
	  }
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
 
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
 
#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll alp[26] = {0};
  rep(i,s.size()) alp[s[i]-'a']++;
  ll ans = 0;
  rep(i,26) ans += alp[i] * (alp[i] - 1 ) / 2;
  cout<<s.size()*(s.size()-1)/2 - ans +1<<endl;
  
}
 
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 720