akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef pair<int, int> pii;
const int INF = 1e9;

int dy[4] = {0,1,0,-1};
int dx[4] = {1,0,-1,0};

int main() {
	int h, w;
	cin >> h >> w;
	int si, sj;
	cin >> si >> sj;
	si--, sj--;
	int ti, tj;
	cin >> ti >> tj;
	ti--, tj--;
	vector<string> g(h);
	rep(i,h) cin >> g[i];

	deque<pii> q;
	vector<vector<int>> dist(h,vector<int>(w,INF));
	q.push_back(pii(si,sj));
	dist[si][sj] = 0;
	while (!q.empty()) {
		auto p = q.front(); q.pop_front();
		int i = p.first;
		int j = p.second;
		rep(d,4) {
			int ni = i + dy[d];
			int nj = j + dx[d];
			if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
			if (g[ni][nj] == '#') continue;
			if (dist[ni][nj] <= dist[i][j]) continue;
			dist[ni][nj] = dist[i][j];
			q.push_front(pii(ni,nj));
		}
		for (int di = -2; di <= 2; di++) {
			for (int dj = -2; dj <= 2; dj++) {
				int ni = i + di;
				int nj = j + dj;
				if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
				if (g[ni][nj] == '#') continue;
				if (dist[ni][nj] <= dist[i][j] + 1) continue;
				dist[ni][nj] = dist[i][j] + 1;
				q.push_back(pii(ni,nj));
			}
		}
	}

	if (dist[ti][tj] == INF) cout << -1 << endl;
	else cout << dist[ti][tj] << endl;
}

Measured memory_bytes: 9472
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    s = input().rstrip()
    ans = [s[0]]
    now = s[0]
    for i in s[1:]:
        if i != now:
            ans.append(i)
            now = i
    print(len(ans))

if __name__=="__main__":
    main()


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

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //-----------------------------------------
    ll N, K;
    cin >> N >> K;

    ll cnt=0;
    while(N>0)
    {
        N/=K;
        ++cnt;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int solve(int three, int five, int seven, long int val, long int N, int len) {
    if (len == 0) return val <= N ? 1 : 0;
    int score = 0;
    if (three > 0) score += solve(three - 1, five, seven, val * 10 + 3, N, len - 1);
    if (five > 0) score += solve(three, five - 1, seven, val * 10 + 5, N, len - 1);
    if (seven > 0) score += solve(three, five, seven - 1, val * 10 + 7, N, len - 1);
    return score;
}

int main() {
    long int N;
    scanf("%ld", &N);
    int score = 0;
    for (int t = 1; t <= 7; t++) {
        for (int f = 1; t + f <= 8; f++) {
            for (int s = 1; t + f + s <= 9; s++) {
                score += solve(t, f, s, 0, N, t + f + s);
            }
        }
    }
    printf("%d\n", score);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int d;cin>>d;
  int n=s.size();
  vector<vector<int>> dp(d,vector<int>(n+1,0));
  int sup=0;
  rep1(i,n){
      rep(j,d){
          rep(k,10){
              dp[(j+k)%d][i]+=dp[j][i-1];
              dp[(j+k)%d][i]%=MOD;
          }
      }
      int num=s[i-1]-'0';
      for(int j=0;j<num;++j){
          dp[(sup+j)%d][i]+=1;
          dp[(sup+j)%d][i]%=MOD;
      }
      sup+=num;
      sup%=d;
  }
  if(sup==0){
      dp[0][n]+=1;
      dp[0][n]%=MOD;
  }
  rep(j,0){
      printf("j = %lld, ",j);
      rep1(i,n){
          cout<<dp[j][i]<<" ";
      }
      cout<<endl;
  }
  cout<<(dp[0][n]+MOD-1)%MOD<<"\n";
  return 0;
}

Measured memory_bytes: 9728
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int L = NextInt();
        int min = INF;
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            int b = L + i;
            sum += b;
            if (Math.Abs(min) > Math.Abs(b)) min = b;
        }
        Console.WriteLine(sum - min);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
import heapq
N,K = map(int,input().split())
Hlist = list(map(int,input().split()))
for i in range(len(Hlist)):
    Hlist[i] *= -1
