akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
dx = [1, 1, 0, -1, -1, -1, 0, 1]
dy = [0, 1, 1, 1, 0, -1, -1, -1]

c = 0
for i in range(H):
  if S[i] != "#" * W:
    for j in range(W):
      if S[i][j] == ".":
        S[i][j] = "0"
      else:
        c += 1

if c != H * W:
 for x in range(H):
  for y in range(W):
    if S[x][y] == "#":
      for z in range(8):
        X = x + dx[z]
        Y = y + dy[z]
        if 0 <= X <= H-1  and  0 <= Y <= W-1:
          if S[X][Y] != "#":
            S[X][Y] = str(int(S[X][Y]) + 1)


for i in range(H):
  a = ""
  for j in range(W):
    a += S[i][j]
  print(a)

Measured memory_bytes: 3064
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    from math import gcd
    from collections import defaultdict
    dd = defaultdict(int)
    temp0=0

    for i in range(N):
        a,b=MI()
        if (a,b)==(0,0):
            temp0+=1
            continue
        
        if a<0:
            a*=-1
            b*=-1
        
        #(+,+)と(+,-)だけにする
        if a*b!=0:
            g=gcd(a,b)
            a=a//g
            b=b//g
            if a*b>0:#(+,+)
                dd[(a,b)]+=1
                dd[b,-a]+=0
                
            else:#(+,-)
                dd[(a,b)]+=1
                dd[(-b,a)]+=0
            
        elif (a,b)!=(0,0):
            #assert 0
            if a==0:
                b=1
            else:
                a=1
                
            dd[(a,b)]+=1
            dd[(b,a)]+=0
        

    ans=1
    
    for k,v in dd.items():
        a,b=k
        if b<=0:
            continue
        #( +,+)と(0,1)だけ見る
        
        if a*b!=0:
            v=dd[k]
            v2=dd[(b,-a)]
        else:
            v=dd[k]
            v2=dd[(b,a)]
        temp=pow(2,v,mod)+pow(2,v2,mod)-1
        
        ans=(ans*temp)%mod

    ans=(ans-1+temp0)%mod
    print(ans)
        
        
            
            
    #せんぶ０の組みをひく
        
    

main()


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

using namespace std;

typedef long long ll;

int type_A(int x){
    int ans;
    ans=x*2;
    return ans;
}

int type_B(int x,int k){
    int ans;
    if(x>k)ans=(x-k)*2;
    else ans=(k-x)*2;
    
    return ans;
}

