akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n;
int a[3][3];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<bool> >v(3,vector<bool>(3,false));
    for (int i = 0; i < 3; i++)
    {
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    cin >> n;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if(a[i][j]==temp){
                    v[i][j]=true;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if(!v[i][j])break;
            if(j==2)return yes,0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if(!v[j][i])break;
            if(j==2)return yes,0;
        }
    }
    if(v[0][0]&&v[1][1]&&v[2][2])return yes,0;
    if(v[0][2]&&v[1][1]&&v[2][0])return yes,0;
    no;
}


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

using ll = long long;

#define P107 10000010L
#define CUT   5000050L

signed main()
{
    ll n; cin >> n;
    if (n == 1){ cout << 1 << endl; return 0;}
    vector<ll> numDivisor(P107,1);
//    for (ll i = 2; P107/2; ++i) {
    for (ll i = 2; i <= n; ++i){
//        if (i > CUT) break;
//        for (ll j = i; j <= P107; j += i){
        for (ll j = i; j <= n; j += i){
            numDivisor[j]++;
        }
    }

    ll ans = 0;
    for (ll k = 1; k <= n; ++k)
        ans += k * numDivisor[k];

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


Measured memory_bytes: 81316
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define re(i , n) for(Long i = 0; i < (Long)n ; i++)
#define rer(i, a, b) for (Long i = a, to = b; i < to; i++)
 
using namespace std;
typedef long long Long;
const Long MX=2e5 + 1;
const Long MOD=1000000007;
const Long MX2=9223372036854775806;
 
 
int main(){
	ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	Long k;cin>>k;
	Long a,b;cin>>a>>b;
	Long r=b/k;
	if(r*k>=a){
		cout<<"OK";
	}else{
		cout<<"NG";
	}
	
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<long long,int> P;

int main(){
	char w[101];
	scanf("%s",w);

	int num[26];
	for(int i=0;i<26;i++) num[i] = 0;

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

	for(int i=0;i<26;i++){
		if(num[i]%2!=0){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 256
n=int(input())
tarou=0
hanako=0
for i in range(n):
  #print(tarou,hanako)
  t,h=map(str,input().split())
  if t==h:
    tarou+=1
    hanako+=1
  elif (t>h)==True:
    tarou+=3
  else:
    hanako+=3

print(tarou,hanako)


Measured memory_bytes: 5596
def cal(direction, pre_top, pre_front, pre_right)
    
    if direction == "North" then 
        top = pre_front
        front = 7 - pre_top
        right = pre_right
    
    elsif direction == "South" then
        top = 7 - pre_front
        front =pre_top
        right = pre_right
        
    elsif direction ==  "East" then
        top = 7 - pre_right
        front = pre_front
        right = pre_top
    
    elsif direction ==  "West" then
        top = pre_right
        front =pre_front
        right = 7 - pre_top

    elsif direction ==  "Right" then
        top = pre_top
        front = pre_right
        right = 7 - pre_front
    

    elsif direction ==  "Left" then
        top = pre_top
        front = 7 - pre_right
        right = pre_front
    
    else
        #printf("弾かれた%s %d" ,direction, direction.length)
    end
    
    return top, front, right
end



j = 0
while (j == 0)
num = gets
if num.to_i == 0 then
    break
end
top = 1
front = 2
right = 3
sum = 1
for i in 0..num.to_i-1 do
    order = gets
    #printf("%s", order)
    top, front, right = cal(order.chomp ,top,front, right)
    sum = sum + top
end

printf("%d\n",sum)
end


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)

int main()
{
    lint n;
    cin >> n;
    lint ans=0,power=0, count,monster;

    vector<lint> a(n+1), b(n);
    REP(i, n+1) { cin >> a[i]; }
    REP(i, n) { cin >> b[i]; }

    REP(i, n)
    {
        monster = a[i];
        if(power>=monster){
            power = b[i];
            ans += a[i];
        }else{
            monster = monster - power;
            if (b[i] >=monster){
                power = b[i] - monster;
                ans += a[i];
            }else
            {
                ans += power + b[i];
                power = 0;
            }
        }
    }

    ans += min(a[n], power);

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long var265;const int var272=1039074182;using namespace std;int var286;int a[100005];int main(){cin>>var286;for(int var317=0;var317<var286;var317++){scanf("%d",a+var317);}sort(a,a+var286);int var359,var361;for(int var317=0;var317<var286;var317++){if(a[var317]>=0 && var317>=1) break;if(var317==var286-1) break;var361=var317+1;}var359=var286-var361;int var436=0;for(int var317=0;var317<var361;var317++){var436-=a[var317];}for(int var317=var361;var317<var286;var317++){var436+=a[var317];}cout<<var436<<endl;int now=0;if(var361==var359-1){cout<<a[0]<<' '<<a[var361]<<endl;int now=a[0]-a[var361];int var569=1,var573=var361+1,var579=1;for(int var317=0;var317<var286-2;var317++){if(var579==0){var579=1;printf("%d %d\n",a[var569],now);now=a[var569++]-now;}else{var579=0;printf("%d %d\n",a[var573],now);now=a[var573++]-now;}}return 0;}if(var361>=var359){cout<<a[var361]<<' '<<a[0]<<endl;now=a[var361]-a[0];int var573=var361+1,var569=1,var579=0;for(int var317=0;var317<var359*2-2;var317++){if(var579==0){var579=1;printf("%d %d\n",a[var569],now);now=a[var569++]-now;}else{var579=0;printf("%d %d\n",a[var573],now);now=a[var573++]-now;}}for(int var317=var359;var317<var361;var317++){printf("%d %d\n",now,a[var317]);now=now-a[var317];}return 0;}if(var361==1){int now=a[0];for(int var317=1;var317<var286-1;var317++){printf("%d %d\n",now,a[var317]);now=now-a[var317];}printf("%d %d\n",a[var286-1],now);}else{cout<<a[var361]<<' '<<a[0]<<endl;now=a[var361]-a[0];int var573=var361+1,var569=1,var579=0;for(int var317=0;var317<var361*2-3;var317++){if(var579==0){var579=1;printf("%d %d\n",a[var569],now);now=a[var569++]-now;}else{var579=0;printf("%d %d\n",a[var573],now);now=a[var573++]-now;}}for(int var317=var573;var317<var286-1;var317++){printf("%d %d\n",now,a[var317]);now=now-a[var317];}printf("%d %d\n",a[var286-1],now);return 0;}return 0;}

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

using namespace std;

typedef long long ll;

//int d[4*100000];



int main ()
{
    ios_base::sync_with_stdio(false);
  //  freopen("input.txt", "r", stdin);
    int a, b, k;
    cin >> a >> b >> k;

    for (int i = a; i < a+k && i <= b; i++) {
        cout << i << endl;
    }
    vector<int> v;
    for (int i = b; b - k < i && i >= a + k; i--) {
        v.push_back(i);
    }
    reverse(v.begin(), v.end());
    for (auto i: v) {
        cout << i << endl;
    }
    return 0;
}


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

int main()
{
	int N, T;
	cin >> N >> T;
	vector<pair<int, int>> d(N);
	for (int i = 0; i < N; ++i)
	{
		int a, b;
		cin >> a >> b;
		d[i] = {a, b};
	}
	sort(d.begin(), d.end());
				
	vector<int> dp(T + 3000, 0); // dp[t] = max happiness at time t
	
	for (int i = 0; i < N; ++i)
		for (int t = T - 1; t >= 0; --t)
			dp[t+d[i].first] = max(dp[t+d[i].first], dp[t] + d[i].second);
	
	cout << *max_element(dp.begin(), dp.end()) << '\n';
}


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

int const N = 100000;
int b[N], l[N], r[N];
pair<ll, ll> x[N];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, n)scanf("%d%d%d", b + i, l + i, r + i);
	ll s = 0, an = 0;
	f(i, 0, n)s += (ll)b[i] * l[i];
	f(i, 0, n)x[i] = make_pair((ll)m * r[i] - (ll)(r[i] - l[i]) * b[i], i);
	sort(x, x + n, greater<pair<ll, ll> >());
	int i = 0;
	while (s > 0)if (x[i].first <= s){
		s -= x[i].first;
		an += m;
		++i;
	}else break;
	if (s > 0){
		int mn = m;
		f(j, i, n){
			int id = x[j].second;
			ll nan = (s + l[id] - 1) / l[id];
			nan = min(nan, (s + (ll)(r[id] - l[id]) * b[id] + r[id] - 1) / r[id]);
			mn = min((ll)mn, nan);
		}
		s -= x[i].first;
		f(j, 0, i){
			s += x[j].first;
			int id = x[j].second;
			ll nan = (s + l[id] - 1) / l[id];
			nan = min(nan, (s + (ll)(r[id] - l[id]) * b[id] + r[id] - 1) / r[id]);
			mn = min((ll)mn, nan);
			s -= x[j].first;
		}
		an += mn;
	}
	printf("%lld\n", an);
}

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

sunuke_list = [0 for i in range(n)]

for i in range(k):
    d = int(input())
    As = list(map(int, input().split()))
    for A in As:
        sunuke_list[A-1] += 1

ans = 0

for i in range(n):
    if sunuke_list[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9188
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut ans = 0;
    for i in 1..=n {
        let x = n / i;
        ans += x * (x + 1) * i / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2200
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++)cin >> d[i];
	int ans = 0;
	sort(d.begin(), d.end());
	cout << (d[n / 2] - d[n / 2-1]) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;cin>>k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[k-1]<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
int main()
{
    ll n,x,m;
    cin>>n>>x>>m;
    map<ll,ll> mp;
    vector<ll> v;
    ll sum=0;    
    v.push_back(0);
    ll last=0;
    for(ll i=1;i<=n;i++)
    {
        // cout<<x<<endl;
        x=x%m;
        if(x==0)
        break;
        if(mp[x])
        {
            last=i;
            break;
        }
        sum+=x;
        v.push_back(x);
        mp[x]=i;
        x=(x*x)%m;
    }
    // cout<<last<<" "<<mp[x]<<" "<<sum<<" "<<v.size();
    if(last==0)
    {
        cout<<sum<<endl;
        return 0;
    }
    ll ans=sum;
    ll my_size=last-mp[x];
    n=n-last+1;
    ll sum2=0;
    for(ll i=mp[x];i<last;i++)
    sum2+=v[i];
    ans+=(n/my_size)*sum2;
    n=n%my_size;
    for(ll i=mp[x];i<mp[x]+n;i++)
    ans+=v[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 6584
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
double pi = 3.1415926535898;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      double n;
      cin >> n;
      n = 2*n*pi;
      cout << n << endl;
      return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


bool comp(const pii &a, const pii &b)
{
    return a.second > b.second;
}

void solve()
{
    int N, M, Q; cin >> N >> M >> Q;
    vector<pii> train(M); REP(i, M) cin >> train[i].first >> train[i].second;
    vector<pii> section(Q); REP(i, Q) cin >> section[i].first >> section[i].second;
    sort(ALL(train));

    vvi sum(N+1, vi(N+2));
    REP(i, M)
    {
        sum[train[i].first][train[i].second+1]++;
    }
    REP1(i, N)
    {
        REP1(j, N)
        {
            sum[i][j+1] += sum[i][j];
        }
    }

    REP(i, Q)
    {
        int ans = 0;
        for(int j = section[i].first; j <= section[i].second; j++)
        {
            ans += sum[j][section[i].second+1] - sum[j][section[i].first];
        }
        cout << ans << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main(int argc, char const *argv[]){
    int n;
    cin >> n;

    if (n%2==0){
        cout << (n/2.0)/n << endl;
    } else {
        cout << ((n+1)/2.0)/n << endl;
    }

    return 0;
}


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


int main()
{
   int T;
   cin>>T;
   while(T--)
   {
       int N;
       cin>>N;
       string s;
       cin>>s;
       vector<bool> done(s.size(),false);
       vector<vector<int> > dp(3,vector<int>(N+2,1000000));
       dp[0][0]=0;
       for(int c=0;c<=N;c++)
       {
           bool b1 = (c != 0 && s[c*2-1]=='Y') || (c != N && s[c*2] == 'Y');
           bool b2 = (c != 0 && s[c*2-1+2*N]=='Y') || (c != N && s[c*2+2*N] == 'Y');
           if(b1 && b2)
           {
               dp[0][c+1] = min(dp[0][c]+4,min(dp[1][c]+3,dp[2][c]+3));
               dp[1][c+1] = min(dp[0][c]+3,min(dp[2][c]+3,dp[1][c]+4));
               dp[2][c+1] = min(dp[0][c]+3,min(dp[2][c]+4,dp[1][c]+3));

           }
           else if(!b1 && b2)
           {
                dp[0][c+1] = min(dp[0][c]+4,min(dp[1][c]+3,dp[2][c]+3));
                dp[1][c+1] = min(dp[0][c]+3,min(dp[1][c]+2,dp[2][c]+2));
                dp[2][c+1] = min(dp[0][c]+3,min(dp[1][c]+2,dp[2][c]+2));
           }
           else if(b1 && !b2)
           {
                dp[0][c+1] = min(dp[0][c]+2,min(dp[1][c]+2,dp[2][c]+3));
                dp[1][c+1] = min(dp[0][c]+2,min(dp[1][c]+2,dp[2][c]+3));
                dp[2][c+1] = min(dp[0][c]+3,min(dp[1][c]+3,dp[2][c]+4));
           }
           else if(!b1 && !b2)
           {
                dp[0][c+1] = min(dp[0][c]+1,min(dp[1][c]+2,dp[2][c]+3));
                dp[1][c+1] = min(dp[0][c]+2,min(dp[1][c]+1,dp[2][c]+2));
                dp[2][c+1] = min(dp[0][c]+3,min(dp[1][c]+2,dp[2][c]+1));
           }
       }
       cout<<dp[0][N+1]-1<<endl;

   }
}

Measured memory_bytes: 1452
//#define anjn
//      Anjan Agarwala - anjn98

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, 
                  tree_order_statistics_node_update> ordered_set;

//ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

#define PR(x) cout<<#x<<": "<<x<<"\n";
#define PR1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<"  |  "<<#z<<": "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007


const int N=5e3+99;


int32_t main() 
{
    IO
  

    ll n,x,cnt=1,d=0,l;
    cin>>n>>x;


    for(int i=0;i<n;i++)
    {
        cin>>l;
        if(d+l<=x) cnt++,d+=l;
        else break;
    }

    cout<<cnt<<endl;        
    
}




 
    

Measured memory_bytes: 256
I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10**18]
Xs = accumulate(xs)

N = len(xs) - 1
rs = [0]*I
mny = N+1
for l, (x, X) in enumerate(zip(xs[1:], Xs)):
    l += 2
    y = X//(x+1) + (N-l+1) + 1
    if y-(N-l+1) > 0 and x <= X//(y-(N-l+1)):
        y+=1
    for i in range(y, mny):
        rs[i-1] = X//(i-(N-l+1))
    mny = min(y, mny)
for r in rs:
    print(r)

Measured memory_bytes: 118456
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int LINF=1e18;
const int MOD=1e9+7;
//
int main(){
    LLI n; cin>>n; n++;
    int k,i=0;
    while(n!=0){
        if(n<=9) k=n;
        n/=10;
        i++;
    }
    if(i==1) cout<<k-1<<endl;
    else {
        cout<<k-1+9*(i-1)<<endl;
    }
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (chunk) {
	var a = chunk.split(' ');
	var b = parseInt(a[0],10);
	var c = parseInt(a[1],10);
	var menseki = b*c;
	var nagasa = b*2+c*2;
    console.log(menseki+' '+nagasa);
});



Measured memory_bytes: 15280
import java.util.*;

import static java.lang.System.*;

//https://atcoder.jp/contests/abc090/tasks/arc091_b
//a%b>=Kの組み合わせ。bを固定して考えるとO(n)
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        solver(N, K);
    }

    public static void solver(int N, int K) {
        long ans = 0;

        for (int b = 1; b <= N; b++) {
            // 0<= a=pb+r <=N
            int p = N / b;
            int r = N % b;
            ans += p*Math.max(b-K, 0);
            ans += Math.max(r-K+1, 0);
        }
        // 例外：K=0の時は、a=0を含んでしまうため、カウントしない
        if(K==0) {
            ans -= N;
        }
        out.println(ans);
    }
}


Measured memory_bytes: 23764
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
int main(void){
    ll A,B;cin>>A>>B;
    ll gcd=GCD(A,B);
    ll ans=1;

    ll sq=sqrt(gcd);
    FOR(i,2,sq+1){
        bool f=false;
        while(gcd%i==0)gcd/=i,f=true;
        if(f)ans++;
    }
    if(gcd>1)ans++;
    cout<<ans<<"\n";
}

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

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    string s;
    cin >> s;
    int value = 700;
    rep(i,3){
        if(s[i]=='o') value += 100;
    }
    cout << value << endl;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

hs = Hash.new

n.times do |i|
  hs[s[i]] ||= []
  hs[s[i]] << i
end

res = 0
10.times do |i|
  if hs[i.to_s].nil?
    next
  end
  ix = hs[i.to_s][0]
  10.times do |j|
    if hs[j.to_s].nil?
      next
    end
    jx = hs[j.to_s].bsearch {|x| x > ix }
    if jx.nil?
      next
    end
    10.times do |k|
      if hs[k.to_s].nil?
        next
      end
      kx = hs[k.to_s].bsearch {|x| x > jx }
      if !kx.nil?
        res += 1
      end
    end
  end
end
puts res

Measured memory_bytes: 14844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;

int main(){
        int N,D,X,A[100];
        cin >> N >> D >> X;
        rep(i,N) cin>>A[i];
        int eat = 0;
        rep(i,N){
                int day = 0;
                int j = 0;
                while(true) {
                        day = j*A[i]+1;
                        if(day > D) break;
                        eat++;
                        j++;
                }
        }

        cout << eat + X << endl;

        return 0;

}


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

int main(){
    int a, b, c;
    int n = 0;
    cin>>a>>b>>c;
    for (int i = a;i <= b; i++)
    {
        if (c%i == 0)
        {
            n += 1;
        }   
    }
    cout<<n<<endl;
}


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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;

int N;

int main(){
	scanf("%d", &N);
	int mn = N;
	int ans = 0;
	for(int i=1; i<=N; i++){
		int a; scanf("%d", &a);
		if(mn>=a)	ans++;
		mn = min(mn, a);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,A;
  cin>>N>>A;
  
  int amari = N%500;
  if(amari<=A){
    cout <<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int d,m;
	scanf("%d %d",&m,&d);
	
	int i=22,j,c=0;
	for(i=22;i<=d;i++)
	{
		int d1=i%10;
		int d2=i/10;
		if(d1>=2 && d2>=2 && d1*d2<=m)
		{
			c++;
		}
	}
	printf("%d\n",c);
}

Measured memory_bytes: 128
x=int(input())
days=[]
for i in range(x):
    days.append(list(map(int,input().split())))
#print(days)
dp=[0]*3
dp=days[0]
for cur in range(1,x):
    m=[0]*3
    for i in range(3):
        for j in range(3):
            if i!=j:
                m[i]=max(m[i],days[cur][i]+dp[j])
    dp=m
print(max(dp))
            

Measured memory_bytes: 90344
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

int n;
bool flag=true;
string s;
int q[100010];
int ans[100010];
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='o')q[i]=0;
	else q[i]=1;
    }
    for(int t=0;t<4;t++){
        ans[0]=t/2;
	ans[1]=t%2;
    	for(int i=2;i<n;i++){
	    ans[i]=(q[i-1]+ans[i-2]+ans[i-1])%2;
	
	}
	if((ans[n-2]+ans[n-1]+ans[0]+q[n-1])%2==0 
	&&(ans[n-1]+ans[0]+ans[1]+q[0])%2==0){
	  for(int i=0;i<n;i++){
              cout<<(ans[i]?'W':'S');
          }
	  cout<<"\n";
	  flag=false;
	  t=5;
	}
    }
    if(flag)cout<<-1<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, c;
  cin >> n >> c;
  vector<vector<ll>> d(c, vector<ll>(c));
  vector<vector<ll>> mp(n, vector<ll>(n));
  for (int i = 0; i < c; i++) for (int j = 0; j < c; j++) cin >> d[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> mp[i][j];
      mp[i][j]--;
    }
  vector<vector<ll>> cost(3, vector<ll>(c));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < c; k++) {
        cost[(i + j) % 3][k] += d[mp[i][j]][k];
      }
  ll INF = 1000000000000000LL;
  ll ans = INF;
  for (int i = 0; i < c; i++)
    for (int j = 0; j < c; j++)
      for (int k = 0; k < c; k++) {
        if (i == j || j == k || k == i) continue;
        ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
      }
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0) break;

    n /= 4;
    int result = 0;
    for (int i = 0,buf = 0; i < n; ++i)
    {
      cin >> buf;
      result += buf;
    }
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
N = int(input())

def dfs(s): # 文字列sで始まる七五三数の個数
    if int(s) > N: # s>Nなら個数は当然0
        return(0)
    else:
        if s.count('7') > 0 and s.count('5') > 0 and s.count('3') > 0: # s自体が七五三数なら+1
            num = 1
        else:
            num = 0
        for c in '753': # sに7,5,3をそれぞれ後ろからくっつける
            num += dfs(s + c)
        return(num)

print(dfs('0')) # 0が先頭にくっつくが特に影響はない

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

int main() {
	int N; cin >> N;
	vector<pair<int,int> > A(N);
	for(int i=0;i<N;++i) cin >> A[i].first,A[i].second=i;
	sort(A.begin(),A.end());
	int cnt=0;
	for(int i=0;i<N;++i)
		if((A[i].second+i)&1) ++cnt;
	cout << cnt/2 << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#define rad(i) (i/180)*M_PI

typedef struct {
	double x;
	double y;
}N;

int Koch(int n, N p1, N p2) {
	double d;
	N s, u, t;

	d = p2.x - p1.x;

	if (n == 0) {
    return 0;
  }
	s.x = (2.0*p1.x + p2.x) / 3.0;
	s.y = (2.0*p1.y + p2.y) / 3.0;
	t.x = (p1.x + 2.0* p2.x) / 3.0;
	t.y = (p1.y + 2.0* p2.y) / 3.0;
	u.x = (t.x - s.x)*cos(M_PI / 3.0) - (t.y - s.y)*sin(M_PI / 3.0) + s.x;
	u.y = (t.x - s.x)*sin(M_PI / 3.0) + (t.y - s.y)*cos(M_PI / 3.0) + s.y;

	Koch(n-1, p1, s);
	printf("%f %f\n", s.x, s.y);

	Koch(n - 1, s, u);
	printf("%f %f\n", u.x, u.y);

	Koch(n - 1, u, t);
	printf("%f %f\n", t.x, t.y);
  
	Koch(n - 1, t, p2);

  return 0;
}

int main() {
	int n;
	N p1, p2;

	p1.x = p1.y = p2.y = 0.0;
	p2.x = 100.0;

	scanf("%d", &n);
	printf("%f %f\n", p1.x, p1.y);

	Koch(n,p1,p2);

	printf("%f %f\n", p2.x, p2.y);

	return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    map<string,int>maps;
    maps["AC"] = 0;
    maps["WA"] = 0;
    maps["TLE"] = 0;
    maps["RE"] = 0;    
    f(i,0,n){
        string s;
        cin >> s;
        maps[s]++;
    }
    cout << "AC x " << maps["AC"] << "\n";
    cout << "WA x " << maps["WA"] << "\n";
    cout << "TLE x " << maps["TLE"] << "\n";
    cout << "RE x " << maps["RE"] << "\n";
    return 0;
}
 

Measured memory_bytes: 3664
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll ans=0,ans1=0,ans2=0;
    for(int i=0;i<s.length()-1;i++)
    {
        if(s[i]=='R'&&s[i+1]=='R')
        ans=2;
    }
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
    ans1=3;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        ans2=1;
    }
    cout<<max({ans,ans2,ans1})<<endl;
    return 0;
}


Measured memory_bytes: 3644
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
    var a=[];
    var b=[];
    
    let n,m,l;
    [n,m,l]=lines.shift().trim().split(' ').map(Number);
    //console.log("reader n: " + n +", m: "+m+", l: "+l);

    for (var i=0; i<n; i++){
	a.push(lines.shift().trim().split(' ').map(Number));
    }
    //dump(a);
    for (var i=0; i<m; i++){
	b.push(lines.shift().trim().split(' ').map(Number));
    }
    //dump(a);
    
    var c = aux(a,b);

    dump(c);
});

