akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
vector<int> a[100020];
bool v[100020];
int d[100020], n, m;
bool ans;
void dfs(int x, int y) {
	d[x] = d[y] ^ 1;
	v[x] = true;
	for (int i: a[x]) {
		if (!v[i]) {
			dfs(i, x);
		} else {
			if (d[i] == d[x]) {
				ans = true;
			}
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	dfs(1, 0);
	if (ans) {
		printf("%lld\n", (long long)n * (n - 1) / 2 - m);
	} else {
		long long cnt[2] = {};
		for (int i = 1; i <= n; i++) {
			cnt[d[i]]++;
		}
		printf("%lld\n", cnt[0] * cnt[1] - m);
	}
}

Measured memory_bytes: 7040
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <map>
using namespace std;
const int MAXN = 2 * (int)1e5 + 5;

class DSU {
private:
  std::vector<int> p;
public:
  DSU(int n): p(n, - 1) {}

  int findRep(int x) {
    return p[x] < 0? x: p[x] = findRep(p[x]);
  }

  void unite(int x, int y) {
    int p1 = findRep(x), p2 = findRep(y);
    if (p1 == p2) return;
    if (-p[p1] < -p[p2]) std::swap(p1, p2);
    p[p1] += p[p2];
    p[p2] = p1;    
  }

  int getSize(int x) {
    return -p[findRep(x)];
  }

  bool isSame(int x, int y) {
    return findRep(x) == findRep(y);
  }
};

int main() {
  int n, k, l;
  cin >> n >> k >> l;
  DSU dsu1(n); DSU dsu2(n);
  for (int i = 0; i < k; ++i) {
    int p, q;
    cin >> p >> q;
    p--; q--;
    dsu1.unite(p, q);
  }

  for (int i = 0; i < l; ++i) {
    int r, s;
    cin >> r >> s;
    r--; s--;
    dsu2.unite(r, s);
  }

  map<pair<int, int>, int> m;
  for (int i = 0; i < n; ++i) {
    int x = dsu1.findRep(i), y = dsu2.findRep(i);
    m[pair<int, int>(x, y)]++;
  }

  for (int i = 0; i < n; ++i) {
    int x = dsu1.findRep(i), y = dsu2.findRep(i);
    int ans = m[pair<int, int>(x, y)];
    cout << ans << " ";
  }
  puts("");
  return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

ll digitsum(ll X){
    int x=0;
    while(X > 0){
        x += X % 10;
        X/=10;
    }

    return x;

}

int main(){
    ll N,A,B,min=1000000;
    cin >> N;

    for(ll i = 1;i < N;i++){
        A = digitsum(i);
        B = digitsum(N-i);
        if(min > A+B)
            min = A+B;
    }

    cout << min <<endl; 

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define ln '\n'
#define MAX 1000000009
#define MOD 1000000007
#define N 105
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pii;
typedef vector<int> vi;   
long double d; 
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    cin >> d;
    d = (long double)d / 3;
    cout << setprecision(32) << d*d*d; 

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[20];
	cin>>s;
	int c=0;
	int l=strlen(s);
	for(int i=0;i<l;i=i+2)
	{
		if(s[i]=='h'&&s[i+1]=='i')
		{
			c++;
		}
	}
	if(((l+1)/2)==(c))
	{
		cout<<"Yes"<<endl;
	}else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, num = map(int, input().split())

ans = [-1 for i in range(n)]

flag = True

for i in range(num):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        flag = False

if n != 1 and ans[0] == 0:
    flag = False

if flag:
    if ans[0] == -1 and n != 1:
        ans[0] = 1
    for i, x in enumerate(ans):
        if x == -1:
            ans[i] = 0
    print("".join(map(str, ans)))
else:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int cnt=100000000;
	for(int i=0;i<=s.size()-t.size();i++)
	{
		string m=s.substr(i,t.size());
	//	cout<<m<<endl;
		int ans=0;
		for(int j=0;j<t.size();j++)
			if(m[j]!=t[j])
				ans++;
		cnt=min(cnt,ans);
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
d={}
mina=min(a)
maxa=max(a)
for i in range(mina-1,maxa+2):
  d[i]=0
for i in a:
  d[i]+=1
ans=0
for i in range(mina,maxa+1):
  ans=max(ans,d[i-1]+d[i]+d[i+1])
print(ans)

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

def check8(n):
    cnt = 0
    for i in range(1,n+1):
        if n % i == 0:
            cnt += 1
    if cnt == 8:
        return True
    else:
        return False

cnt8 = 0
for i in range(1, N+1, 2):
    if check8(i):
        cnt8 += 1
print(cnt8)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}

int main()
{

	int n;
	cin >> n;

	vector<string> s(n);
	vector<int> count(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	sort(s.begin(), s.end());
	count[0] = 1;

	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1]) {
			count[i] = count[i - 1] + 1;
		}
		else {
			count[i] = 1;
		}
	}

	int maxi = 0;
	for (int i = 0; i < n; i++) {
		maxi = max(maxi, count[i]);
	}

	for (int i = 0; i < n; i++) {
		if (count[i] == maxi) {
			cout << s[i] << endl;
		}

	}
	


	return 0;



}



Measured memory_bytes: 15104
N, M = map(int, input().split())

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    a -= 1
    b -= 1
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)

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

#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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
int64_t factorial(int64_t n) {
  if (n == 1) {
    return 1;
  }
  int64_t ans = factorial(n-1);
  return ans*n;
}

int main() {
  int64_t n, t;
  cin >> n >> t;
  int64_t ans = 0;
  vector <int64_t> v(n);
  rep(i, n) cin >> v.at(i);
  rep(i, n-1) {
    if (v.at(i+1)-v.at(i) < t) {
      ans += v.at(i+1)-v.at(i);
    } else {
      ans += t;
    }
  }
  cout << ans + t << endl;
}

Measured memory_bytes: 1792
/* Print a Chessboard */
#include <stdio.h>

int main()
{
    int H, W, i, j;
    while(1){
        scanf("%d %d", &H, &W);
        if(H ==0 && W == 0){ break; }
        for(i=1; i <= H; i++){
            for(j=1; j <= W; j++){
                if(j%2 == 0 && i%2 == 0){
                    printf("#");
                }
                else if(j%2 == 0 && i%2 != 0){
                    printf(".");
                }
                else if(j%2 != 0 && i%2 == 0){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2036
#include <stdio.h>
int main(){
  int h,w;
  int bool=1;
  while(bool){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0){
      bool=0;
    }else{
      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){
            printf("#");
          }else{
            printf(".");
          }
        }
        putchar('\n');
      }
      putchar('\n');
    }
  }
}



Measured memory_bytes: 2044
s = input()
n = len(s)
li = []
for i in range(0, n-1):
    if s[i] == "R" and s[i+1] == "L":
        li.append(i)

ans = [0] * n
j = 0
for i in range(n):
    if i > li[j] and s[i] == "R":
        j += 1
    if (li[j] - i) % 2 == 0:
        ans[li[j]] += 1
    else:
        ans[li[j] + 1] += 1 
print(" ".join(map(str, ans)))


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
#define vv vector


ll N;
ll A[202020],B[202020];
ll i, j, k;
ll mk[202020],mka[202020],mkb[202020];

ll anss[202020];



int main()
{
    scanf("%lld", &N);
    

    rep(i,0,N){
        scanf("%lld", &A[i]);
        ++mka[A[i]];
    }
    rep(i,0,N){
        scanf("%lld", &B[i]);
        ++mkb[B[i]];
    }
    rep(i,0,N+1){
        if(N<mka[i]+mkb[i]){
            break;
        }
    }

    if(i<N+1){
        printf("No\n");
        return 0;
    }

    ll a = 0;
    rep(i,0,N){

        while (i+a<N&&A[i + a] <= B[i])
        {
            ++a;
        }
    }
    rep(i,0,N){
        anss[(i + a) % N] = B[i];
    }

    printf("Yes\n");
    rep(i,0,N){
        printf("%lld ", anss[i]);
    }
    return 0;
}

Measured memory_bytes: 11596
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  int N=sqrt(n);
  cout<<N*N<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

using ll = long long;
using Graph = vector<vector<int>>;

vector<bool> seen;
vector<int> gp;

void dfs(const Graph &g, int v, int cnt) {
  seen.at(v) = true;
  gp.at(v) = cnt;
  for(auto next_v:g.at(v)) {
    if(seen.at(next_v))continue;
    dfs(g,next_v, cnt);
  }
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  Graph g(N);
  Graph gg(N);
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    g.at(x-1).push_back(y-1);
    g.at(y-1).push_back(x-1);
  }
  for(int i = 0; i < K; i++) {
    int x, y;
    cin >> x >> y;
    gg.at(x-1).push_back(y-1);
    gg.at(y-1).push_back(x-1);
  }
  seen.assign(N,false);
  gp.assign(N,0);
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(seen.at(i)) continue;
    dfs(g,i,cnt);
    cnt++;
  }
  vector<int> gpnum(N, 0);
  for(int i = 0; i < N; i++) {
    gpnum.at(gp.at(i))++;
  }
  for(int i = 0; i< N; i++) {
    int blcnt=0;
    for(int j:gg.at(i)) {
      if(gp.at(j) == gp.at(i)) blcnt++;
    }
    cout << gpnum.at(gp.at(i))-g.at(i).size() - 1 - blcnt <<" ";
  }
}

