akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner; public class Main { private static Scanner sc=new Scanner(System.in); public static void main(String[] args){ int n=sc.nextInt(); int[] a=new int[n]; int notprime=0; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); for(int j=2;j<=Math.sqrt(a[i]);j++){ if(a[i]%j==0){ notprime++; break; } } } System.out.println(n-notprime); } } 


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



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<long long> A(N),B(N),C(N),D(M),E(M),F(M);
	
	vector<long long> X,Y;
	X.push_back(Inf);
	X.push_back(-Inf);
	Y.push_back(Inf);
	Y.push_back(-Inf);
	
	for(int i=0;i<N;i++){
		cin>>A[i]>>B[i]>>C[i];
		Y.push_back(A[i]);
		Y.push_back(B[i]);
		X.push_back(C[i]);
	}
	for(int i=0;i<M;i++){
		cin>>D[i]>>E[i]>>F[i];
		Y.push_back(D[i]);
		X.push_back(E[i]);
		X.push_back(F[i]);
	}
	
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	int H = X.size()-1;
	int W = Y.size()-1;
	
	vector<vector<vector<pair<int,int>>>> edge(H,vector<vector<pair<int,int>>> (W,vector<pair<int,int>>()));
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			for(int d=0;d<4;d++){
				int y = i;
				int x = j;
				if(d==0)y++;
				if(d==1)y--;
				if(d==2)x++;
				if(d==3)x--;
				if(y<0||y>=H||x<0||x>=W)continue;
				edge[i][j].emplace_back(y,x);
			}
		}
	}
	
	for(int i=0;i<N;i++){
		int t = distance(X.begin(),lower_bound(X.begin(),X.end(),C[i]));
		t--;
		for(int j=0;j<W;j++){
			if(Y[j]>=B[i])break;
			if(Y[j]<A[i])continue;
			
			for(int k=0;k<edge[t][j].size();k++){
				if(edge[t][j][k]==make_pair(t+1,j)){
					edge[t][j].erase(edge[t][j].begin()+k);
					break;
				}
			}
		}
		for(int j=0;j<W;j++){
			if(Y[j]>=B[i])break;
			if(Y[j]<A[i])continue;
			
			for(int k=0;k<edge[t+1][j].size();k++){
				if(edge[t+1][j][k]==make_pair(t,j)){
					edge[t+1][j].erase(edge[t+1][j].begin()+k);
					break;
				}
			}
		}
	}
	
	
	for(int i=0;i<M;i++){
		int t = distance(Y.begin(),lower_bound(Y.begin(),Y.end(),D[i]));
		t--;
		for(int j=0;j<H;j++){
			if(X[j]>=F[i])break;
			if(X[j]<E[i])continue;
			
			for(int k=0;k<edge[j][t].size();k++){
				if(edge[j][t][k]==make_pair(j,t+1)){
					edge[j][t].erase(edge[j][t].begin()+k);
					break;
				}
			}
		}
		for(int j=0;j<H;j++){
			if(X[j]>=F[i])break;
			if(X[j]<E[i])continue;
			
			for(int k=0;k<edge[j][t+1].size();k++){
				if(edge[j][t+1][k]==make_pair(j,t)){
					edge[j][t+1].erase(edge[j][t+1].begin()+k);
					break;
				}
			}
		}
	}
	
	vector<vector<bool>> ok(H,vector<bool>(W,false));
	queue<pair<int,int>> Q;
	int tx = distance(X.begin(),upper_bound(X.begin(),X.end(),0));
	int ty = distance(Y.begin(),upper_bound(Y.begin(),Y.end(),0));
	tx--;ty--;
	Q.emplace(tx,ty);
	ok[tx][ty] = true;
	
	while(Q.size()!=0){
		tx = Q.front().first;
		ty = Q.front().second;
		Q.pop();
		for(int i=0;i<edge[tx][ty].size();i++){
			int nx = edge[tx][ty][i].first;
			int ny = edge[tx][ty][i].second;
			if(ok[nx][ny])continue;
			ok[nx][ny]=true;
			Q.emplace(nx,ny);
		}
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(i==0||j==0||i==H-1||j==W-1){
				if(ok[i][j]){
					cout<<"INF"<<endl;
					return 0;
				}
			}
		}
	}
	
	long long ans = 0;
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(ok[i][j]){
				ans += (X[i+1]-X[i])*(Y[j+1]-Y[j]);
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 638296
#include<bits/stdc++.h>
#define mod 1000000000
#define ll long long
#define _USE_MATH_DEFINES
using namespace std;
int main()
{
 int s,w;
 cin>>s>>w;
 if(w>=s)
 {
    cout<<"unsafe";
 }
 else
 {
    cout<<"safe";
 }
}


Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll ans = 0;
  ll a, b;
  for(ll i=1;i*i<=N;++i) {
    if(N%i==0) {
      a = N/i;
      b = i;
      if(a-1>b) ans += a-1;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define strcin(s) string (s); cin >> (s);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
    void YN (bool b){
        if(b){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin2(n,m);
    incin2(x,y);
    intv X(n),Y(m);
    input(n,X);
    input(m,Y);
    sort(all(X));
    sort(all(Y));

    if(X[n-1]<Y[0] && (x < Y[0] && Y[0] <= y)){
        cout<<"No ";
    }
    cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll k; cin >> k;
	constexpr ll MX = 3234566667;
	vector<ll> v;
	auto dfs = [&](auto&& f, ll cur)->void {
		v.emplace_back(cur);
		ll t = cur % 10;
		if (t > 0) {
			ll nxt = cur * 10 + t - 1;
			if (nxt <= MX) {
				f(f, nxt);
			}
		}
		{
			ll nxt = cur * 10 + t;
			if (nxt <= MX) {
				f(f, nxt);
			}
		}
		if(t < 9) {
			ll nxt = cur * 10 + t + 1;
			if (nxt <= MX) {
				f(f, nxt);
			}
		}
	};
	for (int i = 1; i <= 9; i++) dfs(dfs, i);
	sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
	cout << v[k - 1] << endl;
	return 0;
}


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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define fi first
#define se second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;  
const int mod = inf + 7;

const int N = 205000;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);
double dp[3010][3010];

int main()
{
  run_forrest_run;
  int n;
  cin >> n;
  double p[n+1];
  for (int i = 1; i <= n; i++)
    cin >> p[i];

  dp[1][1] = p[1];
  dp[1][0] = 1 - p[1];
  for (int i = 2; i <= n; i++)
  {
    for (int j = 0; j <= i; j++)
    {
      if (j == 0)
        dp[i][j] = dp[i-1][j] * (1 - p[i]);
      else if (i == j)
        dp[i][j] = dp[i-1][j-1] * (p[i]);
      else dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * (p[i]);
    }
  }
  double ans = 0;
  for (int i = (n+1)/2; i <= n; i++)
    ans+=dp[n][i];
  cout << setprecision(10) << fixed  << ans;
}

Measured memory_bytes: 75008
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int h, a;
	cin >> h >> a;
	int ans ;
	if (h%a == 0)ans = h / a;
	else ans = h / a + 1;
	print(ans);
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimization ("O3,unroll-loops")
#pragma GCC target ("avx,avx2,fma")
using namespace std;

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define _ << ": " <<
#define watch1(var1) (cerr << #var1 _ var1 << ' ')
#define watch2(var1, var2) cerr << #var1 _ var1 << ", " << #var2 _ var2 << '\n';
#define watch3(var1, var2, var3) cerr << #var1 _ var1 << ", " << #var2 _ var2 << ", " << #var3 _ var3 << '\n';
#define wloop(size, arr) cerr << #arr << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size];

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int64_t n; read(n);
    int64_t sum = 0;
    for (int i = 1; i <= n; i++) sum += i * ((n/i + (n/i) * (n/i)) / 2);
    cout << sum;
    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],p,vis[3];
char s[1000005];

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<n;i++) a[i]=abs(s[i]-s[i+1]),vis[a[i]]=1;
	if(!vis[1]) for(int i=1;i<n;i++) a[i]/=2;
	else for(int i=1;i<n;i++) a[i]%=2;
	int S=n-2;
	for(int i=0;i<n-1;i++) if((S&i)==i) p+=a[i+1];
	int op=p%2;
	if(!vis[1]) if(op) op=2;
	printf("%d\n",op);

	return 0;
}

Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            var t = new long[n];

            for(int i = 0; i < n; i++) {
                t[i] = long.Parse(Console.ReadLine());
            }

            decimal t0 = t[0];

            for(int i = 1; i < n; i++) {
                t0 = Eucrid(t0, t[i]);
            }

            Console.WriteLine(t0);

            Console.Out.Flush();
        }

        public static decimal Eucrid(decimal n1, decimal n2)
        {
            var max = Math.Max(n1, n2);
            var min = Math.Min(n1, n2);

            while (true) {
                var a = max % min;
                if(a == 0) {
                    break;
                }

                max = min;
                min = a;
            }

            return (n1 / min) * n2;
        }
    }
}


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

void extgcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return;
  }
  extgcd(b, a%b, y, x);
  y -= a/b*x;
  return; 
}

ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a,m,x,y);
  return (m + x % m) % m;
}

int main(){
  ll n, mod;
  cin >> n >> mod;
  string s;
  cin >> s;
  ll ans = 0;
  if(mod == 2) {
    rep(i,n) {
      if((s[i]-'0') % 2 == 0) ans += i+1;
    }
  } else if(mod == 5) {
    rep(i,n) {
      if(s[i] == '5' || s[i] == '0') ans += i+1;
    }
  } else {
    map<ll,ll> m;
    ll v = 0, d = 1;
    m[0]++;
    rep(i,n) {
      v = (v*10 + (s[i]-'0')) % mod;
      (d *= 10) %= mod;
      ll c = (v*mod_inverse(d,mod)) % mod;
      ans += m[c];
      m[c]++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1028
#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    if (n % 2 == 0)
    {
        printf("%d",n/2);
    }else if (n % 2 == 1)
    {
        printf("%d",n/2 + 1);

    }
    return 0;
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
double n,k;
 
main()
{
        cin>>n>>k;
        int a[(int)n];
        rep(i,n)cin>>a[i];
        cout<<1+ceil((n-k)/(k-1))<<endl;
}

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

using namespace std;

int main(){
  string str;
  string s;
  int cnt=0;

  cin >> s;
  while(1)
    {
      cin >> str;
      if(str == "END_OF_TEXT") break;

      for(int i=0;i < str.size();i++)
	{
	  if(str[i] >= 'A' && str[i] <= 'Z')
	    {
	      str[i] = str[i]-'A'+'a';
	    }
	}

      if(str == s) cnt++;
    }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001] = {};
ll s[100001] = {};
map<ll, ll> mp;
int main() {
	ll n, m; cin >> n >> m;
	repe(i, 1, n) {
		cin >> a[i];
		s[i] += s[i - 1] + a[i];
		mp[s[i] % m]++;
	}

	ll ans = 0;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->first == 0) {
			ans += it->second;
		}

		ll v = it->second;
		ans += v * (v - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

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

  double ans = 0;
  int cur = N;
  int i = 0;
  while (cur > 0) {
    int border = ceil(K / pow(2, i));
    if (cur >= border) {
      ans += (cur - border + 1) / (double)N * (1 / pow(2, i));
      cur = border - 1;
    }
    i++;
  }

  cout << setprecision(20) << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

struct edge
{
    int to,cap,rev;
};

const int MAX_N = 1002;

int d[102][102];
vector<edge> G[2*MAX_N];
int level[2*MAX_N];
int iter[2*MAX_N];
int n,m,L;

void warshall_floyd()
{
    rep(i,n){
        rep(j,n){
            rep(k,n){
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
}

void add_edge(int from,int to,int cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

void bfs(int s)
{
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front();
		que.pop();
		rep(i,G[v].size()){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f)
{
	if(v==t){
		return f;
	}
	for(int &i = iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t)
{
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0){
			return flow;
		}
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,INF)) > 0){
			flow += f;
		}
	}
}

int main()
{
    while(1){
        cin >> n >> m >> L;
        if(n == 0 && m == 0 && L == 0){
            break;
        }
        rep(i,n){
            rep(j,n){
                d[i][j] = INF;
            }
        }
        rep(i,n){
            d[i][i] = 0;
        }
        rep(i,m){
            int x,y,z;
            cin >> x >> y >> z;
            d[x][y] = z;
            d[y][x] = z;
        }
        vector<int> p(L),t(L);
        rep(i,L){
            cin >> p[i] >> t[i];
        }
        warshall_floyd();
        rep(i,2*L+2){
            G[i].clear();
        }
        rep(i,L){
            rep(j,L){
                if(i != j){
                    if(t[i] + d[p[i]][p[j]] <= t[j]){
                        add_edge(i+1,L+j+1,INF);
                    }
                }
            }
        }
        rep(i,L){
            add_edge(0,i+1,1);
            add_edge(L+i+1,2*L+1,1);
        }
        cout << L - max_flow(0,2*L+1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 27984
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int Digit_Count(ll N){
  int ans = 0;
  while (N > 0){
    ans++; N /= 10;
  }
  return ans;
}

int main(){
  ll N; cin >> N;
  int ans = 1e5;
  for (ll i = 1; i * i <= N; i++){
    if (N % i == 0){
      int now = max(Digit_Count(i), Digit_Count(N / i));
      ans = min(ans, now);
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
	string S;
	cin>>S;
	int res=0;
	rep(i,S.size()/2){
		if(S[i]!=S[S.size()-1-i])res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
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 main() {
    string s;
    cin >> s;
    int ssize = s.size()-2;
    string ns;
    string n = to_string(ssize);
    ns = s[0]+n+s[s.size()-1];
    cout << ns << "\n";
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
using ll = long long;
int main (void){
    ll n;
    cin >> n;
    ll num[n];
    for(ll i=0;i<n;i++)num[i]=1;
    ll ans=1;
    ll i,j,k;
    for(i=2;i <= n;i++){
        ll tmp=i;
        for(j=2;i>=j;j++){
            for(k=0;tmp%j==0;k++){
                tmp/=j;
            }
            num[j-1]+=k;
        }
    }

    for(i=0;i<n;i++){
        ans*=num[i];
        ans%=1000000007;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int tmp;
int dp[1000][5001];

struct node {
  //  struct node* parent;                                                                           
  struct node* child;
  struct node* next;
  //  int depth;                                                                                     
  int x;
  int y;
};

long sum(struct node* p, int x, int depth){
  long ans = 100000000, ans_tmp;
  if(p == NULL){
    ans = 0;
  }
  else{
    if(x >= p->x){
      if(dp[depth][x - p->x] == -1) dp[depth][x - p->x] = sum(p->next, x - p->x, depth + 1);
      ans = dp[depth][x - p->x] + p->y;
    }
    if(x >= p->y){
      if(dp[depth][x - p->y] == -1) dp[depth][x - p->y] = sum(p->next, x - p->y, depth + 1);
      ans_tmp = dp[depth][x - p->y] + p->x;
      if(ans_tmp < ans) ans = ans_tmp;
    }
  }
  return ans;
}

int main(void) {
  struct node* p[1001];
  struct node* p_tmp;

  scanf("%d",&n);
  for(int i=0;i<=n;i++) p[i] = new struct node;
  //  p[1]->parent = NULL;                                                                           
  p[1]->child = NULL;
  p[1]->next = NULL;
  for(int i=2;i<=n;i++){
    scanf("%d",&tmp);
    //    p[i]->parent = p[tmp];                                                                     
    if(p[tmp]->child == NULL)  p[tmp]->child = p[i];
    else{
      p_tmp = p[tmp]->child;
      while(p_tmp->next != NULL) p_tmp = p_tmp->next;
      p_tmp->next = p[i];
    }
    p[i]->next = NULL;
    p[i]->child = NULL;
  }

  for(int i=1;i<=n;i++){
    scanf("%d",&p[i]->x);
  }
  /*                                                                                                 
  printf("\n");                                                                                      
  for(int i=1;i<=n;i++){                                                                             
    printf("%d %d %d %d %d\n", i, p[i], p[i]->x, p[i]->child, p[i]->next);                           
  }                                                                                                  
  printf("\n");                                                                                      
  */

  for(int i=n;i>0;i--){
    for(int j=0;j<n;j++) for(int k=p[i]->x;k>=0;k--) dp[j][k] = -1;
    p[i]->y = sum(p[i]->child, p[i]->x, 0);
    if(p[i]->y >= 100000000){
      printf("IMPOSSIBLE\n");
      return 0;
    }
  }

  printf("POSSIBLE\n");
  return 0;

}


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

#define       sf                 scanf
#define       pf                 printf
#define       pb                 push_back
#define       sz                 200005
#define       inf                0x3f3f3f3f
#define       MOD                1000000007
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef       long long int      ll;

int main()
{
    // READ
    optimize

    ll a, b, c, d;

    cin >> a >> b >> c >> d;

    cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;


    return 0;
}


Measured memory_bytes: 3648
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.IntMap as IM
import Data.List

solve n vs = n - (getUsable $ map feat $ divide vs)

divide [] = [[], []]
divide [e] = [[e], []]
divide (e:o:xs) = [e:es, o:os]
  where [es, os] = divide xs

feat xs = case sortOn (negate . snd) $ IM.toList $ count xs of
  [(k, n)]             -> (k, n, 0)
  (k, n) : (_, n') : _ -> (k, n, n')

count = foldr (flip (IM.insertWith (+)) 1) IM.empty

getUsable [(kA, fA, sA), (kB, fB, sB)]
  | kA /= kB  = fA + fB
  | otherwise = max (fA + sB) (fB + sA)

bsReadInts = map (fst . fromJust . B.readInt) . B.words

main = do
  n:vs <- bsReadInts <$> B.getContents
  putStrLn $ show $ solve n vs


Measured memory_bytes: 21756
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int a,b;
  int i=0;
  long long sum=0;
  double ave = 0;
  while(scanf("%d,%d", &a, &b)==2) {
    sum += a*b;
    ave += b;
    i++;
  }
  cout << sum << endl;
  cout << (int)(ave/i+0.5) << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  while (true) {
    ll p = (ll)pow(n, 0.5);
    if (n == p*p) {
      cout << n << endl;
      break;
    }
    n--;
  }
}

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

const int maxn = 2003;

int n, z, w, res;
int a[maxn];

signed main () { 
    scanf("%d %d %d", &n, &z, &w);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    res = abs(a[n] - w);
    if (n >= 2)
        res = max(res, abs(a[n - 1] - a[n]));
    printf("%d\n", res);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dh[2] = {1, 0};
const int dw[2] = {0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h,w;
  cin>>h>>w;
  vector<string> s(h);
  REP(i,h)cin>>s[i];


  ll dist[h][w];
  REP(i,h)REP(j,w)dist[i][j]=LLINF;
  dist[0][0]=0;
  if(s[0][0]=='#')
    dist[0][0]++;

  deque<pair<pll,ll>> que;
  que.push_back(make_pair(pll(0,0),0));
  while(!que.empty()){
    pair<pll,ll> p=que.front();
    que.pop_front();

    pll point = p.FI;
    ll cnt = p.SE;

    if(cnt>dist[point.SE][point.FI])
      continue;

    REP(i,2){
      if(point.FI+dw[i]>=w || point.SE+dh[i]>=h)
        continue;

      pll np = pll(point.FI+dw[i], point.SE+dh[i]);
      pair<pll,ll> next=make_pair(np, dist[point.SE][point.FI]);
      if(s[np.SE][np.FI]=='#' && s[point.SE][point.FI]=='.')
        next.SE++;

      if(next.SE>=dist[np.SE][np.FI])
        continue;
      dist[np.SE][np.FI] = min(dist[np.SE][np.FI], next.SE);
      que.push_back(next);
    }


  }

  cout<<dist[h-1][w-1]<<endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef pair<int, int> pii;

int d[3000][3000]; // ???i, j????????¢
int minCost[3000]; // ???i????????§???????????°??¢???????????§??????????????¢
vector<pii> g[3000]; // to, cost
int n, m, k;

int main() {
	cin >> n >> m >> k;
	
	fill(d[0], d[n], INF);
	fill(minCost, minCost + n, INF);
	
	REP(i, m) {
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		a--; b--;
		g[a].push_back(pii(b, l));
		g[b].push_back(pii(a, l));
		d[a][b] = d[b][a] = l;
	}
	
	priority_queue<pii, vector<pii>, greater<pii> > pq; // cost, pos
	REP(i, k) {
		int pos;
		scanf("%d", &pos);
		pq.push(pii(0, pos - 1));
	}
	
	while (!pq.empty()) {
		pii now = pq.top(); pq.pop();
		int ncost = now.first;
		int npos = now.second;
		
		if (minCost[npos] <= ncost) continue;
		minCost[npos] = ncost;
		
		REP(j, g[npos].size()) {
			int to = g[npos][j].first;
			int cost = ncost + g[npos][j].second;
			if (minCost[to] > cost) {
				pq.push(pii(cost, to));
			}
		}
	}
	
	int ans = 0;
	REP(i, n) FOR(j, i + 1, n) {
		if (d[i][j] == INF) continue;
		ans = max(ans, (minCost[i] + minCost[j] + d[i][j] + 1) / 2);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 41860
//

fun main() {
    abc168a()
}

fun abc168a() {
    val n = readLine()!!.toInt()
    val c = when(n % 10) {
        in listOf(0, 1, 6, 8) -> "pon"
        3 -> "bon"
        else -> "hon"
    }
    println(c)
}


Measured memory_bytes: 37972
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] cl = sc.next().toCharArray();
        String ans = "";
        for(char c : cl){
            if(c == '0'){
                ans += "0";
            }else if(c == '1'){
                ans += "1";
            }else{
                if(ans.length() != 0){
                    ans = ans.substring(0,ans.length()-1);
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
import sys

N, M = map(int, input().split())
if N==1 and M == 0:
  print('0')
  sys.exit()

d={}
ans = 0
for i in range(M):
  s, c = map(int, input().split())
  if s == 1 and c == 0 and N == 1:
    ans = -2
  elif s == 1 and c == 0:
    ans = -1
  elif s in d and c != d[s]:
    ans = -1
  else:
    d[s] = c
if ans == -1:
  print(ans)
elif ans == -2:
  print('0')
else:
  for i in range(N):
    if i+1 in d:
      print(d[i+1], end='')
    elif i+1 == 1:
      print('1', end='')
    else:
      print('0', end='')

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int k =scn.nextInt();
		long sum=0;
		for(int i=1;i<=k;i++){
			
			for(int j=1;j<=k;j++){
				int val = gcd(i,j);
				for(int m=1;m<=k;m++){
					int val2 = gcd(val,m);
					sum+=val2;
				}
			}
		}
		System.out.println(sum);

	}
	public static int gcd(int a ,int b){
		if(b==0){
			return a;
		}
		
		
		return gcd(b,a%b);
	}

}

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

using ll = long long;

int main(void){
  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for(ll i = 0; i < N; i++){
    cin >> A[i];
  }
  for(ll i = 0; i < N; i++){
    cin >> B[i];
  }

  {
  ll need = 0, have = 0;
  for(ll i = 0; i < N; i++){
    need += B[i];
    have  += A[i];
  }
  if(have < need){
    cout << -1 << endl;
    return 0;
  }
  }

  vector<ll> D(N);
  for(ll i = 0; i < N; i++){
    D[i] = A[i] - B[i];
  }

  ll shortage = 0;
  ll num = 0;
  for(ll i = 0; i < N; i++){
    ll diff = B[i] - A[i];
    if(diff > 0){
      shortage += diff;
      num++;
    }
    // shortage += max(0, B[i] - A[i]);
  }

  sort(D.begin(), D.end(), greater<ll>());

  ll suppliment = 0;
  ll idx = 0;
  while(suppliment < shortage){
    assert(D[idx] > 0);
    suppliment +=D[idx];
    idx++;
  }

  cout << idx +  num << endl;
}


Measured memory_bytes: 2560
n = int(input())
L = list(map(int, input().split()))

sL = sorted(L)
#print(sL)
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if sL[i] == sL[j]: continue
        for k in range(j+1, n):
            if (sL[i] == sL[k]) or (sL[j] == sL[k]): continue
            #print( sL[i], sL[j], sL[k] )
            if (sL[i] + sL[j]) > sL[k]:
                ans += 1
                #print(ans)

print(ans)

Measured memory_bytes: 9200
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u){
    if(u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

void postParse(int u){
    if(u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main(){
    int i, v, l, r, root;
    
    scanf("%d", &n);
    for(i=0; i<n; i++){
        T[i].p = NIL;
    }
    
    for(i=0; i<n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }
    
    for(i=0; i<n; i++) if(T[i].p == NIL) root = i;
    
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    
    return 0;
}


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

n10 = 1
n8 = 1
n9 = 1
beki = N
while beki>4:
    n10 = (n10*(10**5))%(10**9+7)
    beki -= 5  
n10 = (n10*(10**beki))%(10**9+7)
beki = N
while beki>4:
    n8 = (n8*(8**5))%(10**9+7)
    beki -= 5  
n8 = (n8*(8**beki))%(10**9+7)
beki = N
while beki>4:
    n9 = (n9*(9**5))%(10**9+7)
    beki -= 5  
n9 = (n9*(9**beki))%(10**9+7)

print((n10-2*n9+n8)%(10**9+7))

Measured memory_bytes: 9228
S = input()
N = len(S)
a = [0] * (N + 1)
for i in range(N):
    if S[i] == '<':
        a[i + 1] = a[i] + 1
for i in range(N - 1, -1, -1):
    if S[i] == '>' and a[i] <= a[i+1]:
        a[i] = a[i+1] + 1
print(sum(a))


Measured memory_bytes: 29052
// D - Chat in a Circle
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int in(){int x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	priority_queue<int> q;
	rep(i, N) q.push(in());
	int64_t ans = q.top(); q.pop();
	rep(c, N-2){
		int a = q.top(); q.pop();
		ans += a;
		if(++c >= N-2) continue;
		ans += a;
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 4324
io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
max=10**9
m=Math.sqrt max
aa=a.map do |x|
  mmm=0
  (1..m).each do |mm|
    if x%(2**mm)==0
      mmm=mm
    else
      break
    end
  end
  mmm
end
p aa.min


Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline


def main():
    N = int(input())

    ans = "Yes"
    W = [input()[:-1]]
    for _ in range(N-1):
        w = input()[:-1]
        p = W[len(W)-1]
        if w in W or w[:1]!=p[-1:]:
            ans = "No"
            break
        W.append(w)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int m;
  int wle[1000000],eri[1000000];
  string s;
  cin >> n >> s;
  wle[0] = 0;
  eri[0] = count(s.begin()+1,s.end(),'E');
  int ans = 99999999;
  //cout << count(s.begin(),s.begin()+1,'W') << endl;
  for(int i=0; i<n; i++){
    if(i==0){
      ans = min(ans,eri[0]);
    }else{
      if(s.at(i-1) == 'W'){
        wle[i] = wle[i-1]+1;
      }else{
        wle[i] = wle[i-1];
      }
      if(s.at(i) == 'E'){
        eri[i] = eri[i-1]-1;
      }else{
        eri[i] = eri[i-1];
      }
      ans = min(ans,wle[i]+eri[i]);
    }
    //cout << wle[i] << " " << eri[i] << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7556
import math
import cmath
def dot(a:complex,b:complex):
  return (a.conjugate()*b).real
def cross(a:complex,b:complex):
  return (a.conjugate()*b).imag
p=[]
try:
  while True:
    x,y=map(float,input().split(','))
    p.append(complex(x,y))
except EOFError:
  pass
S=0
for i in range(1,len(p)-1):
  S+=cross(p[i]-p[0],p[i+1]-p[0])
print(abs(S)/2)


Measured memory_bytes: 5692
#include<stdio.h>
#include<string.h>
#define MAX 1000000
int can[MAX+1];

int main(){
	int n,a,b,ans,i;
	while(scanf("%d %d %d",&n,&a,&b),n||a||b){
		memset(can,0,sizeof(can));
		can[0]=1;
		ans=0;
		for(i=0;i<=n;i++){
			if(can[i]){
				if(i+a<=n)can[i+a]=1;
				if(i+b<=n)can[i+b]=1;
			}
			else ans++;
		}
		printf("%d\n",ans);
	}
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 n, ans = 0; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];

    sort(all(a));
    ans += *--a.end(); a.pop_back();

    n -= 2;
    for(i32 i = 0; i < n; a.size()) {
        ans += *--a.end();
        ++i;
        if(i >= n) break;
        ans += *--a.end();
        ++i;
        a.pop_back();
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 4820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int cnt = 0;
		for(int i=a;i<=b;i++) {
			if((c % i) ==0) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}



Measured memory_bytes: 26292
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, u, v, w, color[100008];
vector<vector<P>> edge(100008);

int dfs(ll at, ll from){
	for(ll j = 0; j < edge[at].size(); j++){
		ll next = edge[at][j].first;
		if(next != from){
			color[next] = (edge[at][j].second%2 == 0)? color[at] : 1-color[at];
			dfs(next, at);
		}
	}
	return 0;
}

int main(){
	cin >> n;
	
	for(ll i = 1; i <= n-1; i++){
		cin >> u >> v >> w;
		edge[u].push_back(P(v, w));
		edge[v].push_back(P(u, w));
	}
	
	color[1] = 0;
	dfs(1, 0);
	for(ll i = 1; i <= n; i++){
		cout << color[i] << endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  ll a[200005];
  map<ll,ll> ma1,ma2;
  rep(i,n){
    cin>>a[i];
    ma1[a[i]+i]++;
    ma2[-a[i]+i]++;
  }
  ll ans=0;
  for(auto x:ma1){
    ans+=x.second*ma2[x.first];
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
#define pii pair< pair<ll,ll> , ll>
const int N = 305;

int n , m , q , l;
pair<int,int> cost[N][N];
vector< pair<int,int> > adj[N];

void dijk(int sc)
{
    for(int i=0; i<=n; i++)
    {
        cost[sc][i] = {1e9,-1e9};
    }
    cost[sc][sc] = {0,-l};
    priority_queue<pii , vector<pii> , greater<pii> > q;
    q.push({cost[sc][sc] , sc});

    while(q.size())
    {
        int node = q.top().s;
        pair<int,int> cst = q.top().f;
        q.pop();
        if (cst > cost[sc][node]) continue;

        for(auto ch : adj[node])
        {
            int needFuel = ch.s , time = cst.f , cur = -cst.s;
            if (cur >= needFuel)
            {
                pair<int,int> cstt = {time , -(cur-needFuel)};
                if (cstt < cost[sc][ch.f])
                {
                    cost[sc][ch.f] = cstt;
                    q.push({cstt , ch.f});
                }
            }
            else if (l >= needFuel)
            {
                pair<int,int> cstt = {time+1 , -(l-needFuel)};
                if (cstt < cost[sc][ch.f])
                {
                    cost[sc][ch.f] = cstt;
                    q.push({cstt , ch.f});
                }
            }
        }
    }
}

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

    cin >> n >> m >> l;
    for(int i=1; i<=m; i++)
    {
        int x,y,c;
        cin >> x >> y >> c;
        adj[x].push_back({y,c});
        adj[y].push_back({x,c});
    }

    for(int i=1; i<=n; i++)
    {
        dijk(i);
    }

    cin >> q;
    while(q--)
    {
        int s , t;
        cin >> s >> t;
        if (cost[s][t].f == 1e9) cout << "-1\n";
        else cout << cost[s][t].f << '\n';
    }

    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		main(void){
	int n;
	cin >> n;
	if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3596
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    h, w, k = nm()
    d = dict()
    for _ in range(k):
        r, c, v = nm()
        d[r * 10000 + c - 10001] = v
    prv = [[0]*4 for _ in range(w+1)]
    nxt = [[0]*4 for _ in range(w+1)]
    for i in range(h):
        for j in range(w):
            f = d.get(i * 10000 + j, 0)
            t = max(prv[j])
            for v in range(4):
                nxt[j][v] = max(nxt[j-1][v], t)
                if v:
                    nxt[j][v] = max(nxt[j][v], nxt[j-1][v-1] + f, t + f)
        prv, nxt = nxt, prv
    print(max(prv[w-1]))

    return

solve()


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

namespace ConsoleApplication27
{
    class Program
    {
        static void Main()
        {
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("{0}:{1}:{2}",a/3600,(a%3600)/60,a%3600%60);
        }
    }
}

Measured memory_bytes: 9184
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};

//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!


signed main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	rep(i, N+1) {
		rep(j, N+1) {
			int rg = R * i + G * j;
			if (rg > N) continue;
			int rest = N - rg;
			if (rest % B == 0) {
				ans++;
			}
		}
	}

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

Measured memory_bytes: 256