function aux(a,b)
{
    var n=a.length;
    var m=a[0].length;
    var l=b[0].length;
    
    var x=[];
    for (var k=0; k<l; k++){
	x.push(0)
    }
    var c=[];
    for (var i=0; i<n; i++){
	c.push(x.concat())
    }

    var s;
    for (var i=0; i<n; i++) {
	for (var k=0; k<l; k++) {
	    s=0;
	    for (var j=0; j<m; j++) {
		s += a[i][j]*b[j][k];
	    }
	    c[i][k] = s
	    //console.log(i,k,s);
	}
    }

    //dump(c)
    return(c);
}

function dump(a)
{
    var n=a.length
    //console.log("dump n: "+ n+", m: "+a[0].length)
    for (var i=0;i<n; i++){
	console.log(a[i].map(x=>x.toString()).join(' '))
    }
 }


Measured memory_bytes: 20352
/*
「God Is In His Heaven,
		All's Right With The World.」
*/
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(a)-1; i>=(b); i--)
#define each(i, q) for(auto i : q)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define lowbit(x) x&(-x)
#define all(x) x.begin(),x.end()
#define ffs __builtin_ffs //idxOf(1<-) 
#define clz __builtin_clz //numOf(->0) 
#define ctz __builtin_ctz //numOf(0<-)
#define popcount __builtin_popcount //numOf1
#define parity __builtin_parity //(numOf1)%2
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
template <typename T> inline void read(T& x) {
	int f = 0, c = getchar(); x = 0;
	while (!isdigit(c)) f |= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
	if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T& x, Args& ... args) {
	read(x); read(args...);
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + 48);
}
template <typename T> void writes(T x) { write(x); putchar(' '); }
template <typename T> void writeln(T x) { write(x); puts(""); }
template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }
const int maxn = (int)3e5 + 10;
const ll inf = (ll)1e18;
const int mod = (int)1e9 + 7;
/*
	——ASUKA STRIKES!
*/
int n, a[maxn];
bool check() {
	rep(i, 1, n) {
		if (a[i] <= a[i - 1]) return false;
	}
	return true;
}
int main() {
	read(n);
	rep(i, 0, n) {
		read(a[i]);
	}
	if (check())  return puts("YES"), 0;
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			swap(a[i], a[j]);
			if (check()) return puts("YES"), 0;
			swap(a[i], a[j]);
		}
	}
	puts("NO");
}

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