heapq.heapify(Hlist)
for _ in range(min(K,N)):
    heapq.heappop(Hlist)
print(-sum(Hlist))

Measured memory_bytes: 31668
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
#include <bits/stdc++.h>

struct UnionFind {
  private:
	std::vector<int> rank, par, col;
	int n_;

  public:
	UnionFind(int n) : n_(n) {
		rank.resize(n, 1);
		par.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
		}
		col.resize(n, 1);
	}
	int root(int i) {
		while (par[i] != i) {
			i = par[i];
		}
		return i;
	}
	bool isSame(int x, int y) { return root(x) == root(y); }
	void unite(int x, int y) {
		if (isSame(x, y)) return;
		x = root(x), y = root(y);
		if (rank[x] < rank[y]) {
			par[x] = y;
			col[y] += col[x];
		} else {
			if (rank[x] == rank[y]) rank[x]++;
			par[y] = x;
			col[x] += col[y];
		}
	}
	int cnt(int x) {
		x = root(x);
		return col[x];
	}
};

int main() {
	IOS();
	ll a, b, c;
	cin >> a >> b >> c;
	dump(min(c, b / a));
}

Measured memory_bytes: 256
#include<stdio.h>
#define SIZE 100000

int main(){
    char x[SIZE];
    int i=0;
    double sum=0;

    while(1){
        fgets(x,SIZE,stdin);
        if(atoi(x)==0){
         break;
        }
        for(i=0;x[i]!='\n';i++)
            sum+=x[i]-'0';
        printf("%.f\n",sum);sum=0;
    }

 return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S, T;
  cin >> S >> T;

  ll N = S.size();

  vll S_set(30, 0), T_set(30, 0);

  REP(i, N){
    S_set[S[i]-'a']++;
    T_set[T[i]-'a']++;
  }

  sort(S_set.begin(), S_set.end());
  sort(T_set.begin(), T_set.end());

  REP(i, 30){
    if(S_set[i] != T_set[i]){
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  return 0;

  return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string s;
	cin >> s;
	string t = "";
	vector<int> v;
	int now = 0;
	rep(i,s.size()){
		if(s[i] == 'x')now ++;
		else {
			v.pb(now);
			now = 0;
			t += s[i];
		}
	}
	v.pb(now);
	
	rep(i,t.size()){
		if(t[i] != t[t.size()-1-i]){
			puts("-1");
			return 0;
		}
	}
	
	int ret = 0;
	rep(i,v.size()){
		ret += max(v[i],v[v.size()-1-i])-min(v[i],v[v.size()-1-i]);
	}
	cout << ret/2 << endl;
}



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

int main() {
   char s[101],k[20];
   int i,j,n;

   scanf("%s",s);
   for (i=0;s[i]!='\0';i++) 
      if (s[i]!='1') break;
   scanf("%s",k);
   if (strlen(k)>3)
      printf("%c\n",s[i]);
   else {
      sscanf(k,"%d",&n);
      if (i>=n) printf("1\n");
      else      printf("%c\n",s[i]);
    }
    return 0;
}

Measured memory_bytes: 128
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int stoi (string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}


// 配列の総和
// greater



int main(){
	/*
	ll A;
    cin >> A;
	cout << "hello" << endl;
	cout << stoi("14") << endl;
	*/
	ll s, ans=0;
	cin >> s;
	while(s>1){
		ans++;
		if (s%2==0)s>>=1;
		else s = s*3+1;
		
	}
	ans += 2;
	chmax(ans, 4);
	cout << ans << endl;


}








Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
long long p = 1000000007;
int n;
long long inv[200005];
long long kinv[200005];
long long kai[200005];
long long ans[200005];
using namespace std;
long long rui(long long rui_a, long long rui_b) {
	if (rui_b == 0)return 1;
	if (rui_b == 1)return rui_a % p;
	long long rui_c;
	rui_c = rui(rui_a, rui_b / 2);
	rui_c = rui_c * rui_c % p;
	if (rui_b % 2) {
		return rui_c * rui_a % p;
	}
	return rui_c;
}
void makeinv(void) {
	long long arraynumber = sizeof inv / sizeof inv[0];
	inv[1] = 1;
	for (int invcount = 2; invcount < arraynumber; invcount++) {
		inv[invcount] = p - inv[p % invcount] * (p / invcount) % p;
	}
}
struct vertex {
	vector<long long>way;
};
vertex v[200000];
long long cn[200000];
long long cdp[200000];
long long pn[200000];
long long pdp[200000];
void dfs(long long now, long long pa) {
	//(primary,-1)
	long long nt = 0;
	long long dt = 1;
	if (v[now].way.size() == 1 && v[now].way[0] == pa) {
		cn[now] = 1;
		cdp[now] = 1;
		return;
	}
	for (int i = v[now].way.size() - 1; i >= 0; i--) {
		if (v[now].way[i] != pa) {
			dfs(v[now].way[i], now);
			dt *= kinv[cn[v[now].way[i]]];
			dt %= p;
			dt *= cdp[v[now].way[i]];
			dt %= p;
			nt += cn[v[now].way[i]];
		}
	}
	dt *= kai[nt];
	dt %= p;
	cdp[now] = dt;
	cn[now] = nt + 1;
}
void xdfs(long long now, long long pa) {
	//(primary,-1)
	long long dt = 1;
	long long nt = 0;
	if (pa != -1) {
		pn[now] = pn[pa] + cn[pa] - cn[now];
		pdp[now] = cdp[pa];
		pdp[now] *= kinv[cn[pa] - 1];
		pdp[now] %= p;
		pdp[now] *= kai[cn[pa] - 1 - cn[now] + pn[pa]];
		pdp[now] %= p;
		pdp[now] *= kai[cn[now]];
		pdp[now] %= p;
		pdp[now] *= kinv[pn[pa]];
		pdp[now] %= p;
		pdp[now] *= rui(cdp[now], p - 2);
		pdp[now] %= p;
		pdp[now] *= pdp[pa];
		pdp[now] %= p;
		dt = pdp[now];
		nt = pn[now];
		dt *= kinv[nt];
		dt %= p;
	}
	for (int i = v[now].way.size() - 1; i >= 0; i--) {
		if (v[now].way[i] != pa) {
			xdfs(v[now].way[i], now);
			dt *= cdp[v[now].way[i]];
			dt %= p;
			nt += cn[v[now].way[i]];
			dt *= kinv[cn[v[now].way[i]]];
			dt %= p;
		}
	}
	dt *= kai[nt];
	dt %= p;
	ans[now] = dt;
}
void makegraph(void) {
	long long inx, iny;
	scanf("%lld %lld", &inx, &iny);
	inx--; iny--;
	v[inx].way.push_back(iny);
	v[iny].way.push_back(inx);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		makegraph();
	}
	makeinv();
	kinv[0] = 1; kai[0] = 1;
	for (int i = 1; i < 200005; i++) {
		kai[i] = kai[i - 1] * i;
		kai[i] %= p;
		kinv[i] = kinv[i - 1] * inv[i];
		kinv[i] %= p;
	}
	dfs(0, -1);
	pdp[0] = 1;
	pn[0] = 0;
	xdfs(0, -1);
	for (int i = 0; i < n; i++) {
		printf("%lld\n", ans[i]);
	}
}

Measured memory_bytes: 27120
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

struct unionfind{
  private:
  int maxN;
  vector<int> par,treesize;
  public:unionfind(int N) :maxN(N),par(N),treesize(N,1){
    for(int i=0;i<maxN;++i)par[i]=i;
  }
  int root(int x){
    while(par[x]!=x){
      x=par[x]=par[par[x]];
    }
    return x;
  }
  bool unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return false;
    if(treesize[x]>treesize[y])swap(x,y);
    par[x]=y;
    treesize[y]+=treesize[x];
    return true;
  }
  bool parcheck(int x,int y){
    return root(x)==root(y);
  }
  int size(int x){
    return treesize[root(x)];
  }
  void clear(){
    treesize.assign(maxN,1);
    for(int i=0;i<maxN;++i)par[i]=i;
  }
};