Measured memory_bytes: 13056
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int d[105][105];

void warshall_floyd (int V )
{
	rep (k, V ){
		rep (i, V ){
			rep (j, V ){
				d[i][j] = min (d[i][j], d[i][k] + d[k][j] );
			} // end for
		} // end for
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.WPC", "r", stdin );
	int n, m, s, g1, g2;
	while (scanf ("%d %d %d %d %d", &n, &m, &s, &g1, &g2 ) ){
		if (n == 0 ) break;
		s--; g1--; g2--;
		rep (i, n ) rep (j, n ) d[i][j] = (i != j ? INF: 0 );
	
		rep (i, m ){
			int from, to, c;
			scanf ("%d %d %d", &from, &to, &c );
			from--; to--;
			d[from][to] = c;
		} // end rep
		int res = INF;

		warshall_floyd (n );

		rep (i, n ){
			int curr = d[s][i] + d[i][g1] + d[i][g2];
			res = min (res, curr );
		} // end rep

		printf ("%d\n", res );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1224
from itertools import permutations
from sys import exit, stdin
N, M, K = [int(_) for _ in stdin.readline().rstrip().split()]
for i in range(N+1):
    for j in range(M+1):
        if i*M+j*N-2*i*j == K:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 38896
// AtCoder Grand Contest 012
#include <bits/stdc++.h>
using namespace std;

const int N = 300009;

int n, a[N];

int main(){
    scanf("%d", &n);
    for(int i=0; i<3*n; i++){
        scanf("%d", &a[i]);
        a[i] *= -1;
    }

    sort(a,a+3*n);
    long long ans = 0;
    for(int i=1; i<2*n; i+=2)
        ans += -1LL * a[i];

    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;

  string origin_pic[H];
  for(int h = 0; h < H; h++){
    cin >> origin_pic[h];
    //cout << origin_pic[h] << endl;
  }
  //cout << origin_pic[0].at(1) << endl;//b
  //cout << origin_pic[0][1] << endl;//b
  
  
  string ans_pic[H+2][W+2];
  for(int h=0; h<H+2; h++){
    for(int w=0; w<W+2; w++){
      ans_pic[h][w] = '#';
    }
  }
  
  //cout << ans_pic[1].at(2)<<endl;//エラー!!out of range
  //cout << ans_pic[1][2]<<endl;
  //cout << ans_pic[0] << endl;//なぜか空白が出力される
  //ans_pic[1][1] = origin_pic[0].at(0);//aになる
  //ans_pic[1][2] = origin_pic[0][1];//bになる
  
  for(int h=0; h<H; h++){
    for(int w=0; w<W; w++){
      //ans_pic[h+1][w+1] = origin_pic[h][w];//OK!
      ans_pic[h+1][w+1] = origin_pic[h].at(w);//OK!
    }
  }
  
  for(int h = 0; h< H+2 ; h++){
    for(int w = 0 ; w < W+2; w++){
      cout << ans_pic[h][w];
      if(w == W+1) cout << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 896
/**
*/

//スキャナつかうため

import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		String moji = sc.nextLine();
		char [] chmoji = new char [moji.length()];
		for (int i =0; i<moji.length(); i++){
			 chmoji[i]   = moji.charAt(i);
			  boolean kekka = Character.isUpperCase(chmoji[i]);
			 if (kekka == true ){
				 chmoji[i] = Character.toLowerCase(chmoji[i]);
			 }else {
				 chmoji[i] = Character.toUpperCase(chmoji[i]);
			 }
			 System.out.print(chmoji[i]);

		}
		System.out.println();
	}
}

Measured memory_bytes: 17252
<?php
  $rest=fgets(STDIN);
  while($line=fgets(STDIN)){
    $num[]=trim($line);
  }
  foreach($num as $ele2){
    $trinum=explode(" ",$ele2);
    $maxnum=max($trinum);
    $key=array_search($maxnum,$trinum);
    unset($trinum[$key]);
    $sum=0;
    foreach($trinum as $ele){
      $sum+=pow($ele,2);
    }
    /* echo "max:".(int)$maxnum; */
    if($sum==pow((int)$maxnum,2))
      echo "YES\n";
    else
      echo "NO\n";
  }

Measured memory_bytes: 15200
//Volume2-0226
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
		String[] s;
		int[]    r,
		         a;
		int      hit,
		         blow;
		
		//input
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			s = sc.nextLine().split("\\s");
			if(s[0].equals("0") && s[1].equals("0")){
				break;
			}
			r = chg(s[0]);
			a = chg(s[1]);

			//initialize
			hit  = 0;
			blow = 0;
			
			//calculate
			for(int i=0;i<r.length;i++){
				for(int j=0;j<a.length;j++){
					if(r[i] == a[j]){
						if  (i == j){hit++; }
						else        {blow++;}
					}
				}
			}
			
			//output
			System.out.println(hit + " " + blow);
		}
	}

	//A string is changed into an integer array.
	private static int[] chg(String s){
		
		int[]  ret = new int[s.length()];
		for(int i=0;i<s.length();i++){
			ret[i] = Integer.valueOf(s.substring(i, i+1));
		}
		return ret;
	}
}

Measured memory_bytes: 61648
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 2050
#define MOD 998244353
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,ans;char s[MAX];
int f[MAX][MAX],C[MAX][MAX];
int sb[MAX];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i)sb[i]=sb[i-1]+s[i]-48;
	for(int i=0;i<=n;++i)C[i][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=i;++j)
		{
			if(sb[i]-j)add(f[i][j+1],f[i-1][j]);
			if((2*i-sb[i])-(i-1-j))add(f[i][j],f[i-1][j]);
		}
	for(int j=0;j<=n;++j)add(ans,1ll*f[n][j]*C[n][sb[n]-j]%MOD);
	printf("%d\n",ans);
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    vector<int> v(3);

    rep(i, 3)
    {
        cin >> v[i];
    }

    sort(ALL(v));

    cout << v[0] << " " << v[1] << " " << v[2] << endl;

    return 0;
}