int main()
{
    int n, r, t, a, b;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> r >> t;

        a = t / 30 * 5 + r / 100;
        b = ( t / 30 + 1 ) * 5 + r / 100;

        if( t % 30 == 0 && r % 100 == 0 )
            cout << a << endl;
        else if( r % 100 == 0 )
            cout << a << " " << b << endl;
        else if( t % 30 == 0 )
            cout << a << " " << a + 1 << endl;
        else
            cout << a << " " << a + 1 << " " << b << " " << b + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int lA,ans;char a[25];bool fl=1;
int main()
{
	scanf("%s",a+1);lA=strlen(a+1);ans=9*(lA-1)+(a[1]&15)-1;
	for(int i=2;i<=lA;++i) if(a[i]!='9') {fl=0;break;}printf("%d\n",ans+fl);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cstdlib>
#include <iomanip>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <iterator>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stack>
#include <random>

using namespace std;

#define vi vector<int> 
#define vvi vector<vi>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll, ll>
#define vll vector<ll>
#define io ios::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(a) int((a).size()) 
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define loop(i,b) for (int i = 0; i < b; ++i)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define INF numeric_limits<int>::max()
#define LLINF numeric_limits<ll>::max()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define F first
#define S second
#define MOD 1000000007
#define cflout(x) cout << fixed << setprecision(8) << x << endl
#define setzero(x) memset(x, 0, sizeof(x))

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

random_device _random_device;
default_random_engine _generator(_random_device());
uniform_int_distribution<long long unsigned> _distribution(0, 0xFFFFFFFFFFFFFFFF);

inline long long unsigned get_random_number() {
    return _distribution(_generator);
}

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; }

inline ll nxt() {
	ll x;
	cin >> x;
	return x;
}

namespace aux {	
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) {
		v.emplace_back(x);
    }
    return v;
}
}