int main(){
  startupcpp();
  ll i,N,M,cnt=0,ans=0;
  cin>>N>>M;
  vector<int> a(M),b(M);
  map<int,int> mp;
  rep(i,M){
    cin>>a[i]>>b[i];
    mp[a[i]]+=mp[b[i]];
  }
  for(auto& x:mp)x.second=cnt++;
  ans=N*N-cnt*cnt;
  N=cnt;
  unionfind ut(N*2);
  rep(i,M){
    a[i]=mp[a[i]];
    b[i]=mp[b[i]];
    ut.unite(a[i],b[i]+N);
    ut.unite(a[i]+N,b[i]);
  }
  mp.clear();
  rep(i,N){
    mp[ut.root(i)]|=ut.parcheck(i,i+N);
  }
  cnt=0;
  for(auto& x:mp)cnt+=!x.second;
  print(ans+(mp.size()-cnt/2)*(mp.size()-cnt/2)+cnt*cnt/4);
}

Measured memory_bytes: 7936
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


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


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);

  int N=n;
  int sum=0;

  while(n>0){
    sum+=n%10;
    n/=10;
  }

  if(N%sum==0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector <long long>A(N);
    for(int i=0 ; i<N ; i++){
        cin>>A[i];
    }
	
	queue <long long> q;
	sort(A.begin(),A.end());
	long long a,b;
	for(int i=0 ; i<N ; i++){
		if(A[i]==A[i+1]){
			q.push(A[i]);
			i++;
		}
		if(q.size()==3)q.pop();
	}
	if(q.size()==2){
		a=q.front();
		q.pop();
		b=q.front();
		cout<<a*b<<endl;
	}
	else cout<<0<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1e9;

int main() {

    int n;
    cin>>n;
    int h[n+1];
    for (int i=1; i<=n; i++){
    	cin>>h[i];
    }
    vector<int> dp(n+1, INF);
    
    dp[1]=0;
    for (int i=1; i<=n;i++){
    	for (int j=1; j<=2; j++){
    		if (i+j<=n){
    			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j]-h[i]));	
    		}
    	}
    }
    cout<<dp[n];
}

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

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

	if (n % 2 == 1) {
		cout << 0;
		return 0;
	}

	long long d = 10;
	long long s = 0;
	while (d <= n) {
		s += n / d;
		d *= 5;
	}

	cout << s;
	
	return 0;
}
	