int main() {
    int N,K;cin >> N >> K;
    vector<int>x(N);
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    int sum=0;
    
    for(int s:x){
        if(type_A(s)<type_B(s,K)){
            sum += type_A(s);
        }
        else{
            sum += type_B(s,K);
        }
    }
    
    cout << sum << endl;
    return 0;

}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ab, ans = 0, m = 1000, st = 0, lh = 0, nl;
  cin >> n;
  vector<ll> a;
  // vector<pair<ll, ll>> v;
  queue<pair<ll, ll>> q;
  int s = 0;
  cin >> ab;
  a.push_back(ab);
  rep(i, n - 1) {
    cin >> ab;
    if (ab != a.back()) a.push_back(ab);
  }
  // rep(i, (ll)a.size()) cout << a[i] << " ";
  // cout << endl;

  rep(i, (ll)a.size()) {
    if (i - 1 >= 0 && i + 1 < n && (a[i - 1] - a[i]) * (a[i] - a[i + 1]) < 0) {
      if (a[i - 1] - a[i] < 0)
        s = 1;
      else
        s = -1, lh = max(lh, a[i]);
      q.push(make_pair(s, i));
    }
  }

  int fi, se;
  if (q.size() == 0) {
    if (a[0] - a[1] > 0)
      cout << "1000" << endl;
    else {
      st += m / a[0];
      m -= st * a[0];
      m += st * a[n - 1];
      cout << m << endl;
    }
    return 0;
  }

  if (q.front().first == -1) {
    st = m / a[q.front().second];
    m -= st * a[q.front().second];
    q.pop();
  } else {
    st += m / a[0];
    m -= st * a[0];
  }
  // cout << m << " " << st << endl;

  while (q.size()) {
    fi = q.front().first;
    se = q.front().second;
    q.pop();
    if (fi == 1) {
      m += st * a[se];
      st = 0;
      // cout << m << " " << st << endl;
    } else {
      st = m / a[se];
      m -= st * a[se];
      // cout << m << " " << st << endl;
    }
  }

  m += st * a[a.size() - 1];

  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
     	 Scanner sc = new Scanner(System.in);
      	int n = Integer.parseInt(sc.nextLine());
      	Long num[] = new Long[n];
      	for(int i = 0; i < 9 && i < n; i++)
        {
          	num[i] = (long)(i + 1);
        }
      	int counter = 9;
      	int begin = 0;
      	//boolean judge = true;
      	while( counter < n )
        {
         	 int fixedCounter = counter;
          
          	for(int i = begin; i < fixedCounter && counter < n; i++)
            {
              	int r = (int)(num[i] % 10);
             	 if(r == 0 )
                 {
                   	num[counter] = num[i] * 10;
                   	counter++;
                   	if(counter < n)
                    {
                   		num[counter] = num[i] * 10 + 1;
                   		counter++;
                    }
                 }else if(r == 9){
                   	num[counter] = num[i] * 10 + 8;
                   	counter++;
                   	if(counter < n)
                    {
                   		num[counter] = num[i] * 10 + 9;
                   		counter++;
                    }
                 }else{
                   	
                   	num[counter] = num[i] * 10 + r - 1;
                   	counter++;
                   
                   	if(counter < n)
                    {
                   		num[counter] = num[i] * 10 + r;
                   		counter++;
                    }
                   
                   	if(counter < n)
                    {
                   		num[counter] = num[i] * 10 + r + 1;
                   		counter++;
                    }
                 }
            }
          	begin = fixedCounter;
        }
      
      	System.out.print(num[n - 1]);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    int a,b;
    int cnt = 0;
    cin >> n >> m;
    vector<long long int> v(n);
    vector<int> v1(n,0);
    for(int i=0;i<n;i++) cin >> v[i];
    for(int j=0;j<m;j++){
     cin >> a >> b;
     if(v[a-1]>=v[b-1]) v1[b-1] = 1;
     if(v[b-1]>=v[a-1]) v1[a-1] = 1;
    }
    for(int i=0;i<n;i++){
        if(v1[i] == 0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4580
#include <iostream>
// #include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	long long X;
	cin >> X;

	long long money = 100;
	int times = 0;
	while (money < X)
	{
		money *= 1.01;
		times += 1;
	}
	cout << times << endl;
}


Measured memory_bytes: 3164
/*
*----------------------------------------------
*   Saurabh Srivastava - SAURASS - andha_koder
*----------------------------------------------
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    
    ll mid = 0;
    bool flag = false;
	if(n % 2 == 0) {
		mid = n/2;
	
		for(int i = 0; i < mid; i++) {
			if(s[i] == s[mid + i])
				flag = true;
			else {
				flag = false;
				break;
			}
		}
	}

    if(flag)
		cout << "Yes";
	else
		cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define int lint
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

signed main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, X, D; cin >> N >> X >> D;
  V<> m(N);
  VV<> ch(N);
  for (int i = 0; i < N; ++i) {
    cin >> m[i];
    if (i) {
      int p; cin >> p, --p;
      ch[p].push_back(i);
    }
  }
  V<> v(N);
  auto dfs = [&](const auto& dfs, int i) -> void {
    v[i] = 1;
    for (int j : ch[i]) {
      dfs(dfs, j);
      m[i] += m[j];
      v[i] += v[j];
    }
  };
  dfs(dfs, 0);
  int Y = 0;
  V<> k(N);
  for (int i = 0; i < N; ++i) {
    k[i] = min(N, i ? D : X);
    Y += v[i] * k[i];
  }
  V<> dp(Y + 1, 2e9);
  dp[0] = 0;
  for (int i = 0; i < N; ++i) for (int _ = 0; _ < k[i]; ++_) {
    auto ndp = dp;
    for (int y = 0; y + v[i] <= Y; ++y) ndp[y + v[i]] = min(ndp[y + v[i]], dp[y] + m[i]);
    swap(dp, ndp);
  }
  for (int i = 0; i < N; ++i) k[i] = (i ? D : X) - k[i];
  V<> ord(N);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), [&](int i, int j) { return (lint)v[i] * m[j] > (lint)v[j] * m[i]; });
  int res = 0;
  for (int y = 0; y <= Y; ++y) if (dp[y] <= X) {
    int t = X - dp[y], curr = y;
    for (int i : ord) if (t) {
      int c = min(t / m[i], k[i]);
      t -= c * m[i];
      curr += c * v[i];
    }
    res = max(res, curr);
  }
  cout << res << '\n';
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
long long x[200005];
int main()
{
    int n;
    long long ans;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &x[i]);
        if (i > 0) x[i] += x[i - 1];
    }
    ans = abs(x[n - 1] - x[0] - x[0]);
    for (int i = 1; i < n - 1; i++) {
        ans = min(ans, abs(x[n - 1] - x[i] - x[i]));
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
def main():
    N = int(input())

    def prime_factorize(n):
        res = []
        for i in range(2, n+1):
            if i*i > n:
                break
            if n % i != 0:
                continue
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    divs = prime_factorize(N)
    ans = 0
    for p, e in divs:
        d = p
        for _ in range(e):
            if N % d != 0:
                break
            N //= d
            d *= p
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62900
package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var n int
var az string = "abcdefghijklmnopqrstuvwxyz"
var wr = bufio.NewWriter(os.Stdout)

func dfs(s string, x int) {
	if len(s) == n {
		wr.WriteString(s + "\n")
		return
	}
	for i := 0; i < x+1; i++ {
		dfs(s+az[i:i+1], max(x, i+1))
	}
}

func main() {
	fmt.Scan(&n)

	dfs("", 0)
	wr.Flush()
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n;
    while(cin >> n, n) {
        int cnt[26] = {};
        char c;
        bool ok = false;
        rep(i,0,n) {
            cin >> c;
            // printf("inp: %c\n", c);
            if(ok) continue;
            cnt[c - 'A']++;
            priority_queue<pii> p;
            rep(j,0,26) {
                // printf("cnt[%lld] = %lld\n", j, cnt[j]);
                p.push(pii(cnt[j], j));
            }

            pii first = p.top(); p.pop();
            pii second = p.top(); p.pop();
            // printf("a = %lld, b = %lld, c = %lld\n", first.fr, n-(i+1), second.fr);
            if(first.fr > n-(i+1) + second.fr) {
                printf("%c %lld\n", (char)(first.sc + (char)'A'), i+1);
                ok = true;
            }
        }
        if(!ok) cout << "TIE" << endl;
    }
    return 0;
}

Measured memory_bytes: 3208
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll X;

int main() {
  INCANT;
  cin >> X;
  int idx=0;
  ll tmp = 100; 
  while(tmp<X) {
    tmp*=1.01;
    idx++;
  }
  cout << idx << "\n";
  return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5 + 47;
const LL MAX = 47;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	string s;
	cin >> s;
	FOR(i, 0, SZ(s) - 8)
		cout << s[i];

	cin >> s;
	return 0;
}

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

#define ll long long

int main()
{
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    if(n==1)
    	{
    		cout<<"Yes";
    		return 0;
    	}
    arr[0]--;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]==arr[i+1])
        	continue;
        else if(arr[i]<=arr[i+1])
        	arr[i+1]--;
        else
        {
        	cout<<"No";
        	return 0;
        }
    }
    cout<<"Yes";
} 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000, INF = numeric_limits<int>::max();
char s1[MAXN], s2[MAXN];
int v[MAXN][MAXN], dp[MAXN][MAXN], c1 = 0, c2 = 0;
int main(){
	scanf(" %s", s1 + 1);
	scanf(" %s", s2 + 1);
	int resp = -1;
	for(int i = 1; s1[i] != '\0'; i++)	c1++;
	for(int i = 1; s2[i] != '\0'; i++)	c2++;
	for(int i = 0; i < c1 + 1; i++){
		for(int j = 0; j < c2 + 1; j++){
			if(i == 0 || j == 0)	dp[i][j] = 0;
			else if(s1[i] == s2[j])	dp[i][j] = dp[i - 1][j - 1]	+ 1;
			else	dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			resp = dp[i][j];
		}
	}
	vector <char> p;
	int a = c1, b = c2;
	while(true){
		if(dp[a][b] == 0)	break;
		if(s1[a] == s2[b])	p.push_back(s1[a]), a--, b--;
		else if(dp[a][b - 1] > dp[a - 1][b])	b--;
		else	a--;
	}
	for(int i = p.size() - 1; i >= 0; i--){
		printf("%c",p[i]);
	}
//	printf("%d\n",resp);
}

Measured memory_bytes: 117760
n,m,x,y=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=False
for z in range(x+1,y+1):
  if all([l<z for l in a]) and all([l>=z for l in b]):
    c=True
    break
if c==True:
  print("No War")
else:
  print("War")
    
  


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

const string YES = "Yes";

const string NO = "No";

void solve(int N, int K, vector<int> A)
{
    for (int i = K; i < N; i++)
    {
        cout << ((A.at(i - K) < A.at(i)) ? YES : NO) << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    solve(N, K, move(A));
    return 0;
}


Measured memory_bytes: 4048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
int head,tail;

struct pro{
    char name[12];
    int time;
};

pro Q[1000000];

void enqueue(pro x){
    Q[tail]=x;
    if(tail+1==1000000)tail=0;
    else tail++;
}

pro dequeue(){
    pro deQ=Q[head];
    if(head+1==1000000)head=0;
    else head++;
    return deQ;
}



int main(){
    int n,q,tot=0;
    pro u;
    cin>>n>>q;
    head=1;tail=1;
    pro p;
    for(int i=0;i<n;i++){
        cin>>p.name>>p.time;
        tot+=min(p.time,q);
        if(p.time>q){
            p.time-=q;
            enqueue(p);
        }
        else{
            cout<<p.name<<" "<<tot<<endl;
        }
    }
 /*   for(int i=0;i<40;i++){
        cout<<Q[i].name
        <<" ";
    }
    cout<<head<<tail;*/
    while(head!=tail){
        tot+=min(Q[head].time,q);
        if(Q[head].time>q){
            Q[head].time-=q;
            enqueue(dequeue());
            
        }
        else{
            cout<<dequeue().name<<" "<<tot<<endl;
        }        
        
    }
    
    
}






Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