int n, m, r;
ll dist[205][205];

vi cities;

ll ans = 0;

void floyd() {
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (i != j && dist[i][j] == 0) dist[i][j] = dist[j][i] = LLINF;
		}
	}

	for (int k = 1; k <= n; ++k) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				if (dist[i][k] != LLINF && dist[k][j] != LLINF) uin(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
}

int main() {
	io;
	cin >> n >> m >> r;
	loop(i, r) {
		int x = nxt();
		cities.pb(x);
	}
	loop(i, m) {
		int a = nxt(), b = nxt(), c = nxt();
		dist[a][b] = c;
		dist[b][a] = c;
	}

	floyd();
	sort(all(cities));
	for (int i = 0; i < cities.size()-1; ++i) {
		ans += dist[cities[i]][cities[i+1]];
	}
	while (next_permutation(all(cities))) {
		ll curr = 0;
		for (int i = 0; i < cities.size()-1; ++i) {
			curr += dist[cities[i]][cities[i+1]];
		}
		uin(ans, curr);
	}

	cout << ans << endl;



	return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    int cnt=0;
    for(int c=1;c<n;c++){
        int tmp=n-c;
        for(int a=1;a*a<=tmp;a++){
            if(tmp%a==0){
                cnt+=2;
            }
            if(tmp==a*a){
                cnt--;
            }
        }
    }
    cout<<cnt<<endl;


    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> inputs;
  for(int i=0; i<cnt; i++) {
    int y;
    cin >> y;
    inputs.push_back(y);
  }

  int minv = inputs[0];
  int maxdiff = -1000000000;
  for(int i=1; i<inputs.size(); i++) {
    maxdiff = max(maxdiff, inputs[i] - minv);
    minv = min(minv, inputs[i]);
  }

  cout << maxdiff << endl;
  return 0;
}

