akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int fu(int a[],int k,int n,int x)
{
  int count=0;
  int flag=1;
  for(int i=0;i<n;i++)
  {
    
    if((a[i]+x-1)/x>=1)
      count+=(a[i]+x-1)/x-1;
  }
  /*if(count<=k)
    return true;
  else
    return false;
    */
  return count;
}
int main()
{
  int n;
  int k;
  cin>>n;
  cin>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  if(k==0)
    cout<<a[n-1]<<endl;
  else
  {
    int low=1;
    int high=a[n-1];
   // int flag=1;
    while(low<=high)
    {
      int mid=low+(high-low)/2;
      if(low==high)
      {
       cout<<low<<endl;
        return 0;
      }
   if(fu(a,k,n,mid)<=k)
     high=mid;
      else
        low=mid+1;
        
      
      
    }
  }
}

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

using namespace std;

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

    int r = 0;

    char last = 0;
    for(int i = 0; i < S.size(); i++ ) {
        if(S[i] == last) {
            i++;
            r++;
            last = 0;
            continue;
        }

        if(i == S.size() - 2 && S[i] == S[i+1]) {
            r++;
            break;
        }


        r++;
        last = S[i];
    }

    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 640
// ooooo      ooo                     
// `888b.     `8'                     
//  8 `88b.    8   .ooooo.   .oooo.   
//  8   `88b.  8  d88' `88b `P  )88b  
//  8     `88b.8  888   888  .oP"888  
//  8       `888  888   888 d8(  888  
// o8o        `8  `Y8bod8P' `Y888""8o 
// C++ Conpetitive Programming Template 
// Ver 2.0 (codename: Noa)
// Last Modified : 2019-06-07
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    str a,b,c;
    cin >> a >> b >> c;
    cout << a[0] <<  b[1] << c[2] << endl;
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 256
a,b,c  =map(int,input().split())