int solve(int k,vector<int> r,vector<bool> visit,const vector<vector<int>> &dist){
  int N=r.size();
  int ans=1000000000;
  bool flag=false;
  visit.at(k)=true;
  for(int i=0;i<N;i++){
    flag=flag||!visit.at(i);
  }
  if(!flag){
    return 0;
  }

  for(int i=0;i<N;i++){
    if(visit.at(i)){
      continue;
    }
    ans=min(ans,dist.at(k).at(r.at(i))+solve(i,r,visit,dist));
  }
  return ans;
}

int main(){
  int N,M,R;
  cin>>N>>M>>R;
  vector<int> r(R);
  for(int i=0;i<R;i++){
    cin>>r.at(i);
    r.at(i)--;
  }
  vector<vector<pair<int,int>>> G(N);
  for(int i=0;i<M;i++){
    int A,B,C;
    cin>>A>>B>>C;
    A--;
    B--;
    G.at(A).push_back(make_pair(B,C));
    G.at(B).push_back(make_pair(A,C));
  }

  vector<vector<int>> dist(R,vector<int>(N,1000000000));
  for(int i=0;i<R;i++){
    dist.at(i).at(r.at(i))=0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
    pq.push(make_pair(0,r.at(i)));
    while(!pq.empty()){
      int v=pq.top().second;
      for(auto p:G.at(v)){
        int nv=p.first;
        if(dist.at(i).at(v)+p.second<dist.at(i).at(nv)){
          dist.at(i).at(nv)=dist.at(i).at(v)+p.second;
          pq.push(make_pair(dist.at(i).at(nv),nv));
        }
      }
      pq.pop();
    }
  }

  int ans=1000000000;
  vector<bool> visit(R,false);
  for(int i=0;i<R;i++){
    ans=min(ans,solve(i,r,visit,dist));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i,N)cin >> d[i];
    sort(ALL(d));
    UNIQUE(d);
    cout << d.size() << "\n";
}