Measured memory_bytes: 3896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n,x,t; cin>>n>>x>>t;
    ll ans=(n+x-1)/x;
    cout<<t*ans<<endl;
}









































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

typedef long long ll;
#define int ll

#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

// -----------------------
namespace SegmentTrees{
    template<typename T>
    class RMQ{
    private:
        int Pow2Fit(int _n){
            int d = 1;
            while((d << 1) <= _n) d <<= 1;
            return d;
        }

    public:
        vector<T> dat;
        int n, size;

        RMQ(int _n){
            n = Pow2Fit(_n) << 1;
            size = 2 * n - 1;
            dat = vector<T>(size, 0);
        }

        // node v := a (0-indexed)
        void set(int v, T a){

            // leaf
            v += n - 1;
            dat[v]=a;

            // update toward root
            while(v > 0){
                int parent = v = (v - 1) / 2;
                int chl = parent * 2 + 1, chr = parent * 2 + 2;
                dat[parent] = max(dat[chl], dat[chr]);
            }
        }

        T get(int v){ // v (0-indexed)
            return dat[v + n - 1];
        }

        T query(int a, int b){ // [a,b)
            return query(0, a, b, 0, n);
        }

    private:
        T query(int v, int a, int b, int l, int r){ // [a,b)
            if(r <= a || b <= l) return 0; // out range
            if(a <= l && r <= b) return dat[v]; // covered
 
            T vl = query(v * 2 + 1, a, b, l, (l + r) / 2),
              vr = query(v * 2 + 2, a, b, (l + r) / 2, r);

            return max(vl, vr);
        }
    };
}

