akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None


def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top


def tree_find(node, key):
    if not node:
        return None
    if node.key == key:
        return node
    if key < node.key:
        return tree_find(node.left, key)
    return tree_find(node.right, key)


def tree_delete(top, z):
    if z.left is None or z.right is None:
        y = z
    else:
        y = tree_successor(z)

    if y.left is not None:
        x = y.left
    else:
        x = y.right

    if x is not None:
        x.parent = y.parent
    if y.parent is None:
        top = x
    elif y == y.parent.left:
        y.parent.left = x
    else:
        y.parent.right = x

    if y != z:
        z.key = y.key
    return top


def tree_successor(x):
    if x.right is not None:
        return tree_minimum(x.right)
    y = x.parent
    while y is not None and x == y.right:
        x = y
        y = y.parent
    return y


def tree_minimum(x):
    while x.left is not None:
        x = x.left
    return x


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)


def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)


n = int(stdin.readline())
#assert n <= 500000

top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    elif cmd.startswith('f'):
        key = int(cmd[5:])
        r = tree_find(top, key)
        print('yes' if r else 'no')
    elif cmd.startswith('d'):
        key = int(cmd[7:])
        node = tree_find(top, key)
        if node:
            top = tree_delete(top, node)
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

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

typedef long long ll;
typedef long double ld;
#define ii pair <int, int>
#define MP make_pair
#define endl "\n"
#define PB push_back
#define F first 
#define int long long 
#define S second
#define rise_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;
#define all(v) v.begin(), v.end()
#define sz(a) signed((a).size())
#define forn(i,n) for(int i = 0; i < int(n); i++)
#define ford(i,n) for(int i = int(n) - 1; i >= 0; i--)


signed main()
{	
	rise_up
    int t=1; //cin>>t; 
    while(t--){
		int n, k; cin>>n>>k;
		int a[n+1]={};
		for(int i=1; i<=n; i++){
			cin>>a[i];
		}
		vector <int> v, vl;
		map <int, int> mp; 
		int cur=1, st;
		while(true){
			if(mp[a[cur]]){
				st=a[cur];
				break;
			}
			v.PB(a[cur]); mp[a[cur]]=1; 
			cur = a[cur]; 
		}
		int ind=0;
		for(int i=0; i<sz(v); i++){
			if(v[i] == st){
				ind = i;
				for(int j=i; j<sz(v); j++){
					vl.PB(v[j]);
				}break;
			}
		}
	//	for(int i=0; i<sz(v); i++) cout<<v[i]<<" "; cout<<endl;
	//	for(int i=0; i<sz(vl); i++) cout<<vl[i]<<" "; cout<<endl;
		if(k < ind+1) cout<<v[k-1];
		else{
			k-=ind;
			cout<<vl[(k%sz(vl)-1+sz(vl))%sz(vl)];
		}
	}
	return 0;
}

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

int alpha_count[26];

int main() {
    string S;
    int start = -1, end = -1;
    cin >> S;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] == S[i + 1]) {
            start = i + 1;
            end = i + 2;
            break;
        }
    }
    if (start == -1 && end == -1 && S.length() > 2) {
        for (int i = 0; i < S.length() - 2; i++) {
            if (S[i] == S[i + 2]) {
                start = i + 1;
                end = i + 3;
                break;
            }
        }
    }
    cout << start << " " << end << endl;
    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> c;
    ll tmp;
    cin >> tmp;
    c.push_back(tmp);
    for(i = 1;i < n;++i){
        ll tmp1;
        cin >> tmp1;
        if(tmp != tmp1){
            tmp = tmp1;
            c.push_back(tmp);
        }
    }
    n = c.size();
    unordered_map<ll,ll> mp;
    vector<ll> prev(n, -1);
    for(i = 0;i < n;++i){
        if(mp.count(c.at(i))){
            prev.at(i) = mp[c.at(i)];
            mp[c.at(i)] = i;
        }else{
            mp[c.at(i)] = i;
        }
    }
    ll MOD = 1e9+7;
    vector<ll> dp(n+1,1);
    for(i = 1;i < n;++i){
       dp.at(i+1) = dp.at(i)%MOD;
       if(prev.at(i) != -1){
           dp.at(i+1) += dp.at(prev.at(i) + 1);
           dp.at(i+1) %= MOD;
       }
    }
    cout << dp.at(n) << endl;

    return 0;
}