Measured memory_bytes: 3652
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        l: [usize; 3]
    };

    let mut l = l;
    l.sort();

    println!("{}", l[0] * l[1] / 2);
}


Measured memory_bytes: 2132
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
template <class T> using vec_alias = ::std::vector<T>;

template <template <class> class Container> class union_find {
  protected:
    class node_type;

  public:
    using container_type = Container<node_type>;
    using size_type = typename container_type::size_type;

  protected:
    class node_type {
      public:
        typename union_find::size_type parent;
        typename union_find::size_type size;
    };

    container_type tree;

  public:
    union_find() : tree() {}
    explicit union_find(const size_type size) : tree(size, {0, 1}) {
        for(size_type i = 0; i < size; ++i)
            tree[i].parent = i;
    }

    bool empty() const { return tree.empty(); }
    size_type size() const { return tree.size(); }

    size_type find(size_type x) {
        assert(x < size());
        while(tree[x].parent != x)
            x = tree[x].parent = tree[tree[x].parent].parent;
        return x;
    }
    bool same(const size_type x, const size_type y) {
        assert(x < size());
        assert(y < size());
        return find(x) == find(y);
    }
    size_type size(const size_type x) {
        assert(x < size());
        return tree[find(x)].size;
    }

    ::std::pair<size_type, size_type> unite(size_type x, size_type y) {
        assert(x < size());
        assert(y < size());
        x = find(x);
        y = find(y);
        if(x != y) {
            if(tree[x].size < tree[y].size)
                ::std::swap(x, y);
            tree[x].size += tree[y].size;
            tree[y].parent = x;
        }
        return {x, y};
    }
};