using namespace SegmentTrees;
// -----------------------

signed main(){
    int n; cin >> n;
    RMQ<int> rmq(n);

    rep(i, n){
        int x; cin >> x;
        rmq.set(x - 1, rmq.query(0, x) + x);
    }

    cout << n * (n + 1) / 2 - rmq.query(0, n) << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    int now = abs(n);
    string s = "";
    for(int i = 30; i >= 0; i--){
        if(now >= (1LL << i)){
            now -= (1LL << i);
            s += "1";
        }else{
            if(s != "") s += "0";
        }
    }
    reverse(s.begin(), s.end());
    if(n > 0){
        for(int i = 0; i <= s.size(); i++){
            if(s[i] == '2'){
                s[i] = '0';
                if(i + 1 < s.size()) s[i + 1]++;
                else s = s + "1";
            }
            if(i % 2 && s[i] == '1'){
                if(i + 1 < s.size()) s[i + 1]++;
                else s = s + "1";
            }
        }
    }else if(n < 0){
        for(int i = 0; i <= s.size(); i++){
            if(s[i] == '2'){
                s[i] = '0';
                if(i + 1 < s.size()) s[i + 1]++;
                else s = s + "1";
            }
            if(i % 2 == 0 && s[i] == '1'){
                if(i + 1 < s.size()) s[i + 1]++;
                else s = s + "1";
            }
        }
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 256