Measured memory_bytes: 13168
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}






void solve()
{  
  string s;
  cin >> s;int ans=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]=='?')
    s[i]='D';
  }
  cout << s << endl;
}

signed main()
{ boost
  int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 3744
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        String a=sc.next();
		String[] b1=a.split("");
  		int[] a1=new int[4];
		for(int c=0;c<4;c++){
    		a1[c]=Integer.parseInt(b1[c]);
    	}
  	
  	String[] n=new String[4];
    for(int bit=0;bit<(1<<3);bit++){
      int ans=a1[0];
    	for(int g=0;g<3;g++){
        if((1&bit>>g)==1){
         ans+=a1[g+1];
         n[g+1]="+";
        }else{
        ans-=a1[g+1];
        n[g+1]="-";
        }
        }
      if(ans==7){
      break;
      }
    }
 	 String sans="";
   for(int e=0;e<4;e++){
    if(n[e]!=null){
   sans+=n[e];
    }
     sans+=b1[e];
   }
	sans+="=7";
    	System.out.println(sans);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
const int MX=100005;

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<ll> cnt(MX);
   for (int i=0;i<n;++i){
       int a;
       cin >> a;
       cnt[a]++;
   }
   ll tot=0;
   for (int i=0;i<MX;++i){
       tot+=i*cnt[i];
   }
   int q;
   cin >> q;
   for (int i=0;i<q;++i){
       int b,c;
       cin >> b >> c;
       tot-=b*cnt[b];
       tot-=c*cnt[c];
       cnt[c]+=cnt[b];
       cnt[b]=0;
       //tot+=b*cnt[b];
       tot+=c*cnt[c];
       cout << tot << endl;
   }
   return 0;
}


Measured memory_bytes: 3980
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val m = sc.nextInt()

    val sub = Array(m) { Sub(sc.nextInt(), sc.next()) }

    val pen = Array(n + 1) { 0}
    val solved = Array(n + 1) { false}
    for (i in 0 until m) {
        if(solved[sub[i].n]) continue
        if(sub[i].res == "AC") solved[sub[i].n] = true
        if(sub[i].res == "WA") pen[sub[i].n]++
    }

    val c = solved.count { it }
    var p = 0

    for(i in 1..n){
        if(solved[i]) p+= pen[i]
    }

    println("$c $p")

}

data class Sub(val n: Int, val res: String)

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 48136
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        pq.push(x);
    }
    while(m-- > 0 && !pq.empty()){
        int x = pq.top();   pq.pop();
        if(x > 1)   pq.push(x/2);
    }
    ll sum = 0;
    while(!pq.empty()){
        sum += pq.top();   pq.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(void){
        int a, b;
        scanf("%d %d", &a, &b);
        if((a>=-1000 && a<=1000) && (b>=-1000 && b<=1000)){
                if(a<b)
                        puts("a < b");
                else if(a>b)
                        puts("a > b");
                else
                        puts("a == b");
        }
        return 0;
}

Measured memory_bytes: 1656
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k,x,i;
    int ans;
    cin>>k>>x;
    for(i=0; i<k*2-1; i++){
        ans=x-(k-1)+i;
        if(-1000000<=ans<=1000000){
            cout<<ans;
            cout<<" ";
        }
    }
}

Measured memory_bytes: 256
import sys
input_num = int(input())
input_str = str(input())

if input_num % 2 == 1:
    print('No')
    sys.exit()
    
