akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

l = [0]*N

for num in A:
    l[num-1] += 1

for a in l:
    print(a)

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

#include <chrono>

using namespace std;
int main()
{
	int age;
	cin >> age;
	
	if (age == 3 | age==5 | age == 7) {
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
	
	
	return 0;
}

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

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

  int index = 0;
  int times = 0;

  for(int i=0;i<N;i++) {
    index = a[index] - 1;
    times++;
    if(index == 1) {
      break;
    }
  }

  if(times == N) {
    times = -1;
  }

  cout << times << endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N)cin >> A[i];
	sort(A.begin(), A.end());

	auto imos = A;
	rep(i, N - 1)imos[i + 1] += imos[i];
	int cnt = 1;
	while (cnt < N) {
		if (2 * imos[N - 1 - cnt] < A[N - cnt]) {
			break;
		}
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 105

int N,M,ans=0;
int t[MAX_N];

int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cout<<"lst "<<i<<endl;
    int k,a;
    cin>>k;
    ans+=k*(k-1);
    for(int j=0;j<k;j++)cin>>a;
    t[i]=k;
  }
  cout<<"ans "<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
// #include <cctype>


using namespace std;


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

    int point_taro = 0, point_hanako = 0;

    while (n--)
    {
        string card_taro, card_hanako;

        cin >> card_taro >> card_hanako;

        if (card_taro > card_hanako)
            point_taro += 3;
        else if (card_taro < card_hanako)
            point_hanako += 3;
        else
        {
            point_taro ++;
            point_hanako ++;            
        }

    }

    cout << point_taro << ' ' << point_hanako << endl; 
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int s = scanner.nextInt();
		int[] num = new int[n + 1];
		int max = Integer.MIN_VALUE;
		int top = 0;
		for (int i = 0; i < s; i++) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			num[a] += b;
			if (top == a && b < 0) {
				max = Integer.MIN_VALUE;
				for (int j = 1; j <= n; j++) {
					if (max < num[j]) {
						top = j;
						max = num[j];
					}
				}
			} else if (top != a && b > 0) {
				if (num[top] < num[a]) {
					top = a;
					max = num[a];
				} else if (num[top] == num[a]) {
					if (top > a) {
						top = a;
					}
				}
			}

			System.out.println(top + " " + num[top]);
		}
	}
}

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