Measured memory_bytes: 256
s = str(input())
t = str(input())
index = []
n = len(s)
m = len(t)
if n>=m:
    for i in range(n-m+1):
        isFittable = True
        for j in range(m):
            if not (s[i+j]==t[j] or s[i+j]=="?"):
                isFittable = False
                break
        if isFittable:
            index.append(i)
ans = ""
if len(index)>0:
    i = index[-1]
    for j in range(n):
        if j<i or j>=i+m:
            if s[j]=="?":
                ans += "a"
            else:
                ans += s[j]
        else:
            ans += t[j-i]
    print(ans)
else:
    print("UNRESTORABLE")
        

Measured memory_bytes: 3064
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for j in range(h):
        for i in range(w):
            if (i+j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) throws IOException {
		//For Reader
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		//Save Array and Hashmap
		ArrayList<HashMap<String, String>> alHmConvertCodeList = new ArrayList<HashMap<String, String>>();
		ArrayList<String> alDefaultString = new ArrayList<String>();
		ArrayList<StringBuffer> alConvertedStrBuff = new ArrayList<StringBuffer>();

		while(true) {

			int countOfRead = Integer.parseInt(bufferedReader.readLine());

			if (countOfRead == 0) break;

			HashMap<String, String> hmConvetCode = new HashMap<String, String>();

			for(int i = 0; i < countOfRead; i++) {
				String[] arrConvertCode = bufferedReader.readLine().split(" ");

				hmConvetCode.put(arrConvertCode[0], arrConvertCode[1]);
			}

			alHmConvertCodeList.add(hmConvetCode);

			int defaultStringLength = Integer.parseInt(bufferedReader.readLine());
			StringBuffer defaultStringBuff = new StringBuffer();

			for(int i = 0; i < defaultStringLength; i++) defaultStringBuff.append(bufferedReader.readLine());
			alDefaultString.add(defaultStringBuff.toString());
		}

		for(int i = 0; i < alDefaultString.size(); i++) {
			StringBuffer convertedStrBuff = new StringBuffer();
			String defaultStr = alDefaultString.get(i);

			for(int j = 0; j < defaultStr.length(); j++) {
				char charAt = defaultStr.charAt(j);
				String charStr = convetCharToString(charAt);
				String convertedCharAt = alHmConvertCodeList.get(i).get(charStr) == null ?
												charStr : alHmConvertCodeList.get(i).get(charStr);
				convertedStrBuff.append(convertedCharAt);
			}

			alConvertedStrBuff.add(convertedStrBuff);
		}

		for(int i = 0; i < alConvertedStrBuff.size(); i++) System.out.println(alConvertedStrBuff.get(i).toString());

	}

	private static String convetCharToString(char charStr) {
		return String.valueOf(charStr);
	}
}