half_str = input_str[0:int(input_num/2)]
result = input_str.replace(half_str,"")
if result == "":
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int l,m,n,i,total=0,num[12];
	while(1){
		scanf("%d",&l);
		total=0;
		if(l==0)break;
		for(i=0;i<12;i++){
			scanf("%d %d",&m,&n);
			total+=m-n;
			num[i]=total;
		}
		for(i=0;i<12;i++){
			if(num[i]>=l){
				printf("%d\n",i+1);
				break;
			}
		}
		if(total<l) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 612
import sys


def dfs1(root, links):
    parent = [0] * n
    subtree_count = [{} for _ in range(n)]
    q = [(root, -1, 0)]  # 2番目:親  3番目:0=初, 1=全ての子巡回後
    while q:
        v, p, t = q.pop()
        if t == 0:
            parent[v] = p
            q.append((v, p, 1))
            for u in links[v]:
                if u == p:
                    continue
                q.append((u, v, 0))
        elif p != -1:
            subtree_count[p][v] = sum(subtree_count[v].values()) + 1
    return parent, subtree_count


def dfs2(root, parent, subtree_count, d2, d2s):
    ans = 0
    q = [(root, 0)]
    while q:
        v, pc = q.pop()

        if len(subtree_count[v]) == 0:
            continue

        p = parent[v]
        children, st_counts = map(list, zip(*subtree_count[v].items()))
        children.append(p)
        st_counts.append(pc)
        cl = len(st_counts)
        ct = sum(st_counts)

        for u, stc in subtree_count[v].items():
            q.append((u, ct - stc + 1))

        if cl == 1:
            continue

        tmp = 0
        for stc in st_counts:
            tmp = (tmp + d2s[ct - stc]) % MOD
        tmp = (tmp - d2s[ct] * (cl - 1)) % MOD
        ans = (ans + (1 - tmp) * d2) % MOD
    return ans


n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
root = 0
MOD = 10 ** 9 + 7
d2 = 500000004  # 2^-1 mod 10**9+7
d2s = [1]
for i in range(n):
    d2s.append(d2s[-1] * d2 % MOD)
parent, subtree_count = dfs1(root, links)
# print(parent)
# print(subtree_count)
ans = dfs2(root, parent, subtree_count, d2, d2s)
print(ans)


Measured memory_bytes: 154620
import java.util.*;

public class Main {

    static List<String> z;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        Arrays.setAll(p, i -> sc.nextInt());
        Arrays.setAll(q, i -> sc.nextInt());

        z = new ArrayList<>();
        String s = "";
        String pa = "";
        String qb = "";
        for (int i = 1; i <= n; i++) {
            s += i;
        }
        for (int i = 0; i < n; i++) {
            pa += p[i];
            qb += q[i];
        }
        permutation(s,"");
        int a = 0;
        int b = 0;
        for(int i = 0; i < z.size(); i++) {
            if (z.get(i).equals(pa)) a = i;
            if (z.get(i).equals(qb)) b = i;
        }
        System.out.println(Math.abs(a-b));
    }

    public static void permutation(String q, String ans){
        if(q.length() <= 1) {
            z.add(ans + q);
        }
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                ans + q.charAt(i));
            }
        }
    }

}

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

int main() {
	ll d, t, s;
	cin >> d >> t >> s;
	if (t*s  >= d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	int n,i,ans = 100000,a,risi[2];
	cin >> n;
	for(i = 1;n >= i;i++){
		risi[0] =  ans * 0.05;
		risi[1] = risi[0];
		while(risi[1] >= 1000){risi[1] = risi[1] - 1000;}
			if(risi[1] > 0){risi[0] = risi[0] - risi[1] + 1000;}
		ans = ans + risi[0];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i=0; i<N;i++){
        cin >> H[i];
    }
    int ans = 0;
    for(int i=0; i<N;i++){
        if(H[i]>=K){
            ans += 1;
        }
    }
    cout << ans << endl;
} 



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};

int main(){
	
	int n,k;
	cin>>n>>k;
	
	int ans = 0;
	combi C(1000000);
	
	for(int i=0;i<=min(n-1,k);i++){
		int t = C.combination(n,i);
		t = mod(t * C.junretsu(n-i-1,i));
		ans = mod(ans + t);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int n, m, q;
int ans;
vi a, b, c, d;

void dfs(vi A) {
    if(A.size() == n) {
        int tmp = 0;
        rep(i, q) if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
        ans = max(ans, tmp);
        return;
    }

    int last = (A.empty() ? 1 : A.back());
    for(int add = last; add <= m; add++) {
        A.push_back(add);
        dfs(A);
        A.pop_back();
    }
}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vi(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    } 

    vi A;
    dfs(A);

    cout << ans << endl;

    return 0;
}


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

int main () {
  int N;
  cin >> N;
  vector<int> num(N);
  for (int i = 0; i < N; i++)
    cin >> num.at(i);
  
  int A = 0, B = 0;
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0)
      A += num.at(i);
    else {
      B += num.at(i);
    }
  }
  
  cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a+b==15)cout << "+"<<endl;
  else if(a*b==15)cout << "*"<<endl;
  else cout << "x"<<endl;
}

