akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int main(void)
{
        double weight = 0;

        while(scanf("%lf", &weight) != EOF)
        {
                if(48.00 >= weight)
                {
                        printf("light fly\n");
                }
                else if(51.00 >= weight)
                {
                        printf("fly\n");
                }
                else if(54.00 >= weight)
                {
                        printf("bantam\n");
                }
                else if(57.00 >= weight)
                {
                        printf("feather\n");
                }
                else if(60.00 >= weight)
                {
                        printf("light\n");
                }
                else if(64.00 >= weight)
                {
                        printf("light welter\n");
                }
                else if(69.00 >= weight)
                {
                        printf("welter\n");
                }
                else if(75.00 >= weight)
                {
                        printf("light middle\n");
                }
                else if(81.00 >= weight)
                {
                        printf("middle\n");
                }
                else if(91.00 >= weight)
                {
                        printf("light heavy\n");
                }
                else
                {
                        printf("heavy\n");
                }
        }
        return 0;
}

Measured memory_bytes: 608
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
d = A[0]
e = B[A[0] - 1]
for a in A[1:]:
    e += B[a - 1]
    if a == d + 1:
        e += C[d - 1]
    d = a
print(e)


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
typedef long long bitset;
bitset mask[6]={0x5555555555555555,0x3333333333333333,0x0f0f0f0f0f0f0f0f,
                0x00ff00ff00ff00ff,0x0000ffff0000ffff,0x00000000ffffffff};