int main()
{
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    string ans = "NO";
    if(t*(v-w) >= abs(b-a)) ans = "YES";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;

int main() {
  cin >> N;

  int ans = 0;
  int ansnum = 1;

  repe(i, 1, N) {
    int num = i;
    int cnt = 0;
    while (num % 2 == 0) {
      ++cnt;
      num /= 2;
    };
    if (chmax(ans, cnt)) {
      ansnum = i;
    }
  }

  cout << ansnum;
}


Measured memory_bytes: 3600
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  int x = stoi(s.substr(0, 2));
  int y = stoi(s.substr(2, 2));
  int X = 0, Y = 0;
  if(1 <= x && x <= 12) X = 1;
  if(1 <= y && y <= 12) Y = 1;
  if(X && Y) cout << "AMBIGUOUS" << endl;
  else if(X) cout << "MMYY" << endl;
  else if(Y) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N, M; cin >> N >> M;

  ll ans = 0;
  vector<ll> a(M); rep(i, M) cin >> a[i];

  if(N >= M) {
    cout << 0 << endl;
    return;
  }
  sort(a.begin(), a.end());
  vector<ll> b(M);
  rep(i, M-1) {
    b[i] = a[i +1 ] - a[i];
  }
  sort(b.begin(), b.end(), greater<ll>());

  ans = a[M-1] - a[0];
  rep(i, N - 1) {
    ans -= b[i];
  }
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18
void solve(vector<vector<pair<ll,ll>>> &node,ll num,ll used,vector<ll> &clr){
	ll color=1;
	REP(i,node[num].size()){
		if(clr[node[num][i].second]==0){
			if(color==used)color++;
			clr[node[num][i].second]=color;
			solve(node,node[num][i].first,color,clr);
			color++;
		}
	}
}
int main(){
	ll N;
	cin>>N;
	vector<vector<pair<ll,ll>>> node(N);
	REP(i,N-1){
		ll tmp1,tmp2;
		cin>>tmp1>>tmp2;
		tmp1--;tmp2--;
		node[tmp1].push_back(pair<ll,ll>(tmp2,i));
		node[tmp2].push_back(pair<ll,ll>(tmp1,i));
	}
	int max=0;
	REP(i,N){
		if(max<node[i].size()) max=node[i].size();
	}
	cout<<max<<endl;
	vector<ll> clr(N-1);
	solve(node,0,0,clr);
	REP(i,N-1){
		cout<<clr[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>

using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;
	int a1, a2, l = 1, r = n;
	for(int i = 0; i < m; i++) {
		cin >> a1 >> a2;
		if(l <= r) 
		{
			if(l < a1)
				l = a1;
			if(r > a2)
				r = a2;
		}
	}
	if(l > r)
		cout << 0 << endl;
	else
		cout << r - l + 1 << endl;
}

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

#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   int A,B,C,D;
   cin>>A>>B>>C>>D;
   if(A+B>C+D)cout<<"Left"<<endl;
   else if(A+B<C+D)cout<<"Right"<<endl;
   else if(A+B==C+D)cout<<"Balanced"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct node{
    int next,to;
}a[1000001];
int n,m,e,h[1001000],link[1000010],red[1100][2],blue[1100][2],ans,tot;
bool vis[100001];
void add(int from,int to)
{
    a[++tot].next=h[from];
    a[tot].to=to;
    h[from]=tot;
}
bool dfs(int u)
{
    for(int i=h[u];i;i=a[i].next)
    {
        int v=a[i].to;
        if(!vis[v])
        {
            vis[v]=1;
            if(!link[v]||dfs(link[v]))
            {
                link[v]=u;
                return 1;
            }
        }
    }
    return 0;
}
void judge(int x)
{
	for(int i=1;i<=n;i++){
		if(red[x][0]<blue[i][0]&&red[x][1]<blue[i][1])
		{
			add(x,i+n+1);
		}
	}
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>red[i][0]>>red[i][1];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>blue[i][0]>>blue[i][1];
	}
	for(int i=1;i<=n;i++)
	{
		judge(i); 
	}
    for(int i=1;i<=2*n+1;i++)
    {
        memset(vis,0,sizeof(vis));
        if(dfs(i))
        {
         ans++;
        }
    }
    cout<<ans; 
    return 0;
} 

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

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

  for (int i = 1; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3988
#include<cstdio>
#include<algorithm>
//#include<map>
using namespace std;
typedef long long ll;
const ll maxn=1e9;
const ll minn=-1e9;
#define M 200005
ll al[M],bl[M];
bool bbq(int x,int y){return x>y;}
ll read(){
	ll l=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){l=(l<<1)+(l<<3)+(ch^'0');ch=getchar();}
	return f?l:-l;
}
int main(){
	int m,f,k;ll p,l,r,ans=0,ak=0,ct=0,rt=0;
//	int min1=maxn,min2=maxn,max1=minn,max2=minn; 
	m=read();p=read();
	for(int i=1;i<=m;++i){l=read();if(l<0)al[++ct]=l;else bl[++rt]=l;
//		if(min1>al[i])min2=min1,min1=al[i];
//		else if(min2>al[i])min2=al[i];
//		if(max1<al[i])max2=max1,max1=al[i];
//		else if(max2<al[i])max2=al[i];
	}
	if(!p){puts("0");return 0;}
	if(m==1){puts("0");return 0;}
	if(ct)sort(al+1,al+1+ct,bbq);
	if(rt)sort(bl+1,bl+1+rt);
//	l=max1*min1;
//	r=max(max1*max2,min1*min2);
	l=maxn*minn;
	r=maxn*maxn;
//	printf("%lld\n",r);
	while(l<=r){
		ll mid=(l+r)/2;
		f=1;
		if(ct){
		k=ct-1;
		while(k>0&&al[ct]*al[k]>mid)--k;}
		ans=0;
		for(int i=ct;i;--i){
			while(k<=i&&al[i]*al[k+1]<=mid)++k;
			while(f<=rt&&al[i]*bl[f]>mid)++f;
			if(k>=i)k=i-1;
			ans+=k+(rt-f+1);
			if(ans>p) break;
		}
		f=1;
		for(int i=rt;i;--i){
			while(f<i&&bl[i]*bl[f]<=mid)++f;
			if(f>i)f=i;
			ans+=f-1;
			if(ans>p) break;
		}
//		printf("ans %lld mid %lld\n",ans,mid);
		if(ans<p)l=mid+1;
		else {r=mid-1;ak=mid;}
	}
	printf("%lld\n",ak);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>

using namespace std;

int biggest_number(int* array, int num){
    int i;
    int max = 0;
    for(i = 0; i < num; i++){
        if(array[i] > max){
            max = array[i];
        }
    }
    return max;
}


int main(){
    string str;
    cin >> str;
    int num;
    num = str.length();
    int* array;
    array = new int(num);
    int i;
    int counter = 0;
    for(i = 0; i < num; i++){
        if(str[i] == 'A' || str[i] == 'T' || str[i] == 'G' || str[i] == 'C'){
            counter++;
            array[i] = counter;
        }else{
            counter = 0;
            array[i] = counter;
        }
    }
    int answer = 0;
    answer = biggest_number(array, num);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
const ll INF = 1LL << 60;

vector<vll> dp(110, vll(100100, INF));

int main(){
    int n, weight;
    cin >> n >> weight;
    vi w(n), v(n);
    rep(i, n){
        cin >> w.at(i) >> v.at(i);
    }
    dp.at(0).at(0) = 0;
    rep(i, n){
        rep(j, 100100){
            if(j-v.at(i) >= 0)
            chmin(dp.at(i+1).at(j), dp.at(i).at(j-v.at(i)) + w.at(i));
            chmin(dp.at(i+1).at(j), dp.at(i).at(j));
        }
    }
    ll value_max = 0;
    rep(i, 100100){
        if(dp.at(n).at(i) <= weight)
            value_max = i;
    }
    cout << value_max << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


const ll mx = 1e5+9;
ll dp[mx][2];
int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,p;cin>>a>>p;
    cout<<(3*a+p)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] values = new int[n];
		for (int i = 0; i < n; i++) {
			values[i] = sc.nextInt();
		}
		ArrayList<Integer> leftList = new ArrayList<>();
		long leftSum = 0;
		long max = Long.MIN_VALUE;
		for (int i = 0; i <= n && i <= k; i++) {
			if (i != 0) {
				if (values[i - 1] < 0) {
					leftList.add(values[i - 1]);
				} else {
					leftSum += values[i - 1];
				}
			}
			long sum = leftSum;
			ArrayList<Integer> list = new ArrayList<Integer>(leftList);
			for (int j = 0; i + j <= n && i + j <= k; j++) {
				if (j != 0) {
					if (values[n - j] < 0) {
						list.add(values[n - j]);
					} else {
						sum += values[n - j];
					}
				}
				Collections.sort(list);
				long ans = sum;
				for (int l = k - i - j; l < list.size(); l++) {
					ans += list.get(l);
				}
				max = Math.max(max, ans);
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    for(int i=0;i<=m;i++)
        for(int j=0;j<=m;j++)
            for(int k=0;k<=m,i+j+k<=m;k++)
            {
                if(i+j+k==m && i*1000+j*5000+k*10000==n)
                {
                    printf("%d %d %d",k,j,i);
                    return 0;   
                }
            }
    printf("-1 -1 -1");
    return 0;
}

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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int MOD = 1e9+7;

const int N = 1e4+10;
const int M = 101;

int dp[N][M][2];

string s;
int d;

int go(int i,int md,int flag)
{
    if(i == s.length()) return (md == 0);
    
    int & res = dp[i][md][flag];
    
    if(res != -1) return res;
    
    res = 0;

    int r = 9*flag + (1-flag)*(s[i]-'0');
    
    for(int v=0;v<=r;v++)
    {
       int nmd = ((md - v)%d + d)%d;
       res+=go(i+1,nmd,flag | (v < r));
    }
    
    res%=MOD;
    
    return res;
}

signed main()
{
    fast;
    
    memset(dp,-1,sizeof(dp));
    
    cin >> s >> d;
    
    cout << (go(0,0,0) - 1 + MOD)%MOD;
}

Measured memory_bytes: 16896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

bool IsPrime(int64_t i){
  int64_t j = 2;
  while(j * j <= i){
    if(i % j == 0){
      return false;
    }
    j++;
  }
  return true;
}

int main(){
  int64_t X;
  cin >> X;
  int64_t i = X;
  while(true){
    if(IsPrime(i)){
      cout << i << endl;
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll m;
    cin >> m;
    ll d[m], c[m];
    rep(i, m) { cin >> d[i] >> c[i]; }
    ll ans = 0;
    rep(i, m) { ans += c[i]; }

    ll sum = 0;
    rep(i, m) { sum += d[i] * c[i]; }

    while (sum >= 10) {
        ll num = sum / 10;
        ans += num;
        sum -= num * 9;
    }

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



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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};

long long modpow( long long a, long long n, long long mod ) {
	long long res = 1;
	while (n > 0){
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
ll* com;
ll com_init( ll N, ll K ){
	com = new ll[ K + 1 ];
	com[ 0 ] = 1;
	rep( i, 1, K + 1 ){
		com[ i ] = ((( ll )( N - i + 1 ) * (( ll )com[ i - 1 ] ) % k_mod ) * modpow( i, k_mod - 2, k_mod )) % k_mod;
		if (com[ i ] < 0){
			cout << com[ i ] << endl;
			exit( 1 );
		}
	}
}
int main( void ){
	initialize();
	ll N, A, B;
	cin >> N >> A >> B;
	com_init( N, max( A, B ));
	ll sum = modpow( 2, N, k_mod ) - 1;
	sum = ( sum + k_mod - com[ A ] ) % k_mod;
	sum = ( sum + k_mod - com[ B ] ) % k_mod;
	cout << sum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	cin.tie( 0 );
	ios::sync_with_stdio( false );
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str;
	cin >> str;
	rep(bit, 8) {
		int tmp = str[0] - '0';
		rep(i, 3) {
			// ビットbitにi番目のフラグが立っているかどうか
			if (bit & (1 << i)) {
				tmp += str[i + 1] - '0';
			}
			else {
				tmp -= str[i + 1] - '0';
			}
		}
		if (tmp == 7) {
			cout << str[0];
			rep(i, 3) {
				if (bit&(1 << i)) {
					cout << "+";
				}
				else {
					cout << "-";
				}
				cout << str[i + 1];
			}
			cout << "=7" << endl; return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int n, k;
    cin >> n >> k;
    
    string s;
    cin >> s;
    
    vector<int> nums;
    int now = 1;
    int cnt = 0;
    
    for (int i = 0; i < n; i++){
        if (s[i] == (char)(now + '0')) cnt++;
        else{
            nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) nums.push_back(cnt);
    
    if(nums.size() % 2 == 0) nums.push_back(0);
    
    vector<int> sum(nums.size() + 1);
    for (int i = 0; i < nums.size(); i++){
        sum[i + 1] = sum[i] + nums[i];
    }
    
    int add = 2 * k + 1;
    int ans = 0;
    
    for (int i = 0; i < nums.size(); i += 2){
        int tmp = 0;
        int left = i;
        int right = min(i + add, (int)nums.size());
        tmp = sum[right] - sum[left];
        ans = max(ans, tmp);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1272
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

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

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

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

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int N, L, M, K;

    double R;

    scanf("%lf", &R);

    printf("%f", 2*M_PI*R);

}



Measured memory_bytes: 3824
#include <iostream>

using namespace std;

int main()
{
    int x ,y ,z, count;
    
    cin >> x >> y >> z;
    
    for(x; x <= y ; x++){
        
        if(z % x == 0){
            count++;
        }
    }
    
    cout << count << endl;
   
   return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

bool cmp(Pll a, Pll b)
{
    return a.first < b.first;
}

int main()
{
    int N, T;
    cin >> N >> T;
    vector<Pll> A(N);
    for(int i=0; i<N; i++) cin >> A[i].first >> A[i].second;

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

    ll ans = 0;
    Vvec<ll> dp(N+1, vector<ll>(T+A[N-1].first+1, 0));
    for(int i=1; i<=N; i++){
        for(int j=0; j<=T+A[N-1].first; j++){
            dp[i][j] = dp[i-1][j];
            if(j-A[i-1].first>=0 && j-A[i-1].first<T)
                dp[i][j] = max(dp[i][j], dp[i-1][j-A[i-1].first]+A[i-1].second);
            ans = max(ans, dp[i][j]);
        }
    }

    cout << ans << endl;
    // for(int i=0; i<=N; i++){
    //     for(int j=0; j<T; j++) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
}

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

int main() {
    int n;
    cin>>n;
    long long int A[n];
    for( int i=0;i<n ;i++) cin>>A[i];
    
	long long int su[n+1];
    su[0]=0;
    for( int i=1;i<=n;i++)
    {
        if(i==1) su[i]=A[i-1];
        else su[i]=su[i-1]+A[i-1];
    }
    
    long long int arr[n][n];
    for( int i=1;i<=n;i++)
    {
        for( int j=0;j<=n-i;j++)
        {
            if(i==1)
            {
                arr[j][j+i-1]=A[j];
            }
            else
            {
                arr[j][j+i-1] = max(su[j+i]-su[j]-arr[j][j+i-2],su[j+i]-su[j]-arr[j+1][j+i-1]);
            }
        }
    }
    
    cout<< (2*arr[0][n-1]) - su[n];
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
const long long INF = LLONG_MAX/2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans=0, sum = 0;

string s;
ll cnt;

int main()
{
	cnt = 0;
	cin >> s;
	REP(i, s.size())
	{
		if (s[i] == 'S')
		{
			ans++;
			cnt++;
		}
		else if (s[i] == 'T')
		{
			if (cnt > 0) {
				cnt--;
				ans--;
			}
			else ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int T,a,b;ll ans;
db cal(ll x) {return (-(ll)b*x-1)*1./(a+x);}
int main()
{
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	for(scanf("%d",&T);T--;)
	{
		scanf("%d%d",&a,&b),ans=0;
		if(a<b) swap(a,b);
		if(a==1&&b==1) {puts("0");continue;}
		if(b>=1000000)
		{
			ll dd=sqrt(1ll*a*b),ans=dd*2-1;
			if(dd*dd==1ll*a*b)
			{
				if(a==b)ans--;
				else ans-=2;
			}
			else if(dd*(dd+1)>=1ll*a*b)ans--;
			cout<<ans<<endl;
			continue;
		}
		/*
		for(ll x=-a+1,y,tmp;;x++)
		{
			tmp=floor(((ll)-b*x-1)*1./(a+x));
			dbg1(x),dbg2(tmp);
			if(tmp==-b) break;
			if(tmp)
			{
				if(tmp^last) ans++,last=tmp;
				else
				{
					ans+=tmp+b-1;
					if(tmp>0) ans--;
					break;
				}
			}
		}
		dbg2(ans);*/
		ll l=-a+1,r=1e10,mid;
		for(;l<r;)
		{
			mid=l+r>>1;
//			dbg2(mid);
//			dbg1(cal(mid+1)),dbg2(cal(mid));
			cal(mid)-cal(mid+1)<1?r=mid:l=mid+1;
		}
//		dbg2(l);
		ll tmp1=floor((-(ll)b*l-1)*1./(a+l));
		ans=l+a+tmp1+b-1;
		if(l==-a+1)
		{
			if(tmp1>=0) ans--;
			cout<<ans<<"\n";
			continue;
		}
		ll tmp2=floor((-(ll)b*(l-1)-1)*1./(a+l-1));
//		dbg1(l-1),dbg1(cal(l-1)),dbg2(tmp2);
//		dbg1(l),dbg1(cal(l)),dbg2(tmp1);
//		dbg1(tmp1),dbg2(tmp2);
		if(tmp1>=0||tmp2<=0) ans--;
//		printf("%lld\n",ans);
		cout<<ans<<"\n";
	}
	return 0;
}


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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  string s;
  cin >> s;
  int d[4];
  char p[4];
  REP(i,4) d[i] = (int)(s[i] - '0');
  REP(i,(1<<3)) {
    int x = d[0]; 
    REP(j,3) {
      if (i & (1<<j)) {
        x += d[j+1];
        p[j+1] = '+';
      } else {
        x -= d[j+1];
        p[j+1] = '-';
      }
    }
    if (x == 7) {
      fprintf(stdout, "%d", d[0]);
      FOR(i,1,4) fprintf(stdout, "%c%d", p[i], d[i]);
      puts("=7");
      break;
    }
  }
  return 0;
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  set<string> st;
  int N = S.size();
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= 5; j++) {
      st.insert(S.substr(i, j));
    }
  }
  int i = 0;
  for (auto x : st) {
    i++;
    if (i == K) {
      cout << x << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1664
from itertools import permutations

N=int(input())
l=[i+1 for i in range(N)]
P=tuple(map(int, input().split()))
Q=tuple(map(int, input().split()))
counter=0
for t in permutations(l):
  if P==t:
    a=counter
    
  if Q==t:
    b=counter
    
  counter+=1
  
print(abs(a-b))

Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x[5];
    for(int i = 0; i < 5; i++){
        cin >> x[i];
    }
    
    for(int i = 0; i < 5; i++){
        if(x[i] == 0) cout << i + 1 << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int depth[100002];

inline int getComponent(int n, vector<int> &comp) {
    while (n != comp[n]) n = comp[n];
    return n;
}

void work() {
    int N,M,K; cin>>N>>M>>K;
    vector<int> comp(N+1); for (int i = 0; i <= N; ++i) comp[i] = i;
    vector<int> sz(N+1, 1);
    vector<vector<int>> friends(N+1);
    for (int i = 0; i < M; ++i) {
        int u,v; cin>>u>>v; friends[u].push_back(v); friends[v].push_back(u);
        int compu = getComponent(u, comp); int compv = getComponent(v, comp);
        if (compu == compv) continue;
        if (depth[compu] < depth[compv]) {
            if (depth[compu] == depth[compv]) ++depth[compv];
            sz[compv] += sz[compu];
            comp[compu] = compv;
        } else {
            if (depth[compu] == depth[compv]) ++depth[compu];
            sz[compu] += sz[compv];
            comp[compv] = compu;
        }
    }
    
    vector<vector<int>> block(N+1);
    for (int i = 0; i < K; ++i) {
        int u,v; cin>>u>>v;
        block[u].push_back(v); block[v].push_back(u);
    }
    for (int i = 1; i <= N; ++i) {
        int ans = sz[getComponent(i,comp)] - friends[i].size() - 1;
        for (int j : block[i]) {
            if (getComponent(j, comp) == getComponent(i, comp)) --ans;
        }
        cout << ans << " ";
    }
    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();

    return 0;
}


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

using namespace std;

struct node {
  int key;
  node *lp,*rp;

  node(){}
  node(int z):key(z),lp(NULL),rp(NULL){}

} *root;

void insert(node* z){
  node *x=root,*y=NULL;

  while(x){
    y = x;
    x = (z->key < x->key) ? x->lp : x->rp;
  }

  if(!y)root = z;
  else (z->key < y->key ? y->lp : y->rp) = z;
}

bool find(node *t, int v){
  if(!t)return false;
  if(t->key == v)return true;
  return find((v < t->key)?t->lp:t->rp,v);
}

void erase(node *t,int v,node *p){
  if(!t)return;
  if(t->key == v){
    if(!t->lp && !t->rp){
      (p->lp==t? p->lp : p->rp) = NULL;
      delete t;
    }
    else if(t->lp && t->rp){
      node *c = t->rp,*cp = t;
      while(c->lp)cp=c,c=c->lp;
      t->key = c->key;

      if(!c->lp && !c->rp){
        (cp->lp==c?cp->lp:cp->rp)=NULL;
        delete c;
      }
      else {
        node *cc = (c->lp) ? c->lp : c->rp;
        (cp->lp==c ? cp->lp : cp->rp) = cc;
        delete c;
      }
    }
    else {
      node *c = (t->lp) ? t->lp : t->rp;
      (p->lp==t? p->lp : p->rp) = c;
      delete t;
    }
    return;
  }
  return erase((v < t->key ? t->lp : t->rp),v,t);
}

vector<int> preorder, inorder;

void dfs(node *t = root){
  preorder.push_back(t->key);
  if(t->lp)dfs(t->lp);
  inorder.push_back(t->key);
  if(t->rp)dfs(t->rp);
}

int main(void) {

  root = NULL;

  int n,v;
  string s;
  cin >> n;

  for(int i=0;i<n;i++){
    cin >> s;
    if(s=="insert"){
      cin >> v;
      insert(new node(v));
    } else if(s=="find"){
      cin >> v;
      cout << (find(root,v)?"yes":"no") << endl;
    } else if(s=="delete"){
      cin >> v;
      erase(root,v,root);
    } else {
      dfs();
      for(int j=0;j<inorder.size();j++)cout << " " << inorder[j];
      cout << endl;
      for(int j=0;j<preorder.size();j++)cout << " " << preorder[j];
      cout << endl;

      preorder.clear();
      inorder.clear();
    }
  }

  return 0;
}

Measured memory_bytes: 16932
#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>;

const int MOD = 998244353;

const int C = 3005, D = 3005;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int dp[C][D][2];
  rep(i, c+1) rep(j, d+1) rep(k, 2) dp[i][j][k] = 0;

  rep(i, c+1) rep(j, d+1) {
    if (i < a) continue;
    if (j < b) continue;
    if (i == a && j == b) {
      dp[i][j][0] = 1;
      continue;
    }
    dp[i][j][0] = ((ll)dp[i][j-1][0] * i % MOD + dp[i][j-1][1]) % MOD;
    dp[i][j][1] = (ll)(dp[i-1][j][0] + dp[i-1][j][1]) % MOD * j % MOD;
  }
  int ans = (dp[c][d][0] + dp[c][d][1]) % MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 74008
# -*- Coding: utf-8 -*-

import numpy as np

NMC=list(map(int,input().split()))
B=list(map(int,input().split()))

A=[0]*NMC[0]
count=0

for i in range(int(NMC[0])):
	A[i]=list(map(int,input().split()))
A=np.array(A)
B=np.array(B)
B=B[np.newaxis,:]
for i in range(NMC[0]):
	if np.sum(A[i,:]*B[0,:])+NMC[2]>0:
		count=count+1
print(count)

Measured memory_bytes: 12392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  map<ll, bool> m;
  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    if (m[a]) m[a] = false;
    else m[a] = true;
  }
  ll ans = 0;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (i -> second) ans++;
  }
  cout << ans << endl;
}

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

int main()
{
    int w, b = 4280;

    while( cin >> w )
    {
        if( w == -1 )
            break;
        
        if( w <= 10 )
            cout << b - 1150 << endl;
        else if( w <= 20 )
            cout << b - ( 1150 + ( w - 10 ) * 125 ) << endl;
        else if( w <= 30 )
            cout << b - ( 1150 + 10 * 125 + ( w - 20 ) * 140 ) << endl;
        else
            cout << b - ( 1150 + 10 * 125 + 10 * 140 + ( w - 30 ) * 160 ) << endl;
    }
    return 0;
}


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

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x)   (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second
#define pf printf
#define sf scanf

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

const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  ll n;
  int num[10];
  while(sf("%lld",&n)!=EOF){
    for(int i=9;i>=0;i--){
      num[i]=(n%10);
      n/=10;
    }

    for(int i=8;i>=0;i--){
      rep(j,i+1){
	num[j]=(num[j]+num[j+1])%10;
      }
    }
    cout<< num[0]<< endl;
  }


}

Measured memory_bytes: 1208
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

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

ans = H * W

if H % 3 == 0:
    ans = 0
elif H >= 4:
    ans = min(ans, W)

if W % 3 == 0:
    ans = 0
elif W >= 4:
    ans = min(ans, H)

for h in range(1, H):
    tmp1 = W * h
    tmp2 = (H - h) * (W // 2)
    tmp3 = (H - h) * ((W + 1) // 2)
    tmp_ans = max(tmp1, tmp3) - min(tmp1, tmp2)
    ans = min(ans, tmp_ans)

H, W = W, H
for h in range(1, H):
    tmp1 = W * h
    tmp2 = (H - h) * (W // 2)
    tmp3 = (H - h) * ((W + 1) // 2)
    tmp_ans = max(tmp1, tmp3) - min(tmp1, tmp2)
    ans = min(ans, tmp_ans)

    
print (ans)

Measured memory_bytes: 3064
n = int(input())
INF = 10**5
answer = INF
for i in range(n+1):
    money = i
    cnt = 0
    while money > 0:
        cnt += money % 6
        money //= 6

    money = n-i
    while money > 0:
        cnt += money % 9
        money //= 9
    if answer > cnt:
        answer = cnt
print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int x; 
        cin >> x;
        ans += 2 * min(k-x, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  char S[12];
  cin >> A >> B >> S;
  for(int i=0;i<A;i++){
  if(!('0'<=S[i]&&S[i]<='9')){
      cout << "No" << endl;
      return 0;
  }}
  if(S[A]!='-'){ cout << "No" << endl;
  return 0;}
  for(int i=A+1;i<A+B;i++){
  if(!('0'<=S[i]&&S[i]<='9')){
      cout << "No" << endl;
      return 0;
  }}
cout << "Yes" << endl;
}

Measured memory_bytes: 3648
import math
import itertools

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

ans=cnt=0
for i in itertools.permutations([_ for _ in range(n)]):
  for j in range(n-1):
    x1,x2=d[i[j]][0],d[i[j+1]][0]
    y1,y2=d[i[j]][1],d[i[j+1]][1]
    ans+=math.sqrt((x1-x2)**2+(y1-y2)**2)
  cnt+=1
  #print(j,ans,cnt)
print(ans/cnt)

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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long number = 1; number < N + 1; number++) {
    if (number % 3 != 0 && number % 5 != 0) {
      ans += number;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
vector<int> G[1010];
int came[1010];
int finish[1010];
vector<int> dat;
bool cycle = false;
bool con[1010];
int st;

void dfs(int v){
    if(cycle) return;

    came[v] = true;
    dat.push_back(v);

    for(auto& u : G[v]){
        if(!came[u]) dfs(u);

        if(cycle) return;

        if(came[u] && !finish[u]){
            st = u;
            cycle = true;
            return;
        }
    }
    finish[v] = true;
    if(cycle) return;
    dat.pop_back();

    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
    }
    for(int i = 1; i <= N; i++){
        if(!came[i]) dfs(i);
    }

    if(dat.size() == 0){
        cout << -1 << endl;
        return 0;
    }
    for(auto it = dat.begin(); it < dat.end(); it++){
        if(*it == st){
            dat.erase(dat.begin(), it);
            break;
        }
    }
    for(auto& u : dat) con[u] = true;

    while(true){
        dat.push_back(dat[0]);
        
        int s = 0, t = 0;
        bool flag = false;
        for(int i = 0; i < dat.size() - 2; i++){
            for(auto u : G[dat[i]]){
                if(dat[i + 1] == u) continue;
                if(con[u]) s = dat[i], t = u;
            }
        }
        if(s == 0 && t == 0) break;
        vector<int> dat2 = {t};
        while(true){
            for(auto u : G[t]){
                if(con[u]){
                    dat2.push_back(u);
                    t = u;
                    break;
                }
            }
            if(t == s) break;
        }
        dat = dat2;
        for(int i = 1; i <= N; i++) con[i] = false;
        for(auto& u : dat) con[u] = true;
    }
    cout << dat.size() - 1 << endl;
    for(int i = 0; i < dat.size() - 1; i++) cout << dat[i] << endl;
    return 0;
}

Measured memory_bytes: 384
import numpy as np

N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
cx = sum(X)/N
cy = sum(Y)/N
dist1 = []
dist2 = []

for x, y in zip(X, Y):
    dist1_ = x-cx + y-cy
    dist1.append(dist1_)
    dist2_ = (x-cx) - (y-cy)
    dist2.append(dist2_)

p1_max = np.argmax(np.array(dist1))
p1_min = np.argmin(np.array(dist1))
p2_max = np.argmax(np.array(dist2))
p2_min = np.argmin(np.array(dist2))

ans1 = abs(X[p1_max] - X[p1_min]) + abs(Y[p1_max] - Y[p1_min])
ans2 = abs(X[p2_max] - X[p2_min]) + abs(Y[p2_max] - Y[p2_min]) 

print(max(ans1, ans2))


Measured memory_bytes: 60172
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(N: int, A: "List[int]"):
    cnt = 0
    for a in A:
        if a == cnt + 1:
            cnt += 1

    if cnt == 0:
        return -1
    return N - cnt


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, A)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31596
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>

using namespace std;
using lli = long long int;

int main(void){
    string a;
    string b;
    cin >> a >> b;
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    if(a < b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

long long gcd(const long long a, const long long b){ 
  return (a % b) ? gcd(b, a % b) : b; 
}
long long lcm(const long long a, const long long b){
  long long re = a / gcd(a, b) * b;
  return re;
}

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  long long ans = a[0];
  for(int i = 1; i < n; i++) ans = lcm(ans, a[i]);
  cout << ans << endl;
}

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

using namespace std;

int main(){
  string str;
  int k;
  cin >> str;
  cin >> k;
  vector<string> target;
  for(int i=0; i<str.length(); i++) for(int j=0; j<5; j++){
    if(i+j>str.length()) continue;
    target.push_back((string)str.substr(i, j+1));
  }
  sort(target.begin(), target.end());
  unique(target.begin(), target.end());

  cout << target[k-1] << endl;

  return 0;
}

Measured memory_bytes: 1660