Measured memory_bytes: 256
//////////////////////////
//////////////////////////
////Please give me AC!////
////Please give me AC!////
//////////////////////////
//////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  unordered_map<ll,ll> mp;
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    mp[A.at(i)]++;
  }
  ll ans=0;
  for(ll i=0;i<N;i++){
    if(mp[A.at(i)]>A.at(i)){
      ans+=mp[A.at(i)]-A.at(i);
      mp[A.at(i)]=A.at(i);
    }
    if(mp[A.at(i)]<A.at(i)){
      ans+=mp[A.at(i)];
      mp[A.at(i)]=0;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
    int64_t A, Bx100;
    double B;
    cin >> A >> B;
    Bx100 = B * 100.1;
    string ans = to_string(A * Bx100);
    if (A * Bx100 >= 100) {
        for (int64_t i = 0; i < ans.size() - 2; i++) {
            cout << ans[i];
        }
    } else {
        cout << '0';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3808
n=int(input())
s=list(map(int,input().split()))
a=sorted(s,reverse=True)
b=[]
c=[]
for i in range(len(a)):
    if i%2==0:
        b.append(a[i])
    else:
        c.append(a[i])
print(sum(b)-sum(c))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  vector<char> v(6);
  FOR(i,0,6)cin >> v[i];
  sort(ALL(v));
  cout << upper_bound(ALL(v),'1') - lower_bound(ALL(v),'1') << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  cout.precision(11);
  cout << 2 * pi * n << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3804
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> process(1)
    |> IO.inspect()
  end
  
  defp process([1, k], acc), do: acc * k
  defp process([n, k], acc), do: process([n - 1, k], acc * (k - 1))
end

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    swap(A, B);
    swap(A, C);

    cout << A << " " << B << " " << C << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define MOD 100000000;
#define EPS 0.001
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    string s;
    cin>>s;
    ll ans = 0;
    for(auto l : s) ans+=(l-'0');
    ll x = stoi(s);
    cout<<(x%ans==0? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define pb push_back
#define all(v) (v).begin(), (v).end()

#define INF 200000 //n<=100,000より

int main(){
  int N;
  cin>>N;
  vi a(N);
  for(int i=0; i<N; i++)cin>>a[i];

  vi dp; //ありうるLISのi個の最小

  for(int x: a){
    auto itr = lower_bound(all(dp), x);
    if(itr!=dp.end()){
     *itr = x; 
    }else{
      dp.pb(x);
    }
  }

  int ans = dp.size();
  cout<<ans<<endl;
}


Measured memory_bytes: 3932
from collections import deque

def check753(num):
    three = False
    five = False
    seven = False
    for s in num:
        if s == "3":
            three = True
        elif s == "5":
            five = True
        elif s == "7":
            seven = True
        if three and five and seven:
            return True
    return False

n = int(input())

q = deque([3,5,7])

ans = 0
while q:
    now = q.popleft()
    
    t = "".join([str(now), "3"])
    if int(t) <= n:
        q.append(int(t))
        if check753(t):
            ans += 1
    f = "".join([str(now), "5"])
    if int(f) <= n:
        q.append(int(f))
        if check753(f):
            ans += 1
    s = "".join([str(now), "7"])
    if int(s) <= n:
        q.append(s)
        if check753(s):
            ans += 1
print(ans)

Measured memory_bytes: 72660
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;


int main(){
  int N ;
  string S ;
  cin >> N >> S ;
  for(int i=0;i<N;i++){
    for(int j=0;j<S.length();j++){
      if(S[j] == 'Z') S[j] = 'A' ;
      else S[j]++ ;
    }  
  }  
  cout << S << endl ;
  return 0 ;
}

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2) ans*=a, ans%=(mod);
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll n;
	cin >> n;
	ll dp[2][n + 2];
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	ll ans = 0;
	rep(_,1,n + 1) {
		ll c = dp[0][0];
		ll tmp;
		rep(j,3,n + 1) {
			dp[1][j] = c;
			c += dp[0][j-2];
			c %= M;
			// dp[j] += dp[j-1];
			// dp[j] %= M;
		}
		rep(j,0,n + 1) {
			dp[0][j] = dp[1][j];
			dp[1][j] = 0;  
		}
		// rep(i,0,n+1) {
		// 	cout << dp[i] << " ";
		// }
		// cout << endl;
		// rep(i,)
		ans += dp[0][n];
		ans %= M;
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if((C - B) % 2 == 0){
    cout << "Alice" << endl;
  }
  
  else{
    cout << "Borys" << endl;
  }
}


Measured memory_bytes: 3584
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    ans = []
    l = 0
    for r in range(k, n):
        if a[l] < a[r]:
            print('Yes')
        else:
            print('No')
        l += 1

if __name__=='__main__':
    main()


Measured memory_bytes: 31604
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	cout << max(a*b,c*d) << endl;
	//printf((s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3]) ? "Yes\n" :"No\n");
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int f(string s1,string s2)
{
    int cnt=0;
    for(int i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i])cnt++;
    }
    return cnt;
}
int main()
{
    string s,t;
    cin>>s>>t;
    int mx=s.size();
    for(int i=0;i<s.size();i++)
    {
        if(i+t.size()<=s.size())
        {
           mx=min(mx, f(t,s.substr(i,t.size())));
        }
    }
    cout<<mx;

}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
using namespace std;
int main()
{
	int n,cnt=0;
	cin>>n;
	while(n--) 
	{
		++cnt;
		string f[8];
		for(int i = 0; i < 8; ++i)
		{
			cin>>f[i];
		}
		int x,y;
		cin>>x>>y;

		queue<int> xs,ys;
		xs.push(x-1); ys.push(y-1);
		f[y-1][x-1]='0';
		while(!xs.empty())
		{
			int xx=xs.front(),yy=ys.front();
			xs.pop(); ys.pop();
			
			for(int i = 1; i < 4; ++i)
			{
				if(0<=xx-i&&f[yy][xx-i]=='1')
				{
					f[yy][xx-i]='0';
					xs.push(xx-i); ys.push(yy);
				}
				if(xx+i<8&&f[yy][xx+i]=='1')
				{
					f[yy][xx+i]='0';
					xs.push(xx+i); ys.push(yy);
				}
				if(0<=yy-i&&f[yy-i][xx]=='1')
				{
					f[yy-i][xx]='0';
					xs.push(xx); ys.push(yy-i);
				}
				if(yy+i<8&&f[yy+i][xx]=='1')
				{
					f[yy+i][xx]='0';
					xs.push(xx); ys.push(yy+i);
				}
			}
		}
		cout<<"Data "<<cnt<<":"<<endl;
		for(int i = 0; i < 8; ++i)
		{
			cout<<f[i]<<endl;
		}
	}
  return 0;
}

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

typedef long long ll;

int main() {
	ll A, B;

	cin >> A >> B;
	set<ll> s;
	for (ll i = 1LL; i <= sqrt(A) || i <= sqrt(B); i++) {
		if (A % i == 0 && B % i == 0) {
			s.insert(i);
		}
		if (B % i == 0 && A % (B / i) == 0) {
			s.insert(B / i);
		}
		if (A % i == 0 && B % (A / i) == 0) {
			s.insert(A / i);
		}
	}

	vector<ll> v;
	for (auto i: s) v.push_back(i);
	reverse(v.begin(), v.end());

	int ans = v.size();

	for (int i = 0; i < v.size(); i++) {
		for (int j = i + 1; j < v.size(); j++) {
			if (__gcd(v[i], v[j]) > 1) {
				ans--;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
using System;
        using System.Collections.Generic;
        using System.Linq;

        public class Program
        {
            public static void Main(string[] args)
            {
            string input = Console.ReadLine();
            List<int> inputList = new List<int> { };
            string answer = "";

            foreach(char n in input)
            {
                inputList.Add(int.Parse(n.ToString()));
            }

            if (input.Distinct().Count() == 1) answer = input;
            else
            {
                if (inputList[1] > inputList[0])
                {
                    int hundred = int.Parse(input.Substring(0, 1));
                    for (int i = 0; i < input.Length; i++)
                    {
                        answer += hundred + 1;
                    }
                }
                else
                {
                    for (int i = 0; i < input.Length; i++)
                    {
                        answer += inputList.Max();
                    }
                }
            }

            Console.WriteLine(answer);
            }
        }

Measured memory_bytes: 11232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()

class Solver {
  public:
    bool solve() {
        string T; cin >> T;
        if(T == "#") return false;
        priority_queue<string> firsts;
        priority_queue<string, vector<string>, greater<string>> lasts;
        int cnt = 0;
        for(int flg = 0; flg < (1 << T.size()); flg++) {
            string s = T;
            vector<int> swaped('z' - 'a' + 1);
            vector<int> need_swap('z' - 'a' + 1);
            for(int i = s.size() - 1; i >= 0; i--) {
                if(flg & (1 << i)) {
                    if(s[i] == 'z') goto FAIL;
                    s[i]++;
                    if(swaped[s[i] - 'a']) goto FAIL;
                    swaped[s[i] - 'a'] = true;                    
                } else {
                    if(swaped[s[i] - 'a']) goto FAIL;
                    if(s[i] != 'a') need_swap[s[i] - 'a'] = true;
                }
            }
            rep(i, 'z'- 'a' + 1) {
                if(need_swap[i] and not swaped[i]) goto FAIL;
            }
            firsts.push(s);
            lasts.push(s);
            cnt++;
            if(firsts.size() > 10) firsts.pop();           
            if(lasts.size() > 10) lasts.pop();

      FAIL:;
        }
        cout << cnt << endl;
        vector<string> res;
        if(cnt <= 10) {            
            while(firsts.size()) {
                res.push_back(firsts.top());
                firsts.pop();
            }
            reverse(all(res));
        } else {
            while(firsts.size() > 5) firsts.pop();           
            while(lasts.size() > 5) lasts.pop();
            while(firsts.size()) {
                res.push_back(firsts.top());
                firsts.pop();
            }
            reverse(all(res));
            while(lasts.size()) {                
                res.push_back(lasts.top());
                lasts.pop();
            }
        }
        for(auto s : res) cout << s << endl;
        return true;
    }
};

int main() {    
    while(Solver().solve());
    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>

using namespace std;

class Card
{
public:
	bool S[13], H[13], C[13], D[13];
	Card()
	{
		int i;
		for (i=0;i<13;i++)
		{
			S[i] = false;
			H[i] = false;
			C[i] = false;
			D[i] = false;
		}
	}

};

int main()
{
	int n, number;
	char mark;
	int i;
	Card card;

	cin >> n;
	for (i=0;i<n;i++)
	{
		cin >> mark >> number;
		switch (mark)
		{
		case 'S':
			card.S[number - 1] = true;
			break;
		case 'H':
			card.H[number - 1] = true;
			break;
		case 'C':
			card.C[number - 1] = true;
			break;
		case 'D':
			card.D[number - 1] = true;
			break;
		}
	}
	for (i=0;i<13;i++)
	{
		if (card.S[i] == false) cout << "S " << i + 1 << endl;
	}
	for (i = 0; i < 13; i++)
	{
		if (card.H[i] == false) cout << "H " << i + 1 << endl;
	}
	for (i = 0; i< 13; i++)
	{
		if (card.C[i] == false) cout << "C " << i + 1 << endl;
	}
	for (i = 0; i < 13; i++)
	{
		if (card.D[i] == false) cout << "D " << i + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <unordered_set>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int a,b;
    cin >> a >> b;
    if(a==b && a!=0){
        cout << "Positive" << endl;
    }
    else if(a>0){
        cout << "Positive" << endl;
    }
    else if(a<0 && b > 0){
        cout << "Zero" << endl;
    }
    else if(b<0){
        if((b-a)%2==0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }else{
        cout << "Zero" << endl;
    }
}

Measured memory_bytes: 256
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
#pragma endregion

int main()
{
  init_main();
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++)
  {
    if (i % k == 0)
    {
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;
}


Measured memory_bytes: 3608
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def is_MM(s):
    num = int(s)
    return 0 < num <= 12


def solve():
    N = ii(str)
    ans_pattern = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
    ans = 0
    pre = N[:2]
    post = N[2:]
    if is_MM(post):
        ans += 1
    if is_MM(pre):
        ans += 2
    return ans_pattern[ans]


if __name__ == "__main__":
    print(solve())


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    
}

void solve_B(){
    int n, m;
    cin >> n >> m;

    int all = 0;
    
    int a[n];
    REP(i,n){
        cin >> a[i];
        all += a[i];
    }

    int ctr = 0;
    int max = (all + 4 * m - 1)/4/m;
    REP(i,n){
        if(a[i] >= max){
            ctr++;
        }
    }

    if(ctr >= m) cout << "Yes";
    else cout << "No";
}


int main(void){
    solve_B();
    
    return 0;
}

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

int main(){

    string S;
    cin >> S;
    
    int ans = 0;
    int red = 0;
    int blue = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '0'){
            red++;
        }else if(S[i] == '1'){
            blue++;
        }
    }

    ans = min(red, blue) * 2;

    cout << ans << endl;

    return 0;
}

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

int sosu(int);

int main(){
  int i, n, a, cnt = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &a);
    if(a == 2){
      cnt++;
      continue;
    }else if(a % 2 == 0) continue;
    if(sosu(a) == 1) cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}

int sosu(int x){
  int i=3, sq;
  sq = sqrt(x);
  while(i <= sq){
    if(x % i == 0) return 0;
    i += 2;
  }
  return 1;
}


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

#define ll long long

using namespace std;

vector <ll> p(20);

ll n;

ll hm(ll n) {
	if (n <= -1)
		return 0;
	return hm(n - 1) + p[n];
}

ll ans(ll first, ll last, vector <ll> &a) {
	if (first == 0)
		return 0;
	if (a.size() == 1)
		return (first == last);
	vector <ll> b(a.size());
	b[0] = first;
	b[a.size() - 1] = last;
	if (b[0] > a[0]) {
		if (a.size() >= 3)
			return (hm(a.size() - 3)) + (first == last);
		return (first == last);
	}
	if (b[0] < a[0])
		return (hm(a.size() - 2)) + (first == last);
	if (a.size() >= 3)
		return (n - first * p[a.size() - 1]) / 10 + (hm(a.size() - 3)) + (first == last) + (last <= a[a.size() - 1]);
	return (n - first * p[a.size() - 1]) / 10 + (first == last) + (last <= a[a.size() - 1]);
}

int main() {
	p[0] = 1;
	for (ll i = 1; i < 10; i++)
		p[i] = p[i - 1] * 10;
	cin >> n;
	ll copy_n = n;
	vector <ll> kek;
	while (copy_n > 0) {
		kek.push_back(copy_n % 10);
		copy_n /= 10;
	}
	reverse(kek.begin(), kek.end());
	ll answer = 0;
	for (ll i = 1; i <= n; i++) {
		ll last_digit = i % 10;
		ll copy_i = i;
		ll first_digit;
		while (copy_i > 0) {
			first_digit = copy_i % 10;
			copy_i /= 10;
		}
		answer += ans(last_digit, first_digit, kek);
	}
	cout << answer;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n;
  int cnt;

  while(1){
    cnt=0;
    scanf("%d",&n);
    if(n==0)
      break;
    while(n!=1){
      if(n%2==0)
	n=n/2;
      else
	n=3*n+1;
      cnt++;
    }
    printf("%d\n",cnt);
  }
  return 0;
}

    

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N=1;

int bit0[1000000],bit1[1000000];
int sum(int *b,int i){
  int res=0;
  while(i){
    res+=b[i];
    i-=i&-i;
  }
  return res;
}
void add(int *b,int i,int v){
  while(i<=N){
    b[i]+=v;
    i+=i&-i;
  }
}

signed main(){
  int n,q;cin>>n>>q;
  while(n>N)N*=2;
  memset(bit0,0,sizeof(bit0));
  memset(bit1,0,sizeof(bit1));
  std::vector<int> ans;
  for(int i=0;i<q;i++){
    int a;cin>>a;
    if(a){
      int s;cin>>s;
      int res=0;
      res+=sum(bit0,s)+sum(bit1,s)*s;
      res-=sum(bit0,s-1)+sum(bit1,s-1)*(s-1);
      ans.push_back(res);
    }
    else{
      int l,r,x;cin>>l>>r>>x;
      add(bit0,l,-x*(l-1));
      add(bit1,l,x);
      add(bit0,r+1,x*r);
      add(bit1,r+1,-x);
    }
  }
  for(int p:ans)cout<<p<<endl;
}



Measured memory_bytes: 19416
n,m=(int(i) for i in input().split())
#print(n,m)
list1=[0 for i in range(n)]
#print(list1)

for k in range(m):
  a,b=(int(i) for i in input().split())
  for j in range(1,n+1):
    if j==a:
      list1[j-1]+=1
    if j==b:
      list1[j-1]+=1
      
for i in range(n):
  print(list1[i])




Measured memory_bytes: 3060
import java.util.*;
public class Main{
   public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   
   int n = Integer.parseInt(sc.nextLine());
   int[] arr = new int[n];
   
   for(int i = 0; i < n; i ++) {
      arr[i] = Integer.parseInt(sc.nextLine());
   }
   
   int min = arr[0];
   int maxP = arr[1] - arr[0];
   
   for(int i = 1; i < n; i ++) {
      int dif = arr[i] - min;
      if(dif > maxP) {
         maxP = dif;  
      }
      if(arr[i] < min) {
         min = arr[i];
      }
   }
   
   System.out.println(maxP);
    
   }//main
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

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

const ll N = (ll)1e6 + 5;
const ll MOD = (ll)1e9 + 7;
const ll inf = (ll)1e18 + 5;

template <class T>
bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T>
bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll add(ll x, ll y)
{
	x += y;
	if (x >= MOD)
		return x - MOD;
	return x;
}

ll sub(ll x, ll y)
{
	x -= y;
	if (x < 0)
		return x + MOD;
	return x;
}

ll mult(ll x, ll y)
{
	return (x * y) % MOD;
}

ll bin_pow(ll x, ll p)
{
	if (p == 0)
		return 1;
	if (p & 1)
		return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

ll rev(ll x)
{
	return bin_pow(x, MOD - 2);
}

int main()
{

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
#ifdef LOCAL_DEFINE
	freopen("input.txt", "rt", stdin);
#endif
	ll a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc =  new Scanner(System.in);
		int A[] = new int[9];
		for(int i = 0; i < 9; i++) {
			A[i] = sc.nextInt();
		}
		int N = sc.nextInt();
		int B[] = new int[N];
		for(int i =0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		boolean E[] = {false,false,false,false,false,false,false,false,false};
		boolean BINGO = false;
		for(int i = 0; i < 9; i++) {
			for(int j = 0; j < N; j++) {
				if(A[i] == B[j]) {
					E[i] = true;
					break;
				}
			}			
		}
		//縦
		if(E[0] == true && E[3] == true && E[6] == true) {
			BINGO = true;
		}
		if(E[1] == true && E[4] == true && E[7] == true) {
			BINGO = true;
		}
		if(E[2] == true && E[5] == true && E[8] == true) {
			BINGO = true;
		}
		//横
		if(E[0] == true && E[1] == true && E[2] == true) {
			BINGO = true;
		}
		if(E[3] == true && E[4] == true && E[5] == true) {
			BINGO = true;
		}
		if(E[6] == true && E[7] == true && E[8] == true) {
			BINGO = true;
		}
		//斜め
		if(E[0] == true && E[4] == true && E[8] == true) {
			BINGO = true;
		}
		if(E[2] == true && E[4] == true && E[6] == true) {
			BINGO = true;
		}
		System.out.println(BINGO?"Yes":"No");
	}
}

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class BIT:
    """ Binary Indexed Tree """

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

N = INT()
A = LIST()

bit = BIT(N+1)
ans = 0
for i in range(N):
    # 自分より左にある、自分より小さな数の個数
    if bit.sum(A[i]) == 0:
        ans += 1
    bit.add(A[i], 1)
print(ans)


Measured memory_bytes: 25864