bitset count(bitset x){
  for(int i=0;i<6;i++)x=(x&mask[i])+((x>>(1<<i))&mask[i]);
  return x;
}
int main(){
    int n;
    char s[101];
    bitset x[101],y[101];
    scanf("%d%s",&n,s);
    x[0]=0;
    for(int i=0;i<n;i++){
        x[i+1]=x[i]|(1<<(s[i]-'a'));
    }
    y[n]=0;
    for(int i=n-1;i>=0;i--){
        y[i]=y[i+1]|(1<<(s[i]-'a'));
    }
    long long ans=0;
    for(int i=0;i<=n;i++){
        ans=std::max(ans,(long long)count(x[i]&y[i]));
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
X = int(input())
if 400 <= X and X <= 599:
  print(8)
elif X <= 799:
  print(7)
elif X <= 999:
  print(6)
elif X <= 1199:
  print(5)
elif X <= 1399:
  print(4)
elif X <= 1599:
  print(3)
elif X <= 1799:
  print(2)
elif X <= 1999:
  print(1)


Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int len,i=0;
char a[100];
int main()
{
    while(cin>>a[i])
    {
        if(a[i]=='0' || a[i]=='1')len++,i++;
        else
        {
            if(len>0)len--,i--;
            a[i]=' ';
        }
    }
    for(int i=0;i<len;i++)cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from bisect import bisect_left

N,P = LI()
S = list(map(int,list(str(input()))))

ans = 0
if P == 2:
    for i in range(N):
        if S[i]%2 == 0:
            ans += i+1
elif P == 5:
    for i in range(N):
        if S[i]%5 == 0:
            ans += i+1
else:
    M = [0]*(N+1)
    now = 0
    for i in range(N):
        now += pow(10,i,P)*S[N-1-i]
        now %= P
        M[N-1-i] = now
    d = defaultdict(list)
    for i in range(N+1):
        d[M[i]].append(i)
    for i in range(N):
        p = bisect_left(d[M[i+1]],i+1)
        ans += p

print(ans)

Measured memory_bytes: 66504
#include <stdio.h>
#define NUL -1

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node N[25];
int n,D[25],H[25];


void depth(int u,int p)
{
  if(u==NUL)return;
  D[u]=p;
  depth(N[u].left,p+1);
  depth(N[u].right,p+1);
}

int height(int u)
{
  int a=0;
  int b=0;
  if(N[u].left!=NUL){a = height(N[u].left)+1;}
  if(N[u].right!=NUL){b = height(N[u].right)+1;}

  if(a>b){H[u]=a;return a;}
  else{H[u]=b;return b;}
}

int sibl(int u)
{
  if(N[u].parent == NUL)return NUL;
  if(N[N[u].parent].left!=u&&N[N[u].parent].left!=NUL){return N[N[u].parent].left;}
  if(N[N[u].parent].right!=u&&N[N[u].parent].right!=NUL){return N[N[u].parent].right;}
  return NUL;
}

void print(int u){
  printf("node %d: parent = %d, ",u,N[u].parent);
  printf("sibling = %d, ",sibl(u));
  int k=0;
  if(N[u].left!=NUL)k++;
  if(N[u].right!=NUL)k++;
  printf("degree = %d, ",k);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(N[u].parent==NUL)printf("root");
  else if(N[u].left==NUL && N[u].right==NUL)printf("leaf");
  else printf("internal node");
  printf("\n");
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      N[i].parent=NUL;
    }
  for(i=0;i<n;i++)
    {
      scanf("%d%d%d",&v,&l,&r);
      N[v].left=l;
      N[v].right=r;
      if(l!=NUL)N[l].parent=v;
      if(r!=NUL)N[r].parent=v;      
    }
  for(i=0;i<n;i++)
    {
      if(N[i].parent==NUL)root=i;
    }
  depth(root,0);
  height(root);

  for(i=0;i<n;i++)
    {
      print(i);
    }
  return 0;
}



Measured memory_bytes: 2076
#include<stdio.h>
#define N 101

int x;
int P[N];
int M[N][N];

void Matrix_Chain_Order(){
  int n,i,j,l,k,q;
  n=x;
  
  for(i=1;i<=n;i++){
    M[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j]=100000;
      for(k=i;k<=j-1;k++){
	q=M[i][k]+M[k+1][j]+P[i]*P[k+1]*P[j+1];
	if(q<M[i][j]){
	  M[i][j]=q;
	}
      }
    }
  }
  printf("%d\n", M[1][x]);
}
 
int main(){
   
  int n,i,a,count;
  scanf("%d",&x);
   
  for(i=0;i<x;i++){
    scanf("%d %d",&P[i+1],&a);
     
  }
  P[i+1]=a;
   
  Matrix_Chain_Order();
   
  return 0;
}

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

int dp[50][410][410],n,ma,mb,ans;
int c[50][3];

int getx(int a,int b){
	if (a%b!=0) return getx(b,a%b);
	else return b;
}


int main(){
	cin >> n >> ma >> mb;
	for (int i=1;i<=n;i++) cin >> c[i][1] >> c[i][2] >> c[i][0];
	const int x=n*10;
	ans=10000;
	for (int i=0;i<=x;i++)
		 for (int j=0;j<=x;j++) dp[0][i][j]=10000;
	dp[0][0][0]=0;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=x;j++){
			for (int k=0;k<=x;k++){
				if (j-c[i][1]<0 || k-c[i][2]<0) dp[i][j][k]=10000;
				else{
					int p=10000;
					for (int l=0;l<i;l++){
						if (dp[l][j-c[i][1]][k-c[i][2]]<p) p=dp[l][j-c[i][1]][k-c[i][2]];
					}
					if (p==10000) dp[i][j][k]=10000;
					else dp[i][j][k]=p+c[i][0];
					if (j%ma==0 && k%mb==0 && ans>dp[i][j][k]){
						int p=getx(max(j,k),min(j,k));
						if (j/p==ma && k/p==mb) ans=dp[i][j][k];
					}
				}
			}
		}
	}
	if (ans==10000) cout << "-1" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 29056
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


line = input()
num_query = int(input())

for loop in range(num_query):

    input_str = list(input().split())

    if input_str[0] == 'replace':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + input_str[3] + line[right:]

    elif input_str[0] == 'reverse':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + line[left:right][::-1] + line[right:]

    else: #print
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        for i in range(left,right):
            print(line[i],end = "")
        print()



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