if a%2 == b%2 and b%2 == c%2:
    x = sorted([a,b,c])
    print((2*x[2]-x[1]-x[0])//2)
else:
    x = [a,b,c]
    cnt = 0
    for i in range(3):
        if x[i] % 2 == 0:
            cnt += 1
    if cnt == 1:
        for i in range(3):
            if x[i] % 2 == 1:
                x[i] += 1
        x.sort()
        print((2*x[2]-x[1]-x[0])//2 +1)
    else:
        for i in range(3):
            if x[i] % 2 == 0:
                x[i] += 1
        x.sort()
        print((2*x[2]-x[1]-x[0])//2 +1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int a[1000];
ll M = 1e9 + 7;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;
  for(int i = 0; i < N; i++){
    int t = S[i];
    a[t]++;
  }
  ll ans = 1;
  for(int i = 'a'; i <= 'z'; i++){
    ans = ans*(a[i] + 1) %M;
  }
  ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def unite(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

    def get_size(self, x):
        return -self.table[self._root(x)]


n, m = map(int, input().split())
uft = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uft.unite(a, b)

ans = 0
for p in uft.table:
    if p < 0:
        ans += 1
print(ans - 1)


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

ll a[100010];
ll b[100010];
ll n, m;
ll sum[100010];

bool ok(ll k, ll &s) {
    ll cnt = 0;
    ll num = 0;

    for (int i = 0; i < n; i++) {
        ll pos = n - (lower_bound(b,b+n,k+1-a[i]) - b);
        num += (upper_bound(b,b+n,k-a[i]) - lower_bound(b,b+n,k-a[i]));
        cnt += pos;
        s += pos * a[i];
        if (pos > 0) {
            s += sum[pos - 1];
        }
    }
    if (cnt < m) {
        s += min(m - cnt, num) * k;
        return 1;
    }
    return cnt <= m;
}

int main() {
    ll s;
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    for (int i = 0; i < n; i++) b[i] = a[i];
    reverse(a,a+n);
    for (int i = 0; i < n; i++) {
        sum[i] = a[i];
        if (i != 0) sum[i] += sum[i-1];
    }

    ll left = 0, right = 200010;
    ll ans = 0;
    while (left < right) {
        s = 0;
        ll mid = (left + right) / 2;
        if (ok(mid, s)) {
            ans = max(ans,s);
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<int> L(2 * N);
	vector<int> n(N);
	rep(i, 2 * N)cin >> L[i];
	sort(L.begin(), L.end());
	rep(i, N) n[i] = min(L[i * 2], L[i * 2 + 1]);
	cout << accumulate(n.begin(), n.end(), 0) << endl;
	cin >> N;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
int main()
{
        int n;
        cin>>n;
        if(n==1)
                cout<<"Hello World"<<endl;
        else
        {
                int a,b;
                cin>>a>>b;
                cout<<a+b<<endl;
        }
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	int div[n][2];
	int gcd = 0;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	} int resl = a[0];
	int resr = a[n-1];
	for(int i = 0; i < n; i++) {
		resl = __gcd(resl, a[i]);
		div[i][0] = resl;
		resr = __gcd(resr, a[n-i-1]);
		div[n-i-1][1] = resr;
	} for(int i = 0; i < n; i++) {
		if(i == 0) gcd = div[i+1][1];
		else if(i == n-1) gcd = div[i-1][0];
		else gcd = __gcd(div[i-1][0], div[i+1][1]);
		ans = max(gcd, ans);
	} cout << ans;
	return 0;
}

Measured memory_bytes: 1408
def topologicalSort(g: list, deg: list):
	ret = []
	q = []
	for i, d in enumerate(deg):
		if not d:
			ret.append(i)
			q.append(i)
	while q:
		cur = q.pop(0)
		for nxt in g[cur]:
			deg[nxt] -= 1
			if not deg[nxt]:
				ret.append(nxt)
				q.append(nxt)
	return ret

def main():
	v, e, *L = map(int, open(0).read().split())
	g = [[] for _ in range(v)]
	rev = [[] for _ in range(v)]
	deg = [0] * v
	for s, t in zip(*[iter(L)] * 2):
		g[s - 1].append(t - 1)
		rev[t - 1].append(s - 1)
		deg[t - 1] += 1
	order = topologicalSort(g, deg)
	idx = [None] * v
	for i, o in enumerate(order):
		idx[o] = i
	ans = [0] * v
	for i in range(v):
		if rev[i]:
			ans[i] = max(rev[i], key=lambda x: idx[x]) + 1
	print("\n".join(map(str, ans)))

if __name__ == "__main__":
	main()


Measured memory_bytes: 57288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; 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>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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 n;
    cin >> n;
    VI l(n);
    rep(i,n) cin >> l[i];
    sort(all(l));
    ll ans = 0;
    rep(i,n) rep(j,n){
        if (i >= j) continue;
        int a = l[i], b = l[j];
        int pos = lower_bound(all(l), a+b) - l.begin() - 1;
        ans += pos - j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
int d[200];
int main(){
	int k, t;
	cin>>k>>t;
	rep(i, t) cin>>d[i];
	sort(d, d+t);
	int a = d[t-1];
	if(a*2-1<=k) cout<<0<<endl;
	else {
		int b = k-a;
		a -= b+1;
		cout<<a<<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;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}
int main(){
	ll a,b;cin>>a>>b;
	ll g=__gcd(a,b);
	auto mp=prime_factor(g);
	cout<<1+mp.size()<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,m;
  cin >> n >> m;
  vec s(n),t(m);
  for(ll i=0;i<n;i++) cin >> s[i];
  for(ll i=0;i<m;i++) cin >> t[i];
  mat sum(n+1,vec(m+1,0));
  mat dp(n+1,vec(m+1,0));
  dp[0][0]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<m;j++) {
      if(s[i]==t[j]) {
        dp[i+1][j+1]=(sum[i][j]+1)%mod;
      }
      sum[i+1][j+1]=(sum[i+1][j]+sum[i][j+1]-sum[i][j]+dp[i+1][j+1]+mod)%mod;
    }
  }
  cout << (sum[n][m]+1)%mod << endl;
}

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}


ll solve(ll src ,set<ll>& a)
{
    static map<ll,ll> list;
    if(a.find(src)!=a.end()) return 0; //steps broken
    if(src < 0) return 0;//from basement
    if(src == 0) return 1;//from basement
    if(src == 1) return 1;
    if(list.find(src)!=list.end()) return list[src];
    list[src]=(solve(src-1,a) + solve(src-2,a) )% mod;
    return list[src];
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // source code

    ll n,m;
    set<ll> a;
    cin >> n >> m;
    rep(i,m){
        ll t;
        cin >> t;
        a.insert(t);    
    }

    cout << solve(n,a) << endl;

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  ll l, r;
  cin >> l >> r;
  if(r - l >= 2019){
    cout << 0;
  }
  else{
    ll ans = 2018;
    for(long long i = l; i <= r - 1; i++){
      for(long long j = i + 1; j <= r; j++){
        ll a, b;
        a = i % 2019;
        b = j % 2019;
        
        ll x;
        x = (a * b) % 2019;
        
        ans = min(ans, x);
      }
    }
   cout << ans;
  }
        
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)

int main()
{
    int no_of_elements;
    scanf("%d", &no_of_elements);

    const int oo = 1e9;
    int minimum = oo, maximum = -oo;

    while(no_of_elements--)
    {
        int element;
        scanf("%d", &element);

        maximum = max(maximum, element);
        minimum = min(minimum, element);
    }

    int difference = maximum - minimum;
    printf("%d\n", difference);

    return 0;
}


Measured memory_bytes: 128
move = []
min_time =0

N = int(input())
for i in range (5):
    move.append(int(input()))

if (N == min(move)):
    min_time = 5;
elif (N//min(move) == N/min(move)):
    min_time = N//min(move) + 4;
else:
    min_time = N//min(move) + 5;

print (min_time);

Measured memory_bytes: 3064
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            String S,T;
            int ans = 0;

            S = Console.ReadLine();
            T = Console.ReadLine();

            for (int i=0; i<S.Length; i++)
            {
                if (T[i] != S[i])
                {
                    ans++;
                }
            }
            
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18176
#include <cstdio>
#include <algorithm>

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
int A, B, Q;

ll s[100002];
ll t[100002];
ll xs[100001];

ll dis(ll a, ll b) {
  return a > b ? a-b : b-a;
}

int main() {
  scanf("%d %d %d\n", &A, &B, &Q);

  REP(i, A) scanf("%lld\n", &s[i+1]);
  s[0] = -100000000001;
  s[A+1] = 100000000001;
  REP(i, B) scanf("%lld\n", &t[i+1]);
  t[0] = -100000000001;
  t[B+1] = 100000000001;
  REP(i, Q) scanf("%lld\n", &xs[i]);
  std::sort(s, s+A+2);
  std::sort(t, t+B+2);
  REP(i, Q) {
    ll x = xs[i];
    ll best = 1000000000000000000;
    scanf("%lld\n", &x);

    ll sright = *std::lower_bound(s, s+A+2, x);
    ll sleft = *(std::lower_bound(s, s+A+2, x) - 1);
    ll tright = *std::lower_bound(t, t+B+2, x);
    ll tleft = *(std::lower_bound(t, t+B+2, x) - 1);

    // sright
    ll srtr = *std::lower_bound(t, t+B+2, sright);
    if (best > dis(sright, x) + dis(sright, srtr)) {
      best = dis(sright, x) + dis(sright, srtr);
    }
    ll srtl = *(std::lower_bound(t, t+B+2, sright) - 1);
    if (best > dis(sright, x) + dis(sright, srtl)) {
      best = dis(sright, x) + dis(sright, srtl);
    }
    // sleft
    ll sltr = *std::lower_bound(t, t+B+2, sleft);
    if (best > dis(sleft, x) + dis(sleft, sltr)) {
      best = dis(sleft, x) + dis(sleft, sltr);
    }
    ll sltl = *(std::lower_bound(t, t+B+2, sleft) - 1);
    if (best > dis(sleft, x) + dis(sleft, sltl)) {
      best = dis(sleft, x) + dis(sleft, sltl);
    }
    // tright
    ll trsr = *std::lower_bound(s, s+A+2, tright);
    if (best > dis(tright, x) + dis(tright, trsr)) {
      best = dis(tright, x) + dis(tright, trsr);
    }
    ll trsl = *(std::lower_bound(s, s+A+2, tright) - 1);
    if (best > dis(tright, x) + dis(tright, trsl)) {
      best = dis(tright, x) + dis(tright, trsl);
    }
    // tleft
    ll tlsr = *std::lower_bound(s, s+A+2, tleft);
    if (best > dis(tleft, x) + dis(tleft, tlsr)) {
      best = dis(tleft, x) + dis(tleft, tlsr);
    }
    ll tlsl = *(std::lower_bound(s, s+A+2, tleft) - 1);
    if (best > dis(tleft, x) + dis(tleft, tlsl)) {
      best = dis(tleft, x) + dis(tleft, tlsl);
    }
    printf("%lld\n", best);
  }
  return 0;
}


Measured memory_bytes: 3712
#pragma region // {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion // }}}

void main() {
    string s;
    cin >> s;
    int ans=0;
    REP(i,SZ(s)) if ( s[i]=='1' ) ans++;
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3688
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		double a = scane.nextDouble();

		double b = scane.nextDouble();

		double C = scane.nextDouble();

		System.out.println(a*(b*Math.sin(Math.toRadians(C)))/2);

		System.out.println(a+b+Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2)-(2*a*b*Math.cos(Math.toRadians(C)))));

		System.out.println(Math.sin(Math.toRadians(C))*b);

	}

}

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

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

    int ans = 0;
    if (N >= 105) {
        for (int i = 105; i <= N; i+=2) {
            int count = 0;
            for (int j = 1; j <= N; j++) {
                if (i%j == 0) count++;
            }
            if (count == 8) ans++;
        }
    }

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



Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
num=defaultdict(int)
sm=0
for e in a:
    sm+=e
    num[e]+=1
q=int(input())
for _ in range(q):
  b,c=map(int,input().split())
  ans= sm+(c-b)*num[b]
  num[c]+=num[b]
  num[b]=0
  sm=ans
  print(ans)
  


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

// red + blue
// = (all_xor ^ blue) + blue
// = (all_xor ^ blue) ^ blue + ((all_xor ^ blue) & blue) * 2
// = all_xor + ((all_xor & blue) ^ blue) * 2
//
// {1, 0} => 0
// {1, 1} => 0
// {0, 0} => 0
// {0, 1} => 1
int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> A(N);
	for (auto& e: A) scanf("%lld", &e);
	int64_t all_xor{};
	for (auto& e: A) all_xor ^= e;
	// all_xorが立ってればblueの総^が立つようなblueの選び方
	for (int row{60}, col{}; row >= 0 && col < N; row--)
	{
		if (all_xor >> row & 1) continue;
		for (int i{col}; i < N; i++)
			if (A[i] >> row & 1)
			{
				std::swap(A[col], A[i]);
				break;
			}
		if (~A[col] >> row & 1) continue;
		for (int i{}; i < N; i++)
			if (i != col && (A[i] >> row & 1))
				A[i] ^= A[col];
		col++;
	}
	int64_t blue{};
	for (auto& e: A) blue ^= e;
	printf("%lld\n", all_xor + 2 * ((all_xor & blue) ^ blue));

	return 0;
}

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

int main() {
	string s,s1="",s2="";
	int diff1=0,diff2=0;
	cin>>s;
	int len=s.length();
	if(len==1)
	{
		cout<<0;
		return 0;
	}
	for(int i=0;i<len;i++)
	{
		if(i%2==0)
		{
			s1+='0';
			
		}
		else
		s1+='1';
	}
	for(int i=0;i<len;i++)
	{
		if(i%2==0)
		{
			s2+='1';
			
		}
		else
		s2+='0';
	}
	for(int i=0;i<len;i++)
	{
		if(s[i]!=s1[i]) diff1++;
	}
	for(int i=0;i<len;i++)
	{
		if(s[i]!=s2[i]) diff2++;
	}
	cout<<min(diff1,diff2);
	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if (x==1) {
            System.out.println(0);
        }
        if(x==0) {
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 35688
#include<stdio.h>

int main(){
    int a, b, i;
    char op;
    for (i = 1; i > 0; i++){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '+'){
            printf("%d\n", a + b);
        }
        else if(op == '-'){
            printf("%d\n", a - b);
        }
        else if(op == '*'){
            printf("%d\n", a * b);
        }
        else if(op == '/'){
            printf("%d\n", a / b);
        }
        else if(op == '?'){
            break;
        }
    }
   return 0; 
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 2e5;
llong a[mxN+3],b[mxN+3],a2[mxN+3],b2[mxN+3],sb[mxN+3],sb2[mxN+3],c[mxN+3]; double f[mxN+3];
int stk[mxN+3];
int n,mxid,tp;

double calc(int l,int r,int k)
{
	double x = ((a[r]-a[l])-2.0*(r*(sb[r-1]-sb[l])-(sb2[r-1]-sb2[l])))/(r-l);
	double ret = a[l]+x*(k-l)+2.0*(k*(sb[k-1]-sb[l])-(sb2[k-1]-sb2[l]));
	return ret;
}

int main()
{
	n = read();
	for(int i=1; i<=n; i++) {scanf("%lld",&a[i]); if(mxid==0||a[i]>=a[mxid]) {mxid = i;}}
	for(int i=1; i<=n; i++) b[i] = read();
	for(int i=0; i<=n; i++) {a2[i] = a[(i+mxid-1)%n+1],b2[i] = b[(i+mxid-1)%n+1];}
	for(int i=0; i<=n; i++) {a[i] = a2[i],b[i] = b2[i];}
	for(int i=1; i<=n; i++) {sb[i] = sb[i-1]+b[i],sb2[i] = sb2[i-1]+b[i]*i;}
	tp = 0; stk[tp] = 0;
	for(int i=1; i<=n; i++)
	{
		while(tp>0&&calc(stk[tp-1],i,stk[tp])>=a[stk[tp]]) {tp--;}
		stk[++tp] = i;
	}
	for(int i=1; i<=tp; i++)
	{
		for(int j=stk[i-1]+1; j<=stk[i]; j++)
		{
			f[j] = calc(stk[i-1],stk[i],j);
		}
	}
	double ans = 0.0;
	for(int i=1; i<=n; i++) ans += f[i];
	ans /= n;
	printf("%.12lf\n",ans);
	return 0;
}

Measured memory_bytes: 15440
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>

int main(void) {

	int n, m, x;
	int left = 0, right = 0;

	std::cin >> n >> m >> x;

	for (size_t i = 0; i < m; i++) {
		int a;
		std::cin >> a;

		if (a < x) {
			left++;
		}
		else {
			right++;
		}
	}

	std::cout << std::min(left, right) << std::endl;

	return 0;
}

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

using namespace std;

int main()
{
    int N, Q;
    cin>>N>>Q;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;
    vector<long long> X(Q);
    for (long long &x: X)
        cin>>x;

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

    vector<long long> S1(N);
    S1[0] = A[0];
    S1[1] = A[1];
    for (int i=2; i<N; i++)
        S1[i] = S1[i-2] + A[i];

    vector<long long> S2(N);
    S2[N-1] = A[N-1];
    for (int i=N-2; i>=0; i--)
        S2[i] = S2[i+1] + A[i];

    for (long long x: X)
    {
        auto check = [&](long long t) -> bool
        {
            if (2*t > N)
                return false;
            if (t<=1)
                return true;

            long long a1 = A[N-t];
            long long a2 = A[N-2*t+1];
            return abs(a2-x) <= abs(a1-x);
        };

        if (N%2!=0 && abs(A[0]-x) <= abs(A[N/2]-x))
            cout<<S2[N/2]<<endl;
        else if (N%2==0 && abs(A[1]-x) <= abs(A[N/2]-x))
            cout<<S2[N/2]<<endl;
        else
        {
            long long t = 0;
            for (long long b=0x8000; b>0; b/=2)
                if (check(t+b))
                    t += b;

            cout<<S1[N-2*t-1] + S2[N-t]<<endl;
        }
    }
}


Measured memory_bytes: 4864
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S;
	cin >> N >> S;
	VI A(N,0), B(N,0);
	int suma = 0, sumb = 0;
	REP(i, N) {
		if (i == 0) {
			if (S[i] == '#') {
				A[i] = 1;
				suma++;
			}
		}
		else if (S[i] == '#'){
			A[i] = A[i - 1] + 1;
			suma++;
		}
		else {
			A[i] = A[i - 1];
		}
		//cout << A[i] <<" "<<S[i]<<" "<<i<< endl;
	}
	for (int i = N - 1; i >= 0; i--) {
		if (i == N-1) {
			if (S[i] == '.') {
				B[i] = 1;
				sumb++;
			}
		}
		else if (S[i] == '.') {
			B[i] = B[i + 1] + 1;
			sumb++;
		}
		else {
			B[i] = B[i + 1];
		}
	}
	int ans = LLINF;
	REP(i, N) {
		//cout << A[i] << " " << B[i] << endl;
		ans = min(ans, A[i] + B[i]-1);
	}
	ans = min(ans, suma);
	ans = min(ans, sumb);
	cout << ans << endl;
	return 0;
}



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

int solve(int x, int y, int w, int h, vector<vector<int> > &f)
{
int ans = 0;

if(f[x][y] == 0)
return 0;

f[x][y] = 0;

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

for(int i = 0; i < 4; ++i) {
int nx = dx[i] + x;
int ny = dy[i] + y;
if(nx < 0 || ny < 0 || nx >= w || ny >= h)
continue;
int tmp = solve(nx, ny, w, h, f);
ans = max(ans, tmp);
}

f[x][y] = 1;

return ans + 1;
}

int main()
{
while(true) {
int w, h;
vector<vector<int> > f;
scanf("%d%d", &w, &h);
if(w == 0)
break;
f.resize(w);
for(int i = 0; i < w; ++i)
f[i].resize(h);
for(int y = 0; y < h; ++y) {
for(int x = 0; x < w; ++x)
scanf("%d", &f[x][y]);
}
int ans = 0;
for(int x = 0; x < w; ++x) {
for(int y = 0; y < h; ++y)
ans = max(ans, solve(x, y, w, h, f));
}
printf("%d\n", ans);
}
return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define apo ios::sync_with_stdio(false);cin.tie(0)
#define MAX 1000
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}

ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

int main(){
	apo;
	ll i,n,k,sum=0;
	cin>>n>>k;
	ll arr[n];
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	for(i=0;i<k;i++){
		sum+=arr[i];
	}
	cout<<sum;
}
	
	


Measured memory_bytes: 3612
from itertools import permutations
from collections import Counter

N,*xyf = map(int, open(0).read().split())
xy = [(xyf[i*2],xyf[i*2+1]) for i in range(N)]
if N == 1:
    print(1)
else:
    count = []
    for a, b in permutations(xy,2):
        count.append((b[0]-a[0],b[1]-a[1]))
    c = Counter(count)
    print(N-max(c.values()))

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

int main () {
    int N;
    cin >> N;
    string alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string S;
    cin >> S;
    
    for (int i=0; i<S.size(); i++) {
        for (int j=0; j<26; j++) {
            if (alphabet.at(j)==S.at(i)) {
                cout << alphabet.at((j+N)%26);
            }
        }
    }
    cout << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long M){
    lli ans = 1900*M+100*(N-M);
    REP(i,0,M)ans*=2;
    cout<<ans<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    func(N, M);
    return 0;
}


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

int main(int argc, char **argv){
  int iN;
  string sNkind = "Three";
  string sS[100];

  cin >> iN;
  for(int i=0; i<iN; i++){
    cin >> sS[i];
    if(sS[i] == "Y"){
      sNkind = "Four";
    }
  }
  cout << sNkind << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
//using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));
const double pi = 3.14159265358979;

//関数：
int gcd(int mx, int mn) {
	if(mn == 0) return(mx);
	else gcd(mn, mx%mn);
}

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

	double a, b, x; cin >> a >> b >> x;
	double theta;

	if(x*2.0 <= a*a*b) theta = atan((2.0*x)/(b*b*a));
	else theta = atan((a*a*a)/(2.0*(a*a*b - x)));

	theta = 90.0 - (theta*180.0/pi);
	cout << fixed << setprecision(10) << theta << endl;
	return 0;
}
//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b);i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;

struct triple {
    ll l, r, w;
};

triple a[1000];
// i,j 以降は空いている
ll dp[2][400][400];
int n;

ll solve(){
    memset(dp, 0, sizeof(dp));
    sort(a, a + n, [](triple const& a, triple const& b){
        return a.l < b.l;
    });
    rep(i, n){
        auto next = dp[i & 1];
        auto cur = dp[(i + 1) & 1];
        int l = a[i].l;
        int r = a[i].r;
        int w = a[i].w;
        rep(j, 380){
            rep(k, 380){
                next[j][k] = cur[j][k];
                if (j != 0){
                    next[j][k] = max(next[j][k], next[j - 1][k]);
                }
                if (k != 0){
                    next[j][k] = max(next[j][k], next[j][k - 1]);
                }
                if (j == r){
                    next[j][k] = max(next[j][k], cur[l][k] + w);
                }
                if (k == r){
                    next[j][k] = max(next[j][k], cur[j][l] + w);
                }
            }
        }
    }
    return max(dp[0][370][370], dp[1][370][370]);
}

int main(){
    while (cin >> n && n){
        rep(i, n){
            ll l, r, w; cin >> l >> r >> w;
            r++;
            a[i] = { l, r, w };
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

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

int main(void){
	int x,y;
	std::cin >> x;
	y = x*360/gcd(x,360);
	std::cout << y/x << std::endl;
	return 0;
}


Measured memory_bytes: 3632
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
        a: [u32; 1 << n],
    }
    let mut a = a;
    a.push(0);
    let mut dp = vec![(0, 1 << n); 1 << n];
    for i in 1..(1 << n) {
        dp[i].0 = i;
    }
    for j in 0..n {
        for i in 1..(1 << n) {
            if (i >> j) & 1 == 0 {
                continue;
            }
            let (x, y) = dp[i];
            let (z, w) = dp[i ^ (1 << j)];
            dp[i] = if x == z {
                (x, if a[y] >= a[w] {y} else {w})
            } else if a[x] >= a[z] {
                (x, if a[z] >= a[y] {z} else {y})
            } else {
                (z, if a[x] >= a[w] {x} else {w})
            };
        }
    }
    let mut ans = a[1] + a[0];
    for i in 1..(1 << n) {
        ans = std::cmp::max(ans, a[dp[i].0] + a[dp[i].1]);
        writeln!(out, "{}", ans).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 17528
from collections import deque
N, K = map(int, input().split())
dt = []
for _ in range(N):
    t, d = map(int, input().split())
    dt.append((d, t))
dt.sort(reverse=True)

s = set()
bests = []
rems = deque()
for d, t in dt:
    if t in s:
        rems.append(d)
    else:
        s.add(t)
        bests.append(d)
    if len(bests) == K:
        break
x = len(bests)
k = x
p = sum(bests) + x * x
while k < K:
    p += rems.popleft()
    k += 1
maxp = p
while len(rems) and rems[0] > bests[-1]:
    p -= bests.pop() + x * x
    x -= 1
    p += rems.popleft() + x * x
    maxp = max(maxp, p)
print(maxp)


Measured memory_bytes: 20048
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=new int[10][];
		for(int i = 0;i<10;i++) {
			a[i]=new int[10];
		}
		for(int i = 1;i<=n;i++) {
			var t=i.ToString();
			a[t[0]-'0'][t[t.Length-1]-'0']++;
		}
		long ans=0;
		for(int i = 0;i<10;i++) {
			for(int j = 0;j<10;j++) {
				ans+=((long)a[i][j])*a[j][i];
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 17360
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if(S[K-1] == 'A') S[K-1] = 'a';
  if(S[K-1] == 'B') S[K-1] = 'b';
  if(S[K-1] == 'C') S[K-1] = 'c';
  cout << S << rt;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
if a > 0 and b > 0:
    print("Positive")
elif a < 0 and b > 0:
    print("Zero")
elif a == 0 or b == 0:
    print("Zero")
else:
    d = abs(a) - abs(b)
    if d % 2 == 1:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 9112
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

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

#define pow CHANGETHENAMESTUPID

using namespace std;

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

const int N = 1e5 + 100;

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

void load() {
	scanf("%d", &n);
	FOR(i, n) scanf("%d", a + i);
	FOR(i, n) scanf("%d", b + i);
}

bool solve() {
	vector<pii> bs;
	FOR(i, n) bs.push_back({b[i], i});
	sort(bs.begin(), bs.end());
	vector<int> as(n);
	FOR(i, n) as[i] = a[bs[i].second];
	sort(a, a + n);
	FOR(i, n) if (a[i] > bs[i].first) return false;
	for (int i = 1; i < n; i++) if (a[i] == a[i-1]) return true;
	vector<pii> ass;
	FOR(i, n) ass.push_back({as[i], bs[i].second});
	sort(ass.begin(), ass.end());
	vector<pii> cyc;
	cyc.push_back({0, ass[0].second});
	vector<int> has(n);
	FOR(i, n) has[ass[i].second] = i;
	while (true) {
		pii p = cyc.back();
		int kuda = bs[p.first].second;
		int kudass = has[kuda];
		if (kudass == 0) break;
		cyc.push_back({kudass, ass[kudass].second});
	}
	//for (auto x : cyc) printf("%d %d\n", x.first, x.second);
	if ((int)cyc.size() < n-1) return true;
	for (int i = 1; i < n; i++) if (ass[i].first <= bs[i-1].first) return true;
	return false;
}

int main() {
	load();
	printf("%s\n", (solve()) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 4852
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main(void)
{
    int N, od;
    scanf("%d", &N);
    od = (N + 1) / 2;
    float ans;
    ans = float(od / N);
    printf("%f\n", double(od) / N);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        int result = 0;
        int l = 0;
        int r = s.length() - 1;
        while (l < r) {
            if (s.charAt(l) != s.charAt(r)) {
                if (s.charAt(l) == 'x') {
                    l++;
                    result++;
                } else if (s.charAt(r) == 'x') {
                    r--;
                    result++;
                } else {
                    result = -1;
                    break;
                }
            } else {
                l++;
                r--;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 25556
#include <stdio.h>

int main(void){
    long n,k,min;
    scanf("%ld %ld", &n,&k);
    n%=k;
    min=n;
    while(1){
        n-=k;
        if(n<0){
            n*=-1;
        }
        /*nを正にする*/
        if(n<min){
            min=n;
        }
        else{
            break;
        }
    }
    printf("%ld\n",min);
    return 0;
}


Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    p = list(map(int, input().split()))
    check = [i for i in range(1, n+1)]
    cnt = 0
    for a, b in zip(p, check):
        if a != b:
            cnt += 1
    if cnt == 0 or cnt == 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9108