Measured memory_bytes: 3116
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  vector<pii> fucktors;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      fucktors.push_back({i, 0});
      while (n % i == 0) {
        n /= i;
        fucktors.back().se++;
      }
    }
  }
  if (n > 1) {
    fucktors.push_back({n , 1});
  }
  vector<int> a;
  for (auto &el : fucktors) {
    a.push_back(el.se);
  }
  vector<int> s;
  for (int sum = 1, i = 2; i <= 50; i++) {
    s.push_back(sum);
    sum += i;
  }
  int ans = 0;
  for (auto &x : a) {
    ans += upper_bound(s.begin(), s.end(), x) - s.begin();
  }
  cout << ans << "\n";
}



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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	int h, w, k;

	cin >> h >> w >> k;

	char c[h][w];

	for(int i = 0; i < h; i++){
		string str;
		cin >> str;

		for(int j = 0; j < (int)str.size(); j++){
			c[i][j] = str[j];
		}
	}

/*	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << c[i][j] << " ";
		}
		cout << endl;
	}
	*/
	int ans = 0;
	for(int i = 0; i < (1 << h); i++){
		for(int j = 0; j < (1 << w); j++){
			int black = 0;
			for(int k = 0; k < h; k++){
				if((i >> k) % 2 == 0){
					continue;
				}
				for(int l = 0; l < w; l++){
					if((j >> l) % 2 == 0){
						continue;
					}
					if(c[k][l] == '#'){
						black++;
					}
				}
			}
			if(black == k){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <numeric>
#include <algorithm>

using namespace std;

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

    for (int i = 0; i <= N / 4; ++i)
    {
        for (int j = 0; j <= N / 7; ++j)
        {
            int p = i * 4 + j * 7;
            if (p == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int n;
multiset<int> S, T;
vector<int> v;

int main() {
    cin >> n;
    REP(i,(1<<n)){
        int s;
        cin >> s;
        S.insert(s);
        v.push_back(s);
    }
    T.insert(*--S.end());
    S.erase(--S.end());
    S.insert(IINF);
    vector<int> tmp;
    REP(i,n){
        tmp.clear();
        for(auto itr = --T.end();;--itr){
            int x = *itr;
            auto y = S.lower_bound(x);
            if(y == S.begin()){
                cout << "No" << endl;
                return 0;
            }
            --y;
            tmp.push_back(*y);
            S.erase(y);
            if(itr == T.begin()) break;
        }
        for(auto x : tmp) T.insert(x);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 14580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int white = 0;
    rep(i, h)rep(j, w){
        if(s[i][j] == '.') white++;
    }

    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<P> que;

    dist[0][0] = 1;
    que.push(make_pair(0, 0));
    while(!que.empty()){
        P v = que.front();
        que.pop();

        int y = v.first;
        int x = v.second;

        rep(i, 4){
            if(y + dy[i] < 0 || y + dy[i] >= h) continue;
            if(x + dx[i] < 0 || x + dx[i] >= w) continue;
            if(dist[y + dy[i]][x + dx[i]] != -1) continue;
            if(s[y + dy[i]][x + dx[i]] == '#') continue;

            dist[y + dy[i]][x + dx[i]] = dist[y][x] + 1;
            que.push(make_pair(y + dy[i], x + dx[i]));
        }
    }

    if(dist[h - 1][w - 1] == -1) cout << -1 << endl;
    else cout << white - dist[h - 1][w - 1] << endl;
}

Measured memory_bytes: 256
n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]

def compare(x, y):
    succeed = False
    for i in range(6):
        match = True
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
                match = False
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        if match:
            if 2 in order:
                succeed = True
                break
            if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:
                succeed = True
                break
            if z[i][3] == 1 and not sum(order) % 2:
                succeed = True
                break
    if succeed:
        return True
    else:
        return False

different = True
for i in range(n):
    for j in range(i+1, n, 1):
        if compare(x[i], x[j]):
            different = False
            break
    if not different:
        break
if different:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7856
A,B,C = map(int,input().split())
K = int(input())

while A >= B and K > 0:
    B = B*2
    K=K-1

while B >= C and K > 0:
    C = C*2
    K=K-1

if A<B and B<C:
    print("Yes")
else:
    print("No")

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


int bubbleSort(int A[], int N) {
	int sw = 0;
	for (int i = 0; i < N; i++){
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				sw++;
			}
		}
	}

	return sw;

}

int main(void) {
	int N, sw;
	int A[100];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sw = bubbleSort(A, N);

	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << sw << endl;

	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int d[k];
  int cnt[n] = {0};
  vector<vector<int>> a(k, vector<int>(n));
  for(int i=0;i<k;i++){
    cin >> d[i];
    for(int j=0;j<d[i];j++){
      cin >> a.at(i).at(j);
      cnt[(a.at(i).at(j))-1]++;	//添え字のずれ修正
    }
  }
  int total=0;
  for(int i=0;i<n;i++){
    if(cnt[i] == 0) total++;
  }
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int h, n, i, sum=0;
	scanf("%d%d", &h, &n);
	int a[n];
	rep(i,n) scanf("%d", &a[i]);
	rep(i,n){
		sum += a[i];
	}
	if(h - sum <= 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

void sayNo(){
    cout<<"0"<<endl;
    return;
}
int main(){

long long  N;
cin>>N;
long long T[N+1],A[N+1];

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

for(int i=1;i<=N;i++){
    cin>>A[i];
}
long long vt[N+1]={};
long long va[N+1]={};
vt[1]=T[1];
va[N]=A[N];
long long ans=1;
if(T[N]!=A[1]){
    cout<<"0"<<endl;
    return 0;
}

for(int i=1;i<N;i++){
    if(T[i]<T[i+1]){
        if(T[i+1]>A[i+1]){
            sayNo();
            return 0;
        }
        vt[i+1]=T[i+1];
    }
}
for(int i=N;i>1;i--){
    if(A[i]<A[i-1]){
        if(A[i-1]>T[i-1]){
            sayNo();
            return 0;
        }
        va[i-1]=A[i-1];
    }
}
for(int i=1;i<=N;i++){
    if(va[i]==0 && vt[i]==0){
        long long t=min(T[i],A[i]);
        if(t>mod){
            t%=mod;
        }
        ans*=t;
        if(ans>mod){
            ans%=mod;
        }
    }
}
/*
for(int i=1;i<=N;i++){
    cout<<v[i]<<" ";
}
cout<<endl;
*/
cout<<ans<<endl;
 return 0;
}
/*
5
1 3 3 3 3
3 3 2 2 2

4


5
1 1 1 2 2
3 2 1 1 1

0


10
1 3776 3776 8848 8848 8848 8848 8848 8848 8848
8848 8848 8848 8848 8848 8848 8848 8848 3776 5

884111967


1
17
17

1

*/

Measured memory_bytes: 3328
s = input()

s_len = len(s)

sum_num = 0
for i in range(1<<(s_len-1), 1<<s_len):
	n, a = 0, 0
	for j in range(s_len):
		if (i>>j)%2 == 0:
			continue
		n += int(s[a:j+1])
		a = j+1
	sum_num += n

print(sum_num)

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }

int main() {
    int N; cin >> N;
    vector<vint> G(N);
    priority_queue<Pi, vector<Pi>, greater<Pi>> pq;
    int mas[100005];
    
    fill_n(mas, 100005, -1);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int K; cin >> K;
    for (int i = 0; i < K; i++) {
        int v, p;
        cin >> v >> p; --v;
        pq.emplace(p, v);
        mas[v] = p;
    }
    
    while (!pq.empty()) {
        auto d = pq.top(); pq.pop();
        for (int &e : G[d.second]) {
            if (mas[e] == -1) {
                mas[e] = d.first + 1;
                pq.emplace(d.first + 1, e);
            } else if (mas[e] != d.first + 1 && mas[e] != d.first - 1) {
                cout << "No" << endl;
                return (0);
            }
        }
    }
    
    cout << "Yes" << endl;
    for (int i = 0; i < N; i++) {
        cout << mas[i] << endl;
    }
    return (0);
}

Measured memory_bytes: 7924
#include <stdio.h>
#include <string.h>

int main(void)
{
    int num[9][9];
    int row[9][10], col[9][10], group[9][10];
    int t;
    int i, j, k;
    
    scanf("%d", &t);
    
    for (i = 0; i < t; i++){
        memset(row, 0, sizeof(row));
        memset(col, 0, sizeof(col));
        memset(group, 0, sizeof(group));
        for (j = 0; j < 9; j++){
            for (k = 0; k < 9; k++){
                scanf("%d", &num[j][k]);
                row[k][num[j][k]]++;
                col[j][num[j][k]]++;
                group[j - j % 3 + k / 3][num[j][k]]++;
            }
        }
        
        if (i > 0){
            printf("\n");
        }
        
        for (j = 0; j < 9; j++){
            for (k = 0; k < 9; k++){
                printf("%c%d", ((row[k][num[j][k]] > 1 || col[j][num[j][k]] > 1 || group[j - j % 3 + k / 3][num[j][k]] > 1) ? '*' : ' '), num[j][k]);
            }
            printf("\n");
        }
    }
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int n; cin >> n;
	ll ans = 0;
	map<int, int> cnt;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		ans += x, cnt[x]++;
	}
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int b, c; cin >> b >> c;
		ans += 1LL * (c - b) * cnt[b];
		cout << ans << "\n";
		cnt[c] += cnt[b], cnt[b] = 0;
	}
}

Measured memory_bytes: 8088
package main

import "fmt"

func main() {

	var a, b int
	fmt.Scan(&a, &b)

	aResult := -1
	bResult := -1
	cResult := -1
	for i := 0; i <= a; i++ {
		for j := 0; j <= a-i; j++ {
			if 10000*i+5000*j+1000*(a-i-j) == b {
				aResult = i
				bResult = j
				cResult = a - i - j
			}
		}
	}
	fmt.Println(aResult, bResult, cResult)
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <=9; j++) {
          out.println(i + "x" + j + "=" + i*j);
        }
      }
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 23920
#include<iostream>
using namespace std;
int main()
{
	int n,i,d;
	string s;
	cin>>n>>s;

	if(n%2!=0)
		cout<<"No"<<endl;
	else
	{
		d = n/2;
		bool ok = true;

		for(i=0;i<d;i++)
		{
			if(s[i]!=s[i+d])
			{
				ok = false;
				break;
			}
		}

		if(ok)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	private static final String LESS_THAN = "<";
	private static final String GREATHER_THAN = ">";
	private static final String EQUALS = "=";

	public static void main(String[] args) {

		Main myself = new Main();
		myself.execute();

	}

	/**
	 * 実処理メソッド
	 */
	public void execute() {

		Scanner sc = new Scanner(System.in);

		final String X = sc.next();
		int x = parse(X);
		final String Y = sc.next();
		int y = parse(Y);

		if (x < y) {
			System.out.println(LESS_THAN);
		} else if (x > y) {
			System.out.println(GREATHER_THAN);
		} else if (x == y) {
			System.out.println(EQUALS);
		}

	}

	private int parse(String str) {

		switch (str) {
		case "A":
			return 10;
		case "B":
			return 11;
		case "C":
			return 12;
		case "D":
			return 13;

		case "E":
			return 14;

		case "F":
			return 15;
		default:
			return -1;

		}
	}

}


Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        long[] NHW = LSRead();
        long N = NHW[0], H = NHW[1], W = NHW[2];
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            long[] box = LSRead();
            if (box[0] >= H && box[1] >= W) ans++;
        }
        Console.WriteLine(ans);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    int x,a,b;
    cin >> x >> a >> b;

    int c = a + x;

    if(b <= a){
        cout << "delicious" << endl;
    }else if(b <= c){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll cnt[n+1];
    fill(cnt,cnt+n+1,0);
    rep(i,1,n+1){
        for(ll j=i;j<=n;j+=i)cnt[j]++;
    }
    ll ans=0;
    rep(i,1,n+1)ans+=i*cnt[i];
    cout<<ans<<endl;
}


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

using lli = long long;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
template <typename T>
using Vector = vector<vector<T>>;
template <typename T>
using Prior = priority_queue<T>;
template <typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define X first
#define Y second
#define Push push_back
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

const lli mod = 1E9 + 7;

void solve() {
	int n;
	cin >> n;
	cout << n * n << "\n";
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>

#define rep(i,n) for(int i = 0; i != n; i++)

using namespace std;

int main(){
	int N,K,X,Y;
	cin >> N >> K >> X >> Y;
	if(N > K)
		cout << K*X + (N-K)*Y << endl;
	else
		cout << N*X << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> num(n);
  for(int i = 0;i < n;i++){
    cin >> num[i];
    num[i]--;
  }
  vector<ll> tele;
  ll now = 0;
  tele.push_back(0);
  map<int,int> count;
  count[0] = 1;
  ll end = 0;
  while(1){
    now = num[now];
    tele.push_back(now);
    count[now]++;
    if(count[now] >= 2){
      tele.erase(tele.begin() + tele.size() - 1);
      break;
    }
  }
  ll begin = 0;
  int size = tele.size();
  for(int i = 0;i < size;i++){
    if(tele[i] == now)begin = (ll)i;
  }
  ll res = 0;
  //for(int i = 0;i < size;i++)cout << tele[i] << " ";
  //cout << endl;
  //cout << begin << endl;
  if(k <= begin - 1){
    res = tele[k];
  }
  else{
    ll syuuki = 0;
    syuuki = tele.size() - begin;
    //cout << "syuuki" << syuuki << endl;
    k -= begin;
    ll memo = 0;
    memo = k % syuuki;
    if(memo == 0)memo = syuuki;
    res = tele[memo + begin];
    //cout << "memo" << memo << endl;
    //cout << "k" << k % syuuki << " " << begin << endl;
  }
  cout << res + 1 << endl;
}

Measured memory_bytes: 15408
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[100100];

int main(){
	cin>>n;
	REP(i,n)
		cin>>a[i];
	
	sort(a,a+n);
	int k=0;
	ll sum=0;
	for(int i=0;i<n-1;i++){
		sum+=a[i];
		if(sum*2<a[i+1]){
			k=i+1;
		}
	}
	cout<<n-k<<endl;
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d;
  cin >> d;
  rep(i,d){
    if(i != 0) cout << endl;
    int n;
    cin >> n;
    vector<vector<char>> v(n,vector<char>(n,' '));
    rep(i,n){
      v[0][i] = '#';
    }
    if(n % 2){
      int cnt = n-1,dir = 1,x = 0,y = 0;
      v[x][y] = '#';
      while(cnt > 0){
        rep(j,2){
          rep(k,cnt){
            x += dx[dir];
            y += dy[dir];
            if(value(x,y,n,n))
                v[x][y] ='#';
          }
          ++dir;
          dir %=4;
        }
        cnt -= 2;
      }
    }
    else{
      int cnt = n-1,dir = 1,x = 0,y = 0;
      while(cnt > 0){
        rep(j,2){
          rep(k,cnt){
            x += dx[dir];
            y += dy[dir];
            if(value(x,y,n,n))
                v[x][y] ='#';
          }
          ++dir;
          dir %= 4;
        }
        cnt -=2;
      }
      v[n/2][n/2] = ' ' ;
    }
    rep(i,n){
      rep(j,n){
        cout << v[j][i];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3088
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
Mod = 1000000007



def main(): #startline-------------------------------------------
    ans = 0
    for i in range(1,int(input())+1):
        if len(str(i)) % 2 == 1:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================




def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Measured memory_bytes: 5424