int main() {
    int n, m, l;
    cin >> n >> m >> l;

    int a[100][100], b[100][100];
    fill(a[0], a[100], 0);
    fill(b[0], b[100], 0);
    int t;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> t;
            a[i][j] = t; 
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> t;
            b[i][j] = t; 
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            if(j) cout << " ";
            long h = 0;
            for(int k = 0; k < m; k++){
                h += a[i][k] * b[k][j];
            }
            cout << h;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int inf = 2000000000;

int main() {
    int x, y;
    cin >> x >> y;

    int ans = inf;
    if (y >= x) ans = min(ans, y - x);
    if (y >= -x) ans = min(ans, y + x + 1);
    if (-y >= x) ans = min(ans, -y - x + 1);
    if (-y >= -x) ans = min(ans, -y + x + 2);

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

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, M;
  cin >> N >> M;
  priority_queue<ll> que;
  int a;
  REP(i,N){
    IN(a);
    que.push(a);
  }
  REP(i,M){
    a = que.top()/2;
    que.pop();
    que.push(a);
  }
  ll sum=0;
  while (!que.empty()) {
    sum += que.top();
    que.pop();
  }
  OUT(sum);
}

Measured memory_bytes: 1400
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    VI cnt(10);
    VVI ru(n+1,VI(10));
    set<int> se;
    REP(i,0,n) {
        int v = s[i] - '0';
        REP(j,0,10) ru[i+1][j] = ru[i][j];
        ru[i+1][v]++;
    }
    REP(i,1,n-1) {
        int v = s[i] - '0';
        REP(j,0,10) {
            if (ru[i][j] == 0) continue;
            REP(k,0,10) {
                if (ru[n][k] - ru[i+1][k] == 0) continue;
                se.insert(j * 100 + v * 10 + k);
            }
        }
    }
    /*
    for (auto &v: se) dump(v);
    REP(i,0,n+1) {
        REP(j,0,10) cout << ru[i][j] <<" ";
        cout << endl;
    }
    */
    
    cout << se.size() << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 2432
def resolve():
	s = input()
	k = int(input())
	cnt = set()
	for i in range(len(s)):
		for j in range(1, k+1):
			if j > k:
				break
			cnt.add(s[i:i+j])
	v = sorted(list(cnt))[k-1]
	print(v)
resolve()

Measured memory_bytes: 40176
#include <bits/stdc++.h>
#pragma GCC optimize(100000000)
using namespace std;

long long n,sum[200005],num;
map<long long,long long> a; 

int main()
{
    cin>>n;
    for(long long i=1;i<=n;i++){
    	long long x;
    	cin>>x;
    	sum[i]=sum[i-1]+x;
    	a[sum[i]]++;
    	if(sum[i]==0) num++; 
	}
	for(long long i=1;i<=n;i++){
		if(a[sum[i]]==0) continue;
		num+=(a[sum[i]]*(a[sum[i]]-1)/2);
		a[sum[i]]=0;
	}
	cout<<num<<endl;
	return 0;
}
// 1 0 1 0 1 0 1

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("ce.in","r",stdin);
    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(n>m) swap(n,m);
    long long ans=0;
    if(n==1)
    {
        if(m==1) ans=1;else ans=m-2;
    }
    else ans=(n-2)*(m-2);
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

std::vector<int> graph[100];
int d[100]={0},f[100]={0};
int t = 0;

void dfs(int v){
  t++;
  d[v] = t;
  for(const auto &next_v:graph[v]){
    if(d[next_v]==0){
      dfs(next_v);
    }
  }
  t++;
  f[v] = t;
}

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;++i){
    int u,k;
    cin >> u >> k;
    for(int j=0;j<k;++j){
      int v;
      cin >> v;
      graph[u-1].push_back(v-1);
    }
  }
  
  for(int i=0;i<n;++i){
    if(d[i]==0) dfs(i);
  }
  for(int i=0;i<n;++i){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

void check(int N, int Y, int& ansX, int& ansY, int& ansZ)
{
	for (int i = N; i >= 0; i--)
	{
		for (int j = N - i; j >= 0; j--)
		{
			for (int k = 0; k <= N - (i + j); k++)
			{
				bool check1 = 10000 * i + 5000 * j + 1000 * k == Y;
				bool check2 = i + j + k == N;
				if (check1 && check2)
				{
					ansX = i;
					ansY = j;
					ansZ = k;
					return;
				}
			}
		}
	}
}

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

	int ansX = -1, ansY = -1, ansZ = -1;

	check(N, Y, ansX, ansY, ansZ);

	cout << ansX << " " << ansY << " " << ansZ << endl;

	return 0;
}

Measured memory_bytes: 256
D, G = map(int, input().split())
p = []
c = []
for _ in range(D):
    p_i, c_i = map(int, input().split())
    p.append(p_i)
    c.append(c_i)