Measured memory_bytes: 42568
#include <stdio.h>
int main(void){
    int a[3];
    int sum=0;
    for(int i = 0;i<3;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
    }
    if (sum>=22){
        printf("bust");
    }else{
        printf("win");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e4 + 5;
const ll mod = 1e9 + 7;
int n;	
int a[maxn] , f[maxn * 100] , p[maxn * 100];
bool nprime[maxn * 100];
int cnt = 0;
void init(int t) {
	nprime[1] = 1;
	for(register int i = 2; i <= t; ++i) {
		if(!nprime[i]) p[++cnt] = i;
		for(register int j = 1; i * p[j] <= t; ++j) {
			nprime[i * p[j]] = 1;
			if(i % p[j] == 0) break;
		}
	}
}
inline ll fpow(int x , int k) {
	ll ret = 1 , base = x;
	while(k) {
		if(k & 1) ret = ret * base % mod;
		base = base * base % mod;
		k >>= 1;
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	int mx = 0;
	for(register int i = 1; i <= n; ++i) {
		cin >> a[i];
		mx = max(mx , a[i]);
	}
	init(mx);
	for(register int i = 1; i <= n; ++i) {
		int tmp = a[i] , count;
		if(tmp != 1) {
			for(register int j = 1; j <= cnt; ++j) {
				if(tmp == 1 || !nprime[tmp]) break;
				count = 0;
				while(tmp % p[j] == 0) count++ , tmp /= p[j];
				f[p[j]] = max(f[p[j]] , count);
			}
			if(!nprime[tmp])
				f[tmp] = max(f[tmp] , 1);
		}
	}
	ll l = 1 , ans = 0;
	for(register int i = 1; i <= cnt; ++i)
		l = l * fpow(p[i] , f[p[i]]) % mod;
	for(register int i = 1; i <= n; ++i)
		ans = (ans + l * fpow(a[i] , mod - 2) % mod) % mod;
	cout << ans << endl;
	return 0;
}

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

int main() {
    
    string s1, s2;
    long long len, cnt=0;
    cin >> s1 >> s2;
    len = s1.length();
    for(int i=0; i<len; i++){
        if(s1[i] != s2[i]) ++cnt;
    }
    if(cnt>0) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    
    
	return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s>>t;
  ll ans=0,n=s.length();
  rep(i,n) if(s[i]!=t[i]) ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 3884
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var n = Read();
        var x = Reads();
        long a = 0;
        long a1 = 0;
        double aa = 0;
        long m = 0;
        for (int j = 0; j < n; j++)
        {
            a += x[j];
        }
        a1 = a / n;
        aa =(double) a / n;
        if (aa - a1 >= 0.5)
            m = a1 + 1;
        else
            m = a1;
        long ans = 0;
        for(int i = 0; i < n; i++)
        {
            ans += (x[i] - m) * (x[i] - m);
        }
        Console.WriteLine(ans);
        Console.Out.Flush();
    }
}




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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;
typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main()
{IOS
ll mod=1e9+7;
int t,k;
cin>>t>>k;
int a[t];
for(int i=0;i<t;++i) cin>>a[i];
int dp[t];
memset(dp,0,sizeof(dp));

dp[0]=0;
dp[1]=abs(a[1]-a[0]);
for(int i=2;i<t;++i)
{ int cost=1000000005;
    for(int j=1;j<=k;++j)
    {
        if((i-j)<0) continue;
        else
        {
            cost=min(cost,abs(a[i]-a[i-j])+dp[i-j]);
        }
    }
    dp[i]=cost;
    //cout<<dp[i]<<" ";
}
cout<<dp[t-1];
}

Measured memory_bytes: 1024
#include<stdio.h>

int prime[250000]={},num[1000000]={};
int main(void){
	int a,d,n,i,j,k=0,l,count;
	prime[k++]=2;
	prime[k++]=3;

	for(i=5;i<1000000;i+=2){
		int flag=0;
		for(j=0;i>=prime[j]*prime[j];j++){
			if(i%prime[j]==0){
				flag=1;
				break;
			}
		}
		if(flag==0){prime[k++]=i;}
	}

	
	
	for(i=0;i<k;i++){
		l=prime[i];
		num[l]=1;
	}
	
	while(1){
		count=0;
		scanf("%d %d %d",&a,&d,&n);
		if(a==0&&d==0&&n==0)break;
		for(i=a;count!=n;i+=d){
			count+=num[i];
		}
		printf("%d\n",i-d);
	}
	return 0;
}

Measured memory_bytes: 4808
#include <stdio.h>
#include <stdlib.h>
int main(){
    int n,i,j;
    int *A,*B;
    int C[10001];
    
    scanf("%d",&n);
    
    A=malloc(sizeof(int)*n);
    B=malloc(sizeof(int)*n);
    
    for(i=0;i<10001;i++){
        C[i]=0;
    }
    
    for(i=0;i<n;i++){
        scanf("%d",&A[i+1]);
        C[A[i+1]]++;
    }
    for(i=1;i<10001;i++){
        C[i]+=C[i-1];
    }
    for ( j = 1; j <= n; j++ ){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for ( i = 1; i <= n; i++ ){
        if(i>1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    int X;
    cin >> X;
    for(int i = X; true; i++){
        for(int j = 2; j * j <= i; j++){
            if(i % j == 0){
                goto next;
            }
        }
        cout << i << endl;
        return 0;
    next:;
    }
}



Measured memory_bytes: 256
import collections

n, m = map(int, input().split())
k = []
for i in range(n):
    a = list(map(int, input().split()))
    k.extend(a[1:])
ans = 0
c = collections.Counter(k)
for i in range(1, m + 1):
    if c[i] >= n:
        ans += 1
print(ans)


Measured memory_bytes: 3316
H, W = map(int, input().split())
A = [[] for i in range(H)]
check1 = 0
check2 = 1
now = [0, 0]
flag = True

for i in range(H):
    A[i] = input()
    check1 += A[i].count('#')
    
for iii in range(30000):
    lim = 0
    for dy, dx in [1, 0], [0, 1]:
        lim += 1
        if now[0] + dy <= H-1 and now[1] + dx <= W-1:
            if A[now[0] + dy][now[1] + dx] == '#':
                check2 += 1
                now[0] += dy
                now[1] += dx
                break
                
        if lim == 2:
            break
                
if check2 == check1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
string s;
ll d;
ll dp[10005][105][2];

ll solve(ll pos,ll sum,bool tight){
	if(pos==s.size())return sum==0;
	if(dp[pos][sum][tight]!=-1)
		return dp[pos][sum][tight];
	ll ans=0;
	ll end=((tight)?(s[pos]-'0'):9);
	for(ll i=0;i<=end;i++){
		ans=(ans+solve(pos+1,(sum+i)%d,tight&(i==end)))%mod;
	}
	return dp[pos][sum][tight]=ans;
}

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

	cin>>s>>d;
	memset(dp,-1,sizeof(dp));
	cout<<(solve(0,0,1)-1+mod)%mod<<endl;
	return 0;
}

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

int main() {
    string t;;
    cin >> t;
    int n = t.length();
    for(int i = 0; i < n; i++){
        if(t[i] == '?'){
            if(i-1 >= 0 and t[i-1] == 'P'){
                t[i] = 'D';
            }
            else if(i-1 >= 0 and t[i-1] == 'D'){
                if((i+1 < n and t[i+1] == 'P') or (i+1 == n))t[i] = 'D';
                else t[i] = 'P';
            }
            else if(i==0){
                if(i+1 == n)t[i] = 'D';
                else if(t[i+1] == 'P') t[i] = 'D';
                else t[i] = 'P';
            }
        }
    }
    cout << t << "\n";
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    std::deque<char> tmp(n,'\0');
    int sum=0;
    for (int i=0;i<n;i++) {
        if (i<k) {
            if (t[i]=='r') {
                sum+=p;
                tmp[i]='p';
            } else if (t[i]=='s') {
                sum+=r;
                tmp[i]='r';
            } else {
                sum+=s;
                tmp[i]='s';
            }
        } else {
            if (t[i]=='r'&&tmp[i-k]=='p') {
                if (i+k<n) {
                    if (t[i+k]=='r') {
                        tmp[i]='s';
                    } else if (t[i+k]=='p') {
                        tmp[i]='r';
                    } else if (t[i+k]=='s') {
                        tmp[i]='s';
                    }
                } else {
                    tmp[i]='s';
                }
            } else if (t[i]=='s'&&tmp[i-k]=='r') {
                if (i+k<n) {
                    if (t[i+k]=='r') {
                        tmp[i]='s';
                    } else if (t[i+k]=='p') {
                        tmp[i]='p';
                    } else if (t[i+k]=='s') {
                        tmp[i]='p';
                    }
                } else {
                    tmp[i]='p';
                }
            } else if (t[i]=='p'&&tmp[i-k]=='s') {
                if (i+k<n) {
                    if (t[i+k]=='r') {
                        tmp[i]='r';
                    } else if (t[i+k]=='p') {
                        tmp[i]='r';
                    } else if (t[i+k]=='s') {
                        tmp[i]='p';
                    }
                } else {
                    tmp[i]='r';
                }
            } else {
                if (t[i]=='r') {
                    sum+=p;
                    tmp[i]='p';
                } else if (t[i]=='s') {
                    sum+=r;
                    tmp[i]='r';
                } else {
                    sum+=s;
                    tmp[i]='s';
                }
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <double, int> P; typedef vector <int> vecint;
const int INF = 2000000000;
const double EPS = 10e-9;
int main()
{
	char a, b; cin >> a >> b;
	if (a == b) cout << "=" << endl;
	else if (a > b) cout << ">" << endl;
	else cout << "<" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys 
from collections import Counter
from math import factorial

def combinations_count(n, r):
  return factorial(n) // (factorial(n - r) * factorial(r))
 
def main():
  input = sys.stdin.readline
  N = int(input())
  texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]
  c = Counter(texts)
  cnt = 0
  for t in c.values():
    if t > 1:
      cnt += combinations_count(t, 2)
  print(cnt)
 
if __name__ == '__main__':
  main()


Measured memory_bytes: 19844
#include<bits/stdc++.h>
 
// @author : sam000013
 
#define int long long
 
#define PI 3.14159265
#define pb(x) push_back(x)
#define all(v) v.begin(), v.end()
#define endl cout<<"\n" 
#define dbg(x) cout<<#x<<" "<<x;endl;
#define bye endl;return
#define uni 1.000000
using namespace std;

const int mod = 1000000007;
template <typename T>

void debug(vector<T> x)
{
    for (auto e : x)
    {
        cout << e << " ";
    }
    cout << "\n";
}
/*


*/


vector<int> divisors(int n){
    
    vector<int> divs;
    for(int i=1; i*i<=n; ++i){
        
        if(n%i==0){
            divs.pb(i);
        }
        if((n/i)!=i){
            divs.pb(n/i);
        }
    }
    return divs;
    
}
void solve(){
    int n;
    cin>>n;
    int ans = 0;
    vector<int> v(n+1, 1);
    vector<bool> marked(n+1);
    bool found = false;
    int cur = 2;
    while(cur <= n){
        for(int i=cur; i<= n; i+= cur){
            v[i]++;
        }
        cur++;
    }
    for(int c=1; c<n; c++){
        int x = n-c;
        if(x <= 1)
            ans += x;
        else{
            ans += v[x];
        }
    }

    cout<<ans;endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //    cin >> t;
    for (int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11288
n=int(input())
ti=input().split(' ')
times=[]
for i in ti:
    times.append(int(i))
summ=sum(times)
nu=int(input())
for i in range(0,nu):
    inps=input().split(' ')
    tempsum=summ
    tempsum=tempsum-times[int(inps[0])-1]
    tempsum+=int(inps[1])
    print(tempsum)

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n)cin >> numbers[i];
    vector<ll> numbers2 = numbers;
    sort(numbers2.begin(), numbers2.end());

    ll under = numbers2[n / 2 - 1],
            over = numbers2[n / 2];

    for (ll a : numbers) {
        if (a <= under) {
            cout << over << endl;
        } else {
            cout << under << endl;
        }
    }

}



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

using namespace std;
const int N = 1010;
int _w;

int n, vis[N];
char s[N];

int main() {
	cin >> s;
	n = (int)strlen(s);
	for( int i = 0; i < n; ++i )
		vis[s[i]] = 1;
	bool c1 = vis['N'] == vis['S'];
	bool c2 = vis['E'] == vis['W'];
	puts( c1 && c2 ? "Yes" : "No" );
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


int main(void) {
  ll N;
  cin >> N;
  ll a[MAX];
  ll i;
  
  priority_queue<P> q;
  for(i=0; i<N; i++) {
    cin >> a[i];
  }
  
  ll clr=0;
  vector<ll> v;
  v.push_back(a[N-1]);
  for(i=N-2; i>=0; i--) {
    ll len=v.size();
    
    if(v[len-1]<=a[i]) {
      v.push_back(a[i]);
    }else {
      ll itr=upper_bound(v.begin(), v.end(), a[i])-v.begin();
      v[itr]=a[i];
    }
    
  }
  
  pt(v.size());
  
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=a;i>=b;--i)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i != (int)(s.size())-1) cout << " ";
  }
  cout << "\n";
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n; cin >> n;
  ll l = 0, r = n;
  while(r - l > 1) {
    ll mid = (l + r) / 2;
    if(mid < 1) {
      l = mid;
      continue;
    }
    ll tmpn = n;
    vll now;
    RFOR(i, mid, 1) {
      if(tmpn >= i) {
        tmpn -= i;
      }
    }
    if(tmpn == 0) {
      r = mid;
    }
    else l = mid;
  }

  ll tmpn = n;
  vll ans;
  RFOR(i, r, 1) {
    if(tmpn >= i) {
      ans.push_back(i);
      tmpn -= i;
    }
  }
  REP(i, SZ(ans)) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        if((A*B)%2==1||(A*B*3)%2==1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using ll = long long; using vi = vector<int>; using vll = vector<ll>;
using vvi = vector<vi>; using vvll = vector<vll>;
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll INF_MAX = numeric_limits<ll>::max();

int f(int x) {
  if (x % 2) return 3 * x + 1;
  else return x / 2;
}

int main() {
  int a;
  cin >> a;
  int i = 1;
  unordered_set<int> an;
  while (an.find(a) == an.end()) {
    an.insert(a);
    a = f(a);
    ++i;
  }
  cout << i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[100];
	int c,b;
	cin>>c>>b;
	cin>>a;
	if(a[c]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=1;i<c+b+1;i++){
		if((a[i]!='0')&&(i!=c)&&(a[i]!='1')&&(a[i]!='2')&&(a[i]!='3')&&(a[i]!='4')&&(a[i]!='5')&&(a[i]!='6')&&(a[i]!='7')&&(a[i]!='8')&&(a[i]!='9')){
		cout<<"No"<<endl;
		return 0;
		}
	}
	cout<<"Yes"<<endl;;
}

Measured memory_bytes: 256
try:
    N = int(input())
    Li = [int(x) for x in input().split()]
    Li = sorted(Li, reverse=True)
    if N < 3 or N > 10:
        exit()
    for x in Li:
        if x < 1 or x > 100:
            exit()
    if N is not len(Li):
        exit()
    maxL = Li[0]
    a = 0

    for i in range(1, N):
        a += Li[i]
    if maxL < a:
        print("Yes")
    elif maxL >= a:
        print("No")
except ValueError:
    exit()
    

Measured memory_bytes: 3064