akhauriyash/Code-Regression huggingface dataset:
## abc070d: Transit Tree Path

n = int(input())

T = [None]*(n+1)
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    if(T[v1] is None): T[v1] = [[v1,v2,d]]
    else: T[v1].append([v1,v2,d])
    if(T[v2] is None): T[v2] = [[v2,v1,d]]
    else: T[v2].append([v2,v1,d])

q,k = map(int, input().split())

visit = [False]*(n+1)
depth = [0]*(n+1)
stack = [[0,k,0]]
while stack:
    p,c,d = stack.pop()
    if visit[c]: continue
    visit[c] = True
    depth[c] = depth[p] + d
    for pp,cc,dd in T[c]:
        if not visit[cc]: stack.append([pp,cc,dd])

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1]+depth[v2])

Measured memory_bytes: 51412
import copy
import sys
sys.setrecursionlimit(4100000)

n = int(input())
p = [int(i) for i in input().split()]

d = copy.deepcopy(p)
p.sort()
counter = 0
for i in range(n):
    if p[i] != d[i]:
        counter += 1
    if counter >= 3:
        break
if counter >= 3:
    print("NO")
else:
    print("YES")


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

using namespace std;

int main() {
  int H, W, D;
  cin >> H >> W >> D;
  vector<pair<int, int>> A(H * W + D + 1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int a;
      cin >> a;
      A[a] = {i, j};
    }
  }
  int Q;
  cin >> Q;
  vector<int> L(Q), R(Q);
  for (int i = 0; i < Q; i++) {
    cin >> L[i] >> R[i];
  }

  vector<long long> C(H * W + D + 1);
  for (int i = 0; i <= H * W; i++) {
    C[i + D] = abs(A[i].first - A[i + D].first) + abs(A[i].second - A[i + D].second) + C[i];
  }
  for (int i = 0; i < Q; i++) {
    cout << C[R[i]] - C[L[i]] << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


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

#define MAX_N 2003

const int mod = 1e9+7;
int fact[MAX_N] ,factinv[MAX_N];

int nCr(int n ,int r){
    if(r > n || r < 0) return 0;
    return 1LL*fact[n]*factinv[n-r]%mod*factinv[r]%mod;
}
int modinv(int a ,int p=mod-2){
    int x = 1;
    for( ; p; p>>=1){
        if(p&1)
            x = 1LL*x*a%mod;
        a = 1LL*a*a%mod;
    }
    return x;
}

int main()
{
    fact[0] = factinv[0] = 1;
    for(int i=1; i<MAX_N; i++){
        fact[i] = 1LL*i*fact[i-1]%mod;
        factinv[i] = modinv(fact[i]);
    }

    int n ,k;
    scanf("%d%d",&n,&k);
    printf("%d\n",n-k+1);
    for(int i=2; i<=k; i++)
        printf("%d\n",1LL*nCr(k-1 ,i-1)*(nCr(n-k-1 ,i)+2LL*nCr(n-k-1 ,i-1)+nCr(n-k-1 ,i-2))%mod);
}


Measured memory_bytes: 256
t = gets.chomp.split.map(&:to_i)
t.sort!
ans = 0
ans += (t[0] - t[1]).abs/2
t[0] +=  ans * 2
if(t[0] == t[1]) 
  ans += t[2] - t[0] 
else
  ans += t[2] - t[0] + 1
end
p ans

Measured memory_bytes: 1788
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

ll i,j,k,l,ii,jj;
ll n,m;
ll a[100005],b[100005];
ll ab[200005];
bool x[200005];
ll num=0;
ll ans=1;
bool flag=false;


ll kai(ll x){
    ll kotae=1;
    for(i=1;i<=x;i++){
        kotae*=i;
        kotae %=mod;
    }
    return kotae;
}

int main(){
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        ab[i]=a[i];
    }
    for(i=0;i<n;i++){
        cin>>b[i];
        ab[i+n]=b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(ab,ab+2*n);
    ll af=0,bf=0;
    ll aru=0,bru=0;
    num=0;
    while(true){
        if(af==n)af=n-1;
        else if(bf==n)bf=n-1;
        if(a[af]==ab[num]){
            aru++;
            af++;
        }else if(b[bf]==ab[num]){
            bru++;
            bf++;
        }
        if(aru==1 && bru>=1){
            ans *= bru;
            ans %=mod;
            aru--;
            bru--;
        }else if(bru==1 && aru>=1){
            ans *= aru;
            ans %=mod;
            aru--;
            bru--;
        }
        num++;
        if(num>=2*n)break;
    }
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 8064
r, c = [int(i) for i in input().split()]
 
data = []
sum_row = [0] * (c + 1)
 
for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7676
n,m = map(int,input().split())
h = list(map(int,input().split()))

tembo = [True]*n

for i in range(m) :
    a,b = map(int,input().split())
    d = h[a-1] - h[b-1]
    if d>0 :
        tembo[b-1] = False
    elif d<0:
        tembo[a-1] = False
    else :
        tembo[a-1] = False
        tembo[b-1] = False

print(tembo.count(True))


Measured memory_bytes: 20112
n,k=map(int,input().split())
a=list(map(int,input().split()))
t1=[0]*n
t2=[0]*n
for i in range(n):
  for j in range(n):
    if a[i]>a[j]:
      t1[i]=t1[i]+1
      if i<j:
        t2[i]=t2[i]+1
ans=0
for i in range(n):
  ans=(ans+k*t2[i]+(k*(k-1)*t1[i])//2)%(10**9+7)
print(ans)

Measured memory_bytes: 9244
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=[input() for i in range(n)]
dic=defaultdict(int)

for i in range(n):
    dic[s[i]]+=1

print("AC x "+str(dic["AC"]))
print("WA x "+str(dic["WA"]))
print("TLE x "+str(dic["TLE"]))
print("RE x "+str(dic["RE"]))
# AC x 3
# WA x 1
# TLE x 2
# RE x 0


Measured memory_bytes: 81432
#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

string tri(int a, int b, int c){
	if(a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)return "YES";
	return "NO";
}

int main(void) {
	int len, a, b, c;
	cin >> len;
	for(int i = 0; i < len; i++){
		cin >> a >> b >> c;
		cout << tri(a, b, c) << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007
#define PI 3.14159265
#define seive_len 1

typedef long long int lli;

int *array;
int seive[seive_len];

long long int min(long long int a, long long int b) {
    return a<b?a:b;
}

long long int max(long long int a, long long int b) {
    return a>b?a:b;
}

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

int cmp(const void *a, const void *b){
    int ia = *(int *)a;
    int ib = *(int *)b;
    return array[ia] < array[ib] ? -1 : array[ia] > array[ib];
}

long double abs1(long double n) {
    if(n < 0)
        return n*(-1.0);
    return n*1.0;
}

void swap(int *a, int *b) {
    *a = (*a)^(*b);
    *b = (*a)^(*b);
    *a = (*a)^(*b);
}

int binSearch(int a[], int x, int l, int r) {
    if(r >= l) {
        int mid = l + ((r-l)>>1);
        if(a[mid] == x)
            return mid;
        if(a[mid] > x) {
            return binSearch(a, x, l, mid-1);
        }
        else if(a[mid] < x) {
            return binSearch(a, x, mid+1, r);
        }
    }
    return -1;
}

void makeSeive() {
    int i;
	seive[1] = 1;
    for(i=2;i<seive_len;i++) {
        if(seive[i] == 0) {
            long long int temp=(long long int)i*i;
            while(temp <= seive_len-1) {
                seive[temp] = 1;
                temp += i;
            }
        }
    }
}

int isPrime(int n) {
    int i;
    for(i=2;i*i<=n;i++)  {
        if(n%i == 0)
            return 0;
    }
    return 1;
}

void getInput(lli a[], lli n) {
    for(lli i=0;i<n;i++)
        scanf("%lld", &a[i]);
}

void testCase() {
    lli n, i, k;
    scanf("%lld%lld", &n, &k);
    lli a[n];
    getInput(a, n);
    qsort(a, n, sizeof(lli), compare);
    // for(i=0;i<n;i++)
    //     printf("%lld ", a[i]);
    lli sum = 0;
    for(i=0;i<k;i++)
        sum += a[i];
    printf("%lld", sum);
}

int main() {
    int t=1;
    // scanf("%d", &t);
    // makeSeive();
    while(t--) {
        testCase();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1744
import java.util.Map.Entry;
import java.util.*;
 
//import org.w3c.dom.css.Counter;
 
public class Main {
//public class App {
 
    public static void main(final String[] args){
     //スキャン
     final Scanner s = new Scanner(System.in);
      int N = Integer.parseInt(s.next());
      int K = Integer.parseInt(s.next());
      ArrayList<Long> A = new ArrayList<Long>();
      for(long i=0;i<N;i++){
            A.add(s.nextLong());
      }
      //出力回数
      int counter = N-K;
      //今何回出力したか
      int now = 0;
      //比較対象１
      long bef =1;
      //比較対象2
      long aft =1;
      while(counter > now){
        //初回のみこっち
        

            //befだけが持つやつ
            bef = A.get(now);
            //aftに増えるやつ
            aft = A.get(now+K);
          
        //カウントアップ
        now ++;
        if(bef<aft){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
      }
    }
}

Measured memory_bytes: 66720
s = str(input())
q = int(input())
now = True
before = str()
after = str()

for i in range(q):
    que = list(map(str,input().split()))
    if que[0] == "1":
        now = not now
    else:
        if que[1] == "1":
            if now:
                before += (que[2])
            else:
                after += (que[2])
        else:
            if not now:
                before += (que[2])
            else:
                after += (que[2])

ans = (before[::-1] + s + after)
if now:
    print(ans)
else:
    print(ans[::-1])

Measured memory_bytes: 4596
N, M = map(int, input().split())

H = list(map(int, input().split()))

x = [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] < H[B-1]:
        x[A-1] &= 0
        x[B-1] &= 1
    elif H[A-1] > H[B-1]:
        x[A-1] &= 1
        x[B-1] &= 0
    else:
        x[A-1] &= 0
        x[B-1] &= 0

print(sum(x))

Measured memory_bytes: 20068
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,k;
int main()
{
    cin>>a>>b>>c;
    if(b>=a){
        cout<<1<<endl;
        return 0;
    }
    if(c>=b){
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)
        k=1;
    cout<<((a-b)/(b-c)+k)*2+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    long n;
    cin >> n;
    cout << 180*(n-2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n + 1, 0);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if (v[t] == 0) {
            k--;
        }
        v[t]++;
    }
    vector<int> c;
    for (int i = 1; i <= n; i++) {
        if (v[i] > 0) {
            c.push_back(v[i]);
        }
    }
    sort(c.begin(), c.end());
    if (k < 0) {
        cout << accumulate(c.begin(), c.begin() - k, 0) << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 4836
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a>b){
		cout<<"a > b"<<endl;
	}
	else{
		cout<<"a == b"<<endl;
	}


	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define mod 1000000009
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
vector<pi> v;
bool compare(pi a,pi b) {
    if (a.second!=b.second) return a.second<b.second;
    return a.first<b.first;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b,n,m;
    cin>>n>>m;
    for (int i=0;i<m;i++) {
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end(),compare);
    int ans = 0,j;
    for (int i=0;i<v.size();i++) {
        ans++;
        j = v[i].second;
        while (i<v.size() && v[i].first<j) {
            i++;
        }
        i--;
    }
    cout<<ans;
}


Measured memory_bytes: 1528
h,w = map(int,input().split())
f = [input()for i in range(h)]
H = []
W = []
for i in range(h):
    ok = True
    for j  in range(w):
        if f[i][j] == '#':
            ok = False
            break
    if ok:H.append(i)
for i in range(w):
    ok = True
    for j in range(h):
        if f[j][i] == '#':
            ok = False
            break
    if ok:W.append(i)
nf = []
for i in range(h):
    p = []
    for j in range(w):
        if  i in H or j in W:continue
        p.append(f[i][j])
        
    if len(p) > 0:nf.append(p)
for i in range(len(nf)):
    print("".join(nf[i]))
               
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vdebug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;
    int slen = s.length();

    ll res = 0;
    ll cnt = 0;
    repr(i, slen-1, 0){
        if(s[i] == 'B'){
            res += (slen - 1 - cnt) - i;
            cnt++;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 720
//
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};

int cnt[10][10];
int d[10][10];
int main(){
    int N;
    cin>>N;
    string s;
    cin>>s;
    for(int i:range(N-1)){
        cnt[s[i]-'0'][s[i+1]-'0']++;
    }
    pair<int,vector<int>> ret(912345,vector<int>());
    vector<int> o(9);
    iota(ALL(o),1);
    do{
        for(int i:range(1,10)){
            d[i][i]=0;
            for(int j:range(1,10))d[i][j]=10;
        }
        for(int i:range(6)){
            d[o[i]][o[i+3]]=1;
            d[o[i+3]][o[i]]=1;
        }
        for(int i:range(10)){
            if(i%3){
                d[o[i]][o[i-1]]=1;
                d[o[i-1]][o[i]]=1;
            }
        }
        for(int k:range(1,10))
        for(int i:range(1,10))
        for(int j:range(1,10))
        chmin(d[i][j],d[i][k]+d[k][j]);
        int ans=0;
        for(int i:range(1,10)){
            for(int j:range(1,10)){
                ans+=d[i][j]*cnt[i][j];
            }
        }
        chmin(ret,make_pair(ans,o));
    }while(next_permutation(ALL(o)));
    for(int i:range(3)){
        for(int j:range(3)){
            cout<<ret.second[i*3+j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3328
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    D, G = map(int, input().split())

    PC = [list(map(int, input().split())) for _ in range(D)]

    result = 0
    new_dp = [0] * 1001

    for d, pc in enumerate(PC, 1):
        dp = new_dp[:]

        p, c = pc
        result += p

        s = {x: x * 100 * d for x in range(p)}
        s[p] = p * 100 * d + c

        for i in range(1, result + 1):
            for j in range(0, i + 1):
                if i - j > p:
                    continue
                else:
                    new_dp[i] = max(new_dp[i], dp[j] + s[i - j])

    for i, a in enumerate(new_dp):
        if a >= G:
            print(i)
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    else:
        print('1' + '0' * (N-1))
    exit()

ans = [-1 for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())

    if ans[s - 1] == -1 or ans[s - 1] == c:
        ans[s - 1] = c
    else:
        print(-1)
        exit()


if N != 1 and ans[0] == 0:
    print(-1)
    exit()


for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0

print(''.join([str(s) for s in ans]))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,sum=0; cin >> N;
  for(int i=1; i<=N; i++) {
    if(i%3 != 0 && i%5 != 0) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i=0; i<n; i++)
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int n;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n;
    cout<<(1000 - (n%1000))%1000<<"\n";
    return 0;
}

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

int main(){
    int d,g; cin >> d >> g ;
    vector<int> p(d),c(d); rep(i,d) cin >> p[i] >> c[i];
    int cnt;
    int cntmin = 1e9;
    int pnt;
    int restmax;
    int need;
    int restuse;
    for(int bit = 0; bit < (1<<d); bit++){
        cnt = 0,pnt = 0,restmax = -1;
        for(int j = 0; j < d; j++){
            if((1<<j) & bit){
                pnt += (j+1)*100*p[j] + c[j];
                cnt += p[j];
            }else{
                restmax = j;
            }
        }
        if(pnt < g){
            restuse = 100*(restmax + 1);
            need = (g - pnt + restuse - 1)/restuse;
            if(need >= p[restmax]) continue;
            cnt += need;
        }
        
        if(cnt < cntmin) cntmin = cnt;
    }
    cout << cntmin << endl;
}

Measured memory_bytes: 256
program sum_of_gcd_of_tuples
  implicit none
  integer :: k, i, j
  integer(8) :: x(200) = 0, y(200) = 0
  read(*,*) k
  do i = k, 1, -1
    x(i) = (k / i) ** 3
    do j = 2 * i, k, i
      x(i) = x(i) - x(j)
    end do
    y(i) = i
  end do
  write(*,'(i0)') dot_product(x, y)
end program sum_of_gcd_of_tuples

Measured memory_bytes: 2912
s = list(input())
lens = len(s)

for i in range(lens):
    for j in range(lens - i):
        left = s[0: j + 1]
        right = s[j + 1: lens - i]
        left = ''.join(left)
        right = ''.join(right)
        if left == right and i != 0:
            print(len(left)+len(right))
            exit()
        

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

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define ms memset
#define mp make_pair
#define f first
#define s second
#define int long long

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef pair<int, pair<int, int>> piii;

#define MAXN 1010
#define MAXK 5010


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

	int n;
	int d;

	cin >> n >> d;

	int ans = 0;

	while(n--){
		int x1, y1;

		cin >> x1 >> y1;

		double v = sqrt(x1*x1+y1*y1);

		if(v <= d)
			ans++;
	}

	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) <= abs(x - b)) {
        cout << "A" << endl;
    }else {
        cout << "B" << endl;
    }
}

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

#define ll long long int

using namespace std;

int main() {
    ll x, y;

    cin >> x >> y;

    if (2 * x > y || 4 * x < y) {
        cout << "No" << endl;
        return 0;
    }
    auto d = y - 2 * x;
    if (d % 2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std ;
int a[110] ;
int main()
{
  int n ;
  cin >> n ;
  int x = 0 ;
  for(int i = 1; i <= n ;i ++) cin >> a[i] , x = max(x , a[i]) ;;
  int ans = 1e9 ;
  for(int i = 1 ;i <= x ;i ++)
   {
     int res = 0 ;
     for(int j = 1; j <= n ;j ++)
      res += (a[j] - i) * (a[j] - i) ;
    //  cout << res << endl ;
    ans = min(ans , res) ;
   }
   cout << ans << endl ;
  return 0 ;
}


Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

template<typename T>
tuple<vector<T>, vector<bool>, vector<T>> prime_sieve(T lim) {
	vector<T> primes = vector<T>();
	vector<T> lp = vector<T>(lim+1, 0);
	vector<bool> composite = vector<bool>(lim+1);
	for (T num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) {
				lp[num] = primes[i];
				break;
			}
		}
	}
	return {primes, composite, lp};
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	auto [primes, composite, lp] = prime_sieve((int)min(1e3+100, ceil(sqrt(maxx)) + 100));
	umap<int, int> prime_freq = umap<int, int>();
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	for (const auto& [p, freq] : prime_freq) {
		max_freq = max(max_freq, freq);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

Measured memory_bytes: 10448
import java.io.*;
import java.util.*;
import java.lang.String;

class Main{
				
		public static void main(String args[]) throws IOException{
			String str;

			Scanner scan = new Scanner(System.in);
			
			scan.useDelimiter("\n");
			
			while(scan.hasNext()){
				str = scan.next();
				str = str.toUpperCase();
				System.out.println(str);
			}
		}
}

Measured memory_bytes: 11000
//AC 

//答案错误,原因：应该是i<n+1而不是i<=n+1,多算了一个i 
#include<stdio.h>
int main()
{
	int n,m,i,cnt=0;
	int a[105]={0};
	int b[105]={0};
	while(~scanf("%d%d",&n,&m)){
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}for(i=1;i<=n+1;i++){
			b[i]=b[i-1]+a[i];
		}for(i=0;i<n+1;i++){
			if(b[i]<=m){
				cnt++;
			}
		}printf("%d\n",cnt);
		cnt=0;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int z[1562500],i,j;
int main(void){
	for(;++i<1600;)
		if(!(z[i>>5]&1<<i))
			for(j=-2*i*~i;j<5000000;j+=i-~i)z[j>>5]|=1<<j;
	for(;scanf("%d",&i),i;)
		for(j=i-1>>1;i;j--)
			z[j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
	return 0;
}

Measured memory_bytes: 1016
from decimal import *
import re
def solve2(m, n):
    maxlen = 80
    PREC=180
    getcontext().prec = PREC
    x = Decimal(m) / Decimal(n)
    s = x.to_eng_string()
    if len(s) < PREC:
        return(s[2:],'')
    rep = 1
    while True:
        r = r'(.{%d})\1{%d,}' % (rep, int(maxlen/rep))  #ex. '(.{6})\\1{13,}'
        a=re.search(r, s)
        if a:
            break
        rep += 1
        if rep > maxlen:
            raise ValueError('This cannot happen.rep=%d' % rep)

    u = s[2:a.start()+len(a.group(1))]
    v = (' '*PREC + '^'*len(a.group(1)))[-len(u):]
    return(u,v)

while True:
    try:
        m,n = map(int, input().strip().split())
        s,t = solve2(m, n)
        print(s)
        if t!='':
            print(t)
    except EOFError:
        break

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<double, double>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

P sub_vector(P a, P b)
{
    P res;

    res.fi = a.fi - b.fi;
    res.se = a.se - b.se;

    return res;
}

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

    double x1, x2, x3, y1, y2, y3, xp, yp;
    
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
    {
        P AB = sub_vector(P{x2, y2}, P{x1, y1});   
        P BP = sub_vector(P{xp, yp}, P{x2, y2});

        P BC = sub_vector(P{x3, y3}, P{x2, y2});
        P CP = sub_vector(P{xp, yp}, P{x3, y3});

        P CA = sub_vector(P{x1, y1}, P{x3, y3});
        P AP = sub_vector(P{xp, yp}, P{x1, y1});

        double c1 = AB.fi * BP.se - AB.se * BP.fi;
        double c2 = BC.fi * CP.se - BC.se * CP.fi;
        double c3 = CA.fi * AP.se - CA.se * AP.fi;

        if((c1 < 0 && c2 < 0 && c3 < 0) || (0 < c1 && 0 < c2 && 0 < c3))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;

    }
    
    return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;

    for (int i = 0; i < w+2; i++) {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }

    for (int i = 0; i < w+2; i++) {
        cout << "#";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i;
	int data[5];
	int k;
	for (i = 0; i < 5; i++) {
		if (scanf("%d", &data[i]) != 1) return 1;
	}
	if (scanf("%d", &k) != 1) return 1;
	puts(data[4] - data[0] <= k ? "Yay!" : ":(");
	return 0;
}


Measured memory_bytes: 128
import bisect
n = int(input())
l = sorted(list(map(int, input().split())))
s = 0
for i in range(0,n-2):
  a = l[i]
  for j in range(i+1,n-1):
    b = l[j]
    s += bisect.bisect_left(l,a+b,j+1)-j-1
print(s)

Measured memory_bytes: 3316
//17571@nith.ac.in (mail address) @Ankit Verma
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n, m; cin >> n >> m;
   list <int> ar[m + 1];
   for(int i = 0; i < n; i++) {
   		int x, y; cin >> x >> y;
         if(x <= m)
   		ar[x].push_back(y);
   }
   priority_queue<int> pq;
   int cnt = 1; long long ans = 0;
   while(m--) {
   	 for(auto i : ar[cnt]) {
   	 	pq.push(i);
   	 }
       if(!pq.empty())
   	 ans += pq.top();
   	 //cout << pq.top() << endl;
       if(!pq.empty())
   	 pq.pop();
   	 cnt++;
 
   }
   cout << ans << endl;
 
   return 0;
}

Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	cout << (a <= b ? a : a - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String S = scanner.next();
            Map<String, List<String>> collect = Stream.of(S.split(""))
                    .collect(Collectors.groupingBy(Function.identity()));
            if (collect.keySet().size() != 2) {
                System.out.println("No");
            } else if (collect.values().stream().anyMatch(l -> l.size() != 2)) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }
    }

}


Measured memory_bytes: 28884
#include<algorithm>
#include<stack>
#include<ctime>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<queue>
using namespace std;
inline int read(){
	int num=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9'){num=num*10+x-'0';x=getchar();}
	return num*f;
}
int L,R,d;
int main(){
	L=read();R=read();d=read();
	int ans=0;
	for(int i=1;i*d<=R;++i){
		ans+=(i*d>=L);
	}
	printf("%d\n",ans);
	return 0;
}


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

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

    cout << 180 * (n-2) << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
Alphabet = ['a','b','c','d','e','f','g','h','i','j']
L = []

for l in range(N):
    if l == 0:
        L.append(['a'])
    else:
        applist = []
        for content in L[l-1]:
            ind = 0
            for j in range(len(content)):
                ind = max(ind,Alphabet.index(content[j]))
            for i in range(ind+2):
                applist.append(content+Alphabet[i])
        L.append(applist)

for content in L[N-1]:
    print(content)


Measured memory_bytes: 14548
#include <stdio.h>
#include <math.h>

int main()
{
    double v, y;
    int i;
    
    while(scanf("%lf", &v) != EOF){
        y = v * v / 9.8 / 2;
        for (i = 2; ; i++){
            if (5 * (i - 1) >= y) break;
        }
        printf("%d\n", i);
    }
    return 0;
}

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

int main()
{
	
	int k,x,i;
	
	cin>>k>>x;
	
	for(i=x-k+1;i<x;i++){
		cout<<i<<" ";
	}
	cout<<x;
	
	for(i=x+1;i<x+k;i++){
		cout<<" "<<i;
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		for (int j = i + 1; j < num; j++)
		{
			for (int k = 0;; k++)
			{
				if ((i&(1 << k)) != (j&(1 << k)))
				{
					printf("%d ", k + 1);
					break;
				}
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
char a[200005];
int dp[3000];
int mod=2019;
ll sum;
int main()
{
    cin>>a;
    int n=strlen(a);
    int ans=0,y=1;
    for(int i=n-1;i>=0;i--)
    {
        ans=(ans+(a[i]-'0')*y)%mod;
        y=y*10%mod;
        dp[ans]++;
    }
    for(int i=1;i<2019;i++)
    {
        if(dp[i]>1)
        {
            sum+=(ll)dp[i]*(dp[i]-1)/2;
        }
    }
    sum+=dp[0]*(dp[0]+1)/2;
        cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3780
n, k = map(int, input().split())

import math
ans = 0
for i in range(1, n+1):
    if i >= k:
        t = 0
    else:
        t = math.ceil(math.log2(k/i))
    #print(t)
    ans += (1/n)*((1/2)**t)
print(ans)


Measured memory_bytes: 2940
import copy
n=int(input())
n_copy1=copy.copy(n)
n_copy2=copy.copy(n)
alfabet=list("abcdefghijklmnopqrstuvwxyz")
ans=[]
i=0
while n_copy1>0:
    i+=1
    n_copy1-=26**i
n_copy2=n_copy2-(26**i-1)//25
for i in range(i):
    ans.append(alfabet[n_copy2%26])
    n_copy2=n_copy2//26
print("".join(ans[::-1]))

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{

  string w;
  cin >> w;

  int count[26] = {};
  int n = w.size();
  int num;

  for (int i = 0; i < n; i++)
  {
    num = w[i] - 'a';
    count[num]++;
  }

  bool judge = true;

  for (int i = 0; i < 26; i++)
  {
    if (count[i] % 2 != 0)
    {
      judge = false;
      break;
    }
  }

  if (judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3592
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[]) {
	char cnt[256] = {};
	string s;
	cin >> s;
	for (char c : s) {
		cnt[c] += 1;
	}
	string ans = "None";
	for (char c = 'a'; c <= 'z'; ++c) {
		if (!cnt[c]) {
			ans = string(1, c);
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, a;
    cin >> n >> a;
    int ans = n % 500;
    if(a >= ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
s=sum(map(abs,a))
c=min(list(map(abs,a)))
z=[]
for i in a:
    if i<0:
        z.append(i)
x=len(z)%2
if x:
    print(s-2*c)
else:
    print(s)

Measured memory_bytes: 65440
#include<stdio.h>
#include<string.h>

int main(void){
    char s[100000];
    scanf("%s",s);
    int a=-1, b=-1;
    for(int i=0;i<strlen(s);i++){
        if(s[i]==s[i+1]){
            a=i+1;
            b=i+2;
            break;
        }
        else if(s[i]==s[i+2]){
            a=i+1;
            b=i+3;
            break;
        }
    }
    printf("%d %d\n",a,b);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main{
    public static void main(String[] args) throws Exception
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String toks;
        while((toks = in.readLine())!=null)
        {
            int offset = 0;
            String finalStr = "";
            while(offset < 26)
            {
                StringBuilder tmpStr = new StringBuilder();
                int tmp;
                for(int j = 0; j<toks.length();j++)
                {
                    tmp = (int)toks.charAt(j);
                    if(tmp >= 'a' && tmp <= 'z')
                    {   
                        tmp += offset;
                        if (tmp > 'z')
                        {
                            tmp -=26;
                        }
                    }
                    tmpStr.append((char)tmp);
                }
                finalStr = " " + tmpStr.toString() + " ";
                if (finalStr.contains(" the ") || finalStr.contains(" this ") || finalStr.contains(" that "))
                {
                    finalStr = tmpStr.toString();
                    break;
                }

                offset++;
            }
           System.out.println(finalStr);
       }


    }
}

Measured memory_bytes: 16916
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for A in range(a + 1):
  for B in range(b + 1):
    for C in range(c + 1):
      if 500 * A + 100 * B + 50 * C == x:
        ans += 1
print(ans)

Measured memory_bytes: 2940
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans_l = []
ans_r = []
for i in range(N-K+1):
    ans_l.append(abs(x[i]) + abs(x[i+K-1] - x[i]))
    ans_r.append(abs(x[i+K-1]) + abs(x[i+K-1] - x[i]))
print(min(min(ans_l), min(ans_r)))

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

#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF (INT_MAX/3)

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

using namespace std;

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

    vector<int> rate;
    rate.resize(N);

    REP(i, N)
        cin >> rate[i];

    bool colors[8] = {false};

    int pro = 0;

    REP(i, N)
    {
        if( 4800 >= rate[i] && rate[i] >= 3200 )
        {
            pro++;
            continue;
        }
        else if( 3200 > rate[i] )
            colors[rate[i] / 400] = true;
    }

    int colors_n = 0;
    REP(i, 8)
    {
        if(colors[i]) colors_n++;
    }

    if( colors_n == 0 )
    {
        cout << (pro == 0?0:1) << " " << pro << endl;
    }
    else
    {
        cout << colors_n << " " << colors_n+pro << endl;
    }
}

// 00:13:00


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

ll f(ll n){
// ll ans;
// if(n%2 == 0)ans = n;
// ans ^= ((n+1)/2)%2;
// return ans; 
  if(n%2) return n%4 == 1;
  return n + (n%4==2);
}

int main(void){
  ll A,B,X,Y;
  cin >> A >> B;
  cout << (f(A-1) ^ f(B)) << endl;
  return 0;
}

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

int main() {

string S;
  cin >> S;
  if (S=="SUN"){cout<<"7"<<endl;}
  else if (S=="MON"){cout<<"6"<<endl;}
  else if (S=="TUE"){cout<<"5"<<endl;}
  else if (S=="WED"){cout<<"4"<<endl;}
  else if (S=="THU"){cout<<"3"<<endl;}  
  else if (S=="FRI"){cout<<"2"<<endl;}  
  else if (S=="SAT"){cout<<"1"<<endl;};
  

  
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;

namespace Equeue
{
    class Equeue
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            
            var ans = new char[S.Length];
          
            for(int i = 0;i < S.Length ;i++){
              ans[i] = 'x';
            }
          
            Console.WriteLine(String.Join("",ans));
        }
    }


    public class PriorityQueue<T> : IEnumerable<T>
    {
        private readonly List<T> _data = new List<T>();
        private readonly IComparer<T> _comparer;
        private readonly bool _isDescending;

        public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
        {
            _comparer = comparer;
            _isDescending = isDescending;
        }

        public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
            : this(Comparer<T>.Create(comparison), isDescending)
        {
        }

        public PriorityQueue(bool isDescending = true)
            : this(Comparer<T>.Default, isDescending)
        {
        }

        public void Enqueue(T item)
        {
            _data.Add(item);
            var childIndex = _data.Count - 1;
            while (childIndex > 0)
            {
                var parentIndex = (childIndex - 1) / 2;
                if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                    break;
                Swap(childIndex, parentIndex);
                childIndex = parentIndex;
            }
        }

        public T Dequeue()
        {
            var lastIndex = _data.Count - 1;
            var firstItem = _data[0];
            _data[0] = _data[lastIndex];
            _data.RemoveAt(lastIndex--);
            var parentIndex = 0;
            while (true)
            {
                var childIndex = parentIndex * 2 + 1;
                if (childIndex > lastIndex)
                    break;
                var rightChild = childIndex + 1;
                if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                    childIndex = rightChild;
                if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                    break;
                Swap(parentIndex, childIndex);
                parentIndex = childIndex;
            }
            return firstItem;
        }

        public T Peek()
        {
            return _data[0];
        }

        private void Swap(int a, int b)
        {
            var tmp = _data[a];
            _data[a] = _data[b];
            _data[b] = tmp;
        }

        private int Compare(T a, T b)
        {
            return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
        }

        public int Count => _data.Count;

        public IEnumerator<T> GetEnumerator()
        {
            return _data.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
    }
}


Measured memory_bytes: 13268
N=int(input())
cnt=0
S=[]
while cnt < N:
    S.append(input())
    cnt += 1
print(f'AC x {S.count("AC")}')
print(f'WA x {S.count("WA")}')
print(f'TLE x {S.count("TLE")}')
print(f'RE x {S.count("RE")}')


Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  
  int q;
  cin>>q;
  while(q--){
    int k;
    cin>>k;
    int l = lower_bound(A.begin(),A.end(), k) - A.begin();
    int r = upper_bound(A.begin(),A.end(), k) - A.begin();
    cout<<l<<" "<<r<<endl;
  }
  

  
  return 0;
}



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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 4;

void solve(){
    int N;
    cin >> N;

    if(N==1){
        cout <<  "1\n";
        return;
    }

    int tmp = (N / 2);
    if(N % 2 == 1) ++tmp;
    double ans = (double)tmp / N;
    cout << ans << "\n";
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256