ans = sum(p)
for i in range(pow(2, D) - 1):
    status = bin(i)[2:].zfill(D)
    all_index = [j for j, k in enumerate(status) if k == str(1)]
    not_all_index = [j for j, k in enumerate(status) if k == str(0)]
    score = 0
    nums = 0
    for j in all_index:
        score += 100 * (j + 1) * p[j] + c[j]
        nums += p[j]
    if score < G:
        flag = 0
        for n in not_all_index[::-1]:
            if flag == 1:
                break
            for m in range(1, p[n]):
                score += 100 * (n + 1)
                nums += 1
                if score >= G:
                    flag = 1
                    break
    if score >= G:
        ans = min(nums, ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

long long factor(long long X) {

	for (long long a = 2; a*a <= X;) {
		if (X%a == 0) {
			X++;
			a = 2;
			continue;
		}
		a++;
	}
	return X;
}

int main() {
	long long X;
	cin >> X;

	long long Y = factor(X);

	cout << Y << endl;

}

Measured memory_bytes: 3600
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto N = readln.chomp.to!int;
  int count = 0;
  foreach(i; 1..N+1) {
    if (i%2 == 1) count++; 
  }
  writeln(1.0f * count / N);
}


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

int main() {
  // input
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++) cin >> vec.at(i);
  
  // sort in descending order
  sort(vec.begin(),vec.end());
  reverse(vec.begin(), vec.end());
  
  // calc.
  int diff= 0;
  for(int i=0; i<N; i++){
  	if( i%2==0 ){
      diff += vec.at(i);
    }
    else{
      diff -= vec.at(i);
    }
  }
  
  cout << diff << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef string str;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m ;
  cin >> n >> m ;
  int sum = 0 ;
  REP(i,m){
    int a ;
    cin >> a ;
    sum += a  ;
  }
  if(n<sum){
    cout << -1 <<endl ;
  }
  else{
    cout << n-sum <<endl ;
  }
  
  
  
  return 0 ;
}




Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2233614#1
#define PI 3.1415926535897932
typedef pair<int, int> pii;
template <typename T>
struct edge {
    int from, to;
    T cost;
    edge(int s, T d): to(s),cost(d) {}
    edge(int f, int s, T d): from(f), to(s), cost(d) {}
    bool operator<(const edge &e) const {
        return cost<e.cost;
    }
    bool operator>(const edge &e) const {
        return cost>e.cost;
    }
};

#define Graph(type) vector< vector< edge<type> > >

int main(){
    int mod=1000000007;
    int v,e,start;
    scanf("%d %d %d",&v,&e,&start);
    Graph(int) g(v);
    for(int i=0;i<e;i++) {
        int s,t,d;
        scanf("%d %d %d",&s,&t,&d);
        g[s].push_back(edge<int>(t,d));
    }

    vector<bool> inq(v, false);
    queue<int> que;
    vector<int> rec(v, 1<<30);
    que.push(start);
    inq[start]=true;
    rec[start]=0;

    while(!que.empty()) {
        int point = que.front(); que.pop();
        inq[point]=false;
        for(size_t i=0;i<g[point].size();i++) {
            edge<int> next=g[point][i];
            int to = next.to, cost=next.cost;
            if(rec[to]>rec[point]+cost) {
                rec[to]=rec[point]+cost;
                if(!inq[to]) {
                    inq[to]=true;
                    que.push(to);
                }
            }
        }
    }
    for (int i=0;i<v;i++) {
        if(rec[i]!=1<<30) printf("%d\n",rec[i]);
        else printf("INF\n");
    }
    return 0;
}




Measured memory_bytes: 14728
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    tmp = ""
    prev = ""
    cnt = 0
    for s in S:
        tmp += s
        if tmp != prev:
            cnt += 1
            prev = tmp
            tmp = ""
        elif tmp == prev:
            continue

    print(cnt)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 72664
import os
import heapq
import sys
import math
import bisect
import operator
from collections import defaultdict
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]


# def bubbleSort(arr,b):
#     n = len(arr)
#     for i in range(n):
#         for j in range(0, n - i - 1):
#             if arr[j] > arr[j + 1] and b[j]!=b[j+1]:
#                 arr[j], arr[j + 1] = arr[j + 1], arr[j]
#                 b[j],b[j+1]=b[j+1],b[j]
def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #for _ in range(int(input())):
    n=int(input())
    # n,k=map(int,input().split())
    # arr=inar()
    if n>=400 and n<=599:
        print('8')
    elif n>=600 and n<=799:
        print('7')
    elif n>=800 and n<=999:
        print('6')
    elif n>=1000 and n<=1199:
        print('5')
    elif n>=1200 and n<=1399:
        print('4')
    elif n>=1400 and n<=1599:
        print('3')
    elif n>=1600 and n<=1799:
        print('2')
    else:
        print('1')












BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 67296
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	int a; cin >> a;
	int l = a / 100;
	int r = a % 100;
	if (1 <= l && l <= 12) {
		if (1 <= r && r <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (1 <= r && r <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int a, b, c, k;

   cin>>a>>b>>c>>k;

   cout<<1 * min(a, k) + 0 * min(b, max(0, k-a)) - 1* min(c, max(0, k - a- b));




    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3584
import heapq as hq
N = int(input())
L = [set() for _ in range(N)]
for _ in range(N-1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    L[u].add((w, v))
    L[v].add((w, u))
# print(L)

INF = float('inf')
D = [INF]*N
D[0] = 0
task = []
hq.heapify(task)
for w, v in L[0]:
    hq.heappush(task, (w, v))
while task:
    w, v = hq.heappop(task)
    # print(v,w)
    if D[v] <= w:
        continue
    D[v] = w
    for y, x in L[v]:
        hq.heappush(task, (w+y, x))
# print(D)

for i in range(N):
    print(D[i] % 2)


Measured memory_bytes: 116296
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
const int N=100005;
const int MOD=1e9+7;
 
 
 /*
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 */
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/ 



int n;
cin>>n;
vector<int> v(n);
int sum=0;
for(int i=0;i<n;i++)
{
	cin>>v[i];
	sum=sum^v[i];
}
for(int i=0;i<n;i++)
{
	int x=sum^v[i];
	cout<<x<<" ";
}


}
 
 





Measured memory_bytes: 4660
local s=io.read()
local l,r=1,#s
local counter=0
while l<r do
    sl=s:sub(l,l)
    sr=s:sub(r,r)
    if sl==sr then
        l=l+1
        r=r-1
    elseif sl=="x" then
        l=l+1
        counter=counter+1
    elseif sr=="x" then
        r=r-1
        counter=counter+1
    else
        print(-1)
        return
    end
end
print(counter)

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

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

int n,l[2000],ans;

int main() {
    scanf("%d", &n);
    rep(i,n) scanf("%d", &l[i]);
    sort(l,l+n);
    rep(i,n) repo(j,i+1,n) repo(k,j+1,n) if (l[k] < l[i]+l[j]) ans++;
    printf("%d\n", ans);
}


Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String b = sc.nextLine();

		if (b.charAt(0) == 'A') {
			System.out.println("T");
		}
		if (b.charAt(0) == 'T') {
			System.out.println("A");
		}
		if (b.charAt(0) == 'G') {
			System.out.println("C");
		}
		if (b.charAt(0) == 'C') {
			System.out.println("G");
		}
	}

}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<ll,ll>> a(n);
	rep(i, n) {
		ll ai;
		cin >> ai;
		a[i] = { ai,(ll)i };
	}
	sort(a.rbegin(), a.rend());
	vector<vector<ll>> dp(n+1, vector<ll>(n+1,0));
	rep(i, n) {
		rep(j, i + 1) {//合計i+1人、dp[j][i-j]から遷移していく
			dp[j + 1][i - j] = max(dp[j + 1][i - j], dp[j][i - j] + a[i].first * (a[i].second - j));
			dp[j][i - j + 1] = max(dp[j][i - j + 1], dp[j][i - j] + a[i].first * (((ll)n-i+j-1) - a[i].second));
		}
	}
	ll ans = 0;
	rep(i, n + 1) {
		ans = max(ans, dp[i][n - i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 34624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split(' ').Select(num => long.Parse(num)).ToArray();

            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];

            var cCnt = Calc(a, b, c);
            var dCnt = Calc(a, b, d);
            var cdCnt = Calc(a, b, c * d / Gcd(c, d));

            Console.WriteLine(b - a + 1 - (cCnt + dCnt - cdCnt));
        }

        private static long Gcd(long a, long b)
        {
            var big = Math.Max(a, b);
            var small = Math.Min(a, b);

            var tmp = big % small;
            if (tmp == 0)
            {
                return small;
            }
            else
            {
                return Gcd(small, tmp);
            }
        }
        private static long Calc(long a, long b, long n)
        {
            var result = (b / n) - (a / n);
            if (a % n == 0) result++;

            return result;
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  vector<int> ss(s.size()+1,0);
  vector<int> st(t.size()+1,0);
  for(int i=0;i<s.size();i++)
    ss.at(i+1)=ss.at(i)+(s.at(i)=='A'?1:2);
  for(int i=0;i<t.size();i++)
    st.at(i+1)=st.at(i)+(t.at(i)=='A'?1:2);
  int q;
  cin>>q;
  for(int _=0;_<q;_++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<((ss.at(b)-ss.at(a-1))%3==(st.at(d)-st.at(c-1))%3?"YES":"NO")<<endl;
  }
}

Measured memory_bytes: 4320
S = list(input())
judge_yymm = 0
judge_mmyy= 0

if(1<=int(S[2]+S[3])<=12): judge_yymm = 1
if(1<=int(S[0]+S[1])<=12): judge_mmyy = 1
  
if((judge_yymm==1)and(judge_mmyy==1)): print('AMBIGUOUS')
elif((judge_yymm==1)and(judge_mmyy==0)): print('YYMM')
elif((judge_yymm==0)and(judge_mmyy==1)): print('MMYY')
else: print('NA')

Measured memory_bytes: 3064
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var d = o.a();
  var a = o.a();
  var x = o.m(n).sort((a,b)=>a[0]-b[0]);
  var ans = 0;
  var ary = [], l = 0, now = 0;
  for(var i = 0; i < n; i++){
    while(ary.length > l){
      if(ary[l][0] < x[i][0]-d)now -= ary[l][1], l++;
      else break;
    }
    var y = x[i][1]-now*a;
    if(y <= 0)continue;
    y = Math.ceil(y/a);
    ary.push([x[i][0]+d,y]);
    ans += y;
    now += y;
  }
  return ans;
}

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

int main() {
  int N, M;
  cin >> N;
  
  M = N%10;
  
  if (M==3) {
    cout << "bon" << endl;
  }
  else if (M==0 || M==1 || M==6 || M==8) {
    cout << "pon" << endl;
  }
  else if (M==2 || M==4 || M==5 || M==7 || M==9) {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vi a(N);
  int s=0;
  rep(i,N) {
    cin >> a[i];
    s^=a[i];
  }
  
  rep(i,N) cout << (int)(s^a[i]) << endl;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
 int l,a,b,i,m=0,k=0,p=0;
 char t,q;
 string s,s1,s2;
 cin>>s;
 l=s.size();
 a=(l-1)/2;
 b=(l+3)/2;
 m=b-1;
for(i=0;i<a;i++)
{  ;

    if(s[i]==s[m])
    {
      k=k+1;
      m=m+1;
    }
    else
    {
        p=1;
        break;
    }
}
if((p==0)&&(k==a))
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;










}


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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    string a, b; cin >> a >> b;
    int r = stoi(a + b);
    
    for (int i = 1; i <= 1000; i++) {
        if (r == i * i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
} 


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] rec = new int[26];
        for(int i=0;i<s.length();i++){
            rec[s.charAt(i)-'a']++;
        }
        String ans = "Yes";
        for(int i=0;i<26;i++){
            if(rec[i]%2==1) ans = "No";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
z[4000],*a=z,*b=z+2000,m,i,j,t,u;main(n){for(;scanf("%d",&n)*n++;m=!printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)t=b[j]=n+~i&&getchar()>45?1+fmin(u=a[j],t<u?t:u):0;}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  k = min(n,k);
  rep(i,k){
    h.pop_back();
  }
  ll ans = 0;
  rep(i, h.size()) ans += h[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N;cin>>N;
    vector<ll> A(N);
    REP(i,N)cin>>A[i];
    
    ll ans=0;
    ll z=-1;ll m=0;
    REP(i,N+1){
        if(i!=0&&i==N){
            ans+=z;
            break;
        }
        if(A[i]==z+1)z=A[i];
        else{
            if(z>=A[i]){
                ans+=z;
                z=A[i];
            }else{
                cout<<-1<<"\n";
                exit(0);
            }
        }
    }
    cout<<ans<<"\n";
}

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

int main() {
    ll L,R;
    cin>>L>>R;
    ll N=R-L+1;
    vector<ll> v;
    if(N>=2019) cout<<0<<endl;
    else {
        for(int i=L; i<=R; i++) v.pb(i);
        rep(i,v.size()) v.at(i)%=2019;
        ll answer=2018;
        rep(i,v.size()) {
            int j=0;
            while(i!=j&&j<v.size()) {
                answer=min(answer,v.at(i)*v.at(j)%2019);
                j++;
            }
        }
        cout<<answer<<endl;
    }
}

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

int a[10010];

int main()
{
	int n;
	
	while(~scanf("%d",&n))
	{int sum = 0;
		for(int i = 0; i < n;i++)
		{
			scanf("%d",&a[i]);
			sum += a[i];
		}
		int ave =round((double)sum/n);
		
		ll ans = 0ll;
	//	printf("	%d\n",ave);
		for(int i = 0 ; i < n;i++)
		{
			ll ai = ((ll)a[i]-ave)*((ll)a[i]-ave);
			ans+=ai;
		}
		printf("%I64d\n",ans);
		
		
	}

/*
2
4 8
3
1 1 3

3
4 2 5

4
-100 -100 -100 -100


*/


 return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_set>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<string> conv(n);

    for(int i = 0; i < n; ++i) {
        cin>>conv[i];
    }

    char last = conv[0][conv[0].size()-1];
    unordered_set<string> hist;
    hist.insert(conv[0]);
    
    bool ok = true;
    for (int i = 1; i < n ; ++i){
        if (last != conv[i][0]) {
            ok = false;
            // cout << conv[i] << "is illegal chain" << endl;
            // cout << "last :" << last <<", cur :" << conv[i][0] << endl;
            break;
        }

        if (find(hist.begin(), hist.end(), conv[i]) != hist.end()){
            ok = false;
            // cout << conv[i] << "is duplicated" << endl;
            // cout << *find(conv.begin(), conv.end(), conv[i]) << endl;
            break;
        } else {
            hist.insert(conv[i]);
        }

        last = conv[i][conv[i].size()-1];
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
I=h*w
d=[I]*I
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j;p=d[s]+1
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

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

int main() {
    int N;
    cin >> N;
    double ans = 0;
    rep(i, N) {
        int A;
        cin >> A;
        ans += 1.0/A;
    }
    printf("%.10lf", 1.0/ans);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector <int> A;
    vector<int> n;
    vector<int> p;
    rep(i, N){
        int tmp; cin >> tmp;
        if(tmp>0){
            p.emplace_back(tmp);
        }else{
            n.emplace_back(tmp);
        }
        A.emplace_back(tmp);
    }
    
    vector <pair<int, int>> P;

    int ans = 0;

    if(n.size()>1 && p.size()>0){
        // printf("ok");
        sort(A.begin(), A.end());
        int tt = A[N-1];
        A[N-1] = A[0];
        A[0] = tt;

        rep(i, N-2){
            // if(A[i]<A[i+1]){
            int ma = max(A[i], A[i+1]);
            int mi = min(A[i], A[i+1]);
            if(A[i+2]>0){
                P.emplace_back(make_pair(mi, ma));
                A[i+1] = mi - ma;
            }else{
                P.emplace_back(make_pair(ma, mi));
                A[i+1] = ma - mi;
            }
        }
        P.emplace_back(make_pair(max(A[N-1], A[N-2]), min(A[N-1], A[N-2])));
        A[N-1] = abs(A[N-1] - A[N-2]);
    }else if(p.size()>0){
        sort(A.begin(), A.end());
        rep(i, N-2){
            // if(A[i]<A[i+1]){
            int ma = max(A[i], A[i+1]);
            int mi = min(A[i], A[i+1]);
            if(A[i+2]>0){
                P.emplace_back(make_pair(mi, ma));
                A[i+1] = mi - ma;
            }else{
                P.emplace_back(make_pair(ma, mi));
                A[i+1] = ma - mi;
            }
        }
        P.emplace_back(make_pair(max(A[N-1], A[N-2]), min(A[N-1], A[N-2])));
        A[N-1] = abs(A[N-1] - A[N-2]);
    }else if(n.size()>0){
        sort(A.begin(), A.end(), greater<int>());
        rep(i, N-2){
            // if(A[i]<A[i+1]){
            int ma = max(A[i], A[i+1]);
            int mi = min(A[i], A[i+1]);
            if(A[i+2]>0){
                P.emplace_back(make_pair(mi, ma));
                A[i+1] = mi - ma;
            }else{
                P.emplace_back(make_pair(ma, mi));
                A[i+1] = ma - mi;
            }
        }
        P.emplace_back(make_pair(max(A[N-1], A[N-2]), min(A[N-1], A[N-2])));
        A[N-1] = abs(A[N-1] - A[N-2]);
    }

    printf("%d\n", A[N-1]);
    rep(i, N-1){
        printf("%d %d\n", P[i].first, P[i].second);
    }
    return 0;
}

Measured memory_bytes: 3824
n, k = map(int, input().split())
A = list(map(int, input().split()))
D = [1]
seen = [0]*n
seen[0] = 1
now = 0
while True:
    now = A[now] - 1
    D.append(now+1)
    if seen[now]:
        break
    seen[now] = 1
f = D.index(D[-1])
if k < f:
    print(D[k])
else:
    cycle = len(D) - f - 1
    k -= f
    print(D[f + k%(cycle)])

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int& pi : p) {
    cin >> pi;
  }
  sort(p.begin(), p.end());
  int ret = 0;
  for (int i = 0; i < k; ++i) {
    ret += p[i];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

const int64 MOD = 1000000007;
int main() {
    int n, k; cin >> n >> k;

    map<int, pair<int64, int64>> m;
    int64 ans = 1;
    reps(k, i, n+1) {
        int64 _i = i;
        int64 _min = (_i - 1) * _i / 2;
        int64 _max = (n + n - _i + 1) * _i / 2;

        ans = (ans + _max - _min + 1) % MOD;

        // cout << _min << " " << _max << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
const int MAXN=10005;
using namespace std;
int n;
vector<int> v[MAXN];
int c[MAXN];
int ans=0;
int index=0;
int xans[MAXN];

bool cmp(int x,int y){return x>y;}

void dfs(int no,int father)
{
	xans[no]=++index;
	for (int i=0;i<v[no].size();i++)
	{
		int u=v[no][i];
		if (u!=father)
		{
			dfs(u,no);
		}
	}
}
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}

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

	sort(c+1,c+1+n,cmp);

	for (int i=2;i<=n;i++)
	{
		ans+=c[i];
	}
	cout<<ans<<endl;

	dfs(1,-1);
	for (int i=1;i<=n;i++)
	{
		cout<<c[xans[i]]<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1280
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1005;
const int INF = 1e10;

int n, m, sx, sy, dx, dy;
char a[N][N];

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        cin >> n >> m;
        cin >> sx >> sy;
        cin >> dx >> dy;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++)
                cin >> a[i][j];
        }

        vector<vector<int>> dist(n, vector<int> (m, INF));

        sx--, sy--, dx--, dy--;
        deque<pair<int, int> > dq;
        dist[sx][sy] = 0;
        dq.push_back({sx, sy});
        while (!dq.empty()) {
            auto v = dq.front();
            dq.pop_front();

            int vx = v.first;
            int vy = v.second;
            for (int dx = -2; dx <= 2; dx++) {
                for (int dy = -2; dy <= 2; dy++) {
                    int nx = vx + dx;
                    int ny = vy + dy;
                    if ((nx == vx && ny == vy) || nx < 0 || ny < 0 || nx >= n || ny >= m || a[nx][ny] == '#')
                        continue;

                    int wt = (abs(nx - vx) + abs(ny - vy) > 1);
                    if (dist[nx][ny] > dist[vx][vy] + wt) {
                        dist[nx][ny] = dist[vx][vy] + wt;
                        if (wt == 0)
                            dq.push_front({nx, ny});
                        else
                            dq.push_back({nx, ny});
                    }
                }
            }
        }

        int ans = (dist[dx][dy] == INF ? -1 : dist[dx][dy]);
        cout << ans << '\n';

    }
    
    return 0;
}



Measured memory_bytes: 12620
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
  int R1,R2;
  cin>>R1>>R2;
  double a=R1*R2,b=R1+R2;

  double R3=a/b;

  cout<<fixed<<setprecision(6)<<R3<<endl;
  return 0;
}


Measured memory_bytes: 256