int main() {
    long long N, M;
    cin >> N >> M;
    vector<vector<int>> bridge(M, vector<int>(2));
    vector<long long> res(M);
    union_find<vec_alias> uf(N);
    for(int i = 0; i < M; i++) {
        cin >> bridge.at(i).at(0) >> bridge.at(i).at(1);
    }
    res.at(M - 1) = N * (N - 1) / 2;

    int b1, b2;
    for(int m = M - 1; m >= 1; m--) {
        b1 = bridge.at(m).at(0) - 1;
        b2 = bridge.at(m).at(1) - 1;
        if(uf.same(b1, b2)) {
            res.at(m - 1) = res.at(m);
        } else {
            res.at(m - 1) = res.at(m) - (uf.size(b1) * uf.size(b2));
            uf.unite(b1, b2);
        }
    }

    for(int i = 0; i < M; i++)
        cout << res.at(i) << endl;

    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;


bool seen[55][55];
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin >> H >> W;
  vector<string> field(H);
  REP(h,H) cin >> field[h];
  memset(seen, 0, sizeof(seen));
  
  REP(h,H){
    REP(w,W){
      if(field[h][w]=='.') continue;
      bool flag=true;
      REP(i,4){
        int nh = h+dx[i];
        int nw = w+dy[i];
        if(nh<0 || nw<0 || nh>=H || nw>=W) continue;
        if(field[nh][nw]=='#'){
          flag = false;
          break;
        }
      }
      if(flag){
        cout << "No" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <cstdio>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>
 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const ll INF = 1e7;
const ll MOD = (1e9)+7;
int main(){
	string s;
	cin >> s;
	vector<vector<ll>> nextc('z'-'a'+2, vector<ll>(s.size(), INF)); //nextc['x'-'a'][l] = next_x[l]
	const ll mu = 'z' - 'a' + 1;
	for(ll i=s.size()-1; i>=0; i--){
		nextc[s[i]-'a'][i] = i+1;
		for(char c=s[i]+1-'a';c<='z'-'a'+1;c++){
			if(nextc[c-1][i]<s.size())
				nextc[c][i] = nextc[c-1][nextc[c-1][i]];
		}
 
		for(char c=0; c<s[i]-'a';c++){
			if(nextc[mu][i]<s.size()){
				nextc[c][i] = nextc[c][nextc[mu][i]];
			}
		}
	}
	vector<vector<ll>> nextl(s.size());
	for(ll i=s.size()-1;i>=0;i--){
		ll to = nextc[mu][i];
		ll count=0;
		while(to!=INF){
			nextl[i].push_back(to);
			if(to>=nextl.size() || count>=nextl[to].size())
				break;
			to = nextl[to][count];
			count++;
		}
	}
	ll Q;
	cin >> Q;
	for(ll q=0;q<Q;q++){
		ll l,r;
		cin >> l >> r;
		l--;
		ll to=0;
		while(to+1<nextl[l].size() && nextl[l][to+1]<=r)
			to++;
		if(to<nextl[l].size())
			l=nextl[l][to];
		while(to>0){
			to--;
			if(l<nextl.size() && to<nextl[l].size() && nextl[l][to]<=r)
				l=nextl[l][to];
		}
		if(l==r)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

typedef long long i64;
const int nmax = 1 << 18;

int v[nmax + 1];

pair<int, int> aux[4];

struct str {
    int x, y, vx, vy;

    str () {
        x = y = -1;
        vx = vy = -1 << 30;
    }

    str operator + (const str &shp) const {
        aux[0] = {vx, x};
        aux[1] = {vy, y};
        aux[2] = {shp.vx, shp.x};
        aux[3] = {shp.vy, shp.y};
        sort(aux, aux + 4);

        int f = unique(aux, aux + 4) - aux;

        str ans;
        ans.vx = aux[f - 1].first;
        ans.x = aux[f - 1].second;

        ans.vy = aux[f - 2].first;
        ans.y = aux[f - 2].second;
        return ans;
    }
} d[nmax + 1];

int main() {
    fin.sync_with_stdio(false); fin.tie(); fout.tie();

    int n;
    fin >> n;

    n = 1 << n;
    for (int i = 0; i < n; ++ i) {
        fin >> v[i];
    }

    int ans = -1 << 30;

    for (int i = 0; i < n; ++ i) {
        d[i].x = i;
        d[i].vx = v[i];

        for (int j = 0; (1 << j) < n; ++ j) {
            if (i & (1 << j)) {
                d[i] = d[i] + d[i - (1 << j)];
            }
        }

        ans = max(ans, d[i].vx + d[i].vy);
        if (i > 0)
            fout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 8192
program main
  implicit none
  integer :: i, j, Nmax, Wmax
  integer(16),allocatable,dimension(:) :: v, DP
  integer(16),allocatable,dimension(:) :: w
  read*, Nmax, Wmax
  allocate(v(Nmax), w(Nmax), DP(0:Wmax))

  do i = 1, Nmax
    read*, w(i), v(i)
  enddo

  DP = 0
  do i = 1, Nmax
    do j = Wmax, 0, -1
      if(j >= w(i))then
        DP(j) = max(DP(j - w(i)) + v(i), DP(j))
      endif
    enddo
  enddo
  print*, DP(Wmax)
end program

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

int main()
{
	set<string> s;
	string a;
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>a;
		s.insert(a);
	}
	cout<<s.size();
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    ll int n,k,sum=0;
    cin >> n;
    for (int i=1; i<=n; i++){
        k=n/i;
        sum+=k*(k+1)/2*i;
    }
    cout << sum;
}

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

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    map<int, int> mp;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        mp[a]++;
    }
    if(mp[0]==N){cout<<"Yes"<<endl; return 0;}
    if(mp[0]==0) mp.erase(0);
    if(N%3){cout<<"No"<<endl; return 0;}
    if(mp.size()==2){
        if(mp[0]==N/3){cout<<"Yes"<<endl; return 0;}
        else {cout<<"No"<<endl; return 0;}
    } else if(mp.size()==3){
        bool ok = true;
        int res = 0;
        for(auto p : mp){
            if(p.second!=N/3) ok = false;
            res ^= p.first;
        }
        if(ok and res==0){cout<<"Yes"<<endl; return 0;}
        else {cout<<"No"<<endl; return 0;}
    } else {cout<<"No"<<endl; return 0;}
}

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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int h,w;
  cin>>h>>w;
  int n;
  cin>>n;
  int gyou=0,retu=0,dr=1;
  int ans[h][w];
  rep(i,h)rep(j,w)ans[i][j]=0;
  rep(i,n){
    int t;
    cin>>t;
    while(t>0){
      ans[gyou][retu]=i+1;
      retu+=dr;
      if(retu==w){
        retu=w-1;
        gyou++;
        dr*=-1;
      }
      if(retu==-1){
        retu=0;
        gyou++;
        dr*=-1;
      }
        t--;
    }
  }

  rep(i,h)rep(j,w){
    cout<<ans[i][j]<<' ';
    if(j==w-1)cout<<endl;
  }
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int n,k,h[200000],mn;
int main(){
    cin>>n>>k;
    mn = 1000000000;
    for(int i=1;i<=n;i++)cin>>h[i];
    sort(h+1,h+1+n);

    for(int i=1;i<=n-k+1;i++){
        int dif;
        dif = h[i+k-1] - h[i];
        mn = min(mn,dif);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int a, b, c, k;
// main solution goes here:
void execute(int test_number)
{
    cin>>a>>b>>c>>k;
    int ans = 0;
    while (b<=a) b*=2, ans++;
    while (c<=b) c*=2, ans++;
    if (ans<=k) cout<<"Yes";
    else cout<<"No";
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

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

using namespace std;


int main()
{
  int X;
  double P;
  cin >> X >> P;
  if(P == 100) cout << (X + 1) / 2 << endl;
  else cout << fixed << setprecision(10) << (X + 1) / 2 / P * 100.0 << endl;
}

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

const int N = 100001;
int a[N] = {};
int n, m;

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1, a+n+1);
	int ans = 0;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			for (int k=j+1;k<=n;k++) {
//				cout<<a[k]<<' '<<a[i]+a[j]<<endl;
				if (a[k] < a[i] + a[j]) ans ++;
					else break;
				}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
int calc(float,float,float,float,float,float);

int main(){
  int i;
  float cl[6];
  for(i=0;i<6;i++){
    scanf("%f",&cl[i]);
    /*
    if((i != 2) || (i != 5)){
      if(fabsf (cl[i]) >= 1000.0) return -1;
    }else{
      if(cl[i] < 1.0 || cl[i] > 1000.0) return -2;
    }
    */
  }
  printf("%d\n",calc(cl[0],cl[1],cl[2],cl[3],cl[4],cl[5]));
  return 0;
}

int calc(float c1x,float c1y,float c1r,float c2x,float c2y,float c2r){
  float oto = sqrtf(powf(c1x-c2x,2)+powf(c1y-c2y,2));
  float rtr = c1r + c2r;
  float rir = fabsf(c1r - c2r);
  int f = -1;
  if(oto < rir) f = 0;
  if(oto == rir) f = 1;
  if(rir < oto && oto < rtr) f = 2;
  if(oto == rtr) f = 3;
  if(oto > rtr) f = 4;
  return f;
}



Measured memory_bytes: 2148
#include<iostream>

int main() {
	int n,m,a[100][100],b[100],i,j,tmp;

	for (i = 0; i < 100; i++) {
		for (j = 0; j < 100; j++) {
			a[i][j] = 0;
			b[i] = 0;
		}
	}

	std::cin >> n>>m;
			
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			std::cin >> a[i][j];
		}
	}
	for (j = 0; j < m; j++) {
		std::cin >> b[j];
	}

	for (i = 0; i < n; i++) {
		tmp = 0;
		for (j = 0; j < m; j++) {
			tmp += a[i][j] * b[j];
		}
		std::cout << tmp <<std::endl;
	}


		return 0;
}


Measured memory_bytes: 3156
pub fn multiplication2(numbers: &[i64]) -> i64 {
    fn f(a: i64, numbers: &[i64]) -> i64 {
        if numbers.len() == 0 {
            return a;
        }
        match a.checked_mul(numbers[0]) {
            Some(v) => {
                if v > i64::pow(10, 18) {
                    -1
                } else {
                    f(v, &numbers[1..])
                }
            }
            None => -1,
        }
    }
    if numbers.contains(&0i64) {
        return 0;
    }
    f(1, numbers)
}

fn readline<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readline_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    readline::<i32>();
    println!("{}", multiplication2(readline_vec::<i64>().as_slice()));
}


Measured memory_bytes: 4820
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
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);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 100000;
    ll N, M, A[MAX_N + 1] = {}, S[MAX_N + 1];
    map<ll, ll> mp;
    cin >> N >> M;
    FOR(i, 1, N + 1, 1) {
        cin >> A[i];
        S[i] = S[i - 1] + A[i];
        mp[S[i] % M]++;
    }
    ll res = mp[0];
    for (auto x : mp) {
        if (x.second >= 2) {
            res += x.second * (x.second - 1) / 2;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main() {
    unsigned n {}, m {};
    cin >> n >> m;

    vector<string> arr (n, "1");
    vector<size_t> wa_cnt (n, 0);
    size_t penalty {}, correct {};

    while (m--) {
        size_t ind {};
        cin >> ind;

        string ver {};
        cin >> ver;

        if (ver == "WA") {
            if (arr.at(ind-1) != "AC") {
                arr.at(ind-1) = "WA";
                ++wa_cnt.at(ind-1);
            }
        }
        else if (ver == "AC") {
            if (arr.at(ind-1) == "WA") {
                arr.at(ind-1) = "AC";
                penalty += wa_cnt.at(ind-1);
                ++correct;
            }
            else if (arr.at(ind-1) == "1") {
                arr.at(ind-1) = "AC";
                ++correct;
            }
        }
    }
    cout<<correct<<" "<<penalty<<endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  vi p(n);
  REP(i,n)cin >> p[i];

  sort(ALL(p));

  int diff = INF;
  int ans;

  REP(i,102){
    bool ok=true;
    REP(j,n){
      if(i==p[j])ok=false;
    }
    if(ok==false)continue;

    if(diff > abs(x - i)){
      diff = abs(x - i);
      ans = i;
    }
  }

  PRINT(ans);
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
#define MAXN   1000005
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
int getFactorization(int x) 
{ 
    map<int,int> ret;
    while (x != 1) 
    { 
        ret[spf[x]]++;
        x = x / spf[x]; 
    } 
    int res = 1;
    for(auto x : ret)
    {
        res*=(x.ss+1);
    }

    return res;

} 
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    sieve();
    int ans(0);
    
    for(int i = 1 ; i < n ; i++)
    {
        ans+=(getFactorization(n-i));
    }
    cout<<ans;

    printclock;
    return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll k, n = 50; cin >> k;

    VL a(n);
    FOR(i, 0, n)a[i] = i + k / n;
    FOR(i, 0, k % n)FOR(j, 0, n) {
        if (i == j)a[j] += 50LL;
        else --a[j];
    }

    cout << n << "\n";
    FOR(i, 0, n)cout << a[i] << ENDL(i, n);
}

Measured memory_bytes: 256
import random
from collections import  Counter
def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range (0,k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

x=int(input())
while(1):
    if is_prime3(x):
        print(x)
        exit()
    else:
        x+=1

Measured memory_bytes: 4592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      br.lines()
        .map(Integer::valueOf)
        .sorted(Comparator.reverseOrder())
        .limit(3)
        .forEach(System.out::println);
    }
  }
}


Measured memory_bytes: 30848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private final static String NEGATIVE = "NO\n";
	private final static String AFFIRMATIVE = "YES\n";

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 512);
		int number = Integer.parseInt(br.readLine());//行数
		int sides[] = new int[3];
		StringTokenizer tknz;
		StringBuilder builder = new StringBuilder();

		for (; 0 < number; number--) {
			tknz = new StringTokenizer(br.readLine());
			for (int i = 0; i < 3; i++) {
				sides[i] = Integer.parseInt(tknz.nextToken());
			}
			Arrays.sort(sides);
			if (sides[0] * sides[1] * sides[2] % 60 != 0) {
				builder.append(NEGATIVE);
			} else if (Math.pow(sides[0], 2) + Math.pow(sides[1], 2) != Math.pow(sides[2], 2)) {
				builder.append(NEGATIVE);
			} else {
				builder.append(AFFIRMATIVE);
			}
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 18360